@superatomai/sdk-node 0.0.70-dsp → 0.0.71-dsp

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
@@ -1909,6 +1909,32 @@ declare const IncomingMessageSchema: z.ZodObject<{
1909
1909
  payload?: unknown;
1910
1910
  }>;
1911
1911
  type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
1912
+ /**
1913
+ * A file attached to a question. Synced with sdk-web: PromptAttachmentSchema.
1914
+ *
1915
+ * The file itself is in R2 (uploaded through sa-api's /upload/chat-attachment
1916
+ * routes); the message carries only its reference. The host backend fetches it
1917
+ * with /upload/chat-attachment/signed-get.
1918
+ */
1919
+ declare const PromptAttachmentSchema: z.ZodObject<{
1920
+ /** The R2 object key. */
1921
+ key: z.ZodString;
1922
+ fileName: z.ZodString;
1923
+ /** Size in bytes. */
1924
+ size: z.ZodNumber;
1925
+ contentType: z.ZodOptional<z.ZodString>;
1926
+ }, "strip", z.ZodTypeAny, {
1927
+ key: string;
1928
+ fileName: string;
1929
+ size: number;
1930
+ contentType?: string | undefined;
1931
+ }, {
1932
+ key: string;
1933
+ fileName: string;
1934
+ size: number;
1935
+ contentType?: string | undefined;
1936
+ }>;
1937
+ type PromptAttachment = z.infer<typeof PromptAttachmentSchema>;
1912
1938
  declare const ComponentSchema: z.ZodObject<{
1913
1939
  id: z.ZodString;
1914
1940
  name: z.ZodString;
@@ -2172,6 +2198,8 @@ interface AnswerProviderContext {
2172
2198
  signal?: AbortSignal;
2173
2199
  /** Where the question was asked from, when the client said. */
2174
2200
  context?: PromptContext;
2201
+ /** Files attached to this question (R2 references). Absent when none. */
2202
+ attachments?: PromptAttachment[];
2175
2203
  }
2176
2204
  /**
2177
2205
  * One narrator tick while an answer was being produced: what the narrator was
@@ -6628,4 +6656,4 @@ declare class SuperatomSDK {
6628
6656
  getConversationSimilarityThreshold(): number;
6629
6657
  }
6630
6658
 
6631
- export { ALL_COLUMN_KEYS, ANSWER_COMPONENT_NAMES, type AgentConfig, type AgentEvent, type AgentResponse, type AgentRunContext, type AgentRunHandlers, type AgentRunRecord, type AgentRunResult, type AgentTrigger, type AgentUsage, type AnalyticsEventType, type AnalyticsStatus, type AnswerProvider, type AnswerProviderContext, type ApplySummary, BM25L, type BM25LOptions, type BaseLLMConfig, type BuildTriggerInput, CATEGORY_KEYS, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CodexSessionOptions, type CodingAgentCollectionConfig, type CodingAgentDefinition, type CodingAgentSession, type CodingAgentSessionOptions, type CodingAgentsConfig, type ColInfo, type ColType, type CollectionHandler, type CollectionOperation, type Component, type DBUIBlock, DEFAULT_AGENT_CONFIG, DEFAULT_FMT_CONFIG, type DashboardAgentCollectionConfig, type DatabaseType, type FindingCode, type Fmt, type FmtConfig, type Harness, type HybridSearchOptions, INSTRUCTIONS_FILE, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, type McpServerSpec, type Message, MissingRequestContextError, type ModelStrategy, NUMERIC_KEYS, type NarrationUpdate, type OutputContract, type OutputField, type OutputValidator, type PiSessionListener, type PiSessionState, type PiTranscriptEntry, type Principal, type PromptContext, type RequestContext, type RerankedResult, type RowFilter, type RunAgentOptions, STORAGE_CONFIG, type ScriptComponentSpec, ScriptMatcher, type ScriptParameter, type ScriptRecipe, type ScriptRecipeMetaRow, type ScriptRecipeStore, type ScriptResult, ScriptStore, type ScriptStoreOptions, type SelectedWorkflow, type ShimDef, type ShimSummary, type ShimTarget, type SourcePolicy, type SpecToValidate, SuperatomSDK, type SuperatomSDKConfig, type T_RESPONSE, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, type TriggerEvent, type TriggerFireInfo, UIBlock, UILogCollector, type User, UserManager, type UsersData, type ValidationContext, type ValidationFinding, type WorkflowDescriptor, type Workspace, analyticsClient, answerCatalogForBinding, answerComponents, anthropicLLM, assertReadOnlySql, bindContext, bridgePreamble, captureContext, clearContextTokens, contextTokenCount, createCodexSession, createCodingAgentSession, dashboardConversationHistory, dataFingerprint, describeContext, describeTriggers, emitAgentEvent, extractNamedExport, formatFindingsForAgent, geminiLLM, getCodingAgent, getCodingAgentsConfig, getPiSessionState, getRequestContext, groqLLM, hybridRerank, inferColumns, isUserContext, listCodingAgents, llmUsageLogger, logger, makeFmt, mintContextToken, normalizeScriptBody, onAgentRun, onPiSessionUpdate, openaiLLM, policiesFromConfig, projectForDatasetBinding, promptLoader, queryCache, registerCodingAgentCollection, registerCodingAgents, registerDashboardAgentCollection, requireRequestContext, rerankChromaResults, rerankConversationResults, resolveContextToken, resolveScriptRecipeStore, revokeContextToken, runAsSystem, runAsUser, runCodingAgent, runScript, runWithContext, runWithMessageIdentity, startAgentTriggers, stopAgentTriggers, userPromptErrorLogger, validateComponentSpec, withCapturedContext, writeBridgeShims, writeShims };
6659
+ export { ALL_COLUMN_KEYS, ANSWER_COMPONENT_NAMES, type AgentConfig, type AgentEvent, type AgentResponse, type AgentRunContext, type AgentRunHandlers, type AgentRunRecord, type AgentRunResult, type AgentTrigger, type AgentUsage, type AnalyticsEventType, type AnalyticsStatus, type AnswerProvider, type AnswerProviderContext, type ApplySummary, BM25L, type BM25LOptions, type BaseLLMConfig, type BuildTriggerInput, CATEGORY_KEYS, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CodexSessionOptions, type CodingAgentCollectionConfig, type CodingAgentDefinition, type CodingAgentSession, type CodingAgentSessionOptions, type CodingAgentsConfig, type ColInfo, type ColType, type CollectionHandler, type CollectionOperation, type Component, type DBUIBlock, DEFAULT_AGENT_CONFIG, DEFAULT_FMT_CONFIG, type DashboardAgentCollectionConfig, type DatabaseType, type FindingCode, type Fmt, type FmtConfig, type Harness, type HybridSearchOptions, INSTRUCTIONS_FILE, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, type McpServerSpec, type Message, MissingRequestContextError, type ModelStrategy, NUMERIC_KEYS, type NarrationUpdate, type OutputContract, type OutputField, type OutputValidator, type PiSessionListener, type PiSessionState, type PiTranscriptEntry, type Principal, type PromptAttachment, type PromptContext, type RequestContext, type RerankedResult, type RowFilter, type RunAgentOptions, STORAGE_CONFIG, type ScriptComponentSpec, ScriptMatcher, type ScriptParameter, type ScriptRecipe, type ScriptRecipeMetaRow, type ScriptRecipeStore, type ScriptResult, ScriptStore, type ScriptStoreOptions, type SelectedWorkflow, type ShimDef, type ShimSummary, type ShimTarget, type SourcePolicy, type SpecToValidate, SuperatomSDK, type SuperatomSDKConfig, type T_RESPONSE, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, type TriggerEvent, type TriggerFireInfo, UIBlock, UILogCollector, type User, UserManager, type UsersData, type ValidationContext, type ValidationFinding, type WorkflowDescriptor, type Workspace, analyticsClient, answerCatalogForBinding, answerComponents, anthropicLLM, assertReadOnlySql, bindContext, bridgePreamble, captureContext, clearContextTokens, contextTokenCount, createCodexSession, createCodingAgentSession, dashboardConversationHistory, dataFingerprint, describeContext, describeTriggers, emitAgentEvent, extractNamedExport, formatFindingsForAgent, geminiLLM, getCodingAgent, getCodingAgentsConfig, getPiSessionState, getRequestContext, groqLLM, hybridRerank, inferColumns, isUserContext, listCodingAgents, llmUsageLogger, logger, makeFmt, mintContextToken, normalizeScriptBody, onAgentRun, onPiSessionUpdate, openaiLLM, policiesFromConfig, projectForDatasetBinding, promptLoader, queryCache, registerCodingAgentCollection, registerCodingAgents, registerDashboardAgentCollection, requireRequestContext, rerankChromaResults, rerankConversationResults, resolveContextToken, resolveScriptRecipeStore, revokeContextToken, runAsSystem, runAsUser, runCodingAgent, runScript, runWithContext, runWithMessageIdentity, startAgentTriggers, stopAgentTriggers, userPromptErrorLogger, validateComponentSpec, withCapturedContext, writeBridgeShims, writeShims };
package/dist/index.d.ts CHANGED
@@ -1909,6 +1909,32 @@ declare const IncomingMessageSchema: z.ZodObject<{
1909
1909
  payload?: unknown;
1910
1910
  }>;
1911
1911
  type IncomingMessage = z.infer<typeof IncomingMessageSchema>;
1912
+ /**
1913
+ * A file attached to a question. Synced with sdk-web: PromptAttachmentSchema.
1914
+ *
1915
+ * The file itself is in R2 (uploaded through sa-api's /upload/chat-attachment
1916
+ * routes); the message carries only its reference. The host backend fetches it
1917
+ * with /upload/chat-attachment/signed-get.
1918
+ */
1919
+ declare const PromptAttachmentSchema: z.ZodObject<{
1920
+ /** The R2 object key. */
1921
+ key: z.ZodString;
1922
+ fileName: z.ZodString;
1923
+ /** Size in bytes. */
1924
+ size: z.ZodNumber;
1925
+ contentType: z.ZodOptional<z.ZodString>;
1926
+ }, "strip", z.ZodTypeAny, {
1927
+ key: string;
1928
+ fileName: string;
1929
+ size: number;
1930
+ contentType?: string | undefined;
1931
+ }, {
1932
+ key: string;
1933
+ fileName: string;
1934
+ size: number;
1935
+ contentType?: string | undefined;
1936
+ }>;
1937
+ type PromptAttachment = z.infer<typeof PromptAttachmentSchema>;
1912
1938
  declare const ComponentSchema: z.ZodObject<{
1913
1939
  id: z.ZodString;
1914
1940
  name: z.ZodString;
@@ -2172,6 +2198,8 @@ interface AnswerProviderContext {
2172
2198
  signal?: AbortSignal;
2173
2199
  /** Where the question was asked from, when the client said. */
2174
2200
  context?: PromptContext;
2201
+ /** Files attached to this question (R2 references). Absent when none. */
2202
+ attachments?: PromptAttachment[];
2175
2203
  }
2176
2204
  /**
2177
2205
  * One narrator tick while an answer was being produced: what the narrator was
@@ -6628,4 +6656,4 @@ declare class SuperatomSDK {
6628
6656
  getConversationSimilarityThreshold(): number;
6629
6657
  }
6630
6658
 
6631
- export { ALL_COLUMN_KEYS, ANSWER_COMPONENT_NAMES, type AgentConfig, type AgentEvent, type AgentResponse, type AgentRunContext, type AgentRunHandlers, type AgentRunRecord, type AgentRunResult, type AgentTrigger, type AgentUsage, type AnalyticsEventType, type AnalyticsStatus, type AnswerProvider, type AnswerProviderContext, type ApplySummary, BM25L, type BM25LOptions, type BaseLLMConfig, type BuildTriggerInput, CATEGORY_KEYS, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CodexSessionOptions, type CodingAgentCollectionConfig, type CodingAgentDefinition, type CodingAgentSession, type CodingAgentSessionOptions, type CodingAgentsConfig, type ColInfo, type ColType, type CollectionHandler, type CollectionOperation, type Component, type DBUIBlock, DEFAULT_AGENT_CONFIG, DEFAULT_FMT_CONFIG, type DashboardAgentCollectionConfig, type DatabaseType, type FindingCode, type Fmt, type FmtConfig, type Harness, type HybridSearchOptions, INSTRUCTIONS_FILE, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, type McpServerSpec, type Message, MissingRequestContextError, type ModelStrategy, NUMERIC_KEYS, type NarrationUpdate, type OutputContract, type OutputField, type OutputValidator, type PiSessionListener, type PiSessionState, type PiTranscriptEntry, type Principal, type PromptContext, type RequestContext, type RerankedResult, type RowFilter, type RunAgentOptions, STORAGE_CONFIG, type ScriptComponentSpec, ScriptMatcher, type ScriptParameter, type ScriptRecipe, type ScriptRecipeMetaRow, type ScriptRecipeStore, type ScriptResult, ScriptStore, type ScriptStoreOptions, type SelectedWorkflow, type ShimDef, type ShimSummary, type ShimTarget, type SourcePolicy, type SpecToValidate, SuperatomSDK, type SuperatomSDKConfig, type T_RESPONSE, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, type TriggerEvent, type TriggerFireInfo, UIBlock, UILogCollector, type User, UserManager, type UsersData, type ValidationContext, type ValidationFinding, type WorkflowDescriptor, type Workspace, analyticsClient, answerCatalogForBinding, answerComponents, anthropicLLM, assertReadOnlySql, bindContext, bridgePreamble, captureContext, clearContextTokens, contextTokenCount, createCodexSession, createCodingAgentSession, dashboardConversationHistory, dataFingerprint, describeContext, describeTriggers, emitAgentEvent, extractNamedExport, formatFindingsForAgent, geminiLLM, getCodingAgent, getCodingAgentsConfig, getPiSessionState, getRequestContext, groqLLM, hybridRerank, inferColumns, isUserContext, listCodingAgents, llmUsageLogger, logger, makeFmt, mintContextToken, normalizeScriptBody, onAgentRun, onPiSessionUpdate, openaiLLM, policiesFromConfig, projectForDatasetBinding, promptLoader, queryCache, registerCodingAgentCollection, registerCodingAgents, registerDashboardAgentCollection, requireRequestContext, rerankChromaResults, rerankConversationResults, resolveContextToken, resolveScriptRecipeStore, revokeContextToken, runAsSystem, runAsUser, runCodingAgent, runScript, runWithContext, runWithMessageIdentity, startAgentTriggers, stopAgentTriggers, userPromptErrorLogger, validateComponentSpec, withCapturedContext, writeBridgeShims, writeShims };
6659
+ export { ALL_COLUMN_KEYS, ANSWER_COMPONENT_NAMES, type AgentConfig, type AgentEvent, type AgentResponse, type AgentRunContext, type AgentRunHandlers, type AgentRunRecord, type AgentRunResult, type AgentTrigger, type AgentUsage, type AnalyticsEventType, type AnalyticsStatus, type AnswerProvider, type AnswerProviderContext, type ApplySummary, BM25L, type BM25LOptions, type BaseLLMConfig, type BuildTriggerInput, CATEGORY_KEYS, CONTEXT_CONFIG, type CapturedLog, CleanupService, type CodexSessionOptions, type CodingAgentCollectionConfig, type CodingAgentDefinition, type CodingAgentSession, type CodingAgentSessionOptions, type CodingAgentsConfig, type ColInfo, type ColType, type CollectionHandler, type CollectionOperation, type Component, type DBUIBlock, DEFAULT_AGENT_CONFIG, DEFAULT_FMT_CONFIG, type DashboardAgentCollectionConfig, type DatabaseType, type FindingCode, type Fmt, type FmtConfig, type Harness, type HybridSearchOptions, INSTRUCTIONS_FILE, type IncomingMessage, type KbNodesQueryFilters, type KbNodesRequestPayload, LLM, type LLMUsageEntry, type LogLevel, MainAgent, type McpServerSpec, type Message, MissingRequestContextError, type ModelStrategy, NUMERIC_KEYS, type NarrationUpdate, type OutputContract, type OutputField, type OutputValidator, type PiSessionListener, type PiSessionState, type PiTranscriptEntry, type Principal, type PromptAttachment, type PromptContext, type RequestContext, type RerankedResult, type RowFilter, type RunAgentOptions, STORAGE_CONFIG, type ScriptComponentSpec, ScriptMatcher, type ScriptParameter, type ScriptRecipe, type ScriptRecipeMetaRow, type ScriptRecipeStore, type ScriptResult, ScriptStore, type ScriptStoreOptions, type SelectedWorkflow, type ShimDef, type ShimSummary, type ShimTarget, type SourcePolicy, type SpecToValidate, SuperatomSDK, type SuperatomSDKConfig, type T_RESPONSE, type TaskType, Thread, ThreadManager, type Tool$1 as Tool, type ToolOutputSchema, type TriggerEvent, type TriggerFireInfo, UIBlock, UILogCollector, type User, UserManager, type UsersData, type ValidationContext, type ValidationFinding, type WorkflowDescriptor, type Workspace, analyticsClient, answerCatalogForBinding, answerComponents, anthropicLLM, assertReadOnlySql, bindContext, bridgePreamble, captureContext, clearContextTokens, contextTokenCount, createCodexSession, createCodingAgentSession, dashboardConversationHistory, dataFingerprint, describeContext, describeTriggers, emitAgentEvent, extractNamedExport, formatFindingsForAgent, geminiLLM, getCodingAgent, getCodingAgentsConfig, getPiSessionState, getRequestContext, groqLLM, hybridRerank, inferColumns, isUserContext, listCodingAgents, llmUsageLogger, logger, makeFmt, mintContextToken, normalizeScriptBody, onAgentRun, onPiSessionUpdate, openaiLLM, policiesFromConfig, projectForDatasetBinding, promptLoader, queryCache, registerCodingAgentCollection, registerCodingAgents, registerDashboardAgentCollection, requireRequestContext, rerankChromaResults, rerankConversationResults, resolveContextToken, resolveScriptRecipeStore, revokeContextToken, runAsSystem, runAsUser, runCodingAgent, runScript, runWithContext, runWithMessageIdentity, startAgentTriggers, stopAgentTriggers, userPromptErrorLogger, validateComponentSpec, withCapturedContext, writeBridgeShims, writeShims };
package/dist/index.js CHANGED
@@ -384,6 +384,16 @@ var AuthVerifyRequestMessageSchema = import_zod3.z.object({
384
384
  type: import_zod3.z.literal("AUTH_VERIFY_REQ"),
385
385
  payload: AuthVerifyRequestPayloadSchema
386
386
  });
387
+ var MAX_PROMPT_ATTACHMENTS = 5;
388
+ var MAX_PROMPT_ATTACHMENT_SIZE = 25 * 1024 * 1024;
389
+ var PromptAttachmentSchema = import_zod3.z.object({
390
+ /** The R2 object key. */
391
+ key: import_zod3.z.string(),
392
+ fileName: import_zod3.z.string(),
393
+ /** Size in bytes. */
394
+ size: import_zod3.z.number().int().positive().max(MAX_PROMPT_ATTACHMENT_SIZE),
395
+ contentType: import_zod3.z.string().optional()
396
+ });
387
397
  var UserPromptRequestPayloadSchema = import_zod3.z.object({
388
398
  prompt: import_zod3.z.string(),
389
399
  userId: import_zod3.z.string().optional(),
@@ -396,6 +406,10 @@ var UserPromptRequestPayloadSchema = import_zod3.z.object({
396
406
  uiBlockId: import_zod3.z.string()
397
407
  }).optional(),
398
408
  responseMode: import_zod3.z.enum(["component", "text"]).optional(),
409
+ /** The chat agent (sa-api app id) the question was asked to. */
410
+ agentId: import_zod3.z.string().optional(),
411
+ /** Files attached to this question, already uploaded to R2. */
412
+ attachments: import_zod3.z.array(PromptAttachmentSchema).max(MAX_PROMPT_ATTACHMENTS).optional(),
399
413
  /**
400
414
  * Where the question was asked from — e.g. the dashboard being viewed. See
401
415
  * `PromptContext`. Accepted as anything so a client sending an unexpected shape
@@ -19397,7 +19411,7 @@ function hasTraceContent(trace) {
19397
19411
  return (trace.kbNodes?.global?.length ?? 0) > 0 || (trace.kbNodes?.query?.length ?? 0) > 0 || (trace.schemaNodes?.routing?.length ?? 0) > 0 || (trace.schemaNodes?.preResolve?.length ?? 0) > 0 || !!trace.schemaNodes?.mainAgentCatalog || (trace.schemaNodes?.sourceAgentSchemas?.length ?? 0) > 0 || trace.script != null || trace.scriptMatcher != null || !!trace.entityResolution?.catalogText || (trace.entityResolution?.calls?.length ?? 0) > 0 || !!trace.conversationHistory || !!trace.userAccessContext || !!trace.userKbContext || !!trace.concepts?.catalogText || !!trace.concepts?.invariantsText || (trace.concepts?.calls?.length ?? 0) > 0 || (trace.directTools?.calls?.length ?? 0) > 0 || (trace.componentGen?.length ?? 0) > 0;
19398
19412
  }
19399
19413
  async function saveConversation(params) {
19400
- const { userId, userPrompt, uiblock, uiBlockId, threadId, collections, status = "success", error: turnError, trace } = params;
19414
+ const { userId, userPrompt, uiblock, uiBlockId, threadId, collections, agentId, attachments, status = "success", error: turnError, trace } = params;
19401
19415
  if (!userId) {
19402
19416
  logger.warn("[CONVERSATION_SAVER] Skipping save: userId not provided");
19403
19417
  return {
@@ -19452,7 +19466,9 @@ async function saveConversation(params) {
19452
19466
  userPrompt,
19453
19467
  response: dbUIBlock,
19454
19468
  threadId,
19455
- status
19469
+ status,
19470
+ agentId,
19471
+ ...attachments?.length ? { attachments } : {}
19456
19472
  });
19457
19473
  if (!saveResult?.success) {
19458
19474
  logger.warn(`[CONVERSATION_SAVER] Failed to save conversation to PostgreSQL: ${saveResult?.message || "Unknown error"}`);
@@ -19614,6 +19630,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19614
19630
  const userId = payload.userId;
19615
19631
  const userConfig = payload.config;
19616
19632
  const SA_RUNTIME = payload.SA_RUNTIME;
19633
+ const agentId = payload.agentId;
19634
+ const attachments = payload.attachments?.length ? payload.attachments : void 0;
19617
19635
  const wsId = userPromptRequest.from.id || "unknown";
19618
19636
  const reported = (response) => ({
19619
19637
  model: response?.data?.model,
@@ -19730,7 +19748,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19730
19748
  };
19731
19749
  let userResponse;
19732
19750
  try {
19733
- const replayed = answerProvider ? (await replayExactMatch({ prompt, collections, userId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19751
+ const replayed = answerProvider && !attachments ? (await replayExactMatch({ prompt, collections, userId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19734
19752
  userResponse = replayed ? replayed : answerProvider ? await answerProvider({
19735
19753
  prompt,
19736
19754
  components,
@@ -19743,7 +19761,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19743
19761
  onStream: streamCallback,
19744
19762
  onNarration: narrationCallback,
19745
19763
  signal: abortController.signal,
19746
- context: promptContextFrom(payload.context)
19764
+ context: promptContextFrom(payload.context),
19765
+ attachments
19747
19766
  }) : await get_agent_user_response(
19748
19767
  prompt,
19749
19768
  components,
@@ -19789,6 +19808,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19789
19808
  uiBlockId,
19790
19809
  threadId,
19791
19810
  collections,
19811
+ agentId,
19812
+ attachments,
19792
19813
  status: "aborted",
19793
19814
  trace: userResponse.data?.trace
19794
19815
  });
@@ -19806,6 +19827,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19806
19827
  type: "chat_agent",
19807
19828
  userId,
19808
19829
  projectId: process.env.SUPERATOM_PROJECT_ID || "",
19830
+ appId: agentId,
19809
19831
  threadId,
19810
19832
  messageIndex: 0,
19811
19833
  question: prompt,
@@ -19855,6 +19877,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19855
19877
  uiBlockId,
19856
19878
  threadId,
19857
19879
  collections,
19880
+ agentId,
19881
+ attachments,
19858
19882
  status: "error",
19859
19883
  // The raw errors array, not the joined string below — that string
19860
19884
  // is only for sa-api's plain-text analytics column.
@@ -19875,6 +19899,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19875
19899
  type: "chat_agent",
19876
19900
  userId,
19877
19901
  projectId: process.env.SUPERATOM_PROJECT_ID || "",
19902
+ appId: agentId,
19878
19903
  threadId,
19879
19904
  messageIndex: 0,
19880
19905
  question: prompt,
@@ -19945,6 +19970,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19945
19970
  if (isNoDataAnswer) {
19946
19971
  logger.info(`[UserPromptRequest] No tools executed \u2014 saving as status='general' (not replayable from cache)`);
19947
19972
  }
19973
+ const notReplayable = isNoDataAnswer || !!attachments;
19948
19974
  const saveResult = await saveConversation({
19949
19975
  userId,
19950
19976
  userPrompt: prompt,
@@ -19952,7 +19978,9 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19952
19978
  uiBlockId,
19953
19979
  threadId,
19954
19980
  collections,
19955
- ...isNoDataAnswer ? { status: "general" } : {},
19981
+ agentId,
19982
+ attachments,
19983
+ ...notReplayable ? { status: "general" } : {},
19956
19984
  trace: userResponse.data?.trace
19957
19985
  });
19958
19986
  if (saveResult.success) {
@@ -19992,6 +20020,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19992
20020
  type: "chat_agent",
19993
20021
  userId,
19994
20022
  projectId: process.env.SUPERATOM_PROJECT_ID || "",
20023
+ appId: agentId,
19995
20024
  threadId,
19996
20025
  messageIndex: thread.getUIBlockCount(),
19997
20026
  question: prompt,
package/dist/index.mjs CHANGED
@@ -271,6 +271,16 @@ var AuthVerifyRequestMessageSchema = z3.object({
271
271
  type: z3.literal("AUTH_VERIFY_REQ"),
272
272
  payload: AuthVerifyRequestPayloadSchema
273
273
  });
274
+ var MAX_PROMPT_ATTACHMENTS = 5;
275
+ var MAX_PROMPT_ATTACHMENT_SIZE = 25 * 1024 * 1024;
276
+ var PromptAttachmentSchema = z3.object({
277
+ /** The R2 object key. */
278
+ key: z3.string(),
279
+ fileName: z3.string(),
280
+ /** Size in bytes. */
281
+ size: z3.number().int().positive().max(MAX_PROMPT_ATTACHMENT_SIZE),
282
+ contentType: z3.string().optional()
283
+ });
274
284
  var UserPromptRequestPayloadSchema = z3.object({
275
285
  prompt: z3.string(),
276
286
  userId: z3.string().optional(),
@@ -283,6 +293,10 @@ var UserPromptRequestPayloadSchema = z3.object({
283
293
  uiBlockId: z3.string()
284
294
  }).optional(),
285
295
  responseMode: z3.enum(["component", "text"]).optional(),
296
+ /** The chat agent (sa-api app id) the question was asked to. */
297
+ agentId: z3.string().optional(),
298
+ /** Files attached to this question, already uploaded to R2. */
299
+ attachments: z3.array(PromptAttachmentSchema).max(MAX_PROMPT_ATTACHMENTS).optional(),
286
300
  /**
287
301
  * Where the question was asked from — e.g. the dashboard being viewed. See
288
302
  * `PromptContext`. Accepted as anything so a client sending an unexpected shape
@@ -19284,7 +19298,7 @@ function hasTraceContent(trace) {
19284
19298
  return (trace.kbNodes?.global?.length ?? 0) > 0 || (trace.kbNodes?.query?.length ?? 0) > 0 || (trace.schemaNodes?.routing?.length ?? 0) > 0 || (trace.schemaNodes?.preResolve?.length ?? 0) > 0 || !!trace.schemaNodes?.mainAgentCatalog || (trace.schemaNodes?.sourceAgentSchemas?.length ?? 0) > 0 || trace.script != null || trace.scriptMatcher != null || !!trace.entityResolution?.catalogText || (trace.entityResolution?.calls?.length ?? 0) > 0 || !!trace.conversationHistory || !!trace.userAccessContext || !!trace.userKbContext || !!trace.concepts?.catalogText || !!trace.concepts?.invariantsText || (trace.concepts?.calls?.length ?? 0) > 0 || (trace.directTools?.calls?.length ?? 0) > 0 || (trace.componentGen?.length ?? 0) > 0;
19285
19299
  }
19286
19300
  async function saveConversation(params) {
19287
- const { userId, userPrompt, uiblock, uiBlockId, threadId, collections, status = "success", error: turnError, trace } = params;
19301
+ const { userId, userPrompt, uiblock, uiBlockId, threadId, collections, agentId, attachments, status = "success", error: turnError, trace } = params;
19288
19302
  if (!userId) {
19289
19303
  logger.warn("[CONVERSATION_SAVER] Skipping save: userId not provided");
19290
19304
  return {
@@ -19339,7 +19353,9 @@ async function saveConversation(params) {
19339
19353
  userPrompt,
19340
19354
  response: dbUIBlock,
19341
19355
  threadId,
19342
- status
19356
+ status,
19357
+ agentId,
19358
+ ...attachments?.length ? { attachments } : {}
19343
19359
  });
19344
19360
  if (!saveResult?.success) {
19345
19361
  logger.warn(`[CONVERSATION_SAVER] Failed to save conversation to PostgreSQL: ${saveResult?.message || "Unknown error"}`);
@@ -19501,6 +19517,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19501
19517
  const userId = payload.userId;
19502
19518
  const userConfig = payload.config;
19503
19519
  const SA_RUNTIME = payload.SA_RUNTIME;
19520
+ const agentId = payload.agentId;
19521
+ const attachments = payload.attachments?.length ? payload.attachments : void 0;
19504
19522
  const wsId = userPromptRequest.from.id || "unknown";
19505
19523
  const reported = (response) => ({
19506
19524
  model: response?.data?.model,
@@ -19617,7 +19635,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19617
19635
  };
19618
19636
  let userResponse;
19619
19637
  try {
19620
- const replayed = answerProvider ? (await replayExactMatch({ prompt, collections, userId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19638
+ const replayed = answerProvider && !attachments ? (await replayExactMatch({ prompt, collections, userId, streamCallback, method: "custom-exact-match", startTime: Date.now() }))?.response : void 0;
19621
19639
  userResponse = replayed ? replayed : answerProvider ? await answerProvider({
19622
19640
  prompt,
19623
19641
  components,
@@ -19630,7 +19648,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19630
19648
  onStream: streamCallback,
19631
19649
  onNarration: narrationCallback,
19632
19650
  signal: abortController.signal,
19633
- context: promptContextFrom(payload.context)
19651
+ context: promptContextFrom(payload.context),
19652
+ attachments
19634
19653
  }) : await get_agent_user_response(
19635
19654
  prompt,
19636
19655
  components,
@@ -19676,6 +19695,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19676
19695
  uiBlockId,
19677
19696
  threadId,
19678
19697
  collections,
19698
+ agentId,
19699
+ attachments,
19679
19700
  status: "aborted",
19680
19701
  trace: userResponse.data?.trace
19681
19702
  });
@@ -19693,6 +19714,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19693
19714
  type: "chat_agent",
19694
19715
  userId,
19695
19716
  projectId: process.env.SUPERATOM_PROJECT_ID || "",
19717
+ appId: agentId,
19696
19718
  threadId,
19697
19719
  messageIndex: 0,
19698
19720
  question: prompt,
@@ -19742,6 +19764,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19742
19764
  uiBlockId,
19743
19765
  threadId,
19744
19766
  collections,
19767
+ agentId,
19768
+ attachments,
19745
19769
  status: "error",
19746
19770
  // The raw errors array, not the joined string below — that string
19747
19771
  // is only for sa-api's plain-text analytics column.
@@ -19762,6 +19786,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19762
19786
  type: "chat_agent",
19763
19787
  userId,
19764
19788
  projectId: process.env.SUPERATOM_PROJECT_ID || "",
19789
+ appId: agentId,
19765
19790
  threadId,
19766
19791
  messageIndex: 0,
19767
19792
  question: prompt,
@@ -19832,6 +19857,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19832
19857
  if (isNoDataAnswer) {
19833
19858
  logger.info(`[UserPromptRequest] No tools executed \u2014 saving as status='general' (not replayable from cache)`);
19834
19859
  }
19860
+ const notReplayable = isNoDataAnswer || !!attachments;
19835
19861
  const saveResult = await saveConversation({
19836
19862
  userId,
19837
19863
  userPrompt: prompt,
@@ -19839,7 +19865,9 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19839
19865
  uiBlockId,
19840
19866
  threadId,
19841
19867
  collections,
19842
- ...isNoDataAnswer ? { status: "general" } : {},
19868
+ agentId,
19869
+ attachments,
19870
+ ...notReplayable ? { status: "general" } : {},
19843
19871
  trace: userResponse.data?.trace
19844
19872
  });
19845
19873
  if (saveResult.success) {
@@ -19879,6 +19907,7 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19879
19907
  type: "chat_agent",
19880
19908
  userId,
19881
19909
  projectId: process.env.SUPERATOM_PROJECT_ID || "",
19910
+ appId: agentId,
19882
19911
  threadId,
19883
19912
  messageIndex: thread.getUIBlockCount(),
19884
19913
  question: prompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superatomai/sdk-node",
3
- "version": "0.0.70-dsp",
3
+ "version": "0.0.71-dsp",
4
4
  "description": "Node.js TypeScript SDK for Superatom",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",