@superatomai/sdk-node 0.0.81-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 +38 -2
- package/dist/index.d.ts +38 -2
- package/dist/index.js +64 -7
- package/dist/index.mjs +63 -7
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5140,6 +5140,25 @@ interface RequestContext {
|
|
|
5140
5140
|
* — see the backend's policy-gate.
|
|
5141
5141
|
*/
|
|
5142
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;
|
|
5143
5162
|
/** Correlates the audit log with a chat turn. */
|
|
5144
5163
|
requestId?: string;
|
|
5145
5164
|
/**
|
|
@@ -5173,6 +5192,7 @@ declare function runAsUser<T>(user: {
|
|
|
5173
5192
|
projectId?: string;
|
|
5174
5193
|
requestId?: string;
|
|
5175
5194
|
policies?: SourcePolicy[];
|
|
5195
|
+
allowedSources?: string[] | null;
|
|
5176
5196
|
graphVersion?: GraphVersion;
|
|
5177
5197
|
}, fn: () => T): T;
|
|
5178
5198
|
/**
|
|
@@ -5231,6 +5251,22 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
|
|
|
5231
5251
|
* backend/docs/SQL-AUTHORIZATION-DESIGN.md.
|
|
5232
5252
|
*/
|
|
5233
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;
|
|
5234
5270
|
/**
|
|
5235
5271
|
* Read access policies out of the admin-authored per-user config.
|
|
5236
5272
|
*
|
|
@@ -5241,7 +5277,7 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
|
|
|
5241
5277
|
* schema (and refusing, rather than dropping) is the fix, and is not built yet.
|
|
5242
5278
|
*
|
|
5243
5279
|
* Accepts either a single object or an array, so one user can be scoped across
|
|
5244
|
-
* several sources
|
|
5280
|
+
* several sources — and the object form, whose policies sit under `policies`.
|
|
5245
5281
|
*/
|
|
5246
5282
|
declare function policiesFromConfig(config: unknown): SourcePolicy[];
|
|
5247
5283
|
/**
|
|
@@ -6700,4 +6736,4 @@ declare class SuperatomSDK {
|
|
|
6700
6736
|
getConversationSimilarityThreshold(): number;
|
|
6701
6737
|
}
|
|
6702
6738
|
|
|
6703
|
-
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 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
|
@@ -5140,6 +5140,25 @@ interface RequestContext {
|
|
|
5140
5140
|
* — see the backend's policy-gate.
|
|
5141
5141
|
*/
|
|
5142
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;
|
|
5143
5162
|
/** Correlates the audit log with a chat turn. */
|
|
5144
5163
|
requestId?: string;
|
|
5145
5164
|
/**
|
|
@@ -5173,6 +5192,7 @@ declare function runAsUser<T>(user: {
|
|
|
5173
5192
|
projectId?: string;
|
|
5174
5193
|
requestId?: string;
|
|
5175
5194
|
policies?: SourcePolicy[];
|
|
5195
|
+
allowedSources?: string[] | null;
|
|
5176
5196
|
graphVersion?: GraphVersion;
|
|
5177
5197
|
}, fn: () => T): T;
|
|
5178
5198
|
/**
|
|
@@ -5231,6 +5251,22 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
|
|
|
5231
5251
|
* backend/docs/SQL-AUTHORIZATION-DESIGN.md.
|
|
5232
5252
|
*/
|
|
5233
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;
|
|
5234
5270
|
/**
|
|
5235
5271
|
* Read access policies out of the admin-authored per-user config.
|
|
5236
5272
|
*
|
|
@@ -5241,7 +5277,7 @@ declare function isUserContext(ctx?: RequestContext | undefined): boolean;
|
|
|
5241
5277
|
* schema (and refusing, rather than dropping) is the fix, and is not built yet.
|
|
5242
5278
|
*
|
|
5243
5279
|
* Accepts either a single object or an array, so one user can be scoped across
|
|
5244
|
-
* several sources
|
|
5280
|
+
* several sources — and the object form, whose policies sit under `policies`.
|
|
5245
5281
|
*/
|
|
5246
5282
|
declare function policiesFromConfig(config: unknown): SourcePolicy[];
|
|
5247
5283
|
/**
|
|
@@ -6700,4 +6736,4 @@ declare class SuperatomSDK {
|
|
|
6700
6736
|
getConversationSimilarityThreshold(): number;
|
|
6701
6737
|
}
|
|
6702
6738
|
|
|
6703
|
-
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 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,
|
|
@@ -1948,9 +1949,19 @@ function runWithContext(ctx, fn) {
|
|
|
1948
1949
|
return getStorage().run(ctx, fn);
|
|
1949
1950
|
}
|
|
1950
1951
|
function runAsUser(user, fn) {
|
|
1951
|
-
const { userId, orgId, role, projectId, requestId, policies, graphVersion } = user;
|
|
1952
|
+
const { userId, orgId, role, projectId, requestId, policies, allowedSources, graphVersion } = user;
|
|
1952
1953
|
return runWithContext(
|
|
1953
|
-
|
|
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
|
+
},
|
|
1954
1965
|
fn
|
|
1955
1966
|
);
|
|
1956
1967
|
}
|
|
@@ -2632,8 +2643,40 @@ function graphVersionOf(v) {
|
|
|
2632
2643
|
if (v === "draft") return "draft";
|
|
2633
2644
|
return Number.isInteger(v) && v > 0 ? v : void 0;
|
|
2634
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
|
+
}
|
|
2635
2677
|
function policiesFromConfig(config2) {
|
|
2636
|
-
const
|
|
2678
|
+
const raw = scopedForm(config2)?.policies ?? config2;
|
|
2679
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
2637
2680
|
const out = [];
|
|
2638
2681
|
for (const entry of entries) {
|
|
2639
2682
|
if (!entry || typeof entry !== "object") continue;
|
|
@@ -2676,12 +2719,13 @@ function policiesFromConfig(config2) {
|
|
|
2676
2719
|
var warnedUntrusted = false;
|
|
2677
2720
|
var warnedAnonymous = false;
|
|
2678
2721
|
var warnedUnlabelled = false;
|
|
2722
|
+
var warnedBadSources = false;
|
|
2679
2723
|
var announcedVerified = false;
|
|
2680
2724
|
var reportedIdMismatches = /* @__PURE__ */ new Set();
|
|
2681
2725
|
function runWithMessageIdentity(message, fn) {
|
|
2682
2726
|
const verified = message?.authContext;
|
|
2683
2727
|
const requestId = message?.id;
|
|
2684
|
-
const policies = verified ?
|
|
2728
|
+
const { policies, allowedSources } = verified ? accessFromConfig(verified.config) : accessFromConfig(message?.payload?.config);
|
|
2685
2729
|
if (verified?.userId) {
|
|
2686
2730
|
const claimedId = message?.payload?.userId;
|
|
2687
2731
|
if (!announcedVerified) {
|
|
@@ -2706,6 +2750,9 @@ function runWithMessageIdentity(message, fn) {
|
|
|
2706
2750
|
role: verified.role,
|
|
2707
2751
|
requestId,
|
|
2708
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,
|
|
2709
2756
|
// Only from the verified context: an unverified message has no say in which graph answers.
|
|
2710
2757
|
graphVersion: graphVersionOf(verified.graphVersion)
|
|
2711
2758
|
},
|
|
@@ -2720,7 +2767,7 @@ function runWithMessageIdentity(message, fn) {
|
|
|
2720
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."
|
|
2721
2768
|
);
|
|
2722
2769
|
}
|
|
2723
|
-
return runAsUser({ userId: claimed, requestId, policies }, fn);
|
|
2770
|
+
return runAsUser({ userId: claimed, requestId, policies, allowedSources: allowedSources ?? void 0 }, fn);
|
|
2724
2771
|
}
|
|
2725
2772
|
if (!warnedAnonymous) {
|
|
2726
2773
|
warnedAnonymous = true;
|
|
@@ -18186,7 +18233,8 @@ function storeScriptDatasetQuery(q, ctx) {
|
|
|
18186
18233
|
return queryCache.storeQuery(q.sql, { data, count });
|
|
18187
18234
|
}
|
|
18188
18235
|
function buildUserAccessContext(userConfig) {
|
|
18189
|
-
const
|
|
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];
|
|
18190
18238
|
const restrictions = [];
|
|
18191
18239
|
const prompts = [];
|
|
18192
18240
|
let anyRestriction = false;
|
|
@@ -25748,6 +25796,11 @@ fetch(BRIDGE + '/run-tool', {
|
|
|
25748
25796
|
// have been shown to you in full, and guessing column names wastes a turn on
|
|
25749
25797
|
// a failed query. Generated per run \u2014 do not edit.
|
|
25750
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)};
|
|
25751
25804
|
|
|
25752
25805
|
const [toolId, ...keywords] = process.argv.slice(2);
|
|
25753
25806
|
if (!toolId || !keywords.length) {
|
|
@@ -25757,7 +25810,10 @@ if (!toolId || !keywords.length) {
|
|
|
25757
25810
|
|
|
25758
25811
|
fetch(BRIDGE + '/schema-search', {
|
|
25759
25812
|
method: 'POST',
|
|
25760
|
-
headers: {
|
|
25813
|
+
headers: {
|
|
25814
|
+
'content-type': 'application/json',
|
|
25815
|
+
...(CONTEXT_TOKEN ? { 'x-sa-context': CONTEXT_TOKEN } : {}),
|
|
25816
|
+
},
|
|
25761
25817
|
body: JSON.stringify({ toolId, keywords }),
|
|
25762
25818
|
})
|
|
25763
25819
|
.then(async (r) => {
|
|
@@ -30094,6 +30150,7 @@ var SuperatomSDK = class {
|
|
|
30094
30150
|
UIBlock,
|
|
30095
30151
|
UILogCollector,
|
|
30096
30152
|
UserManager,
|
|
30153
|
+
accessFromConfig,
|
|
30097
30154
|
analyticsClient,
|
|
30098
30155
|
answerCatalogForBinding,
|
|
30099
30156
|
answerComponents,
|
package/dist/index.mjs
CHANGED
|
@@ -1837,9 +1837,19 @@ function runWithContext(ctx, fn) {
|
|
|
1837
1837
|
return getStorage().run(ctx, fn);
|
|
1838
1838
|
}
|
|
1839
1839
|
function runAsUser(user, fn) {
|
|
1840
|
-
const { userId, orgId, role, projectId, requestId, policies, graphVersion } = user;
|
|
1840
|
+
const { userId, orgId, role, projectId, requestId, policies, allowedSources, graphVersion } = user;
|
|
1841
1841
|
return runWithContext(
|
|
1842
|
-
|
|
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
|
+
},
|
|
1843
1853
|
fn
|
|
1844
1854
|
);
|
|
1845
1855
|
}
|
|
@@ -2521,8 +2531,40 @@ function graphVersionOf(v) {
|
|
|
2521
2531
|
if (v === "draft") return "draft";
|
|
2522
2532
|
return Number.isInteger(v) && v > 0 ? v : void 0;
|
|
2523
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
|
+
}
|
|
2524
2565
|
function policiesFromConfig(config2) {
|
|
2525
|
-
const
|
|
2566
|
+
const raw = scopedForm(config2)?.policies ?? config2;
|
|
2567
|
+
const entries = Array.isArray(raw) ? raw : [raw];
|
|
2526
2568
|
const out = [];
|
|
2527
2569
|
for (const entry of entries) {
|
|
2528
2570
|
if (!entry || typeof entry !== "object") continue;
|
|
@@ -2565,12 +2607,13 @@ function policiesFromConfig(config2) {
|
|
|
2565
2607
|
var warnedUntrusted = false;
|
|
2566
2608
|
var warnedAnonymous = false;
|
|
2567
2609
|
var warnedUnlabelled = false;
|
|
2610
|
+
var warnedBadSources = false;
|
|
2568
2611
|
var announcedVerified = false;
|
|
2569
2612
|
var reportedIdMismatches = /* @__PURE__ */ new Set();
|
|
2570
2613
|
function runWithMessageIdentity(message, fn) {
|
|
2571
2614
|
const verified = message?.authContext;
|
|
2572
2615
|
const requestId = message?.id;
|
|
2573
|
-
const policies = verified ?
|
|
2616
|
+
const { policies, allowedSources } = verified ? accessFromConfig(verified.config) : accessFromConfig(message?.payload?.config);
|
|
2574
2617
|
if (verified?.userId) {
|
|
2575
2618
|
const claimedId = message?.payload?.userId;
|
|
2576
2619
|
if (!announcedVerified) {
|
|
@@ -2595,6 +2638,9 @@ function runWithMessageIdentity(message, fn) {
|
|
|
2595
2638
|
role: verified.role,
|
|
2596
2639
|
requestId,
|
|
2597
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,
|
|
2598
2644
|
// Only from the verified context: an unverified message has no say in which graph answers.
|
|
2599
2645
|
graphVersion: graphVersionOf(verified.graphVersion)
|
|
2600
2646
|
},
|
|
@@ -2609,7 +2655,7 @@ function runWithMessageIdentity(message, fn) {
|
|
|
2609
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."
|
|
2610
2656
|
);
|
|
2611
2657
|
}
|
|
2612
|
-
return runAsUser({ userId: claimed, requestId, policies }, fn);
|
|
2658
|
+
return runAsUser({ userId: claimed, requestId, policies, allowedSources: allowedSources ?? void 0 }, fn);
|
|
2613
2659
|
}
|
|
2614
2660
|
if (!warnedAnonymous) {
|
|
2615
2661
|
warnedAnonymous = true;
|
|
@@ -18075,7 +18121,8 @@ function storeScriptDatasetQuery(q, ctx) {
|
|
|
18075
18121
|
return queryCache.storeQuery(q.sql, { data, count });
|
|
18076
18122
|
}
|
|
18077
18123
|
function buildUserAccessContext(userConfig) {
|
|
18078
|
-
const
|
|
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];
|
|
18079
18126
|
const restrictions = [];
|
|
18080
18127
|
const prompts = [];
|
|
18081
18128
|
let anyRestriction = false;
|
|
@@ -25637,6 +25684,11 @@ fetch(BRIDGE + '/run-tool', {
|
|
|
25637
25684
|
// have been shown to you in full, and guessing column names wastes a turn on
|
|
25638
25685
|
// a failed query. Generated per run \u2014 do not edit.
|
|
25639
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)};
|
|
25640
25692
|
|
|
25641
25693
|
const [toolId, ...keywords] = process.argv.slice(2);
|
|
25642
25694
|
if (!toolId || !keywords.length) {
|
|
@@ -25646,7 +25698,10 @@ if (!toolId || !keywords.length) {
|
|
|
25646
25698
|
|
|
25647
25699
|
fetch(BRIDGE + '/schema-search', {
|
|
25648
25700
|
method: 'POST',
|
|
25649
|
-
headers: {
|
|
25701
|
+
headers: {
|
|
25702
|
+
'content-type': 'application/json',
|
|
25703
|
+
...(CONTEXT_TOKEN ? { 'x-sa-context': CONTEXT_TOKEN } : {}),
|
|
25704
|
+
},
|
|
25650
25705
|
body: JSON.stringify({ toolId, keywords }),
|
|
25651
25706
|
})
|
|
25652
25707
|
.then(async (r) => {
|
|
@@ -29982,6 +30037,7 @@ export {
|
|
|
29982
30037
|
UIBlock,
|
|
29983
30038
|
UILogCollector,
|
|
29984
30039
|
UserManager,
|
|
30040
|
+
accessFromConfig,
|
|
29985
30041
|
analyticsClient,
|
|
29986
30042
|
answerCatalogForBinding,
|
|
29987
30043
|
answerComponents,
|