@theokit/agents 16.6.0 → 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 +14 -0
- package/README.md +84 -3
- 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-4xtsYrzm.d.ts → agent-orchestrator-DQtfrPaq.d.ts} +1 -1
- package/dist/{agent-runner-CE8MzVTu.d.ts → agent-runner-BuuqK_Dp.d.ts} +2 -2
- package/dist/{bridge-entry-BT2ou71q.d.ts → bridge-entry-nkeH6pAk.d.ts} +49 -6
- package/dist/bridge.d.ts +5 -5
- package/dist/bridge.js +7 -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-CZIJFINK.js → chunk-XGW7IZP6.js} +67 -3
- 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 +454 -60
- package/dist/config.js.map +1 -1
- package/dist/{delegation-scoring-4dQIXi-w.d.ts → delegation-scoring-DPckVefy.d.ts} +1 -1
- package/dist/evals.d.ts +2 -2
- package/dist/evals.js +2 -2
- package/dist/handoff.d.ts +3 -3
- 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 +21 -11
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/{sdk-adapter-BE0Cmj7f.d.ts → sdk-adapter-B0i8J7N0.d.ts} +1 -1
- 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 +3 -3
- package/dist/tools.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-AZ2FOUSN.js.map +0 -1
- package/dist/chunk-CZIJFINK.js.map +0 -1
- package/dist/chunk-KXE52FP2.js.map +0 -1
- package/dist/chunk-NIQJ4GZX.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/config.js
CHANGED
|
@@ -87,13 +87,105 @@ function buildReport(layers) {
|
|
|
87
87
|
}
|
|
88
88
|
__name(buildReport, "buildReport");
|
|
89
89
|
|
|
90
|
+
// src/config/app-bootstrap.ts
|
|
91
|
+
import { existsSync, readFileSync } from "fs";
|
|
92
|
+
import { join } from "path";
|
|
93
|
+
import { parseEnv } from "util";
|
|
94
|
+
import { loadProjectEnv } from "@theokit/sdk";
|
|
95
|
+
import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
|
|
96
|
+
var BootstrapStepError = class extends TheokitAgentError2 {
|
|
97
|
+
static {
|
|
98
|
+
__name(this, "BootstrapStepError");
|
|
99
|
+
}
|
|
100
|
+
name = "BootstrapStepError";
|
|
101
|
+
step;
|
|
102
|
+
constructor(step, cause) {
|
|
103
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
104
|
+
super(`[@theokit/agents] bootstrap step "${step}" failed: ${detail}`, {
|
|
105
|
+
code: "bootstrap_step_failed",
|
|
106
|
+
isRetryable: false,
|
|
107
|
+
cause
|
|
108
|
+
});
|
|
109
|
+
this.step = step;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var BootstrapNotRunError = class extends TheokitAgentError2 {
|
|
113
|
+
static {
|
|
114
|
+
__name(this, "BootstrapNotRunError");
|
|
115
|
+
}
|
|
116
|
+
name = "BootstrapNotRunError";
|
|
117
|
+
constructor(caller) {
|
|
118
|
+
super(`[@theokit/agents] ${caller} was called before the app bootstrap completed`, {
|
|
119
|
+
code: "bootstrap_not_run",
|
|
120
|
+
isRetryable: false
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
function defineAppBootstrap(steps) {
|
|
125
|
+
const seen = /* @__PURE__ */ new Set();
|
|
126
|
+
for (const step of steps) {
|
|
127
|
+
if (seen.has(step.name)) {
|
|
128
|
+
throw new Error(`[@theokit/agents] defineAppBootstrap: duplicate step name "${step.name}"`);
|
|
129
|
+
}
|
|
130
|
+
seen.add(step.name);
|
|
131
|
+
}
|
|
132
|
+
const list = [
|
|
133
|
+
...steps
|
|
134
|
+
];
|
|
135
|
+
let pending;
|
|
136
|
+
let done = false;
|
|
137
|
+
const execute = /* @__PURE__ */ __name(async (ctx) => {
|
|
138
|
+
await Promise.resolve();
|
|
139
|
+
const ran = [];
|
|
140
|
+
for (const step of list) {
|
|
141
|
+
try {
|
|
142
|
+
await step.run(ctx);
|
|
143
|
+
} catch (cause) {
|
|
144
|
+
throw new BootstrapStepError(step.name, cause);
|
|
145
|
+
}
|
|
146
|
+
ran.push(step.name);
|
|
147
|
+
}
|
|
148
|
+
done = true;
|
|
149
|
+
return {
|
|
150
|
+
ran
|
|
151
|
+
};
|
|
152
|
+
}, "execute");
|
|
153
|
+
return {
|
|
154
|
+
run(ctx) {
|
|
155
|
+
pending ??= execute(ctx);
|
|
156
|
+
return pending;
|
|
157
|
+
},
|
|
158
|
+
steps: list.map((s) => s.name),
|
|
159
|
+
get done() {
|
|
160
|
+
return done;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
__name(defineAppBootstrap, "defineAppBootstrap");
|
|
165
|
+
function assertBootstrapped(bootstrap, caller) {
|
|
166
|
+
if (!bootstrap.done) throw new BootstrapNotRunError(caller);
|
|
167
|
+
}
|
|
168
|
+
__name(assertBootstrapped, "assertBootstrapped");
|
|
169
|
+
var projectEnvStep = {
|
|
170
|
+
name: "project-env",
|
|
171
|
+
run(ctx) {
|
|
172
|
+
loadProjectEnv(ctx.env, () => {
|
|
173
|
+
const file = join(ctx.cwd, ".env");
|
|
174
|
+
if (!existsSync(file)) return;
|
|
175
|
+
for (const [key, value] of Object.entries(parseEnv(readFileSync(file, "utf8")))) {
|
|
176
|
+
ctx.env[key] ??= value;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
90
182
|
// src/config/trust-store.ts
|
|
91
|
-
import { chmodSync, existsSync, readFileSync, realpathSync, statSync } from "fs";
|
|
183
|
+
import { chmodSync, existsSync as existsSync2, readFileSync as readFileSync2, realpathSync, statSync } from "fs";
|
|
92
184
|
import { resolve } from "path";
|
|
93
185
|
import { resolveTrustPosture } from "@theokit/sdk";
|
|
94
|
-
import { TheokitAgentError as
|
|
186
|
+
import { TheokitAgentError as TheokitAgentError3 } from "@theokit/sdk/errors";
|
|
95
187
|
import { atomicWriteJson, withFileLock } from "@theokit/sdk/persistence";
|
|
96
|
-
var TrustStorePermissionsError = class extends
|
|
188
|
+
var TrustStorePermissionsError = class extends TheokitAgentError3 {
|
|
97
189
|
static {
|
|
98
190
|
__name(this, "TrustStorePermissionsError");
|
|
99
191
|
}
|
|
@@ -145,9 +237,9 @@ var TrustStore = class {
|
|
|
145
237
|
* correct starting state and the safe one.
|
|
146
238
|
*/
|
|
147
239
|
read() {
|
|
148
|
-
if (!
|
|
240
|
+
if (!existsSync2(this.file)) return [];
|
|
149
241
|
this.assertSafePermissions();
|
|
150
|
-
const parsed = JSON.parse(
|
|
242
|
+
const parsed = JSON.parse(readFileSync2(this.file, "utf8"));
|
|
151
243
|
return parsed.records;
|
|
152
244
|
}
|
|
153
245
|
/**
|
|
@@ -166,7 +258,7 @@ var TrustStore = class {
|
|
|
166
258
|
async trust(record) {
|
|
167
259
|
ensureSecureDir(this.file);
|
|
168
260
|
await withFileLock(this.file, async () => {
|
|
169
|
-
const existing =
|
|
261
|
+
const existing = existsSync2(this.file) ? this.read() : [];
|
|
170
262
|
const key = canonicalDir(record.path);
|
|
171
263
|
const records = [
|
|
172
264
|
...existing.filter((r) => canonicalDir(r.path) !== key),
|
|
@@ -204,7 +296,7 @@ var TrustStore = class {
|
|
|
204
296
|
};
|
|
205
297
|
|
|
206
298
|
// src/config/instruction-imports.ts
|
|
207
|
-
import { existsSync as
|
|
299
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "fs";
|
|
208
300
|
import { dirname, resolve as resolve2 } from "path";
|
|
209
301
|
var MAX_IMPORT_DEPTH = 4;
|
|
210
302
|
var IMPORT_REGEX = /(?<![\w`])@([\w~./-]+\.md)\b/g;
|
|
@@ -228,7 +320,7 @@ function importTarget(name, filePath, rootDir, visited, warn) {
|
|
|
228
320
|
return void 0;
|
|
229
321
|
}
|
|
230
322
|
const target = resolve2(dirname(filePath), name);
|
|
231
|
-
if (!
|
|
323
|
+
if (!existsSync3(target)) {
|
|
232
324
|
warn(`instruction import @${name} in ${filePath} was not found \u2014 kept literal`);
|
|
233
325
|
return void 0;
|
|
234
326
|
}
|
|
@@ -277,7 +369,7 @@ function expand(text, filePath, ctx) {
|
|
|
277
369
|
ctx.visited.add(target);
|
|
278
370
|
let content;
|
|
279
371
|
try {
|
|
280
|
-
content =
|
|
372
|
+
content = readFileSync3(target, "utf8");
|
|
281
373
|
} catch {
|
|
282
374
|
ctx.warn(`instruction import @${name} in ${filePath} could not be read \u2014 kept literal`);
|
|
283
375
|
out.push(match[0]);
|
|
@@ -295,8 +387,8 @@ function expand(text, filePath, ctx) {
|
|
|
295
387
|
__name(expand, "expand");
|
|
296
388
|
|
|
297
389
|
// src/config/instruction-tree.ts
|
|
298
|
-
import { readFileSync as
|
|
299
|
-
import { join, relative, resolve as resolve3 } from "path";
|
|
390
|
+
import { readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "fs";
|
|
391
|
+
import { join as join2, relative, resolve as resolve3 } from "path";
|
|
300
392
|
import { assertNoSymlinkEscape } from "@theokit/sdk/path-safety";
|
|
301
393
|
|
|
302
394
|
// src/config/frontmatter.ts
|
|
@@ -435,7 +527,7 @@ function walkOrder(dir, entries, order) {
|
|
|
435
527
|
for (const entry of [
|
|
436
528
|
...entries
|
|
437
529
|
].sort((a, b) => a.localeCompare(b))) {
|
|
438
|
-
const path =
|
|
530
|
+
const path = join2(dir, entry);
|
|
439
531
|
try {
|
|
440
532
|
found.push({
|
|
441
533
|
entry,
|
|
@@ -458,7 +550,7 @@ __name(walkOrder, "walkOrder");
|
|
|
458
550
|
function parseInstructionFile(path, cwd, warn) {
|
|
459
551
|
let raw;
|
|
460
552
|
try {
|
|
461
|
-
raw =
|
|
553
|
+
raw = readFileSync4(path, "utf8");
|
|
462
554
|
} catch {
|
|
463
555
|
return void 0;
|
|
464
556
|
}
|
|
@@ -573,21 +665,21 @@ function composeInstructions(base, sources, options) {
|
|
|
573
665
|
__name(composeInstructions, "composeInstructions");
|
|
574
666
|
|
|
575
667
|
// src/config/custom-commands.ts
|
|
576
|
-
import { readFileSync as
|
|
577
|
-
import { extname, join as
|
|
668
|
+
import { readFileSync as readFileSync5, readdirSync as readdirSync3, statSync as statSync3 } from "fs";
|
|
669
|
+
import { extname, join as join4, relative as relative2 } from "path";
|
|
578
670
|
|
|
579
671
|
// src/bridge/unloaded-surfaces.ts
|
|
580
|
-
import { existsSync as
|
|
581
|
-
import { join as
|
|
582
|
-
var WORKFLOWS_DIR =
|
|
672
|
+
import { existsSync as existsSync4, readdirSync as readdirSync2 } from "fs";
|
|
673
|
+
import { join as join3 } from "path";
|
|
674
|
+
var WORKFLOWS_DIR = join3(".claude", "workflows");
|
|
583
675
|
var SCRIPT_SUFFIXES = [
|
|
584
676
|
".js",
|
|
585
677
|
".mjs",
|
|
586
678
|
".cjs"
|
|
587
679
|
];
|
|
588
680
|
function reportUnloadedSurfaces(input) {
|
|
589
|
-
const dir =
|
|
590
|
-
if (!
|
|
681
|
+
const dir = join3(input.cwd, WORKFLOWS_DIR);
|
|
682
|
+
if (!existsSync4(dir)) return;
|
|
591
683
|
let scripts;
|
|
592
684
|
try {
|
|
593
685
|
scripts = readdirSync2(dir).filter((f) => SCRIPT_SUFFIXES.some((s) => f.endsWith(s)));
|
|
@@ -602,8 +694,8 @@ function reportUnloadedSurfaces(input) {
|
|
|
602
694
|
__name(reportUnloadedSurfaces, "reportUnloadedSurfaces");
|
|
603
695
|
|
|
604
696
|
// src/config/custom-commands.ts
|
|
605
|
-
var COMMANDS_DIR =
|
|
606
|
-
var COMPAT_COMMANDS_DIR =
|
|
697
|
+
var COMMANDS_DIR = join4(".theokit", "commands");
|
|
698
|
+
var COMPAT_COMMANDS_DIR = join4(".claude", "commands");
|
|
607
699
|
var CLAUDE_CODE_SOURCE = "claude-code";
|
|
608
700
|
var IGNORE_WARNING3 = /* @__PURE__ */ __name(() => void 0, "IGNORE_WARNING");
|
|
609
701
|
function declaresCommands(sources) {
|
|
@@ -625,9 +717,9 @@ function projectCommandDirs(input) {
|
|
|
625
717
|
if (input.projectDir === void 0) return [];
|
|
626
718
|
const dirs = [];
|
|
627
719
|
if (declaresCommands(input.compatSources)) {
|
|
628
|
-
dirs.push(
|
|
720
|
+
dirs.push(join4(input.projectDir, COMPAT_COMMANDS_DIR));
|
|
629
721
|
}
|
|
630
|
-
dirs.push(
|
|
722
|
+
dirs.push(join4(input.projectDir, COMMANDS_DIR));
|
|
631
723
|
return dirs;
|
|
632
724
|
}
|
|
633
725
|
__name(projectCommandDirs, "projectCommandDirs");
|
|
@@ -660,7 +752,7 @@ function loadCustomCommands(input) {
|
|
|
660
752
|
});
|
|
661
753
|
}
|
|
662
754
|
if (input.homeDir !== void 0) {
|
|
663
|
-
for (const command of readCommandsDir(
|
|
755
|
+
for (const command of readCommandsDir(join4(input.homeDir, COMMANDS_DIR), "user", warn)) {
|
|
664
756
|
loaded.set(command.name, command);
|
|
665
757
|
}
|
|
666
758
|
}
|
|
@@ -696,7 +788,7 @@ function readCommandsDir(dir, source, warn, root = dir) {
|
|
|
696
788
|
entries.sort((a, b) => a.localeCompare(b));
|
|
697
789
|
const commands = [];
|
|
698
790
|
for (const entry of entries) {
|
|
699
|
-
const path =
|
|
791
|
+
const path = join4(dir, entry);
|
|
700
792
|
let stats;
|
|
701
793
|
try {
|
|
702
794
|
stats = statSync3(path);
|
|
@@ -717,7 +809,7 @@ __name(readCommandsDir, "readCommandsDir");
|
|
|
717
809
|
function parseCommandFile(path, entry, source, warn) {
|
|
718
810
|
let raw;
|
|
719
811
|
try {
|
|
720
|
-
raw =
|
|
812
|
+
raw = readFileSync5(path, "utf8");
|
|
721
813
|
} catch {
|
|
722
814
|
return void 0;
|
|
723
815
|
}
|
|
@@ -878,13 +970,13 @@ function settingsLayerChain(values) {
|
|
|
878
970
|
__name(settingsLayerChain, "settingsLayerChain");
|
|
879
971
|
|
|
880
972
|
// src/config/output-styles.ts
|
|
881
|
-
import { existsSync as
|
|
882
|
-
import { join as
|
|
883
|
-
import { TheokitAgentError as
|
|
973
|
+
import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
|
|
974
|
+
import { join as join6 } from "path";
|
|
975
|
+
import { TheokitAgentError as TheokitAgentError4 } from "@theokit/sdk/errors";
|
|
884
976
|
|
|
885
977
|
// src/config/settings-file.ts
|
|
886
|
-
import { existsSync as
|
|
887
|
-
import { join as
|
|
978
|
+
import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
|
|
979
|
+
import { join as join5 } from "path";
|
|
888
980
|
import { z } from "zod";
|
|
889
981
|
var SETTINGS_SCHEMA = z.looseObject({
|
|
890
982
|
/** Selects a file under `.claude/output-styles/`. Consumed by `loadOutputStyle`. */
|
|
@@ -915,6 +1007,44 @@ var SETTINGS_SCHEMA = z.looseObject({
|
|
|
915
1007
|
ask: z.array(z.string()).optional()
|
|
916
1008
|
}).loose().optional()
|
|
917
1009
|
});
|
|
1010
|
+
var FOREIGN_KEY_DECISIONS = {
|
|
1011
|
+
permissions: {
|
|
1012
|
+
verdict: "honoured",
|
|
1013
|
+
because: "translated into PermissionRule[] and enforced by a pre_tool_call plugin, with denies ordered ahead of allows"
|
|
1014
|
+
},
|
|
1015
|
+
hooks: {
|
|
1016
|
+
verdict: "honoured",
|
|
1017
|
+
because: "granted per surface, and withheld entirely by a consumer that gates them, because a hook executes shell from a file the repository ships"
|
|
1018
|
+
},
|
|
1019
|
+
outputStyle: {
|
|
1020
|
+
verdict: "honoured",
|
|
1021
|
+
because: "read by loadSettings and resolved against .claude/output-styles/ by loadOutputStyle"
|
|
1022
|
+
},
|
|
1023
|
+
model: {
|
|
1024
|
+
verdict: "honoured",
|
|
1025
|
+
because: "this package has a model of its own for the run to select, so a key written here names something the code can act on"
|
|
1026
|
+
},
|
|
1027
|
+
cleanupPeriodDays: {
|
|
1028
|
+
verdict: "honoured",
|
|
1029
|
+
because: "a consumer here keeps session transcripts and collects them on a window, so the number has somewhere to land"
|
|
1030
|
+
},
|
|
1031
|
+
env: {
|
|
1032
|
+
verdict: "refused",
|
|
1033
|
+
because: "an environment variable is not inert: NODE_OPTIONS --require runs a file before the program does, and the directory usually arrives with the clone, so applying it would let a repository choose what runs inside every subprocess"
|
|
1034
|
+
},
|
|
1035
|
+
statusLine: {
|
|
1036
|
+
verdict: "refused",
|
|
1037
|
+
because: "it is a command spec rather than a value, so honouring it would execute a shell command written in a file the repository ships \u2014 the same trust decision env is refused for, with a nicer name"
|
|
1038
|
+
},
|
|
1039
|
+
autoMemoryEnabled: {
|
|
1040
|
+
verdict: "refused",
|
|
1041
|
+
because: "it toggles a per-project transcript memory this package does not have, and a flag that switches off something absent reads as a control in force while governing nothing"
|
|
1042
|
+
},
|
|
1043
|
+
workflows: {
|
|
1044
|
+
verdict: "refused",
|
|
1045
|
+
because: "a workflow file is code, and executing JavaScript found under a caller-supplied directory is a trust decision that belongs to the host rather than to this library"
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
918
1048
|
var IGNORE_WARNING4 = /* @__PURE__ */ __name(() => void 0, "IGNORE_WARNING");
|
|
919
1049
|
var FILE_LAYERS = [
|
|
920
1050
|
{
|
|
@@ -934,9 +1064,9 @@ var FILE_LAYERS = [
|
|
|
934
1064
|
}
|
|
935
1065
|
];
|
|
936
1066
|
function readLayer(path, warn) {
|
|
937
|
-
if (!
|
|
1067
|
+
if (!existsSync5(path)) return {};
|
|
938
1068
|
try {
|
|
939
|
-
const parsed = JSON.parse(
|
|
1069
|
+
const parsed = JSON.parse(readFileSync6(path, "utf8"));
|
|
940
1070
|
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
941
1071
|
warn(`${path} is not a JSON object \u2014 it is NOT being applied.`);
|
|
942
1072
|
return {};
|
|
@@ -959,7 +1089,7 @@ function loadSettings(input) {
|
|
|
959
1089
|
{
|
|
960
1090
|
layer: entry.layer,
|
|
961
1091
|
precedence: declared.precedence,
|
|
962
|
-
values: readLayer(
|
|
1092
|
+
values: readLayer(join5(root, ".claude", entry.file), warn)
|
|
963
1093
|
}
|
|
964
1094
|
];
|
|
965
1095
|
});
|
|
@@ -979,8 +1109,8 @@ function loadSettings(input) {
|
|
|
979
1109
|
__name(loadSettings, "loadSettings");
|
|
980
1110
|
|
|
981
1111
|
// src/config/output-styles.ts
|
|
982
|
-
var OUTPUT_STYLES_DIR =
|
|
983
|
-
var OutputStyleError = class extends
|
|
1112
|
+
var OUTPUT_STYLES_DIR = join6(".claude", "output-styles");
|
|
1113
|
+
var OutputStyleError = class extends TheokitAgentError4 {
|
|
984
1114
|
static {
|
|
985
1115
|
__name(this, "OutputStyleError");
|
|
986
1116
|
}
|
|
@@ -995,15 +1125,15 @@ var OutputStyleError = class extends TheokitAgentError3 {
|
|
|
995
1125
|
function loadOutputStyle(input) {
|
|
996
1126
|
if (input.name === void 0) return void 0;
|
|
997
1127
|
const searched = [
|
|
998
|
-
|
|
1128
|
+
join6(input.cwd, OUTPUT_STYLES_DIR),
|
|
999
1129
|
...input.homeDir === void 0 ? [] : [
|
|
1000
|
-
|
|
1130
|
+
join6(input.homeDir, OUTPUT_STYLES_DIR)
|
|
1001
1131
|
]
|
|
1002
1132
|
];
|
|
1003
1133
|
for (const dir of searched) {
|
|
1004
|
-
const path =
|
|
1005
|
-
if (!
|
|
1006
|
-
const raw =
|
|
1134
|
+
const path = join6(dir, `${input.name}.md`);
|
|
1135
|
+
if (!existsSync6(path)) continue;
|
|
1136
|
+
const raw = readFileSync7(path, "utf8");
|
|
1007
1137
|
const parsed = splitFrontmatter(raw);
|
|
1008
1138
|
const body = parsed === void 0 ? raw : parsed.body;
|
|
1009
1139
|
const description = parsed === void 0 ? void 0 : frontmatterValue(parsed.frontmatter, "description");
|
|
@@ -1029,11 +1159,11 @@ function resolveOutputStyle(input) {
|
|
|
1029
1159
|
__name(resolveOutputStyle, "resolveOutputStyle");
|
|
1030
1160
|
|
|
1031
1161
|
// src/config/operator-roots.ts
|
|
1032
|
-
import { readdirSync as readdirSync4, readFileSync as
|
|
1162
|
+
import { readdirSync as readdirSync4, readFileSync as readFileSync8, statSync as statSync4 } from "fs";
|
|
1033
1163
|
import { homedir } from "os";
|
|
1034
|
-
import { join as
|
|
1035
|
-
import { TheokitAgentError as
|
|
1036
|
-
var OperatorRootUnreadableError = class extends
|
|
1164
|
+
import { join as join7 } from "path";
|
|
1165
|
+
import { TheokitAgentError as TheokitAgentError5 } from "@theokit/sdk/errors";
|
|
1166
|
+
var OperatorRootUnreadableError = class extends TheokitAgentError5 {
|
|
1037
1167
|
static {
|
|
1038
1168
|
__name(this, "OperatorRootUnreadableError");
|
|
1039
1169
|
}
|
|
@@ -1075,10 +1205,10 @@ function readDefinitions(root, origin, skipped) {
|
|
|
1075
1205
|
const out = [];
|
|
1076
1206
|
for (const entry of entries) {
|
|
1077
1207
|
if (!entry.endsWith(".md")) continue;
|
|
1078
|
-
const path =
|
|
1208
|
+
const path = join7(root, entry);
|
|
1079
1209
|
let body;
|
|
1080
1210
|
try {
|
|
1081
|
-
body =
|
|
1211
|
+
body = readFileSync8(path, "utf8");
|
|
1082
1212
|
} catch (cause) {
|
|
1083
1213
|
throw new OperatorRootUnreadableError(path, cause);
|
|
1084
1214
|
}
|
|
@@ -1118,7 +1248,7 @@ function resolveOperatorRoots(options) {
|
|
|
1118
1248
|
"skills",
|
|
1119
1249
|
"agents"
|
|
1120
1250
|
]) {
|
|
1121
|
-
const root =
|
|
1251
|
+
const root = join7(base, dir, kind);
|
|
1122
1252
|
if (!exists(root)) continue;
|
|
1123
1253
|
if (dialect !== void 0 && !grants.has(dialect)) {
|
|
1124
1254
|
withheld.push({
|
|
@@ -1141,9 +1271,9 @@ function resolveOperatorRoots(options) {
|
|
|
1141
1271
|
__name(resolveOperatorRoots, "resolveOperatorRoots");
|
|
1142
1272
|
|
|
1143
1273
|
// src/config/agent-memory.ts
|
|
1144
|
-
import { existsSync as
|
|
1145
|
-
import { join as
|
|
1146
|
-
import { TheokitAgentError as
|
|
1274
|
+
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
|
|
1275
|
+
import { join as join8, resolve as resolve4 } from "path";
|
|
1276
|
+
import { TheokitAgentError as TheokitAgentError6 } from "@theokit/sdk/errors";
|
|
1147
1277
|
var MEMORY_LINE_CAP = 200;
|
|
1148
1278
|
var MEMORY_BYTE_CAP = 25e3;
|
|
1149
1279
|
var ROOTS2 = {
|
|
@@ -1160,7 +1290,7 @@ var ROOTS2 = {
|
|
|
1160
1290
|
"agent-memory"
|
|
1161
1291
|
]
|
|
1162
1292
|
};
|
|
1163
|
-
var AgentMemoryError = class extends
|
|
1293
|
+
var AgentMemoryError = class extends TheokitAgentError6 {
|
|
1164
1294
|
static {
|
|
1165
1295
|
__name(this, "AgentMemoryError");
|
|
1166
1296
|
}
|
|
@@ -1207,15 +1337,15 @@ function resolveAgentMemory(input) {
|
|
|
1207
1337
|
if (baseDir === void 0) {
|
|
1208
1338
|
throw new AgentMemoryError(`memory scope "user" needs a home directory and none was given. Falling back to the project would write cross-project notes into one repository, which is the opposite of what the scope asks for.`);
|
|
1209
1339
|
}
|
|
1210
|
-
const memoryRoot =
|
|
1340
|
+
const memoryRoot = join8(baseDir, ".claude", dir);
|
|
1211
1341
|
assertContained(memoryRoot, input.agent);
|
|
1212
|
-
const root =
|
|
1213
|
-
const file =
|
|
1214
|
-
if (!
|
|
1342
|
+
const root = join8(memoryRoot, input.agent);
|
|
1343
|
+
const file = join8(root, "MEMORY.md");
|
|
1344
|
+
if (!existsSync7(file)) return {
|
|
1215
1345
|
root,
|
|
1216
1346
|
truncated: false
|
|
1217
1347
|
};
|
|
1218
|
-
const { text, truncated } = capped(
|
|
1348
|
+
const { text, truncated } = capped(readFileSync9(file, "utf8"));
|
|
1219
1349
|
return {
|
|
1220
1350
|
root,
|
|
1221
1351
|
memory: text,
|
|
@@ -1392,14 +1522,268 @@ function permissionRulesFromSettings(block, opts = {}) {
|
|
|
1392
1522
|
}
|
|
1393
1523
|
__name(permissionRulesFromSettings, "permissionRulesFromSettings");
|
|
1394
1524
|
|
|
1525
|
+
// src/config/settings-roots.ts
|
|
1526
|
+
import { existsSync as existsSync8, readFileSync as readFileSync10 } from "fs";
|
|
1527
|
+
import { join as join9 } from "path";
|
|
1528
|
+
var CLAUDE_SETTINGS_KEYS = /* @__PURE__ */ new Set([
|
|
1529
|
+
"advisorModel",
|
|
1530
|
+
"agent",
|
|
1531
|
+
"agentPushNotifEnabled",
|
|
1532
|
+
"allowAllClaudeAiMcps",
|
|
1533
|
+
"allowedChannelPlugins",
|
|
1534
|
+
"allowedHttpHookUrls",
|
|
1535
|
+
"allowedMcpServers",
|
|
1536
|
+
"allowManagedHooksOnly",
|
|
1537
|
+
"allowManagedMcpServersOnly",
|
|
1538
|
+
"allowManagedPermissionRulesOnly",
|
|
1539
|
+
"alwaysThinkingEnabled",
|
|
1540
|
+
"apiKeyHelper",
|
|
1541
|
+
"askUserQuestionTimeout",
|
|
1542
|
+
"attribution",
|
|
1543
|
+
"autoCompactEnabled",
|
|
1544
|
+
"autoCompactWindow",
|
|
1545
|
+
"autoConnectIde",
|
|
1546
|
+
"autoContinueAtUsageLimit",
|
|
1547
|
+
"autoInstallIdeExtension",
|
|
1548
|
+
"autoMemoryDirectory",
|
|
1549
|
+
"autoMemoryEnabled",
|
|
1550
|
+
"autoMode",
|
|
1551
|
+
"autoScrollEnabled",
|
|
1552
|
+
"autoUpdatesChannel",
|
|
1553
|
+
"availableModels",
|
|
1554
|
+
"awaySummaryEnabled",
|
|
1555
|
+
"awsAuthRefresh",
|
|
1556
|
+
"awsCredentialExport",
|
|
1557
|
+
"axScreenReader",
|
|
1558
|
+
"bashOutputMaxChars",
|
|
1559
|
+
"blockedMarketplaces",
|
|
1560
|
+
"browserExternalPageTools",
|
|
1561
|
+
"channelsEnabled",
|
|
1562
|
+
"claudeMd",
|
|
1563
|
+
"claudeMdExcludes",
|
|
1564
|
+
"cleanupPeriodDays",
|
|
1565
|
+
"companyAnnouncements",
|
|
1566
|
+
"crossSessionInbound",
|
|
1567
|
+
"defaultShell",
|
|
1568
|
+
"deniedMcpServers",
|
|
1569
|
+
"desktopSessionCleanupPeriodDays",
|
|
1570
|
+
"dialogExpiry",
|
|
1571
|
+
"diffTool",
|
|
1572
|
+
"disableAgentView",
|
|
1573
|
+
"disableAllHooks",
|
|
1574
|
+
"disableArtifact",
|
|
1575
|
+
"disableAutoMode",
|
|
1576
|
+
"disableBrowserExternalNavigation",
|
|
1577
|
+
"disableBundledSkills",
|
|
1578
|
+
"disableClaudeAiConnectors",
|
|
1579
|
+
"disableCommandPluginSources",
|
|
1580
|
+
"disableDeepLinkRegistration",
|
|
1581
|
+
"disableDesktopLocalSessions",
|
|
1582
|
+
"disabledMcpjsonServers",
|
|
1583
|
+
"disableMobileSimulatorTools",
|
|
1584
|
+
"disableRemoteControl",
|
|
1585
|
+
"disableSideloadFlags",
|
|
1586
|
+
"disableSkillShellExecution",
|
|
1587
|
+
"disableWorkflows",
|
|
1588
|
+
"editorMode",
|
|
1589
|
+
"effortLevel",
|
|
1590
|
+
"emojiCompletionEnabled",
|
|
1591
|
+
"enableAllProjectMcpServers",
|
|
1592
|
+
"enableArtifact",
|
|
1593
|
+
"enabledMcpjsonServers",
|
|
1594
|
+
"enabledPlugins",
|
|
1595
|
+
"enableWorkflows",
|
|
1596
|
+
"enforceAvailableModels",
|
|
1597
|
+
"env",
|
|
1598
|
+
"externalEditorContext",
|
|
1599
|
+
"extraKnownMarketplaces",
|
|
1600
|
+
"fallbackModel",
|
|
1601
|
+
"fastMode",
|
|
1602
|
+
"fastModePerSessionOptIn",
|
|
1603
|
+
"feedbackDrafts",
|
|
1604
|
+
"feedbackSurveyRate",
|
|
1605
|
+
"fileCheckpointingEnabled",
|
|
1606
|
+
"fileSuggestion",
|
|
1607
|
+
"footerLinksRegexes",
|
|
1608
|
+
"forceLoginGatewayUrl",
|
|
1609
|
+
"forceLoginMethod",
|
|
1610
|
+
"forceLoginOrgUUID",
|
|
1611
|
+
"forceRemoteSettingsRefresh",
|
|
1612
|
+
"gcpAuthRefresh",
|
|
1613
|
+
"httpHookAllowedEnvVars",
|
|
1614
|
+
"includeCoAuthoredBy",
|
|
1615
|
+
"includeGitInstructions",
|
|
1616
|
+
"inputNeededNotifEnabled",
|
|
1617
|
+
"isolatePeerMachines",
|
|
1618
|
+
"keybindingFlavor",
|
|
1619
|
+
"language",
|
|
1620
|
+
"managedSourcesBehavior",
|
|
1621
|
+
"minimumVersion",
|
|
1622
|
+
"modelOverrides",
|
|
1623
|
+
"modelPicker",
|
|
1624
|
+
"modelPricing",
|
|
1625
|
+
"modelSettings",
|
|
1626
|
+
"otelHeadersHelper",
|
|
1627
|
+
"parentSettingsBehavior",
|
|
1628
|
+
"permissionExplainerEnabled",
|
|
1629
|
+
"permissions",
|
|
1630
|
+
"plansDirectory",
|
|
1631
|
+
"pluginConfigs",
|
|
1632
|
+
"pluginSuggestionMarketplaces",
|
|
1633
|
+
"pluginTrustMessage",
|
|
1634
|
+
"policyHelper",
|
|
1635
|
+
"preferredNotifChannel",
|
|
1636
|
+
"prefersReducedMotion",
|
|
1637
|
+
"processWrapper",
|
|
1638
|
+
"promptCacheTtl",
|
|
1639
|
+
"promptSuggestionEnabled",
|
|
1640
|
+
"prUrlTemplate",
|
|
1641
|
+
"remoteControlAtStartup",
|
|
1642
|
+
"requiredMaximumVersion",
|
|
1643
|
+
"requiredMinimumVersion",
|
|
1644
|
+
"respectGitignore",
|
|
1645
|
+
"respondToBashCommands",
|
|
1646
|
+
"sandbox",
|
|
1647
|
+
"showClearContextOnPlanAccept",
|
|
1648
|
+
"showThinkingSummaries",
|
|
1649
|
+
"showTurnDuration",
|
|
1650
|
+
"skillListingBudgetFraction",
|
|
1651
|
+
"skillListingMaxDescChars",
|
|
1652
|
+
"skillOverrides",
|
|
1653
|
+
"skipAutoPermissionPrompt",
|
|
1654
|
+
"skipDangerousModePermissionPrompt",
|
|
1655
|
+
"skipWebFetchPreflight",
|
|
1656
|
+
"spellcheck",
|
|
1657
|
+
"spinnerTipsEnabled",
|
|
1658
|
+
"spinnerTipsOverride",
|
|
1659
|
+
"spinnerVerbs",
|
|
1660
|
+
"sshConfigs",
|
|
1661
|
+
"sshHostAllowlist",
|
|
1662
|
+
"statusLine",
|
|
1663
|
+
"strictKnownMarketplaces",
|
|
1664
|
+
"strictPluginOnlyCustomization",
|
|
1665
|
+
"subagentPromptCacheTtl",
|
|
1666
|
+
"ultracode",
|
|
1667
|
+
"workflowSizeGuideline"
|
|
1668
|
+
]);
|
|
1669
|
+
function settingsCandidates(input) {
|
|
1670
|
+
const foreign = input.foreignRoot ?? ".claude";
|
|
1671
|
+
const roots = [
|
|
1672
|
+
{
|
|
1673
|
+
root: input.ownRoot,
|
|
1674
|
+
foreignRoot: false
|
|
1675
|
+
},
|
|
1676
|
+
...foreign === false ? [] : [
|
|
1677
|
+
{
|
|
1678
|
+
root: foreign,
|
|
1679
|
+
foreignRoot: true
|
|
1680
|
+
}
|
|
1681
|
+
]
|
|
1682
|
+
];
|
|
1683
|
+
const scope = /* @__PURE__ */ __name((base, file) => roots.map((r) => ({
|
|
1684
|
+
path: join9(base, r.root, file),
|
|
1685
|
+
foreignRoot: r.foreignRoot
|
|
1686
|
+
})), "scope");
|
|
1687
|
+
return {
|
|
1688
|
+
user: scope(input.home, "settings.json"),
|
|
1689
|
+
project: scope(input.cwd, "settings.json"),
|
|
1690
|
+
projectLocal: scope(input.cwd, "settings.local.json")
|
|
1691
|
+
};
|
|
1692
|
+
}
|
|
1693
|
+
__name(settingsCandidates, "settingsCandidates");
|
|
1694
|
+
function isConvention(key) {
|
|
1695
|
+
return key === "$schema" || key.startsWith("_");
|
|
1696
|
+
}
|
|
1697
|
+
__name(isConvention, "isConvention");
|
|
1698
|
+
function isKnownForeign(key) {
|
|
1699
|
+
return CLAUDE_SETTINGS_KEYS.has(key) || Object.hasOwn(FOREIGN_KEY_DECISIONS, key) || isConvention(key);
|
|
1700
|
+
}
|
|
1701
|
+
__name(isKnownForeign, "isKnownForeign");
|
|
1702
|
+
function parseFile(path, warn) {
|
|
1703
|
+
if (!existsSync8(path)) return void 0;
|
|
1704
|
+
try {
|
|
1705
|
+
const parsed = JSON.parse(readFileSync10(path, "utf8"));
|
|
1706
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1707
|
+
warn(`${path} is not a JSON object \u2014 it is NOT being applied.`);
|
|
1708
|
+
return void 0;
|
|
1709
|
+
}
|
|
1710
|
+
return parsed;
|
|
1711
|
+
} catch (error) {
|
|
1712
|
+
warn(`${path} could not be parsed (${error.message}) \u2014 it is NOT being applied.`);
|
|
1713
|
+
return void 0;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
__name(parseFile, "parseFile");
|
|
1717
|
+
function readSettingsFile(candidate, options) {
|
|
1718
|
+
const raw = parseFile(candidate.path, options.onWarn ?? (() => void 0));
|
|
1719
|
+
if (raw === void 0) return void 0;
|
|
1720
|
+
const own = new Set(options.ownKeys);
|
|
1721
|
+
const values = {};
|
|
1722
|
+
const ignored = [];
|
|
1723
|
+
const unrecognised = [];
|
|
1724
|
+
let permissionRules = [];
|
|
1725
|
+
let unsupportedPermissions = [];
|
|
1726
|
+
let hooks;
|
|
1727
|
+
let hasHooks = false;
|
|
1728
|
+
for (const [rawKey, value] of Object.entries(raw)) {
|
|
1729
|
+
const key = options.renames?.[rawKey] ?? rawKey;
|
|
1730
|
+
if (key === "permissions") {
|
|
1731
|
+
const translated = permissionRulesFromSettings(value, {
|
|
1732
|
+
...options.specifierArg === void 0 ? {} : {
|
|
1733
|
+
specifierArg: options.specifierArg
|
|
1734
|
+
},
|
|
1735
|
+
...options.baseDir === void 0 ? {} : {
|
|
1736
|
+
baseDir: options.baseDir
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
permissionRules = translated.rules;
|
|
1740
|
+
unsupportedPermissions = translated.unsupported.map((u) => ({
|
|
1741
|
+
entry: u.entry,
|
|
1742
|
+
reason: u.reason
|
|
1743
|
+
}));
|
|
1744
|
+
} else if (key === "hooks") {
|
|
1745
|
+
hooks = value;
|
|
1746
|
+
hasHooks = true;
|
|
1747
|
+
} else if (own.has(key)) {
|
|
1748
|
+
values[key] = value;
|
|
1749
|
+
} else if (isKnownForeign(key)) {
|
|
1750
|
+
ignored.push(key);
|
|
1751
|
+
} else if (candidate.foreignRoot) {
|
|
1752
|
+
unrecognised.push(key);
|
|
1753
|
+
} else {
|
|
1754
|
+
values[key] = value;
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
return {
|
|
1758
|
+
path: candidate.path,
|
|
1759
|
+
values,
|
|
1760
|
+
ignored,
|
|
1761
|
+
unrecognised,
|
|
1762
|
+
permissionRules,
|
|
1763
|
+
unsupportedPermissions,
|
|
1764
|
+
...hasHooks ? {
|
|
1765
|
+
hooks
|
|
1766
|
+
} : {}
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
__name(readSettingsFile, "readSettingsFile");
|
|
1770
|
+
function firstSettingsFile(candidates, options) {
|
|
1771
|
+
for (const candidate of candidates) {
|
|
1772
|
+
const read = readSettingsFile(candidate, options);
|
|
1773
|
+
if (read !== void 0) return read;
|
|
1774
|
+
}
|
|
1775
|
+
return void 0;
|
|
1776
|
+
}
|
|
1777
|
+
__name(firstSettingsFile, "firstSettingsFile");
|
|
1778
|
+
|
|
1395
1779
|
// src/config/context-pressure.ts
|
|
1396
1780
|
import { resolveEffectiveContextWindow } from "@theokit/sdk/compaction";
|
|
1397
|
-
import { TheokitAgentError as
|
|
1781
|
+
import { TheokitAgentError as TheokitAgentError7 } from "@theokit/sdk/errors";
|
|
1398
1782
|
var DEFAULT_CONTEXT_PRESSURE_THRESHOLDS = {
|
|
1399
1783
|
warn: 0.75,
|
|
1400
1784
|
critical: 0.9
|
|
1401
1785
|
};
|
|
1402
|
-
var ContextPressureThresholdError = class extends
|
|
1786
|
+
var ContextPressureThresholdError = class extends TheokitAgentError7 {
|
|
1403
1787
|
static {
|
|
1404
1788
|
__name(this, "ContextPressureThresholdError");
|
|
1405
1789
|
}
|
|
@@ -1425,9 +1809,13 @@ function contextPressure(usedTokens, effectiveWindow, thresholds = DEFAULT_CONTE
|
|
|
1425
1809
|
__name(contextPressure, "contextPressure");
|
|
1426
1810
|
export {
|
|
1427
1811
|
AgentMemoryError,
|
|
1812
|
+
BootstrapNotRunError,
|
|
1813
|
+
BootstrapStepError,
|
|
1814
|
+
CLAUDE_SETTINGS_KEYS,
|
|
1428
1815
|
ContextPressureThresholdError,
|
|
1429
1816
|
DEFAULT_CONTEXT_PRESSURE_THRESHOLDS,
|
|
1430
1817
|
FILE_INLINE_CAP,
|
|
1818
|
+
FOREIGN_KEY_DECISIONS,
|
|
1431
1819
|
LAYERS_ARE_POSITIONED,
|
|
1432
1820
|
LayerOutOfOrderError,
|
|
1433
1821
|
LayeredConfig,
|
|
@@ -1439,13 +1827,16 @@ export {
|
|
|
1439
1827
|
TrustStore,
|
|
1440
1828
|
TrustStorePermissionsError,
|
|
1441
1829
|
applySubagentMemory,
|
|
1830
|
+
assertBootstrapped,
|
|
1442
1831
|
blockAppliesTo,
|
|
1443
1832
|
composeInstructions,
|
|
1444
1833
|
contextPressure,
|
|
1445
1834
|
currentOperatorPolicy,
|
|
1835
|
+
defineAppBootstrap,
|
|
1446
1836
|
resolveEffectiveContextWindow as effectiveContextWindow,
|
|
1447
1837
|
expandCommandTemplate,
|
|
1448
1838
|
expandInstructionImports,
|
|
1839
|
+
firstSettingsFile,
|
|
1449
1840
|
frontmatterValue,
|
|
1450
1841
|
layerPrecedence,
|
|
1451
1842
|
loadCustomCommands,
|
|
@@ -1454,9 +1845,12 @@ export {
|
|
|
1454
1845
|
loadSettings,
|
|
1455
1846
|
mcpServerAdmitted,
|
|
1456
1847
|
permissionRulesFromSettings,
|
|
1848
|
+
projectEnvStep,
|
|
1849
|
+
readSettingsFile,
|
|
1457
1850
|
resolveAgentMemory,
|
|
1458
1851
|
resolveOperatorRoots,
|
|
1459
1852
|
resolveOutputStyle,
|
|
1853
|
+
settingsCandidates,
|
|
1460
1854
|
settingsLayerChain,
|
|
1461
1855
|
splitFrontmatter,
|
|
1462
1856
|
templateHints
|