Skip to content

At 68/agent overview update javascript client repo#432

Open
dmitrycnstrc wants to merge 5 commits intoConstructor-io:masterfrom
dmitrycnstrc:AT-68/agent-overview-update-javascript-client-repo
Open

At 68/agent overview update javascript client repo#432
dmitrycnstrc wants to merge 5 commits intoConstructor-io:masterfrom
dmitrycnstrc:AT-68/agent-overview-update-javascript-client-repo

Conversation

@dmitrycnstrc
Copy link
Contributor

Added a new AgentOverview module that extends Agent with two additional SSE event types: MESSAGE and FOLLOW_UP_QUESTIONS. It exposes a getIntentResults method as a public API for streaming intent-based overview responses.

Also extended the Agent module with new query parameters: threadId, guard, numResultsPerEvent, numResultEvents, qs, preFilterExpression, and fmtOptions - aligning the client with the current backend API. Marked numResultsPerPage as deprecated in favor of numResultsPerEvent

@dmitrycnstrc dmitrycnstrc marked this pull request as ready for review February 27, 2026 14:02
Copilot AI review requested due to automatic review settings February 27, 2026 14:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an AgentOverview module alongside the existing Agent module to support streaming “overview” intent responses with additional SSE event types, and extends the Agent request parameters to match the backend API.

Changes:

  • Introduces agentOverview (runtime + types) as a new ConstructorIO client module, extending Agent and adding SSE event types (MESSAGE, FOLLOW_UP_QUESTIONS).
  • Extends Agent URL/query parameter support (e.g., threadId, guard, numResultsPerEvent, numResultEvents, qs, preFilterExpression, fmtOptions) and updates tests accordingly.
  • Updates TypeScript declarations and README to expose the new module.

Reviewed changes

Copilot reviewed 7 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/types/tests/agent-overview.test-d.ts Adds tsd coverage for new/extended IAgentParameters fields.
src/types/index.d.ts Re-exports agent-overview typings from the root type entry.
src/types/constructorio.d.ts Adds agentOverview property and namespace export for typing.
src/types/agent.d.ts Extends IAgentParameters with new query parameters and updates stream method signature.
src/types/agent-overview.d.ts Adds TS declaration for AgentOverview module extending Agent.
src/modules/agent.js Extends URL building with new query params; ensures subclass event types are used for listener setup.
src/modules/agent-overview.js Adds new AgentOverview module with extended event types and getIntentResults API.
src/constructorio.js Instantiates and exposes agentOverview on the client.
spec/src/modules/agent.js Adds unit tests for new Agent query parameters.
spec/src/modules/agent-overview.js Adds tests for new module event types and streaming behavior.
README.md Updates module list to include agentOverview.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 184 to 186
* @param {object} [parameters] - Additional parameters to refine result set
* @param {string} [parameters.domain] - domain name e.g. swimming sports gear, groceries
* @param {string} parameters.domain - Domain name (e.g. "recipes", "recipes")
* @param {string} [parameters.threadId] - Conversation thread ID for multi-turn dialogue
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDoc marks parameters as optional ([parameters]), but createAgentUrl / getAgentResultsStream will throw if parameters (and parameters.domain) is missing. The docs should reflect that parameters is required, and the domain example currently repeats the same value ("recipes", "recipes").

Copilot uses AI. Check for mistakes.
Comment on lines 190 to 191
* @param {number} [parameters.numResultsPerPage] - The total number of results to return
* @deprecated Use numResultsPerEvent instead
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standalone @deprecated tag inside getAgentResultsStream JSDoc will mark the entire method as deprecated in generated docs/IDE hints. If only parameters.numResultsPerPage is deprecated, move the note into that parameter’s description (or otherwise avoid using the @deprecated tag here).

Suggested change
* @param {number} [parameters.numResultsPerPage] - The total number of results to return
* @deprecated Use numResultsPerEvent instead
* @param {number} [parameters.numResultsPerPage] - The total number of results to return. Deprecated: use numResultsPerEvent instead.

Copilot uses AI. Check for mistakes.
Comment on lines 24 to 25
* @param {object} [parameters] - Additional parameters to refine result set
* @param {string} parameters.domain - Domain name (e.g. "recipes", "recipes")
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDoc marks parameters as optional ([parameters]), but the underlying getAgentResultsStream implementation requires parameters.domain and throws when it’s missing. The docs should mark parameters as required, and the domain example currently repeats the same value ("recipes", "recipes").

Suggested change
* @param {object} [parameters] - Additional parameters to refine result set
* @param {string} parameters.domain - Domain name (e.g. "recipes", "recipes")
* @param {object} parameters - Additional parameters to refine result set
* @param {string} parameters.domain - Domain name (e.g. "recipes", "fashion")

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Pull qs from parameters
if (qs) {
queryParams.qs = typeof qs === 'string' ? qs : JSON.stringify(qs);
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional handling of qs parameter (checking if it's a string) is inconsistent with other modules (autocomplete, browse, search) which always use JSON.stringify regardless of type. Consider either always JSON.stringify'ing qs like other modules, or document why agent requires different handling.

Suggested change
queryParams.qs = typeof qs === 'string' ? qs : JSON.stringify(qs);
queryParams.qs = JSON.stringify(qs);

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +106
queryParams.pre_filter_expression = typeof preFilterExpression === 'string'
? preFilterExpression
: JSON.stringify(preFilterExpression);
}

// Pull fmt_options from parameters
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional handling of preFilterExpression (checking if it's a string) is inconsistent with other modules (autocomplete, browse, search, recommendations) which always use JSON.stringify regardless of type. Consider either always JSON.stringify'ing preFilterExpression like other modules, or document why agent requires different handling.

Suggested change
queryParams.pre_filter_expression = typeof preFilterExpression === 'string'
? preFilterExpression
: JSON.stringify(preFilterExpression);
}
// Pull fmt_options from parameters
queryParams.pre_filter_expression = JSON.stringify(preFilterExpression);
}
// Pull fmt_options from parameters
// Pull fmt_options from parameters

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants