@theokit/agents 13.1.0 → 13.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,98 @@
1
1
  # @theokit/agents
2
2
 
3
+ ## 13.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b6e135e: Let a consumer read what the operator policy refuses
8
+
9
+ `disableAllHooks` shipped in 13.2.0 working and unreadable. `OperatorPolicy` and
10
+ `currentOperatorPolicy` were never exported, so nothing downstream could ask whether a policy was in
11
+ force — a diagnostic could report `hooks: none` and never `hooks: refused by operator policy`, which
12
+ is the ambiguity the switch exists to remove, restored one layer up in the type system.
13
+
14
+ Found by auditing all 628 exported symbols against the built `.d.ts`, distinguishing DECLARED from
15
+ merely MENTIONED: `OperatorPolicy` was declared in none of them, and `currentOperatorPolicy` appeared
16
+ only inside a docblock, where a grep reads it as present.
17
+
18
+ `OperatorPolicy`, `currentOperatorPolicy` and `mcpServerAdmitted` are now exported from
19
+ `@theokit/agents/config`. Nothing about the policy's enforcement changes; what changes is that a
20
+ consumer can see it and say so.
21
+
22
+ ## 13.2.0
23
+
24
+ ### Minor Changes
25
+
26
+ - af53600: Read the settings files the declared layers correspond to
27
+
28
+ `SETTINGS_LAYERS` published a precedence stack — `user` 10, `project-shared` 20, `project-local` 30 —
29
+ and opened no file. Measured with controls (`loadMcpJson` 5 files, an invented term 0):
30
+ `settings.local.json` appeared once in this package, as a comment; `outputStyle` appeared zero times
31
+ here and zero times in the SDK's built output.
32
+
33
+ Three documented features were unreachable for that one reason. `settings.local.json` had a
34
+ precedence and no reader. `outputStyle` had a loader — shipped in this same line of work — with no
35
+ caller and no source for the name it takes. The session `env` had neither.
36
+
37
+ `loadSettings` opens the three files, folds them through the existing `LayeredConfig` (rather than
38
+ deriving a second answer to "which layer wins"), and reports which declared layers contributed
39
+ nothing. `resolveOutputStyle` joins the two halves so the documented path works end to end: name a
40
+ style in settings, get the style — and a named style with no file behind it still refuses, because
41
+ returning nothing there would restore the silence this work removed.
42
+
43
+ Unknown keys pass through untouched. The brief is the same mechanisms, not every configuration, and
44
+ a reader that dropped what it did not recognise would silently discard an operator's settings.
45
+
46
+ - 88dd1ca: Translate a settings `permissions` block into rules the engine evaluates
47
+
48
+ The SDK ships a real permission engine — `PermissionEngine(rules, { defaultAction })`,
49
+ `PermissionRule`, `PermissionAction` — and it is a code surface: you construct it with rules. What
50
+ was missing was the path from the FILE to those rules. Measured: `permissions` appears in 13 SDK
51
+ files, and the SDK reads `settings.json` in three, of which two are sourcemaps and the third
52
+ describes the hooks shape. An operator writing `{ "permissions": { "deny": ["Bash(curl:*)"] } }` got
53
+ a file nothing translated.
54
+
55
+ `permissionRulesFromSettings` renders `Tool` and `Tool(prefix:*)` / `Tool(exact)` into anchored
56
+ rules, emitted deny-before-ask-before-allow because the engine is first-match-wins and an operator
57
+ reading their own file top to bottom has no reason to expect an `allow` above a `deny` to win.
58
+
59
+ Anything it cannot render faithfully — path globs, `~` expansion, per-tool argument names — is
60
+ RETURNED as unsupported with a reason, never quietly turned into a matcher that almost fires. A
61
+ `deny` an operator believes is in force and is not is strictly more dangerous than no rule, because
62
+ without one they would have written the guard themselves.
63
+
64
+ - 6022a2a: An operator can refuse every hook a foreign configuration root declares
65
+
66
+ `.claude/hooks.json` runs shell commands out of a working directory that usually arrived with the
67
+ clone, and the operator tier had no switch for it: an operator who inherited an untrusted checkout
68
+ could not decline hook execution without editing files inside it. `disableAllHooks` in the managed
69
+ policy now drops the `hooks` surface where `resolveCompatSources` grants the root — one place, and
70
+ the place whose own refusal message already says that root "includes hooks.json, which executes
71
+ shell". It applies whether the consumer took the whole root or narrowed it, and when hooks were the
72
+ only surface asked for, nothing is granted at all.
73
+
74
+ Unlike every other key in this policy, a malformed value fails CLOSED: `"disableAllHooks": "true"`
75
+ as a string is read as `true`, with a warning naming what happened. The asymmetry is the reason —
76
+ fail-open is silent and unsafe, fail-closed is loud and recoverable. An absent key still means hooks
77
+ run, so no existing consumer changes behaviour.
78
+
79
+ ### Patch Changes
80
+
81
+ - c692b54: Report a malformed operator policy to every reader, not just whichever ran first
82
+
83
+ `currentOperatorPolicy` memoises, and the memo took the warn channel with it: the first caller in the
84
+ process received the warnings and every caller after passed a channel that was never invoked.
85
+ Measured with a policy declaring `disableSkillShellExecution: "true"` — a string where a boolean is
86
+ required — the first reader heard one warning and the second heard none.
87
+
88
+ Three modules read this policy and nothing orders them, so whether an operator learned their policy
89
+ was malformed depended on which code path a given application happened to run first. The whole
90
+ operator tier is a set of refusals; one that silently fails to apply, in a process where nobody is
91
+ told, is the failure the tier exists to remove.
92
+
93
+ The warnings are now kept beside the policy and replayed to each reader. A well-formed policy
94
+ collects nothing, so nothing is replayed and no new noise appears.
95
+
3
96
  ## 13.1.0
4
97
 
5
98
  ### Minor Changes
@@ -2,7 +2,7 @@ import { InlineSkill, SystemPromptResolver, SessionStore, PermissionGate, Memory
2
2
  import { AgentDefinition } from '@theokit/sdk/subagents-loader';
3
3
  import { TheokitAgentError } from '@theokit/sdk/errors';
4
4
  import { R as ReasoningEffort, a as MemoryOptions, P as ProjectContextOptions, M as McpServersMap, H as HumanInTheLoopOptions, C as CheckpointOptions, T as ToolOptions, A as ApprovalOptions, B as BudgetOptions } from './types-C16Wuh9E.js';
5
- import { G as GatedSettingSource, a as GatedCompatSource } from './setting-sources-gate-DFu51i50.js';
5
+ import { G as GatedSettingSource, a as GatedCompatSource } from './setting-sources-gate-BXdZmY78.js';
6
6
 
7
7
  /**
8
8
  * M9 (theokit-ai-first) — guardrail contract + typed errors.
package/dist/auth.js CHANGED
@@ -2,15 +2,15 @@ import {
2
2
  readSecureJson,
3
3
  writeSecureJson
4
4
  } from "./chunk-D2EFYZBV.js";
5
- import {
6
- currentOperatorPolicy
7
- } from "./chunk-M5DRNOIU.js";
8
5
  import {
9
6
  debugLog
10
7
  } from "./chunk-M5J3Q6YC.js";
11
8
  import {
12
9
  ConfigurationError
13
10
  } from "./chunk-U72XTMYB.js";
11
+ import {
12
+ currentOperatorPolicy
13
+ } from "./chunk-2SP5BB6U.js";
14
14
  import {
15
15
  __name
16
16
  } from "./chunk-Z4QWC7IK.js";
@@ -1,14 +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 { a as CompiledAgentOptions, b as CompiledTool, G as Guardrail, S as SkillsSelection, H as HookApprovalGate, C as CodePlugin } from './agent-compiler-B_Z3OZel.js';
3
+ import { a as CompiledAgentOptions, b as CompiledTool, G as Guardrail, S as SkillsSelection, H as HookApprovalGate, C as CodePlugin } from './agent-compiler-BaOZzU7Q.js';
4
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-195_ROT3.js';
5
+ import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-DLsMQ4BJ.js';
6
6
  import { RetryOptions } from '@theokit/sdk/retry';
7
7
  import { SandboxPosture } from '@theokit/sdk/sandbox';
8
- import { A as AgentDefinition } from './define-agent-Cm7UGHx-.js';
8
+ import { A as AgentDefinition } from './define-agent-DOZL_0uP.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
+ import { S as SettingSourcesSelection } from './setting-sources-gate-BXdZmY78.js';
12
12
  import { WireChunk } from '@theokit/presenter/wire';
13
13
  import { TheokitAgentError } from '@theokit/sdk/errors';
14
14
 
package/dist/bridge.d.ts CHANGED
@@ -1,8 +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, 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-vzdHNu_x.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-B_Z3OZel.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-195_ROT3.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-Cm7UGHx-.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';
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-BgWauyLQ.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-BaOZzU7Q.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-DLsMQ4BJ.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-DOZL_0uP.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-BXdZmY78.js';
6
6
  import '@theokit/http';
7
7
  import './types-C16Wuh9E.js';
8
8
  import '@theokit/sdk';
package/dist/bridge.js CHANGED
@@ -29,8 +29,7 @@ import {
29
29
  runWithApiErrorHandling,
30
30
  streamAgentResponse,
31
31
  streamAgentUIMessages
32
- } from "./chunk-AAW4I45J.js";
33
- import "./chunk-M5DRNOIU.js";
32
+ } from "./chunk-SL3QW5WZ.js";
34
33
  import {
35
34
  APPROVAL_MODES,
36
35
  BudgetExceededError,
@@ -57,7 +56,7 @@ import {
57
56
  translateSdkEvent,
58
57
  withClockCap,
59
58
  withEphemeralAgent
60
- } from "./chunk-HBHZV3KL.js";
59
+ } from "./chunk-CBP72LFM.js";
61
60
  import "./chunk-MJ6FRILJ.js";
62
61
  import {
63
62
  AGENT_BRAND,
@@ -66,9 +65,10 @@ import {
66
65
  isAgentDefinition,
67
66
  resolveCompatSources,
68
67
  resolveSettingSources
69
- } from "./chunk-PMMOOXR6.js";
68
+ } from "./chunk-PYVLRSXZ.js";
70
69
  import "./chunk-M5J3Q6YC.js";
71
70
  import "./chunk-U72XTMYB.js";
71
+ import "./chunk-2SP5BB6U.js";
72
72
  import "./chunk-OXNDJSAJ.js";
73
73
  import "./chunk-Z4QWC7IK.js";
74
74
  export {
@@ -7,6 +7,7 @@ import { existsSync, readFileSync } from "fs";
7
7
  import { join } from "path";
8
8
  var KNOWN_KEYS = /* @__PURE__ */ new Set([
9
9
  "disableSkillShellExecution",
10
+ "disableAllHooks",
10
11
  "deniedMcpServers",
11
12
  "allowedMcpServers",
12
13
  "apiKeyHelper"
@@ -73,13 +74,23 @@ function applyPolicyKey(out, key, value, path, warn) {
73
74
  if (key === "apiKeyHelper") out.apiKeyHelper = value.trim();
74
75
  return;
75
76
  }
76
- if (typeof value !== "boolean") {
77
- warn(`${path} declares "${key}" as ${typeof value}, not a boolean \u2014 it is NOT being applied.`);
77
+ applyBooleanKey(out, key, value, path, warn);
78
+ }
79
+ __name(applyPolicyKey, "applyPolicyKey");
80
+ function applyBooleanKey(out, key, value, path, warn) {
81
+ if (typeof value === "boolean") {
82
+ if (key === "disableSkillShellExecution") out.disableSkillShellExecution = value;
83
+ if (key === "disableAllHooks") out.disableAllHooks = value;
84
+ return;
85
+ }
86
+ if (key === "disableAllHooks") {
87
+ out.disableAllHooks = true;
88
+ warn(`${path} declares "disableAllHooks" as ${typeof value}, not a boolean. It is being read as TRUE \u2014 hooks are refused \u2014 because a security switch that silently fails open is worse than one that fails visibly. Write \`true\` or \`false\` to say which you meant.`);
78
89
  return;
79
90
  }
80
- if (key === "disableSkillShellExecution") out.disableSkillShellExecution = value;
91
+ warn(`${path} declares "${key}" as ${typeof value}, not a boolean \u2014 it is NOT being applied.`);
81
92
  }
82
- __name(applyPolicyKey, "applyPolicyKey");
93
+ __name(applyBooleanKey, "applyBooleanKey");
83
94
  function readStringList(value, key, path, warn) {
84
95
  if (Array.isArray(value) && value.every((v) => typeof v === "string")) {
85
96
  return value;
@@ -90,8 +101,18 @@ function readStringList(value, key, path, warn) {
90
101
  __name(readStringList, "readStringList");
91
102
  var cached;
92
103
  var rootOverride;
104
+ var cachedWarnings = [];
93
105
  function currentOperatorPolicy(warn) {
94
- cached ??= readOperatorPolicy(rootOverride, warn);
106
+ if (cached === void 0) {
107
+ const collected = [];
108
+ cached = readOperatorPolicy(rootOverride, (message) => {
109
+ collected.push(message);
110
+ warn(message);
111
+ });
112
+ cachedWarnings = collected;
113
+ return cached;
114
+ }
115
+ for (const message of cachedWarnings) warn(message);
95
116
  return cached;
96
117
  }
97
118
  __name(currentOperatorPolicy, "currentOperatorPolicy");
@@ -106,4 +127,4 @@ export {
106
127
  currentOperatorPolicy,
107
128
  mcpServerAdmitted
108
129
  };
109
- //# sourceMappingURL=chunk-M5DRNOIU.js.map
130
+ //# sourceMappingURL=chunk-2SP5BB6U.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/operator-policy.ts"],"mappings":";;;;;AA4BA,SAASA,YAAYC,oBAAoB;AACzC,SAASC,YAAY;AA8DrB,IAAMC,aAAa,oBAAIC,IAA0B;EAC/C;EACA;EACA;EACA;EACA;CACD;AAGD,IAAMC,cAAc,oBAAID,IAA0B;EAAC;CAAe;AAGlE,IAAME,YAAY,oBAAIF,IAA0B;EAAC;EAAoB;CAAoB;AASzF,SAASG,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;AATSP;AAqBT,SAASQ,mBACPP,MACAQ,MAA+B;AAE/B,QAAMC,OAAOV,mBAAmBC,IAAAA;AAChC,QAAMU,SAASC,mBAAmBF,MAAMD,IAAAA;AACxC,MAAIE,WAAWT,OAAW,QAAO,CAAC;AAElC,QAAMW,MAAsB,CAAC;AAC7B,aAAW,CAACC,KAAKC,KAAAA,KAAUC,OAAOC,QAAQN,MAAAA,GAAS;AACjDO,mBAAeL,KAAKC,KAA6BC,OAAOL,MAAMD,IAAAA;EAChE;AACA,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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","trim","length","apiKeyHelper","applyBooleanKey","disableSkillShellExecution","disableAllHooks","every","v","cached","rootOverride","cachedWarnings","currentOperatorPolicy","collected","push","mcpServerAdmitted","name","policy","deniedMcpServers","includes","allowedMcpServers","undefined"]}
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-MJ6FRILJ.js";
5
5
  import {
6
6
  compileAgentDefinition
7
- } from "./chunk-PMMOOXR6.js";
7
+ } from "./chunk-PYVLRSXZ.js";
8
8
  import {
9
9
  debugLog
10
10
  } from "./chunk-M5J3Q6YC.js";
@@ -2777,4 +2777,4 @@ export {
2777
2777
  delegateBackground,
2778
2778
  delegateWithScoring
2779
2779
  };
2780
- //# sourceMappingURL=chunk-HBHZV3KL.js.map
2780
+ //# sourceMappingURL=chunk-CBP72LFM.js.map
@@ -1,9 +1,20 @@
1
+ import {
2
+ currentOperatorPolicy
3
+ } from "./chunk-2SP5BB6U.js";
1
4
  import {
2
5
  __name
3
6
  } from "./chunk-Z4QWC7IK.js";
4
7
 
5
8
  // src/bridge/setting-sources-gate.ts
6
9
  import { TheokitAgentError } from "@theokit/sdk/errors";
10
+ var EVERY_SURFACE = [
11
+ "commands",
12
+ "hooks",
13
+ "plugins",
14
+ "skills",
15
+ "subagents"
16
+ ];
17
+ var IGNORE_WARNING = /* @__PURE__ */ __name(() => void 0, "IGNORE_WARNING");
7
18
  var UntrustedSettingSourceError = class extends TheokitAgentError {
8
19
  static {
9
20
  __name(this, "UntrustedSettingSourceError");
@@ -39,7 +50,7 @@ function resolveSettingSources(selection) {
39
50
  return sources;
40
51
  }
41
52
  __name(resolveSettingSources, "resolveSettingSources");
42
- function resolveCompatSources(selection) {
53
+ function resolveCompatSources(selection, onWarn) {
43
54
  if (selection?.claudeCode === void 0) return [];
44
55
  const posture = selection.claudeCode.trustedBy;
45
56
  if (!posture.allows.projectSettings) {
@@ -50,6 +61,15 @@ function resolveCompatSources(selection) {
50
61
  throw new UntrustedSettingSourceError(`\`claudeCode.import\` is an empty list, which could mean "no surfaces" or "unset, so all of them" \u2014 and the two differ by whether <cwd>/.claude/hooks.json executes. Name the surfaces you want, or omit \`import\` to take the whole root (usetheokit/theokit#686).`, selection.claudeCode.trustedBy.source, "projectSettings");
51
62
  }
52
63
  const gated = /* @__PURE__ */ __name((source) => source, "gated");
64
+ if (currentOperatorPolicy(onWarn ?? IGNORE_WARNING).disableAllHooks === true) {
65
+ const kept = (surfaces ?? EVERY_SURFACE).filter((surface) => surface !== "hooks");
66
+ return kept.length === 0 ? [] : [
67
+ gated({
68
+ kind: "claude-code",
69
+ import: kept
70
+ })
71
+ ];
72
+ }
53
73
  if (surfaces !== void 0) return [
54
74
  gated({
55
75
  kind: "claude-code",
@@ -255,4 +275,4 @@ export {
255
275
  compileAgentDefinition,
256
276
  compileSkillsSelection
257
277
  };
258
- //# sourceMappingURL=chunk-PMMOOXR6.js.map
278
+ //# sourceMappingURL=chunk-PYVLRSXZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bridge/setting-sources-gate.ts","../src/bridge/define-agent.ts"],"mappings":";;;;;;;;AACA,SAASA,yBAAyB;AA+JlC,IAAMC,gBAA0C;EAC9C;EACA;EACA;EACA;EACA;;AAGF,IAAMC,iBAAiB,6BAAYC,QAAZ;AAehB,IAAMC,8BAAN,cAA0CC,kBAAAA;EAtLjD,OAsLiDA;;;;;EAC7BC,OAAO;EAEzB,YACEC,SAESC,aAEAC,YACT;AACA,UAAMF,OAAAA,GAAAA,KAJGC,cAAAA,aAAAA,KAEAC,aAAAA;EAGX;AACF;AA0FO,SAASC,sBACdC,WAA8C;AAE9C,MAAIA,cAAcR,OAAW,QAAO,CAAA;AAIpC,QAAMS,UAAgC,CAAA;AACtC,QAAMC,QAAQ,wBAACC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C9C;WAAIL;QAAWQ,KAAK,IAAA,KAAS,QAAA,GAAW;IAEjE;AACAL,UAAMM,IAAIJ,UAAUC,OAAAA;EACtB;AACA,SAAOH;AACT;AAbSnC;","names":["TheokitAgentError","EVERY_SURFACE","IGNORE_WARNING","undefined","UntrustedSettingSourceError","TheokitAgentError","name","message","trustSource","capability","resolveSettingSources","selection","sources","gated","root","user","push","grant","project","posture","trustedBy","allows","projectSettings","level","source","pluginsGrant","plugins","resolveCompatSources","onWarn","claudeCode","surfaces","import","length","currentOperatorPolicy","disableAllHooks","kept","filter","surface","kind","AGENT_BRAND","Symbol","for","defineAgent","config","assertValidMaxIterations","maxIterations","value","undefined","Number","isInteger","Error","String","isAgentDefinition","toCompiledTool","tool","handler","compiled","name","description","inputSchema","input","ctx","sym","Object","getOwnPropertySymbols","compileAgentDefinition","def","model","reasoningEffort","systemPrompt","system","tools","map","agents","stream","context","runContext","guardrails","approvals","hitl","compileApprovals","compileSkillsSelection","skills","settingSources","resolveSettingSources","claudeCode","compatSources","resolveCompatSources","hookApproval","memory","telemetry","compileHooksAndPlugins","mcpServers","hooks","entries","filter","h","explicit","plugins","length","plugin","version","kind","register","hookName","on","skillsResolver","enabled","inline","entry","push","autoInject","toolNames","Set","t","gates","Map","toolName","options","has","join","set"]}
@@ -1,22 +1,22 @@
1
- import {
2
- currentOperatorPolicy,
3
- mcpServerAdmitted
4
- } from "./chunk-M5DRNOIU.js";
5
1
  import {
6
2
  createHitlPlugin,
7
3
  createSdkAgentStream,
8
4
  moderateOutputStream,
9
5
  runInputGuards,
10
6
  textPayloadExtractor
11
- } from "./chunk-HBHZV3KL.js";
7
+ } from "./chunk-CBP72LFM.js";
12
8
  import {
13
9
  compileAgentDefinition,
14
10
  defineAgent,
15
11
  isAgentDefinition
16
- } from "./chunk-PMMOOXR6.js";
12
+ } from "./chunk-PYVLRSXZ.js";
17
13
  import {
18
14
  ConfigurationError
19
15
  } from "./chunk-U72XTMYB.js";
16
+ import {
17
+ currentOperatorPolicy,
18
+ mcpServerAdmitted
19
+ } from "./chunk-2SP5BB6U.js";
20
20
  import {
21
21
  __name
22
22
  } from "./chunk-Z4QWC7IK.js";
@@ -1340,4 +1340,4 @@ export {
1340
1340
  generateAgentManifest,
1341
1341
  agentsPlugin
1342
1342
  };
1343
- //# sourceMappingURL=chunk-AAW4I45J.js.map
1343
+ //# sourceMappingURL=chunk-SL3QW5WZ.js.map
package/dist/config.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { TheokitAgentError } from '@theokit/sdk/errors';
2
2
  import { z } from 'zod';
3
- import { TrustPosture, LayerValues } from '@theokit/sdk';
4
- export { DeclaredLayer, LayerValues } from '@theokit/sdk';
5
- import { R as ResolvedCompatSource } from './setting-sources-gate-DFu51i50.js';
3
+ import { TrustPosture, LayerValues, PermissionRule } from '@theokit/sdk';
4
+ export { DeclaredLayer, LayerValues, PermissionAction, PermissionRule } from '@theokit/sdk';
5
+ import { R as ResolvedCompatSource } from './setting-sources-gate-BXdZmY78.js';
6
6
  export { resolveEffectiveContextWindow as effectiveContextWindow } from '@theokit/sdk/compaction';
7
7
 
8
8
  /**
@@ -724,6 +724,182 @@ interface LoadOutputStyleInput {
724
724
  * were searched.
725
725
  */
726
726
  declare function loadOutputStyle(input: LoadOutputStyleInput): OutputStyle | undefined;
727
+ /**
728
+ * The style the project's settings name, read from the project's style files.
729
+ *
730
+ * The two halves of the documented mechanism, joined. `loadSettings` reads the `outputStyle` key and
731
+ * {@link loadOutputStyle} reads the file; until this existed nothing connected them, so a consumer
732
+ * had to find both modules and know that one feeds the other. Two halves each individually correct
733
+ * and jointly unreachable is the same defect as a capability with no caller — it just takes two
734
+ * files to make.
735
+ *
736
+ * Deliberately does NOT soften the loader: a style named in settings with no file behind it still
737
+ * throws {@link OutputStyleError}. Returning `undefined` there would restore the exact silence this
738
+ * work removed — configured, not applied, and no way to tell which.
739
+ *
740
+ * @throws OutputStyleError when settings name a style and no file backs it.
741
+ */
742
+ declare function resolveOutputStyle(input: {
743
+ readonly cwd: string;
744
+ readonly homeDir?: string;
745
+ readonly onWarn?: (message: string) => void;
746
+ }): OutputStyle | undefined;
747
+
748
+ /** What an operator may impose on THIS layer. */
749
+ interface OperatorPolicy {
750
+ /**
751
+ * Refuse to execute the `` !`command` `` form in a skill or command body.
752
+ *
753
+ * A skill is a markdown file a repository can carry, and its body runs shell at expansion time.
754
+ * Without this the only way to decline was to stop reading skills at all.
755
+ */
756
+ disableSkillShellExecution?: boolean;
757
+ /**
758
+ * Refuse every hook declared under a foreign configuration root.
759
+ *
760
+ * B-042. `.claude/hooks.json` runs shell commands out of a working directory that usually arrived
761
+ * with the clone, and until this key existed an operator who inherited an untrusted checkout could
762
+ * not decline hook execution without editing files in it. `resolveCompatSources` reads this and
763
+ * drops the `hooks` surface from what it grants.
764
+ *
765
+ * ## It fails CLOSED, unlike every other key here
766
+ *
767
+ * The others ignore a value of the wrong shape and warn. For this one that is fail-OPEN: an
768
+ * operator who writes `"true"` as a string would get hooks running while believing they were off.
769
+ * The asymmetry decides it — fail-open is silent and unsafe, fail-closed is loud and recoverable:
770
+ * hooks stop, somebody notices, the typo is fixed. For a control whose purpose is refusing,
771
+ * failing toward the refusal is the only direction where the failure announces itself.
772
+ *
773
+ * An ABSENT key is not a malformed one and still means "hooks run": most machines have no operator
774
+ * tier, and refusing by default would remove hooks nobody asked to remove.
775
+ */
776
+ disableAllHooks?: boolean;
777
+ /**
778
+ * Servers from a project `.mcp.json` that may NOT start, by name.
779
+ *
780
+ * Deny wins over {@link OperatorPolicy.allowedMcpServers}. A server named in both is a
781
+ * contradiction, and the safe reading of a contradiction is the restrictive one — resolving it the
782
+ * other way would let an allow entry re-enable something an operator explicitly refused.
783
+ */
784
+ deniedMcpServers?: readonly string[];
785
+ /**
786
+ * When present, the ONLY servers from a project `.mcp.json` that may start.
787
+ *
788
+ * Absent means "no allow list", not "allow nothing": the file is the project's own declaration and
789
+ * the default stays permissive by CHOICE, because refusing it outright would break every existing
790
+ * consumer to protect against a file they wrote themselves. An empty ARRAY is a real decision and
791
+ * refuses everything.
792
+ */
793
+ allowedMcpServers?: readonly string[];
794
+ /**
795
+ * B-069 — a command that prints a credential on stdout, re-run whenever one is needed.
796
+ *
797
+ * An operator whose tokens rotate had no seam at all: a long-running agent failed mid-run and the
798
+ * only answer was a restart with a fresh environment variable. This is declared HERE rather than
799
+ * on `defineAgent` for the reason B-065 records — the person answerable for what runs on a machine
800
+ * is frequently not the person who wrote the code, and a command that mints a secret is the most
801
+ * operator-shaped thing in the system.
802
+ *
803
+ * Run by {@link runCredentialHelper}, which bounds it with a timeout and refuses an empty result.
804
+ */
805
+ apiKeyHelper?: string;
806
+ }
807
+ declare function currentOperatorPolicy(warn: (message: string) => void): OperatorPolicy;
808
+ /**
809
+ * Whether a server declared in a project `.mcp.json` may start.
810
+ *
811
+ * Deny first: a server in both lists is refused. An allow list, once present, is EXHAUSTIVE —
812
+ * anything unnamed is refused — while an absent one means "no allow list", not "allow nothing".
813
+ */
814
+ declare function mcpServerAdmitted(name: string, policy: OperatorPolicy): boolean;
815
+
816
+ /**
817
+ * Translate a settings `permissions` block into rules the SDK's engine evaluates.
818
+ *
819
+ * The SDK ships `PermissionEngine(rules, { defaultAction })` and it is a CODE surface: you construct
820
+ * it with `PermissionRule[]`. What was missing was the path from the FILE to those rules. Measured
821
+ * 2026-09-11: `permissions` appears in 13 SDK files, and the SDK reads `settings.json` in three, of
822
+ * which two are sourcemaps and the third describes the hooks shape. An operator writing
823
+ * `{ "permissions": { "deny": ["Bash(curl:*)"] } }` got a file nothing translated.
824
+ *
825
+ * ## Partial fidelity would be worse than absence
826
+ *
827
+ * A `deny` that silently fails to match is a control the operator believes is in force — strictly
828
+ * more dangerous than no rule, because without one they would have written the guard themselves. So
829
+ * every entry this module cannot render faithfully is RETURNED as unsupported, with a reason, and
830
+ * excluded from the rules. Nothing is quietly turned into a matcher that does not bite.
831
+ *
832
+ * ## What it deliberately does not attempt
833
+ *
834
+ * The reference's specifier language is larger than this: path globs with `~` expansion, per-tool
835
+ * argument names, and matching semantics that differ by tool. Implementing a lookalike would produce
836
+ * rules that match *almost* the right calls, which is the failure above. Two forms are translated —
837
+ * a bare tool name, and `Tool(prefix:*)` / `Tool(exact)` — and everything else is reported.
838
+ */
839
+
840
+ /** An entry that was understood well enough to refuse, but not well enough to translate. */
841
+ interface UnsupportedPermissionEntry {
842
+ /** The entry as written, so the operator can find it in their file. */
843
+ readonly entry: string;
844
+ /** Why it was not translated. */
845
+ readonly reason: string;
846
+ }
847
+ interface PermissionTranslation {
848
+ readonly rules: readonly PermissionRule[];
849
+ readonly unsupported: readonly UnsupportedPermissionEntry[];
850
+ }
851
+ /** The `permissions` block as a settings file may carry it. */
852
+ interface PermissionsBlock {
853
+ readonly allow?: readonly string[];
854
+ readonly deny?: readonly string[];
855
+ readonly ask?: readonly string[];
856
+ }
857
+ /**
858
+ * The rules a `permissions` block means, and the entries that could not be rendered.
859
+ *
860
+ * An absent or empty block yields nothing and reports nothing: most projects declare no permissions,
861
+ * and a translator that warned there would be noise in every one of them.
862
+ */
863
+ declare function permissionRulesFromSettings(block: PermissionsBlock | undefined): PermissionTranslation;
864
+
865
+ /**
866
+ * The keys this layer can act on today, plus everything else untouched.
867
+ *
868
+ * Typed narrowly on purpose: a key is listed here when something in this package reads it, not
869
+ * because the reference documents it. Declaring a field the code ignores would publish a control
870
+ * that does nothing, which is the shape every item in this batch had.
871
+ */
872
+ declare const SETTINGS_SCHEMA: z.ZodObject<{
873
+ outputStyle: z.ZodOptional<z.ZodString>;
874
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
875
+ permissions: z.ZodOptional<z.ZodObject<{
876
+ allow: z.ZodOptional<z.ZodArray<z.ZodString>>;
877
+ deny: z.ZodOptional<z.ZodArray<z.ZodString>>;
878
+ ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
879
+ }, z.core.$loose>>;
880
+ }, z.core.$loose>;
881
+ type Settings = z.infer<typeof SETTINGS_SCHEMA>;
882
+ interface LoadSettingsInput {
883
+ /** Project root. Its `.claude/settings.json` and `.claude/settings.local.json` are read. */
884
+ readonly cwd: string;
885
+ /** Home directory, for the user-level file. Omit to read the project only. */
886
+ readonly homeDir?: string;
887
+ /** Where a file that exists and cannot be parsed is reported. */
888
+ readonly onWarn?: (message: string) => void;
889
+ }
890
+ interface LoadSettingsResult {
891
+ readonly values: Settings;
892
+ /** Which layer each resolved key came from. */
893
+ readonly provenancePerKey: Readonly<Record<string, string>>;
894
+ /** Which declared layers contributed nothing — a file nobody is reading is named, not hidden. */
895
+ readonly precedenceReport: PrecedenceReport;
896
+ }
897
+ /**
898
+ * The settings as the declared layers resolve them.
899
+ *
900
+ * Never throws for a missing or malformed file; see {@link readLayer}.
901
+ */
902
+ declare function loadSettings(input: LoadSettingsInput): LoadSettingsResult;
727
903
 
728
904
  /**
729
905
  * Split a markdown file into frontmatter lines and body.
@@ -814,4 +990,4 @@ declare class ContextPressureThresholdError extends TheokitAgentError {
814
990
  */
815
991
  declare function contextPressure(usedTokens: number, effectiveWindow: number, thresholds?: ContextPressureThresholds): ContextPressure;
816
992
 
817
- export { type ComposeInstructionsOptions, type ComposedInstructions, type ConfigLayer, type ContextPressure, ContextPressureThresholdError, type ContextPressureThresholds, type CustomCommand, type CustomCommandsResult, DEFAULT_CONTEXT_PRESSURE_THRESHOLDS, type ExpandImportsInput, FILE_INLINE_CAP, type InstructionBlock, type InstructionSource, type InstructionTree, type InstructionTreeBudget, LAYERS_ARE_POSITIONED, LayerOutOfOrderError, LayeredConfig, type LayeredConfigInput, type LayeredConfigResult, type LoadCustomCommandsInput, type LoadInstructionTreeInput, type LoadOutputStyleInput, type OutputStyle, OutputStyleError, type ParsedFrontmatter, type PrecedenceReport, type ProvenancePerKey, SETTINGS_LAYERS, type SettingsLayer, type ShellResult, type TemplateDeps, type TrustRecord, TrustStore, TrustStorePermissionsError, blockAppliesTo, composeInstructions, contextPressure, expandCommandTemplate, expandInstructionImports, frontmatterValue, layerPrecedence, loadCustomCommands, loadInstructionTree, loadOutputStyle, settingsLayerChain, splitFrontmatter, templateHints };
993
+ export { type ComposeInstructionsOptions, type ComposedInstructions, type ConfigLayer, type ContextPressure, ContextPressureThresholdError, type ContextPressureThresholds, type CustomCommand, type CustomCommandsResult, DEFAULT_CONTEXT_PRESSURE_THRESHOLDS, type ExpandImportsInput, FILE_INLINE_CAP, type InstructionBlock, type InstructionSource, type InstructionTree, type InstructionTreeBudget, LAYERS_ARE_POSITIONED, LayerOutOfOrderError, LayeredConfig, type LayeredConfigInput, type LayeredConfigResult, type LoadCustomCommandsInput, type LoadInstructionTreeInput, type LoadOutputStyleInput, type LoadSettingsInput, type LoadSettingsResult, type OperatorPolicy, type OutputStyle, OutputStyleError, type ParsedFrontmatter, type PermissionTranslation, type PermissionsBlock, type PrecedenceReport, type ProvenancePerKey, SETTINGS_LAYERS, type Settings, type SettingsLayer, type ShellResult, type TemplateDeps, type TrustRecord, TrustStore, TrustStorePermissionsError, type UnsupportedPermissionEntry, blockAppliesTo, composeInstructions, contextPressure, currentOperatorPolicy, expandCommandTemplate, expandInstructionImports, frontmatterValue, layerPrecedence, loadCustomCommands, loadInstructionTree, loadOutputStyle, loadSettings, mcpServerAdmitted, permissionRulesFromSettings, resolveOutputStyle, settingsLayerChain, splitFrontmatter, templateHints };