At 68/agent overview update javascript client repo#432
At 68/agent overview update javascript client repo#432dmitrycnstrc wants to merge 5 commits intoConstructor-io:masterfrom
Conversation
There was a problem hiding this comment.
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 newConstructorIOclient module, extendingAgentand adding SSE event types (MESSAGE, FOLLOW_UP_QUESTIONS). - Extends
AgentURL/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.
src/modules/agent.js
Outdated
| * @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 |
There was a problem hiding this comment.
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").
src/modules/agent.js
Outdated
| * @param {number} [parameters.numResultsPerPage] - The total number of results to return | ||
| * @deprecated Use numResultsPerEvent instead |
There was a problem hiding this comment.
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).
| * @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. |
src/modules/agent-overview.js
Outdated
| * @param {object} [parameters] - Additional parameters to refine result set | ||
| * @param {string} parameters.domain - Domain name (e.g. "recipes", "recipes") |
There was a problem hiding this comment.
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").
| * @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") |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
| queryParams.qs = typeof qs === 'string' ? qs : JSON.stringify(qs); | |
| queryParams.qs = JSON.stringify(qs); |
| queryParams.pre_filter_expression = typeof preFilterExpression === 'string' | ||
| ? preFilterExpression | ||
| : JSON.stringify(preFilterExpression); | ||
| } | ||
|
|
||
| // Pull fmt_options from parameters |
There was a problem hiding this comment.
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.
| 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 |
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