@theokit/agents 13.0.0-next.8 → 13.0.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +1707 -0
  2. package/README.md +31 -0
  3. package/dist/{agent-compiler-C2jIZ4CZ.d.ts → agent-compiler-B0hb6HCo.d.ts} +182 -26
  4. package/dist/ask.d.ts +1 -0
  5. package/dist/auth.d.ts +148 -1
  6. package/dist/auth.js +36 -0
  7. package/dist/auth.js.map +1 -1
  8. package/dist/{bridge-entry-BJ86tO6e.d.ts → bridge-entry-DBkqwe6b.d.ts} +72 -6
  9. package/dist/bridge.d.ts +6 -4
  10. package/dist/bridge.js +9 -4
  11. package/dist/{chunk-3GQJ2BHT.js → chunk-G7QBDGZ4.js} +93 -18
  12. package/dist/chunk-G7QBDGZ4.js.map +1 -0
  13. package/dist/chunk-HGVT4VCE.js +97 -0
  14. package/dist/chunk-HGVT4VCE.js.map +1 -0
  15. package/dist/{chunk-NZTLBLHB.js → chunk-KTQID5V3.js} +560 -342
  16. package/dist/chunk-KTQID5V3.js.map +1 -0
  17. package/dist/chunk-M5J3Q6YC.js +17 -0
  18. package/dist/chunk-M5J3Q6YC.js.map +1 -0
  19. package/dist/{chunk-RKWCXVYG.js → chunk-MJ6FRILJ.js} +67 -5
  20. package/dist/chunk-MJ6FRILJ.js.map +1 -0
  21. package/dist/{chunk-X4IGZHOV.js → chunk-PMMOOXR6.js} +43 -8
  22. package/dist/chunk-PMMOOXR6.js.map +1 -0
  23. package/dist/chunk-U72XTMYB.js +7 -0
  24. package/dist/chunk-U72XTMYB.js.map +1 -0
  25. package/dist/client-react.d.ts +1 -0
  26. package/dist/client.d.ts +1 -0
  27. package/dist/config.d.ts +163 -36
  28. package/dist/config.js +119 -7
  29. package/dist/config.js.map +1 -1
  30. package/dist/{define-agent-WYnUlWaH.d.ts → define-agent-DhwNmdej.d.ts} +28 -153
  31. package/dist/{delegation-scoring-BrBQXvIp.d.ts → delegation-scoring-BzJEheml.d.ts} +1 -1
  32. package/dist/hooks.d.ts +0 -32
  33. package/dist/hooks.js +42 -14
  34. package/dist/hooks.js.map +1 -1
  35. package/dist/index.d.ts +191 -17
  36. package/dist/index.js +43 -5
  37. package/dist/index.js.map +1 -1
  38. package/dist/sandbox.js.map +1 -1
  39. package/dist/setting-sources-gate-DFu51i50.d.ts +278 -0
  40. package/dist/testing.d.ts +5 -2
  41. package/dist/testing.js +1 -1
  42. package/dist/tools.d.ts +4 -2
  43. package/dist/tools.js +22 -4
  44. package/dist/tools.js.map +1 -1
  45. package/dist/usage.d.ts +30 -0
  46. package/dist/usage.js +3 -0
  47. package/dist/usage.js.map +1 -1
  48. package/package.json +3 -3
  49. package/dist/chunk-3GQJ2BHT.js.map +0 -1
  50. package/dist/chunk-NZTLBLHB.js.map +0 -1
  51. package/dist/chunk-RKWCXVYG.js.map +0 -1
  52. package/dist/chunk-X4IGZHOV.js.map +0 -1
@@ -1,13 +1,14 @@
1
1
  import { ExecutionContext } from '@theokit/http';
2
2
  import { c as AgentOptions, T as ToolOptions, P as ProjectContextOptions, H as HumanInTheLoopOptions, R as ReasoningEffort, M as McpServersMap } from './types-C16Wuh9E.js';
3
- import { C as CompiledAgentOptions, a as CompiledTool, G as Guardrail, S as SkillsSelection, H as HookApprovalGate } from './agent-compiler-C2jIZ4CZ.js';
4
- import { SkillsSettings, ContextSettings, SystemPromptResolver, ModelSelection, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, CustomTool, RunEventSink, MemorySettings } from '@theokit/sdk';
5
- import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-BrBQXvIp.js';
3
+ import { a as CompiledAgentOptions, b as CompiledTool, G as Guardrail, S as SkillsSelection, H as HookApprovalGate, C as CodePlugin } from './agent-compiler-B0hb6HCo.js';
4
+ import { SkillsSettings, ContextSettings, SystemPromptResolver, ModelSelection, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, CustomTool, RunEventSink, MemorySettings, TelemetrySettings } from '@theokit/sdk';
5
+ import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-BzJEheml.js';
6
6
  import { RetryOptions } from '@theokit/sdk/retry';
7
7
  import { SandboxPosture } from '@theokit/sdk/sandbox';
8
- import { A as AgentDefinition, S as SettingSourcesSelection } from './define-agent-WYnUlWaH.js';
8
+ import { A as AgentDefinition } from './define-agent-DhwNmdej.js';
9
9
  import { z } from 'zod';
10
10
  import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
11
+ import { S as SettingSourcesSelection } from './setting-sources-gate-DFu51i50.js';
11
12
  import { WireChunk } from '@theokit/presenter/wire';
12
13
  import { TheokitAgentError } from '@theokit/sdk/errors';
13
14
 
@@ -82,6 +83,20 @@ declare function compileSkills(options: SkillsOptions): SkillsSettings;
82
83
  interface ContextWindowOptions {
83
84
  /** Maximum tokens before compaction triggers. */
84
85
  maxTokens?: number;
86
+ /**
87
+ * Per-file truncation cap in CHARACTERS (SDK default 40 000, ~10k tokens). Larger files are
88
+ * truncated head/tail with a marker.
89
+ *
90
+ * Reachable here because the surface that turns instruction discovery on is the same surface that
91
+ * decides when an instruction file gets cut: a 60 000-character `CLAUDE.md` was silently
92
+ * truncated to 40 000, and the only knob on offer was named after tokens.
93
+ */
94
+ maxBytesPerFile?: number;
95
+ /**
96
+ * Aggregate cap across all context files in CHARACTERS (SDK default 120 000). Past it,
97
+ * lower-priority sources are DROPPED — not truncated.
98
+ */
99
+ maxBytesTotal?: number;
85
100
  }
86
101
  interface CompiledContextWindow {
87
102
  /** SDK-shaped context budget passed to `Agent.create({ context })`. */
@@ -508,6 +523,35 @@ interface SdkTurnHandle {
508
523
  type SdkSendOptions = Record<string, unknown>;
509
524
  interface SdkAgentHandle {
510
525
  readonly agentId: string;
526
+ /**
527
+ * B-062 — a tool-using run that returns schema-validated output.
528
+ *
529
+ * The SDK's `agent.generate(input, { output })` "runs the agent's NORMAL tool loop (the user's
530
+ * tools run first) and then coerces the final answer into a Zod schema". It existed and this
531
+ * handle did not declare it, so a consumer of `@theokit/agents` could reach it only by importing
532
+ * `@theokit/sdk` directly — the one thing this layer's doctrine forbids.
533
+ *
534
+ * The survey that filed this concluded the capability was absent, having measured `generateObject`
535
+ * — which is the TOOLLESS path by design: it builds a transient agent whose only tool is the
536
+ * synthetic output tool. Both paths exist and answer different questions.
537
+ *
538
+ * OPTIONAL, because a caller-injected handle (tests, a custom transport) need not implement it,
539
+ * and requiring it would break every such double to add a method most of them never call.
540
+ *
541
+ * BOTH wrappers below forward it. A wrapper that rebuilds the handle silently removes every method
542
+ * it does not name, and the consumer meets the loss at runtime as "the handle has no `generate`"
543
+ * after the types said it had one. Each forward is pinned by its own mutation.
544
+ *
545
+ * It is NOT put through the output guards, stated rather than assumed: `generate` resolves to a
546
+ * validated OBJECT and those guards moderate TEXT, so running them over a serialised object would
547
+ * moderate a shape no guard was written against. Guarding the structured path needs its own
548
+ * decision about what a redaction means to a schema, and inventing one would be the gate that
549
+ * reports without gating this module already refuses to build.
550
+ */
551
+ readonly generate?: (message: string, options: {
552
+ output: unknown;
553
+ [key: string]: unknown;
554
+ }) => Promise<unknown>;
511
555
  /**
512
556
  * M91 — era `(msg: string, opts?: unknown) => unknown`.
513
557
  *
@@ -934,6 +978,17 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
934
978
  * `MemorySettings` verbatim — `{ enabled: true }` is the minimal opt-in.
935
979
  */
936
980
  memory(settings: MemorySettings): AgentBuilder<TInput, TModel, TContext, TTools>;
981
+ /**
982
+ * B-072 — emit OpenTelemetry spans for this agent's runs (`agent.send`, `llm.call`, `tool.call`,
983
+ * `memory.search`). Takes the SDK's `TelemetrySettings` verbatim; `{ enabled: true }` is the
984
+ * minimal opt-in, and content (prompts, responses, tool args) is omitted unless
985
+ * `includeContent: true` is set.
986
+ *
987
+ * Distinct from a diagnostics sink, which answers "what did this run LOG". A trace answers "where
988
+ * did this run SPEND its time, and which call was the slow one" — two questions, and the sink
989
+ * could never answer the second.
990
+ */
991
+ telemetry(settings: TelemetrySettings): AgentBuilder<TInput, TModel, TContext, TTools>;
937
992
  /**
938
993
  * Attach LIFECYCLE HOOKS in code, keyed by `HookName` — the builder-chain seam for intercepting
939
994
  * the agent loop. `pre_tool_call` may VETO a tool by returning `{ block: true, message }` before
@@ -960,8 +1015,13 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
960
1015
  * For lifecycle interception prefer {@link AgentBuilder.hooks} — a hook needs a plugin only as its
961
1016
  * transport, and `plugins()` makes the caller assemble that transport by hand. Reach for this when
962
1017
  * you genuinely have a plugin (a provider, a memory adapter, a tool-registering extension).
1018
+ *
1019
+ * NOT the Claude Code filesystem-bundle form (B-055). `[{ type: 'local', path: './p' }]` used to
1020
+ * typecheck here against `readonly unknown[]` and do nothing — the typecheck that should have
1021
+ * caught it was what let it through. A bundle is declared by living in a `plugins/` directory
1022
+ * under `.theokit/` or `.claude/`, where its `skills/` and `agents/` are discovered.
963
1023
  */
964
- plugins(list: readonly unknown[]): AgentBuilder<TInput, TModel, TContext, TTools>;
1024
+ plugins(list: readonly CodePlugin[]): AgentBuilder<TInput, TModel, TContext, TTools>;
965
1025
  /**
966
1026
  * Declare MCP (Model Context Protocol) servers available to this agent — the builder-chain
967
1027
  * equivalent of the `@MCP` class decorator. Each key is a server name; the value is its config
@@ -1403,6 +1463,12 @@ declare function mcpToolApprovals(specs: Record<string, McpApprovalSpec>): Recor
1403
1463
  */
1404
1464
  interface LoadMcpJsonOptions {
1405
1465
  onWarn?: (warning: string) => void;
1466
+ /**
1467
+ * The environment `${VAR}` references resolve against. Injected rather than read from
1468
+ * `process.env` so a test can prove the expansion without mutating the process it runs in —
1469
+ * the convention `diagnostic-sink.ts` and `transcript-root-hint.ts` already follow.
1470
+ */
1471
+ env?: Record<string, string | undefined>;
1406
1472
  }
1407
1473
  /**
1408
1474
  * Raised when `<cwd>/.mcp.json` exists but cannot be read, is not valid JSON, or does not match the
@@ -1573,4 +1639,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
1573
1639
  register(app: PluginApp): void;
1574
1640
  };
1575
1641
 
1576
- export { compileProjectContext as $, type AgentManifestEntry as A, type BeforeToolCallContext as B, type ContextWindowOptions as C, type DefinitionOrThunk as D, type EphemeralAgent as E, type McpSelection as F, type SdkAgentHandle as G, type HitlDecision as H, type SdkMessage as I, type SdkSendOptions as J, type SdkTurnHandle as K, type LLMCallContext as L, type McpApprovalSpec as M, type Segment as N, type ShouldAutoApproveOptions as O, type ProcessInputContext as P, type ToolHooks as Q, type ToolHooksPlugin as R, type SkillsOptions as S, type ToolCallVeto as T, agentsPlugin as U, applyPosture as V, WRITE_SCOPED_TOOLS as W, buildModelSelection as X, compileAgentModule as Y, compileContextWindow as Z, compileLoadedAgentModule as _, type ApprovalPosture as a, compileSkills as a0, createAgentExecutionContext as a1, createApiErrorHandler as a2, createSdkAgentStream as a3, createThinkTagExtractor as a4, createToolHooksPlugin as a5, extractThinkTagStream as a6, generateAgentManifest as a7, generateAgentRoutes as a8, isAgentContext as a9, loadMcpJson as aa, mcpRegistry as ab, mcpToolApprovals as ac, projectContextMetadataOnlyKnobs as ad, reasoningEffortOf as ae, resolveMcpServers as af, runWithApiErrorHandling as ag, shouldAutoApprove as ah, toAgentFactory as ai, translateSdkEvent as aj, withClockCap as ak, withEphemeralAgent as al, type AgentModule as b, APPROVAL_MODES as c, type AfterToolCallContext as d, AgentBuilder as e, AgentDefinitionError as f, type AgentExecutionContext as g, type AgentManifest as h, type AgentManifestSource as i, type AgentManifestTool as j, type AgentRoute as k, type AgentRouteContext as l, type AgentRunInfo as m, type AgentsPluginOptions as n, type ApiErrorContext as o, type ApiErrorDecision as p, type ApiErrorPolicy as q, type ApprovalMode as r, streamAgentUIMessages as s, type ApprovalRequest as t, type CompiledContextWindow as u, ContextualTool as v, DelegationTimeoutError as w, McpFileError as x, type McpRegistryConfig as y, type McpRequestContext as z };
1642
+ export { compileLoadedAgentModule as $, type AgentManifestEntry as A, type BeforeToolCallContext as B, type ContextWindowOptions as C, type DefinitionOrThunk as D, type EphemeralAgent as E, type McpSelection as F, type SdkAgentHandle as G, type HitlDecision as H, type SdkMessage as I, type SdkSendOptions as J, type SdkTurnHandle as K, type LLMCallContext as L, type McpApprovalSpec as M, type Segment as N, type ShouldAutoApproveOptions as O, type ProcessInputContext as P, type ToolHooks as Q, type RuntimeOverrides as R, type SkillsOptions as S, type ToolCallVeto as T, type ToolHooksPlugin as U, agentsPlugin as V, WRITE_SCOPED_TOOLS as W, applyPosture as X, buildModelSelection as Y, compileAgentModule as Z, compileContextWindow as _, type ApprovalPosture as a, compileProjectContext as a0, compileSkills as a1, createAgentExecutionContext as a2, createApiErrorHandler as a3, createSdkAgentStream as a4, createThinkTagExtractor as a5, createToolHooksPlugin as a6, extractThinkTagStream as a7, generateAgentManifest as a8, generateAgentRoutes as a9, isAgentContext as aa, loadMcpJson as ab, mcpRegistry as ac, mcpToolApprovals as ad, projectContextMetadataOnlyKnobs as ae, reasoningEffortOf as af, resolveMcpServers as ag, runWithApiErrorHandling as ah, shouldAutoApprove as ai, toAgentFactory as aj, translateSdkEvent as ak, withClockCap as al, withEphemeralAgent as am, type AgentModule as b, APPROVAL_MODES as c, type AfterToolCallContext as d, AgentBuilder as e, AgentDefinitionError as f, type AgentExecutionContext as g, type AgentManifest as h, type AgentManifestSource as i, type AgentManifestTool as j, type AgentRoute as k, type AgentRouteContext as l, type AgentRunInfo as m, type AgentsPluginOptions as n, type ApiErrorContext as o, type ApiErrorDecision as p, type ApiErrorPolicy as q, type ApprovalMode as r, streamAgentUIMessages as s, type ApprovalRequest as t, type CompiledContextWindow as u, ContextualTool as v, DelegationTimeoutError as w, McpFileError as x, type McpRegistryConfig as y, type McpRequestContext as z };
package/dist/bridge.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export { c as APPROVAL_MODES, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinitionError, g as AgentExecutionContext, h as AgentManifest, A as AgentManifestEntry, i as AgentManifestSource, j as AgentManifestTool, b as AgentModule, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentsPluginOptions, o as ApiErrorContext, p as ApiErrorDecision, q as ApiErrorPolicy, r as ApprovalMode, a as ApprovalPosture, B as BeforeToolCallContext, u as CompiledContextWindow, v as ContextualTool, D as DefinitionOrThunk, w as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, x as McpFileError, y as McpRegistryConfig, z as McpRequestContext, F as McpSelection, P as ProcessInputContext, G as SdkAgentHandle, I as SdkMessage, J as SdkSendOptions, K as SdkTurnHandle, N as Segment, O as ShouldAutoApproveOptions, T as ToolCallVeto, Q as ToolHooks, R as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, U as agentsPlugin, V as applyPosture, X as buildModelSelection, Y as compileAgentModule, Z as compileContextWindow, _ as compileLoadedAgentModule, $ as compileProjectContext, a0 as compileSkills, a1 as createAgentExecutionContext, a2 as createApiErrorHandler, a3 as createSdkAgentStream, a4 as createThinkTagExtractor, a5 as createToolHooksPlugin, a6 as extractThinkTagStream, a7 as generateAgentManifest, a8 as generateAgentRoutes, a9 as isAgentContext, aa as loadMcpJson, ab as mcpRegistry, ac as mcpToolApprovals, ad as projectContextMetadataOnlyKnobs, ae as reasoningEffortOf, af as resolveMcpServers, ag as runWithApiErrorHandling, ah as shouldAutoApprove, s as streamAgentUIMessages, ai as toAgentFactory, aj as translateSdkEvent, ak as withClockCap, al as withEphemeralAgent } from './bridge-entry-BJ86tO6e.js';
2
- export { C as CompiledAgentOptions, a as CompiledTool, H as HookApprovalGate, g as HookApprovalRequest, h as HookGateUnsupportedError, T as ToolWalkResult, j as ToolboxWalkResult, k as compileTools } from './agent-compiler-C2jIZ4CZ.js';
3
- export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetExceededError, m as DelegationError, n as DelegationPort, c as DelegationResult, D as DelegationTarget, o as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, P as PartialToolCallEvent, v as RunStartedEvent, w as ScoreVerdict, x as ScoredDelegation, y as Scorer, z as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, G as ThinkingEvent, H as ToolCallEvent, J as ToolResultEvent, K as delegate, M as delegateBackground, N as delegateWithScoring, O as isApprovalRequired, Q as isDone, U as isError, V as isPartialToolCall, W as isTextDelta, X as isToolCall, Y as isToolResult, a0 as presentUIMessageStream, a3 as streamAgentResponse } from './delegation-scoring-BrBQXvIp.js';
4
- export { a as AGENT_BRAND, A as AgentDefinition, D as DefineAgentConfig, I as InferAgentInput, b as InferAgentToolNames, P as ProjectSettingsGrant, c as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, d as compileAgentDefinition, i as isAgentDefinition, r as resolveCompatSources, e as resolveSettingSources } from './define-agent-WYnUlWaH.js';
1
+ export { c as APPROVAL_MODES, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinitionError, g as AgentExecutionContext, h as AgentManifest, A as AgentManifestEntry, i as AgentManifestSource, j as AgentManifestTool, b as AgentModule, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentsPluginOptions, o as ApiErrorContext, p as ApiErrorDecision, q as ApiErrorPolicy, r as ApprovalMode, a as ApprovalPosture, B as BeforeToolCallContext, u as CompiledContextWindow, v as ContextualTool, D as DefinitionOrThunk, w as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, x as McpFileError, y as McpRegistryConfig, z as McpRequestContext, F as McpSelection, P as ProcessInputContext, G as SdkAgentHandle, I as SdkMessage, J as SdkSendOptions, K as SdkTurnHandle, N as Segment, O as ShouldAutoApproveOptions, T as ToolCallVeto, Q as ToolHooks, U as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, V as agentsPlugin, X as applyPosture, Y as buildModelSelection, Z as compileAgentModule, _ as compileContextWindow, $ as compileLoadedAgentModule, a0 as compileProjectContext, a1 as compileSkills, a2 as createAgentExecutionContext, a3 as createApiErrorHandler, a4 as createSdkAgentStream, a5 as createThinkTagExtractor, a6 as createToolHooksPlugin, a7 as extractThinkTagStream, a8 as generateAgentManifest, a9 as generateAgentRoutes, aa as isAgentContext, ab as loadMcpJson, ac as mcpRegistry, ad as mcpToolApprovals, ae as projectContextMetadataOnlyKnobs, af as reasoningEffortOf, ag as resolveMcpServers, ah as runWithApiErrorHandling, ai as shouldAutoApprove, s as streamAgentUIMessages, aj as toAgentFactory, ak as translateSdkEvent, al as withClockCap, am as withEphemeralAgent } from './bridge-entry-DBkqwe6b.js';
2
+ export { c as CompatImportUnsupportedError, a as CompiledAgentOptions, b as CompiledTool, H as HookApprovalGate, j as HookApprovalRequest, k as HookGateUnsupportedError, T as ToolWalkResult, m as ToolboxWalkResult, n as compileTools } from './agent-compiler-B0hb6HCo.js';
3
+ export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetExceededError, m as DelegationError, n as DelegationPort, c as DelegationResult, D as DelegationTarget, o as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, P as PartialToolCallEvent, v as RunStartedEvent, w as ScoreVerdict, x as ScoredDelegation, y as Scorer, z as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, G as ThinkingEvent, H as ToolCallEvent, J as ToolResultEvent, K as delegate, M as delegateBackground, N as delegateWithScoring, O as isApprovalRequired, Q as isDone, U as isError, V as isPartialToolCall, W as isTextDelta, X as isToolCall, Y as isToolResult, a0 as presentUIMessageStream, a3 as streamAgentResponse } from './delegation-scoring-BzJEheml.js';
4
+ export { a as AGENT_BRAND, A as AgentDefinition, D as DefineAgentConfig, I as InferAgentInput, b as InferAgentToolNames, c as compileAgentDefinition, i as isAgentDefinition } from './define-agent-DhwNmdej.js';
5
+ export { C as CompatSurface, a as GatedCompatSource, G as GatedSettingSource, P as ProjectSettingsGrant, R as ResolvedCompatSource, b as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, r as resolveCompatSources, c as resolveSettingSources } from './setting-sources-gate-DFu51i50.js';
5
6
  import '@theokit/http';
6
7
  import './types-C16Wuh9E.js';
7
8
  import '@theokit/sdk';
@@ -11,3 +12,4 @@ import '@theokit/sdk/sandbox';
11
12
  import './hook-handlers-Cw2FsnE5.js';
12
13
  import '@theokit/presenter/wire';
13
14
  import '@theokit/sdk/errors';
15
+ import '@theokit/sdk/subagents-loader';
package/dist/bridge.js CHANGED
@@ -29,10 +29,12 @@ import {
29
29
  runWithApiErrorHandling,
30
30
  streamAgentResponse,
31
31
  streamAgentUIMessages
32
- } from "./chunk-3GQJ2BHT.js";
32
+ } from "./chunk-G7QBDGZ4.js";
33
+ import "./chunk-HGVT4VCE.js";
33
34
  import {
34
35
  APPROVAL_MODES,
35
36
  BudgetExceededError,
37
+ CompatImportUnsupportedError,
36
38
  DelegationBudgetExceededError,
37
39
  DelegationError,
38
40
  DelegationTimeoutError,
@@ -55,8 +57,8 @@ import {
55
57
  translateSdkEvent,
56
58
  withClockCap,
57
59
  withEphemeralAgent
58
- } from "./chunk-NZTLBLHB.js";
59
- import "./chunk-RKWCXVYG.js";
60
+ } from "./chunk-KTQID5V3.js";
61
+ import "./chunk-MJ6FRILJ.js";
60
62
  import {
61
63
  AGENT_BRAND,
62
64
  UntrustedSettingSourceError,
@@ -64,7 +66,9 @@ import {
64
66
  isAgentDefinition,
65
67
  resolveCompatSources,
66
68
  resolveSettingSources
67
- } from "./chunk-X4IGZHOV.js";
69
+ } from "./chunk-PMMOOXR6.js";
70
+ import "./chunk-M5J3Q6YC.js";
71
+ import "./chunk-U72XTMYB.js";
68
72
  import "./chunk-OXNDJSAJ.js";
69
73
  import "./chunk-Z4QWC7IK.js";
70
74
  export {
@@ -73,6 +77,7 @@ export {
73
77
  AgentBuilder,
74
78
  AgentDefinitionError,
75
79
  BudgetExceededError,
80
+ CompatImportUnsupportedError,
76
81
  ContextualTool,
77
82
  DelegationBudgetExceededError,
78
83
  DelegationError,
@@ -1,19 +1,26 @@
1
+ import {
2
+ currentOperatorPolicy,
3
+ mcpServerAdmitted
4
+ } from "./chunk-HGVT4VCE.js";
1
5
  import {
2
6
  createHitlPlugin,
3
- createSdkAgentStream
4
- } from "./chunk-NZTLBLHB.js";
7
+ createSdkAgentStream,
8
+ moderateOutputStream,
9
+ runInputGuards,
10
+ textPayloadExtractor
11
+ } from "./chunk-KTQID5V3.js";
5
12
  import {
6
13
  compileAgentDefinition,
7
14
  defineAgent,
8
15
  isAgentDefinition
9
- } from "./chunk-X4IGZHOV.js";
16
+ } from "./chunk-PMMOOXR6.js";
17
+ import {
18
+ ConfigurationError
19
+ } from "./chunk-U72XTMYB.js";
10
20
  import {
11
21
  __name
12
22
  } from "./chunk-Z4QWC7IK.js";
13
23
 
14
- // src/errors.ts
15
- import { ConfigurationError } from "@theokit/sdk/errors";
16
-
17
24
  // src/bridge/compile-context-window.ts
18
25
  var STRATEGY_KNOBS = [
19
26
  "compactionStrategy",
@@ -26,6 +33,12 @@ function compileContextWindow(options) {
26
33
  if (typeof options.maxTokens === "number") {
27
34
  context.maxTokens = options.maxTokens;
28
35
  }
36
+ if (typeof options.maxBytesPerFile === "number") {
37
+ context.maxBytesPerFile = options.maxBytesPerFile;
38
+ }
39
+ if (typeof options.maxBytesTotal === "number") {
40
+ context.maxBytesTotal = options.maxBytesTotal;
41
+ }
29
42
  const opts = options;
30
43
  const metadataOnlyKnobs = STRATEGY_KNOBS.filter((knob) => opts[knob] !== void 0);
31
44
  return {
@@ -649,6 +662,10 @@ function makeBuilder(config) {
649
662
  ...config,
650
663
  memory: settings
651
664
  }), "memory"),
665
+ telemetry: /* @__PURE__ */ __name((settings) => makeBuilder({
666
+ ...config,
667
+ telemetry: settings
668
+ }), "telemetry"),
652
669
  hooks: /* @__PURE__ */ __name((map) => makeBuilder({
653
670
  ...config,
654
671
  hooks: map
@@ -777,6 +794,29 @@ async function* appendCheckpointSaved(source, sessionId) {
777
794
  }
778
795
  __name(appendCheckpointSaved, "appendCheckpointSaved");
779
796
  function streamAgentUIMessages(compiled, apiKey, input) {
797
+ const guardrails = compiled.guardrails;
798
+ if (guardrails !== void 0 && guardrails.length > 0) {
799
+ return guardedStream(compiled, apiKey, input, guardrails);
800
+ }
801
+ return unguardedStream(compiled, apiKey, input);
802
+ }
803
+ __name(streamAgentUIMessages, "streamAgentUIMessages");
804
+ async function* guardedStream(compiled, apiKey, input, guardrails) {
805
+ const safe = await runInputGuards(input.message, guardrails);
806
+ const inner = moderateOutputStream(unguardedStream(compiled, apiKey, {
807
+ ...input,
808
+ message: safe
809
+ }), guardrails, textPayloadExtractor("text-delta", (e) => e.delta), (delta, replaced) => ({
810
+ ...replaced,
811
+ delta
812
+ }), (_text, result) => result);
813
+ yield* moderateOutputStream(inner, guardrails, textPayloadExtractor("reasoning-delta", (e) => e.delta), (delta, replaced) => ({
814
+ ...replaced,
815
+ delta
816
+ }), (_text, result) => result);
817
+ }
818
+ __name(guardedStream, "guardedStream");
819
+ function unguardedStream(compiled, apiKey, input) {
780
820
  const textId = crypto.randomUUID();
781
821
  const overrides = {};
782
822
  if (input.cwd !== void 0) overrides.cwd = input.cwd;
@@ -841,7 +881,7 @@ function streamAgentUIMessages(compiled, apiKey, input) {
841
881
  onError: input.onError
842
882
  });
843
883
  }
844
- __name(streamAgentUIMessages, "streamAgentUIMessages");
884
+ __name(unguardedStream, "unguardedStream");
845
885
 
846
886
  // src/bridge/api-error-handler.ts
847
887
  var DEFAULT_MAX_ATTEMPTS = 3;
@@ -940,6 +980,27 @@ __name(mcpToolApprovals, "mcpToolApprovals");
940
980
  import { existsSync, readFileSync } from "fs";
941
981
  import { join } from "path";
942
982
  import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
983
+ var ENV_REFERENCE_REGEX = /^\$\{([A-Za-z_]\w*)\}$/;
984
+ function expandEnvReferences(record, env, field, server, warn) {
985
+ const out = {};
986
+ for (const [key, value] of Object.entries(record)) {
987
+ const match = ENV_REFERENCE_REGEX.exec(value);
988
+ if (match === null) {
989
+ out[key] = value;
990
+ continue;
991
+ }
992
+ const name = match[1];
993
+ const resolved = env[name];
994
+ if (resolved === void 0) {
995
+ warn(`${MCP_FILENAME}: server "${server}" references \${${name}} in "${field}.${key}", and that variable is not set \u2014 the reference is left as written`);
996
+ out[key] = value;
997
+ continue;
998
+ }
999
+ out[key] = resolved;
1000
+ }
1001
+ return out;
1002
+ }
1003
+ __name(expandEnvReferences, "expandEnvReferences");
943
1004
  function warningChannel(opts) {
944
1005
  return opts.onWarn ?? ((warning) => {
945
1006
  process.stderr.write(`[@theokit/agents] ${warning}
@@ -972,10 +1033,10 @@ function loadMcpJson(cwd, opts = {}) {
972
1033
  } catch (err) {
973
1034
  throw new McpFileError(`${path} is not valid JSON: ${describeIt(err)}`);
974
1035
  }
975
- return parseMcpJson(parsed, path, warningChannel(opts));
1036
+ return parseMcpJson(parsed, path, warningChannel(opts), opts.env ?? process.env);
976
1037
  }
977
1038
  __name(loadMcpJson, "loadMcpJson");
978
- function parseMcpJson(raw, source, onWarn) {
1039
+ function parseMcpJson(raw, source, onWarn, env) {
979
1040
  if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
980
1041
  throw new McpFileError(`${source}: root must be a JSON object with an "mcpServers" key.`);
981
1042
  }
@@ -985,13 +1046,18 @@ function parseMcpJson(raw, source, onWarn) {
985
1046
  throw new McpFileError(`${source}: "mcpServers" must be an object keyed by server name.`);
986
1047
  }
987
1048
  const out = {};
1049
+ const policy = currentOperatorPolicy(onWarn);
988
1050
  for (const [name, entryRaw] of Object.entries(serversRaw)) {
1051
+ if (!mcpServerAdmitted(name, policy)) {
1052
+ onWarn(`${source}: server "${name}" not started \u2014 an operator policy does not admit it`);
1053
+ continue;
1054
+ }
989
1055
  const reason = validateEntry(name, entryRaw);
990
1056
  if (reason !== void 0) {
991
1057
  onWarn(`${source}: server "${name}" ignored \u2014 ${reason}`);
992
1058
  continue;
993
1059
  }
994
- out[name] = buildEntry(entryRaw);
1060
+ out[name] = buildEntry(entryRaw, name, env, onWarn);
995
1061
  }
996
1062
  return out;
997
1063
  }
@@ -1018,6 +1084,12 @@ function validateStdio(entry) {
1018
1084
  return void 0;
1019
1085
  }
1020
1086
  __name(validateStdio, "validateStdio");
1087
+ function normaliseTransport(value) {
1088
+ if (value === "http" || value === "streamable-http") return "http";
1089
+ if (value === "sse") return "sse";
1090
+ return void 0;
1091
+ }
1092
+ __name(normaliseTransport, "normaliseTransport");
1021
1093
  function validateRemote(entry) {
1022
1094
  if (typeof entry.url !== "string" || entry.url.length === 0) {
1023
1095
  return 'field "url" must be a non-empty string.';
@@ -1027,8 +1099,8 @@ function validateRemote(entry) {
1027
1099
  } catch {
1028
1100
  return 'field "url" is not a valid URL.';
1029
1101
  }
1030
- if (entry.type !== void 0 && entry.type !== "http" && entry.type !== "sse") {
1031
- return 'field "type" must be "http" or "sse".';
1102
+ if (entry.type !== void 0 && normaliseTransport(entry.type) === void 0) {
1103
+ return 'field "type" must be "http", "streamable-http" or "sse".';
1032
1104
  }
1033
1105
  if (entry.headers !== void 0 && !isStringRecord(entry.headers)) {
1034
1106
  return 'field "headers" must be a map of strings.';
@@ -1039,13 +1111,15 @@ function validateRemote(entry) {
1039
1111
  return void 0;
1040
1112
  }
1041
1113
  __name(validateRemote, "validateRemote");
1042
- function buildEntry(entry) {
1114
+ function buildEntry(entry, name, env, warn) {
1043
1115
  if (entry.url !== void 0) {
1044
1116
  const remote = {
1045
1117
  url: entry.url
1046
1118
  };
1047
- if (entry.type !== void 0) remote.type = entry.type;
1048
- if (entry.headers !== void 0) remote.headers = entry.headers;
1119
+ if (entry.type !== void 0) remote.type = normaliseTransport(entry.type);
1120
+ if (entry.headers !== void 0) {
1121
+ remote.headers = expandEnvReferences(entry.headers, env, "headers", name, warn);
1122
+ }
1049
1123
  if (entry.auth !== void 0) remote.auth = entry.auth;
1050
1124
  if (entry.requestTimeoutMs !== void 0) remote.requestTimeoutMs = entry.requestTimeoutMs;
1051
1125
  return remote;
@@ -1054,7 +1128,9 @@ function buildEntry(entry) {
1054
1128
  command: entry.command
1055
1129
  };
1056
1130
  if (entry.args !== void 0) stdio.args = entry.args;
1057
- if (entry.env !== void 0) stdio.env = entry.env;
1131
+ if (entry.env !== void 0) {
1132
+ stdio.env = expandEnvReferences(entry.env, env, "env", name, warn);
1133
+ }
1058
1134
  if (entry.cwd !== void 0) stdio.cwd = entry.cwd;
1059
1135
  return stdio;
1060
1136
  }
@@ -1206,7 +1282,6 @@ function matchRoute(routes, method, pathname) {
1206
1282
  __name(matchRoute, "matchRoute");
1207
1283
 
1208
1284
  export {
1209
- ConfigurationError,
1210
1285
  compileContextWindow,
1211
1286
  compileSkills,
1212
1287
  toolRuntimeName,
@@ -1240,4 +1315,4 @@ export {
1240
1315
  generateAgentManifest,
1241
1316
  agentsPlugin
1242
1317
  };
1243
- //# sourceMappingURL=chunk-3GQJ2BHT.js.map
1318
+ //# sourceMappingURL=chunk-G7QBDGZ4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bridge/compile-context-window.ts","../src/bridge/compile-skills.ts","../src/bridge/agent-compiler.ts","../src/bridge/agent-execution-context.ts","../src/bridge/present-ui-message-stream.ts","../src/bridge/hitl-call-correlation.ts","../src/bridge/agent-sse-handler.ts","../src/bridge/agent-stream-events.ts","../src/bridge/agent-route-generator.ts","../src/bridge/agent-builder.ts","../src/bridge/agent-endpoint.ts","../src/bridge/api-error-handler.ts","../src/bridge/mcp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","opts","metadataOnlyKnobs","filter","knob","undefined","compileSkills","options","autoDiscover","autoInject","enabled","include","SDK_TOOL_NAME","SDK_TOOL_NAME_MAX_LENGTH","SDK_TOOL_NAME_CHARSET","SDK_RESERVED_TOOL_NAMES","Set","SDK_RESERVED_TOOL_PREFIX","toolRuntimeName","namespace","toolName","trim","length","where","ConfigurationError","name","test","String","has","startsWith","join","compileHitlGates","toolboxes","gates","Map","tb","tool","tools","hitl","set","config","compileTools","toolboxInstances","instance","get","class","handler","propertyKey","push","description","inputSchema","input","call","createAgentExecutionContext","base","agent","run","toolCall","getRequest","getUrl","getClass","getMethodName","getAgent","getRun","getToolCall","isAgentContext","ctx","UIMessageStreamPresenter","WIRE_APPROVAL_DETAIL_PART","claim","queues","toolName","queue","get","undefined","claimed","shift","length","delete","enqueue","id","set","push","forget","at","indexOf","splice","HitlCallCorrelation","Map","announceToolCall","callId","announced","approvalToolCallId","approvalId","resultToolCallId","toAgentOutputEvent","e","type","text","content","callId","name","toolName","input","result","output","isError","doneToMetadata","event","usage","durationMs","cost","undefined","stopReason","model","ERROR_CODE_DATA_PART","INPUT_REQUESTED_DATA_PART","TASK_PROGRESS_DATA_PART","SHELL_OUTPUT_DATA_PART","dataPart","data","transient","UNMASKED_CODES","Set","MASK_ERROR","error","code","has","message","errorChunks","errorText","diagnosticDataPart","checkpointId","resumeToken","step","requestId","status","correlateToolIds","correlation","announceToolCall","resultToolCallId","presentUIMessageStream","events","opts","onError","presenter","UIMessageStreamPresenter","textId","HitlCallCorrelation","turnMetadata","correlated","present","closeBlock","toolCallId","approvalToolCallId","hasSeen","markSeen","dynamic","WIRE_APPROVAL_DETAIL_PART","approvalId","question","timeoutMs","diagnostic","err","codeOrUndefined","String","finish","encoder","TextEncoder","DONE_FRAME","streamAgentResponse","eventStream","opts","stream","ReadableStream","start","controller","closed","safeEnqueue","chunk","enqueue","chunks","presentUIMessageStream","textId","crypto","randomUUID","onError","undefined","data","JSON","stringify","encode","type","close","Response","status","headers","isTextDelta","e","type","isToolCall","isPartialToolCall","isToolResult","isDone","isError","isApprovalRequired","generateAgentRoutes","ctx","walkResult","createRun","getRun","basePath","route","replace","routes","push","method","path","handler","request","body","json","message","length","Response","JSON","stringify","error","code","status","headers","rawSessionId","sessionId","Date","now","streamAgentResponse","url","URL","runId","pathname","split","pop","run","ContextualTool","of","tool","_requiredContext","makeBuilder","config","runtime","input","schema","model","id","system","prompt","reasoningEffort","effort","maxIterations","limit","context","value","tools","list","when","condition","apply","builder","guardrail","g","guardrails","gs","approval","toolName","options","approvals","map","skills","selection","settingSources","hookApproval","gate","memory","settings","telemetry","hooks","plugins","mcp","servers","mcpServers","use","preset","build","defineAgent","AgentBuilder","create","TheokitAgentError","AgentDefinitionError","TheokitAgentError","name","source","code","isRetryable","extractDefaultExport","mod","default","isCompiledAgentOptions","value","v","Array","isArray","tools","agents","compileAgentModule","def","isAgentDefinition","compileAgentDefinition","compileLoadedAgentModule","asAgentStream","events","e","EventQueue","push","item","r","shift","done","close","splice","undefined","drain","length","next","Promise","resolve","appendCheckpointSaved","sessionId","emitted","checkpoint","type","checkpointId","crypto","randomUUID","step","resumeToken","ev","streamAgentUIMessages","compiled","apiKey","input","guardrails","guardedStream","unguardedStream","safe","runInputGuards","message","inner","moderateOutputStream","textPayloadExtractor","delta","replaced","_text","result","textId","overrides","cwd","baseDir","images","onRunEvent","retry","signal","exposeUsageToTools","hitl","gated","size","createSdkAgentStream","queue","addEventListener","once","plugin","createHitlPlugin","emit","awaitApproval","sdkStream","plugins","err","Error","String","retryable","durableCheckpoint","storage","presentUIMessageStream","onError","DEFAULT_MAX_ATTEMPTS","runWithApiErrorHandling","thunk","policy","maxAttempts","attempt","error","decision","processApiError","retry","fallback","undefined","createApiErrorHandler","resolveMcpServers","selection","ctx","undefined","resolved","Error","mcpRegistry","config","registry","apps","composio","command","args","length","join","env","COMPOSIO_API_KEY","apiKey","profile","MCP_RUN_API_KEY","JSON","stringify","mcpToolApprovals","specs","out","tool","spec","Object","entries","question","existsSync","readFileSync","join","TheokitAgentError","ENV_REFERENCE_REGEX","expandEnvReferences","record","env","field","server","warn","out","key","value","Object","entries","match","exec","name","resolved","undefined","MCP_FILENAME","warningChannel","opts","onWarn","warning","process","stderr","write","McpFileError","TheokitAgentError","message","loadMcpJson","cwd","path","join","existsSync","text","readFileSync","err","describeIt","parsed","JSON","parse","parseMcpJson","raw","source","Array","isArray","serversRaw","mcpServers","policy","currentOperatorPolicy","entryRaw","mcpServerAdmitted","reason","validateEntry","buildEntry","entry","hasUrl","url","hasCommand","command","validateRemote","validateStdio","length","args","isStringArray","isStringRecord","normaliseTransport","URL","type","headers","requestTimeoutMs","remote","auth","stdio","Error","String","v","every","x","values","generateAgentManifest","sources","version","generatedAt","Date","toISOString","agents","map","r","name","agentConfig","route","model","stream","mainLoop","method","String","propertyKey","strategy","guards","g","interceptors","i","tools","toolboxes","flatMap","tb","t","namespace","config","description","risk","approval","undefined","capabilities","trace","audit","gateway","platforms","sessionStrategy","subAgents","subAgentClasses","cls","memory","provider","embeddings","fts","scope","skills","include","mcpServers","Object","keys","validateUniqueRoutes","results","seen","Map","r","existing","get","route","undefined","Error","agentConfig","name","set","agentsPlugin","opts","routes","register","app","addHook","pluginCtx","initRoutes","request","url","URL","method","toUpperCase","matched","matchRoute","pathname","handler","allRoutes","routeIdentities","entry","agents","push","createRun","createRunFactory","compiled","defaultCreateRun","generateAgentRoutes","walkResult","compiledOptions","compileRoutePatterns","_message","_sessionId","Promise","resolve","type","runId","Date","now","agentName","model","code","message","retryable","map","path","includes","regexSource","replace","regex","RegExp","find","test"]}
@@ -0,0 +1,97 @@
1
+ import {
2
+ __name
3
+ } from "./chunk-Z4QWC7IK.js";
4
+
5
+ // src/config/operator-policy.ts
6
+ import { existsSync, readFileSync } from "fs";
7
+ import { join } from "path";
8
+ var KNOWN_KEYS = /* @__PURE__ */ new Set([
9
+ "disableSkillShellExecution",
10
+ "deniedMcpServers",
11
+ "allowedMcpServers"
12
+ ]);
13
+ var LIST_KEYS = /* @__PURE__ */ new Set([
14
+ "deniedMcpServers",
15
+ "allowedMcpServers"
16
+ ]);
17
+ function operatorPolicyPath(root) {
18
+ if (root !== void 0) return join(root, "claude-code", "managed-settings.json");
19
+ if (process.platform === "darwin") {
20
+ return "/Library/Application Support/ClaudeCode/managed-settings.json";
21
+ }
22
+ if (process.platform === "win32") {
23
+ return join(process.env.PROGRAMDATA ?? "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
24
+ }
25
+ return "/etc/claude-code/managed-settings.json";
26
+ }
27
+ __name(operatorPolicyPath, "operatorPolicyPath");
28
+ function readOperatorPolicy(root, warn) {
29
+ const path = operatorPolicyPath(root);
30
+ const parsed = readPolicyDocument(path, warn);
31
+ if (parsed === void 0) return {};
32
+ const out = {};
33
+ for (const [key, value] of Object.entries(parsed)) {
34
+ applyPolicyKey(out, key, value, path, warn);
35
+ }
36
+ return out;
37
+ }
38
+ __name(readOperatorPolicy, "readOperatorPolicy");
39
+ function readPolicyDocument(path, warn) {
40
+ if (!existsSync(path)) return void 0;
41
+ let parsed;
42
+ try {
43
+ parsed = JSON.parse(readFileSync(path, "utf8"));
44
+ } catch (cause) {
45
+ warn(`${path} could not be read as JSON (${cause.message}) \u2014 NO operator policy is being applied.`);
46
+ return void 0;
47
+ }
48
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
49
+ warn(`${path} is not a JSON object \u2014 NO operator policy is being applied.`);
50
+ return void 0;
51
+ }
52
+ return parsed;
53
+ }
54
+ __name(readPolicyDocument, "readPolicyDocument");
55
+ function applyPolicyKey(out, key, value, path, warn) {
56
+ if (!KNOWN_KEYS.has(key)) return;
57
+ if (LIST_KEYS.has(key)) {
58
+ const list = readStringList(value, key, path, warn);
59
+ if (list === void 0) return;
60
+ if (key === "deniedMcpServers") out.deniedMcpServers = list;
61
+ if (key === "allowedMcpServers") out.allowedMcpServers = list;
62
+ return;
63
+ }
64
+ if (typeof value !== "boolean") {
65
+ warn(`${path} declares "${key}" as ${typeof value}, not a boolean \u2014 it is NOT being applied.`);
66
+ return;
67
+ }
68
+ if (key === "disableSkillShellExecution") out.disableSkillShellExecution = value;
69
+ }
70
+ __name(applyPolicyKey, "applyPolicyKey");
71
+ function readStringList(value, key, path, warn) {
72
+ if (Array.isArray(value) && value.every((v) => typeof v === "string")) {
73
+ return value;
74
+ }
75
+ warn(`${path} declares "${key}" as ${Array.isArray(value) ? "an array with a non-string entry" : typeof value}, not an array of strings \u2014 it is NOT being applied.`);
76
+ return void 0;
77
+ }
78
+ __name(readStringList, "readStringList");
79
+ var cached;
80
+ var rootOverride;
81
+ function currentOperatorPolicy(warn) {
82
+ cached ??= readOperatorPolicy(rootOverride, warn);
83
+ return cached;
84
+ }
85
+ __name(currentOperatorPolicy, "currentOperatorPolicy");
86
+ function mcpServerAdmitted(name, policy) {
87
+ if (policy.deniedMcpServers?.includes(name) === true) return false;
88
+ if (policy.allowedMcpServers === void 0) return true;
89
+ return policy.allowedMcpServers.includes(name);
90
+ }
91
+ __name(mcpServerAdmitted, "mcpServerAdmitted");
92
+
93
+ export {
94
+ currentOperatorPolicy,
95
+ mcpServerAdmitted
96
+ };
97
+ //# sourceMappingURL=chunk-HGVT4VCE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/operator-policy.ts"],"mappings":";;;;;AA4BA,SAASA,YAAYC,oBAAoB;AACzC,SAASC,YAAY;AA8BrB,IAAMC,aAAa,oBAAIC,IAA0B;EAC/C;EACA;EACA;CACD;AAGD,IAAMC,YAAY,oBAAID,IAA0B;EAAC;EAAoB;CAAoB;AASzF,SAASE,mBAAmBC,MAAa;AACvC,MAAIA,SAASC,OAAW,QAAOC,KAAKF,MAAM,eAAe,uBAAA;AACzD,MAAIG,QAAQC,aAAa,UAAU;AACjC,WAAO;EACT;AACA,MAAID,QAAQC,aAAa,SAAS;AAChC,WAAOF,KAAKC,QAAQE,IAAIC,eAAe,mBAAmB,cAAc,uBAAA;EAC1E;AACA,SAAO;AACT;A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ImB,6BAA6BjB;AAC7E;AApBSG;AA4BT,SAASW,eACPd,OACAD,KACAJ,MACAD,MAA+B;AAE/B,MAAIgB,MAAMC,QAAQX,KAAAA,KAAUA,MAAMkB,MAAM,CAACC,MAAM,OAAOA,MAAM,QAAA,GAAW;AACrE,WAAOnB;EACT;AACAN,OACE,GAAGC,IAAAA,cAAkBI,GAAAA,QAChBW,MAAMC,QAAQX,KAAAA,IAAS,qCAAqC,OAAOA,KAAAA,2DAClB;AAExD,SAAOb;AACT;AAfS2B;AAwBT,IAAIM;AACJ,IAAIC;AAEG,SAASC,sBAAsB5B,MAA+B;AACnE0B,aAAW3B,mBAAmB4B,cAAc3B,IAAAA;AAC5C,SAAO0B;AACT;AAHgBE;AAuBT,SAASC,kBAAkBC,MAAcC,QAAsB;AACpE,MAAIA,OAAOC,kBAAkBC,SAASH,IAAAA,MAAU,KAAM,QAAO;AAC7D,MAAIC,OAAOG,sBAAsBC,OAAW,QAAO;AACnD,SAAOJ,OAAOG,kBAAkBD,SAASH,IAAAA;AAC3C;AAJgBD;","names":["existsSync","readFileSync","join","KNOWN_KEYS","Set","LIST_KEYS","operatorPolicyPath","root","undefined","join","process","platform","env","PROGRAMDATA","readOperatorPolicy","warn","path","parsed","readPolicyDocument","out","key","value","Object","entries","applyPolicyKey","existsSync","JSON","parse","readFileSync","cause","message","Array","isArray","has","list","readStringList","deniedMcpServers","allowedMcpServers","disableSkillShellExecution","every","v","cached","rootOverride","currentOperatorPolicy","mcpServerAdmitted","name","policy","deniedMcpServers","includes","allowedMcpServers","undefined"]}