@theokit/agents 13.0.0-next.5 → 13.0.0-next.7
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 +50 -0
- package/dist/{agent-compiler-uhleFZj_.d.ts → agent-compiler-C2jIZ4CZ.d.ts} +61 -1
- package/dist/{bridge-entry--4VYlECy.d.ts → bridge-entry-Db0SZbYj.d.ts} +3 -3
- package/dist/bridge.d.ts +4 -4
- package/dist/bridge.js +5 -3
- package/dist/{chunk-GHRHJPJS.js → chunk-NZTLBLHB.js} +178 -130
- package/dist/chunk-NZTLBLHB.js.map +1 -0
- package/dist/{chunk-OAQEWLQJ.js → chunk-X4IGZHOV.js} +7 -1
- package/dist/chunk-X4IGZHOV.js.map +1 -0
- package/dist/{chunk-LTPL32XW.js → chunk-YVPQ3KSA.js} +3 -3
- package/dist/{chunk-LTPL32XW.js.map → chunk-YVPQ3KSA.js.map} +1 -1
- package/dist/{define-agent-BL3jMyJi.d.ts → define-agent-WYnUlWaH.d.ts} +9 -1
- package/dist/{delegation-scoring--OiOTcAW.d.ts → delegation-scoring-BrBQXvIp.d.ts} +1 -1
- package/dist/index.d.ts +18 -9
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-GHRHJPJS.js.map +0 -1
- package/dist/chunk-OAQEWLQJ.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# @theokit/agents
|
|
2
2
|
|
|
3
|
+
## 13.0.0-next.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a2b0a59: The hook gate's vocabulary crosses with the capability that takes it
|
|
8
|
+
|
|
9
|
+
`13.0.0-next.6` exported `HookApprovalCapability` and withheld `HookApprovalGate`,
|
|
10
|
+
`HookApprovalRequest` and `HookGateUnsupportedError`. A consumer could build the gate, and could
|
|
11
|
+
neither type the object it takes nor catch its refusal by class — which matters more here than
|
|
12
|
+
usual, because refusing loudly is the whole design.
|
|
13
|
+
|
|
14
|
+
Fourth instance of the same shape (#663 `AgentModule`, #668 `transcriptOf`, #675 `RegistryOutcome`),
|
|
15
|
+
and the first three were each found by installing the published package. The source is correct every
|
|
16
|
+
time: the type IS exported from its own module, and only the barrel omits it.
|
|
17
|
+
|
|
18
|
+
A guard now reads the EMITTED `dist/index.d.ts` export list rather than the source, and it was
|
|
19
|
+
proved able to fail by removing one export and watching it name that one.
|
|
20
|
+
|
|
21
|
+
## 13.0.0-next.6
|
|
22
|
+
|
|
23
|
+
### Minor Changes
|
|
24
|
+
|
|
25
|
+
- 462bb62: The pre-spawn hook approval gate crosses the layer, or refuses to pretend it did
|
|
26
|
+
|
|
27
|
+
`@theokit/sdk@5.4.0` added `local.hooks.approve` — a consumer's decision point before the runtime
|
|
28
|
+
spawns a hook. This layer never forwarded it, so a hook declared in a config root, including a
|
|
29
|
+
foreign dialect imported through `compatSources`, ran shell without passing the consumer's approval.
|
|
30
|
+
|
|
31
|
+
Measured in a consumer against 5.4.0, with a control arm proving the zero was not an empty turn:
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
control_nothing fires=0 tool_ran=yes
|
|
35
|
+
claude_project_unapproved fires=1 tool_ran=yes
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`defineAgent({ hookApproval })` and the new `HookApprovalCapability` now carry it to
|
|
39
|
+
`Agent.create({ local: { hooks } })`. Named `hookApproval` rather than `hooks` because
|
|
40
|
+
`defineAgent({ hooks })` is already the LIFECYCLE seam, and two security-relevant things under one
|
|
41
|
+
name is how a consumer configures the wrong one.
|
|
42
|
+
|
|
43
|
+
**Declaring it against an SDK older than 5.4.0 is REFUSED, not forwarded.** The option is 5.4.0-only
|
|
44
|
+
while this package's floor is `^4.52.1`, so a pass-through would compile and do nothing on most
|
|
45
|
+
admitted versions — a gate that silently does not gate, which is worse than offering none, because
|
|
46
|
+
whoever configured it stops looking. An unreadable SDK version is refused for the same reason:
|
|
47
|
+
"cannot tell" and "is gated" must not collapse.
|
|
48
|
+
|
|
49
|
+
The floor is unchanged, so no consumer is pinned to a newer SDK for a feature they did not ask for.
|
|
50
|
+
|
|
51
|
+
Closes usetheokit/theokit#686 (the `hooks` half; `resolveCompatSources` widening is tracked there).
|
|
52
|
+
|
|
3
53
|
## 13.0.0-next.5
|
|
4
54
|
|
|
5
55
|
### Patch Changes
|
|
@@ -97,6 +97,58 @@ type SkillsSelection = readonly (string | InlineSkill)[] | ((ctx: SkillsRequestC
|
|
|
97
97
|
*/
|
|
98
98
|
declare function resolveEnabledSkills(selection: SkillsSelection | undefined, ctx: SkillsRequestContext): Promise<string[] | undefined>;
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Project the M8 fields from `CompiledAgentOptions` into `Agent.create()` arguments. Only the async
|
|
102
|
+
* `@ProjectContext` resolver is built here (it does I/O, so the compiler keeps it raw). `applied`
|
|
103
|
+
* lists which decorators contributed, for the observability log (wiring triad — runtime metric).
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* #686 — a consumer's decision point before the SDK spawns a hook, forwarded to
|
|
107
|
+
* `Agent.create({ local: { hooks } })`.
|
|
108
|
+
*
|
|
109
|
+
* Declared here rather than imported: the SDK's `HookApprovalGate` landed in `5.4.0` and this
|
|
110
|
+
* package's floor is `^4.52.1`, so importing the type would refuse to build on every version below
|
|
111
|
+
* it. The shape is structural and small, which is the same reasoning `compatSources` already
|
|
112
|
+
* records — "a string union is declarable here".
|
|
113
|
+
*
|
|
114
|
+
* The SDK calls the option `hooks`. On this layer's authoring surface it is `hookApproval`, because
|
|
115
|
+
* `defineAgent({ hooks })` is already the LIFECYCLE seam and two different security-relevant things
|
|
116
|
+
* under one name is how a consumer configures the wrong one.
|
|
117
|
+
*/
|
|
118
|
+
interface HookApprovalGate {
|
|
119
|
+
readonly approve?: (request: HookApprovalRequest) => boolean | Promise<boolean>;
|
|
120
|
+
}
|
|
121
|
+
/** What the consumer is shown when asked to approve a hook. Mirrors the SDK's shape (5.4.0). */
|
|
122
|
+
interface HookApprovalRequest {
|
|
123
|
+
readonly command: string;
|
|
124
|
+
readonly event: string;
|
|
125
|
+
readonly sourcePath?: string;
|
|
126
|
+
readonly matcher?: string;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Refuses when the installed SDK cannot honour a declared hook gate.
|
|
130
|
+
*
|
|
131
|
+
* ## Why this THROWS where its `compatSources` sibling only warns
|
|
132
|
+
*
|
|
133
|
+
* That one guards a configuration source: ignored, the foreign root is not read, and the agent runs
|
|
134
|
+
* with less than was asked for. This one guards a SECURITY decision. Ignored, the agent runs with
|
|
135
|
+
* MORE than was asked for — every hook spawns unreviewed — while the consumer believes it is gated
|
|
136
|
+
* and stops looking. The consumer that reported #686 asked for the refusal in those words: they
|
|
137
|
+
* would rather have no gate than a silent one, because their `doctor` would otherwise publish a
|
|
138
|
+
* guarantee that is false on `@theokit/sdk@5.0.0`.
|
|
139
|
+
*
|
|
140
|
+
* ## Why an unreadable version is a refusal and not a shrug
|
|
141
|
+
*
|
|
142
|
+
* The sibling stays silent when it cannot read the version, and that is right for a diagnostic. Here
|
|
143
|
+
* "cannot tell" and "is gated" must not collapse: unproven is not proven, and this whole issue is
|
|
144
|
+
* one instance of that confusion. A bundled SDK that hides `package.json` gets an explicit refusal
|
|
145
|
+
* naming what it could not read, which is recoverable; a silent pass is not.
|
|
146
|
+
*/
|
|
147
|
+
declare class HookGateUnsupportedError extends TheokitAgentError {
|
|
148
|
+
readonly name = "HookGateUnsupportedError";
|
|
149
|
+
constructor(version: string | undefined);
|
|
150
|
+
}
|
|
151
|
+
|
|
100
152
|
/**
|
|
101
153
|
* Agent compiler — transforms decorator metadata into SDK calls.
|
|
102
154
|
*
|
|
@@ -194,6 +246,14 @@ interface CompiledAgentOptions {
|
|
|
194
246
|
* can only hold a source some posture granted, so the adapter projects rather than decides.
|
|
195
247
|
*/
|
|
196
248
|
compatSources?: readonly string[];
|
|
249
|
+
/**
|
|
250
|
+
* #686 — the consumer's pre-spawn approval gate, forwarded to `Agent.create({ local: { hooks } })`.
|
|
251
|
+
*
|
|
252
|
+
* Distinct from `hitl` (which gates TOOLS at run time) and from the lifecycle `plugins` below
|
|
253
|
+
* (which react to events). This one decides whether a hook declared in a config root — including
|
|
254
|
+
* a foreign dialect imported through `compatSources` — is spawned at all.
|
|
255
|
+
*/
|
|
256
|
+
hookApproval?: HookApprovalGate;
|
|
197
257
|
/** Code `Plugin` objects forwarded to `Agent.create({ plugins })` (lifecycle-hook seam). */
|
|
198
258
|
plugins?: readonly unknown[];
|
|
199
259
|
tools: CompiledTool[];
|
|
@@ -238,4 +298,4 @@ interface CompiledAgentOptions {
|
|
|
238
298
|
skillsResolver?: SkillsSelection;
|
|
239
299
|
}
|
|
240
300
|
|
|
241
|
-
export { type CompiledAgentOptions as C, type Guardrail as G, type SkillsSelection as S, type ToolWalkResult as T, type CompiledTool as a, CostBudgetExceededError as b, type GuardrailAction as c, type GuardrailPhase as d, type GuardrailResult as e, GuardrailViolationError as f, type
|
|
301
|
+
export { type CompiledAgentOptions as C, type Guardrail as G, type HookApprovalGate as H, type SkillsSelection as S, type ToolWalkResult as T, type CompiledTool as a, CostBudgetExceededError as b, type GuardrailAction as c, type GuardrailPhase as d, type GuardrailResult as e, GuardrailViolationError as f, type HookApprovalRequest as g, HookGateUnsupportedError as h, type SkillsRequestContext as i, type ToolboxWalkResult as j, compileTools as k, resolveEnabledSkills as r };
|
|
@@ -1,11 +1,11 @@
|
|
|
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 } from './agent-compiler-
|
|
3
|
+
import { C as CompiledAgentOptions, a as CompiledTool, G as Guardrail, S as SkillsSelection } from './agent-compiler-C2jIZ4CZ.js';
|
|
4
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
|
|
5
|
+
import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-BrBQXvIp.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-
|
|
8
|
+
import { A as AgentDefinition, S as SettingSourcesSelection } from './define-agent-WYnUlWaH.js';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
|
|
11
11
|
import { WireChunk } from '@theokit/presenter/wire';
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
2
|
-
export { C as CompiledAgentOptions, a as CompiledTool, T as ToolWalkResult,
|
|
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
|
|
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-
|
|
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-Db0SZbYj.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';
|
|
5
5
|
import '@theokit/http';
|
|
6
6
|
import './types-C16Wuh9E.js';
|
|
7
7
|
import '@theokit/sdk';
|
package/dist/bridge.js
CHANGED
|
@@ -29,13 +29,14 @@ import {
|
|
|
29
29
|
runWithApiErrorHandling,
|
|
30
30
|
streamAgentResponse,
|
|
31
31
|
streamAgentUIMessages
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-YVPQ3KSA.js";
|
|
33
33
|
import {
|
|
34
34
|
APPROVAL_MODES,
|
|
35
35
|
BudgetExceededError,
|
|
36
36
|
DelegationBudgetExceededError,
|
|
37
37
|
DelegationError,
|
|
38
38
|
DelegationTimeoutError,
|
|
39
|
+
HookGateUnsupportedError,
|
|
39
40
|
WRITE_SCOPED_TOOLS,
|
|
40
41
|
applyPosture,
|
|
41
42
|
buildModelSelection,
|
|
@@ -54,7 +55,7 @@ import {
|
|
|
54
55
|
translateSdkEvent,
|
|
55
56
|
withClockCap,
|
|
56
57
|
withEphemeralAgent
|
|
57
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-NZTLBLHB.js";
|
|
58
59
|
import "./chunk-RKWCXVYG.js";
|
|
59
60
|
import {
|
|
60
61
|
AGENT_BRAND,
|
|
@@ -63,7 +64,7 @@ import {
|
|
|
63
64
|
isAgentDefinition,
|
|
64
65
|
resolveCompatSources,
|
|
65
66
|
resolveSettingSources
|
|
66
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-X4IGZHOV.js";
|
|
67
68
|
import "./chunk-OXNDJSAJ.js";
|
|
68
69
|
import "./chunk-Z4QWC7IK.js";
|
|
69
70
|
export {
|
|
@@ -76,6 +77,7 @@ export {
|
|
|
76
77
|
DelegationBudgetExceededError,
|
|
77
78
|
DelegationError,
|
|
78
79
|
DelegationTimeoutError,
|
|
80
|
+
HookGateUnsupportedError,
|
|
79
81
|
McpFileError,
|
|
80
82
|
UntrustedSettingSourceError,
|
|
81
83
|
WRITE_SCOPED_TOOLS,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-RKWCXVYG.js";
|
|
5
5
|
import {
|
|
6
6
|
compileAgentDefinition
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-X4IGZHOV.js";
|
|
8
8
|
import {
|
|
9
9
|
createRunUsageMeter
|
|
10
10
|
} from "./chunk-OXNDJSAJ.js";
|
|
@@ -517,6 +517,174 @@ function reasoningEffortOf(model) {
|
|
|
517
517
|
}
|
|
518
518
|
__name(reasoningEffortOf, "reasoningEffortOf");
|
|
519
519
|
|
|
520
|
+
// src/bridge/sdk-adapter-create-options.ts
|
|
521
|
+
import { createRequire } from "module";
|
|
522
|
+
import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
|
|
523
|
+
var HOOK_GATE_SINCE = {
|
|
524
|
+
major: 5,
|
|
525
|
+
minor: 4
|
|
526
|
+
};
|
|
527
|
+
var HookGateUnsupportedError = class extends TheokitAgentError2 {
|
|
528
|
+
static {
|
|
529
|
+
__name(this, "HookGateUnsupportedError");
|
|
530
|
+
}
|
|
531
|
+
name = "HookGateUnsupportedError";
|
|
532
|
+
constructor(version) {
|
|
533
|
+
super(`a hook approval gate was declared, but the installed @theokit/sdk (${version ?? "version unreadable"}) cannot honour it: \`local.hooks\` landed in ${String(HOOK_GATE_SINCE.major)}.${String(HOOK_GATE_SINCE.minor)}.0. Forwarding it anyway would leave every hook spawning unreviewed while the gate reports as installed. Upgrade @theokit/sdk, or remove \`hookApproval\` and keep whatever refusal you have today (usetheokit/theokit#686).`, {
|
|
534
|
+
code: "hook_gate_unsupported",
|
|
535
|
+
isRetryable: false
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
function assertSdkCanGateHooks(version) {
|
|
540
|
+
const [major, minor] = (version ?? "").split(".").map((n) => Number.parseInt(n, 10));
|
|
541
|
+
const known = Number.isFinite(major) && Number.isFinite(minor);
|
|
542
|
+
const supported = known && (major > HOOK_GATE_SINCE.major || major === HOOK_GATE_SINCE.major && minor >= HOOK_GATE_SINCE.minor);
|
|
543
|
+
if (!supported) throw new HookGateUnsupportedError(version);
|
|
544
|
+
}
|
|
545
|
+
__name(assertSdkCanGateHooks, "assertSdkCanGateHooks");
|
|
546
|
+
function installedSdkVersion() {
|
|
547
|
+
try {
|
|
548
|
+
return createRequire(import.meta.url)("@theokit/sdk/package.json").version;
|
|
549
|
+
} catch {
|
|
550
|
+
return void 0;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
__name(installedSdkVersion, "installedSdkVersion");
|
|
554
|
+
var sdkCompatWarningEmitted = false;
|
|
555
|
+
function warnIfSdkCannotReadCompatSources() {
|
|
556
|
+
if (sdkCompatWarningEmitted) return;
|
|
557
|
+
let version;
|
|
558
|
+
try {
|
|
559
|
+
version = createRequire(import.meta.url)("@theokit/sdk/package.json").version;
|
|
560
|
+
} catch {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
const major = Number.parseInt(version?.split(".")[0] ?? "", 10);
|
|
564
|
+
if (!Number.isFinite(major) || major >= 5) return;
|
|
565
|
+
sdkCompatWarningEmitted = true;
|
|
566
|
+
console.warn(`[theokit/agents] \`compatSources\` was declared, but @theokit/sdk@${version} does not know that option and will ignore it \u2014 the foreign configuration root will NOT be read. It landed in 5.0.0. Until this package's floor can name a stable 5.x, override the SDK in your workspace (usetheokit/theokit#634).`);
|
|
567
|
+
}
|
|
568
|
+
__name(warnIfSdkCannotReadCompatSources, "warnIfSdkCannotReadCompatSources");
|
|
569
|
+
function applyLocalSources(compiled, options, applied) {
|
|
570
|
+
if (compiled.settingSources !== void 0 && compiled.settingSources.length > 0) {
|
|
571
|
+
options.local = {
|
|
572
|
+
...options.local,
|
|
573
|
+
settingSources: [
|
|
574
|
+
...compiled.settingSources
|
|
575
|
+
]
|
|
576
|
+
};
|
|
577
|
+
applied.push("settingSources");
|
|
578
|
+
}
|
|
579
|
+
if (compiled.compatSources !== void 0 && compiled.compatSources.length > 0) {
|
|
580
|
+
options.local = {
|
|
581
|
+
...options.local,
|
|
582
|
+
compatSources: [
|
|
583
|
+
...compiled.compatSources
|
|
584
|
+
]
|
|
585
|
+
};
|
|
586
|
+
applied.push("compatSources");
|
|
587
|
+
warnIfSdkCannotReadCompatSources();
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
__name(applyLocalSources, "applyLocalSources");
|
|
591
|
+
function applyHookApproval(compiled, options, applied, sdkVersion) {
|
|
592
|
+
if (compiled.hookApproval === void 0) return;
|
|
593
|
+
assertSdkCanGateHooks(sdkVersion ?? installedSdkVersion());
|
|
594
|
+
options.local = {
|
|
595
|
+
...options.local,
|
|
596
|
+
hooks: compiled.hookApproval
|
|
597
|
+
};
|
|
598
|
+
applied.push("hookApproval");
|
|
599
|
+
}
|
|
600
|
+
__name(applyHookApproval, "applyHookApproval");
|
|
601
|
+
function assembleM8CreateOptions(compiled, deps = {}) {
|
|
602
|
+
const options = {};
|
|
603
|
+
const applied = [];
|
|
604
|
+
const base = compiled.systemPrompt;
|
|
605
|
+
if (compiled.skills) {
|
|
606
|
+
options.skills = compiled.skills;
|
|
607
|
+
applied.push("skills");
|
|
608
|
+
}
|
|
609
|
+
if (compiled.plugins) {
|
|
610
|
+
options.plugins = compiled.plugins;
|
|
611
|
+
applied.push("plugins");
|
|
612
|
+
}
|
|
613
|
+
applyLocalSources(compiled, options, applied);
|
|
614
|
+
applyHookApproval(compiled, options, applied, deps.sdkVersion);
|
|
615
|
+
if (compiled.context) {
|
|
616
|
+
options.context = compiled.context;
|
|
617
|
+
applied.push("context");
|
|
618
|
+
}
|
|
619
|
+
if (compiled.projectContext) {
|
|
620
|
+
options.systemPrompt = compileProjectContext(compiled.projectContext, base);
|
|
621
|
+
applied.push("projectContext");
|
|
622
|
+
} else if (base !== void 0) {
|
|
623
|
+
options.systemPrompt = base;
|
|
624
|
+
}
|
|
625
|
+
if (compiled.mcpServers && Object.keys(compiled.mcpServers).length > 0) {
|
|
626
|
+
options.mcpServers = compiled.mcpServers;
|
|
627
|
+
applied.push("mcpServers");
|
|
628
|
+
}
|
|
629
|
+
if (compiled.memory !== void 0) {
|
|
630
|
+
if ("enabled" in compiled.memory) {
|
|
631
|
+
options.memory = compiled.memory;
|
|
632
|
+
} else {
|
|
633
|
+
const dropped = Object.keys(compiled.memory);
|
|
634
|
+
if (dropped.length > 0) {
|
|
635
|
+
process.stderr.write(`[theokit-agents] @Memory decorator options not yet mapped to the SDK (${dropped.join(", ")}) \u2014 memory enabled with defaults
|
|
636
|
+
`);
|
|
637
|
+
}
|
|
638
|
+
options.memory = {
|
|
639
|
+
enabled: true
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
applied.push("memory");
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
options,
|
|
646
|
+
applied
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
__name(assembleM8CreateOptions, "assembleM8CreateOptions");
|
|
650
|
+
function stopReasonOf(result) {
|
|
651
|
+
if (result.stoppedByDoomLoop === true) return "no_progress";
|
|
652
|
+
if (result.stoppedAtIterationLimit === true) return "step_limit";
|
|
653
|
+
return void 0;
|
|
654
|
+
}
|
|
655
|
+
__name(stopReasonOf, "stopReasonOf");
|
|
656
|
+
function realUsageDone(result, t0, model) {
|
|
657
|
+
const u = result.usage;
|
|
658
|
+
const inputTokens = u?.inputTokens ?? 0;
|
|
659
|
+
const outputTokens = u?.outputTokens ?? 0;
|
|
660
|
+
const stopReason = stopReasonOf(result);
|
|
661
|
+
return {
|
|
662
|
+
type: "done",
|
|
663
|
+
result: result.result ?? "",
|
|
664
|
+
// V4-O: forward the SDK reasoning/cache buckets (0 when the provider omits them) so a
|
|
665
|
+
// consumer keeps full per-turn usage through the loop into DelegationResult (passthrough — ADR D1).
|
|
666
|
+
usage: {
|
|
667
|
+
inputTokens,
|
|
668
|
+
outputTokens,
|
|
669
|
+
totalTokens: inputTokens + outputTokens,
|
|
670
|
+
reasoningTokens: u?.reasoningTokens ?? 0,
|
|
671
|
+
cacheReadTokens: u?.cacheReadTokens ?? 0,
|
|
672
|
+
cacheWriteTokens: u?.cacheWriteTokens ?? 0
|
|
673
|
+
},
|
|
674
|
+
durationMs: Date.now() - t0,
|
|
675
|
+
cost: result.cost?.amount ?? 0,
|
|
676
|
+
...terminalExtras(stopReason, model)
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
__name(realUsageDone, "realUsageDone");
|
|
680
|
+
function terminalExtras(stopReason, model) {
|
|
681
|
+
const extras = {};
|
|
682
|
+
if (stopReason !== void 0) extras.stopReason = stopReason;
|
|
683
|
+
if (model !== void 0) extras.model = model;
|
|
684
|
+
return extras;
|
|
685
|
+
}
|
|
686
|
+
__name(terminalExtras, "terminalExtras");
|
|
687
|
+
|
|
520
688
|
// src/bridge/event-translator.ts
|
|
521
689
|
function asString(value, fallback) {
|
|
522
690
|
if (typeof value === "string") return value;
|
|
@@ -888,127 +1056,6 @@ function resolveProjection(def, overrides) {
|
|
|
888
1056
|
}
|
|
889
1057
|
__name(resolveProjection, "resolveProjection");
|
|
890
1058
|
|
|
891
|
-
// src/bridge/sdk-adapter-create-options.ts
|
|
892
|
-
import { createRequire } from "module";
|
|
893
|
-
var sdkCompatWarningEmitted = false;
|
|
894
|
-
function warnIfSdkCannotReadCompatSources() {
|
|
895
|
-
if (sdkCompatWarningEmitted) return;
|
|
896
|
-
let version;
|
|
897
|
-
try {
|
|
898
|
-
version = createRequire(import.meta.url)("@theokit/sdk/package.json").version;
|
|
899
|
-
} catch {
|
|
900
|
-
return;
|
|
901
|
-
}
|
|
902
|
-
const major = Number.parseInt(version?.split(".")[0] ?? "", 10);
|
|
903
|
-
if (!Number.isFinite(major) || major >= 5) return;
|
|
904
|
-
sdkCompatWarningEmitted = true;
|
|
905
|
-
console.warn(`[theokit/agents] \`compatSources\` was declared, but @theokit/sdk@${version} does not know that option and will ignore it \u2014 the foreign configuration root will NOT be read. It landed in 5.0.0. Until this package's floor can name a stable 5.x, override the SDK in your workspace (usetheokit/theokit#634).`);
|
|
906
|
-
}
|
|
907
|
-
__name(warnIfSdkCannotReadCompatSources, "warnIfSdkCannotReadCompatSources");
|
|
908
|
-
function assembleM8CreateOptions(compiled) {
|
|
909
|
-
const options = {};
|
|
910
|
-
const applied = [];
|
|
911
|
-
const base = compiled.systemPrompt;
|
|
912
|
-
if (compiled.skills) {
|
|
913
|
-
options.skills = compiled.skills;
|
|
914
|
-
applied.push("skills");
|
|
915
|
-
}
|
|
916
|
-
if (compiled.plugins) {
|
|
917
|
-
options.plugins = compiled.plugins;
|
|
918
|
-
applied.push("plugins");
|
|
919
|
-
}
|
|
920
|
-
if (compiled.settingSources !== void 0 && compiled.settingSources.length > 0) {
|
|
921
|
-
options.local = {
|
|
922
|
-
...options.local,
|
|
923
|
-
settingSources: [
|
|
924
|
-
...compiled.settingSources
|
|
925
|
-
]
|
|
926
|
-
};
|
|
927
|
-
applied.push("settingSources");
|
|
928
|
-
}
|
|
929
|
-
if (compiled.compatSources !== void 0 && compiled.compatSources.length > 0) {
|
|
930
|
-
options.local = {
|
|
931
|
-
...options.local,
|
|
932
|
-
compatSources: [
|
|
933
|
-
...compiled.compatSources
|
|
934
|
-
]
|
|
935
|
-
};
|
|
936
|
-
applied.push("compatSources");
|
|
937
|
-
warnIfSdkCannotReadCompatSources();
|
|
938
|
-
}
|
|
939
|
-
if (compiled.context) {
|
|
940
|
-
options.context = compiled.context;
|
|
941
|
-
applied.push("context");
|
|
942
|
-
}
|
|
943
|
-
if (compiled.projectContext) {
|
|
944
|
-
options.systemPrompt = compileProjectContext(compiled.projectContext, base);
|
|
945
|
-
applied.push("projectContext");
|
|
946
|
-
} else if (base !== void 0) {
|
|
947
|
-
options.systemPrompt = base;
|
|
948
|
-
}
|
|
949
|
-
if (compiled.mcpServers && Object.keys(compiled.mcpServers).length > 0) {
|
|
950
|
-
options.mcpServers = compiled.mcpServers;
|
|
951
|
-
applied.push("mcpServers");
|
|
952
|
-
}
|
|
953
|
-
if (compiled.memory !== void 0) {
|
|
954
|
-
if ("enabled" in compiled.memory) {
|
|
955
|
-
options.memory = compiled.memory;
|
|
956
|
-
} else {
|
|
957
|
-
const dropped = Object.keys(compiled.memory);
|
|
958
|
-
if (dropped.length > 0) {
|
|
959
|
-
process.stderr.write(`[theokit-agents] @Memory decorator options not yet mapped to the SDK (${dropped.join(", ")}) \u2014 memory enabled with defaults
|
|
960
|
-
`);
|
|
961
|
-
}
|
|
962
|
-
options.memory = {
|
|
963
|
-
enabled: true
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
applied.push("memory");
|
|
967
|
-
}
|
|
968
|
-
return {
|
|
969
|
-
options,
|
|
970
|
-
applied
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
__name(assembleM8CreateOptions, "assembleM8CreateOptions");
|
|
974
|
-
function stopReasonOf(result) {
|
|
975
|
-
if (result.stoppedByDoomLoop === true) return "no_progress";
|
|
976
|
-
if (result.stoppedAtIterationLimit === true) return "step_limit";
|
|
977
|
-
return void 0;
|
|
978
|
-
}
|
|
979
|
-
__name(stopReasonOf, "stopReasonOf");
|
|
980
|
-
function realUsageDone(result, t0, model) {
|
|
981
|
-
const u = result.usage;
|
|
982
|
-
const inputTokens = u?.inputTokens ?? 0;
|
|
983
|
-
const outputTokens = u?.outputTokens ?? 0;
|
|
984
|
-
const stopReason = stopReasonOf(result);
|
|
985
|
-
return {
|
|
986
|
-
type: "done",
|
|
987
|
-
result: result.result ?? "",
|
|
988
|
-
// V4-O: forward the SDK reasoning/cache buckets (0 when the provider omits them) so a
|
|
989
|
-
// consumer keeps full per-turn usage through the loop into DelegationResult (passthrough — ADR D1).
|
|
990
|
-
usage: {
|
|
991
|
-
inputTokens,
|
|
992
|
-
outputTokens,
|
|
993
|
-
totalTokens: inputTokens + outputTokens,
|
|
994
|
-
reasoningTokens: u?.reasoningTokens ?? 0,
|
|
995
|
-
cacheReadTokens: u?.cacheReadTokens ?? 0,
|
|
996
|
-
cacheWriteTokens: u?.cacheWriteTokens ?? 0
|
|
997
|
-
},
|
|
998
|
-
durationMs: Date.now() - t0,
|
|
999
|
-
cost: result.cost?.amount ?? 0,
|
|
1000
|
-
...terminalExtras(stopReason, model)
|
|
1001
|
-
};
|
|
1002
|
-
}
|
|
1003
|
-
__name(realUsageDone, "realUsageDone");
|
|
1004
|
-
function terminalExtras(stopReason, model) {
|
|
1005
|
-
const extras = {};
|
|
1006
|
-
if (stopReason !== void 0) extras.stopReason = stopReason;
|
|
1007
|
-
if (model !== void 0) extras.model = model;
|
|
1008
|
-
return extras;
|
|
1009
|
-
}
|
|
1010
|
-
__name(terminalExtras, "terminalExtras");
|
|
1011
|
-
|
|
1012
1059
|
// src/bridge/sdk-error.ts
|
|
1013
1060
|
function sdkErrorEvent(err) {
|
|
1014
1061
|
const sdkErr = err;
|
|
@@ -1235,14 +1282,14 @@ async function* stripToolDialectStream(source) {
|
|
|
1235
1282
|
__name(stripToolDialectStream, "stripToolDialectStream");
|
|
1236
1283
|
|
|
1237
1284
|
// src/bridge/turn-retry.ts
|
|
1238
|
-
import { TheokitAgentError as
|
|
1285
|
+
import { TheokitAgentError as TheokitAgentError3 } from "@theokit/sdk/errors";
|
|
1239
1286
|
function asText(value) {
|
|
1240
1287
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
1241
1288
|
}
|
|
1242
1289
|
__name(asText, "asText");
|
|
1243
1290
|
function startFailure(event, outcome) {
|
|
1244
1291
|
if (outcome.failure !== void 0) return outcome.failure;
|
|
1245
|
-
return new
|
|
1292
|
+
return new TheokitAgentError3(asText(event.message) ?? "The turn failed before producing any output.", {
|
|
1246
1293
|
code: asText(event.code) ?? "TURN_START_FAILED",
|
|
1247
1294
|
isRetryable: event.retryable === true
|
|
1248
1295
|
});
|
|
@@ -1733,8 +1780,8 @@ var noopReflectionStrategy = {
|
|
|
1733
1780
|
};
|
|
1734
1781
|
|
|
1735
1782
|
// src/bridge/delegation-types.ts
|
|
1736
|
-
import { TheokitAgentError as
|
|
1737
|
-
var DelegationBudgetExceededError = class extends
|
|
1783
|
+
import { TheokitAgentError as TheokitAgentError4 } from "@theokit/sdk/errors";
|
|
1784
|
+
var DelegationBudgetExceededError = class extends TheokitAgentError4 {
|
|
1738
1785
|
static {
|
|
1739
1786
|
__name(this, "DelegationBudgetExceededError");
|
|
1740
1787
|
}
|
|
@@ -1751,7 +1798,7 @@ var DelegationBudgetExceededError = class extends TheokitAgentError3 {
|
|
|
1751
1798
|
}
|
|
1752
1799
|
};
|
|
1753
1800
|
var BudgetExceededError = DelegationBudgetExceededError;
|
|
1754
|
-
var DelegationError = class extends
|
|
1801
|
+
var DelegationError = class extends TheokitAgentError4 {
|
|
1755
1802
|
static {
|
|
1756
1803
|
__name(this, "DelegationError");
|
|
1757
1804
|
}
|
|
@@ -2341,8 +2388,8 @@ async function delegate(spec, message, opts = {}) {
|
|
|
2341
2388
|
__name(delegate, "delegate");
|
|
2342
2389
|
|
|
2343
2390
|
// src/bridge/delegation-lifecycle.ts
|
|
2344
|
-
import { TheokitAgentError as
|
|
2345
|
-
var DelegationTimeoutError = class extends
|
|
2391
|
+
import { TheokitAgentError as TheokitAgentError5 } from "@theokit/sdk/errors";
|
|
2392
|
+
var DelegationTimeoutError = class extends TheokitAgentError5 {
|
|
2346
2393
|
static {
|
|
2347
2394
|
__name(this, "DelegationTimeoutError");
|
|
2348
2395
|
}
|
|
@@ -2474,6 +2521,7 @@ export {
|
|
|
2474
2521
|
applyPosture,
|
|
2475
2522
|
buildModelSelection,
|
|
2476
2523
|
reasoningEffortOf,
|
|
2524
|
+
HookGateUnsupportedError,
|
|
2477
2525
|
translateSdkEvent,
|
|
2478
2526
|
createThinkTagExtractor,
|
|
2479
2527
|
extractThinkTagStream,
|
|
@@ -2505,4 +2553,4 @@ export {
|
|
|
2505
2553
|
delegateBackground,
|
|
2506
2554
|
delegateWithScoring
|
|
2507
2555
|
};
|
|
2508
|
-
//# sourceMappingURL=chunk-
|
|
2556
|
+
//# sourceMappingURL=chunk-NZTLBLHB.js.map
|