@theokit/agents 16.5.2 → 16.7.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 +28 -0
- package/README.md +88 -5
- package/dist/{agent-compiler-C-4X_vKz.d.ts → agent-compiler-aubY9WIa.d.ts} +13 -1
- package/dist/{agent-handle-rEWdERuv.d.ts → agent-handle-C343-xUh.d.ts} +16 -1
- package/dist/{agent-orchestrator-BHF1bS6k.d.ts → agent-orchestrator-DQtfrPaq.d.ts} +2 -2
- package/dist/{agent-runner-BoMoOnHV.d.ts → agent-runner-BuuqK_Dp.d.ts} +3 -3
- package/dist/{agent-sse-handler-BRp9vHrb.d.ts → agent-sse-handler-BtIpJZxO.d.ts} +3 -1
- package/dist/auth.d.ts +21 -1
- package/dist/auth.js +23 -13
- package/dist/auth.js.map +1 -1
- package/dist/{bridge-entry-DO1LjHkc.d.ts → bridge-entry-nkeH6pAk.d.ts} +50 -7
- package/dist/bridge.d.ts +6 -6
- package/dist/bridge.js +9 -5
- package/dist/{chunk-KXE52FP2.js → chunk-4DOKIDGC.js} +59 -1
- package/dist/chunk-4DOKIDGC.js.map +1 -0
- package/dist/{chunk-NIQJ4GZX.js → chunk-JJ6Y6EBP.js} +4 -1
- package/dist/chunk-JJ6Y6EBP.js.map +1 -0
- package/dist/{chunk-ZLKZOSWR.js → chunk-RXD6S6RV.js} +2 -2
- package/dist/{chunk-K4MY4CV7.js → chunk-UARNAQ6O.js} +3 -3
- package/dist/{chunk-AZ2FOUSN.js → chunk-W533YIGA.js} +32 -5
- package/dist/chunk-W533YIGA.js.map +1 -0
- package/dist/{chunk-RZWD73QG.js → chunk-XGW7IZP6.js} +70 -5
- package/dist/chunk-XGW7IZP6.js.map +1 -0
- package/dist/client-react.d.ts +1 -1
- package/dist/client-react.js +1 -1
- package/dist/client.d.ts +14 -4
- package/dist/client.js +49 -2
- package/dist/client.js.map +1 -1
- package/dist/commands.d.ts +64 -12
- package/dist/commands.js +104 -12
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +105 -1
- package/dist/config.js +460 -62
- package/dist/config.js.map +1 -1
- package/dist/{delegation-scoring-BBPJ9eug.d.ts → delegation-scoring-DPckVefy.d.ts} +1 -1
- package/dist/evals.d.ts +3 -3
- package/dist/evals.js +2 -2
- package/dist/handoff.d.ts +4 -4
- package/dist/handoff.js +3 -3
- package/dist/hooks.d.ts +24 -1
- package/dist/hooks.js +78 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +22 -12
- package/dist/index.js +17 -5
- package/dist/index.js.map +1 -1
- package/dist/{sdk-adapter-C57SpmLH.d.ts → sdk-adapter-B0i8J7N0.d.ts} +2 -2
- package/dist/session.d.ts +17 -1
- package/dist/session.js +15 -0
- package/dist/session.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools.d.ts +4 -4
- package/dist/tools.js +4 -4
- package/package.json +3 -3
- package/dist/chunk-AZ2FOUSN.js.map +0 -1
- package/dist/chunk-KXE52FP2.js.map +0 -1
- package/dist/chunk-NIQJ4GZX.js.map +0 -1
- package/dist/chunk-RZWD73QG.js.map +0 -1
- /package/dist/{chunk-ZLKZOSWR.js.map → chunk-RXD6S6RV.js.map} +0 -0
- /package/dist/{chunk-K4MY4CV7.js.map → chunk-UARNAQ6O.js.map} +0 -0
package/dist/commands.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
|
|
5
5
|
// src/commands/command-router.ts
|
|
6
6
|
function defineCommand(input) {
|
|
7
|
+
const { arg, ...rest } = input;
|
|
7
8
|
return {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
arg: input.arg ?? "optional"
|
|
9
|
+
...rest,
|
|
10
|
+
arg: arg ?? "optional"
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
__name(defineCommand, "defineCommand");
|
|
@@ -18,32 +18,40 @@ function routeCommand(input, commands) {
|
|
|
18
18
|
text: input
|
|
19
19
|
};
|
|
20
20
|
const body = input.slice(PREFIX.length);
|
|
21
|
+
const entries = commands.flatMap((command2) => [
|
|
22
|
+
command2.name,
|
|
23
|
+
...command2.aliases ?? []
|
|
24
|
+
].map((typed) => ({
|
|
25
|
+
typed,
|
|
26
|
+
command: command2
|
|
27
|
+
})));
|
|
21
28
|
const byLength = [
|
|
22
|
-
...
|
|
23
|
-
].sort((a, b) => b.
|
|
24
|
-
const matches = byLength.filter((
|
|
29
|
+
...entries
|
|
30
|
+
].sort((a, b) => b.typed.length - a.typed.length);
|
|
31
|
+
const matches = byLength.filter((entry) => matchesName(body, entry.typed));
|
|
25
32
|
if (matches.length === 0) return {
|
|
26
33
|
kind: "error",
|
|
27
34
|
reason: "unknown-command",
|
|
28
35
|
input
|
|
29
36
|
};
|
|
30
37
|
const best = matches[0];
|
|
31
|
-
if (matches.length > 1 && matches[1].
|
|
38
|
+
if (matches.length > 1 && matches[1].typed.length === best.typed.length) {
|
|
32
39
|
return {
|
|
33
40
|
kind: "error",
|
|
34
41
|
reason: "ambiguous-command",
|
|
35
42
|
input
|
|
36
43
|
};
|
|
37
44
|
}
|
|
38
|
-
const arg = body.slice(best.
|
|
39
|
-
|
|
45
|
+
const arg = body.slice(best.typed.length).trim();
|
|
46
|
+
const command = best.command;
|
|
47
|
+
if (arg !== "" && command.arg === "none") {
|
|
40
48
|
return {
|
|
41
49
|
kind: "error",
|
|
42
50
|
reason: "unexpected-argument",
|
|
43
51
|
input
|
|
44
52
|
};
|
|
45
53
|
}
|
|
46
|
-
if (arg === "" &&
|
|
54
|
+
if (arg === "" && command.arg === "required") {
|
|
47
55
|
return {
|
|
48
56
|
kind: "error",
|
|
49
57
|
reason: "missing-argument",
|
|
@@ -52,7 +60,7 @@ function routeCommand(input, commands) {
|
|
|
52
60
|
}
|
|
53
61
|
return {
|
|
54
62
|
kind: "command",
|
|
55
|
-
command
|
|
63
|
+
command,
|
|
56
64
|
arg
|
|
57
65
|
};
|
|
58
66
|
}
|
|
@@ -64,6 +72,61 @@ function matchesName(body, name) {
|
|
|
64
72
|
}
|
|
65
73
|
__name(matchesName, "matchesName");
|
|
66
74
|
|
|
75
|
+
// src/commands/command-registry.ts
|
|
76
|
+
import { TheokitAgentError } from "@theokit/sdk/errors";
|
|
77
|
+
var CommandRegistryError = class extends TheokitAgentError {
|
|
78
|
+
static {
|
|
79
|
+
__name(this, "CommandRegistryError");
|
|
80
|
+
}
|
|
81
|
+
name = "CommandRegistryError";
|
|
82
|
+
claimed;
|
|
83
|
+
owners;
|
|
84
|
+
constructor(claimed, first, second) {
|
|
85
|
+
super(`command name "${claimed}" is claimed by both "${first}" and "${second}"`, {
|
|
86
|
+
code: "COMMAND_NAME_COLLISION",
|
|
87
|
+
// the same definitions collide the same way on every attempt.
|
|
88
|
+
isRetryable: false
|
|
89
|
+
});
|
|
90
|
+
this.claimed = claimed;
|
|
91
|
+
this.owners = [
|
|
92
|
+
first,
|
|
93
|
+
second
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
function createCommandRegistry(definitions) {
|
|
98
|
+
const owners = /* @__PURE__ */ new Map();
|
|
99
|
+
for (const definition of definitions) {
|
|
100
|
+
for (const name of [
|
|
101
|
+
definition.name,
|
|
102
|
+
...definition.aliases ?? []
|
|
103
|
+
]) {
|
|
104
|
+
const owner = owners.get(name);
|
|
105
|
+
if (owner !== void 0) throw new CommandRegistryError(name, owner, definition.name);
|
|
106
|
+
owners.set(name, definition.name);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const list = [
|
|
110
|
+
...definitions
|
|
111
|
+
];
|
|
112
|
+
const route = /* @__PURE__ */ __name((input) => routeCommand(input, list), "route");
|
|
113
|
+
return {
|
|
114
|
+
palette: /* @__PURE__ */ __name(() => list.filter((definition) => definition.hidden !== true).map(({ name, description }) => ({
|
|
115
|
+
name,
|
|
116
|
+
description
|
|
117
|
+
})), "palette"),
|
|
118
|
+
route,
|
|
119
|
+
async dispatch(input, ctx) {
|
|
120
|
+
const routed = route(input);
|
|
121
|
+
if (routed.kind === "command" && routed.command.run !== void 0) {
|
|
122
|
+
await routed.command.run(routed.arg, ctx);
|
|
123
|
+
}
|
|
124
|
+
return routed;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
__name(createCommandRegistry, "createCommandRegistry");
|
|
129
|
+
|
|
67
130
|
// src/commands/shutdown.ts
|
|
68
131
|
var SHUTDOWN_EXIT_CODES = {
|
|
69
132
|
clean: 130,
|
|
@@ -71,11 +134,32 @@ var SHUTDOWN_EXIT_CODES = {
|
|
|
71
134
|
"watchdog-timeout": 2
|
|
72
135
|
};
|
|
73
136
|
var DEFAULT_WATCHDOG_MS = 3e3;
|
|
137
|
+
function exitAfterDrain(code, deps = {}) {
|
|
138
|
+
const setExitCode = deps.setExitCode ?? ((c) => {
|
|
139
|
+
process.exitCode = c;
|
|
140
|
+
});
|
|
141
|
+
const exit = deps.exit ?? ((c) => process.exit(c));
|
|
142
|
+
setExitCode(code);
|
|
143
|
+
const timer = setTimeout(() => {
|
|
144
|
+
exit(code);
|
|
145
|
+
}, deps.capMs ?? DEFAULT_WATCHDOG_MS);
|
|
146
|
+
timer.unref();
|
|
147
|
+
}
|
|
148
|
+
__name(exitAfterDrain, "exitAfterDrain");
|
|
74
149
|
var IGNORE = /* @__PURE__ */ __name(() => void 0, "IGNORE");
|
|
75
150
|
function createShutdown(deps = {}) {
|
|
76
151
|
const tasks = [];
|
|
77
152
|
const warn = deps.onWarn ?? IGNORE;
|
|
78
153
|
const exit = deps.exit ?? IGNORE;
|
|
154
|
+
const finish = /* @__PURE__ */ __name((code) => {
|
|
155
|
+
if (deps.drain !== true) {
|
|
156
|
+
exit(code);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
exitAfterDrain(code, deps.exit === void 0 ? {} : {
|
|
160
|
+
exit: deps.exit
|
|
161
|
+
});
|
|
162
|
+
}, "finish");
|
|
79
163
|
const watchdogMs = deps.watchdogMs ?? DEFAULT_WATCHDOG_MS;
|
|
80
164
|
let running;
|
|
81
165
|
const withWatchdog = /* @__PURE__ */ __name(async () => {
|
|
@@ -115,10 +199,15 @@ function createShutdown(deps = {}) {
|
|
|
115
199
|
const shutdown = {
|
|
116
200
|
register(task) {
|
|
117
201
|
tasks.push(task);
|
|
202
|
+
return () => {
|
|
203
|
+
if (running !== void 0) return;
|
|
204
|
+
const i = tasks.indexOf(task);
|
|
205
|
+
if (i !== -1) tasks.splice(i, 1);
|
|
206
|
+
};
|
|
118
207
|
},
|
|
119
208
|
run() {
|
|
120
209
|
running ??= withWatchdog().then((outcome) => {
|
|
121
|
-
|
|
210
|
+
finish(SHUTDOWN_EXIT_CODES[outcome]);
|
|
122
211
|
return outcome;
|
|
123
212
|
});
|
|
124
213
|
return running;
|
|
@@ -136,10 +225,13 @@ function createShutdown(deps = {}) {
|
|
|
136
225
|
}
|
|
137
226
|
__name(createShutdown, "createShutdown");
|
|
138
227
|
export {
|
|
228
|
+
CommandRegistryError,
|
|
139
229
|
DEFAULT_WATCHDOG_MS,
|
|
140
230
|
SHUTDOWN_EXIT_CODES,
|
|
231
|
+
createCommandRegistry,
|
|
141
232
|
createShutdown,
|
|
142
233
|
defineCommand,
|
|
234
|
+
exitAfterDrain,
|
|
143
235
|
routeCommand
|
|
144
236
|
};
|
|
145
237
|
//# sourceMappingURL=commands.js.map
|
package/dist/commands.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/command-router.ts","../src/commands/shutdown.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"sources":["../src/commands/command-router.ts","../src/commands/command-registry.ts","../src/commands/shutdown.ts"],"mappings":";;;;;AAwCO,SAASA,cAA0BC,OAOzC;AACC,QAAM,EAAEC,KAAK,GAAGC,KAAAA,IAASF;AACzB,SAAO;IAAE,GAAGE;IAAMD,KAAKA,OAAO;EAAW;AAC3C;AAVgBF;AAyBhB,IAAMI,SAAS;AAU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AAA;MACV,GAAGV,UAAAA;IACL,CAAA;AAEA,UAAMc,YAAY,YAAA;AAChB,UAAIC,UAA2B;AAC/B,iBAAWC,QAAQrB,OAAO;AACxB,YAAI;AACF,gBAAMqB,KAAKC,IAAG;QAChB,SAASC,OAAO;AACdH,oBAAU;AACVnB,eAAK,YAAYoB,KAAKT,IAAI,aAAcW,MAAgBC,OAAO,EAAE;QACnE;AACAhB,gBAAQiB,OAAOJ,KAAKT,IAAI;MAC1B;AACA,aAAOQ;IACT,GAAA;AAEA,QAAI;AACF,aAAO,MAAMN,QAAQY,KAAK;QAACP;QAAUN;OAAS;IAChD,UAAA;AAGE,UAAIpB,UAAUK,OAAW6B,cAAalC,KAAAA;IACxC;EACF,GApCqB;AAsCrB,QAAMmC,WAAqB;IACzBC,SAASR,MAAI;AACXrB,YAAM8B,KAAKT,IAAAA;AACX,aAAO,MAAA;AACL,YAAIf,YAAYR,OAAW;AAC3B,cAAMiC,IAAI/B,MAAMgC,QAAQX,IAAAA;AACxB,YAAIU,MAAM,GAAI/B,OAAMiC,OAAOF,GAAG,CAAA;MAChC;IACF;IACAT,MAAAA;AAGEhB,kBAAYC,aAAAA,EAAe2B,KAAK,CAACd,YAAAA;AAC/BjB,eAAOrB,oBAAoBsC,OAAAA,CAAQ;AACnC,eAAOA;MACT,CAAA;AACA,aAAOd;IACT;EACF;AAEA,MAAInB,KAAKgD,aAAarC,QAAW;AAC/B,eAAWsC,UAAU;MAAC;MAAU;OAAqB;AACnDjD,WAAKgD,SAASC,QAAQ,MAAM,KAAKR,SAASN,IAAG,CAAA;IAC/C;EACF;AACA,SAAOM;AACT;AA9EgB7B;","names":["defineCommand","input","arg","rest","PREFIX","routeCommand","commands","startsWith","kind","text","body","slice","length","entries","flatMap","command","name","aliases","map","typed","byLength","sort","a","b","matches","filter","entry","matchesName","reason","best","trim","next","charAt","TheokitAgentError","CommandRegistryError","TheokitAgentError","name","claimed","owners","first","second","code","isRetryable","createCommandRegistry","definitions","Map","definition","aliases","owner","get","undefined","set","list","route","input","routeCommand","palette","filter","hidden","map","description","dispatch","ctx","routed","kind","command","run","arg","SHUTDOWN_EXIT_CODES","clean","DEFAULT_WATCHDOG_MS","exitAfterDrain","code","deps","setExitCode","c","process","exitCode","exit","timer","setTimeout","capMs","unref","IGNORE","undefined","createShutdown","tasks","warn","onWarn","finish","drain","watchdogMs","running","withWatchdog","pending","Set","map","t","name","watchdog","Promise","resolve","outstanding","join","String","sequence","outcome","task","run","error","message","delete","race","clearTimeout","shutdown","register","push","i","indexOf","splice","then","onSignal","signal"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -128,6 +128,48 @@ declare const LayeredConfig: {
|
|
|
128
128
|
resolve<TSchema extends z.ZodType>(input: LayeredConfigInput<TSchema>): LayeredConfigResult<z.infer<TSchema>>;
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
+
/** What every step receives: the environment to mutate, the working directory and the app's home. */
|
|
132
|
+
interface BootstrapContext {
|
|
133
|
+
readonly env: NodeJS.ProcessEnv;
|
|
134
|
+
readonly cwd: string;
|
|
135
|
+
readonly home: string;
|
|
136
|
+
}
|
|
137
|
+
interface BootstrapStep {
|
|
138
|
+
readonly name: string;
|
|
139
|
+
readonly run: (ctx: BootstrapContext) => void | Promise<void>;
|
|
140
|
+
}
|
|
141
|
+
interface AppBootstrap {
|
|
142
|
+
/**
|
|
143
|
+
* Run every step once, in order. A second call returns the first call's promise, including when
|
|
144
|
+
* that promise rejected: a bootstrap that failed is not retried by asking again.
|
|
145
|
+
*/
|
|
146
|
+
run(ctx: BootstrapContext): Promise<{
|
|
147
|
+
ran: readonly string[];
|
|
148
|
+
}>;
|
|
149
|
+
readonly steps: readonly string[];
|
|
150
|
+
/** True after run() completed. Lets a module that resolves SDK paths assert it is not too early. */
|
|
151
|
+
readonly done: boolean;
|
|
152
|
+
}
|
|
153
|
+
/** A step threw. Names the step and keeps the original error as `cause`; later steps did not run. */
|
|
154
|
+
declare class BootstrapStepError extends TheokitAgentError {
|
|
155
|
+
readonly name = "BootstrapStepError";
|
|
156
|
+
readonly step: string;
|
|
157
|
+
constructor(step: string, cause: unknown);
|
|
158
|
+
}
|
|
159
|
+
/** Something that needs the bootstrap ran before it. Names the caller. */
|
|
160
|
+
declare class BootstrapNotRunError extends TheokitAgentError {
|
|
161
|
+
readonly name = "BootstrapNotRunError";
|
|
162
|
+
constructor(caller: string);
|
|
163
|
+
}
|
|
164
|
+
declare function defineAppBootstrap(steps: readonly BootstrapStep[]): AppBootstrap;
|
|
165
|
+
/** Throws {@link BootstrapNotRunError} naming `caller` unless `bootstrap.run()` has completed. */
|
|
166
|
+
declare function assertBootstrapped(bootstrap: AppBootstrap, caller: string): void;
|
|
167
|
+
/**
|
|
168
|
+
* Loads `<cwd>/.env` into `ctx.env` without overwriting set variables, then restores the SDK's
|
|
169
|
+
* sovereign keys (`SOVEREIGN_ENV_KEYS`) through `loadProjectEnv`. A missing file is not an error.
|
|
170
|
+
*/
|
|
171
|
+
declare const projectEnvStep: BootstrapStep;
|
|
172
|
+
|
|
131
173
|
/**
|
|
132
174
|
* M73 — the per-directory trust store: a trust decision that survives the process.
|
|
133
175
|
*
|
|
@@ -1063,6 +1105,22 @@ declare const SETTINGS_SCHEMA: z.ZodObject<{
|
|
|
1063
1105
|
ask: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1064
1106
|
}, z.core.$loose>>;
|
|
1065
1107
|
}, z.core.$loose>;
|
|
1108
|
+
/**
|
|
1109
|
+
* What this package does with each `.claude/settings.json` key its diagnostics name, and why.
|
|
1110
|
+
*
|
|
1111
|
+
* #736 — the issue's ask in its own words: "Decide each documented key: honoured, or explicitly
|
|
1112
|
+
* unsupported with the reason." Reporting a key as "not implemented here" says the code does not act
|
|
1113
|
+
* on it. It does not say whether that is a REFUSAL or an OMISSION, and an author reading it cannot
|
|
1114
|
+
* tell whether to stop writing the key or to wait for it — the accepted-and-ignored failure one step
|
|
1115
|
+
* removed, arriving through the diagnostic instead of through the loader.
|
|
1116
|
+
*
|
|
1117
|
+
* Each verdict is decided on what exists HERE, never on what the reference documents. Exported
|
|
1118
|
+
* because a decision nobody can read is not a decision.
|
|
1119
|
+
*/
|
|
1120
|
+
declare const FOREIGN_KEY_DECISIONS: Readonly<Record<string, {
|
|
1121
|
+
readonly verdict: 'honoured' | 'refused';
|
|
1122
|
+
readonly because: string;
|
|
1123
|
+
}>>;
|
|
1066
1124
|
type Settings = z.infer<typeof SETTINGS_SCHEMA>;
|
|
1067
1125
|
interface LoadSettingsInput {
|
|
1068
1126
|
/** Project root. Its `.claude/settings.json` and `.claude/settings.local.json` are read. */
|
|
@@ -1086,6 +1144,52 @@ interface LoadSettingsResult {
|
|
|
1086
1144
|
*/
|
|
1087
1145
|
declare function loadSettings(input: LoadSettingsInput): LoadSettingsResult;
|
|
1088
1146
|
|
|
1147
|
+
/** The keys Claude Code's `settings.json` defines, for classifying a foreign file's keys. */
|
|
1148
|
+
declare const CLAUDE_SETTINGS_KEYS: ReadonlySet<string>;
|
|
1149
|
+
interface SettingsCandidate {
|
|
1150
|
+
readonly path: string;
|
|
1151
|
+
readonly foreignRoot: boolean;
|
|
1152
|
+
}
|
|
1153
|
+
interface SettingsCandidates {
|
|
1154
|
+
readonly user: readonly SettingsCandidate[];
|
|
1155
|
+
readonly project: readonly SettingsCandidate[];
|
|
1156
|
+
readonly projectLocal: readonly SettingsCandidate[];
|
|
1157
|
+
}
|
|
1158
|
+
/** Per scope, the ordered candidate paths: the own root before the foreign root. */
|
|
1159
|
+
declare function settingsCandidates(input: {
|
|
1160
|
+
readonly cwd: string;
|
|
1161
|
+
readonly home: string;
|
|
1162
|
+
readonly ownRoot: string;
|
|
1163
|
+
readonly foreignRoot?: string | false;
|
|
1164
|
+
}): SettingsCandidates;
|
|
1165
|
+
interface SettingsFileRead {
|
|
1166
|
+
readonly path: string;
|
|
1167
|
+
/** Own keys, renamed per `renames`. In an own-root file this also holds unknown keys. */
|
|
1168
|
+
readonly values: Record<string, unknown>;
|
|
1169
|
+
/** Known foreign keys not implemented here, plus `$schema` and `_`-prefixed keys. */
|
|
1170
|
+
readonly ignored: readonly string[];
|
|
1171
|
+
/** Keys neither own nor known to Claude Code; foreign file only. */
|
|
1172
|
+
readonly unrecognised: readonly string[];
|
|
1173
|
+
readonly permissionRules: readonly PermissionRule[];
|
|
1174
|
+
readonly unsupportedPermissions: readonly {
|
|
1175
|
+
readonly entry: string;
|
|
1176
|
+
readonly reason: string;
|
|
1177
|
+
}[];
|
|
1178
|
+
/** Raw `hooks`; pass to `parseClaudeHooks` for the foreign dialect. */
|
|
1179
|
+
readonly hooks?: unknown;
|
|
1180
|
+
}
|
|
1181
|
+
interface ReadSettingsFileOptions {
|
|
1182
|
+
readonly ownKeys: readonly string[];
|
|
1183
|
+
readonly renames?: Readonly<Record<string, string>>;
|
|
1184
|
+
readonly baseDir?: string;
|
|
1185
|
+
readonly specifierArg?: Readonly<Record<string, string>>;
|
|
1186
|
+
readonly onWarn?: (message: string) => void;
|
|
1187
|
+
}
|
|
1188
|
+
/** Read one candidate. `undefined` when the file is absent, or exists and cannot be parsed (warned). */
|
|
1189
|
+
declare function readSettingsFile(candidate: SettingsCandidate, options: ReadSettingsFileOptions): SettingsFileRead | undefined;
|
|
1190
|
+
/** The first candidate that yields a file; later candidates are not read. */
|
|
1191
|
+
declare function firstSettingsFile(candidates: readonly SettingsCandidate[], options: ReadSettingsFileOptions): SettingsFileRead | undefined;
|
|
1192
|
+
|
|
1089
1193
|
/**
|
|
1090
1194
|
* Split a markdown file into frontmatter lines and body.
|
|
1091
1195
|
*
|
|
@@ -1175,4 +1279,4 @@ declare class ContextPressureThresholdError extends TheokitAgentError {
|
|
|
1175
1279
|
*/
|
|
1176
1280
|
declare function contextPressure(usedTokens: number, effectiveWindow: number, thresholds?: ContextPressureThresholds): ContextPressure;
|
|
1177
1281
|
|
|
1178
|
-
export { type AgentMemory, AgentMemoryError, type AgentMemoryScope, 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, MEMORY_BYTE_CAP, MEMORY_LINE_CAP, type OperatorDefinition, type OperatorOrigin, type OperatorPolicy, OperatorRootUnreadableError, type OperatorRootsOptions, type OperatorRootsResult, type OutputStyle, OutputStyleError, type ParsedFrontmatter, type PermissionTranslation, type PermissionsBlock, type PrecedenceReport, type ProvenancePerKey, type ResolveAgentMemoryInput, SETTINGS_LAYERS, type Settings, type SettingsLayer, type ShellResult, type SkippedDefinition, type TemplateDeps, type TrustRecord, TrustStore, TrustStorePermissionsError, type UnsupportedPermissionEntry, type WithheldRoot, applySubagentMemory, blockAppliesTo, composeInstructions, contextPressure, currentOperatorPolicy, expandCommandTemplate, expandInstructionImports, frontmatterValue, layerPrecedence, loadCustomCommands, loadInstructionTree, loadOutputStyle, loadSettings, mcpServerAdmitted, permissionRulesFromSettings, resolveAgentMemory, resolveOperatorRoots, resolveOutputStyle, settingsLayerChain, splitFrontmatter, templateHints };
|
|
1282
|
+
export { type AgentMemory, AgentMemoryError, type AgentMemoryScope, type AppBootstrap, type BootstrapContext, BootstrapNotRunError, type BootstrapStep, BootstrapStepError, CLAUDE_SETTINGS_KEYS, type ComposeInstructionsOptions, type ComposedInstructions, type ConfigLayer, type ContextPressure, ContextPressureThresholdError, type ContextPressureThresholds, type CustomCommand, type CustomCommandsResult, DEFAULT_CONTEXT_PRESSURE_THRESHOLDS, type ExpandImportsInput, FILE_INLINE_CAP, FOREIGN_KEY_DECISIONS, 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, MEMORY_BYTE_CAP, MEMORY_LINE_CAP, type OperatorDefinition, type OperatorOrigin, type OperatorPolicy, OperatorRootUnreadableError, type OperatorRootsOptions, type OperatorRootsResult, type OutputStyle, OutputStyleError, type ParsedFrontmatter, type PermissionTranslation, type PermissionsBlock, type PrecedenceReport, type ProvenancePerKey, type ReadSettingsFileOptions, type ResolveAgentMemoryInput, SETTINGS_LAYERS, type Settings, type SettingsCandidate, type SettingsCandidates, type SettingsFileRead, type SettingsLayer, type ShellResult, type SkippedDefinition, type TemplateDeps, type TrustRecord, TrustStore, TrustStorePermissionsError, type UnsupportedPermissionEntry, type WithheldRoot, applySubagentMemory, assertBootstrapped, blockAppliesTo, composeInstructions, contextPressure, currentOperatorPolicy, defineAppBootstrap, expandCommandTemplate, expandInstructionImports, firstSettingsFile, frontmatterValue, layerPrecedence, loadCustomCommands, loadInstructionTree, loadOutputStyle, loadSettings, mcpServerAdmitted, permissionRulesFromSettings, projectEnvStep, readSettingsFile, resolveAgentMemory, resolveOperatorRoots, resolveOutputStyle, settingsCandidates, settingsLayerChain, splitFrontmatter, templateHints };
|