@letrquan/book 0.3.0 → 0.4.0-beta.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 +1024 -0
- package/README.md +6 -3
- package/dist/{additional-roots-H7UNAEHS.js → additional-roots-VAWRQ625.js} +8 -7
- package/dist/{app-GE4OHJOC.js → app-J7BVPSUH.js} +5397 -2953
- package/dist/app-J7BVPSUH.js.map +1 -0
- package/dist/chunk-32WBCUAN.js +660 -0
- package/dist/chunk-32WBCUAN.js.map +1 -0
- package/dist/{chunk-525CAZPY.js → chunk-4DKHLZRI.js} +6 -6
- package/dist/{chunk-4AS7LKKQ.js → chunk-62EEAUID.js} +2 -2
- package/dist/{chunk-AQEQX4FF.js → chunk-AHC7OU75.js} +385 -55
- package/dist/chunk-AHC7OU75.js.map +1 -0
- package/dist/{chunk-EFJ2NH6E.js → chunk-AJZWLKLQ.js} +63 -14
- package/dist/chunk-AJZWLKLQ.js.map +1 -0
- package/dist/chunk-B5FC3MYZ.js +395 -0
- package/dist/chunk-B5FC3MYZ.js.map +1 -0
- package/dist/{chunk-67UZEWWF.js → chunk-DNFQTSMJ.js} +53 -11
- package/dist/chunk-DNFQTSMJ.js.map +1 -0
- package/dist/{chunk-TLX3H2CL.js → chunk-E5WLQSKA.js} +231 -40
- package/dist/chunk-E5WLQSKA.js.map +1 -0
- package/dist/chunk-ECLC4CIJ.js +1181 -0
- package/dist/chunk-ECLC4CIJ.js.map +1 -0
- package/dist/chunk-EEX6QNXV.js +127 -0
- package/dist/chunk-EEX6QNXV.js.map +1 -0
- package/dist/chunk-EFXVSQ5J.js +931 -0
- package/dist/chunk-EFXVSQ5J.js.map +1 -0
- package/dist/{chunk-RFJ6Q6LE.js → chunk-ENLB7NYV.js} +577 -164
- package/dist/chunk-ENLB7NYV.js.map +1 -0
- package/dist/{chunk-IME7R2UI.js → chunk-FPR7SKIE.js} +1268 -883
- package/dist/chunk-FPR7SKIE.js.map +1 -0
- package/dist/{chunk-VPNLCMVR.js → chunk-HFB74CLM.js} +13 -5
- package/dist/chunk-HFB74CLM.js.map +1 -0
- package/dist/{chunk-5RDRAO4B.js → chunk-HOZXKOE3.js} +37 -1
- package/dist/chunk-HOZXKOE3.js.map +1 -0
- package/dist/chunk-IDYWN37T.js +36 -0
- package/dist/chunk-IDYWN37T.js.map +1 -0
- package/dist/{chunk-YC6W4EJH.js → chunk-JGF5HLSI.js} +193 -75
- package/dist/chunk-JGF5HLSI.js.map +1 -0
- package/dist/{chunk-5YHTKWJN.js → chunk-KDNWMKXV.js} +2447 -907
- package/dist/chunk-KDNWMKXV.js.map +1 -0
- package/dist/{chunk-Y2VHN7TC.js → chunk-MEOB2DZA.js} +11 -1
- package/dist/chunk-MEOB2DZA.js.map +1 -0
- package/dist/{chunk-KBQS35OV.js → chunk-MV5PQNIA.js} +2 -2
- package/dist/chunk-N2G4Q7ME.js +2672 -0
- package/dist/chunk-N2G4Q7ME.js.map +1 -0
- package/dist/{chunk-62QL5QUP.js → chunk-OJBMDM5H.js} +17 -1
- package/dist/chunk-OJBMDM5H.js.map +1 -0
- package/dist/{chunk-56SIEMDX.js → chunk-PTDC7ZUP.js} +2 -2
- package/dist/{chunk-X4NJT436.js → chunk-REASC2QG.js} +67 -28
- package/dist/chunk-REASC2QG.js.map +1 -0
- package/dist/chunk-SBTU5BEC.js +114 -0
- package/dist/chunk-SBTU5BEC.js.map +1 -0
- package/dist/{chunk-HQI7NYGX.js → chunk-SWPDKLNM.js} +2 -2
- package/dist/{chunk-W3XFHEF4.js → chunk-UCFJ43OS.js} +140 -28
- package/dist/chunk-UCFJ43OS.js.map +1 -0
- package/dist/{chunk-QYBD22H5.js → chunk-W7SLYS3M.js} +80 -16
- package/dist/chunk-W7SLYS3M.js.map +1 -0
- package/dist/{chunk-SOW4WRQP.js → chunk-WV3O5PGX.js} +3 -3
- package/dist/{chunk-JTPOI3KU.js → chunk-XJRJVXJR.js} +262 -38
- package/dist/chunk-XJRJVXJR.js.map +1 -0
- package/dist/{chunk-224FJZLH.js → chunk-YIL6HTJX.js} +228 -5
- package/dist/chunk-YIL6HTJX.js.map +1 -0
- package/dist/{command-approvals-VBIU6BLM.js → command-approvals-ZRY66LCW.js} +5 -4
- package/dist/context-C3RAP6K5.js +41 -0
- package/dist/{hook-approvals-ZVT4V7IM.js → hook-approvals-DPQD5H65.js} +5 -4
- package/dist/index.js +657 -754
- package/dist/index.js.map +1 -1
- package/dist/{interactive-assets-T4I4SEHU.js → interactive-assets-73AQO5WP.js} +11 -6
- package/dist/{interactive-assets-T4I4SEHU.js.map → interactive-assets-73AQO5WP.js.map} +1 -1
- package/dist/job-runner.js +10 -3
- package/dist/job-runner.js.map +1 -1
- package/dist/job-supervisor.js +13 -4
- package/dist/job-supervisor.js.map +1 -1
- package/dist/loader-DQNPDKOX.js +27 -0
- package/dist/{mcp-approvals-HJ2VDYMC.js → mcp-approvals-27LJYADQ.js} +5 -4
- package/dist/{mcp-config-RNB5LEVE.js → mcp-config-GXSODNCM.js} +3 -2
- package/dist/memory-store-I6Z54VUN.js +51 -0
- package/dist/{model-window-store-MTSQ5JDJ.js → model-window-store-6VKXXTPJ.js} +4 -3
- package/dist/{openai-compatible-2OB54YST.js → openai-compatible-IPUNBJ53.js} +5 -3
- package/dist/{permission-approvals-YLV6UC5W.js → permission-approvals-Q5IMFEZI.js} +5 -4
- package/dist/{permissions-DHOKF3W2.js → permissions-7Y35X6HZ.js} +26 -9
- package/dist/provider-approvals-5AGH3RVT.js +76 -0
- package/dist/{sandbox-WRYTZH3D.js → sandbox-N2RY72GN.js} +6 -5
- package/dist/{scrollback-35ME2GFX.js → scrollback-GD76GNM4.js} +36 -28
- package/dist/scrollback-GD76GNM4.js.map +1 -0
- package/dist/sdk.d.ts +876 -64
- package/dist/sdk.js +57 -37
- package/dist/sdk.js.map +1 -1
- package/dist/settings-loader-KDBH45AQ.js +43 -0
- package/dist/{settings-removed-JWWPT4WA.js → settings-removed-3ATWJEF3.js} +2 -2
- package/dist/shell-selection-Z5WORZU4.js +31 -0
- package/dist/shell-selection-Z5WORZU4.js.map +1 -0
- package/package.json +5 -5
- package/dist/app-GE4OHJOC.js.map +0 -1
- package/dist/chunk-224FJZLH.js.map +0 -1
- package/dist/chunk-5RDRAO4B.js.map +0 -1
- package/dist/chunk-5YHTKWJN.js.map +0 -1
- package/dist/chunk-62QL5QUP.js.map +0 -1
- package/dist/chunk-67UZEWWF.js.map +0 -1
- package/dist/chunk-6OQQOMZR.js +0 -785
- package/dist/chunk-6OQQOMZR.js.map +0 -1
- package/dist/chunk-AQEQX4FF.js.map +0 -1
- package/dist/chunk-C7ADUNPR.js +0 -273
- package/dist/chunk-C7ADUNPR.js.map +0 -1
- package/dist/chunk-EFJ2NH6E.js.map +0 -1
- package/dist/chunk-IME7R2UI.js.map +0 -1
- package/dist/chunk-J62VZYOB.js +0 -1339
- package/dist/chunk-J62VZYOB.js.map +0 -1
- package/dist/chunk-JTPOI3KU.js.map +0 -1
- package/dist/chunk-QYBD22H5.js.map +0 -1
- package/dist/chunk-RFJ6Q6LE.js.map +0 -1
- package/dist/chunk-S4JMID4G.js +0 -259
- package/dist/chunk-S4JMID4G.js.map +0 -1
- package/dist/chunk-TLX3H2CL.js.map +0 -1
- package/dist/chunk-VPNLCMVR.js.map +0 -1
- package/dist/chunk-W3XFHEF4.js.map +0 -1
- package/dist/chunk-X4NJT436.js.map +0 -1
- package/dist/chunk-X66I2NQO.js +0 -137
- package/dist/chunk-X66I2NQO.js.map +0 -1
- package/dist/chunk-Y2VHN7TC.js.map +0 -1
- package/dist/chunk-YC6W4EJH.js.map +0 -1
- package/dist/context-CBOBDY5Q.js +0 -38
- package/dist/loader-S77OVTHH.js +0 -18
- package/dist/memory-store-DZUT5HUH.js +0 -75
- package/dist/scrollback-35ME2GFX.js.map +0 -1
- package/dist/settings-loader-JUNPGAAM.js +0 -35
- package/dist/shell-selection-CDHGJ4GC.js +0 -17
- /package/dist/{additional-roots-H7UNAEHS.js.map → additional-roots-VAWRQ625.js.map} +0 -0
- /package/dist/{chunk-525CAZPY.js.map → chunk-4DKHLZRI.js.map} +0 -0
- /package/dist/{chunk-4AS7LKKQ.js.map → chunk-62EEAUID.js.map} +0 -0
- /package/dist/{chunk-KBQS35OV.js.map → chunk-MV5PQNIA.js.map} +0 -0
- /package/dist/{chunk-56SIEMDX.js.map → chunk-PTDC7ZUP.js.map} +0 -0
- /package/dist/{chunk-HQI7NYGX.js.map → chunk-SWPDKLNM.js.map} +0 -0
- /package/dist/{chunk-SOW4WRQP.js.map → chunk-WV3O5PGX.js.map} +0 -0
- /package/dist/{command-approvals-VBIU6BLM.js.map → command-approvals-ZRY66LCW.js.map} +0 -0
- /package/dist/{context-CBOBDY5Q.js.map → context-C3RAP6K5.js.map} +0 -0
- /package/dist/{hook-approvals-ZVT4V7IM.js.map → hook-approvals-DPQD5H65.js.map} +0 -0
- /package/dist/{loader-S77OVTHH.js.map → loader-DQNPDKOX.js.map} +0 -0
- /package/dist/{mcp-approvals-HJ2VDYMC.js.map → mcp-approvals-27LJYADQ.js.map} +0 -0
- /package/dist/{mcp-config-RNB5LEVE.js.map → mcp-config-GXSODNCM.js.map} +0 -0
- /package/dist/{memory-store-DZUT5HUH.js.map → memory-store-I6Z54VUN.js.map} +0 -0
- /package/dist/{model-window-store-MTSQ5JDJ.js.map → model-window-store-6VKXXTPJ.js.map} +0 -0
- /package/dist/{openai-compatible-2OB54YST.js.map → openai-compatible-IPUNBJ53.js.map} +0 -0
- /package/dist/{permission-approvals-YLV6UC5W.js.map → permission-approvals-Q5IMFEZI.js.map} +0 -0
- /package/dist/{permissions-DHOKF3W2.js.map → permissions-7Y35X6HZ.js.map} +0 -0
- /package/dist/{sandbox-WRYTZH3D.js.map → provider-approvals-5AGH3RVT.js.map} +0 -0
- /package/dist/{settings-loader-JUNPGAAM.js.map → sandbox-N2RY72GN.js.map} +0 -0
- /package/dist/{settings-removed-JWWPT4WA.js.map → settings-loader-KDBH45AQ.js.map} +0 -0
- /package/dist/{shell-selection-CDHGJ4GC.js.map → settings-removed-3ATWJEF3.js.map} +0 -0
package/dist/sdk.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
|
+
cleanupRunStatus,
|
|
3
|
+
collectSkippedProjectFileNotices,
|
|
2
4
|
collectWithheldProjectNotices,
|
|
3
5
|
connectMcpServers,
|
|
4
6
|
disconnectMcpServers,
|
|
5
7
|
runHeadless
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-E5WLQSKA.js";
|
|
7
9
|
import {
|
|
8
10
|
mcpServersToRecord,
|
|
9
11
|
partitionMcpServersByApproval
|
|
10
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PTDC7ZUP.js";
|
|
11
13
|
import {
|
|
12
14
|
SessionStore,
|
|
13
15
|
createAgentSessionSnapshot,
|
|
16
|
+
discardUntouchedSession,
|
|
14
17
|
reduceAgentSessionSnapshot,
|
|
15
18
|
resolveSessionBootstrap,
|
|
16
19
|
resolveSessionDriver
|
|
17
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-ENLB7NYV.js";
|
|
18
21
|
import {
|
|
19
22
|
AgentManager,
|
|
20
23
|
SessionRuntime,
|
|
@@ -23,17 +26,17 @@ import {
|
|
|
23
26
|
createDefaultRegistry,
|
|
24
27
|
createRegistry,
|
|
25
28
|
createToolSurface
|
|
26
|
-
} from "./chunk-
|
|
27
|
-
import {
|
|
28
|
-
resolveMcpServerList
|
|
29
|
-
} from "./chunk-Y2VHN7TC.js";
|
|
29
|
+
} from "./chunk-KDNWMKXV.js";
|
|
30
30
|
import {
|
|
31
31
|
buildSkillReport,
|
|
32
|
-
freezeAgentConfig,
|
|
33
|
-
loadConfig,
|
|
34
32
|
resolvePermissionMode
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import
|
|
33
|
+
} from "./chunk-FPR7SKIE.js";
|
|
34
|
+
import {
|
|
35
|
+
freezeAgentConfig,
|
|
36
|
+
loadConfig
|
|
37
|
+
} from "./chunk-N2G4Q7ME.js";
|
|
38
|
+
import "./chunk-XJRJVXJR.js";
|
|
39
|
+
import "./chunk-AHC7OU75.js";
|
|
37
40
|
import {
|
|
38
41
|
applySkillOverrides,
|
|
39
42
|
buildSkillListing,
|
|
@@ -42,40 +45,44 @@ import {
|
|
|
42
45
|
generateSkillListing,
|
|
43
46
|
loadSkillBody,
|
|
44
47
|
skillRoots
|
|
45
|
-
} from "./chunk-
|
|
46
|
-
import "./chunk-
|
|
47
|
-
import "./chunk-
|
|
48
|
-
import "./chunk-
|
|
49
|
-
import "./chunk-
|
|
50
|
-
import "./chunk-
|
|
51
|
-
import "./chunk-QYBD22H5.js";
|
|
52
|
-
import "./chunk-EFJ2NH6E.js";
|
|
48
|
+
} from "./chunk-DNFQTSMJ.js";
|
|
49
|
+
import "./chunk-UCFJ43OS.js";
|
|
50
|
+
import "./chunk-HOZXKOE3.js";
|
|
51
|
+
import "./chunk-EFXVSQ5J.js";
|
|
52
|
+
import "./chunk-62EEAUID.js";
|
|
53
|
+
import "./chunk-AJZWLKLQ.js";
|
|
53
54
|
import "./chunk-KXAYUIKP.js";
|
|
54
|
-
import "./chunk-
|
|
55
|
+
import "./chunk-SWPDKLNM.js";
|
|
55
56
|
import "./chunk-2AAOF5B5.js";
|
|
56
|
-
import
|
|
57
|
-
|
|
57
|
+
import {
|
|
58
|
+
resolveMcpServerList
|
|
59
|
+
} from "./chunk-MEOB2DZA.js";
|
|
60
|
+
import "./chunk-W7SLYS3M.js";
|
|
61
|
+
import "./chunk-JGF5HLSI.js";
|
|
62
|
+
import "./chunk-32WBCUAN.js";
|
|
58
63
|
import "./chunk-RT5SATF7.js";
|
|
59
64
|
import "./chunk-XHAO3K7I.js";
|
|
60
|
-
import "./chunk-
|
|
61
|
-
import "./chunk-
|
|
65
|
+
import "./chunk-SBTU5BEC.js";
|
|
66
|
+
import "./chunk-4DKHLZRI.js";
|
|
62
67
|
import {
|
|
63
68
|
DEFAULT_LOCAL_DATA_RETENTION_DAYS,
|
|
64
69
|
cleanupDebugLogs,
|
|
65
70
|
getDebugLogPath
|
|
66
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-OJBMDM5H.js";
|
|
67
72
|
import {
|
|
68
73
|
toolFailure,
|
|
69
74
|
toolSuccess
|
|
70
|
-
} from "./chunk-
|
|
71
|
-
import "./chunk-
|
|
72
|
-
import "./chunk-
|
|
73
|
-
import "./chunk-
|
|
74
|
-
import "./chunk-
|
|
75
|
+
} from "./chunk-YIL6HTJX.js";
|
|
76
|
+
import "./chunk-EEX6QNXV.js";
|
|
77
|
+
import "./chunk-MV5PQNIA.js";
|
|
78
|
+
import "./chunk-B5FC3MYZ.js";
|
|
79
|
+
import "./chunk-WV3O5PGX.js";
|
|
80
|
+
import "./chunk-HFB74CLM.js";
|
|
81
|
+
import "./chunk-REASC2QG.js";
|
|
82
|
+
import "./chunk-IDYWN37T.js";
|
|
75
83
|
import {
|
|
76
84
|
resolveBookHome
|
|
77
85
|
} from "./chunk-ZPSZZUWF.js";
|
|
78
|
-
import "./chunk-5RDRAO4B.js";
|
|
79
86
|
|
|
80
87
|
// src/sdk.ts
|
|
81
88
|
import { join } from "path";
|
|
@@ -548,17 +555,24 @@ async function* query(prompt, options = {}) {
|
|
|
548
555
|
cleanupDebugLogs(DEFAULT_LOCAL_DATA_RETENTION_DAYS, getDebugLogPath());
|
|
549
556
|
sessionStore.cleanup(DEFAULT_LOCAL_DATA_RETENTION_DAYS, /* @__PURE__ */ new Set([bootstrap.sessionId]));
|
|
550
557
|
}
|
|
558
|
+
cleanupRunStatus(DEFAULT_LOCAL_DATA_RETENTION_DAYS);
|
|
551
559
|
const queue = new AsyncEventQueue();
|
|
552
560
|
let connections = [];
|
|
553
561
|
queue.push({ type: "system", model: config.model, cwd: config.workspace });
|
|
554
562
|
queue.push({ type: "session", sessionId: bootstrap.sessionId });
|
|
555
563
|
const running = (async () => {
|
|
556
564
|
try {
|
|
557
|
-
for (const notice of
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
565
|
+
for (const notice of [
|
|
566
|
+
...collectWithheldProjectNotices({
|
|
567
|
+
workspace: config.workspace,
|
|
568
|
+
settings: config.settings,
|
|
569
|
+
settingsEnabled: !options.noSettings,
|
|
570
|
+
providerGate: config.workspaceProviderGate
|
|
571
|
+
}),
|
|
572
|
+
// Instruction files, REVIEW.md and command files that link out of the repository are not
|
|
573
|
+
// loaded (#539, #543).
|
|
574
|
+
...collectSkippedProjectFileNotices(config.workspace)
|
|
575
|
+
]) {
|
|
562
576
|
console.warn(notice);
|
|
563
577
|
}
|
|
564
578
|
const declaredMcpServers = resolveMcpServerList(config.workspace);
|
|
@@ -586,6 +600,8 @@ async function* query(prompt, options = {}) {
|
|
|
586
600
|
history: bootstrap.history,
|
|
587
601
|
transcript: bootstrap.transcript,
|
|
588
602
|
compactBoundaries: bootstrap.compactBoundaries,
|
|
603
|
+
// A resumed session's unmet `/goal` keeps being checked, and `/goal clear` can see it.
|
|
604
|
+
goal: bootstrap.goal,
|
|
589
605
|
mode: resolvePermissionMode(config.settings, options.permissionMode),
|
|
590
606
|
maxTurns: options.maxTurns,
|
|
591
607
|
persistSession,
|
|
@@ -637,7 +653,11 @@ async function* query(prompt, options = {}) {
|
|
|
637
653
|
} finally {
|
|
638
654
|
controller.abort(new Error("SDK event consumer stopped"));
|
|
639
655
|
options.signal?.removeEventListener("abort", abortFromCaller);
|
|
640
|
-
|
|
656
|
+
try {
|
|
657
|
+
await running;
|
|
658
|
+
} finally {
|
|
659
|
+
discardUntouchedSession(sessionStore, bootstrap);
|
|
660
|
+
}
|
|
641
661
|
}
|
|
642
662
|
}
|
|
643
663
|
function createAgentManager(config) {
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk.ts","../src/skill-evaluation.ts","../src/agents/evaluation.ts"],"sourcesContent":["/** Book Agent SDK — programmatic API for embedding Book as a library. */\n\nimport { join } from 'path';\nimport type { ElicitationHandler, UserQuestionHandler } from './types/tools.js';\nimport type { AgentConfig, SessionDriver } from './types/runtime.js';\nimport type { SessionStoreInterface } from './types/sessions.js';\nimport { freezeAgentConfig, loadConfig, type LoadConfigOptions } from './config.js';\nimport { runHeadless } from './headless.js';\nimport { createDefaultRegistry } from './tools/registry.js';\nimport { connectMcpServers, disconnectMcpServers } from './mcp.js';\nimport { mcpServersToRecord, partitionMcpServersByApproval } from './mcp-approvals.js';\nimport { resolveMcpServerList } from './mcp-config.js';\nimport { collectWithheldProjectNotices } from './project-approval-notices.js';\nimport { AgentManager } from './agents/manager.js';\nimport { SessionStore } from './session/store.js';\nimport { resolveSessionBootstrap } from './session/resolve.js';\nimport type { AgentEvent } from './session/agent-events.js';\nimport {\n cleanupDebugLogs,\n DEFAULT_LOCAL_DATA_RETENTION_DAYS,\n getDebugLogPath,\n} from './debug-log.js';\nimport { resolvePermissionMode } from './permission-mode.js';\nimport { resolveBookHome } from './book-home.js';\nimport { resolveSessionDriver } from './session-driver.js';\n\nexport type QueryEvent = AgentEvent;\n\nexport interface QueryOptions {\n workspace?: string;\n model?: string;\n permissionMode?: string;\n maxTurns?: number;\n settingsPath?: string;\n noSettings?: boolean;\n persistSession?: boolean;\n sessionId?: string;\n sessionStore?: SessionStoreInterface;\n signal?: AbortSignal;\n onUserQuestionRequired?: UserQuestionHandler;\n /**\n * Answer MCP form elicitations. Supplying it declares the elicitation\n * capability to connected servers; without it they fail such requests\n * themselves rather than blocking on a prompt no one can see.\n */\n onElicit?: ElicitationHandler;\n agents?: 'adaptive' | 'manual' | 'off';\n /** Forward high-volume managed-agent text deltas. Defaults to false. */\n forwardSubagentText?: boolean;\n /**\n * Who drives the session. Defaults to `BOOK_SESSION_DRIVER`, then to `agent` under another agent\n * harness and `human` otherwise; an agent-driven session saves only what it learned, as\n * project or reference memory, never its delegator's instructions.\n */\n sessionDriver?: SessionDriver;\n}\n\nclass AsyncEventQueue<T> {\n private values: T[] = [];\n private waiters: Array<(value: T | undefined) => void> = [];\n private closed = false;\n\n push(value: T): void {\n if (this.closed) return;\n const waiter = this.waiters.shift();\n if (waiter) waiter(value);\n else this.values.push(value);\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n for (const waiter of this.waiters.splice(0)) waiter(undefined);\n }\n\n next(): Promise<T | undefined> {\n const value = this.values.shift();\n if (value !== undefined) return Promise.resolve(value);\n if (this.closed) return Promise.resolve(undefined);\n return new Promise((resolve) => this.waiters.push(resolve));\n }\n}\n\nexport async function* query(\n prompt: string,\n options: QueryOptions = {},\n): AsyncGenerator<QueryEvent, void, undefined> {\n const workspace = options.workspace || process.cwd();\n const loadedConfig = loadConfig(workspace, {\n settingsOverridePath: options.settingsPath,\n noSettings: options.noSettings,\n runMigrations: !options.noSettings,\n });\n const config = freezeAgentConfig({\n ...loadedConfig,\n sessionDriver: resolveSessionDriver({ explicit: options.sessionDriver, env: process.env })\n .driver,\n ...(options.model ? { model: options.model } : {}),\n ...(options.maxTurns ? { maxTurns: options.maxTurns } : {}),\n ...(options.agents\n ? {\n settings: {\n ...loadedConfig.settings,\n agents: { ...loadedConfig.settings.agents, mode: options.agents },\n },\n }\n : {}),\n });\n\n const controller = new AbortController();\n const abortFromCaller = () => controller.abort(options.signal?.reason);\n if (options.signal?.aborted) abortFromCaller();\n else options.signal?.addEventListener('abort', abortFromCaller, { once: true });\n\n const persistSession = options.persistSession !== false;\n const sessionStore = persistSession\n ? (options.sessionStore ?? new SessionStore(join(resolveBookHome(), 'sessions')))\n : undefined;\n const bootstrap = resolveSessionBootstrap(sessionStore, {\n cwd: config.workspace,\n sessionId: options.sessionId,\n driver: config.sessionDriver,\n });\n if (persistSession && !options.sessionStore && sessionStore) {\n cleanupDebugLogs(DEFAULT_LOCAL_DATA_RETENTION_DAYS, getDebugLogPath());\n sessionStore.cleanup(DEFAULT_LOCAL_DATA_RETENTION_DAYS, new Set([bootstrap.sessionId]));\n }\n const queue = new AsyncEventQueue<QueryEvent>();\n let connections: Awaited<ReturnType<typeof connectMcpServers>>['connections'] = [];\n\n queue.push({ type: 'system', model: config.model, cwd: config.workspace });\n queue.push({ type: 'session', sessionId: bootstrap.sessionId });\n\n const running = (async () => {\n try {\n // Project-declared MCP servers require a prior interactive approval;\n // SDK runs cannot prompt, so unapproved servers are skipped with a warning.\n // Repository-declared allow rules and hooks are withheld until the user\n // decides on them; an SDK run cannot ask, so it reports and continues.\n for (const notice of collectWithheldProjectNotices({\n workspace: config.workspace,\n settings: config.settings,\n settingsEnabled: !options.noSettings,\n })) {\n console.warn(notice);\n }\n const declaredMcpServers = resolveMcpServerList(config.workspace);\n const mcpPartition = partitionMcpServersByApproval(declaredMcpServers, config.settings);\n for (const server of mcpPartition.pending) {\n console.warn(\n `⚠ Skipping MCP server \"${server.name}\" (${server.path}): project-declared servers require one-time approval. Approve it in an interactive session first.`,\n );\n }\n const mcp = await connectMcpServers(config.workspace, {\n signal: controller.signal,\n servers: mcpServersToRecord(mcpPartition.allowed),\n onElicit: options.onElicit,\n });\n connections = mcp.connections;\n const registry = createDefaultRegistry({ agents: config.settings.agents.mode !== 'off' });\n if (mcp.tools.length > 0) registry.registerAll(mcp.tools);\n\n const result = await runHeadless(config, registry, {\n prompt,\n inputFormat: 'text',\n outputFormat: 'text',\n // Progress lines are for a person watching `book -p` in a terminal. An\n // SDK host owns its stderr and receives every tool call as an event.\n quiet: true,\n history: bootstrap.history,\n transcript: bootstrap.transcript,\n compactBoundaries: bootstrap.compactBoundaries,\n mode: resolvePermissionMode(config.settings, options.permissionMode),\n maxTurns: options.maxTurns,\n persistSession,\n sessionStore,\n sessionId: bootstrap.sessionId,\n sessionCreated: bootstrap.created,\n runSource: 'sdk',\n signal: controller.signal,\n onUserQuestionRequired: options.onUserQuestionRequired,\n forwardSubagentText: options.forwardSubagentText,\n stdout: { write: () => true },\n onAgentEvent: (event) => {\n if (\n event.type !== 'system' &&\n event.type !== 'session' &&\n event.type !== 'result' &&\n event.type !== 'done' &&\n (event.type !== 'agent_text_delta' || options.forwardSubagentText === true)\n ) {\n queue.push(event);\n }\n },\n });\n queue.push({\n type: 'result',\n messages: result.messages,\n usage: result.usage,\n sessionId: bootstrap.sessionId,\n outcome: result.outcome,\n runs: result.runs,\n // `stdout` above is a discard sink, so this is the only way an SDK\n // caller sees a slash command the host performed on its behalf.\n commandResults: result.commandResults,\n answer: result.answer,\n });\n } catch (error) {\n if (!controller.signal.aborted) {\n queue.push({\n type: 'error',\n error: error instanceof Error ? error.message : String(error),\n });\n }\n } finally {\n await disconnectMcpServers(connections);\n queue.push({ type: 'done' });\n queue.close();\n }\n })();\n\n try {\n while (true) {\n const event = await queue.next();\n if (!event) break;\n yield event;\n }\n } finally {\n controller.abort(new Error('SDK event consumer stopped'));\n options.signal?.removeEventListener('abort', abortFromCaller);\n await running;\n }\n}\n\nexport { loadConfig, type LoadConfigOptions };\nexport type { ToolDiscoverySettings } from './settings.js';\nexport { AgentManager };\nexport { createDefaultRegistry, createRegistry } from './tools/registry.js';\nexport { createToolSurface } from './tools/catalog.js';\nexport { toolFailure, toolSuccess } from './tools/result.js';\nexport {\n applySkillOverrides,\n buildSkillListing,\n discoverSkills,\n explicitSkillMentions,\n generateSkillListing,\n loadSkillBody,\n skillRoots,\n} from './skills.js';\nexport type {\n DiscoverSkillsOptions,\n LoadedSkillBody,\n ShadowedSkill,\n Skill,\n SkillIssue,\n SkillListingResult,\n SkillResource,\n SkillRoot,\n SkillRootKind,\n SkillSource,\n} from './skills.js';\nexport {\n SkillRegistry,\n SkillRegistryError,\n type SkillActivationFrame,\n type SkillActivationFrameSummary,\n type SkillActivationReason,\n type SkillLifecycleEvent,\n type SkillLifecycleEventType,\n type SkillRegistrySnapshot,\n} from './skill-registry.js';\nexport {\n DEFAULT_SKILL_EVALUATION_THRESHOLDS,\n DEFAULT_SKILL_EVALUATION_FIXTURES,\n SKILL_EVALUATION_CATEGORIES,\n evaluateSkillActivation,\n observeSkillEvaluation,\n renderSkillEvaluationReport,\n runSkillActivationEvaluation,\n writeSkillEvaluationReport,\n} from './skill-evaluation.js';\nexport type {\n SkillEvaluationCategory,\n SkillEvaluationFixture,\n SkillEvaluationObservation,\n SkillEvaluationOutcome,\n SkillEvaluationPromptFixture,\n SkillEvaluationReport,\n SkillEvaluationThresholds,\n} from './skill-evaluation.js';\nexport { SessionRuntime } from './session/runtime.js';\nexport { buildSkillReport } from './skill-report.js';\nexport function createAgentManager(config: AgentConfig): AgentManager {\n return new AgentManager(config, createDefaultRegistry({ agents: true }).getDefinitions());\n}\nexport { runPairedEvaluation, evaluateSuccess } from './agents/evaluation.js';\nexport { createAgentSessionSnapshot, reduceAgentSessionSnapshot } from './session/agent-events.js';\nexport type {\n AgentEvent,\n AgentSessionSnapshot,\n AgentSessionStatus,\n} from './session/agent-events.js';\nexport type {\n EvaluationFixture,\n EvaluationMetric,\n EvaluationRunResult,\n} from './agents/evaluation.js';\nexport type {\n AgentPlanRecord,\n AgentApplyResult,\n AgentRecord,\n AgentSummary,\n AgentCompletion,\n AgentCompletionNotification,\n AgentProfile,\n AgentActivity,\n AgentRuntimeEvent,\n AgentRunMetrics,\n AgentSnapshot,\n AgentSpawnRequest,\n EvidenceItem,\n} from './agents/types.js';\nexport type {\n AgentTerminalOutcome,\n AgentTerminalReason,\n AgentTerminalStatus,\n} from './types/terminal.js';\nexport type {\n AgentModelIdentity,\n AgentModelIdentityStatus,\n AgentRunAmbientSnapshot,\n AgentRunAccounting,\n AgentRunContext,\n AgentRunResult,\n AgentRunSource,\n} from './types/runs.js';\nexport type {\n JsonSchemaObject,\n ToolCatalogMetadata,\n ToolCategory,\n ToolDefinition,\n ToolDiscoveryContext,\n ToolEffect,\n ToolPolicy,\n ToolResult,\n ToolResultArtifacts,\n ToolResultError,\n ToolResultPresentation,\n ToolResultStatus,\n ToolSearchMatch,\n UserQuestion,\n UserQuestionOption,\n UserQuestionRequest,\n UserQuestionResponse,\n UserQuestionSource,\n UserQuestionHandler,\n ElicitationField,\n ElicitationRequest,\n ElicitationResponse,\n ElicitationValue,\n ElicitationHandler,\n} from './types/tools.js';\n","import { createHash } from 'node:crypto';\nimport { mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type { SkillLifecycleEvent } from './skill-registry.js';\n\nexport const SKILL_EVALUATION_CATEGORIES = [\n 'direct',\n 'indirect',\n 'negative',\n 'ambiguous',\n 'conflicting',\n 'disabled',\n 'invalid',\n 'missing-body',\n 'missing-resource',\n] as const;\n\nexport type SkillEvaluationCategory = (typeof SKILL_EVALUATION_CATEGORIES)[number];\n\nexport interface SkillEvaluationFixture {\n id: string;\n category: SkillEvaluationCategory;\n promptHash: string;\n expectedSkills: string[];\n expectedBlockedCodes?: string[];\n}\n\nexport interface SkillEvaluationPromptFixture {\n id: string;\n category: SkillEvaluationCategory;\n prompt: string;\n expectedSkills: string[];\n expectedBlockedCodes?: string[];\n}\n\nexport interface SkillEvaluationOutcome {\n promptChars?: number;\n promptTokens?: number;\n bodyTokens?: number;\n taskCompleted?: boolean;\n userCorrections?: number;\n skillToolFailures?: number;\n exposure?: 'eager' | 'deferred';\n activationTurns?: number;\n}\n\nexport interface SkillEvaluationObservation extends SkillEvaluationFixture {\n activatedSkills: string[];\n blockedCodes: string[];\n promptChars: number;\n promptTokens: number;\n bodyBytes: number;\n bodyTokens: number;\n falseActivationBytes: number;\n activationLatencyMs: number[];\n consentRequests: number;\n unnecessaryPermissionPrompts: number;\n taskCompleted?: boolean;\n userCorrections: number;\n skillToolFailures: number;\n blockingMismatch: boolean;\n exposure?: 'eager' | 'deferred';\n activationTurns?: number;\n}\n\nexport interface SkillEvaluationThresholds {\n minimumPrecision: number;\n minimumRecall: number;\n maximumFalseActivations: number;\n maximumUnnecessaryPermissionPrompts: number;\n maximumSkillToolFailures: number;\n}\n\nexport interface SkillEvaluationExecution {\n evidenceKind: 'offline-observation';\n providerRunEligibility: 'not-applicable';\n controls: {\n evaluationDate: string;\n randomSeed: string;\n runtimeRevision: string;\n fixtureRevision: string;\n fixtureRevisionStatus: 'captured' | 'incomplete';\n };\n}\n\nexport interface SkillEvaluationReport {\n generatedAt: string;\n fixtureCount: number;\n categoryCounts: Record<SkillEvaluationCategory, number>;\n truePositives: number;\n falsePositives: number;\n falseNegatives: number;\n precision: number;\n recall: number;\n falseActivationBytes: number;\n promptChars: { total: number; median: number };\n promptTokens: { total: number; median: number };\n bodyBytes: { total: number; median: number };\n bodyTokens: { total: number; median: number };\n activationLatencyMs: { median: number; p95: number };\n consentRequests: number;\n unnecessaryPermissionPrompts: number;\n taskCompletionRate?: number;\n userCorrections: number;\n skillToolFailures: number;\n blockingMismatches: number;\n exposure: Record<\n 'eager' | 'deferred',\n { samples: number; activationRate: number; medianActivationTurns: number }\n >;\n thresholds: SkillEvaluationThresholds;\n rolloutReady: boolean;\n reasons: string[];\n observations: SkillEvaluationObservation[];\n evaluation?: SkillEvaluationExecution;\n}\n\nexport const DEFAULT_SKILL_EVALUATION_THRESHOLDS: SkillEvaluationThresholds = {\n minimumPrecision: 0.95,\n minimumRecall: 0.8,\n maximumFalseActivations: 0,\n maximumUnnecessaryPermissionPrompts: 0,\n maximumSkillToolFailures: 0,\n};\n\nexport const DEFAULT_SKILL_EVALUATION_FIXTURES: readonly SkillEvaluationPromptFixture[] = [\n {\n id: 'direct-review',\n category: 'direct',\n prompt: '$review inspect the current change',\n expectedSkills: ['review'],\n },\n {\n id: 'indirect-review',\n category: 'indirect',\n prompt: 'Inspect this diff for correctness regressions and missing tests',\n expectedSkills: ['review'],\n },\n {\n id: 'negative-general-question',\n category: 'negative',\n prompt: 'Explain what this function returns',\n expectedSkills: [],\n },\n {\n id: 'ambiguous-review-word',\n category: 'ambiguous',\n prompt: 'Review the available deployment choices with me',\n expectedSkills: [],\n },\n {\n id: 'conflicting-tool-ceilings',\n category: 'conflicting',\n prompt: '$read-review $write-review inspect the change',\n expectedSkills: ['read-review'],\n expectedBlockedCodes: ['skill_tool_intersection_empty'],\n },\n {\n id: 'disabled-skill',\n category: 'disabled',\n prompt: '$disabled-skill run the workflow',\n expectedSkills: [],\n expectedBlockedCodes: ['skill_disabled'],\n },\n {\n id: 'invalid-skill',\n category: 'invalid',\n prompt: '$invalid-skill run the workflow',\n expectedSkills: [],\n expectedBlockedCodes: ['skill_invalid'],\n },\n {\n id: 'missing-body',\n category: 'missing-body',\n prompt: '$missing-body run the workflow',\n expectedSkills: [],\n expectedBlockedCodes: ['skill_load_failed'],\n },\n {\n id: 'missing-resource',\n category: 'missing-resource',\n prompt: '$missing-resource load references/checklist.md',\n expectedSkills: ['missing-resource'],\n expectedBlockedCodes: ['skill_resource_unreadable'],\n },\n];\n\nfunction numberDetail(event: SkillLifecycleEvent, key: string): number {\n const value = event.details?.[key];\n return typeof value === 'number' && Number.isFinite(value) ? value : 0;\n}\n\nfunction median(values: readonly number[]): number {\n if (values.length === 0) return 0;\n const sorted = [...values].sort((left, right) => left - right);\n return sorted[Math.floor(sorted.length / 2)] ?? 0;\n}\n\nfunction percentile(values: readonly number[], fraction: number): number {\n if (values.length === 0) return 0;\n const sorted = [...values].sort((left, right) => left - right);\n const index = Math.min(sorted.length - 1, Math.ceil(sorted.length * fraction) - 1);\n return sorted[index] ?? 0;\n}\n\n/** Convert bounded lifecycle evidence into one prompt-free evaluation observation. */\nexport function observeSkillEvaluation(\n fixture: SkillEvaluationFixture,\n events: readonly SkillLifecycleEvent[],\n outcome: SkillEvaluationOutcome = {},\n): SkillEvaluationObservation {\n const applied = events.filter(\n (event) => event.type === 'skill_activation_applied' && event.skill,\n );\n const activatedSkills = [...new Set(applied.map((event) => event.skill!))];\n const expected = new Set(fixture.expectedSkills);\n const falseActivations = applied.filter((event) => event.skill && !expected.has(event.skill));\n const consentEvents = events.filter((event) => event.type === 'skill_consent_requested');\n const blockedCodes = events\n .filter(\n (event) =>\n event.type === 'skill_activation_blocked' || event.type === 'skill_resource_blocked',\n )\n .map((event) => event.details?.code)\n .filter((code): code is string => typeof code === 'string');\n const expectedBlockedCodes = fixture.expectedBlockedCodes ?? [];\n const promptChars = outcome.promptChars ?? 0;\n const bodyBytes = applied.reduce(\n (total, event) => total + numberDetail(event, 'bodyByteSize'),\n 0,\n );\n return {\n ...fixture,\n expectedSkills: [...fixture.expectedSkills],\n activatedSkills,\n expectedBlockedCodes: [...expectedBlockedCodes],\n blockedCodes,\n promptChars,\n promptTokens: outcome.promptTokens ?? Math.ceil(promptChars / 4),\n bodyBytes,\n bodyTokens: outcome.bodyTokens ?? Math.ceil(bodyBytes / 4),\n falseActivationBytes: falseActivations.reduce(\n (total, event) => total + numberDetail(event, 'bodyByteSize'),\n 0,\n ),\n activationLatencyMs: applied.map((event) => numberDetail(event, 'activationLatencyMs')),\n consentRequests: consentEvents.length,\n unnecessaryPermissionPrompts: consentEvents.filter(\n (event) => !event.skill || !expected.has(event.skill),\n ).length,\n taskCompleted: outcome.taskCompleted,\n userCorrections: outcome.userCorrections ?? 0,\n skillToolFailures: outcome.skillToolFailures ?? 0,\n blockingMismatch:\n expectedBlockedCodes.some((code) => !blockedCodes.includes(code)) ||\n blockedCodes.some((code) => !expectedBlockedCodes.includes(code)),\n exposure: outcome.exposure,\n activationTurns: outcome.activationTurns,\n };\n}\n\nexport function evaluateSkillActivation(\n observations: readonly SkillEvaluationObservation[],\n thresholds: SkillEvaluationThresholds = DEFAULT_SKILL_EVALUATION_THRESHOLDS,\n): SkillEvaluationReport {\n const categoryCounts = Object.fromEntries(\n SKILL_EVALUATION_CATEGORIES.map((category) => [\n category,\n observations.filter((observation) => observation.category === category).length,\n ]),\n ) as Record<SkillEvaluationCategory, number>;\n let truePositives = 0;\n let falsePositives = 0;\n let falseNegatives = 0;\n for (const observation of observations) {\n const expected = new Set(observation.expectedSkills);\n const activated = new Set(observation.activatedSkills);\n truePositives += [...activated].filter((skill) => expected.has(skill)).length;\n falsePositives += [...activated].filter((skill) => !expected.has(skill)).length;\n falseNegatives += [...expected].filter((skill) => !activated.has(skill)).length;\n }\n const precision =\n truePositives + falsePositives === 0 ? 1 : truePositives / (truePositives + falsePositives);\n const recall =\n truePositives + falseNegatives === 0 ? 1 : truePositives / (truePositives + falseNegatives);\n const completed = observations.filter(\n (observation): observation is SkillEvaluationObservation & { taskCompleted: boolean } =>\n observation.taskCompleted !== undefined,\n );\n const exposure = Object.fromEntries(\n (['eager', 'deferred'] as const).map((mode) => {\n const samples = observations.filter((observation) => observation.exposure === mode);\n return [\n mode,\n {\n samples: samples.length,\n activationRate:\n samples.length === 0\n ? 0\n : samples.filter((observation) => observation.activatedSkills.length > 0).length /\n samples.length,\n medianActivationTurns: median(\n samples.map((observation) => observation.activationTurns ?? 0),\n ),\n },\n ];\n }),\n ) as SkillEvaluationReport['exposure'];\n const reasons: string[] = [];\n const missingCategories = SKILL_EVALUATION_CATEGORIES.filter(\n (category) => categoryCounts[category] === 0,\n );\n if (missingCategories.length)\n reasons.push(`Missing fixture categories: ${missingCategories.join(', ')}.`);\n if (precision < thresholds.minimumPrecision) {\n reasons.push(\n `Activation precision ${precision.toFixed(3)} is below ${thresholds.minimumPrecision}.`,\n );\n }\n if (recall < thresholds.minimumRecall) {\n reasons.push(`Activation recall ${recall.toFixed(3)} is below ${thresholds.minimumRecall}.`);\n }\n if (falsePositives > thresholds.maximumFalseActivations) {\n reasons.push(\n `False activations ${falsePositives} exceed ${thresholds.maximumFalseActivations}.`,\n );\n }\n const unnecessaryPermissionPrompts = observations.reduce(\n (total, observation) => total + observation.unnecessaryPermissionPrompts,\n 0,\n );\n if (unnecessaryPermissionPrompts > thresholds.maximumUnnecessaryPermissionPrompts) {\n reasons.push(\n `Unnecessary permission prompts ${unnecessaryPermissionPrompts} exceed ${thresholds.maximumUnnecessaryPermissionPrompts}.`,\n );\n }\n const skillToolFailures = observations.reduce(\n (total, observation) => total + observation.skillToolFailures,\n 0,\n );\n if (skillToolFailures > thresholds.maximumSkillToolFailures) {\n reasons.push(\n `Skill-caused tool failures ${skillToolFailures} exceed ${thresholds.maximumSkillToolFailures}.`,\n );\n }\n const blockingMismatches = observations.filter(\n (observation) => observation.blockingMismatch,\n ).length;\n if (blockingMismatches > 0) {\n reasons.push(`${blockingMismatches} fixture(s) had unexpected or missing block outcomes.`);\n }\n const latencies = observations.flatMap((observation) => observation.activationLatencyMs);\n return {\n generatedAt: new Date().toISOString(),\n fixtureCount: observations.length,\n categoryCounts,\n truePositives,\n falsePositives,\n falseNegatives,\n precision,\n recall,\n falseActivationBytes: observations.reduce(\n (total, observation) => total + observation.falseActivationBytes,\n 0,\n ),\n promptChars: {\n total: observations.reduce((total, observation) => total + observation.promptChars, 0),\n median: median(observations.map((observation) => observation.promptChars)),\n },\n promptTokens: {\n total: observations.reduce((total, observation) => total + observation.promptTokens, 0),\n median: median(observations.map((observation) => observation.promptTokens)),\n },\n bodyBytes: {\n total: observations.reduce((total, observation) => total + observation.bodyBytes, 0),\n median: median(observations.map((observation) => observation.bodyBytes)),\n },\n bodyTokens: {\n total: observations.reduce((total, observation) => total + observation.bodyTokens, 0),\n median: median(observations.map((observation) => observation.bodyTokens)),\n },\n activationLatencyMs: { median: median(latencies), p95: percentile(latencies, 0.95) },\n consentRequests: observations.reduce(\n (total, observation) => total + observation.consentRequests,\n 0,\n ),\n unnecessaryPermissionPrompts,\n taskCompletionRate:\n completed.length === 0\n ? undefined\n : completed.filter((observation) => observation.taskCompleted).length / completed.length,\n userCorrections: observations.reduce(\n (total, observation) => total + observation.userCorrections,\n 0,\n ),\n skillToolFailures,\n blockingMismatches,\n exposure,\n thresholds: { ...thresholds },\n rolloutReady: reasons.length === 0,\n reasons,\n observations: observations.map((observation) => ({\n ...observation,\n expectedSkills: [...observation.expectedSkills],\n expectedBlockedCodes: observation.expectedBlockedCodes\n ? [...observation.expectedBlockedCodes]\n : undefined,\n activatedSkills: [...observation.activatedSkills],\n blockedCodes: [...observation.blockedCodes],\n activationLatencyMs: [...observation.activationLatencyMs],\n })),\n };\n}\n\nexport async function runSkillActivationEvaluation(\n fixtures: readonly SkillEvaluationPromptFixture[],\n execute: (\n fixture: SkillEvaluationPromptFixture,\n ) => Promise<{ events: readonly SkillLifecycleEvent[]; outcome?: SkillEvaluationOutcome }>,\n thresholds: SkillEvaluationThresholds = DEFAULT_SKILL_EVALUATION_THRESHOLDS,\n): Promise<SkillEvaluationReport> {\n const observations: SkillEvaluationObservation[] = [];\n for (const fixture of fixtures) {\n const result = await execute(fixture);\n observations.push(\n observeSkillEvaluation(\n {\n id: fixture.id,\n category: fixture.category,\n promptHash: createHash('sha256').update(fixture.prompt).digest('hex'),\n expectedSkills: [...fixture.expectedSkills],\n expectedBlockedCodes: fixture.expectedBlockedCodes\n ? [...fixture.expectedBlockedCodes]\n : undefined,\n },\n result.events,\n result.outcome,\n ),\n );\n }\n return evaluateSkillActivation(observations, thresholds);\n}\n\nexport function renderSkillEvaluationReport(report: SkillEvaluationReport): string {\n const categories = SKILL_EVALUATION_CATEGORIES.map(\n (category) => `- ${category}: ${report.categoryCounts[category]}`,\n ).join('\\n');\n return [\n '# Skill Activation Evaluation',\n '',\n `Generated: ${report.generatedAt}`,\n `Rollout ready: ${report.rolloutReady ? 'yes' : 'no'}`,\n `Precision: ${report.precision.toFixed(3)}`,\n `Recall: ${report.recall.toFixed(3)}`,\n `False activations: ${report.falsePositives}`,\n `False-activation body bytes: ${report.falseActivationBytes}`,\n `Median prompt tokens: ${report.promptTokens.median}`,\n `Median activated body tokens: ${report.bodyTokens.median}`,\n `Median activation latency: ${report.activationLatencyMs.median} ms`,\n `Unnecessary permission prompts: ${report.unnecessaryPermissionPrompts}`,\n `Skill-caused tool failures: ${report.skillToolFailures}`,\n `Blocking mismatches: ${report.blockingMismatches}`,\n ...(report.evaluation\n ? [\n `Evidence kind: ${report.evaluation.evidenceKind}`,\n `Provider run eligibility: ${report.evaluation.providerRunEligibility}`,\n `Evaluation date: ${report.evaluation.controls.evaluationDate}`,\n `Evaluation seed: ${report.evaluation.controls.randomSeed}`,\n `Runtime revision: ${report.evaluation.controls.runtimeRevision}`,\n `Fixture revision: ${report.evaluation.controls.fixtureRevision} (${report.evaluation.controls.fixtureRevisionStatus})`,\n ]\n : []),\n '',\n '## Fixture Coverage',\n '',\n categories,\n '',\n '## Gate',\n '',\n ...(report.reasons.length\n ? report.reasons.map((reason) => `- ${reason}`)\n : ['- All thresholds passed.']),\n '',\n ].join('\\n');\n}\n\nexport function writeSkillEvaluationReport(\n report: SkillEvaluationReport,\n jsonPath: string,\n markdownPath?: string,\n): void {\n mkdirSync(dirname(jsonPath), { recursive: true });\n writeFileSync(jsonPath, `${JSON.stringify(report, null, 2)}\\n`, 'utf8');\n if (markdownPath) {\n mkdirSync(dirname(markdownPath), { recursive: true });\n writeFileSync(markdownPath, renderSkillEvaluationReport(report), 'utf8');\n }\n}\n","import { createHash } from 'crypto';\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { dirname } from 'path';\nimport type { AgentMode, AgentTopology, IssueQuality } from './types.js';\n\nexport interface EvaluationFixture {\n id: string;\n cohort: 'decomposable' | 'ambiguous' | 'sequential';\n prompt: string;\n}\n\nexport interface EvaluationRunResult {\n passed: boolean;\n validationCorrect?: boolean;\n wallTimeMs: number;\n totalTokens?: number;\n costUsd?: number;\n spawnCount?: number;\n route?: AgentTopology;\n issueQuality?: IssueQuality;\n conflicts?: number;\n interruptions?: number;\n unvalidatedApplications?: number;\n}\n\nexport interface EvaluationMetric extends Omit<EvaluationRunResult, 'route' | 'issueQuality'> {\n fixtureId: string;\n promptHash: string;\n cohort: EvaluationFixture['cohort'];\n mode: Extract<AgentMode, 'adaptive' | 'off'>;\n route?: AgentTopology;\n issueQuality?: IssueQuality;\n}\n\n/** Run each fixture with the single-agent control and adaptive treatment. */\nexport async function runPairedEvaluation(\n fixtures: EvaluationFixture[],\n execute: (\n fixture: EvaluationFixture,\n mode: Extract<AgentMode, 'adaptive' | 'off'>,\n ) => Promise<EvaluationRunResult>,\n outputPath: string,\n): Promise<EvaluationMetric[]> {\n const metrics: EvaluationMetric[] = [];\n for (const fixture of fixtures) {\n for (const mode of ['off', 'adaptive'] as const) {\n const result = await execute(fixture, mode);\n metrics.push({\n fixtureId: fixture.id,\n promptHash: createHash('sha256').update(fixture.prompt).digest('hex'),\n cohort: fixture.cohort,\n mode,\n ...result,\n });\n }\n }\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(\n outputPath,\n `${metrics.map((metric) => JSON.stringify(metric)).join('\\n')}\\n`,\n 'utf8',\n );\n return metrics;\n}\n\nexport function evaluateSuccess(metrics: EvaluationMetric[]): {\n successful: boolean;\n reasons: string[];\n} {\n const reasons: string[] = [];\n const byMode = (cohorts: EvaluationFixture['cohort'][], mode: EvaluationMetric['mode']) =>\n metrics.filter((metric) => cohorts.includes(metric.cohort) && metric.mode === mode);\n const rate = (items: EvaluationMetric[]) =>\n items.length === 0 ? 0 : items.filter((item) => item.passed).length / items.length;\n const median = (values: number[]) => {\n if (values.length === 0) return 0;\n const sorted = [...values].sort((left, right) => left - right);\n return sorted[Math.floor(sorted.length / 2)];\n };\n\n const treatment = byMode(['decomposable', 'ambiguous'], 'adaptive');\n const control = byMode(['decomposable', 'ambiguous'], 'off');\n const passGain = rate(treatment) - rate(control);\n const treatmentWall = median(treatment.map((item) => item.wallTimeMs));\n const controlWall = median(control.map((item) => item.wallTimeMs));\n if (passGain < 0.05 && !(passGain >= 0 && treatmentWall <= controlWall * 0.8)) {\n reasons.push('Decomposable/ambiguous cohort missed the pass-rate or wall-time target.');\n }\n\n const sequentialTreatment = byMode(['sequential'], 'adaptive');\n const sequentialControl = byMode(['sequential'], 'off');\n if (rate(sequentialTreatment) < rate(sequentialControl) - 0.02) {\n reasons.push('Sequential cohort regressed by more than two pass-rate points.');\n }\n\n const adaptiveTokens = median(\n metrics.filter((item) => item.mode === 'adaptive').map((item) => item.totalTokens ?? 0),\n );\n const controlTokens = median(\n metrics.filter((item) => item.mode === 'off').map((item) => item.totalTokens ?? 0),\n );\n if (controlTokens > 0 && adaptiveTokens >= controlTokens * 3) {\n reasons.push('Median adaptive token overhead is not below 3x.');\n }\n if (metrics.some((item) => (item.unvalidatedApplications ?? 0) > 0)) {\n reasons.push('At least one unvalidated patch was applied.');\n }\n return { successful: reasons.length === 0, reasons };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,YAAY;;;ACFrB,SAAS,kBAAkB;AAC3B,SAAS,WAAW,qBAAqB;AACzC,SAAS,eAAe;AAGjB,IAAM,8BAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsGO,IAAM,sCAAiE;AAAA,EAC5E,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,yBAAyB;AAAA,EACzB,qCAAqC;AAAA,EACrC,0BAA0B;AAC5B;AAEO,IAAM,oCAA6E;AAAA,EACxF;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC,QAAQ;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC,QAAQ;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC,aAAa;AAAA,IAC9B,sBAAsB,CAAC,+BAA+B;AAAA,EACxD;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC;AAAA,IACjB,sBA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skill-evaluation.ts","../src/agents/evaluation.ts"],"sourcesContent":["/** Book Agent SDK — programmatic API for embedding Book as a library. */\n\nimport { join } from 'path';\nimport type { ElicitationHandler, UserQuestionHandler } from './types/tools.js';\nimport type { AgentConfig, SessionDriver } from './types/runtime.js';\nimport type { SessionStoreInterface } from './types/sessions.js';\nimport { freezeAgentConfig, loadConfig, type LoadConfigOptions } from './config.js';\nimport { runHeadless } from './headless.js';\nimport { createDefaultRegistry } from './tools/registry.js';\nimport { connectMcpServers, disconnectMcpServers } from './mcp.js';\nimport { mcpServersToRecord, partitionMcpServersByApproval } from './mcp-approvals.js';\nimport { resolveMcpServerList } from './mcp-config.js';\nimport {\n collectSkippedProjectFileNotices,\n collectWithheldProjectNotices,\n} from './project-approval-notices.js';\nimport { AgentManager } from './agents/manager.js';\nimport { SessionStore } from './session/store.js';\nimport { discardUntouchedSession, resolveSessionBootstrap } from './session/resolve.js';\nimport type { AgentEvent } from './session/agent-events.js';\nimport {\n cleanupDebugLogs,\n DEFAULT_LOCAL_DATA_RETENTION_DAYS,\n getDebugLogPath,\n} from './debug-log.js';\nimport { resolvePermissionMode } from './permission-mode.js';\nimport { resolveBookHome } from './book-home.js';\nimport { cleanupRunStatus } from './run-status.js';\nimport { resolveSessionDriver } from './session-driver.js';\n\nexport type QueryEvent = AgentEvent;\n\nexport interface QueryOptions {\n workspace?: string;\n model?: string;\n permissionMode?: string;\n maxTurns?: number;\n settingsPath?: string;\n noSettings?: boolean;\n persistSession?: boolean;\n sessionId?: string;\n sessionStore?: SessionStoreInterface;\n signal?: AbortSignal;\n onUserQuestionRequired?: UserQuestionHandler;\n /**\n * Answer MCP form elicitations. Supplying it declares the elicitation\n * capability to connected servers; without it they fail such requests\n * themselves rather than blocking on a prompt no one can see.\n */\n onElicit?: ElicitationHandler;\n agents?: 'adaptive' | 'manual' | 'off';\n /** Forward high-volume managed-agent text deltas. Defaults to false. */\n forwardSubagentText?: boolean;\n /**\n * Who drives the session. Defaults to `BOOK_SESSION_DRIVER`, then to `agent` under another agent\n * harness and `human` otherwise; an agent-driven session saves only what it learned, as\n * project or reference memory, never its delegator's instructions.\n */\n sessionDriver?: SessionDriver;\n}\n\nclass AsyncEventQueue<T> {\n private values: T[] = [];\n private waiters: Array<(value: T | undefined) => void> = [];\n private closed = false;\n\n push(value: T): void {\n if (this.closed) return;\n const waiter = this.waiters.shift();\n if (waiter) waiter(value);\n else this.values.push(value);\n }\n\n close(): void {\n if (this.closed) return;\n this.closed = true;\n for (const waiter of this.waiters.splice(0)) waiter(undefined);\n }\n\n next(): Promise<T | undefined> {\n const value = this.values.shift();\n if (value !== undefined) return Promise.resolve(value);\n if (this.closed) return Promise.resolve(undefined);\n return new Promise((resolve) => this.waiters.push(resolve));\n }\n}\n\nexport async function* query(\n prompt: string,\n options: QueryOptions = {},\n): AsyncGenerator<QueryEvent, void, undefined> {\n const workspace = options.workspace || process.cwd();\n const loadedConfig = loadConfig(workspace, {\n settingsOverridePath: options.settingsPath,\n noSettings: options.noSettings,\n runMigrations: !options.noSettings,\n });\n const config = freezeAgentConfig({\n ...loadedConfig,\n sessionDriver: resolveSessionDriver({ explicit: options.sessionDriver, env: process.env })\n .driver,\n ...(options.model ? { model: options.model } : {}),\n ...(options.maxTurns ? { maxTurns: options.maxTurns } : {}),\n ...(options.agents\n ? {\n settings: {\n ...loadedConfig.settings,\n agents: { ...loadedConfig.settings.agents, mode: options.agents },\n },\n }\n : {}),\n });\n\n const controller = new AbortController();\n const abortFromCaller = () => controller.abort(options.signal?.reason);\n if (options.signal?.aborted) abortFromCaller();\n else options.signal?.addEventListener('abort', abortFromCaller, { once: true });\n\n const persistSession = options.persistSession !== false;\n const sessionStore = persistSession\n ? (options.sessionStore ?? new SessionStore(join(resolveBookHome(), 'sessions')))\n : undefined;\n const bootstrap = resolveSessionBootstrap(sessionStore, {\n cwd: config.workspace,\n sessionId: options.sessionId,\n driver: config.sessionDriver,\n });\n if (persistSession && !options.sessionStore && sessionStore) {\n cleanupDebugLogs(DEFAULT_LOCAL_DATA_RETENTION_DAYS, getDebugLogPath());\n sessionStore.cleanup(DEFAULT_LOCAL_DATA_RETENTION_DAYS, new Set([bootstrap.sessionId]));\n }\n // headless.ts writes a run record on every query, whatever the session settings.\n cleanupRunStatus(DEFAULT_LOCAL_DATA_RETENTION_DAYS);\n const queue = new AsyncEventQueue<QueryEvent>();\n let connections: Awaited<ReturnType<typeof connectMcpServers>>['connections'] = [];\n\n queue.push({ type: 'system', model: config.model, cwd: config.workspace });\n queue.push({ type: 'session', sessionId: bootstrap.sessionId });\n\n const running = (async () => {\n try {\n // Project-declared MCP servers require a prior interactive approval;\n // SDK runs cannot prompt, so unapproved servers are skipped with a warning.\n // Repository-declared allow rules and hooks are withheld until the user\n // decides on them; an SDK run cannot ask, so it reports and continues.\n for (const notice of [\n ...collectWithheldProjectNotices({\n workspace: config.workspace,\n settings: config.settings,\n settingsEnabled: !options.noSettings,\n providerGate: config.workspaceProviderGate,\n }),\n // Instruction files, REVIEW.md and command files that link out of the repository are not\n // loaded (#539, #543).\n ...collectSkippedProjectFileNotices(config.workspace),\n ]) {\n console.warn(notice);\n }\n const declaredMcpServers = resolveMcpServerList(config.workspace);\n const mcpPartition = partitionMcpServersByApproval(declaredMcpServers, config.settings);\n for (const server of mcpPartition.pending) {\n console.warn(\n `⚠ Skipping MCP server \"${server.name}\" (${server.path}): project-declared servers require one-time approval. Approve it in an interactive session first.`,\n );\n }\n const mcp = await connectMcpServers(config.workspace, {\n signal: controller.signal,\n servers: mcpServersToRecord(mcpPartition.allowed),\n onElicit: options.onElicit,\n });\n connections = mcp.connections;\n const registry = createDefaultRegistry({ agents: config.settings.agents.mode !== 'off' });\n if (mcp.tools.length > 0) registry.registerAll(mcp.tools);\n\n const result = await runHeadless(config, registry, {\n prompt,\n inputFormat: 'text',\n outputFormat: 'text',\n // Progress lines are for a person watching `book -p` in a terminal. An\n // SDK host owns its stderr and receives every tool call as an event.\n quiet: true,\n history: bootstrap.history,\n transcript: bootstrap.transcript,\n compactBoundaries: bootstrap.compactBoundaries,\n // A resumed session's unmet `/goal` keeps being checked, and `/goal clear` can see it.\n goal: bootstrap.goal,\n mode: resolvePermissionMode(config.settings, options.permissionMode),\n maxTurns: options.maxTurns,\n persistSession,\n sessionStore,\n sessionId: bootstrap.sessionId,\n sessionCreated: bootstrap.created,\n runSource: 'sdk',\n signal: controller.signal,\n onUserQuestionRequired: options.onUserQuestionRequired,\n forwardSubagentText: options.forwardSubagentText,\n stdout: { write: () => true },\n onAgentEvent: (event) => {\n if (\n event.type !== 'system' &&\n event.type !== 'session' &&\n event.type !== 'result' &&\n event.type !== 'done' &&\n (event.type !== 'agent_text_delta' || options.forwardSubagentText === true)\n ) {\n queue.push(event);\n }\n },\n });\n queue.push({\n type: 'result',\n messages: result.messages,\n usage: result.usage,\n sessionId: bootstrap.sessionId,\n outcome: result.outcome,\n runs: result.runs,\n // `stdout` above is a discard sink, so this is the only way an SDK\n // caller sees a slash command the host performed on its behalf.\n commandResults: result.commandResults,\n answer: result.answer,\n });\n } catch (error) {\n if (!controller.signal.aborted) {\n queue.push({\n type: 'error',\n error: error instanceof Error ? error.message : String(error),\n });\n }\n } finally {\n await disconnectMcpServers(connections);\n queue.push({ type: 'done' });\n queue.close();\n }\n })();\n\n try {\n while (true) {\n const event = await queue.next();\n if (!event) break;\n yield event;\n }\n } finally {\n controller.abort(new Error('SDK event consumer stopped'));\n options.signal?.removeEventListener('abort', abortFromCaller);\n try {\n await running;\n } finally {\n // The run has ended, SessionEnd hooks included, whether it resolved or rejected: a\n // query that stopped before it recorded its prompt leaves no empty session behind\n // (#444). A rejection still propagates.\n discardUntouchedSession(sessionStore, bootstrap);\n }\n }\n}\n\nexport { loadConfig, type LoadConfigOptions };\nexport type { ToolDiscoverySettings } from './settings.js';\nexport { AgentManager };\nexport { createDefaultRegistry, createRegistry } from './tools/registry.js';\nexport { createToolSurface } from './tools/catalog.js';\nexport { toolFailure, toolSuccess } from './tools/result.js';\nexport {\n applySkillOverrides,\n buildSkillListing,\n discoverSkills,\n explicitSkillMentions,\n generateSkillListing,\n loadSkillBody,\n skillRoots,\n} from './skills.js';\nexport type {\n DiscoverSkillsOptions,\n LoadedSkillBody,\n ShadowedSkill,\n Skill,\n SkillIssue,\n SkillListingResult,\n SkillResource,\n SkillRoot,\n SkillRootKind,\n SkillSource,\n} from './skills.js';\nexport {\n SkillRegistry,\n SkillRegistryError,\n type SkillActivationFrame,\n type SkillActivationFrameSummary,\n type SkillActivationReason,\n type SkillLifecycleEvent,\n type SkillLifecycleEventType,\n type SkillRegistrySnapshot,\n} from './skill-registry.js';\nexport {\n DEFAULT_SKILL_EVALUATION_THRESHOLDS,\n DEFAULT_SKILL_EVALUATION_FIXTURES,\n SKILL_EVALUATION_CATEGORIES,\n evaluateSkillActivation,\n observeSkillEvaluation,\n renderSkillEvaluationReport,\n runSkillActivationEvaluation,\n writeSkillEvaluationReport,\n} from './skill-evaluation.js';\nexport type {\n SkillEvaluationCategory,\n SkillEvaluationFixture,\n SkillEvaluationObservation,\n SkillEvaluationOutcome,\n SkillEvaluationPromptFixture,\n SkillEvaluationReport,\n SkillEvaluationThresholds,\n} from './skill-evaluation.js';\nexport { SessionRuntime } from './session/runtime.js';\nexport { buildSkillReport } from './skill-report.js';\nexport function createAgentManager(config: AgentConfig): AgentManager {\n return new AgentManager(config, createDefaultRegistry({ agents: true }).getDefinitions());\n}\nexport { runPairedEvaluation, evaluateSuccess } from './agents/evaluation.js';\nexport { createAgentSessionSnapshot, reduceAgentSessionSnapshot } from './session/agent-events.js';\nexport type {\n AgentEvent,\n AgentSessionSnapshot,\n AgentSessionStatus,\n} from './session/agent-events.js';\nexport type {\n EvaluationFixture,\n EvaluationMetric,\n EvaluationRunResult,\n} from './agents/evaluation.js';\nexport type {\n AgentPlanRecord,\n AgentApplyResult,\n AgentRecord,\n AgentSummary,\n AgentCompletion,\n AgentCompletionNotification,\n AgentProfile,\n AgentActivity,\n AgentRuntimeEvent,\n AgentRunMetrics,\n AgentSnapshot,\n AgentSpawnRequest,\n EvidenceItem,\n} from './agents/types.js';\nexport type {\n AgentTerminalOutcome,\n AgentTerminalReason,\n AgentTerminalStatus,\n} from './types/terminal.js';\nexport type {\n AgentModelIdentity,\n AgentModelIdentityStatus,\n AgentRunAmbientSnapshot,\n AgentRunAccounting,\n AgentRunContext,\n AgentRunResult,\n AgentRunSource,\n} from './types/runs.js';\nexport type {\n JsonSchemaObject,\n ToolCatalogMetadata,\n ToolCategory,\n ToolDefinition,\n ToolDiscoveryContext,\n ToolEffect,\n ToolPolicy,\n ToolResult,\n ToolResultArtifacts,\n ToolResultError,\n ToolResultPresentation,\n ToolResultStatus,\n ToolSearchMatch,\n UserQuestion,\n UserQuestionOption,\n UserQuestionRequest,\n UserQuestionResponse,\n UserQuestionSource,\n UserQuestionHandler,\n ElicitationField,\n ElicitationRequest,\n ElicitationResponse,\n ElicitationValue,\n ElicitationHandler,\n} from './types/tools.js';\n","import { createHash } from 'node:crypto';\nimport { mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport type { SkillLifecycleEvent } from './skill-registry.js';\n\nexport const SKILL_EVALUATION_CATEGORIES = [\n 'direct',\n 'indirect',\n 'negative',\n 'ambiguous',\n 'conflicting',\n 'disabled',\n 'invalid',\n 'missing-body',\n 'missing-resource',\n] as const;\n\nexport type SkillEvaluationCategory = (typeof SKILL_EVALUATION_CATEGORIES)[number];\n\nexport interface SkillEvaluationFixture {\n id: string;\n category: SkillEvaluationCategory;\n promptHash: string;\n expectedSkills: string[];\n expectedBlockedCodes?: string[];\n}\n\nexport interface SkillEvaluationPromptFixture {\n id: string;\n category: SkillEvaluationCategory;\n prompt: string;\n expectedSkills: string[];\n expectedBlockedCodes?: string[];\n}\n\nexport interface SkillEvaluationOutcome {\n promptChars?: number;\n promptTokens?: number;\n bodyTokens?: number;\n taskCompleted?: boolean;\n userCorrections?: number;\n skillToolFailures?: number;\n exposure?: 'eager' | 'deferred';\n activationTurns?: number;\n}\n\nexport interface SkillEvaluationObservation extends SkillEvaluationFixture {\n activatedSkills: string[];\n blockedCodes: string[];\n promptChars: number;\n promptTokens: number;\n bodyBytes: number;\n bodyTokens: number;\n falseActivationBytes: number;\n activationLatencyMs: number[];\n consentRequests: number;\n unnecessaryPermissionPrompts: number;\n taskCompleted?: boolean;\n userCorrections: number;\n skillToolFailures: number;\n blockingMismatch: boolean;\n exposure?: 'eager' | 'deferred';\n activationTurns?: number;\n}\n\nexport interface SkillEvaluationThresholds {\n minimumPrecision: number;\n minimumRecall: number;\n maximumFalseActivations: number;\n maximumUnnecessaryPermissionPrompts: number;\n maximumSkillToolFailures: number;\n}\n\nexport interface SkillEvaluationExecution {\n evidenceKind: 'offline-observation';\n providerRunEligibility: 'not-applicable';\n controls: {\n evaluationDate: string;\n randomSeed: string;\n runtimeRevision: string;\n fixtureRevision: string;\n fixtureRevisionStatus: 'captured' | 'incomplete';\n };\n}\n\nexport interface SkillEvaluationReport {\n generatedAt: string;\n fixtureCount: number;\n categoryCounts: Record<SkillEvaluationCategory, number>;\n truePositives: number;\n falsePositives: number;\n falseNegatives: number;\n precision: number;\n recall: number;\n falseActivationBytes: number;\n promptChars: { total: number; median: number };\n promptTokens: { total: number; median: number };\n bodyBytes: { total: number; median: number };\n bodyTokens: { total: number; median: number };\n activationLatencyMs: { median: number; p95: number };\n consentRequests: number;\n unnecessaryPermissionPrompts: number;\n taskCompletionRate?: number;\n userCorrections: number;\n skillToolFailures: number;\n blockingMismatches: number;\n exposure: Record<\n 'eager' | 'deferred',\n { samples: number; activationRate: number; medianActivationTurns: number }\n >;\n thresholds: SkillEvaluationThresholds;\n rolloutReady: boolean;\n reasons: string[];\n observations: SkillEvaluationObservation[];\n evaluation?: SkillEvaluationExecution;\n}\n\nexport const DEFAULT_SKILL_EVALUATION_THRESHOLDS: SkillEvaluationThresholds = {\n minimumPrecision: 0.95,\n minimumRecall: 0.8,\n maximumFalseActivations: 0,\n maximumUnnecessaryPermissionPrompts: 0,\n maximumSkillToolFailures: 0,\n};\n\nexport const DEFAULT_SKILL_EVALUATION_FIXTURES: readonly SkillEvaluationPromptFixture[] = [\n {\n id: 'direct-review',\n category: 'direct',\n prompt: '$review inspect the current change',\n expectedSkills: ['review'],\n },\n {\n id: 'indirect-review',\n category: 'indirect',\n prompt: 'Inspect this diff for correctness regressions and missing tests',\n expectedSkills: ['review'],\n },\n {\n id: 'negative-general-question',\n category: 'negative',\n prompt: 'Explain what this function returns',\n expectedSkills: [],\n },\n {\n id: 'ambiguous-review-word',\n category: 'ambiguous',\n prompt: 'Review the available deployment choices with me',\n expectedSkills: [],\n },\n {\n id: 'conflicting-tool-ceilings',\n category: 'conflicting',\n prompt: '$read-review $write-review inspect the change',\n expectedSkills: ['read-review'],\n expectedBlockedCodes: ['skill_tool_intersection_empty'],\n },\n {\n id: 'disabled-skill',\n category: 'disabled',\n prompt: '$disabled-skill run the workflow',\n expectedSkills: [],\n expectedBlockedCodes: ['skill_disabled'],\n },\n {\n id: 'invalid-skill',\n category: 'invalid',\n prompt: '$invalid-skill run the workflow',\n expectedSkills: [],\n expectedBlockedCodes: ['skill_invalid'],\n },\n {\n id: 'missing-body',\n category: 'missing-body',\n prompt: '$missing-body run the workflow',\n expectedSkills: [],\n expectedBlockedCodes: ['skill_load_failed'],\n },\n {\n id: 'missing-resource',\n category: 'missing-resource',\n prompt: '$missing-resource load references/checklist.md',\n expectedSkills: ['missing-resource'],\n expectedBlockedCodes: ['skill_resource_unreadable'],\n },\n];\n\nfunction numberDetail(event: SkillLifecycleEvent, key: string): number {\n const value = event.details?.[key];\n return typeof value === 'number' && Number.isFinite(value) ? value : 0;\n}\n\nfunction median(values: readonly number[]): number {\n if (values.length === 0) return 0;\n const sorted = [...values].sort((left, right) => left - right);\n return sorted[Math.floor(sorted.length / 2)] ?? 0;\n}\n\nfunction percentile(values: readonly number[], fraction: number): number {\n if (values.length === 0) return 0;\n const sorted = [...values].sort((left, right) => left - right);\n const index = Math.min(sorted.length - 1, Math.ceil(sorted.length * fraction) - 1);\n return sorted[index] ?? 0;\n}\n\n/** Convert bounded lifecycle evidence into one prompt-free evaluation observation. */\nexport function observeSkillEvaluation(\n fixture: SkillEvaluationFixture,\n events: readonly SkillLifecycleEvent[],\n outcome: SkillEvaluationOutcome = {},\n): SkillEvaluationObservation {\n const applied = events.filter(\n (event) => event.type === 'skill_activation_applied' && event.skill,\n );\n const activatedSkills = [...new Set(applied.map((event) => event.skill!))];\n const expected = new Set(fixture.expectedSkills);\n const falseActivations = applied.filter((event) => event.skill && !expected.has(event.skill));\n const consentEvents = events.filter((event) => event.type === 'skill_consent_requested');\n const blockedCodes = events\n .filter(\n (event) =>\n event.type === 'skill_activation_blocked' || event.type === 'skill_resource_blocked',\n )\n .map((event) => event.details?.code)\n .filter((code): code is string => typeof code === 'string');\n const expectedBlockedCodes = fixture.expectedBlockedCodes ?? [];\n const promptChars = outcome.promptChars ?? 0;\n const bodyBytes = applied.reduce(\n (total, event) => total + numberDetail(event, 'bodyByteSize'),\n 0,\n );\n return {\n ...fixture,\n expectedSkills: [...fixture.expectedSkills],\n activatedSkills,\n expectedBlockedCodes: [...expectedBlockedCodes],\n blockedCodes,\n promptChars,\n promptTokens: outcome.promptTokens ?? Math.ceil(promptChars / 4),\n bodyBytes,\n bodyTokens: outcome.bodyTokens ?? Math.ceil(bodyBytes / 4),\n falseActivationBytes: falseActivations.reduce(\n (total, event) => total + numberDetail(event, 'bodyByteSize'),\n 0,\n ),\n activationLatencyMs: applied.map((event) => numberDetail(event, 'activationLatencyMs')),\n consentRequests: consentEvents.length,\n unnecessaryPermissionPrompts: consentEvents.filter(\n (event) => !event.skill || !expected.has(event.skill),\n ).length,\n taskCompleted: outcome.taskCompleted,\n userCorrections: outcome.userCorrections ?? 0,\n skillToolFailures: outcome.skillToolFailures ?? 0,\n blockingMismatch:\n expectedBlockedCodes.some((code) => !blockedCodes.includes(code)) ||\n blockedCodes.some((code) => !expectedBlockedCodes.includes(code)),\n exposure: outcome.exposure,\n activationTurns: outcome.activationTurns,\n };\n}\n\nexport function evaluateSkillActivation(\n observations: readonly SkillEvaluationObservation[],\n thresholds: SkillEvaluationThresholds = DEFAULT_SKILL_EVALUATION_THRESHOLDS,\n): SkillEvaluationReport {\n const categoryCounts = Object.fromEntries(\n SKILL_EVALUATION_CATEGORIES.map((category) => [\n category,\n observations.filter((observation) => observation.category === category).length,\n ]),\n ) as Record<SkillEvaluationCategory, number>;\n let truePositives = 0;\n let falsePositives = 0;\n let falseNegatives = 0;\n for (const observation of observations) {\n const expected = new Set(observation.expectedSkills);\n const activated = new Set(observation.activatedSkills);\n truePositives += [...activated].filter((skill) => expected.has(skill)).length;\n falsePositives += [...activated].filter((skill) => !expected.has(skill)).length;\n falseNegatives += [...expected].filter((skill) => !activated.has(skill)).length;\n }\n const precision =\n truePositives + falsePositives === 0 ? 1 : truePositives / (truePositives + falsePositives);\n const recall =\n truePositives + falseNegatives === 0 ? 1 : truePositives / (truePositives + falseNegatives);\n const completed = observations.filter(\n (observation): observation is SkillEvaluationObservation & { taskCompleted: boolean } =>\n observation.taskCompleted !== undefined,\n );\n const exposure = Object.fromEntries(\n (['eager', 'deferred'] as const).map((mode) => {\n const samples = observations.filter((observation) => observation.exposure === mode);\n return [\n mode,\n {\n samples: samples.length,\n activationRate:\n samples.length === 0\n ? 0\n : samples.filter((observation) => observation.activatedSkills.length > 0).length /\n samples.length,\n medianActivationTurns: median(\n samples.map((observation) => observation.activationTurns ?? 0),\n ),\n },\n ];\n }),\n ) as SkillEvaluationReport['exposure'];\n const reasons: string[] = [];\n const missingCategories = SKILL_EVALUATION_CATEGORIES.filter(\n (category) => categoryCounts[category] === 0,\n );\n if (missingCategories.length)\n reasons.push(`Missing fixture categories: ${missingCategories.join(', ')}.`);\n if (precision < thresholds.minimumPrecision) {\n reasons.push(\n `Activation precision ${precision.toFixed(3)} is below ${thresholds.minimumPrecision}.`,\n );\n }\n if (recall < thresholds.minimumRecall) {\n reasons.push(`Activation recall ${recall.toFixed(3)} is below ${thresholds.minimumRecall}.`);\n }\n if (falsePositives > thresholds.maximumFalseActivations) {\n reasons.push(\n `False activations ${falsePositives} exceed ${thresholds.maximumFalseActivations}.`,\n );\n }\n const unnecessaryPermissionPrompts = observations.reduce(\n (total, observation) => total + observation.unnecessaryPermissionPrompts,\n 0,\n );\n if (unnecessaryPermissionPrompts > thresholds.maximumUnnecessaryPermissionPrompts) {\n reasons.push(\n `Unnecessary permission prompts ${unnecessaryPermissionPrompts} exceed ${thresholds.maximumUnnecessaryPermissionPrompts}.`,\n );\n }\n const skillToolFailures = observations.reduce(\n (total, observation) => total + observation.skillToolFailures,\n 0,\n );\n if (skillToolFailures > thresholds.maximumSkillToolFailures) {\n reasons.push(\n `Skill-caused tool failures ${skillToolFailures} exceed ${thresholds.maximumSkillToolFailures}.`,\n );\n }\n const blockingMismatches = observations.filter(\n (observation) => observation.blockingMismatch,\n ).length;\n if (blockingMismatches > 0) {\n reasons.push(`${blockingMismatches} fixture(s) had unexpected or missing block outcomes.`);\n }\n const latencies = observations.flatMap((observation) => observation.activationLatencyMs);\n return {\n generatedAt: new Date().toISOString(),\n fixtureCount: observations.length,\n categoryCounts,\n truePositives,\n falsePositives,\n falseNegatives,\n precision,\n recall,\n falseActivationBytes: observations.reduce(\n (total, observation) => total + observation.falseActivationBytes,\n 0,\n ),\n promptChars: {\n total: observations.reduce((total, observation) => total + observation.promptChars, 0),\n median: median(observations.map((observation) => observation.promptChars)),\n },\n promptTokens: {\n total: observations.reduce((total, observation) => total + observation.promptTokens, 0),\n median: median(observations.map((observation) => observation.promptTokens)),\n },\n bodyBytes: {\n total: observations.reduce((total, observation) => total + observation.bodyBytes, 0),\n median: median(observations.map((observation) => observation.bodyBytes)),\n },\n bodyTokens: {\n total: observations.reduce((total, observation) => total + observation.bodyTokens, 0),\n median: median(observations.map((observation) => observation.bodyTokens)),\n },\n activationLatencyMs: { median: median(latencies), p95: percentile(latencies, 0.95) },\n consentRequests: observations.reduce(\n (total, observation) => total + observation.consentRequests,\n 0,\n ),\n unnecessaryPermissionPrompts,\n taskCompletionRate:\n completed.length === 0\n ? undefined\n : completed.filter((observation) => observation.taskCompleted).length / completed.length,\n userCorrections: observations.reduce(\n (total, observation) => total + observation.userCorrections,\n 0,\n ),\n skillToolFailures,\n blockingMismatches,\n exposure,\n thresholds: { ...thresholds },\n rolloutReady: reasons.length === 0,\n reasons,\n observations: observations.map((observation) => ({\n ...observation,\n expectedSkills: [...observation.expectedSkills],\n expectedBlockedCodes: observation.expectedBlockedCodes\n ? [...observation.expectedBlockedCodes]\n : undefined,\n activatedSkills: [...observation.activatedSkills],\n blockedCodes: [...observation.blockedCodes],\n activationLatencyMs: [...observation.activationLatencyMs],\n })),\n };\n}\n\nexport async function runSkillActivationEvaluation(\n fixtures: readonly SkillEvaluationPromptFixture[],\n execute: (\n fixture: SkillEvaluationPromptFixture,\n ) => Promise<{ events: readonly SkillLifecycleEvent[]; outcome?: SkillEvaluationOutcome }>,\n thresholds: SkillEvaluationThresholds = DEFAULT_SKILL_EVALUATION_THRESHOLDS,\n): Promise<SkillEvaluationReport> {\n const observations: SkillEvaluationObservation[] = [];\n for (const fixture of fixtures) {\n const result = await execute(fixture);\n observations.push(\n observeSkillEvaluation(\n {\n id: fixture.id,\n category: fixture.category,\n promptHash: createHash('sha256').update(fixture.prompt).digest('hex'),\n expectedSkills: [...fixture.expectedSkills],\n expectedBlockedCodes: fixture.expectedBlockedCodes\n ? [...fixture.expectedBlockedCodes]\n : undefined,\n },\n result.events,\n result.outcome,\n ),\n );\n }\n return evaluateSkillActivation(observations, thresholds);\n}\n\nexport function renderSkillEvaluationReport(report: SkillEvaluationReport): string {\n const categories = SKILL_EVALUATION_CATEGORIES.map(\n (category) => `- ${category}: ${report.categoryCounts[category]}`,\n ).join('\\n');\n return [\n '# Skill Activation Evaluation',\n '',\n `Generated: ${report.generatedAt}`,\n `Rollout ready: ${report.rolloutReady ? 'yes' : 'no'}`,\n `Precision: ${report.precision.toFixed(3)}`,\n `Recall: ${report.recall.toFixed(3)}`,\n `False activations: ${report.falsePositives}`,\n `False-activation body bytes: ${report.falseActivationBytes}`,\n `Median prompt tokens: ${report.promptTokens.median}`,\n `Median activated body tokens: ${report.bodyTokens.median}`,\n `Median activation latency: ${report.activationLatencyMs.median} ms`,\n `Unnecessary permission prompts: ${report.unnecessaryPermissionPrompts}`,\n `Skill-caused tool failures: ${report.skillToolFailures}`,\n `Blocking mismatches: ${report.blockingMismatches}`,\n ...(report.evaluation\n ? [\n `Evidence kind: ${report.evaluation.evidenceKind}`,\n `Provider run eligibility: ${report.evaluation.providerRunEligibility}`,\n `Evaluation date: ${report.evaluation.controls.evaluationDate}`,\n `Evaluation seed: ${report.evaluation.controls.randomSeed}`,\n `Runtime revision: ${report.evaluation.controls.runtimeRevision}`,\n `Fixture revision: ${report.evaluation.controls.fixtureRevision} (${report.evaluation.controls.fixtureRevisionStatus})`,\n ]\n : []),\n '',\n '## Fixture Coverage',\n '',\n categories,\n '',\n '## Gate',\n '',\n ...(report.reasons.length\n ? report.reasons.map((reason) => `- ${reason}`)\n : ['- All thresholds passed.']),\n '',\n ].join('\\n');\n}\n\nexport function writeSkillEvaluationReport(\n report: SkillEvaluationReport,\n jsonPath: string,\n markdownPath?: string,\n): void {\n mkdirSync(dirname(jsonPath), { recursive: true });\n writeFileSync(jsonPath, `${JSON.stringify(report, null, 2)}\\n`, 'utf8');\n if (markdownPath) {\n mkdirSync(dirname(markdownPath), { recursive: true });\n writeFileSync(markdownPath, renderSkillEvaluationReport(report), 'utf8');\n }\n}\n","import { createHash } from 'crypto';\nimport { mkdirSync, writeFileSync } from 'fs';\nimport { dirname } from 'path';\nimport type { AgentMode, AgentTopology, IssueQuality } from './types.js';\n\nexport interface EvaluationFixture {\n id: string;\n cohort: 'decomposable' | 'ambiguous' | 'sequential';\n prompt: string;\n}\n\nexport interface EvaluationRunResult {\n passed: boolean;\n validationCorrect?: boolean;\n wallTimeMs: number;\n totalTokens?: number;\n costUsd?: number;\n spawnCount?: number;\n route?: AgentTopology;\n issueQuality?: IssueQuality;\n conflicts?: number;\n interruptions?: number;\n unvalidatedApplications?: number;\n}\n\nexport interface EvaluationMetric extends Omit<EvaluationRunResult, 'route' | 'issueQuality'> {\n fixtureId: string;\n promptHash: string;\n cohort: EvaluationFixture['cohort'];\n mode: Extract<AgentMode, 'adaptive' | 'off'>;\n route?: AgentTopology;\n issueQuality?: IssueQuality;\n}\n\n/** Run each fixture with the single-agent control and adaptive treatment. */\nexport async function runPairedEvaluation(\n fixtures: EvaluationFixture[],\n execute: (\n fixture: EvaluationFixture,\n mode: Extract<AgentMode, 'adaptive' | 'off'>,\n ) => Promise<EvaluationRunResult>,\n outputPath: string,\n): Promise<EvaluationMetric[]> {\n const metrics: EvaluationMetric[] = [];\n for (const fixture of fixtures) {\n for (const mode of ['off', 'adaptive'] as const) {\n const result = await execute(fixture, mode);\n metrics.push({\n fixtureId: fixture.id,\n promptHash: createHash('sha256').update(fixture.prompt).digest('hex'),\n cohort: fixture.cohort,\n mode,\n ...result,\n });\n }\n }\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(\n outputPath,\n `${metrics.map((metric) => JSON.stringify(metric)).join('\\n')}\\n`,\n 'utf8',\n );\n return metrics;\n}\n\nexport function evaluateSuccess(metrics: EvaluationMetric[]): {\n successful: boolean;\n reasons: string[];\n} {\n const reasons: string[] = [];\n const byMode = (cohorts: EvaluationFixture['cohort'][], mode: EvaluationMetric['mode']) =>\n metrics.filter((metric) => cohorts.includes(metric.cohort) && metric.mode === mode);\n const rate = (items: EvaluationMetric[]) =>\n items.length === 0 ? 0 : items.filter((item) => item.passed).length / items.length;\n const median = (values: number[]) => {\n if (values.length === 0) return 0;\n const sorted = [...values].sort((left, right) => left - right);\n return sorted[Math.floor(sorted.length / 2)];\n };\n\n const treatment = byMode(['decomposable', 'ambiguous'], 'adaptive');\n const control = byMode(['decomposable', 'ambiguous'], 'off');\n const passGain = rate(treatment) - rate(control);\n const treatmentWall = median(treatment.map((item) => item.wallTimeMs));\n const controlWall = median(control.map((item) => item.wallTimeMs));\n if (passGain < 0.05 && !(passGain >= 0 && treatmentWall <= controlWall * 0.8)) {\n reasons.push('Decomposable/ambiguous cohort missed the pass-rate or wall-time target.');\n }\n\n const sequentialTreatment = byMode(['sequential'], 'adaptive');\n const sequentialControl = byMode(['sequential'], 'off');\n if (rate(sequentialTreatment) < rate(sequentialControl) - 0.02) {\n reasons.push('Sequential cohort regressed by more than two pass-rate points.');\n }\n\n const adaptiveTokens = median(\n metrics.filter((item) => item.mode === 'adaptive').map((item) => item.totalTokens ?? 0),\n );\n const controlTokens = median(\n metrics.filter((item) => item.mode === 'off').map((item) => item.totalTokens ?? 0),\n );\n if (controlTokens > 0 && adaptiveTokens >= controlTokens * 3) {\n reasons.push('Median adaptive token overhead is not below 3x.');\n }\n if (metrics.some((item) => (item.unvalidatedApplications ?? 0) > 0)) {\n reasons.push('At least one unvalidated patch was applied.');\n }\n return { successful: reasons.length === 0, reasons };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,YAAY;;;ACFrB,SAAS,kBAAkB;AAC3B,SAAS,WAAW,qBAAqB;AACzC,SAAS,eAAe;AAGjB,IAAM,8BAA8B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAsGO,IAAM,sCAAiE;AAAA,EAC5E,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,yBAAyB;AAAA,EACzB,qCAAqC;AAAA,EACrC,0BAA0B;AAC5B;AAEO,IAAM,oCAA6E;AAAA,EACxF;AAAA,IACE,IAAI;AAAA,IACJ,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,gBAAgB,CAAC,QAAQ;AAAA,EAC3B;AAAA,EACA;AAAA,IACE,I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S;AAC9B,cAAM,KAAK;AAAA,UACT,MAAM;AAAA,UACN,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,QAC9D,CAAC;AAAA,MACH;AAAA,IACF,UAAE;AACA,YAAM,qBAAqB,WAAW;AACtC,YAAM,KAAK,EAAE,MAAM,OAAO,CAAC;AAC3B,YAAM,MAAM;AAAA,IACd;AAAA,EACF,GAAG;AAEH,MAAI;AACF,WAAO,MAAM;AACX,YAAM,QAAQ,MAAM,MAAM,KAAK;AAC/B,UAAI,CAAC,MAAO;AACZ,YAAM;AAAA,IACR;AAAA,EACF,UAAE;AACA,eAAW,MAAM,IAAI,MAAM,4BAA4B,CAAC;AACxD,YAAQ,QAAQ,oBAAoB,SAAS,eAAe;AAC5D,QAAI;AACF,YAAM;AAAA,IACR,UAAE;AAIA,8BAAwB,cAAc,SAAS;AAAA,IACjD;AAAA,EACF;AACF;AA4DO,SAAS,mBAAmB,QAAmC;AACpE,SAAO,IAAI,aAAa,QAAQ,sBAAsB,EAAE,QAAQ,KAAK,CAAC,EAAE,eAAe,CAAC;AAC1F;","names":["createHash","mkdirSync","writeFileSync","dirname","median"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applySettingsEnvOverrides,
|
|
3
|
+
emptyWorkspaceProviderGate,
|
|
4
|
+
formatIgnoredWorkspaceSandboxKey,
|
|
5
|
+
ignoredWorkspaceSandboxKeys,
|
|
6
|
+
isUserSettingsFile,
|
|
7
|
+
loadSettingsFile,
|
|
8
|
+
mergeSettings,
|
|
9
|
+
migrateLegacyPermissions,
|
|
10
|
+
resolveSettings,
|
|
11
|
+
resolveSettingsWithProviderGate,
|
|
12
|
+
settingsLayerPaths,
|
|
13
|
+
startupAnimationEnvNote,
|
|
14
|
+
workspaceLayerThatEnabledSandbox
|
|
15
|
+
} from "./chunk-UCFJ43OS.js";
|
|
16
|
+
import "./chunk-HOZXKOE3.js";
|
|
17
|
+
import "./chunk-4DKHLZRI.js";
|
|
18
|
+
import "./chunk-OJBMDM5H.js";
|
|
19
|
+
import "./chunk-YIL6HTJX.js";
|
|
20
|
+
import "./chunk-EEX6QNXV.js";
|
|
21
|
+
import "./chunk-MV5PQNIA.js";
|
|
22
|
+
import "./chunk-B5FC3MYZ.js";
|
|
23
|
+
import "./chunk-WV3O5PGX.js";
|
|
24
|
+
import "./chunk-HFB74CLM.js";
|
|
25
|
+
import "./chunk-REASC2QG.js";
|
|
26
|
+
import "./chunk-IDYWN37T.js";
|
|
27
|
+
import "./chunk-ZPSZZUWF.js";
|
|
28
|
+
export {
|
|
29
|
+
applySettingsEnvOverrides,
|
|
30
|
+
emptyWorkspaceProviderGate,
|
|
31
|
+
formatIgnoredWorkspaceSandboxKey,
|
|
32
|
+
ignoredWorkspaceSandboxKeys,
|
|
33
|
+
isUserSettingsFile,
|
|
34
|
+
loadSettingsFile,
|
|
35
|
+
mergeSettings,
|
|
36
|
+
migrateLegacyPermissions,
|
|
37
|
+
resolveSettings,
|
|
38
|
+
resolveSettingsWithProviderGate,
|
|
39
|
+
settingsLayerPaths,
|
|
40
|
+
startupAnimationEnvNote,
|
|
41
|
+
workspaceLayerThatEnabledSandbox
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=settings-loader-KDBH45AQ.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
normalizeRemovedSettings,
|
|
7
7
|
readSettingsDocumentForNotices,
|
|
8
8
|
removedAuthStoreNotice
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HOZXKOE3.js";
|
|
10
10
|
export {
|
|
11
11
|
REMOVED_AUTH_STORE_FILENAME,
|
|
12
12
|
collectRemovedEnvNotices,
|
|
@@ -16,4 +16,4 @@ export {
|
|
|
16
16
|
readSettingsDocumentForNotices,
|
|
17
17
|
removedAuthStoreNotice
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=settings-removed-
|
|
19
|
+
//# sourceMappingURL=settings-removed-3ATWJEF3.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GIT_BASH_COMMAND_VARIABLE,
|
|
3
|
+
GIT_BASH_EVAL_SCRIPT,
|
|
4
|
+
decodePowerShellCommand,
|
|
5
|
+
describeShell,
|
|
6
|
+
encodePowerShellCommand,
|
|
7
|
+
isGitBash,
|
|
8
|
+
readsSingleQuoteAsPosix,
|
|
9
|
+
receivesCommandOutOfBand,
|
|
10
|
+
resolveShell,
|
|
11
|
+
shellExecution,
|
|
12
|
+
shellPromptLine,
|
|
13
|
+
singleQuoteHint,
|
|
14
|
+
spawnCommandExecution
|
|
15
|
+
} from "./chunk-W7SLYS3M.js";
|
|
16
|
+
export {
|
|
17
|
+
GIT_BASH_COMMAND_VARIABLE,
|
|
18
|
+
GIT_BASH_EVAL_SCRIPT,
|
|
19
|
+
decodePowerShellCommand,
|
|
20
|
+
describeShell,
|
|
21
|
+
encodePowerShellCommand,
|
|
22
|
+
isGitBash,
|
|
23
|
+
readsSingleQuoteAsPosix,
|
|
24
|
+
receivesCommandOutOfBand,
|
|
25
|
+
resolveShell,
|
|
26
|
+
shellExecution,
|
|
27
|
+
shellPromptLine,
|
|
28
|
+
singleQuoteHint,
|
|
29
|
+
spawnCommandExecution
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=shell-selection-Z5WORZU4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@letrquan/book",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-beta.0",
|
|
4
4
|
"description": "AI coding agent CLI with rich TUI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "PolyForm-Small-Business-1.0.0",
|
|
@@ -79,8 +79,8 @@
|
|
|
79
79
|
"deadcode:check": "knip",
|
|
80
80
|
"deadcode:report": "knip --reporter markdown --no-exit-code",
|
|
81
81
|
"deadcode:json": "knip --reporter json --no-exit-code",
|
|
82
|
-
"audit:prod": "
|
|
83
|
-
"audit:all": "
|
|
82
|
+
"audit:prod": "tsx scripts/audit-gate.ts --omit=dev",
|
|
83
|
+
"audit:all": "tsx scripts/audit-gate.ts",
|
|
84
84
|
"version:check": "tsx scripts/verify-release.ts",
|
|
85
85
|
"package:smoke": "npm run build && tsx scripts/package-smoke.ts",
|
|
86
86
|
"release:check": "npm run version:check && npm run audit:all && npm run package:smoke",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
"@types/picomatch": "^4.0.3",
|
|
112
112
|
"@types/react": "^19.2.18",
|
|
113
113
|
"@types/turndown": "^5.0.6",
|
|
114
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
115
|
-
"@typescript-eslint/parser": "8.
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "8.71.0",
|
|
115
|
+
"@typescript-eslint/parser": "8.71.0",
|
|
116
116
|
"@vitest/coverage-v8": "^4.1.9",
|
|
117
117
|
"@xterm/headless": "^6.0.0",
|
|
118
118
|
"eslint": "^10.8.1",
|