@superatomai/sdk-node 0.0.80-dsp → 0.0.82-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
@@ -2217,6 +2217,11 @@ interface AnswerProviderContext {
2217
2217
  context?: PromptContext;
2218
2218
  /** Files attached to this question (R2 references). Absent when none. */
2219
2219
  attachments?: PromptAttachment[];
2220
+ /**
2221
+ * The composition graph to answer from, from the relay-verified identity:
2222
+ * "draft" or a release seq. Absent means the live release.
2223
+ */
2224
+ graphVersion?: 'draft' | number;
2220
2225
  }
2221
2226
  /**
2222
2227
  * One narrator tick while an answer was being produced: what the narrator was
@@ -5135,9 +5140,35 @@ interface RequestContext {
5135
5140
  * — see the backend's policy-gate.
5136
5141
  */
5137
5142
  policies?: SourcePolicy[];
5143
+ /**
5144
+ * The data sources this user may reach AT ALL, by source id.
5145
+ *
5146
+ * Three states, and the third is the point:
5147
+ * - `undefined` / `null` — no source restriction. Every configured source.
5148
+ * - `["mssql-1a2b"]` — only those sources.
5149
+ * - `[]` — NOTHING. Not "everything".
5150
+ *
5151
+ * The empty array is what a computed-but-unprivileged lookup produces
5152
+ * (`user.sources.map(s => s.id)` for a user with nothing assigned), so
5153
+ * reading it as "unrestricted" would hand the least privileged user the most
5154
+ * access. Never collapse `[]` into absent anywhere along this path.
5155
+ *
5156
+ * This is the ONLY control that reaches a source the SQL rewriter cannot
5157
+ * touch: dynamodb, redis, rest_api and graphql have no dialect, so they take
5158
+ * neither row filters nor a table allowlist. Enforced in the backend's
5159
+ * policy-gate, independently of SA_SQL_REWRITE_MODE — it is not a rewrite.
5160
+ */
5161
+ allowedSources?: string[] | null;
5138
5162
  /** Correlates the audit log with a chat turn. */
5139
5163
  requestId?: string;
5164
+ /**
5165
+ * Which composition graph this user's questions are answered from, as the
5166
+ * relay stamped it: "draft" or a release seq. Absent means the live release.
5167
+ */
5168
+ graphVersion?: GraphVersion;
5140
5169
  }
5170
+ /** A composition graph version: the platform's working copy, or a published release seq. */
5171
+ type GraphVersion = 'draft' | number;
5141
5172
  /** The context for the current async chain, or `undefined` if none was established. */
5142
5173
  declare function getRequestContext(): RequestContext | undefined;
5143
5174
  /**
@@ -5161,6 +5192,8 @@ declare function runAsUser<T>(user: {
5161
5192
  projectId?: string;
5162
5193
  requestId?: string;
5163
5194
  policies?: SourcePolicy[];
5195
+ allowedSources?: string[] | null;
5196
+ graphVersion?: GraphVersion;
5164
5197
  }, fn: () => T): T;
5165
5198
  /**
5166
5199
  * Declare a unit of work as trusted, naming why.
@@ -5218,6 +5251,22 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
5218
5251
  * backend/docs/SQL-AUTHORIZATION-DESIGN.md.
5219
5252
  */
5220
5253
 
5254
+ /** Everything one request's config says about what the caller may see. */
5255
+ interface ResolvedAccess {
5256
+ policies: SourcePolicy[];
5257
+ /** `null` means every source; `[]` means none — see `RequestContext.allowedSources`. */
5258
+ allowedSources: string[] | null;
5259
+ }
5260
+ /**
5261
+ * Read the whole access config — both shapes.
5262
+ *
5263
+ * The array form is every existing deployment and is passed straight through to
5264
+ * `policiesFromConfig`. The object form is what sa-api mints when a customer
5265
+ * scopes sources (`lib/sdk-access.ts`); its policies live one level down, and
5266
+ * reading it as a single array entry would find no `rowFilters` on it and so
5267
+ * drop EVERY row filter the customer wrote.
5268
+ */
5269
+ declare function accessFromConfig(config: unknown): ResolvedAccess;
5221
5270
  /**
5222
5271
  * Read access policies out of the admin-authored per-user config.
5223
5272
  *
@@ -5228,7 +5277,7 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
5228
5277
  * schema (and refusing, rather than dropping) is the fix, and is not built yet.
5229
5278
  *
5230
5279
  * Accepts either a single object or an array, so one user can be scoped across
5231
- * several sources.
5280
+ * several sources — and the object form, whose policies sit under `policies`.
5232
5281
  */
5233
5282
  declare function policiesFromConfig(config: unknown): SourcePolicy[];
5234
5283
  /**
@@ -6687,4 +6736,4 @@ declare class SuperatomSDK {
6687
6736
  getConversationSimilarityThreshold(): number;
6688
6737
  }
6689
6738
 
6690
- 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 GeneratedFile, 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 };
6739
+ 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 GeneratedFile, type GraphVersion, 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 ResolvedAccess, 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, accessFromConfig, 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
@@ -2217,6 +2217,11 @@ interface AnswerProviderContext {
2217
2217
  context?: PromptContext;
2218
2218
  /** Files attached to this question (R2 references). Absent when none. */
2219
2219
  attachments?: PromptAttachment[];
2220
+ /**
2221
+ * The composition graph to answer from, from the relay-verified identity:
2222
+ * "draft" or a release seq. Absent means the live release.
2223
+ */
2224
+ graphVersion?: 'draft' | number;
2220
2225
  }
2221
2226
  /**
2222
2227
  * One narrator tick while an answer was being produced: what the narrator was
@@ -5135,9 +5140,35 @@ interface RequestContext {
5135
5140
  * — see the backend's policy-gate.
5136
5141
  */
5137
5142
  policies?: SourcePolicy[];
5143
+ /**
5144
+ * The data sources this user may reach AT ALL, by source id.
5145
+ *
5146
+ * Three states, and the third is the point:
5147
+ * - `undefined` / `null` — no source restriction. Every configured source.
5148
+ * - `["mssql-1a2b"]` — only those sources.
5149
+ * - `[]` — NOTHING. Not "everything".
5150
+ *
5151
+ * The empty array is what a computed-but-unprivileged lookup produces
5152
+ * (`user.sources.map(s => s.id)` for a user with nothing assigned), so
5153
+ * reading it as "unrestricted" would hand the least privileged user the most
5154
+ * access. Never collapse `[]` into absent anywhere along this path.
5155
+ *
5156
+ * This is the ONLY control that reaches a source the SQL rewriter cannot
5157
+ * touch: dynamodb, redis, rest_api and graphql have no dialect, so they take
5158
+ * neither row filters nor a table allowlist. Enforced in the backend's
5159
+ * policy-gate, independently of SA_SQL_REWRITE_MODE — it is not a rewrite.
5160
+ */
5161
+ allowedSources?: string[] | null;
5138
5162
  /** Correlates the audit log with a chat turn. */
5139
5163
  requestId?: string;
5164
+ /**
5165
+ * Which composition graph this user's questions are answered from, as the
5166
+ * relay stamped it: "draft" or a release seq. Absent means the live release.
5167
+ */
5168
+ graphVersion?: GraphVersion;
5140
5169
  }
5170
+ /** A composition graph version: the platform's working copy, or a published release seq. */
5171
+ type GraphVersion = 'draft' | number;
5141
5172
  /** The context for the current async chain, or `undefined` if none was established. */
5142
5173
  declare function getRequestContext(): RequestContext | undefined;
5143
5174
  /**
@@ -5161,6 +5192,8 @@ declare function runAsUser<T>(user: {
5161
5192
  projectId?: string;
5162
5193
  requestId?: string;
5163
5194
  policies?: SourcePolicy[];
5195
+ allowedSources?: string[] | null;
5196
+ graphVersion?: GraphVersion;
5164
5197
  }, fn: () => T): T;
5165
5198
  /**
5166
5199
  * Declare a unit of work as trusted, naming why.
@@ -5218,6 +5251,22 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
5218
5251
  * backend/docs/SQL-AUTHORIZATION-DESIGN.md.
5219
5252
  */
5220
5253
 
5254
+ /** Everything one request's config says about what the caller may see. */
5255
+ interface ResolvedAccess {
5256
+ policies: SourcePolicy[];
5257
+ /** `null` means every source; `[]` means none — see `RequestContext.allowedSources`. */
5258
+ allowedSources: string[] | null;
5259
+ }
5260
+ /**
5261
+ * Read the whole access config — both shapes.
5262
+ *
5263
+ * The array form is every existing deployment and is passed straight through to
5264
+ * `policiesFromConfig`. The object form is what sa-api mints when a customer
5265
+ * scopes sources (`lib/sdk-access.ts`); its policies live one level down, and
5266
+ * reading it as a single array entry would find no `rowFilters` on it and so
5267
+ * drop EVERY row filter the customer wrote.
5268
+ */
5269
+ declare function accessFromConfig(config: unknown): ResolvedAccess;
5221
5270
  /**
5222
5271
  * Read access policies out of the admin-authored per-user config.
5223
5272
  *
@@ -5228,7 +5277,7 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
5228
5277
  * schema (and refusing, rather than dropping) is the fix, and is not built yet.
5229
5278
  *
5230
5279
  * Accepts either a single object or an array, so one user can be scoped across
5231
- * several sources.
5280
+ * several sources — and the object form, whose policies sit under `policies`.
5232
5281
  */
5233
5282
  declare function policiesFromConfig(config: unknown): SourcePolicy[];
5234
5283
  /**
@@ -6687,4 +6736,4 @@ declare class SuperatomSDK {
6687
6736
  getConversationSimilarityThreshold(): number;
6688
6737
  }
6689
6738
 
6690
- 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 GeneratedFile, 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 };
6739
+ 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 GeneratedFile, type GraphVersion, 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 ResolvedAccess, 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, accessFromConfig, 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
@@ -52,6 +52,7 @@ __export(index_exports, {
52
52
  UIBlock: () => UIBlock,
53
53
  UILogCollector: () => UILogCollector,
54
54
  UserManager: () => UserManager,
55
+ accessFromConfig: () => accessFromConfig,
55
56
  analyticsClient: () => analyticsClient,
56
57
  answerCatalogForBinding: () => answerCatalogForBinding,
57
58
  answerComponents: () => answerComponents,
@@ -421,7 +422,10 @@ var UserPromptRequestPayloadSchema = import_zod3.z.object({
421
422
  var MessageAuthContextSchema = import_zod3.z.object({
422
423
  userId: import_zod3.z.string(),
423
424
  orgId: import_zod3.z.string().optional(),
424
- role: import_zod3.z.string().optional()
425
+ role: import_zod3.z.string().optional(),
426
+ // "draft" or a release seq; checked where it is read (request-identity.ts), so
427
+ // an unexpected value counts as the live release instead of rejecting the message.
428
+ graphVersion: import_zod3.z.unknown().optional()
425
429
  });
426
430
  var UserPromptRequestMessageSchema = import_zod3.z.object({
427
431
  id: import_zod3.z.string(),
@@ -1945,9 +1949,19 @@ function runWithContext(ctx, fn) {
1945
1949
  return getStorage().run(ctx, fn);
1946
1950
  }
1947
1951
  function runAsUser(user, fn) {
1948
- const { userId, orgId, role, projectId, requestId, policies } = user;
1952
+ const { userId, orgId, role, projectId, requestId, policies, allowedSources, graphVersion } = user;
1949
1953
  return runWithContext(
1950
- { principal: { kind: "user", userId, orgId, role }, projectId, requestId, policies },
1954
+ // `allowedSources` is spread in only when given, so an absent restriction
1955
+ // stays absent rather than becoming an explicit `undefined` that a later
1956
+ // `'allowedSources' in ctx` check would read as present.
1957
+ {
1958
+ principal: { kind: "user", userId, orgId, role },
1959
+ projectId,
1960
+ requestId,
1961
+ policies,
1962
+ ...allowedSources !== void 0 ? { allowedSources } : {},
1963
+ ...graphVersion !== void 0 ? { graphVersion } : {}
1964
+ },
1951
1965
  fn
1952
1966
  );
1953
1967
  }
@@ -2625,8 +2639,44 @@ function buildDirectToolCacheKey(toolId, parameters) {
2625
2639
  }
2626
2640
 
2627
2641
  // src/handlers/request-identity.ts
2642
+ function graphVersionOf(v) {
2643
+ if (v === "draft") return "draft";
2644
+ return Number.isInteger(v) && v > 0 ? v : void 0;
2645
+ }
2646
+ function scopedForm(config2) {
2647
+ if (!config2 || typeof config2 !== "object" || Array.isArray(config2)) return void 0;
2648
+ const c = config2;
2649
+ return "allowedSources" in c || "policies" in c ? c : void 0;
2650
+ }
2651
+ function allowedSourcesFrom(value) {
2652
+ if (value === void 0 || value === null) return null;
2653
+ if (!Array.isArray(value)) {
2654
+ if (!warnedBadSources) {
2655
+ warnedBadSources = true;
2656
+ logger.warn(
2657
+ `[RequestIdentity] "allowedSources" is ${typeof value}, not a list of source ids \u2014 treating it as NO sources rather than all of them. Fix the config: "allowedSources": ["mssql-1a2b"].`
2658
+ );
2659
+ }
2660
+ return [];
2661
+ }
2662
+ const out = [];
2663
+ for (const item of value) {
2664
+ if (typeof item !== "string" || !item.trim()) continue;
2665
+ const id = item.trim();
2666
+ if (!out.includes(id)) out.push(id);
2667
+ }
2668
+ return out;
2669
+ }
2670
+ function accessFromConfig(config2) {
2671
+ const scoped = scopedForm(config2);
2672
+ return {
2673
+ policies: policiesFromConfig(config2),
2674
+ allowedSources: scoped ? allowedSourcesFrom(scoped.allowedSources) : null
2675
+ };
2676
+ }
2628
2677
  function policiesFromConfig(config2) {
2629
- const entries = Array.isArray(config2) ? config2 : [config2];
2678
+ const raw = scopedForm(config2)?.policies ?? config2;
2679
+ const entries = Array.isArray(raw) ? raw : [raw];
2630
2680
  const out = [];
2631
2681
  for (const entry of entries) {
2632
2682
  if (!entry || typeof entry !== "object") continue;
@@ -2669,12 +2719,13 @@ function policiesFromConfig(config2) {
2669
2719
  var warnedUntrusted = false;
2670
2720
  var warnedAnonymous = false;
2671
2721
  var warnedUnlabelled = false;
2722
+ var warnedBadSources = false;
2672
2723
  var announcedVerified = false;
2673
2724
  var reportedIdMismatches = /* @__PURE__ */ new Set();
2674
2725
  function runWithMessageIdentity(message, fn) {
2675
2726
  const verified = message?.authContext;
2676
2727
  const requestId = message?.id;
2677
- const policies = verified ? policiesFromConfig(verified.config) : policiesFromConfig(message?.payload?.config);
2728
+ const { policies, allowedSources } = verified ? accessFromConfig(verified.config) : accessFromConfig(message?.payload?.config);
2678
2729
  if (verified?.userId) {
2679
2730
  const claimedId = message?.payload?.userId;
2680
2731
  if (!announcedVerified) {
@@ -2693,7 +2744,18 @@ function runWithMessageIdentity(message, fn) {
2693
2744
  }
2694
2745
  }
2695
2746
  return runAsUser(
2696
- { userId: verified.userId, orgId: verified.orgId, role: verified.role, requestId, policies },
2747
+ {
2748
+ userId: verified.userId,
2749
+ orgId: verified.orgId,
2750
+ role: verified.role,
2751
+ requestId,
2752
+ policies,
2753
+ // `?? undefined` so "no restriction" leaves the key off the context
2754
+ // entirely; `[]` is passed through as the deny-everything it means.
2755
+ allowedSources: allowedSources ?? void 0,
2756
+ // Only from the verified context: an unverified message has no say in which graph answers.
2757
+ graphVersion: graphVersionOf(verified.graphVersion)
2758
+ },
2697
2759
  fn
2698
2760
  );
2699
2761
  }
@@ -2705,7 +2767,7 @@ function runWithMessageIdentity(message, fn) {
2705
2767
  "[RequestIdentity] Using the client-supplied payload.userId as the principal \u2014 the relay is not stamping a verified authContext yet, so this identity is NOT trustworthy. Fine for plumbing; do not enable policy enforcement until the relay change lands."
2706
2768
  );
2707
2769
  }
2708
- return runAsUser({ userId: claimed, requestId, policies }, fn);
2770
+ return runAsUser({ userId: claimed, requestId, policies, allowedSources: allowedSources ?? void 0 }, fn);
2709
2771
  }
2710
2772
  if (!warnedAnonymous) {
2711
2773
  warnedAnonymous = true;
@@ -18171,7 +18233,8 @@ function storeScriptDatasetQuery(q, ctx) {
18171
18233
  return queryCache.storeQuery(q.sql, { data, count });
18172
18234
  }
18173
18235
  function buildUserAccessContext(userConfig) {
18174
- const entries = Array.isArray(userConfig) ? userConfig : [userConfig];
18236
+ const config2 = userConfig && !Array.isArray(userConfig) && typeof userConfig === "object" && ("policies" in userConfig || "allowedSources" in userConfig) ? userConfig.policies : userConfig;
18237
+ const entries = Array.isArray(config2) ? config2 : [config2];
18175
18238
  const restrictions = [];
18176
18239
  const prompts = [];
18177
18240
  let anyRestriction = false;
@@ -19820,7 +19883,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19820
19883
  onNarration: narrationCallback,
19821
19884
  signal: abortController.signal,
19822
19885
  context: promptContextFrom(payload.context),
19823
- attachments
19886
+ attachments,
19887
+ graphVersion: getRequestContext()?.graphVersion
19824
19888
  }) : await get_agent_user_response(
19825
19889
  prompt,
19826
19890
  components,
@@ -25732,6 +25796,11 @@ fetch(BRIDGE + '/run-tool', {
25732
25796
  // have been shown to you in full, and guessing column names wastes a turn on
25733
25797
  // a failed query. Generated per run \u2014 do not edit.
25734
25798
  const BRIDGE = ${JSON.stringify(opts.bridgeUrl)};
25799
+ // Sent for the same reason ./query sends it. A schema describes the data, so
25800
+ // WHICH tables may be described is the caller's access, not a free question \u2014
25801
+ // without this the bridge cannot tell whose run this is, and a source the run
25802
+ // may not read would be described to it in full.
25803
+ const CONTEXT_TOKEN = ${JSON.stringify(opts.contextToken ?? null)};
25735
25804
 
25736
25805
  const [toolId, ...keywords] = process.argv.slice(2);
25737
25806
  if (!toolId || !keywords.length) {
@@ -25741,7 +25810,10 @@ if (!toolId || !keywords.length) {
25741
25810
 
25742
25811
  fetch(BRIDGE + '/schema-search', {
25743
25812
  method: 'POST',
25744
- headers: { 'content-type': 'application/json' },
25813
+ headers: {
25814
+ 'content-type': 'application/json',
25815
+ ...(CONTEXT_TOKEN ? { 'x-sa-context': CONTEXT_TOKEN } : {}),
25816
+ },
25745
25817
  body: JSON.stringify({ toolId, keywords }),
25746
25818
  })
25747
25819
  .then(async (r) => {
@@ -30078,6 +30150,7 @@ var SuperatomSDK = class {
30078
30150
  UIBlock,
30079
30151
  UILogCollector,
30080
30152
  UserManager,
30153
+ accessFromConfig,
30081
30154
  analyticsClient,
30082
30155
  answerCatalogForBinding,
30083
30156
  answerComponents,
package/dist/index.mjs CHANGED
@@ -310,7 +310,10 @@ var UserPromptRequestPayloadSchema = z3.object({
310
310
  var MessageAuthContextSchema = z3.object({
311
311
  userId: z3.string(),
312
312
  orgId: z3.string().optional(),
313
- role: z3.string().optional()
313
+ role: z3.string().optional(),
314
+ // "draft" or a release seq; checked where it is read (request-identity.ts), so
315
+ // an unexpected value counts as the live release instead of rejecting the message.
316
+ graphVersion: z3.unknown().optional()
314
317
  });
315
318
  var UserPromptRequestMessageSchema = z3.object({
316
319
  id: z3.string(),
@@ -1834,9 +1837,19 @@ function runWithContext(ctx, fn) {
1834
1837
  return getStorage().run(ctx, fn);
1835
1838
  }
1836
1839
  function runAsUser(user, fn) {
1837
- const { userId, orgId, role, projectId, requestId, policies } = user;
1840
+ const { userId, orgId, role, projectId, requestId, policies, allowedSources, graphVersion } = user;
1838
1841
  return runWithContext(
1839
- { principal: { kind: "user", userId, orgId, role }, projectId, requestId, policies },
1842
+ // `allowedSources` is spread in only when given, so an absent restriction
1843
+ // stays absent rather than becoming an explicit `undefined` that a later
1844
+ // `'allowedSources' in ctx` check would read as present.
1845
+ {
1846
+ principal: { kind: "user", userId, orgId, role },
1847
+ projectId,
1848
+ requestId,
1849
+ policies,
1850
+ ...allowedSources !== void 0 ? { allowedSources } : {},
1851
+ ...graphVersion !== void 0 ? { graphVersion } : {}
1852
+ },
1840
1853
  fn
1841
1854
  );
1842
1855
  }
@@ -2514,8 +2527,44 @@ function buildDirectToolCacheKey(toolId, parameters) {
2514
2527
  }
2515
2528
 
2516
2529
  // src/handlers/request-identity.ts
2530
+ function graphVersionOf(v) {
2531
+ if (v === "draft") return "draft";
2532
+ return Number.isInteger(v) && v > 0 ? v : void 0;
2533
+ }
2534
+ function scopedForm(config2) {
2535
+ if (!config2 || typeof config2 !== "object" || Array.isArray(config2)) return void 0;
2536
+ const c = config2;
2537
+ return "allowedSources" in c || "policies" in c ? c : void 0;
2538
+ }
2539
+ function allowedSourcesFrom(value) {
2540
+ if (value === void 0 || value === null) return null;
2541
+ if (!Array.isArray(value)) {
2542
+ if (!warnedBadSources) {
2543
+ warnedBadSources = true;
2544
+ logger.warn(
2545
+ `[RequestIdentity] "allowedSources" is ${typeof value}, not a list of source ids \u2014 treating it as NO sources rather than all of them. Fix the config: "allowedSources": ["mssql-1a2b"].`
2546
+ );
2547
+ }
2548
+ return [];
2549
+ }
2550
+ const out = [];
2551
+ for (const item of value) {
2552
+ if (typeof item !== "string" || !item.trim()) continue;
2553
+ const id = item.trim();
2554
+ if (!out.includes(id)) out.push(id);
2555
+ }
2556
+ return out;
2557
+ }
2558
+ function accessFromConfig(config2) {
2559
+ const scoped = scopedForm(config2);
2560
+ return {
2561
+ policies: policiesFromConfig(config2),
2562
+ allowedSources: scoped ? allowedSourcesFrom(scoped.allowedSources) : null
2563
+ };
2564
+ }
2517
2565
  function policiesFromConfig(config2) {
2518
- const entries = Array.isArray(config2) ? config2 : [config2];
2566
+ const raw = scopedForm(config2)?.policies ?? config2;
2567
+ const entries = Array.isArray(raw) ? raw : [raw];
2519
2568
  const out = [];
2520
2569
  for (const entry of entries) {
2521
2570
  if (!entry || typeof entry !== "object") continue;
@@ -2558,12 +2607,13 @@ function policiesFromConfig(config2) {
2558
2607
  var warnedUntrusted = false;
2559
2608
  var warnedAnonymous = false;
2560
2609
  var warnedUnlabelled = false;
2610
+ var warnedBadSources = false;
2561
2611
  var announcedVerified = false;
2562
2612
  var reportedIdMismatches = /* @__PURE__ */ new Set();
2563
2613
  function runWithMessageIdentity(message, fn) {
2564
2614
  const verified = message?.authContext;
2565
2615
  const requestId = message?.id;
2566
- const policies = verified ? policiesFromConfig(verified.config) : policiesFromConfig(message?.payload?.config);
2616
+ const { policies, allowedSources } = verified ? accessFromConfig(verified.config) : accessFromConfig(message?.payload?.config);
2567
2617
  if (verified?.userId) {
2568
2618
  const claimedId = message?.payload?.userId;
2569
2619
  if (!announcedVerified) {
@@ -2582,7 +2632,18 @@ function runWithMessageIdentity(message, fn) {
2582
2632
  }
2583
2633
  }
2584
2634
  return runAsUser(
2585
- { userId: verified.userId, orgId: verified.orgId, role: verified.role, requestId, policies },
2635
+ {
2636
+ userId: verified.userId,
2637
+ orgId: verified.orgId,
2638
+ role: verified.role,
2639
+ requestId,
2640
+ policies,
2641
+ // `?? undefined` so "no restriction" leaves the key off the context
2642
+ // entirely; `[]` is passed through as the deny-everything it means.
2643
+ allowedSources: allowedSources ?? void 0,
2644
+ // Only from the verified context: an unverified message has no say in which graph answers.
2645
+ graphVersion: graphVersionOf(verified.graphVersion)
2646
+ },
2586
2647
  fn
2587
2648
  );
2588
2649
  }
@@ -2594,7 +2655,7 @@ function runWithMessageIdentity(message, fn) {
2594
2655
  "[RequestIdentity] Using the client-supplied payload.userId as the principal \u2014 the relay is not stamping a verified authContext yet, so this identity is NOT trustworthy. Fine for plumbing; do not enable policy enforcement until the relay change lands."
2595
2656
  );
2596
2657
  }
2597
- return runAsUser({ userId: claimed, requestId, policies }, fn);
2658
+ return runAsUser({ userId: claimed, requestId, policies, allowedSources: allowedSources ?? void 0 }, fn);
2598
2659
  }
2599
2660
  if (!warnedAnonymous) {
2600
2661
  warnedAnonymous = true;
@@ -18060,7 +18121,8 @@ function storeScriptDatasetQuery(q, ctx) {
18060
18121
  return queryCache.storeQuery(q.sql, { data, count });
18061
18122
  }
18062
18123
  function buildUserAccessContext(userConfig) {
18063
- const entries = Array.isArray(userConfig) ? userConfig : [userConfig];
18124
+ const config2 = userConfig && !Array.isArray(userConfig) && typeof userConfig === "object" && ("policies" in userConfig || "allowedSources" in userConfig) ? userConfig.policies : userConfig;
18125
+ const entries = Array.isArray(config2) ? config2 : [config2];
18064
18126
  const restrictions = [];
18065
18127
  const prompts = [];
18066
18128
  let anyRestriction = false;
@@ -19709,7 +19771,8 @@ var get_user_request = async (data, components, sendMessage, anthropicApiKey, gr
19709
19771
  onNarration: narrationCallback,
19710
19772
  signal: abortController.signal,
19711
19773
  context: promptContextFrom(payload.context),
19712
- attachments
19774
+ attachments,
19775
+ graphVersion: getRequestContext()?.graphVersion
19713
19776
  }) : await get_agent_user_response(
19714
19777
  prompt,
19715
19778
  components,
@@ -25621,6 +25684,11 @@ fetch(BRIDGE + '/run-tool', {
25621
25684
  // have been shown to you in full, and guessing column names wastes a turn on
25622
25685
  // a failed query. Generated per run \u2014 do not edit.
25623
25686
  const BRIDGE = ${JSON.stringify(opts.bridgeUrl)};
25687
+ // Sent for the same reason ./query sends it. A schema describes the data, so
25688
+ // WHICH tables may be described is the caller's access, not a free question \u2014
25689
+ // without this the bridge cannot tell whose run this is, and a source the run
25690
+ // may not read would be described to it in full.
25691
+ const CONTEXT_TOKEN = ${JSON.stringify(opts.contextToken ?? null)};
25624
25692
 
25625
25693
  const [toolId, ...keywords] = process.argv.slice(2);
25626
25694
  if (!toolId || !keywords.length) {
@@ -25630,7 +25698,10 @@ if (!toolId || !keywords.length) {
25630
25698
 
25631
25699
  fetch(BRIDGE + '/schema-search', {
25632
25700
  method: 'POST',
25633
- headers: { 'content-type': 'application/json' },
25701
+ headers: {
25702
+ 'content-type': 'application/json',
25703
+ ...(CONTEXT_TOKEN ? { 'x-sa-context': CONTEXT_TOKEN } : {}),
25704
+ },
25634
25705
  body: JSON.stringify({ toolId, keywords }),
25635
25706
  })
25636
25707
  .then(async (r) => {
@@ -29966,6 +30037,7 @@ export {
29966
30037
  UIBlock,
29967
30038
  UILogCollector,
29968
30039
  UserManager,
30040
+ accessFromConfig,
29969
30041
  analyticsClient,
29970
30042
  answerCatalogForBinding,
29971
30043
  answerComponents,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superatomai/sdk-node",
3
- "version": "0.0.80-dsp",
3
+ "version": "0.0.82-dsp",
4
4
  "description": "Node.js TypeScript SDK for Superatom",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",