@happyvertical/smrt-agents 0.62.3 → 0.62.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +2 -1
- package/README.md +12 -0
- package/agents/data-surface-denials.md +14 -0
- package/agents/principal-binding.md +23 -0
- package/dist/chunks/{execute-as-principal-tnjcjKIp.js → execute-as-principal-D9XLi1tk.js} +39 -1
- package/dist/chunks/execute-as-principal-D9XLi1tk.js.map +1 -0
- package/dist/execute-as-principal.d.ts +41 -0
- package/dist/execute-as-principal.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +1 -1
- package/dist/server/data-surface-actions.d.ts +23 -0
- package/dist/server/data-surface-actions.d.ts.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server.js +27 -2
- package/dist/server.js.map +1 -1
- package/dist/smrt-knowledge.json +13 -7
- package/dist/smrt-knowledge.okf.md +6 -2
- package/package.json +12 -12
- package/dist/chunks/execute-as-principal-tnjcjKIp.js.map +0 -1
package/AGENTS.md
CHANGED
|
@@ -162,7 +162,7 @@ The **`default` persona reuses the singleton identity** (a `null` key), which is
|
|
|
162
162
|
|
|
163
163
|
## Principal Execution (issue #1888)
|
|
164
164
|
|
|
165
|
-
`executeAsPrincipal(options, fn)` runs agent work **AS a persona's bound user
|
|
165
|
+
`executeAsPrincipal(options, fn)` runs agent work **AS a persona's bound user** via the existing RBAC cascade: permissions resolve live unless the caller passes an explicit `permissions` snapshot, which the run then carries as `run.permissionSnapshot`. `agents.invoke` propagates that snapshot as the `DelegationEnvelope.permissions` ceiling, and `executeDelegatedInvocation` runs the worker with ceiling ∩ live grants, so a narrowed run cannot widen via delegation and a tampered ceiling cannot exceed live RBAC (#2978). It publishes `(user_id, tenant_id, permissions[])` onto the DB session (RLS then bounds every query per-`(table, action)` and per-tenant) and hands `fn` a `PrincipalRun` whose `assertToolAllowed()` / `assertOperation()` enforce the persona tool ceiling and the RLS-off catalog gate. Effective authority = **bound-user RBAC ∩ agent-class ceiling ∩ persona `allowedTools`**. Actions audit as on-behalf-of the originating user via a `PrincipalAuditSink`. See [principal-binding](agents/principal-binding.md).
|
|
166
166
|
|
|
167
167
|
## Data Surface Read Tools (issue #2447)
|
|
168
168
|
|
|
@@ -203,6 +203,7 @@ declaring `isNull` (`eq`/`ne` with `null`, `"null"`, `""` or `[]`; a `not` namin
|
|
|
203
203
|
Refusals (#4387: action-specific denials, the `{ action }` catalog argument,
|
|
204
204
|
`onDenied`, audit `denied` entries, missing executors):
|
|
205
205
|
[agents/data-surface-denials.md](agents/data-surface-denials.md).
|
|
206
|
+
Action `visibleTo`: [#2986](agents/data-surface-denials.md#action-visibility-2986).
|
|
206
207
|
|
|
207
208
|
|
|
208
209
|
## Playbook Preflight (issue #2590)
|
package/README.md
CHANGED
|
@@ -146,6 +146,7 @@ such as `MessagingSettingsService`.
|
|
|
146
146
|
| `SmrtCollectionQueryCollection` | Structural collection interface the generic adapter executes against |
|
|
147
147
|
| `SmrtCollectionQueryScope` | Trusted, server-derived scope conditions for the generic adapter |
|
|
148
148
|
| `SmrtCollectionDataSurfaceAction` | Declarative row/bulk action catalog entry surfaced via `metadata.actionCatalog` |
|
|
149
|
+
| `PrincipalBinding` / `PrincipalRun` | `executeAsPrincipal` binding and run handle. Optional server-set `sessionId`, `credentialKind` (`PrincipalCredentialKind`), and `bindingMetadata` pass through to the run (`run.context.sessionId`, `run.credentialKind`, frozen `run.bindingMetadata`). Set them from verified server auth state, never browser input; they never affect `allowedTools` or permissions |
|
|
149
150
|
|
|
150
151
|
### Summary Discovery
|
|
151
152
|
|
|
@@ -285,6 +286,17 @@ callback accepts evidence for the exact request fingerprint and reservation
|
|
|
285
286
|
timestamp. `InMemoryDataSurfaceActionStateStore` is for single-process test
|
|
286
287
|
harnesses only.
|
|
287
288
|
|
|
289
|
+
An action may declare an optional `visibleTo({ run, descriptor, action })`
|
|
290
|
+
seam (sync or async) for a per-principal gate the RBAC catalog does not express.
|
|
291
|
+
The adapter evaluates it before the descriptor/map consistency check: a false,
|
|
292
|
+
non-`true`, throwing, or rejecting result refuses `denied` (fail closed), while an
|
|
293
|
+
action id the surface does not define still refuses `unsupported`. The
|
|
294
|
+
distinction is deliberate and truthful: `denied` tells the caller the action
|
|
295
|
+
exists but is not theirs, so hosts that must not reveal existence should keep
|
|
296
|
+
the action out of the surface instead. A describe-style read should return
|
|
297
|
+
`visibleDataSurfaceDescriptor(run, surface)`, which drops hidden actions from the
|
|
298
|
+
descriptor. Without the seam behaviour is unchanged.
|
|
299
|
+
|
|
288
300
|
`createJobsDataSurfaceBackgroundQueue()` persists a versioned envelope in
|
|
289
301
|
`@happyvertical/smrt-jobs`. The envelope contains the request and a non-secret
|
|
290
302
|
principal reference, never permission snapshots or confirmation-token secrets.
|
|
@@ -21,3 +21,17 @@ success); a throwing audit sink is reported to `onFailure` and the refusal
|
|
|
21
21
|
stands. `onDenied` is separate from `onFailure`: a denial is an authorization
|
|
22
22
|
outcome, not a server error. Request errors (including hidden fields, which
|
|
23
23
|
get `DATA_QUERY_FIELD_NOT_ALLOWED`) are not denials.
|
|
24
|
+
|
|
25
|
+
## Action visibility (#2986)
|
|
26
|
+
|
|
27
|
+
`DataSurfaceServerActionDefinition.visibleTo?({ run, descriptor, action })` is
|
|
28
|
+
the per-principal gate for actions that exist on a surface but that this
|
|
29
|
+
principal may neither see nor run. `createDataSurfaceActionAdapter` evaluates it
|
|
30
|
+
in `resolveInvocation` before the descriptor/map consistency check: a false,
|
|
31
|
+
non-`true`, throwing, or rejecting result refuses `denied` (fail closed); an id
|
|
32
|
+
absent from the surface's action map still refuses `unsupported`. `denied` vs
|
|
33
|
+
`unsupported` is therefore a truthful existence signal, so a host that must not
|
|
34
|
+
reveal an action's existence should omit it from the surface instead.
|
|
35
|
+
Describe-style reads return `visibleDataSurfaceDescriptor(run, surface)`, which
|
|
36
|
+
drops hidden actions from the descriptor. Without the seam behaviour is
|
|
37
|
+
unchanged.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# PrincipalBinding server-set facts (#2944)
|
|
2
|
+
|
|
3
|
+
`PrincipalBinding` takes optional **server-set** `sessionId`, `credentialKind`
|
|
4
|
+
(`'session' | 'device' | 'api-key' | 'oauth' | 'service' | string`), and
|
|
5
|
+
`bindingMetadata` (JSON record). They reach `PrincipalRun` as:
|
|
6
|
+
|
|
7
|
+
- `run.sessionId` and `run.context.sessionId` (plumbed through
|
|
8
|
+
`withPrincipalPermissionContext({ sessionId })`; `context.session` stays
|
|
9
|
+
`null` — no session object is loaded or fabricated; absent means `null`),
|
|
10
|
+
- `run.credentialKind` (absent when not supplied),
|
|
11
|
+
- `run.bindingMetadata`: a frozen deep clone, so a run cannot mutate the
|
|
12
|
+
binding (absent when not supplied).
|
|
13
|
+
|
|
14
|
+
Hosts must set these from verified server auth state, never from browser or
|
|
15
|
+
user input. They are descriptive passthroughs: they never feed `allowedTools`
|
|
16
|
+
(still fail-closed) or permission resolution. Use them instead of encoding
|
|
17
|
+
"how did this run authenticate" as a marker slug in `allowedTools`.
|
|
18
|
+
|
|
19
|
+
`sessionId` is an **unverified server-set label**, not an authenticated
|
|
20
|
+
session: `smrt.session_id` (the Postgres RLS GUC) stays empty for principal
|
|
21
|
+
runs, since only a loaded session may populate it. `bindingMetadata` must be
|
|
22
|
+
JSON-safe; Date, Map, typed arrays, class instances, and cycles throw a clear
|
|
23
|
+
`TypeError` before the run starts.
|
|
@@ -196,6 +196,37 @@ var PrincipalToolNotAllowedError = class extends Error {
|
|
|
196
196
|
this.tool = tool;
|
|
197
197
|
}
|
|
198
198
|
};
|
|
199
|
+
function cloneJsonFrozen(value, path, seen) {
|
|
200
|
+
if (value === null) return null;
|
|
201
|
+
const t = typeof value;
|
|
202
|
+
if (t === "string" || t === "boolean") return value;
|
|
203
|
+
if (t === "number") {
|
|
204
|
+
if (!Number.isFinite(value)) throw new TypeError(`PrincipalBinding.bindingMetadata${path} must be a finite number`);
|
|
205
|
+
return value;
|
|
206
|
+
}
|
|
207
|
+
if (t === "object") {
|
|
208
|
+
const obj = value;
|
|
209
|
+
if (seen.has(obj)) throw new TypeError(`PrincipalBinding.bindingMetadata${path} contains a cycle`);
|
|
210
|
+
seen.add(obj);
|
|
211
|
+
let out;
|
|
212
|
+
if (Array.isArray(obj)) out = obj.map((v, i) => cloneJsonFrozen(v, `${path}[${i}]`, seen));
|
|
213
|
+
else {
|
|
214
|
+
const proto = Object.getPrototypeOf(obj);
|
|
215
|
+
if (proto !== Object.prototype && proto !== null) throw new TypeError(`PrincipalBinding.bindingMetadata${path} must be JSON-safe (got ${obj.constructor?.name ?? "non-plain object"})`);
|
|
216
|
+
const rec = {};
|
|
217
|
+
for (const [k, v] of Object.entries(obj)) Object.defineProperty(rec, k, {
|
|
218
|
+
value: cloneJsonFrozen(v, `${path}.${k}`, seen),
|
|
219
|
+
enumerable: true,
|
|
220
|
+
writable: true,
|
|
221
|
+
configurable: true
|
|
222
|
+
});
|
|
223
|
+
out = rec;
|
|
224
|
+
}
|
|
225
|
+
seen.delete(obj);
|
|
226
|
+
return Object.freeze(out);
|
|
227
|
+
}
|
|
228
|
+
throw new TypeError(`PrincipalBinding.bindingMetadata${path} must be JSON-safe (got ${t})`);
|
|
229
|
+
}
|
|
199
230
|
async function emitAudit(entry, audit, logger) {
|
|
200
231
|
if (audit) {
|
|
201
232
|
await audit(entry);
|
|
@@ -208,6 +239,9 @@ async function executeAsPrincipal(options, fn) {
|
|
|
208
239
|
const { runAsUserId, tenantId, actsAsProfileId = null } = principal;
|
|
209
240
|
const toolWhitelist = Array.isArray(principal.allowedTools) ? principal.allowedTools : [];
|
|
210
241
|
const isToolAllowed = (tool) => typeof tool === "string" && tool.length > 0 && toolWhitelist.includes(tool);
|
|
242
|
+
const boundSessionId = typeof principal.sessionId === "string" && principal.sessionId.length > 0 ? principal.sessionId : null;
|
|
243
|
+
const credentialKind = typeof principal.credentialKind === "string" && principal.credentialKind.length > 0 ? principal.credentialKind : void 0;
|
|
244
|
+
const bindingMetadata = principal.bindingMetadata !== void 0 && principal.bindingMetadata !== null ? cloneJsonFrozen(principal.bindingMetadata, "", /* @__PURE__ */ new Set()) : void 0;
|
|
211
245
|
await emitAudit({
|
|
212
246
|
action,
|
|
213
247
|
actorUserId: runAsUserId,
|
|
@@ -221,6 +255,7 @@ async function executeAsPrincipal(options, fn) {
|
|
|
221
255
|
...smrtOptions,
|
|
222
256
|
userId: runAsUserId,
|
|
223
257
|
tenantId,
|
|
258
|
+
sessionId: boundSessionId,
|
|
224
259
|
permissions,
|
|
225
260
|
resolver,
|
|
226
261
|
postgresRls,
|
|
@@ -231,6 +266,9 @@ async function executeAsPrincipal(options, fn) {
|
|
|
231
266
|
permissions: context.permissions,
|
|
232
267
|
...permissions !== void 0 ? { permissionSnapshot: [...context.permissions] } : {},
|
|
233
268
|
allowedTools: toolWhitelist,
|
|
269
|
+
sessionId: boundSessionId,
|
|
270
|
+
...credentialKind !== void 0 ? { credentialKind } : {},
|
|
271
|
+
...bindingMetadata !== void 0 ? { bindingMetadata } : {},
|
|
234
272
|
isToolAllowed,
|
|
235
273
|
assertToolAllowed(tool) {
|
|
236
274
|
if (!isToolAllowed(tool)) throw new PrincipalToolNotAllowedError(tool);
|
|
@@ -250,4 +288,4 @@ async function executeAsPrincipal(options, fn) {
|
|
|
250
288
|
//#endregion
|
|
251
289
|
export { getAgentClassName as a, instanceScopedSubscriber as c, AgentConfigCollection as i, parseTenantAgentConfigOwnerId as l, executeAsPrincipal as n, getAgentTypeAliases as o, AgentConfig as r, getAgentTypeName as s, PrincipalToolNotAllowedError as t, tenantAgentConfigOwnerId as u };
|
|
252
290
|
|
|
253
|
-
//# sourceMappingURL=execute-as-principal-
|
|
291
|
+
//# sourceMappingURL=execute-as-principal-D9XLi1tk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute-as-principal-D9XLi1tk.js","names":["tenantId"],"sources":["../../src/identity.ts","../../src/config.ts","../../src/execute-as-principal.ts"],"sourcesContent":["import { getClassName, ObjectRegistry } from '@happyvertical/smrt-core';\n\n/**\n * Return the canonical agent type identifier for storage and dispatch routing.\n *\n * Uses the registry's qualified name when available and falls back to the input\n * name for dynamically defined or unregistered classes.\n */\nexport function getAgentTypeName(name: string): string {\n const registered = ObjectRegistry.getClass(name);\n return registered?.qualifiedName || registered?.name || name;\n}\n\n/**\n * Return the human-readable class name for UI and logs.\n */\nexport function getAgentClassName(name: string): string {\n const registered = ObjectRegistry.getClass(name);\n return registered?.name || getClassName(name);\n}\n\n/**\n * Return all meaningful aliases for an agent type.\n *\n * The qualified name is first so persistence lookups prefer canonical rows,\n * while the simple class name keeps legacy rows discoverable during migration.\n */\nexport function getAgentTypeAliases(name: string): string[] {\n return Array.from(\n new Set([getAgentTypeName(name), getAgentClassName(name)].filter(Boolean)),\n );\n}\n\n/**\n * Compose a per-instance dispatch subscriber identity from an agent type and an\n * optional instance key (#1890).\n *\n * Multiple durable instances of one agent class each need their own subscriber\n * name so their dispatch subscriptions and pending dispatches never collide —\n * that is what keeps two instances from double-processing each other's work.\n *\n * Returns the bare `agentType` when `instanceKey` is nullish/empty, so a\n * **singleton** agent's subscriber is byte-for-byte unchanged (the N=1 default).\n * When a key is present the identity is `` `${agentType}#${instanceKey}` `` — a\n * stable, reversible composition (the type never contains `#`).\n */\nexport function instanceScopedSubscriber(\n agentType: string,\n instanceKey?: string | null,\n): string {\n return instanceKey ? `${agentType}#${instanceKey}` : agentType;\n}\n\n/**\n * The `agent_configs.agent_id` that owns a tenant-bound agent's slot config\n * when the binding has no persisted Agent row: `<tenantId>:<agentType>`,\n * with the type canonicalized through {@link getAgentTypeName} (qualified\n * `@scope/package:Class` when the class is registered).\n *\n * `serializeResolvedAgent()` gives a resolved agent this id, and the admin\n * settings panels read and save slot configs under it, so seeders, schedule\n * sync, and any other writer must compose it with this helper rather than by\n * hand. Before smrt #1092 the id used the bare class name\n * (`<tenant>:Praeco`); `repairTenantAgentConfigKeys()` moves such rows.\n */\nexport function tenantAgentConfigOwnerId(\n tenantId: string,\n agentType: string,\n): string {\n return `${tenantId}:${getAgentTypeName(agentType)}`;\n}\n\n/**\n * Split a {@link tenantAgentConfigOwnerId} for a known tenant: the stored\n * agent type after `<tenantId>:`, or null when the owner id is not\n * tenant-derived (a persona id, an Agent row id, another tenant's key).\n */\nexport function parseTenantAgentConfigOwnerId(\n ownerId: string,\n tenantId: string,\n): string | null {\n if (!tenantId) return null;\n const prefix = `${tenantId}:`;\n if (!ownerId.startsWith(prefix)) return null;\n const agentType = ownerId.slice(prefix.length);\n return agentType || null;\n}\n","/**\n * AgentConfig - Persistent configuration storage for agents\n *\n * This module provides database-backed configuration for agents,\n * enabling consuming apps to persist agent settings.\n *\n * @module\n */\n\nimport {\n field,\n type SmrtClassOptions,\n SmrtCollection,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport {\n queryGlobal,\n queryWithGlobals,\n TenantScoped,\n tenantId,\n} from '@happyvertical/smrt-tenancy';\nimport { getAgentTypeName } from './identity.js';\n\n/**\n * AgentConfig stores agent configuration in the database\n *\n * Each config record maps to a UI slot for an agent configuration owner:\n * - agentId: The durable config owner ID (persona ID for persona-backed\n * instances; Agent STI row ID for legacy/singleton instances)\n * - agentClass: The canonical agent type (qualified name when available)\n * - slotId: The configuration slot (e.g., 'sources', 'settings')\n * - configData: JSON object containing the configuration\n *\n * @example\n * ```typescript\n * // Save config for an agent slot\n * const config = new AgentConfig({\n * agentId: agent.id,\n * agentClass: 'Praeco',\n * slotId: 'sources',\n * configData: { scrapers: ['civicweb', 'govstack'] },\n * db: options.db\n * });\n * await config.initialize();\n * await config.save();\n * ```\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'agent_configs',\n api: { include: ['list', 'get', 'create', 'update', 'delete'] },\n mcp: { include: ['list', 'get'] },\n cli: { skipApiCheck: true },\n})\nexport class AgentConfig extends SmrtObject { static __smrtPackage__ = \"@happyvertical/smrt-agents\";\n /**\n * Tenant ID for multi-tenant isolation\n * Nullable to support both tenant-scoped and global agent configs\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Durable configuration owner ID.\n *\n * The database column retains the historical `agent_id` name for backward\n * compatibility. Persona-backed runtimes store their `AgentPersona.id` here;\n * legacy runtimes store the persisted Agent STI row id.\n */\n @field({ type: 'text' })\n agentId: string = '';\n\n /**\n * Canonical agent type for this config (qualified name when available)\n */\n @field({ type: 'text' })\n agentClass: string = '';\n\n /**\n * UI slot ID (e.g., 'sources', 'settings', 'reports')\n */\n @field({ type: 'text' })\n slotId: string = '';\n\n /**\n * Configuration data stored as JSON\n *\n * Sensitive (#1540) for backward compatibility with legacy blobs, so this is\n * excluded from generated API/MCP responses and rejected as a `where` filter\n * key. New settings schemas must keep credentials in a dedicated secrets\n * service rather than this field.\n */\n @field({ type: 'json', sensitive: true })\n configData: Record<string, unknown> = {};\n\n /**\n * Schema version for future migrations\n */\n @field({ type: 'integer' })\n schemaVersion: number = 1;\n\n /**\n * Load all configs for a specific agent\n *\n * @param agentId - Agent instance ID\n * @param options - Database options\n * @returns Map of slotId → configData\n */\n static async forAgent(\n agentId: string,\n options: SmrtClassOptions,\n ): Promise<Map<string, Record<string, unknown>>> {\n const configsByAgent = await AgentConfig.forAgents([agentId], options);\n return configsByAgent.get(agentId) ?? new Map();\n }\n\n /**\n * Load configs for multiple agents in a single query.\n *\n * @param agentIds - Agent instance IDs\n * @param options - Database options\n * @returns Map of agentId -> (slotId -> configData)\n */\n static async forAgents(\n agentIds: string[],\n options: SmrtClassOptions,\n ): Promise<Map<string, Map<string, Record<string, unknown>>>> {\n const configsByAgent = new Map<\n string,\n Map<string, Record<string, unknown>>\n >();\n if (agentIds.length === 0) {\n return configsByAgent;\n }\n\n const collection = await AgentConfigCollection.create(options);\n const configs = await collection.list({\n where: { 'agentId in': agentIds },\n });\n\n for (const config of configs) {\n if (!configsByAgent.has(config.agentId)) {\n configsByAgent.set(config.agentId, new Map());\n }\n configsByAgent.get(config.agentId)?.set(config.slotId, config.configData);\n }\n\n return configsByAgent;\n }\n\n /**\n * Load config for a specific agent and slot\n *\n * @param agentId - Agent instance ID\n * @param slotId - UI slot ID\n * @param options - Database options\n * @returns Config data or undefined if not found\n */\n static async forSlot(\n agentId: string,\n slotId: string,\n options: SmrtClassOptions,\n ): Promise<Record<string, unknown> | undefined> {\n const collection = await AgentConfigCollection.create(options);\n const configs = await collection.list({\n where: { agentId, slotId },\n limit: 1,\n });\n return configs[0]?.configData;\n }\n\n /**\n * Save or update config for an agent slot\n *\n * @param data - Config data including agentId, agentClass, slotId, configData\n * @param options - Database options\n * @returns Saved AgentConfig instance\n */\n static async saveSlot(\n data: {\n agentId: string;\n agentClass: string;\n slotId: string;\n configData: Record<string, unknown>;\n },\n options: SmrtClassOptions,\n ): Promise<AgentConfig> {\n const normalizedAgentClass = getAgentTypeName(data.agentClass);\n const collection = await AgentConfigCollection.create(options);\n\n // Check for existing config using list with where clause\n const existingConfigs = await collection.list({\n where: { agentId: data.agentId, slotId: data.slotId },\n limit: 1,\n });\n\n if (existingConfigs.length > 0) {\n // Update existing\n const existing = existingConfigs[0];\n existing.configData = data.configData;\n existing.agentClass = normalizedAgentClass;\n await existing.save();\n return existing;\n }\n\n // Create new\n const config = await collection.create({\n agentId: data.agentId,\n agentClass: normalizedAgentClass,\n slotId: data.slotId,\n configData: data.configData,\n slug: `${data.agentId}-${data.slotId}`,\n });\n await config.save();\n return config;\n }\n}\n\n/**\n * Collection for AgentConfig objects\n */\nexport class AgentConfigCollection extends SmrtCollection<AgentConfig> {\n static readonly _itemClass = AgentConfig;\n\n /**\n * Find all configs for a specific tenant\n * @param tenantId - Tenant ID to filter by\n * @returns Array of AgentConfig objects for the tenant\n */\n async findByTenant(tenantId: string): Promise<AgentConfig[]> {\n return this.list({ where: { tenantId } });\n }\n\n /**\n * Find all global configs (not associated with any tenant).\n *\n * Routes through the shared tenant-global helper so it does not throw under\n * an active tenant context (an explicit `tenant_id IS NULL` filter would be\n * flagged as an isolation violation). (#1600)\n *\n * @returns Array of global AgentConfig objects\n */\n async findGlobal(): Promise<AgentConfig[]> {\n return queryGlobal<AgentConfig>(this);\n }\n\n /**\n * Find configs for a tenant including global configs.\n *\n * Fails closed if an active tenant context requests a different tenant's\n * rows; the admin/system path keeps the cross-tenant capability. (#1600)\n *\n * @param tenantId - Tenant ID to include\n * @returns Array of AgentConfig objects for the tenant and global configs\n */\n async findWithGlobals(tenantId: string): Promise<AgentConfig[]> {\n return queryWithGlobals<AgentConfig>(\n this,\n tenantId,\n 'AgentConfig.findWithGlobals',\n );\n }\n}\n","/**\n * ExecuteAsPrincipal — run an agent's work AS its persona's bound user.\n *\n * This is deliberately NOT a new authorization layer. It reuses the framework's\n * existing principal-context machinery:\n *\n * - {@link withPrincipalPermissionContext} resolves the bound user's *live*\n * permission set (the standard {@link PermissionResolver} cascade) and\n * publishes `(smrt.user_id, smrt.tenant_id, smrt.permissions[])` onto the DB\n * session. With Postgres RLS enabled, the manifest-derived policies then bound\n * every query the agent makes per-`(table, action)` and per-tenant — through\n * any door (in-process \"side door\", REST, MCP), with no per-call re-checking.\n *\n * - Because RLS is Postgres-only and opt-in, the exec/tool seam must ALSO assert\n * the catalog permission for the `(collection, action)` when RLS is off\n * (SQLite/dev). {@link PrincipalRun.assertOperation} wraps\n * `assertOperationPermission` for exactly that, so the authority bound holds\n * on every adapter.\n *\n * The effective authority of an agent action is therefore:\n *\n * bound-user RBAC ∩ agent-class capability ceiling ∩ persona allowedTools\n *\n * where the RBAC half is enforced at the data layer (RLS) or the catalog seam\n * (`assertOperation`), and the tool half is enforced by\n * {@link PrincipalRun.assertToolAllowed} against `allowedTools` — which a\n * resolved persona has already intersected with the `TenantAgent` ceiling.\n *\n * Actions audit as on-behalf-of the originating user (see {@link PrincipalAuditEntry}).\n *\n * @packageDocumentation\n */\n\nimport { createLogger, type Logger } from '@happyvertical/logger';\nimport type { SmrtClassOptions } from '@happyvertical/smrt-core';\nimport {\n assertOperationPermission,\n type OperationPermissionCollectionInput,\n type OperationPermissionDecision,\n type PermissionResolver,\n type SessionPermissionRuntimeContext,\n withPrincipalPermissionContext,\n} from '@happyvertical/smrt-users';\n\n/** JSON-safe value carried in {@link PrincipalBinding.bindingMetadata}. */\nexport type PrincipalBindingJsonValue =\n | null\n | boolean\n | number\n | string\n | PrincipalBindingJsonValue[]\n | { [key: string]: PrincipalBindingJsonValue };\n\n/**\n * How the credential behind a principal run authenticated. Extensible: hosts\n * may supply their own kind string. Descriptive only — it never grants or\n * narrows authority.\n */\nexport type PrincipalCredentialKind =\n | 'session'\n | 'device'\n | 'api-key'\n | 'oauth'\n | 'service'\n | (string & {});\n\n/**\n * The bound principal an agent runs as. A resolved persona structurally\n * satisfies this once its optional `runAsUserId` has been narrowed to a\n * concrete id — `allowedTools` on a `ResolvedPersona` is already the persona's\n * tools intersected with the `TenantAgent` capability ceiling.\n */\nexport interface PrincipalBinding {\n /** The user whose live permissions bound this execution. Required. */\n runAsUserId: string;\n /** Tenant the principal acts within. */\n tenantId: string | null;\n /**\n * The persona's tool allow-list (already capped by the agent-class ceiling).\n * This is a **fail-closed** whitelist, mirroring\n * `@happyvertical/smrt-chat`'s `AgentSession.isToolAllowed()` (S5 #1392): an\n * absent (`undefined`) or empty allow-list permits **NO** tools, never all of\n * them, so forgetting to pass it can only tighten authority. Resolved personas\n * always provide a concrete `string[]`.\n */\n allowedTools?: string[];\n /** Optional acting `Bot` profile id, recorded in the audit entry. */\n actsAsProfileId?: string | null;\n /**\n * Id of the session this run was bound from. **Server-set only**: the host\n * supplies it from its own verified auth state, never from browser or user\n * input. Surfaces as `run.sessionId` and `run.context.sessionId`; absent\n * means `null`. It is an unverified label, not an authenticated session, and\n * is NOT published to the `smrt.session_id` RLS GUC. A passthrough — it never affects permissions or\n * `allowedTools`.\n */\n sessionId?: string | null;\n /**\n * How the run authenticated (e.g. `'device'`). **Server-set only**, same\n * rule as `sessionId`. Surfaces as `run.credentialKind`; never affects\n * permissions or `allowedTools`.\n */\n credentialKind?: PrincipalCredentialKind;\n /**\n * Generic server-set facts about how the run was bound, passed to\n * `run.bindingMetadata` unchanged (deep-cloned and frozen, so a run cannot\n * mutate the binding). Use this instead of smuggling identity through\n * `allowedTools`. Never affects permissions or `allowedTools`.\n */\n bindingMetadata?: Record<string, PrincipalBindingJsonValue>;\n}\n\n/**\n * A single audit record describing an agent action performed by the bound\n * principal (`actorUserId`) on behalf of the originating user\n * (`onBehalfOfUserId`).\n */\nexport interface PrincipalAuditEntry {\n /** Action label, e.g. `'agent.run'`. */\n action: string;\n /** The persona's bound user the work ran as. */\n actorUserId: string;\n /** The user who triggered the agent, if known. */\n onBehalfOfUserId: string | null;\n /** Tenant the action ran within. */\n tenantId: string | null;\n /** Canonical agent class, when the caller supplies it. */\n agentClass?: string;\n /** Acting profile id, when the persona sets one. */\n actsAsProfileId?: string | null;\n /** Free-form additional context. */\n metadata?: Record<string, unknown>;\n}\n\n/**\n * Sink that records a {@link PrincipalAuditEntry}. Provide one to persist audit\n * rows (e.g. via `AuditLog.record`); when omitted, the entry is emitted as a\n * structured log line.\n */\nexport type PrincipalAuditSink = (\n entry: PrincipalAuditEntry,\n) => void | Promise<void>;\n\n/**\n * Options for {@link executeAsPrincipal}.\n */\nexport interface ExecuteAsPrincipalOptions extends SmrtClassOptions {\n /** The bound principal to run as. */\n principal: PrincipalBinding;\n /** The originating user the action is performed on behalf of (for audit). */\n onBehalfOfUserId?: string | null;\n /** Canonical agent class, recorded in the audit entry. */\n agentClass?: string;\n /** Audit action label. Defaults to `'agent.run'`. */\n action?: string;\n /** Extra audit metadata merged into the emitted entry. */\n auditMetadata?: Record<string, unknown>;\n /**\n * Pre-resolved permission slugs. When omitted, the principal's permissions\n * are resolved live so role changes reflect on the next execution.\n */\n permissions?: string[];\n /** Reuse an initialized resolver across executions. */\n resolver?: PermissionResolver;\n /** Opt into Postgres RLS transaction wrapping (defaults to package config). */\n postgresRls?: boolean;\n /**\n * Enter tenant context so tenant auto-filtering applies on every adapter.\n * Defaults to `true` whenever the principal has a tenant.\n */\n enterTenantContext?: boolean;\n /** Audit sink. Defaults to a structured log line. */\n audit?: PrincipalAuditSink;\n /** Logger used for the default audit sink. */\n logger?: Logger;\n}\n\n/**\n * Thrown when the persona attempts a tool outside its `allowedTools`.\n */\nexport class PrincipalToolNotAllowedError extends Error {\n readonly tool: string;\n readonly status = 403;\n\n constructor(tool: string) {\n super(`Tool '${tool}' is not permitted for this persona.`);\n this.name = 'PrincipalToolNotAllowedError';\n this.tool = tool;\n }\n}\n\n/**\n * The handle passed to the {@link executeAsPrincipal} body. Its\n * session-permission {@link context} is already published for the principal, so\n * data operations are bounded by RLS on Postgres. The assertions enforce the\n * remaining two authority dimensions.\n */\nexport interface PrincipalRun {\n /** The published session-permission runtime context for the principal. */\n context: SessionPermissionRuntimeContext;\n /** The principal's published (snapshot) permission slugs. */\n permissions: string[];\n /**\n * Present only when the caller bound this run to an explicit `permissions`\n * snapshot (rather than live resolution). Delegation carries it forward as a\n * ceiling so a narrowed run cannot widen through a worker (#2978).\n */\n permissionSnapshot?: readonly string[];\n /**\n * The effective, fail-closed tool allow-list — always a concrete array (an\n * absent binding allow-list normalizes to `[]`, i.e. no tools).\n */\n allowedTools: string[];\n /** Server-set session id the run was bound from (`null` when none). */\n sessionId: string | null;\n /** Server-set credential kind, when the binding supplied one. */\n credentialKind?: PrincipalCredentialKind;\n /**\n * Server-set binding metadata: a frozen deep copy of\n * {@link PrincipalBinding.bindingMetadata}, present only when supplied.\n */\n bindingMetadata?: Readonly<Record<string, PrincipalBindingJsonValue>>;\n /**\n * Whether `tool` is within the fail-closed allow-list. An empty allow-list,\n * or an empty/non-string tool name, permits nothing.\n */\n isToolAllowed(tool: string): boolean;\n /** Throw {@link PrincipalToolNotAllowedError} unless `tool` is allowed. */\n assertToolAllowed(tool: string): void;\n /**\n * Assert the principal holds the catalog permission for `(collection,\n * action)`, authorizing against the **published** principal set\n * (`context.permissionSet`) — the same snapshot the RLS session enforces — so\n * the bound is adapter-independent. This is the door-agnostic teeth for the\n * RLS-off adapters; under Postgres RLS it is a redundant (but harmless)\n * second gate. Throws `OperationPermissionError` on denial.\n */\n assertOperation(\n collection: OperationPermissionCollectionInput,\n action: string,\n extraOptions?: SmrtClassOptions,\n ): Promise<OperationPermissionDecision>;\n}\n\n/**\n * Deep-clone and freeze a JSON-only value. Rejects non-JSON values (Date, Map,\n * typed arrays, functions, class instances, cycles) up front with a clear\n * error rather than failing mid-run.\n */\nfunction cloneJsonFrozen(\n value: unknown,\n path: string,\n seen: Set<object>,\n): PrincipalBindingJsonValue {\n if (value === null) return null;\n const t = typeof value;\n if (t === 'string' || t === 'boolean') return value as string | boolean;\n if (t === 'number') {\n if (!Number.isFinite(value as number)) {\n throw new TypeError(\n `PrincipalBinding.bindingMetadata${path} must be a finite number`,\n );\n }\n return value as number;\n }\n if (t === 'object') {\n const obj = value as object;\n if (seen.has(obj)) {\n throw new TypeError(\n `PrincipalBinding.bindingMetadata${path} contains a cycle`,\n );\n }\n seen.add(obj);\n let out: PrincipalBindingJsonValue;\n if (Array.isArray(obj)) {\n out = obj.map((v, i) => cloneJsonFrozen(v, `${path}[${i}]`, seen));\n } else {\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) {\n throw new TypeError(\n `PrincipalBinding.bindingMetadata${path} must be JSON-safe (got ${\n (obj as object).constructor?.name ?? 'non-plain object'\n })`,\n );\n }\n const rec: { [key: string]: PrincipalBindingJsonValue } = {};\n for (const [k, v] of Object.entries(obj)) {\n // defineProperty keeps a `__proto__` key an own data property rather\n // than invoking the prototype setter.\n Object.defineProperty(rec, k, {\n value: cloneJsonFrozen(v, `${path}.${k}`, seen),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n out = rec;\n }\n seen.delete(obj);\n return Object.freeze(out) as PrincipalBindingJsonValue;\n }\n throw new TypeError(\n `PrincipalBinding.bindingMetadata${path} must be JSON-safe (got ${t})`,\n );\n}\n\nasync function emitAudit(\n entry: PrincipalAuditEntry,\n audit: PrincipalAuditSink | undefined,\n logger: Logger | undefined,\n): Promise<void> {\n if (audit) {\n await audit(entry);\n return;\n }\n const log = logger ?? createLogger({ level: 'info' });\n log.info('agent action executed on behalf of originating user', {\n ...entry,\n });\n}\n\n/**\n * Run `fn` AS the persona's bound principal.\n *\n * Resolves the bound user's live permissions, publishes them onto the DB\n * session (so Postgres RLS bounds every query per-`(table, action)`), emits an\n * on-behalf-of audit entry, and hands `fn` a {@link PrincipalRun} whose\n * assertions enforce the persona tool ceiling and the RLS-off catalog gate.\n *\n * @example\n * ```typescript\n * await executeAsPrincipal(\n * {\n * db,\n * principal: {\n * runAsUserId: persona.runAsUserId,\n * tenantId: persona.tenantId,\n * allowedTools: persona.allowedTools,\n * },\n * onBehalfOfUserId: triggeringUserId,\n * agentClass: persona.agentClass,\n * },\n * async (run) => {\n * run.assertToolAllowed('articles.publish');\n * await run.assertOperation('articles', 'update');\n * await agent.run();\n * },\n * );\n * ```\n */\nexport async function executeAsPrincipal<T>(\n options: ExecuteAsPrincipalOptions,\n fn: (run: PrincipalRun) => Promise<T>,\n): Promise<T> {\n const {\n principal,\n onBehalfOfUserId = null,\n agentClass,\n action = 'agent.run',\n auditMetadata,\n permissions,\n resolver,\n postgresRls,\n enterTenantContext,\n audit,\n logger,\n ...smrtOptions\n } = options;\n\n const { runAsUserId, tenantId, actsAsProfileId = null } = principal;\n\n // Fail-closed tool allow-list (mirrors chat's AgentSession, S5 #1392): an\n // absent or non-array binding allow-list normalizes to `[]` — no tools — so a\n // missing ceiling can only tighten authority, never open it up.\n const toolWhitelist = Array.isArray(principal.allowedTools)\n ? principal.allowedTools\n : [];\n const isToolAllowed = (tool: string): boolean =>\n typeof tool === 'string' && tool.length > 0 && toolWhitelist.includes(tool);\n\n const boundSessionId =\n typeof principal.sessionId === 'string' && principal.sessionId.length > 0\n ? principal.sessionId\n : null;\n const credentialKind =\n typeof principal.credentialKind === 'string' &&\n principal.credentialKind.length > 0\n ? principal.credentialKind\n : undefined;\n const bindingMetadata =\n principal.bindingMetadata !== undefined &&\n principal.bindingMetadata !== null\n ? (cloneJsonFrozen(principal.bindingMetadata, '', new Set()) as Readonly<\n Record<string, PrincipalBindingJsonValue>\n >)\n : undefined;\n\n await emitAudit(\n {\n action,\n actorUserId: runAsUserId,\n onBehalfOfUserId,\n tenantId,\n agentClass,\n actsAsProfileId,\n metadata: auditMetadata,\n },\n audit,\n logger,\n );\n\n return withPrincipalPermissionContext(\n {\n ...smrtOptions,\n userId: runAsUserId,\n tenantId,\n sessionId: boundSessionId,\n permissions,\n resolver,\n postgresRls,\n enterTenantContext: enterTenantContext ?? tenantId !== null,\n },\n async (context) => {\n const run: PrincipalRun = {\n context,\n permissions: context.permissions,\n ...(permissions !== undefined\n ? { permissionSnapshot: [...context.permissions] }\n : {}),\n allowedTools: toolWhitelist,\n sessionId: boundSessionId,\n ...(credentialKind !== undefined ? { credentialKind } : {}),\n ...(bindingMetadata !== undefined ? { bindingMetadata } : {}),\n isToolAllowed,\n assertToolAllowed(tool: string): void {\n if (!isToolAllowed(tool)) {\n throw new PrincipalToolNotAllowedError(tool);\n }\n },\n async assertOperation(\n collection: OperationPermissionCollectionInput,\n operationAction: string,\n extraOptions?: SmrtClassOptions,\n ): Promise<OperationPermissionDecision> {\n return assertOperationPermission({\n ...smrtOptions,\n ...extraOptions,\n collection,\n action: operationAction,\n // Authorize against the PUBLISHED principal set (the same snapshot\n // Postgres RLS enforces for this context), not a fresh live\n // re-resolve — keeps the RLS-off gate adapter-independent.\n permissionSet: context.permissionSet,\n });\n },\n };\n return fn(run);\n },\n );\n}\n"],"mappings":";;;;;AAQO,SAAS,iBAAiB,MAAsB;CACrD,MAAM,aAAa,eAAe,SAAS,IAAI;CAC/C,OAAO,YAAY,iBAAiB,YAAY,QAAQ;AAC1D;AAKO,SAAS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IAAI;CAE5E,MAAM,iBACJ,OAAO,UAAU,cAAc,YAAY,UAAU,UAAU,SAAS,IACpE,UAAU,YACV;CACN,MAAM,iBACJ,OAAO,UAAU,mBAAmB,YACpC,UAAU,eAAe,SAAS,IAC9B,UAAU,iBACV,KAAA;CACN,MAAM,kBACJ,UAAU,oBAAoB,KAAA,KAC9B,UAAU,oBAAoB,OACzB,gBAAgB,UAAU,iBAAiB,oBAAI,IAAI,IAAI,CAAC,IAGzD,KAAA;CAEN,MAAM,UACJ;EACE;EACA,aAAa;EACb;EACA;EACA;EACA;EACA,UAAU;CACZ,GACA,OACA,MACF;CAEA,OAAO,+BACL;EACE,GAAG;EACH,QAAQ;EACR;EACA,WAAW;EACX;EACA;EACA;EACA,oBAAoB,sBAAsB,aAAa;CACzD,GACA,OAAO,YAAY;EAkCjB,OAAO,GAAG;GAhCR;GACA,aAAa,QAAQ;GACrB,GAAI,gBAAgB,KAAA,IAChB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,WAAW,EAAE,IAC/C,CAAC;GACL,cAAc;GACd,WAAW;GACX,GAAI,mBAAmB,KAAA,IAAY,EAAE,eAAe,IAAI,CAAC;GACzD,GAAI,oBAAoB,KAAA,IAAY,EAAE,gBAAgB,IAAI,CAAC;GAC3D;GACA,kBAAkB,MAAoB;IACpC,IAAI,CAAC,cAAc,IAAI,GACrB,MAAM,IAAI,6BAA6B,IAAI;GAE/C;GACA,MAAM,gBACJ,YACA,iBACA,cACsC;IACtC,OAAO,0BAA0B;KAC/B,GAAG;KACH,GAAG;KACH;KACA,QAAQ;KAIR,eAAe,QAAQ;IACzB,CAAC;GACH;EAEQ,CAAG;CACf,CACF;AACF"}
|
|
@@ -33,6 +33,16 @@
|
|
|
33
33
|
import { type Logger } from '@happyvertical/logger';
|
|
34
34
|
import type { SmrtClassOptions } from '@happyvertical/smrt-core';
|
|
35
35
|
import { type OperationPermissionCollectionInput, type OperationPermissionDecision, type PermissionResolver, type SessionPermissionRuntimeContext } from '@happyvertical/smrt-users';
|
|
36
|
+
/** JSON-safe value carried in {@link PrincipalBinding.bindingMetadata}. */
|
|
37
|
+
export type PrincipalBindingJsonValue = null | boolean | number | string | PrincipalBindingJsonValue[] | {
|
|
38
|
+
[key: string]: PrincipalBindingJsonValue;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* How the credential behind a principal run authenticated. Extensible: hosts
|
|
42
|
+
* may supply their own kind string. Descriptive only — it never grants or
|
|
43
|
+
* narrows authority.
|
|
44
|
+
*/
|
|
45
|
+
export type PrincipalCredentialKind = 'session' | 'device' | 'api-key' | 'oauth' | 'service' | (string & {});
|
|
36
46
|
/**
|
|
37
47
|
* The bound principal an agent runs as. A resolved persona structurally
|
|
38
48
|
* satisfies this once its optional `runAsUserId` has been narrowed to a
|
|
@@ -55,6 +65,28 @@ export interface PrincipalBinding {
|
|
|
55
65
|
allowedTools?: string[];
|
|
56
66
|
/** Optional acting `Bot` profile id, recorded in the audit entry. */
|
|
57
67
|
actsAsProfileId?: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* Id of the session this run was bound from. **Server-set only**: the host
|
|
70
|
+
* supplies it from its own verified auth state, never from browser or user
|
|
71
|
+
* input. Surfaces as `run.sessionId` and `run.context.sessionId`; absent
|
|
72
|
+
* means `null`. It is an unverified label, not an authenticated session, and
|
|
73
|
+
* is NOT published to the `smrt.session_id` RLS GUC. A passthrough — it never affects permissions or
|
|
74
|
+
* `allowedTools`.
|
|
75
|
+
*/
|
|
76
|
+
sessionId?: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* How the run authenticated (e.g. `'device'`). **Server-set only**, same
|
|
79
|
+
* rule as `sessionId`. Surfaces as `run.credentialKind`; never affects
|
|
80
|
+
* permissions or `allowedTools`.
|
|
81
|
+
*/
|
|
82
|
+
credentialKind?: PrincipalCredentialKind;
|
|
83
|
+
/**
|
|
84
|
+
* Generic server-set facts about how the run was bound, passed to
|
|
85
|
+
* `run.bindingMetadata` unchanged (deep-cloned and frozen, so a run cannot
|
|
86
|
+
* mutate the binding). Use this instead of smuggling identity through
|
|
87
|
+
* `allowedTools`. Never affects permissions or `allowedTools`.
|
|
88
|
+
*/
|
|
89
|
+
bindingMetadata?: Record<string, PrincipalBindingJsonValue>;
|
|
58
90
|
}
|
|
59
91
|
/**
|
|
60
92
|
* A single audit record describing an agent action performed by the bound
|
|
@@ -146,6 +178,15 @@ export interface PrincipalRun {
|
|
|
146
178
|
* absent binding allow-list normalizes to `[]`, i.e. no tools).
|
|
147
179
|
*/
|
|
148
180
|
allowedTools: string[];
|
|
181
|
+
/** Server-set session id the run was bound from (`null` when none). */
|
|
182
|
+
sessionId: string | null;
|
|
183
|
+
/** Server-set credential kind, when the binding supplied one. */
|
|
184
|
+
credentialKind?: PrincipalCredentialKind;
|
|
185
|
+
/**
|
|
186
|
+
* Server-set binding metadata: a frozen deep copy of
|
|
187
|
+
* {@link PrincipalBinding.bindingMetadata}, present only when supplied.
|
|
188
|
+
*/
|
|
189
|
+
bindingMetadata?: Readonly<Record<string, PrincipalBindingJsonValue>>;
|
|
149
190
|
/**
|
|
150
191
|
* Whether `tool` is within the fail-closed allow-list. An empty allow-list,
|
|
151
192
|
* or an empty/non-string tool name, permits nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-as-principal.d.ts","sourceRoot":"","sources":["../src/execute-as-principal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAEL,KAAK,kCAAkC,EACvC,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,KAAK,+BAA+B,EAErC,MAAM,2BAA2B,CAAC;AAEnC;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sEAAsE;IACtE,WAAW,EAAE,MAA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C,CAAC,GACpC,OAAO,CAAC,CAAC,CAAC,CA0GZ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -72,7 +72,7 @@ export { type AgentAIOptions, type AgentAISecretFallback, type ResolvedAgentAICo
|
|
|
72
72
|
export { AgentConfig, AgentConfigCollection } from './config.js';
|
|
73
73
|
export { createDataSurfaceQueryFingerprint, createDataSurfaceTools, DATA_DISCOVER_FUNCTION_NAME, DATA_DISCOVER_TOOL_SLUG, DATA_INSPECT_FUNCTION_NAME, DATA_INSPECT_TOOL_SLUG, DATA_QUERY_FUNCTION_NAME, DATA_QUERY_TOOL_PARAMETERS, DATA_QUERY_TOOL_SLUG, type DataSurfaceAction, DataSurfaceActionDeniedError, type DataSurfaceAuditEntry, type DataSurfaceAuditSink, type DataSurfaceCatalogContext, DataSurfaceDeadlineError, type DataSurfaceDefinition, type DataSurfaceDenialReason, type DataSurfaceDeniedEntry, DataSurfaceDeniedError, type DataSurfaceDeniedSink, type DataSurfaceDiscoverDetail, type DataSurfaceExecutionContext, type DataSurfaceExecutor, type DataSurfaceExecutorResult, type DataSurfaceFailureEntry, type DataSurfaceFailureSink, type DataSurfaceField, type DataSurfaceFieldMetadata, type DataSurfacePrincipal, DataSurfaceQueryError, DataSurfaceRequestError, DataSurfaceResultOrderError, type DataSurfaceRowCountHint, type DataSurfaceSchema, type DataSurfaceSummary, type DataSurfaceToolsOptions, DEFAULT_DATA_SURFACE_DEADLINE_MS, MAX_DATA_SURFACE_DEADLINE_MS, MAX_DATA_SURFACE_ROW_COUNT_HINT_CHARS, MAX_DATA_SURFACE_SUMMARY_DESCRIPTION_CHARS, normalizeDataSurfaceRowCountHint, } from './data-surface.js';
|
|
74
74
|
export { assertPrincipalNotWidened, assertWithinDelegationDepth, DelegationDepthExceededError, type DelegationEnvelope, type DeriveDelegationEnvelopeOptions, deriveDelegationEnvelope, MAX_DELEGATION_DEPTH, PrincipalWideningError, type RequestedPrincipal, type RootDelegationEnvelopeOptions, rootDelegationEnvelope, } from './delegation.js';
|
|
75
|
-
export { type ExecuteAsPrincipalOptions, executeAsPrincipal, type PrincipalAuditEntry, type PrincipalAuditSink, type PrincipalBinding, type PrincipalRun, PrincipalToolNotAllowedError, } from './execute-as-principal.js';
|
|
75
|
+
export { type ExecuteAsPrincipalOptions, executeAsPrincipal, type PrincipalAuditEntry, type PrincipalAuditSink, type PrincipalBinding, type PrincipalBindingJsonValue, type PrincipalCredentialKind, type PrincipalRun, PrincipalToolNotAllowedError, } from './execute-as-principal.js';
|
|
76
76
|
export { getAgentClassName, getAgentTypeName, instanceScopedSubscriber, parseTenantAgentConfigOwnerId, tenantAgentConfigOwnerId, } from './identity.js';
|
|
77
77
|
export type { AgentWithInterestsOptions, AsyncQualifierFn, InterestFilter, InterestHandlerFn, InterestOptions, InterestResult, ObjectFilter, ObjectInterestConfig, QueryFn, } from './interests.js';
|
|
78
78
|
export { mergeFilters, normalizeSort } from './interests.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAKH,OAAO,wBAAwB,CAAC;AAIhC,YAAY,EACV,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,E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