@paymanai/payman-typescript-ask-sdk 4.0.4 → 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -150,7 +150,8 @@ type MessageDisplay = {
150
150
  totalElapsedMs?: number;
151
151
  };
152
152
  type SessionParams = {
153
- id?: string;
153
+ /** Session owner ID sent to the ask API as `sessionOwnerId`. */
154
+ id: string;
154
155
  name?: string;
155
156
  attributes?: Record<string, string>;
156
157
  };
@@ -171,14 +172,14 @@ type ChatConfig = {
171
172
  api: APIConfig;
172
173
  /** Agent ID to run against the k2 playground endpoint */
173
174
  agentId: string;
174
- /** User ID for chatStore and activeStreamStore — required for context store messages management. Set to undefined on logout to clear stored messages. */
175
+ /** User ID for local chatStore and activeStreamStore only. This is not sent to the ask API. */
175
176
  userId?: string;
176
177
  /** Stage/Environment */
177
178
  stage?: AgentStage;
178
179
  /** Query param name for stage (default: "stage"). */
179
180
  stageQueryParam?: string;
180
- /** Session params */
181
- sessionParams?: SessionParams;
181
+ /** Session owner params sent with ask requests. */
182
+ sessionParams: SessionParams;
182
183
  /** Custom placeholder text */
183
184
  placeholder?: string;
184
185
  /** Empty state text */
package/dist/index.d.ts CHANGED
@@ -150,7 +150,8 @@ type MessageDisplay = {
150
150
  totalElapsedMs?: number;
151
151
  };
152
152
  type SessionParams = {
153
- id?: string;
153
+ /** Session owner ID sent to the ask API as `sessionOwnerId`. */
154
+ id: string;
154
155
  name?: string;
155
156
  attributes?: Record<string, string>;
156
157
  };
@@ -171,14 +172,14 @@ type ChatConfig = {
171
172
  api: APIConfig;
172
173
  /** Agent ID to run against the k2 playground endpoint */
173
174
  agentId: string;
174
- /** User ID for chatStore and activeStreamStore — required for context store messages management. Set to undefined on logout to clear stored messages. */
175
+ /** User ID for local chatStore and activeStreamStore only. This is not sent to the ask API. */
175
176
  userId?: string;
176
177
  /** Stage/Environment */
177
178
  stage?: AgentStage;
178
179
  /** Query param name for stage (default: "stage"). */
179
180
  stageQueryParam?: string;
180
- /** Session params */
181
- sessionParams?: SessionParams;
181
+ /** Session owner params sent with ask requests. */
182
+ sessionParams: SessionParams;
182
183
  /** Custom placeholder text */
183
184
  placeholder?: string;
184
185
  /** Empty state text */
package/dist/index.js CHANGED
@@ -954,11 +954,16 @@ function createCancelledMessageUpdate(steps, currentMessage) {
954
954
  var DEFAULT_STREAM_ENDPOINT = "/api/playground/ask/stream";
955
955
  function buildRequestBody(config, userMessage, sessionId, options) {
956
956
  const sessionOwner = config.sessionParams;
957
+ const sessionOwnerId = sessionOwner?.id?.trim();
958
+ if (!sessionOwnerId) {
959
+ throw new Error("ChatConfig.sessionParams.id is required to send ask requests.");
960
+ }
957
961
  const sessionAttributes = sessionOwner?.attributes && Object.keys(sessionOwner.attributes).length > 0 ? sessionOwner.attributes : void 0;
958
962
  return {
959
963
  agentId: config.agentId,
960
964
  userInput: userMessage,
961
965
  sessionId,
966
+ sessionOwnerId,
962
967
  sessionOwnerLabel: sessionOwner?.name || void 0,
963
968
  sessionAttributes,
964
969
  analysisMode: options?.analysisMode
@@ -1176,16 +1181,16 @@ function useStreamManagerV2(config, callbacks, setMessages, setIsWaitingForRespo
1176
1181
  )
1177
1182
  );
1178
1183
  };
1179
- const currentConfig = configRef.current;
1180
- const requestBody = buildRequestBody(
1181
- currentConfig,
1182
- userMessage,
1183
- sessionId,
1184
- options
1185
- );
1186
- const url = buildStreamingUrl(currentConfig);
1187
- const headers = buildRequestHeaders(currentConfig);
1188
1184
  try {
1185
+ const currentConfig = configRef.current;
1186
+ const requestBody = buildRequestBody(
1187
+ currentConfig,
1188
+ userMessage,
1189
+ sessionId,
1190
+ options
1191
+ );
1192
+ const url = buildStreamingUrl(currentConfig);
1193
+ const headers = buildRequestHeaders(currentConfig);
1189
1194
  await streamWorkflowEvents(url, requestBody, headers, {
1190
1195
  signal: abortController.signal,
1191
1196
  onEvent: (event) => {