@theokit/agents 13.0.0 → 13.2.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 +213 -0
- package/dist/{agent-compiler-B0hb6HCo.d.ts → agent-compiler-BaOZzU7Q.d.ts} +26 -3
- package/dist/auth.d.ts +28 -1
- package/dist/auth.js +58 -0
- package/dist/auth.js.map +1 -1
- package/dist/{bridge-entry-DBkqwe6b.d.ts → bridge-entry-BgWauyLQ.d.ts} +4 -4
- package/dist/bridge.d.ts +5 -5
- package/dist/bridge.js +4 -4
- package/dist/{chunk-HGVT4VCE.js → chunk-2SP5BB6U.js} +39 -6
- package/dist/chunk-2SP5BB6U.js.map +1 -0
- package/dist/{chunk-KTQID5V3.js → chunk-CBP72LFM.js} +9 -3
- package/dist/chunk-CBP72LFM.js.map +1 -0
- package/dist/{chunk-PMMOOXR6.js → chunk-PYVLRSXZ.js} +22 -2
- package/dist/chunk-PYVLRSXZ.js.map +1 -0
- package/dist/{chunk-G7QBDGZ4.js → chunk-SL3QW5WZ.js} +32 -7
- package/dist/{chunk-G7QBDGZ4.js.map → chunk-SL3QW5WZ.js.map} +1 -1
- package/dist/config.d.ts +154 -4
- package/dist/config.js +312 -14
- package/dist/config.js.map +1 -1
- package/dist/{define-agent-DhwNmdej.d.ts → define-agent-DOZL_0uP.d.ts} +2 -2
- package/dist/{delegation-scoring-BzJEheml.d.ts → delegation-scoring-DLsMQ4BJ.d.ts} +14 -2
- package/dist/index.d.ts +9 -9
- package/dist/index.js +4 -4
- package/dist/{setting-sources-gate-DFu51i50.d.ts → setting-sources-gate-BXdZmY78.d.ts} +7 -1
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +3 -2
- package/dist/tools.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-HGVT4VCE.js.map +0 -1
- package/dist/chunk-KTQID5V3.js.map +0 -1
- package/dist/chunk-PMMOOXR6.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,218 @@
|
|
|
1
1
|
# @theokit/agents
|
|
2
2
|
|
|
3
|
+
## 13.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- af53600: Read the settings files the declared layers correspond to
|
|
8
|
+
|
|
9
|
+
`SETTINGS_LAYERS` published a precedence stack — `user` 10, `project-shared` 20, `project-local` 30 —
|
|
10
|
+
and opened no file. Measured with controls (`loadMcpJson` 5 files, an invented term 0):
|
|
11
|
+
`settings.local.json` appeared once in this package, as a comment; `outputStyle` appeared zero times
|
|
12
|
+
here and zero times in the SDK's built output.
|
|
13
|
+
|
|
14
|
+
Three documented features were unreachable for that one reason. `settings.local.json` had a
|
|
15
|
+
precedence and no reader. `outputStyle` had a loader — shipped in this same line of work — with no
|
|
16
|
+
caller and no source for the name it takes. The session `env` had neither.
|
|
17
|
+
|
|
18
|
+
`loadSettings` opens the three files, folds them through the existing `LayeredConfig` (rather than
|
|
19
|
+
deriving a second answer to "which layer wins"), and reports which declared layers contributed
|
|
20
|
+
nothing. `resolveOutputStyle` joins the two halves so the documented path works end to end: name a
|
|
21
|
+
style in settings, get the style — and a named style with no file behind it still refuses, because
|
|
22
|
+
returning nothing there would restore the silence this work removed.
|
|
23
|
+
|
|
24
|
+
Unknown keys pass through untouched. The brief is the same mechanisms, not every configuration, and
|
|
25
|
+
a reader that dropped what it did not recognise would silently discard an operator's settings.
|
|
26
|
+
|
|
27
|
+
- 88dd1ca: Translate a settings `permissions` block into rules the engine evaluates
|
|
28
|
+
|
|
29
|
+
The SDK ships a real permission engine — `PermissionEngine(rules, { defaultAction })`,
|
|
30
|
+
`PermissionRule`, `PermissionAction` — and it is a code surface: you construct it with rules. What
|
|
31
|
+
was missing was the path from the FILE to those rules. Measured: `permissions` appears in 13 SDK
|
|
32
|
+
files, and the SDK reads `settings.json` in three, of which two are sourcemaps and the third
|
|
33
|
+
describes the hooks shape. An operator writing `{ "permissions": { "deny": ["Bash(curl:*)"] } }` got
|
|
34
|
+
a file nothing translated.
|
|
35
|
+
|
|
36
|
+
`permissionRulesFromSettings` renders `Tool` and `Tool(prefix:*)` / `Tool(exact)` into anchored
|
|
37
|
+
rules, emitted deny-before-ask-before-allow because the engine is first-match-wins and an operator
|
|
38
|
+
reading their own file top to bottom has no reason to expect an `allow` above a `deny` to win.
|
|
39
|
+
|
|
40
|
+
Anything it cannot render faithfully — path globs, `~` expansion, per-tool argument names — is
|
|
41
|
+
RETURNED as unsupported with a reason, never quietly turned into a matcher that almost fires. A
|
|
42
|
+
`deny` an operator believes is in force and is not is strictly more dangerous than no rule, because
|
|
43
|
+
without one they would have written the guard themselves.
|
|
44
|
+
|
|
45
|
+
- 6022a2a: An operator can refuse every hook a foreign configuration root declares
|
|
46
|
+
|
|
47
|
+
`.claude/hooks.json` runs shell commands out of a working directory that usually arrived with the
|
|
48
|
+
clone, and the operator tier had no switch for it: an operator who inherited an untrusted checkout
|
|
49
|
+
could not decline hook execution without editing files inside it. `disableAllHooks` in the managed
|
|
50
|
+
policy now drops the `hooks` surface where `resolveCompatSources` grants the root — one place, and
|
|
51
|
+
the place whose own refusal message already says that root "includes hooks.json, which executes
|
|
52
|
+
shell". It applies whether the consumer took the whole root or narrowed it, and when hooks were the
|
|
53
|
+
only surface asked for, nothing is granted at all.
|
|
54
|
+
|
|
55
|
+
Unlike every other key in this policy, a malformed value fails CLOSED: `"disableAllHooks": "true"`
|
|
56
|
+
as a string is read as `true`, with a warning naming what happened. The asymmetry is the reason —
|
|
57
|
+
fail-open is silent and unsafe, fail-closed is loud and recoverable. An absent key still means hooks
|
|
58
|
+
run, so no existing consumer changes behaviour.
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- c692b54: Report a malformed operator policy to every reader, not just whichever ran first
|
|
63
|
+
|
|
64
|
+
`currentOperatorPolicy` memoises, and the memo took the warn channel with it: the first caller in the
|
|
65
|
+
process received the warnings and every caller after passed a channel that was never invoked.
|
|
66
|
+
Measured with a policy declaring `disableSkillShellExecution: "true"` — a string where a boolean is
|
|
67
|
+
required — the first reader heard one warning and the second heard none.
|
|
68
|
+
|
|
69
|
+
Three modules read this policy and nothing orders them, so whether an operator learned their policy
|
|
70
|
+
was malformed depended on which code path a given application happened to run first. The whole
|
|
71
|
+
operator tier is a set of refusals; one that silently fails to apply, in a process where nobody is
|
|
72
|
+
told, is the failure the tier exists to remove.
|
|
73
|
+
|
|
74
|
+
The warnings are now kept beside the policy and replayed to each reader. A well-formed policy
|
|
75
|
+
collects nothing, so nothing is replayed and no new noise appears.
|
|
76
|
+
|
|
77
|
+
## 13.1.0
|
|
78
|
+
|
|
79
|
+
### Minor Changes
|
|
80
|
+
|
|
81
|
+
- 62f64de: `loadOutputStyle` reads `.claude/output-styles/*.md`, so a configured output style is no longer
|
|
82
|
+
ignored.
|
|
83
|
+
|
|
84
|
+
Measured for B-022 against the parity reference, which loads the project and home directories with
|
|
85
|
+
the project winning and honours the `outputStyle` key of a `settings.json`. This layer read none of
|
|
86
|
+
it: a grep for `output-style`, `outputStyle` and `output_style` over every package source tree
|
|
87
|
+
returned **0 files** against a control of **26** for `skills`, and the same query over the SDK's
|
|
88
|
+
built output returned **0** against a control of **22** for `SKILL.md`.
|
|
89
|
+
|
|
90
|
+
The failure was the silent kind. An author writes a style, selects it, gets ordinary responses back,
|
|
91
|
+
and cannot tell "my style is wrong" from "nothing reads styles".
|
|
92
|
+
|
|
93
|
+
- The **project wins** over the home directory, as the reference resolves them. Searched rather than
|
|
94
|
+
merged: a style is one document, and two files with one name are a choice, not a composition.
|
|
95
|
+
- **A named style with no file THROWS** a typed `OutputStyleError` listing the directories searched.
|
|
96
|
+
Returning `undefined` there would reproduce the exact state this fixes. A style that was never
|
|
97
|
+
requested still returns `undefined` — not configuring one is the ordinary case, not an error.
|
|
98
|
+
- **`keep-coding-instructions` is carried**, because a style REPLACES the built-in
|
|
99
|
+
software-engineering instructions by default. A consumer who does not know that loses them
|
|
100
|
+
silently, so the flag travels and the decision stays with the caller.
|
|
101
|
+
- **A style with no frontmatter is still a style** — the whole file is the body and every key takes
|
|
102
|
+
its default. `tsc` found that case, not a test: `splitFrontmatter` returns `undefined` for a file
|
|
103
|
+
with no fence, and esbuild strips types so vitest never saw it.
|
|
104
|
+
|
|
105
|
+
Composing the text into the prompt stays with `composeInstructions`, which already owns the
|
|
106
|
+
character budget and the drop report. A style pushed past the ceiling is reported through the same
|
|
107
|
+
path as every other source rather than through a second one invented here.
|
|
108
|
+
|
|
109
|
+
- b3a61c3: An operator can declare `apiKeyHelper` — a command that prints a credential — in the operator policy,
|
|
110
|
+
and `resolveOperatorApiKey` from `@theokit/agents/auth` runs it.
|
|
111
|
+
|
|
112
|
+
Measured before (B-069): `apiKeyHelper`, `awsAuthRefresh`, `gcpAuthRefresh` and `otelHeadersHelper`
|
|
113
|
+
all returned zero occurrences against a control of 31 on the word `hooks`. An agent holding a token
|
|
114
|
+
that rotates failed mid-run, and the only answer was to restart the process with a fresh environment
|
|
115
|
+
variable.
|
|
116
|
+
|
|
117
|
+
It is an OPERATOR declaration, not a `defineAgent` argument, per the decision B-065 recorded: the
|
|
118
|
+
person answerable for what runs on a machine is frequently not the person who wrote the code, and a
|
|
119
|
+
command that mints a secret is the most operator-shaped thing in the system.
|
|
120
|
+
|
|
121
|
+
Three refusals are part of the contract, each pinned by a test:
|
|
122
|
+
|
|
123
|
+
- **A helper that hangs** is killed at 10 s (configurable) and fails with a typed error naming the
|
|
124
|
+
command. A credential helper runs before every request that needs the key; "the agent is slow" is
|
|
125
|
+
the hardest symptom to trace back to a line in a policy file.
|
|
126
|
+
- **A helper that prints nothing** fails rather than returning `''`, which would surface later as a
|
|
127
|
+
401 whose message says nothing about the helper.
|
|
128
|
+
- **The output never reaches the error text.** A failure is read from logs, issue trackers and
|
|
129
|
+
screenshots. `stderr` is not even named as a callback parameter.
|
|
130
|
+
|
|
131
|
+
`runCredentialHelper` — which takes an arbitrary command string — is deliberately NOT exported.
|
|
132
|
+
Offering it publicly would hand a caller the choice of what to execute, the exact decision the
|
|
133
|
+
operator tier exists to take away from them.
|
|
134
|
+
|
|
135
|
+
`awsAuthRefresh`, `gcpAuthRefresh` and `otelHeadersHelper` are still absent, and the module says so
|
|
136
|
+
rather than leaving silence: the first two refresh an ambient cloud session instead of returning a
|
|
137
|
+
value, and the third supplies headers for a telemetry exporter this layer does not own.
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- 996538d: An `.mcp.json` field this runtime does not carry is now REPORTED instead of silently dropped.
|
|
142
|
+
|
|
143
|
+
`buildEntry` assembled each server from a fixed set of keys and let everything else fall off the end
|
|
144
|
+
in silence. Measured (B-071): `alwaysLoad` is declared by the reference format, allowlisted away
|
|
145
|
+
here, and nothing said so. That is the shape B-032 closed for hooks — an author who writes a field
|
|
146
|
+
and sees the server start has been told, by the absence of any complaint, that the setting took
|
|
147
|
+
effect.
|
|
148
|
+
|
|
149
|
+
The report is general rather than a special case for the one field somebody measured: naming only
|
|
150
|
+
`alwaysLoad` would fix the instance and leave the class, and the format gains keys faster than this
|
|
151
|
+
layer does. The server still starts — refusing an entry over an unknown key would turn a cosmetic
|
|
152
|
+
mistake into an outage.
|
|
153
|
+
|
|
154
|
+
`alwaysLoad` gets its reason named in the message: it marks a server whose tools load eagerly rather
|
|
155
|
+
than through TOOL SEARCH, and tool search does not exist here, so there is nothing for "always" to be
|
|
156
|
+
relative to. Honouring it would mean inventing a behaviour and shipping it under the format's name.
|
|
157
|
+
|
|
158
|
+
Two absences are now stated in the module rather than left implicit:
|
|
159
|
+
|
|
160
|
+
- **Tool search.** This runtime always sends every server's full tool list. The cost is context, not
|
|
161
|
+
correctness — and it is why `alwaysLoad` is refused rather than accepted.
|
|
162
|
+
- **The user-level `.mcp.json`.** Only the project file is read. A second location is a precedence
|
|
163
|
+
decision, not a second `readFileSync` — which file wins per key, whether a user may add a server
|
|
164
|
+
the project did not declare, how that composes with the operator gates that already decide which
|
|
165
|
+
servers may start. It belongs in the named settings stack, not in a merge rule invented inside a
|
|
166
|
+
loader.
|
|
167
|
+
|
|
168
|
+
- bdd160d: Report a `.claude/workflows/` directory instead of passing over it in silence
|
|
169
|
+
|
|
170
|
+
A project that declares the `claude-code` dialect and ships workflow scripts now learns, on load,
|
|
171
|
+
that they were found and not executed — with the reason and with the supported alternative. It was
|
|
172
|
+
previously the one surface of the dialect that produced no message at all, so an author who watched
|
|
173
|
+
rules, skills, subagents and commands load out of the same folder had no way to tell a broken
|
|
174
|
+
workflow from a workflow nothing reads.
|
|
175
|
+
|
|
176
|
+
The scripts are still not executed, deliberately. Every configuration surface this package loads is
|
|
177
|
+
data; a workflow file is code, and executing JavaScript found under a caller-supplied directory is a
|
|
178
|
+
trust decision that belongs to the consumer rather than to a library. The orchestration itself is
|
|
179
|
+
unaffected — `Workflow`, `agentStep` and `createSquad` from `@theokit/sdk` build the same pipeline
|
|
180
|
+
from an import the consumer writes.
|
|
181
|
+
|
|
182
|
+
- a50c6af: `AgentBuilder.plugins()` and `defineAgent({ plugins })` accept all three plugin kinds the SDK
|
|
183
|
+
defines, not just one.
|
|
184
|
+
|
|
185
|
+
`CodePlugin` required `register`, so it admitted `kind: "general"` and refused `kind:
|
|
186
|
+
"model-provider"` (which carries `profile`) and `kind: "memory"` (which carries `createProvider`).
|
|
187
|
+
The docblock on `AgentBuilder.plugins`, written in the same change, already described the parameter
|
|
188
|
+
as taking "a model provider / memory adapter (`kind: 'general' | 'model-provider' | 'memory'`)" — so
|
|
189
|
+
the prose promised three kinds while the type admitted one.
|
|
190
|
+
|
|
191
|
+
Found by a real consumer rather than by a gate. On `@theokit/agents@13.0.0`, TheoCode's build stopped
|
|
192
|
+
with `Property 'register' is missing in type 'BasePlugin & { kind: "model-provider"; profile:
|
|
193
|
+
ProviderProfile }'`. Nothing in this package caught it: 1 799 tests, `tsc`, eslint, knip and CodeQL
|
|
194
|
+
were all green over a type that refused two thirds of its own contract.
|
|
195
|
+
|
|
196
|
+
What the guard is FOR is unchanged: the Claude Code filesystem-bundle form (`{ type, path, source,
|
|
197
|
+
marketplace }`) is still refused with a message naming where a bundle belongs. An object carrying a
|
|
198
|
+
`name` and none of the three capability keys is still refused too — widening to three kinds must not
|
|
199
|
+
widen to "anything with a name", which would let the bundle form back in through the front door.
|
|
200
|
+
|
|
201
|
+
- e0813b5: Say at `DelegateOptions.cwd` that a worktree gets no gitignored files
|
|
202
|
+
|
|
203
|
+
Pointing a sub-agent at a git worktree you created gives it a checkout without `.env`, without local
|
|
204
|
+
config, without credentials — and the resulting failure reads as a broken agent rather than as a
|
|
205
|
+
missing file. The option now says so.
|
|
206
|
+
|
|
207
|
+
No copier was built, and the reason is that there is nothing to copy into: this layer creates no
|
|
208
|
+
worktree. Measured with controls — zero `git worktree` invocations, zero `isolation` options, the
|
|
209
|
+
four files mentioning the word being a trust comment, a memory-scope comment, a detector for running
|
|
210
|
+
inside one, and a sentence in a prompt. A `.worktreeinclude` implementation would be a mechanism for
|
|
211
|
+
an event that never happens here.
|
|
212
|
+
|
|
213
|
+
The absence is held falsifiable rather than merely asserted: a test fails the day something does
|
|
214
|
+
create a worktree, and names the obligation that arrives with it.
|
|
215
|
+
|
|
3
216
|
## 13.0.0
|
|
4
217
|
|
|
5
218
|
### 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-
|
|
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.
|
|
@@ -170,10 +170,33 @@ declare function resolveEnabledSkills(selection: SkillsSelection | undefined, ct
|
|
|
170
170
|
* here would be a second declaration to drift from. What this needs to know is the one thing that
|
|
171
171
|
* tells a code plugin from a bundle reference.
|
|
172
172
|
*/
|
|
173
|
-
|
|
173
|
+
/**
|
|
174
|
+
* A code plugin, in any of the three kinds `@theokit/sdk`'s `Plugin` union defines.
|
|
175
|
+
*
|
|
176
|
+
* `general` `register(ctx)` registers tools, commands, hooks
|
|
177
|
+
* `model-provider` `profile` supplies a model provider
|
|
178
|
+
* `memory` `createProvider` supplies a memory adapter
|
|
179
|
+
*
|
|
180
|
+
* The first version of this type required `register`, which accepted the first kind and refused the
|
|
181
|
+
* other two — while the docblock on `AgentBuilder.plugins`, written in the same commit, already
|
|
182
|
+
* described all three. A real consumer found it: on `@theokit/agents@13.0.0` a `model-provider`
|
|
183
|
+
* plugin failed to compile with "Property 'register' is missing". A guard written to refuse the
|
|
184
|
+
* FILESYSTEM-bundle form was refusing two thirds of the CODE form instead.
|
|
185
|
+
*
|
|
186
|
+
* Modelled here as name-plus-one-capability rather than by importing the SDK union, for the reason
|
|
187
|
+
* the module header gives: this layer must not depend on the SDK's value side, and the published
|
|
188
|
+
* floor is `^4.52.1` where the union's shape is not guaranteed identical. The capability keys ARE
|
|
189
|
+
* the discriminator, so the refusal below stays exact.
|
|
190
|
+
*/
|
|
191
|
+
type CodePlugin = {
|
|
174
192
|
readonly name: string;
|
|
193
|
+
} & ({
|
|
175
194
|
readonly register: (...args: never[]) => unknown;
|
|
176
|
-
}
|
|
195
|
+
} | {
|
|
196
|
+
readonly profile: unknown;
|
|
197
|
+
} | {
|
|
198
|
+
readonly createProvider: (...args: never[]) => unknown;
|
|
199
|
+
});
|
|
177
200
|
|
|
178
201
|
/**
|
|
179
202
|
* Project the M8 fields from `CompiledAgentOptions` into `Agent.create()` arguments. Only the async
|
package/dist/auth.d.ts
CHANGED
|
@@ -398,6 +398,33 @@ interface AgentCredentialInput {
|
|
|
398
398
|
*/
|
|
399
399
|
declare function resolveAgentCredential(input: AgentCredentialInput): CredentialResolution;
|
|
400
400
|
|
|
401
|
+
interface RunCredentialHelperOptions {
|
|
402
|
+
/**
|
|
403
|
+
* Milliseconds before the helper is killed and the call fails.
|
|
404
|
+
*
|
|
405
|
+
* A helper that hangs stalls every request that needs the credential, and "the agent is slow" is
|
|
406
|
+
* the hardest symptom to trace back to a command in a policy file. Defaults to 10 s, which is
|
|
407
|
+
* generous for minting a token and short enough to name the cause.
|
|
408
|
+
*/
|
|
409
|
+
readonly timeoutMs?: number;
|
|
410
|
+
/** Working directory for the helper. Defaults to the process's own. */
|
|
411
|
+
readonly cwd?: string;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* The credential an operator's `apiKeyHelper` produces, or `undefined` when none is declared.
|
|
415
|
+
*
|
|
416
|
+
* This — not {@link runCredentialHelper} — is what a consumer calls, and the narrowing is the point.
|
|
417
|
+
* A function taking an arbitrary command string puts the choice of WHAT to execute in the caller's
|
|
418
|
+
* hands, which is exactly the decision the operator tier exists to take away from them. Here the
|
|
419
|
+
* command can only come from the policy file, so "this runs an operator-declared command" is a
|
|
420
|
+
* property of the code rather than a promise in a docblock.
|
|
421
|
+
*
|
|
422
|
+
* `runCredentialHelper` stays exported for the tests that exercise its failure modes directly; a
|
|
423
|
+
* runner whose timeout and redaction could not be tested in isolation would be a guard nobody can
|
|
424
|
+
* check.
|
|
425
|
+
*/
|
|
426
|
+
declare function resolveOperatorApiKey(warn: (message: string) => void, options?: RunCredentialHelperOptions): Promise<string | undefined>;
|
|
427
|
+
|
|
401
428
|
/** What a caller asks about: may THIS tool run THIS command in THIS place? */
|
|
402
429
|
interface PermissionQuery {
|
|
403
430
|
readonly tool: string;
|
|
@@ -590,4 +617,4 @@ interface Veto {
|
|
|
590
617
|
*/
|
|
591
618
|
declare function grantGate(store: PermissionStore, classify: (ctx: GrantGateContext) => Classification): (ctx: GrantGateContext) => Promise<Veto | undefined>;
|
|
592
619
|
|
|
593
|
-
export { type AgentCredentialInput, type AuthMethod, AuthProvider, CODEX_CLIENT_ID_ENV_VAR, CODEX_PROVIDER, type Classification, CredentialNotFoundError, type ProviderDescriptor as CredentialProviderDescriptor, type CredentialResolution, type CredentialSourcesInput, DEFAULT_PROVIDERS, DeclaredProviderError, type DeviceAuthProvider, type Governed, type Grant, type GrantGateContext, type GrantOptions, type NotGoverned, type PermissionQuery, PermissionStore, type PermissionStoreOptions, type PromptHooks, ProviderKeyMismatchError, ProviderPrefixMismatchError, type ResolveCredentialInput, type SourceOrigin, type Veto, credentialSources, grantGate, loginWithDevice, requireCredential, resolveAgentCredential, resolveCredential };
|
|
620
|
+
export { type AgentCredentialInput, type AuthMethod, AuthProvider, CODEX_CLIENT_ID_ENV_VAR, CODEX_PROVIDER, type Classification, CredentialNotFoundError, type ProviderDescriptor as CredentialProviderDescriptor, type CredentialResolution, type CredentialSourcesInput, DEFAULT_PROVIDERS, DeclaredProviderError, type DeviceAuthProvider, type Governed, type Grant, type GrantGateContext, type GrantOptions, type NotGoverned, type PermissionQuery, PermissionStore, type PermissionStoreOptions, type PromptHooks, ProviderKeyMismatchError, ProviderPrefixMismatchError, type ResolveCredentialInput, type RunCredentialHelperOptions, type SourceOrigin, type Veto, credentialSources, grantGate, loginWithDevice, requireCredential, resolveAgentCredential, resolveCredential, resolveOperatorApiKey };
|
package/dist/auth.js
CHANGED
|
@@ -5,6 +5,12 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
debugLog
|
|
7
7
|
} from "./chunk-M5J3Q6YC.js";
|
|
8
|
+
import {
|
|
9
|
+
ConfigurationError
|
|
10
|
+
} from "./chunk-U72XTMYB.js";
|
|
11
|
+
import {
|
|
12
|
+
currentOperatorPolicy
|
|
13
|
+
} from "./chunk-2SP5BB6U.js";
|
|
8
14
|
import {
|
|
9
15
|
__name
|
|
10
16
|
} from "./chunk-Z4QWC7IK.js";
|
|
@@ -478,6 +484,57 @@ function resolveAgentCredential(input) {
|
|
|
478
484
|
}
|
|
479
485
|
__name(resolveAgentCredential, "resolveAgentCredential");
|
|
480
486
|
|
|
487
|
+
// src/auth/credential-helper.ts
|
|
488
|
+
import { execFile } from "child_process";
|
|
489
|
+
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
490
|
+
async function runCredentialHelper(command, options = {}) {
|
|
491
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
492
|
+
const printed = await new Promise((resolve, reject) => {
|
|
493
|
+
execFile(
|
|
494
|
+
command,
|
|
495
|
+
[],
|
|
496
|
+
{
|
|
497
|
+
shell: true,
|
|
498
|
+
timeout: timeoutMs,
|
|
499
|
+
cwd: options.cwd,
|
|
500
|
+
encoding: "utf8"
|
|
501
|
+
},
|
|
502
|
+
// `stderr` is deliberately NOT a parameter. A helper commonly echoes context that includes the
|
|
503
|
+
// credential, and anything named here is one careless template literal away from a log.
|
|
504
|
+
(error, stdout) => {
|
|
505
|
+
if (error === null) {
|
|
506
|
+
resolve(stdout);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (error.killed === true) {
|
|
510
|
+
reject(new ConfigurationError(`the credential helper "${command}" timed out after ${timeoutMs}ms and was killed. It is declared in the operator policy; a helper that cannot finish in that budget blocks every request that needs the credential.`, {
|
|
511
|
+
code: "credential_helper_timeout"
|
|
512
|
+
}));
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const code = typeof error.code === "number" ? error.code : "a non-zero status";
|
|
516
|
+
reject(new ConfigurationError(`the credential helper "${command}" exited ${code}. It is declared in the operator policy. Its output is not reproduced here, because a helper's stdout is a secret.`, {
|
|
517
|
+
code: "credential_helper_failed"
|
|
518
|
+
}));
|
|
519
|
+
}
|
|
520
|
+
);
|
|
521
|
+
});
|
|
522
|
+
const credential = printed.trim();
|
|
523
|
+
if (credential.length === 0) {
|
|
524
|
+
throw new ConfigurationError(`the credential helper "${command}" printed nothing. A helper's stdout IS the credential, so an empty run produces no credential \u2014 returning the empty string would surface later as a 401 whose message says nothing about this command.`, {
|
|
525
|
+
code: "credential_helper_empty"
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
return credential;
|
|
529
|
+
}
|
|
530
|
+
__name(runCredentialHelper, "runCredentialHelper");
|
|
531
|
+
async function resolveOperatorApiKey(warn, options = {}) {
|
|
532
|
+
const { apiKeyHelper } = currentOperatorPolicy(warn);
|
|
533
|
+
if (apiKeyHelper === void 0) return void 0;
|
|
534
|
+
return runCredentialHelper(apiKeyHelper, options);
|
|
535
|
+
}
|
|
536
|
+
__name(resolveOperatorApiKey, "resolveOperatorApiKey");
|
|
537
|
+
|
|
481
538
|
// src/auth/permission-store.ts
|
|
482
539
|
import { realpathSync } from "fs";
|
|
483
540
|
import { join as join2 } from "path";
|
|
@@ -638,6 +695,7 @@ export {
|
|
|
638
695
|
requireCredential,
|
|
639
696
|
resolveAgentCredential,
|
|
640
697
|
resolveCredential,
|
|
698
|
+
resolveOperatorApiKey,
|
|
641
699
|
writeCredential
|
|
642
700
|
};
|
|
643
701
|
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth/auth-provider.ts","../src/auth-entry.ts","../src/auth/device-provider.ts","../src/auth/resolve-credential.ts","../src/auth/permission-store.ts","../src/auth/permission-gate.ts"],"mappings":";;;;;;;;;;;;AAAA,SACEA,cACAC,uBACAC,mBACAC,oBACAC,uBACK;AAQP,SAASC,oBAAoB;AAkCtB,IAAMC,iBAAN,cAA6BC,MAAAA;EAhDpC,OAgDoCA;;;;EAClC,YACEC,SAESC,WACT;AACA,UAAMD,OAAAA,GAAAA,KAFGC,YAAAA;AAGT,SAAKC,OAAO;EACd;AACF;AAMA,IAA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MAAMQ,UAAUL,eAAeM,KAAK,EAAG,QAAOJ,QAAQC,QAAQC,MAAAA;AAIlE,YAAMG,UACJV,MAAMW,kBAAkBJ,SACpB,8BACA;AAQNK,eAAS,oCAAoC;QAC3CC,MAAMX,IAAIY;QACVC,OAAOZ,eAAeM,MAAMM;QAC5BL;MACF,CAAA;AACA,aAAOL,QAAQC,QAAQ;QACrBU,OAAO;QACPC,SAAS,IAAIf,IAAIY,IAAI,yBAAyBX,eAAeM,MAAMM,KAAK,KAAKL,OAAAA;MAC/E,CAAA;IACF,SAASQ,OAAO;AAGd,YAAMC,MAAMD,iBAAiBE,QAAQF,MAAMD,UAAUI,OAAOH,KAAAA;AAI5DN,eAAS,gDAAgD;QAAEC,MAAMX,IAAIY;QAAMK;MAAI,CAAA;AAC/E,aAAOd,QAAQC,QAAQ;QACrBU,OAAO;QACPC,SAAS,uCAAuCf,IAAIY,IAAI,MAAMK,GAAAA;MAChE,CAAA;IACF;EACF;AACF;AA/DgBpB;","names":["authFilePath","ensureFreshCredential","openaiDeviceLogin","persistOAuthTokens","readStoredOAuth","withFileLock","RefreshFailure","Error","message","transient","name","TRANSIENT_REASONS","classifyRefreshFailure","err","text","String","test","some","m","includes","waitWithJitter","attempt","baseMs","random","Math","base","round","AuthProvider","config","store","ensureFresh","resolved","deps","env","kind","ensureFreshCredential","filePath","authFilePath","inFlight","refreshInFlight","get","undefined","promise","refreshUnderLock","set","delete","Map","withFileLock","doDisco","readStoredOAuth","current","apiKey","access","expiresAt","expires","MAX_ATTEMPTS","failure","Promise","resolve","setTimeout","deviceLogin","deviceConfig","hooks","openaiDeviceLogin","persist","provider","tokens","persistOAuthTokens","assertSecureModes","authFilePath","CredentialError","credentialHome","readAuthFile","readStoredOAuth","writeCredential","deviceLogin","openaiDeviceLogin","pollDeviceToken","requestDeviceCode","ensureFreshCredential","extractAccountId","persistOAuthTokens","refreshOAuthTokens","providerFromApiKeyPrefix","openaiDeviceLogin","CODEX_CLIENT_ID","CODEX_ISSUER","CODEX_CLIENT_ID_ENV_VAR","CODEX_OAUTH","provider","clientId","process","env","authorizeEndpoint","tokenEndpoint","scopes","redirectUri","CODEX_DEVICE","deviceUsercodeEndpoint","devicePollEndpoint","verificationUri","CODEX_PROVIDER","Object","freeze","name","oauth","methods","label","type","authorize","deps","hooks","openaiDeviceLogin","comDefaults","fetch","sleep","ms","Promise","resolve","setTimeout","now","Date","loginWithDevice","method","store","opts","length","TypeError","includes","tokens","path","AuthProvider","persist","accountId","undefined","readFileSync","join","providerFromApiKeyPrefix","readAuthFile","TheokitAgentError","ProviderPrefixMismatchError","TheokitAgentError","name","provider","envKey","model","ProviderKeyMismatchError","where","expectedPrefix","code","isRetryable","DeclaredProviderError","message","CredentialNotFoundError","attempts","map","a","i","String","join","declaredNames","path","raw","readFileSync","Set","names","line","split","trimmed","trim","startsWith","withoutExport","slice","length","eq","indexOf","add","credentialSources","input","sources","providers","sort","b","priority","descriptor","store","undefined","config","push","dirName","fileName","assertKeyMatchesProvider","apiKey","inferred","providerFromApiKeyPrefix","keyPrefix","pinnedProvider","byPriority","declaredProviderEnvVar","declared","env","find","d","resolveCredential","pinned","kind","source","originOf","home","available","flatMap","claimed","claimedProvider","found","candidate","storedOAuthResolution","diagnose","console","warn","filePathOf","stored","readAuthFile","cause","Error","p","type","api_key","access","modelPrefix","varName","dotenv","has","requireCredential","resolved","DEFAULT_PROVIDERS","resolveAgentCredential","realpathSync","join","signatureOf","command","trim","replace","PermissionStore","path","lastReadError","options","join","home","now","Date","scope","realpathSync","cause","Error","message","String","isGranted","query","grant","tool","undefined","expiresAt","grants","filter","g","push","grantedAt","toISOString","ttlMs","revoke","signature","kept","list","expired","find","value","error","readSecureJson","raw","parsed","JSON","parse","Array","isArray","writeSecureJson","stringify","grantGate","store","classify","ctx","classification","governed","Promise","resolve","undefined","isGranted","query","because","lastReadError","debugLog","tool","name","scope","block","message","cause","why","Error","String"]}
|
|
1
|
+
{"version":3,"sources":["../src/auth/auth-provider.ts","../src/auth-entry.ts","../src/auth/device-provider.ts","../src/auth/resolve-credential.ts","../src/auth/credential-helper.ts","../src/auth/permission-store.ts","../src/auth/permission-gate.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,SACEA,cACAC,uBACAC,mBACAC,oBACAC,uBACK;AAQP,SAASC,oBAAoB;AAkCtB,IAAMC,iBAAN,cAA6BC,MAAAA;EAhDpC,OAgDoCA;;;;EAClC,YACEC,SAESC,WACT;AACA,UAAMD,OAAAA,GAAAA,KAFGC,YAAAA;AAGT,SAAKC,OAAO;EACd;AACF;AAMA,IAAMC,oBAAoB;EACxB;EACA;EACA;EACA;EACA;EACA;;AAIK,SAASC,uBAAuBC,KAAY;AACjD,QAAMC,OAAOD,eAAeN,QAAQ,GAAGM,IAAIH,IAAI,KAAKG,IAAIL,OAAO,KAAKO,OAAOF,GAAAA;AAC3E,MAAI,qDAAqDG,KAAKF,IAAAA,GAAO;AACnE,WAAO,IAAIR,eACT,mGACA,KAAA;EAEJ;AACA,QAAMG,YACJE,kBAAkBM,KAAK,CAACC,MAAMJ,KAAKK,SAASD,CAAAA,CAAAA,KAAO,gCAAgCF,KAAKF,IAAAA;AAC1F,SAAO,IAAIR,eACTG,YAAY,gDAAgD,qCAC5DA,SAAAA;AAEJ;AAdgBG;AAiBT,SAASQ,eAAeC,SAAiBC,SAAS,KAAKC,SAASC,KAAKD,QAAM;AAChF,QAAME,OAAOH,SAAS,KAAKD;AAC3B,SAAOG,KAAKE,MAAMD,QAAQ,OAAOF,OAAAA,IAAW,IAAE;AAChD;AAHgBH;AAKT,IAAMO,eAAN,MAAMA,cAAAA;EA/Fb,OA+FaA;;;;;EACX,YACmBC,QACAC,OACjB;SAFiBD,SAAAA;SACAC,QAAAA;EAChB;;;;;;EAOH,MAAMC,YACJC,UACAC,MACAC,KAC6B;AAC7B,QAAIF,SAASG,SAAS,SAAS;AAI7B,aAAOC,sBAAsBJ,UAAU;QAAEH,QAAQ,KAAKA;QAAQC,OAAO,KAAKA;QAAO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AM,CAAA,CAAA;CAAM;EACzE;AACF;;;ACtFO,SAASwB,UACdC,OACAC,UAAmD;AAEnD,SAAO,CAACC,QAAAA;AACN,QAAI;AACF,YAAMC,iBAAiCF,SAASC,GAAAA;AAkBhD,UAAIC,eAAeC,aAAa,MAAO,QAAOC,QAAQC,QAAQC,MAAAA;AAC9D,UAAIP,MAAMQ,UAAUL,eAAeM,KAAK,EAAG,QAAOJ,QAAQC,QAAQC,MAAAA;AAIlE,YAAMG,UACJV,MAAMW,kBAAkBJ,SACpB,8BACA;AAQNK,eAAS,oCAAoC;QAC3CC,MAAMX,IAAIY;QACVC,OAAOZ,eAAeM,MAAMM;QAC5BL;MACF,CAAA;AACA,aAAOL,QAAQC,QAAQ;QACrBU,OAAO;QACPC,SAAS,IAAIf,IAAIY,IAAI,yBAAyBX,eAAeM,MAAMM,KAAK,KAAKL,OAAAA;MAC/E,CAAA;IACF,SAASQ,OAAO;AAGd,YAAMC,MAAMD,iBAAiBE,QAAQF,MAAMD,UAAUI,OAAOH,KAAAA;AAI5DN,eAAS,gDAAgD;QAAEC,MAAMX,IAAIY;QAAMK;MAAI,CAAA;AAC/E,aAAOd,QAAQC,QAAQ;QACrBU,OAAO;QACPC,SAAS,uCAAuCf,IAAIY,IAAI,MAAMK,GAAAA;MAChE,CAAA;IACF;EACF;AACF;AA/DgBpB;","names":["authFilePath","ensureFreshCredential","openaiDeviceLogin","persistOAuthTokens","readStoredOAuth","withFileLock","RefreshFailure","Error","message","transient","name","TRANSIENT_REASONS","classifyRefreshFailure","err","text","String","test","some","m","includes","waitWithJitter","attempt","baseMs","random","Math","base","round","AuthProvider","config","store","ensureFresh","resolved","deps","env","kind","ensureFreshCredential","filePath","authFilePath","inFlight","refreshInFlight","get","undefined","promise","refreshUnderLock","set","delete","Map","withFileLock","doDisco","readStoredOAuth","current","apiKey","access","expiresAt","expires","MAX_ATTEMPTS","failure","Promise","resolve","setTimeout","deviceLogin","deviceConfig","hooks","openaiDeviceLogin","persist","provider","tokens","persistOAuthTokens","assertSecureModes","authFilePath","CredentialError","credentialHome","readAuthFile","readStoredOAuth","writeCredential","deviceLogin","openaiDeviceLogin","pollDeviceToken","requestDeviceCode","ensureFreshCredential","extractAccountId","persistOAuthTokens","refreshOAuthTokens","providerFromApiKeyPrefix","openaiDeviceLogin","CODEX_CLIENT_ID","CODEX_ISSUER","CODEX_CLIENT_ID_ENV_VAR","CODEX_OAUTH","provider","clientId","process","env","authorizeEndpoint","tokenEndpoint","scopes","redirectUri","CODEX_DEVICE","deviceUsercodeEndpoint","devicePollEndpoint","verificationUri","CODEX_PROVIDER","Object","freeze","name","oauth","methods","label","type","authorize","deps","hooks","openaiDeviceLogin","comDefaults","fetch","sleep","ms","Promise","resolve","setTimeout","now","Date","loginWithDevice","method","store","opts","length","TypeError","includes","tokens","path","AuthProvider","persist","accountId","undefined","readFileSync","join","providerFromApiKeyPrefix","readAuthFile","TheokitAgentError","ProviderPrefixMismatchError","TheokitAgentError","name","provider","envKey","model","ProviderKeyMismatchError","where","expectedPrefix","code","isRetryable","DeclaredProviderError","message","CredentialNotFoundError","attempts","map","a","i","String","join","declaredNames","path","raw","readFileSync","Set","names","line","split","trimmed","trim","startsWith","withoutExport","slice","length","eq","indexOf","add","credentialSources","input","sources","providers","sort","b","priority","descriptor","store","undefined","config","push","dirName","fileName","assertKeyMatchesProvider","apiKey","inferred","providerFromApiKeyPrefix","keyPrefix","pinnedProvider","byPriority","declaredProviderEnvVar","declared","env","find","d","resolveCredential","pinned","kind","source","originOf","home","available","flatMap","claimed","claimedProvider","found","candidate","storedOAuthResolution","diagnose","console","warn","filePathOf","stored","readAuthFile","cause","Error","p","type","api_key","access","modelPrefix","varName","dotenv","has","requireCredential","resolved","DEFAULT_PROVIDERS","resolveAgentCredential","execFile","DEFAULT_TIMEOUT_MS","runCredentialHelper","command","options","timeoutMs","printed","Promise","resolve","reject","execFile","shell","timeout","cwd","encoding","error","stdout","killed","ConfigurationError","code","credential","trim","length","resolveOperatorApiKey","warn","apiKeyHelper","currentOperatorPolicy","undefined","realpathSync","join","signatureOf","command","trim","replace","PermissionStore","path","lastReadError","options","join","home","now","Date","scope","realpathSync","cause","Error","message","String","isGranted","query","grant","tool","undefined","expiresAt","grants","filter","g","push","grantedAt","toISOString","ttlMs","revoke","signature","kept","list","expired","find","value","error","readSecureJson","raw","parsed","JSON","parse","Array","isArray","writeSecureJson","stringify","grantGate","store","classify","ctx","classification","governed","Promise","resolve","undefined","isGranted","query","because","lastReadError","debugLog","tool","name","scope","block","message","cause","why","Error","String"]}
|
|
@@ -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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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, c as compileAgentDefinition, i as isAgentDefinition } from './define-agent-
|
|
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-
|
|
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-
|
|
33
|
-
import "./chunk-HGVT4VCE.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-
|
|
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-
|
|
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,8 +7,13 @@ 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
|
-
"allowedMcpServers"
|
|
12
|
+
"allowedMcpServers",
|
|
13
|
+
"apiKeyHelper"
|
|
14
|
+
]);
|
|
15
|
+
var STRING_KEYS = /* @__PURE__ */ new Set([
|
|
16
|
+
"apiKeyHelper"
|
|
12
17
|
]);
|
|
13
18
|
var LIST_KEYS = /* @__PURE__ */ new Set([
|
|
14
19
|
"deniedMcpServers",
|
|
@@ -61,13 +66,31 @@ function applyPolicyKey(out, key, value, path, warn) {
|
|
|
61
66
|
if (key === "allowedMcpServers") out.allowedMcpServers = list;
|
|
62
67
|
return;
|
|
63
68
|
}
|
|
64
|
-
if (
|
|
65
|
-
|
|
69
|
+
if (STRING_KEYS.has(key)) {
|
|
70
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
71
|
+
warn(`${path} declares "${key}" as ${typeof value === "string" ? "an empty string" : typeof value}, not a command line \u2014 it is NOT being applied.`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (key === "apiKeyHelper") out.apiKeyHelper = value.trim();
|
|
66
75
|
return;
|
|
67
76
|
}
|
|
68
|
-
|
|
77
|
+
applyBooleanKey(out, key, value, path, warn);
|
|
69
78
|
}
|
|
70
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.`);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
warn(`${path} declares "${key}" as ${typeof value}, not a boolean \u2014 it is NOT being applied.`);
|
|
92
|
+
}
|
|
93
|
+
__name(applyBooleanKey, "applyBooleanKey");
|
|
71
94
|
function readStringList(value, key, path, warn) {
|
|
72
95
|
if (Array.isArray(value) && value.every((v) => typeof v === "string")) {
|
|
73
96
|
return value;
|
|
@@ -78,8 +101,18 @@ function readStringList(value, key, path, warn) {
|
|
|
78
101
|
__name(readStringList, "readStringList");
|
|
79
102
|
var cached;
|
|
80
103
|
var rootOverride;
|
|
104
|
+
var cachedWarnings = [];
|
|
81
105
|
function currentOperatorPolicy(warn) {
|
|
82
|
-
cached
|
|
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);
|
|
83
116
|
return cached;
|
|
84
117
|
}
|
|
85
118
|
__name(currentOperatorPolicy, "currentOperatorPolicy");
|
|
@@ -94,4 +127,4 @@ export {
|
|
|
94
127
|
currentOperatorPolicy,
|
|
95
128
|
mcpServerAdmitted
|
|
96
129
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-2SP5BB6U.js.map
|