@narumitw/pi-subagents 2.1.3 → 3.0.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/README.md +181 -1250
- package/dist/child-communication-bridge.ts +136 -0
- package/dist/child-communication-bridge.ts.map +7 -0
- package/dist/chunks/chunk-UKTWUQRM.js +667 -0
- package/dist/chunks/chunk-UKTWUQRM.js.map +7 -0
- package/dist/index.ts +1448 -1598
- package/dist/index.ts.map +4 -4
- package/docs/design-principles.md +31 -0
- package/docs/ipc-transport-idea.md +103 -0
- package/docs/tools.md +109 -0
- package/package.json +11 -19
- package/src/broker-credentials.ts +71 -0
- package/src/child-communication-bridge.ts +153 -0
- package/src/child-communication-tools.ts +147 -0
- package/src/completion-renderer.ts +60 -0
- package/src/index.ts +1 -1
- package/src/message-broker.ts +628 -0
- package/src/model-output.ts +42 -0
- package/src/process.ts +688 -0
- package/src/runtime.ts +538 -0
- package/src/subagents.ts +33 -34
- package/src/tools.ts +416 -0
- package/src/types.ts +85 -0
- package/src/widget.ts +130 -0
- package/dist/chunks/auto-transport-FUUKFDIG.ts +0 -109
- package/dist/chunks/auto-transport-FUUKFDIG.ts.map +0 -7
- package/dist/chunks/capability-grant-PR72SWWS.ts +0 -19
- package/dist/chunks/capability-grant-PR72SWWS.ts.map +0 -7
- package/dist/chunks/child-peer-bridge.ts +0 -108
- package/dist/chunks/child-peer-bridge.ts.map +0 -7
- package/dist/chunks/chunk-2LMJU25E.ts +0 -1641
- package/dist/chunks/chunk-2LMJU25E.ts.map +0 -7
- package/dist/chunks/chunk-47SK2QYC.ts +0 -56
- package/dist/chunks/chunk-47SK2QYC.ts.map +0 -7
- package/dist/chunks/chunk-4AQSF7AS.ts +0 -29
- package/dist/chunks/chunk-4AQSF7AS.ts.map +0 -7
- package/dist/chunks/chunk-5DGRMKNV.ts +0 -126
- package/dist/chunks/chunk-5DGRMKNV.ts.map +0 -7
- package/dist/chunks/chunk-6H6TBBED.ts +0 -108
- package/dist/chunks/chunk-6H6TBBED.ts.map +0 -7
- package/dist/chunks/chunk-6KJ34M6S.ts +0 -159
- package/dist/chunks/chunk-6KJ34M6S.ts.map +0 -7
- package/dist/chunks/chunk-6NSJVPXX.ts +0 -480
- package/dist/chunks/chunk-6NSJVPXX.ts.map +0 -7
- package/dist/chunks/chunk-7AAJEUSL.ts +0 -238
- package/dist/chunks/chunk-7AAJEUSL.ts.map +0 -7
- package/dist/chunks/chunk-BFK2Z4ZF.ts +0 -189
- package/dist/chunks/chunk-BFK2Z4ZF.ts.map +0 -7
- package/dist/chunks/chunk-BOAXY55Y.ts +0 -153
- package/dist/chunks/chunk-BOAXY55Y.ts.map +0 -7
- package/dist/chunks/chunk-D4CR7T73.ts +0 -353
- package/dist/chunks/chunk-D4CR7T73.ts.map +0 -7
- package/dist/chunks/chunk-FEVPWRMU.ts +0 -300
- package/dist/chunks/chunk-FEVPWRMU.ts.map +0 -7
- package/dist/chunks/chunk-G6VZTCFH.ts +0 -70
- package/dist/chunks/chunk-G6VZTCFH.ts.map +0 -7
- package/dist/chunks/chunk-H3FP6DLR.ts +0 -160
- package/dist/chunks/chunk-H3FP6DLR.ts.map +0 -7
- package/dist/chunks/chunk-HA36LPCO.ts +0 -130
- package/dist/chunks/chunk-HA36LPCO.ts.map +0 -7
- package/dist/chunks/chunk-HOP5FXDT.ts +0 -27
- package/dist/chunks/chunk-HOP5FXDT.ts.map +0 -7
- package/dist/chunks/chunk-IGAMVWFN.ts +0 -139
- package/dist/chunks/chunk-IGAMVWFN.ts.map +0 -7
- package/dist/chunks/chunk-ILEQ27AL.ts +0 -45
- package/dist/chunks/chunk-ILEQ27AL.ts.map +0 -7
- package/dist/chunks/chunk-ITVWPNU4.ts +0 -819
- package/dist/chunks/chunk-ITVWPNU4.ts.map +0 -7
- package/dist/chunks/chunk-IWC32VPY.ts +0 -172
- package/dist/chunks/chunk-IWC32VPY.ts.map +0 -7
- package/dist/chunks/chunk-JSZIP73U.ts +0 -362
- package/dist/chunks/chunk-JSZIP73U.ts.map +0 -7
- package/dist/chunks/chunk-JU6LUNLP.ts +0 -380
- package/dist/chunks/chunk-JU6LUNLP.ts.map +0 -7
- package/dist/chunks/chunk-KMGKCEO4.ts +0 -38
- package/dist/chunks/chunk-KMGKCEO4.ts.map +0 -7
- package/dist/chunks/chunk-LASD73CM.ts +0 -339
- package/dist/chunks/chunk-LASD73CM.ts.map +0 -7
- package/dist/chunks/chunk-LEOYDZI3.ts +0 -22
- package/dist/chunks/chunk-LEOYDZI3.ts.map +0 -7
- package/dist/chunks/chunk-LL4LP2T7.ts +0 -737
- package/dist/chunks/chunk-LL4LP2T7.ts.map +0 -7
- package/dist/chunks/chunk-N2T5IN4X.ts +0 -18
- package/dist/chunks/chunk-N2T5IN4X.ts.map +0 -7
- package/dist/chunks/chunk-N7BLVXKK.ts +0 -73
- package/dist/chunks/chunk-N7BLVXKK.ts.map +0 -7
- package/dist/chunks/chunk-NLT67IZS.ts +0 -322
- package/dist/chunks/chunk-NLT67IZS.ts.map +0 -7
- package/dist/chunks/chunk-NTRPLF46.ts +0 -63
- package/dist/chunks/chunk-NTRPLF46.ts.map +0 -7
- package/dist/chunks/chunk-ONDTY4EL.ts +0 -91
- package/dist/chunks/chunk-ONDTY4EL.ts.map +0 -7
- package/dist/chunks/chunk-OVPHFGKO.ts +0 -1769
- package/dist/chunks/chunk-OVPHFGKO.ts.map +0 -7
- package/dist/chunks/chunk-P7OH4XMF.ts +0 -60
- package/dist/chunks/chunk-P7OH4XMF.ts.map +0 -7
- package/dist/chunks/chunk-PBZMBTNJ.ts +0 -422
- package/dist/chunks/chunk-PBZMBTNJ.ts.map +0 -7
- package/dist/chunks/chunk-PGLSFLYW.ts +0 -52
- package/dist/chunks/chunk-PGLSFLYW.ts.map +0 -7
- package/dist/chunks/chunk-RRR66UWR.ts +0 -28
- package/dist/chunks/chunk-RRR66UWR.ts.map +0 -7
- package/dist/chunks/chunk-RSUXZD6S.ts +0 -275
- package/dist/chunks/chunk-RSUXZD6S.ts.map +0 -7
- package/dist/chunks/chunk-RTCVYIZA.ts +0 -221
- package/dist/chunks/chunk-RTCVYIZA.ts.map +0 -7
- package/dist/chunks/chunk-RY2AEGMZ.ts +0 -34
- package/dist/chunks/chunk-RY2AEGMZ.ts.map +0 -7
- package/dist/chunks/chunk-SWGQLFSD.ts +0 -60
- package/dist/chunks/chunk-SWGQLFSD.ts.map +0 -7
- package/dist/chunks/chunk-TM2R67J3.ts +0 -52
- package/dist/chunks/chunk-TM2R67J3.ts.map +0 -7
- package/dist/chunks/chunk-TMZRHIIK.ts +0 -497
- package/dist/chunks/chunk-TMZRHIIK.ts.map +0 -7
- package/dist/chunks/chunk-TZ34IQ3M.ts +0 -59
- package/dist/chunks/chunk-TZ34IQ3M.ts.map +0 -7
- package/dist/chunks/chunk-UMBPMVJW.ts +0 -22
- package/dist/chunks/chunk-UMBPMVJW.ts.map +0 -7
- package/dist/chunks/chunk-VDG7LTYE.ts +0 -80
- package/dist/chunks/chunk-VDG7LTYE.ts.map +0 -7
- package/dist/chunks/chunk-X4NMONPE.ts +0 -73
- package/dist/chunks/chunk-X4NMONPE.ts.map +0 -7
- package/dist/chunks/chunk-YPJEN6NU.ts +0 -65
- package/dist/chunks/chunk-YPJEN6NU.ts.map +0 -7
- package/dist/chunks/chunk-YU53SHA7.ts +0 -328
- package/dist/chunks/chunk-YU53SHA7.ts.map +0 -7
- package/dist/chunks/completion-delivery-RSJU6BXL.ts +0 -17
- package/dist/chunks/completion-delivery-RSJU6BXL.ts.map +0 -7
- package/dist/chunks/config-status-FKGDECZ3.ts +0 -35
- package/dist/chunks/config-status-FKGDECZ3.ts.map +0 -7
- package/dist/chunks/config-ui-ABHYNGQ7.ts +0 -1212
- package/dist/chunks/config-ui-ABHYNGQ7.ts.map +0 -7
- package/dist/chunks/consult-LJU3IQY5.ts +0 -519
- package/dist/chunks/consult-LJU3IQY5.ts.map +0 -7
- package/dist/chunks/context-QDKLVQXE.ts +0 -11
- package/dist/chunks/context-QDKLVQXE.ts.map +0 -7
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts +0 -130
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts.map +0 -7
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts +0 -17
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +0 -7
- package/dist/chunks/delegation-contract-LA56I5DT.ts +0 -24
- package/dist/chunks/delegation-contract-LA56I5DT.ts.map +0 -7
- package/dist/chunks/discovery-MIFB2U4Y.ts +0 -12
- package/dist/chunks/discovery-MIFB2U4Y.ts.map +0 -7
- package/dist/chunks/execution-Q2JZLKJA.ts +0 -4037
- package/dist/chunks/execution-Q2JZLKJA.ts.map +0 -7
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts +0 -39
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts.map +0 -7
- package/dist/chunks/inspect-UH2TKH6E.ts +0 -634
- package/dist/chunks/inspect-UH2TKH6E.ts.map +0 -7
- package/dist/chunks/peer-communication-KL36Z6CO.ts +0 -294
- package/dist/chunks/peer-communication-KL36Z6CO.ts.map +0 -7
- package/dist/chunks/persistence-UY3PY6E5.ts +0 -348
- package/dist/chunks/persistence-UY3PY6E5.ts.map +0 -7
- package/dist/chunks/registry-BT54L6CY.ts +0 -1445
- package/dist/chunks/registry-BT54L6CY.ts.map +0 -7
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts +0 -81
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts.map +0 -7
- package/dist/chunks/rpc-transport-7R7DVCEB.ts +0 -1222
- package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +0 -7
- package/dist/chunks/runtime-policy-5YELCOVC.ts +0 -15
- package/dist/chunks/runtime-policy-5YELCOVC.ts.map +0 -7
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +0 -19
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +0 -7
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts +0 -13
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts.map +0 -7
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +0 -15
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +0 -7
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts +0 -160
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +0 -7
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +0 -164
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +0 -7
- package/dist/chunks/workspace-WDKLN72J.ts +0 -11
- package/dist/chunks/workspace-WDKLN72J.ts.map +0 -7
- package/docs/async-runtime-protocol.md +0 -84
- package/docs/implementation-notes/pi-subagents-capability-matrix.md +0 -62
- package/docs/implementation-notes/pi-subagents-current-direction.md +0 -99
- package/docs/implementation-notes/pi-subagents-rpc-v1.md +0 -153
- package/docs/pi-subagents-diagrams.md +0 -183
- package/src/adaptive-scheduler.ts +0 -224
- package/src/admission-benchmark.ts +0 -95
- package/src/admission-policy.ts +0 -78
- package/src/agent-projection.ts +0 -53
- package/src/agents/built-ins.ts +0 -71
- package/src/agents/catalog.ts +0 -241
- package/src/agents/discovery.ts +0 -265
- package/src/agents/types.ts +0 -100
- package/src/agents.ts +0 -51
- package/src/async-subagent-benchmark.ts +0 -532
- package/src/auto-transport.ts +0 -121
- package/src/blocking-status.ts +0 -63
- package/src/cached-module-loader.ts +0 -18
- package/src/capabilities.ts +0 -145
- package/src/capability-grant.ts +0 -115
- package/src/capability-router.ts +0 -107
- package/src/child-peer-bridge.ts +0 -124
- package/src/child-peer-tools.ts +0 -132
- package/src/completion-delivery.ts +0 -409
- package/src/completion-render.ts +0 -190
- package/src/completion-requirement.ts +0 -479
- package/src/completion-routing.ts +0 -24
- package/src/config-registration.ts +0 -114
- package/src/config-status.ts +0 -217
- package/src/config-ui.ts +0 -983
- package/src/consult-policy.ts +0 -15
- package/src/consult-registration.ts +0 -125
- package/src/consult-render.ts +0 -194
- package/src/consult-resources.ts +0 -51
- package/src/consult-tool.ts +0 -95
- package/src/consult.ts +0 -566
- package/src/context.ts +0 -126
- package/src/create-stateful-transport.ts +0 -157
- package/src/cwd-policy.ts +0 -183
- package/src/delegation-contract.ts +0 -463
- package/src/execution/budget.ts +0 -56
- package/src/execution/runtime-policy.ts +0 -19
- package/src/execution-plan.ts +0 -322
- package/src/execution-ui.ts +0 -259
- package/src/execution.ts +0 -1679
- package/src/in-process-transport.ts +0 -941
- package/src/inspect-registration.ts +0 -64
- package/src/inspect-render.ts +0 -334
- package/src/inspect-tool.ts +0 -45
- package/src/inspect.ts +0 -769
- package/src/integration-controller.ts +0 -98
- package/src/limits.ts +0 -75
- package/src/orchestration-metrics.ts +0 -116
- package/src/outcome.ts +0 -61
- package/src/panel-child-group.ts +0 -35
- package/src/panel-contract.ts +0 -343
- package/src/panel-evidence.ts +0 -59
- package/src/panel-execution.ts +0 -769
- package/src/panel-failure.ts +0 -56
- package/src/panel-planning.ts +0 -175
- package/src/panel-presets.ts +0 -3
- package/src/panel-prompts.ts +0 -132
- package/src/panel-reconciliation.ts +0 -57
- package/src/panel-render.ts +0 -103
- package/src/parallel-limit-ui.ts +0 -113
- package/src/params.ts +0 -278
- package/src/peer-communication.ts +0 -352
- package/src/peer-transport.ts +0 -49
- package/src/persistence.ts +0 -522
- package/src/pi-args.ts +0 -43
- package/src/pi-invocation.ts +0 -168
- package/src/process-control.ts +0 -43
- package/src/prompt-resources.ts +0 -38
- package/src/prompt-source-safety.ts +0 -48
- package/src/protocol.ts +0 -76
- package/src/registry-types.ts +0 -204
- package/src/registry.ts +0 -1698
- package/src/render-common.ts +0 -252
- package/src/render.ts +0 -704
- package/src/result-contract.ts +0 -431
- package/src/retained-semantic-state.ts +0 -100
- package/src/rpc-timeout-finalization.ts +0 -207
- package/src/rpc-transport-metadata.ts +0 -65
- package/src/rpc-transport.ts +0 -1035
- package/src/rpc-turn-capture.ts +0 -217
- package/src/runner-outcome.ts +0 -31
- package/src/runner-result.ts +0 -55
- package/src/runner-types.ts +0 -102
- package/src/runner-usage.ts +0 -48
- package/src/runner.ts +0 -866
- package/src/safe-text.ts +0 -67
- package/src/semantic-snapshot.ts +0 -214
- package/src/session-guidance-contract.ts +0 -399
- package/src/settings/inspection.ts +0 -302
- package/src/settings/schema.ts +0 -195
- package/src/settings-reader.ts +0 -215
- package/src/settings.ts +0 -452
- package/src/spawn-idempotency.ts +0 -68
- package/src/stateful-agent-view.ts +0 -85
- package/src/stateful-config.ts +0 -13
- package/src/stateful-guidance.ts +0 -29
- package/src/stateful-lifecycle.ts +0 -74
- package/src/stateful-limit-ui.ts +0 -249
- package/src/stateful-limits.ts +0 -96
- package/src/stateful-prompt.ts +0 -49
- package/src/stateful-registration.ts +0 -1320
- package/src/stateful-render.ts +0 -318
- package/src/stateful-safety.ts +0 -47
- package/src/stateful-tool-params.ts +0 -215
- package/src/stateful.ts +0 -12
- package/src/subagent-details.ts +0 -43
- package/src/subagents-extension.ts +0 -355
- package/src/subprocess-transport.ts +0 -145
- package/src/supervision.ts +0 -104
- package/src/task-path.ts +0 -65
- package/src/timeout-checkpoint.ts +0 -305
- package/src/timeout-finalization.ts +0 -75
- package/src/tool-schema-compatibility.ts +0 -73
- package/src/transport-types.ts +0 -74
- package/src/transport-ui.ts +0 -135
- package/src/transport.ts +0 -43
- package/src/turn-budget.ts +0 -109
- package/src/usage-format.ts +0 -42
- package/src/usage-recording-config.ts +0 -13
- package/src/usage-recording-store.ts +0 -183
- package/src/usage-recording.ts +0 -478
- package/src/verification-harness.ts +0 -516
- package/src/verification-policy.ts +0 -67
- package/src/verification-receipt.ts +0 -275
- package/src/verified-execution-benchmark.ts +0 -86
- package/src/verified-execution-contract.ts +0 -191
- package/src/verified-execution-schema.ts +0 -32
- package/src/work-item-ledger.ts +0 -1404
- package/src/work-item-persistence.ts +0 -254
- package/src/workflow-completion-controller.ts +0 -397
- package/src/workflow-planning.ts +0 -172
- package/src/workflow-tree-identity.ts +0 -289
- package/src/workflow-ui.ts +0 -69
- package/src/workflow-verification.ts +0 -296
- package/src/workspace.ts +0 -174
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
-
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
|
|
4
|
-
// src/semantic-snapshot.ts
|
|
5
|
-
import { execFile } from "node:child_process";
|
|
6
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
-
import * as fs from "node:fs";
|
|
8
|
-
import * as path from "node:path";
|
|
9
|
-
import { promisify } from "node:util";
|
|
10
|
-
var execFileAsync = promisify(execFile);
|
|
11
|
-
var SEMANTIC_SNAPSHOT_VERSION = "pi-subagents:semantic-snapshot:v1";
|
|
12
|
-
var SEMANTIC_COMPONENT_KEYS = [
|
|
13
|
-
"agent",
|
|
14
|
-
"rolePrompt",
|
|
15
|
-
"tools",
|
|
16
|
-
"model",
|
|
17
|
-
"thinkingLevel",
|
|
18
|
-
"transport",
|
|
19
|
-
"trust",
|
|
20
|
-
"repository",
|
|
21
|
-
"artifacts",
|
|
22
|
-
"workflowGeneration",
|
|
23
|
-
"schedulerPolicy"
|
|
24
|
-
];
|
|
25
|
-
async function captureRepositoryGeneration(cwd) {
|
|
26
|
-
const resolved = await fs.promises.realpath(path.resolve(cwd));
|
|
27
|
-
try {
|
|
28
|
-
const result = await execFileAsync(
|
|
29
|
-
"git",
|
|
30
|
-
["-C", resolved, "status", "--porcelain=v2", "--branch", "--untracked-files=all"],
|
|
31
|
-
{ encoding: "utf8", timeout: 2e3, maxBuffer: 256 * 1024 }
|
|
32
|
-
);
|
|
33
|
-
const lines = result.stdout.split("\n");
|
|
34
|
-
const head = lines.find((line) => line.startsWith("# branch.oid "))?.slice("# branch.oid ".length).trim();
|
|
35
|
-
if (!head || head === "(initial)") throw new Error("Repository has no stable HEAD");
|
|
36
|
-
const status = lines.filter((line) => line && !line.startsWith("# ")).join("\n");
|
|
37
|
-
return status ? { kind: "git-dirty", generation: digest({ head, status }) } : { kind: "git-commit", generation: head };
|
|
38
|
-
} catch {
|
|
39
|
-
return {
|
|
40
|
-
kind: "filesystem",
|
|
41
|
-
generation: digest({ path: resolved, failClosedNonce: randomUUID() })
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
async function captureSemanticResourceGeneration(paths) {
|
|
46
|
-
const entries = [];
|
|
47
|
-
let totalBytes = 0;
|
|
48
|
-
const visit = async (candidate, label) => {
|
|
49
|
-
if (entries.length >= 256 || totalBytes > 1024 * 1024) {
|
|
50
|
-
throw new Error("Semantic resource snapshot exceeds bounds");
|
|
51
|
-
}
|
|
52
|
-
let stat;
|
|
53
|
-
try {
|
|
54
|
-
stat = await fs.promises.lstat(candidate);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (error.code === "ENOENT") return;
|
|
57
|
-
throw error;
|
|
58
|
-
}
|
|
59
|
-
if (stat.isSymbolicLink()) return;
|
|
60
|
-
if (stat.isDirectory()) {
|
|
61
|
-
const children = (await fs.promises.readdir(candidate)).sort();
|
|
62
|
-
for (const child of children) await visit(path.join(candidate, child), `${label}/${child}`);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (!stat.isFile()) return;
|
|
66
|
-
totalBytes += stat.size;
|
|
67
|
-
if (totalBytes > 1024 * 1024) throw new Error("Semantic resource snapshot exceeds bounds");
|
|
68
|
-
entries.push({ path: label, digest: digestBytes(await fs.promises.readFile(candidate)) });
|
|
69
|
-
};
|
|
70
|
-
try {
|
|
71
|
-
for (const [index, candidate] of paths.entries()) {
|
|
72
|
-
await visit(path.resolve(candidate), `resource-${index}`);
|
|
73
|
-
}
|
|
74
|
-
return digest(entries);
|
|
75
|
-
} catch {
|
|
76
|
-
return digest({ failClosedNonce: randomUUID() });
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function captureSemanticSnapshot(input) {
|
|
80
|
-
if (!Number.isSafeInteger(input.workflowGeneration) || input.workflowGeneration < 0) {
|
|
81
|
-
throw new Error("workflowGeneration must be a non-negative safe integer");
|
|
82
|
-
}
|
|
83
|
-
const components = {
|
|
84
|
-
agent: digest({ name: input.agentName, manifest: input.agentManifest ?? null }),
|
|
85
|
-
rolePrompt: digest(input.rolePrompt),
|
|
86
|
-
tools: digest([...input.tools ?? []].sort()),
|
|
87
|
-
model: digest(input.model ?? null),
|
|
88
|
-
thinkingLevel: digest(input.thinkingLevel ?? null),
|
|
89
|
-
transport: digest(input.transport),
|
|
90
|
-
trust: digest(input.trust),
|
|
91
|
-
repository: digest(input.repository),
|
|
92
|
-
artifacts: digest(input.artifacts),
|
|
93
|
-
workflowGeneration: digest(input.workflowGeneration),
|
|
94
|
-
schedulerPolicy: digest(input.schedulerPolicy)
|
|
95
|
-
};
|
|
96
|
-
return {
|
|
97
|
-
version: SEMANTIC_SNAPSHOT_VERSION,
|
|
98
|
-
digest: digest(components),
|
|
99
|
-
components
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function isSemanticSnapshot(value) {
|
|
103
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
104
|
-
const snapshot = value;
|
|
105
|
-
return snapshot.version === SEMANTIC_SNAPSHOT_VERSION && typeof snapshot.digest === "string" && /^[a-f0-9]{64}$/u.test(snapshot.digest) && Boolean(snapshot.components) && Object.keys(snapshot.components ?? {}).length === SEMANTIC_COMPONENT_KEYS.length && SEMANTIC_COMPONENT_KEYS.every(
|
|
106
|
-
(key) => /^[a-f0-9]{64}$/u.test(snapshot.components?.[key] ?? "")
|
|
107
|
-
) && digest(snapshot.components) === snapshot.digest;
|
|
108
|
-
}
|
|
109
|
-
function evaluateSemanticCompatibility(previous, current) {
|
|
110
|
-
if (previous.version !== SEMANTIC_SNAPSHOT_VERSION || current.version !== SEMANTIC_SNAPSHOT_VERSION) {
|
|
111
|
-
return { status: "rejected", changedComponents: ["version"] };
|
|
112
|
-
}
|
|
113
|
-
if (!isSemanticSnapshot(previous) || !isSemanticSnapshot(current)) {
|
|
114
|
-
return { status: "rejected", changedComponents: ["invalid-snapshot"] };
|
|
115
|
-
}
|
|
116
|
-
if (previous.digest === current.digest) {
|
|
117
|
-
return { status: "compatible", changedComponents: [] };
|
|
118
|
-
}
|
|
119
|
-
const changedComponents = SEMANTIC_COMPONENT_KEYS.filter(
|
|
120
|
-
(key) => previous.components[key] !== current.components[key]
|
|
121
|
-
).sort();
|
|
122
|
-
const warningOnly = changedComponents.every((key) => key === "schedulerPolicy");
|
|
123
|
-
return {
|
|
124
|
-
status: warningOnly ? "warning" : "needs-revalidation",
|
|
125
|
-
changedComponents
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function digest(value) {
|
|
129
|
-
return digestBytes(stableStringify(value));
|
|
130
|
-
}
|
|
131
|
-
function digestBytes(value) {
|
|
132
|
-
return createHash("sha256").update(value).digest("hex");
|
|
133
|
-
}
|
|
134
|
-
function stableStringify(value) {
|
|
135
|
-
return JSON.stringify(sortValue(value));
|
|
136
|
-
}
|
|
137
|
-
function sortValue(value) {
|
|
138
|
-
if (Array.isArray(value)) return value.map(sortValue);
|
|
139
|
-
if (!value || typeof value !== "object") return value;
|
|
140
|
-
return Object.fromEntries(
|
|
141
|
-
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, sortValue(entry)])
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export {
|
|
146
|
-
SEMANTIC_SNAPSHOT_VERSION,
|
|
147
|
-
captureRepositoryGeneration,
|
|
148
|
-
captureSemanticResourceGeneration,
|
|
149
|
-
captureSemanticSnapshot,
|
|
150
|
-
isSemanticSnapshot,
|
|
151
|
-
evaluateSemanticCompatibility
|
|
152
|
-
};
|
|
153
|
-
//# sourceMappingURL=chunk-BOAXY55Y.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/semantic-snapshot.ts"],
|
|
4
|
-
"sourcesContent": ["import { execFile } from \"node:child_process\";\nimport { createHash, randomUUID } from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\nexport const SEMANTIC_SNAPSHOT_VERSION = \"pi-subagents:semantic-snapshot:v1\" as const;\nconst SEMANTIC_COMPONENT_KEYS = [\n\t\"agent\",\n\t\"rolePrompt\",\n\t\"tools\",\n\t\"model\",\n\t\"thinkingLevel\",\n\t\"transport\",\n\t\"trust\",\n\t\"repository\",\n\t\"artifacts\",\n\t\"workflowGeneration\",\n\t\"schedulerPolicy\",\n] as const;\n\nexport interface SemanticSnapshotInput {\n\tagentName: string;\n\tagentManifest?: unknown;\n\trolePrompt: string;\n\ttools?: string[];\n\tmodel?: string;\n\tthinkingLevel?: string;\n\ttransport: string;\n\ttrust: { kind: string; projectTrusted: boolean };\n\trepository: { kind: string; generation: string };\n\tartifacts: Record<string, string>;\n\tworkflowGeneration: number;\n\tschedulerPolicy: string;\n}\n\nexport interface SemanticSnapshot {\n\tversion: typeof SEMANTIC_SNAPSHOT_VERSION;\n\tdigest: string;\n\tcomponents: {\n\t\tagent: string;\n\t\trolePrompt: string;\n\t\ttools: string;\n\t\tmodel: string;\n\t\tthinkingLevel: string;\n\t\ttransport: string;\n\t\ttrust: string;\n\t\trepository: string;\n\t\tartifacts: string;\n\t\tworkflowGeneration: string;\n\t\tschedulerPolicy: string;\n\t};\n}\n\nexport interface RepositoryGeneration {\n\tkind: \"git-commit\" | \"git-dirty\" | \"filesystem\";\n\tgeneration: string;\n}\n\nexport interface SemanticCompatibility {\n\tstatus: \"compatible\" | \"warning\" | \"needs-revalidation\" | \"rejected\";\n\tchangedComponents: string[];\n}\n\nexport async function captureRepositoryGeneration(cwd: string): Promise<RepositoryGeneration> {\n\tconst resolved = await fs.promises.realpath(path.resolve(cwd));\n\ttry {\n\t\tconst result = await execFileAsync(\n\t\t\t\"git\",\n\t\t\t[\"-C\", resolved, \"status\", \"--porcelain=v2\", \"--branch\", \"--untracked-files=all\"],\n\t\t\t{ encoding: \"utf8\", timeout: 2_000, maxBuffer: 256 * 1024 },\n\t\t);\n\t\tconst lines = result.stdout.split(\"\\n\");\n\t\tconst head = lines\n\t\t\t.find((line) => line.startsWith(\"# branch.oid \"))\n\t\t\t?.slice(\"# branch.oid \".length)\n\t\t\t.trim();\n\t\tif (!head || head === \"(initial)\") throw new Error(\"Repository has no stable HEAD\");\n\t\tconst status = lines.filter((line) => line && !line.startsWith(\"# \")).join(\"\\n\");\n\t\treturn status\n\t\t\t? { kind: \"git-dirty\", generation: digest({ head, status }) }\n\t\t\t: { kind: \"git-commit\", generation: head };\n\t} catch {\n\t\treturn {\n\t\t\tkind: \"filesystem\",\n\t\t\tgeneration: digest({ path: resolved, failClosedNonce: randomUUID() }),\n\t\t};\n\t}\n}\n\nexport async function captureSemanticResourceGeneration(paths: string[]): Promise<string> {\n\tconst entries: Array<{ path: string; digest: string }> = [];\n\tlet totalBytes = 0;\n\tconst visit = async (candidate: string, label: string): Promise<void> => {\n\t\tif (entries.length >= 256 || totalBytes > 1024 * 1024) {\n\t\t\tthrow new Error(\"Semantic resource snapshot exceeds bounds\");\n\t\t}\n\t\tlet stat: fs.Stats;\n\t\ttry {\n\t\t\tstat = await fs.promises.lstat(candidate);\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return;\n\t\t\tthrow error;\n\t\t}\n\t\tif (stat.isSymbolicLink()) return;\n\t\tif (stat.isDirectory()) {\n\t\t\tconst children = (await fs.promises.readdir(candidate)).sort();\n\t\t\tfor (const child of children) await visit(path.join(candidate, child), `${label}/${child}`);\n\t\t\treturn;\n\t\t}\n\t\tif (!stat.isFile()) return;\n\t\ttotalBytes += stat.size;\n\t\tif (totalBytes > 1024 * 1024) throw new Error(\"Semantic resource snapshot exceeds bounds\");\n\t\tentries.push({ path: label, digest: digestBytes(await fs.promises.readFile(candidate)) });\n\t};\n\ttry {\n\t\tfor (const [index, candidate] of paths.entries()) {\n\t\t\tawait visit(path.resolve(candidate), `resource-${index}`);\n\t\t}\n\t\treturn digest(entries);\n\t} catch {\n\t\treturn digest({ failClosedNonce: randomUUID() });\n\t}\n}\n\nexport function captureSemanticSnapshot(input: SemanticSnapshotInput): SemanticSnapshot {\n\tif (!Number.isSafeInteger(input.workflowGeneration) || input.workflowGeneration < 0) {\n\t\tthrow new Error(\"workflowGeneration must be a non-negative safe integer\");\n\t}\n\tconst components = {\n\t\tagent: digest({ name: input.agentName, manifest: input.agentManifest ?? null }),\n\t\trolePrompt: digest(input.rolePrompt),\n\t\ttools: digest([...(input.tools ?? [])].sort()),\n\t\tmodel: digest(input.model ?? null),\n\t\tthinkingLevel: digest(input.thinkingLevel ?? null),\n\t\ttransport: digest(input.transport),\n\t\ttrust: digest(input.trust),\n\t\trepository: digest(input.repository),\n\t\tartifacts: digest(input.artifacts),\n\t\tworkflowGeneration: digest(input.workflowGeneration),\n\t\tschedulerPolicy: digest(input.schedulerPolicy),\n\t};\n\treturn {\n\t\tversion: SEMANTIC_SNAPSHOT_VERSION,\n\t\tdigest: digest(components),\n\t\tcomponents,\n\t};\n}\n\nexport function isSemanticSnapshot(value: unknown): value is SemanticSnapshot {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tconst snapshot = value as Partial<SemanticSnapshot>;\n\treturn (\n\t\tsnapshot.version === SEMANTIC_SNAPSHOT_VERSION &&\n\t\ttypeof snapshot.digest === \"string\" &&\n\t\t/^[a-f0-9]{64}$/u.test(snapshot.digest) &&\n\t\tBoolean(snapshot.components) &&\n\t\tObject.keys(snapshot.components ?? {}).length === SEMANTIC_COMPONENT_KEYS.length &&\n\t\tSEMANTIC_COMPONENT_KEYS.every((key) =>\n\t\t\t/^[a-f0-9]{64}$/u.test(snapshot.components?.[key] ?? \"\"),\n\t\t) &&\n\t\tdigest(snapshot.components) === snapshot.digest\n\t);\n}\n\nexport function evaluateSemanticCompatibility(\n\tprevious: SemanticSnapshot,\n\tcurrent: SemanticSnapshot,\n): SemanticCompatibility {\n\tif (\n\t\tprevious.version !== SEMANTIC_SNAPSHOT_VERSION ||\n\t\tcurrent.version !== SEMANTIC_SNAPSHOT_VERSION\n\t) {\n\t\treturn { status: \"rejected\", changedComponents: [\"version\"] };\n\t}\n\tif (!isSemanticSnapshot(previous) || !isSemanticSnapshot(current)) {\n\t\treturn { status: \"rejected\", changedComponents: [\"invalid-snapshot\"] };\n\t}\n\tif (previous.digest === current.digest) {\n\t\treturn { status: \"compatible\", changedComponents: [] };\n\t}\n\tconst changedComponents = SEMANTIC_COMPONENT_KEYS.filter(\n\t\t(key) => previous.components[key] !== current.components[key],\n\t).sort();\n\tconst warningOnly = changedComponents.every((key) => key === \"schedulerPolicy\");\n\treturn {\n\t\tstatus: warningOnly ? \"warning\" : \"needs-revalidation\",\n\t\tchangedComponents,\n\t};\n}\n\nfunction digest(value: unknown): string {\n\treturn digestBytes(stableStringify(value));\n}\n\nfunction digestBytes(value: string | Buffer): string {\n\treturn createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nfunction stableStringify(value: unknown): string {\n\treturn JSON.stringify(sortValue(value));\n}\n\nfunction sortValue(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortValue);\n\tif (!value || typeof value !== \"object\") return value;\n\treturn Object.fromEntries(\n\t\tObject.entries(value as Record<string, unknown>)\n\t\t\t.sort(([left], [right]) => left.localeCompare(right))\n\t\t\t.map(([key, entry]) => [key, sortValue(entry)]),\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;AAAA,SAAS,gBAAgB;AACzB,SAAS,YAAY,kBAAkB;AACvC,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAU,QAAQ;AAEjC,IAAM,4BAA4B;AACzC,IAAM,0BAA0B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AA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C9E,SAAO;AAAA,IACN,QAAQ,cAAc,YAAY;AAAA,IAClC;AAAA,EACD;AACD;AAEA,SAAS,OAAO,OAAwB;AACvC,SAAO,YAAY,gBAAgB,KAAK,CAAC;AAC1C;AAEA,SAAS,YAAY,OAAgC;AACpD,SAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,KAAK;AACvD;AAEA,SAAS,gBAAgB,OAAwB;AAChD,SAAO,KAAK,UAAU,UAAU,KAAK,CAAC;AACvC;AAEA,SAAS,UAAU,OAAyB;AAC3C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,SAAS;AACpD,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,SAAO,OAAO;AAAA,IACb,OAAO,QAAQ,KAAgC,EAC7C,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,MAAM,KAAK,cAAc,KAAK,CAAC,EACnD,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,EAChD;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
-
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
SUBAGENT_SETTINGS_FILE,
|
|
5
|
-
hasOwn,
|
|
6
|
-
isPlainObject,
|
|
7
|
-
isPositiveInteger,
|
|
8
|
-
normalizeSubagentSettings,
|
|
9
|
-
pathEntryExists,
|
|
10
|
-
resolveSubagentSettingsPaths
|
|
11
|
-
} from "./chunk-TMZRHIIK.ts";
|
|
12
|
-
import {
|
|
13
|
-
STATEFUL_LIMIT_FIELDS,
|
|
14
|
-
isValidStatefulLimit,
|
|
15
|
-
resolveStatefulLimits,
|
|
16
|
-
statefulLimitDefinition
|
|
17
|
-
} from "./chunk-VDG7LTYE.ts";
|
|
18
|
-
import {
|
|
19
|
-
MAX_CONFIGURABLE_PARALLEL_TASKS
|
|
20
|
-
} from "./chunk-H3FP6DLR.ts";
|
|
21
|
-
|
|
22
|
-
// src/settings.ts
|
|
23
|
-
import { randomUUID } from "node:crypto";
|
|
24
|
-
import * as fs from "node:fs";
|
|
25
|
-
import { createRequire } from "node:module";
|
|
26
|
-
import * as path from "node:path";
|
|
27
|
-
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
28
|
-
var SETTINGS_FILE = SUBAGENT_SETTINGS_FILE;
|
|
29
|
-
var require2 = createRequire(import.meta.url);
|
|
30
|
-
var SETTINGS_LOCK_FS_ADAPTER = {
|
|
31
|
-
mkdir: fs.mkdir,
|
|
32
|
-
mkdirSync: fs.mkdirSync,
|
|
33
|
-
realpath: fs.realpath,
|
|
34
|
-
realpathSync: fs.realpathSync,
|
|
35
|
-
rmdir: fs.rmdir,
|
|
36
|
-
rmdirSync: fs.rmdirSync,
|
|
37
|
-
stat: fs.stat,
|
|
38
|
-
statSync: fs.statSync,
|
|
39
|
-
utimes: fs.utimes,
|
|
40
|
-
utimesSync: fs.utimesSync
|
|
41
|
-
};
|
|
42
|
-
function updateDelegationWorkflowSetting(value) {
|
|
43
|
-
withSettingsMutationLock(() => {
|
|
44
|
-
const update = readSettingsObjectForUpdate();
|
|
45
|
-
const raw = update.document;
|
|
46
|
-
const blocking = raw.blocking;
|
|
47
|
-
if (blocking !== void 0 && !isPlainObject(blocking)) {
|
|
48
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} blocking settings`);
|
|
49
|
-
}
|
|
50
|
-
const stateful = raw.stateful;
|
|
51
|
-
if (stateful !== void 0 && !isPlainObject(stateful)) {
|
|
52
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);
|
|
53
|
-
}
|
|
54
|
-
writeSettingsObjectUnlocked(
|
|
55
|
-
{
|
|
56
|
-
...raw,
|
|
57
|
-
blocking: {
|
|
58
|
-
...blocking ?? {},
|
|
59
|
-
enabled: value !== "async-only"
|
|
60
|
-
},
|
|
61
|
-
stateful: {
|
|
62
|
-
...stateful ?? {},
|
|
63
|
-
enabled: value !== "blocking-only"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
update.replaceCanonical
|
|
67
|
-
);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
function updateStatefulTransportSetting(value) {
|
|
71
|
-
if (!["subprocess", "in-process", "rpc", "auto"].includes(value)) {
|
|
72
|
-
throw new Error(`Unsupported stateful transport: ${value}`);
|
|
73
|
-
}
|
|
74
|
-
withSettingsMutationLock(() => {
|
|
75
|
-
const update = readSettingsObjectForUpdate();
|
|
76
|
-
const raw = update.document;
|
|
77
|
-
const stateful = raw.stateful;
|
|
78
|
-
if (stateful !== void 0 && !isPlainObject(stateful)) {
|
|
79
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);
|
|
80
|
-
}
|
|
81
|
-
writeSettingsObjectUnlocked(
|
|
82
|
-
{
|
|
83
|
-
...raw,
|
|
84
|
-
stateful: { ...stateful ?? {}, transport: value }
|
|
85
|
-
},
|
|
86
|
-
update.replaceCanonical
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function updateCompletionDeliverySetting(value) {
|
|
91
|
-
withSettingsMutationLock(() => {
|
|
92
|
-
const update = readSettingsObjectForUpdate();
|
|
93
|
-
const raw = update.document;
|
|
94
|
-
const stateful = raw.stateful;
|
|
95
|
-
if (stateful !== void 0 && !isPlainObject(stateful)) {
|
|
96
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);
|
|
97
|
-
}
|
|
98
|
-
writeSettingsObjectUnlocked(
|
|
99
|
-
{
|
|
100
|
-
...raw,
|
|
101
|
-
stateful: {
|
|
102
|
-
...stateful ?? {},
|
|
103
|
-
completionDelivery: value
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
update.replaceCanonical
|
|
107
|
-
);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
function updateUsageRecordingSetting(enabled) {
|
|
111
|
-
withSettingsMutationLock(() => {
|
|
112
|
-
const update = readSettingsObjectForUpdate();
|
|
113
|
-
const raw = update.document;
|
|
114
|
-
const usageRecording = raw.usageRecording;
|
|
115
|
-
if (usageRecording !== void 0 && !isPlainObject(usageRecording)) {
|
|
116
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} usageRecording settings`);
|
|
117
|
-
}
|
|
118
|
-
writeSettingsObjectUnlocked(
|
|
119
|
-
{
|
|
120
|
-
...raw,
|
|
121
|
-
usageRecording: { ...usageRecording ?? {}, enabled }
|
|
122
|
-
},
|
|
123
|
-
update.replaceCanonical
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function updateBlockingMaxParallelTasksSetting(value) {
|
|
128
|
-
if (!isPositiveInteger(value) || value > MAX_CONFIGURABLE_PARALLEL_TASKS) {
|
|
129
|
-
throw new Error(
|
|
130
|
-
`Maximum parallel tasks must be an integer between 1 and ${MAX_CONFIGURABLE_PARALLEL_TASKS}`
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
withSettingsMutationLock(() => {
|
|
134
|
-
const update = readSettingsObjectForUpdate();
|
|
135
|
-
const raw = update.document;
|
|
136
|
-
const blocking = raw.blocking;
|
|
137
|
-
if (blocking !== void 0 && !isPlainObject(blocking)) {
|
|
138
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} blocking settings`);
|
|
139
|
-
}
|
|
140
|
-
writeSettingsObjectUnlocked(
|
|
141
|
-
{
|
|
142
|
-
...raw,
|
|
143
|
-
blocking: {
|
|
144
|
-
...blocking ?? {},
|
|
145
|
-
maxParallelTasks: value
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
update.replaceCanonical
|
|
149
|
-
);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
function updateStatefulLimitSetting(field, value, expected) {
|
|
153
|
-
if (!isValidStatefulLimit(field, value)) {
|
|
154
|
-
throw new Error(
|
|
155
|
-
`${field} must be a safe integer greater than or equal to ${statefulLimitDefinition(field).minimum}`
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
withSettingsMutationLock(() => {
|
|
159
|
-
const update = readSettingsObjectForUpdate();
|
|
160
|
-
const raw = update.document;
|
|
161
|
-
const stateful = raw.stateful;
|
|
162
|
-
if (stateful !== void 0 && !isPlainObject(stateful)) {
|
|
163
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);
|
|
164
|
-
}
|
|
165
|
-
const normalized = normalizeSubagentSettings(raw);
|
|
166
|
-
if (!normalized) throw new Error(`Cannot update invalid ${SETTINGS_FILE}`);
|
|
167
|
-
if (expected && !sameStatefulLimits(resolveStatefulLimits(normalized.stateful), expected)) {
|
|
168
|
-
throw new Error("Detached limit settings changed; reopen settings and retry");
|
|
169
|
-
}
|
|
170
|
-
writeSettingsObjectUnlocked(
|
|
171
|
-
{
|
|
172
|
-
...raw,
|
|
173
|
-
stateful: { ...stateful ?? {}, [field]: value }
|
|
174
|
-
},
|
|
175
|
-
update.replaceCanonical
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function updateConsultResourceSetting(value) {
|
|
180
|
-
withSettingsMutationLock(() => {
|
|
181
|
-
const update = readSettingsObjectForUpdate();
|
|
182
|
-
const raw = update.document;
|
|
183
|
-
const consult = raw.consult;
|
|
184
|
-
if (consult !== void 0 && !isPlainObject(consult)) {
|
|
185
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} consult settings`);
|
|
186
|
-
}
|
|
187
|
-
writeSettingsObjectUnlocked(
|
|
188
|
-
{
|
|
189
|
-
...raw,
|
|
190
|
-
consult: {
|
|
191
|
-
...consult ?? {},
|
|
192
|
-
resources: value
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
update.replaceCanonical
|
|
196
|
-
);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
function updateCwdPolicySetting(field, value) {
|
|
200
|
-
withSettingsMutationLock(() => {
|
|
201
|
-
const update = readSettingsObjectForUpdate();
|
|
202
|
-
const raw = update.document;
|
|
203
|
-
const cwdPolicy = raw.cwdPolicy;
|
|
204
|
-
if (cwdPolicy !== void 0 && !isPlainObject(cwdPolicy)) {
|
|
205
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} cwdPolicy settings`);
|
|
206
|
-
}
|
|
207
|
-
writeSettingsObjectUnlocked(
|
|
208
|
-
{
|
|
209
|
-
...raw,
|
|
210
|
-
cwdPolicy: { ...cwdPolicy ?? {}, [field]: value }
|
|
211
|
-
},
|
|
212
|
-
update.replaceCanonical
|
|
213
|
-
);
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
function updateAgentToolsSetting(name, tools) {
|
|
217
|
-
updateAgentSettingsPatch({ [name]: { tools } });
|
|
218
|
-
}
|
|
219
|
-
function updateAgentSettingsPatch(patches) {
|
|
220
|
-
withSettingsMutationLock(() => {
|
|
221
|
-
const update = readSettingsObjectForUpdate();
|
|
222
|
-
const raw = update.document;
|
|
223
|
-
const rawAgents = raw.agents;
|
|
224
|
-
if (rawAgents !== void 0 && !isPlainObject(rawAgents)) {
|
|
225
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} agent settings`);
|
|
226
|
-
}
|
|
227
|
-
const agents = { ...rawAgents ?? {} };
|
|
228
|
-
for (const [name, patch] of Object.entries(patches)) {
|
|
229
|
-
const rawAgent = hasOwn(agents, name) ? agents[name] : void 0;
|
|
230
|
-
if (rawAgent !== void 0 && !isPlainObject(rawAgent)) {
|
|
231
|
-
throw new Error(`Cannot update invalid ${SETTINGS_FILE} settings for ${name}`);
|
|
232
|
-
}
|
|
233
|
-
const agent = { ...rawAgent ?? {} };
|
|
234
|
-
for (const field of ["tools", "model", "thinkingLevel", "timeoutMs"]) {
|
|
235
|
-
if (!hasOwn(patch, field)) continue;
|
|
236
|
-
const value = patch[field];
|
|
237
|
-
if (value === void 0) delete agent[field];
|
|
238
|
-
else
|
|
239
|
-
Object.defineProperty(agent, field, {
|
|
240
|
-
value,
|
|
241
|
-
enumerable: true,
|
|
242
|
-
configurable: true,
|
|
243
|
-
writable: true
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
if (Object.keys(agent).length > 0) {
|
|
247
|
-
Object.defineProperty(agents, name, {
|
|
248
|
-
value: agent,
|
|
249
|
-
enumerable: true,
|
|
250
|
-
configurable: true,
|
|
251
|
-
writable: true
|
|
252
|
-
});
|
|
253
|
-
} else {
|
|
254
|
-
delete agents[name];
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const normalized = normalizeSubagentSettings({
|
|
258
|
-
...raw,
|
|
259
|
-
...Object.keys(agents).length > 0 ? { agents } : {}
|
|
260
|
-
});
|
|
261
|
-
if (!normalized) throw new Error(`Cannot update invalid ${SETTINGS_FILE} agent settings`);
|
|
262
|
-
const updated = { ...raw };
|
|
263
|
-
if (Object.keys(agents).length > 0) updated.agents = agents;
|
|
264
|
-
else delete updated.agents;
|
|
265
|
-
writeSettingsObjectUnlocked(updated, update.replaceCanonical);
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
function readSettingsObjectForUpdate() {
|
|
269
|
-
const { canonicalPath, activePath } = resolveSubagentSettingsPaths();
|
|
270
|
-
if (activePath === void 0) return { document: {}, replaceCanonical: false };
|
|
271
|
-
const activeFile = path.basename(activePath);
|
|
272
|
-
let parsed;
|
|
273
|
-
try {
|
|
274
|
-
parsed = JSON.parse(fs.readFileSync(activePath, "utf8"));
|
|
275
|
-
} catch {
|
|
276
|
-
throw new Error(`Cannot update malformed ${activeFile}`);
|
|
277
|
-
}
|
|
278
|
-
if (!isPlainObject(parsed) || !normalizeSubagentSettings(parsed)) {
|
|
279
|
-
throw new Error(`Cannot update invalid ${activeFile}`);
|
|
280
|
-
}
|
|
281
|
-
return { document: parsed, replaceCanonical: activePath === canonicalPath };
|
|
282
|
-
}
|
|
283
|
-
function writeSettingsObjectUnlocked(settings, replaceCanonical) {
|
|
284
|
-
const agentDir = getAgentDir();
|
|
285
|
-
fs.mkdirSync(agentDir, { recursive: true });
|
|
286
|
-
const configPath = path.join(agentDir, SETTINGS_FILE);
|
|
287
|
-
const tempFile = path.join(agentDir, `.${SETTINGS_FILE}.${randomUUID()}.tmp`);
|
|
288
|
-
const firstCanonicalPublication = !(replaceCanonical ?? pathEntryExists(configPath));
|
|
289
|
-
try {
|
|
290
|
-
fs.writeFileSync(tempFile, `${JSON.stringify(settings, null, " ")}
|
|
291
|
-
`, {
|
|
292
|
-
encoding: "utf8",
|
|
293
|
-
flag: "wx"
|
|
294
|
-
});
|
|
295
|
-
if (firstCanonicalPublication && pathEntryExists(configPath)) {
|
|
296
|
-
throw new Error(`${SETTINGS_FILE} was created concurrently; reopen settings and retry`);
|
|
297
|
-
}
|
|
298
|
-
fs.renameSync(tempFile, configPath);
|
|
299
|
-
} finally {
|
|
300
|
-
try {
|
|
301
|
-
fs.rmSync(tempFile, { force: true });
|
|
302
|
-
} catch {
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
function withSettingsMutationLock(mutate) {
|
|
307
|
-
const lockfile = require2("proper-lockfile");
|
|
308
|
-
const agentDir = getAgentDir();
|
|
309
|
-
fs.mkdirSync(agentDir, { recursive: true });
|
|
310
|
-
const configPath = path.join(agentDir, SETTINGS_FILE);
|
|
311
|
-
const release = lockfile.lockSync(configPath, {
|
|
312
|
-
fs: SETTINGS_LOCK_FS_ADAPTER,
|
|
313
|
-
lockfilePath: `${configPath}.mutation-lock`,
|
|
314
|
-
realpath: false
|
|
315
|
-
});
|
|
316
|
-
try {
|
|
317
|
-
return mutate();
|
|
318
|
-
} finally {
|
|
319
|
-
release();
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
function sameStatefulLimits(left, right) {
|
|
323
|
-
return STATEFUL_LIMIT_FIELDS.every((field) => left[field] === right[field]);
|
|
324
|
-
}
|
|
325
|
-
function uniqueToolNames(tools) {
|
|
326
|
-
return [...new Set(tools)];
|
|
327
|
-
}
|
|
328
|
-
function sameToolSet(left, right) {
|
|
329
|
-
const leftSet = new Set(left);
|
|
330
|
-
const rightSet = new Set(right);
|
|
331
|
-
if (leftSet.size !== rightSet.size) return false;
|
|
332
|
-
return [...leftSet].every((tool) => rightSet.has(tool));
|
|
333
|
-
}
|
|
334
|
-
function resolveSubagentThinkingLevel(agents, agentName, topLevelThinkingLevel, localThinkingLevel) {
|
|
335
|
-
return localThinkingLevel ?? topLevelThinkingLevel ?? agents.find((agent) => agent.name === agentName)?.thinkingLevel;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
export {
|
|
339
|
-
updateDelegationWorkflowSetting,
|
|
340
|
-
updateStatefulTransportSetting,
|
|
341
|
-
updateCompletionDeliverySetting,
|
|
342
|
-
updateUsageRecordingSetting,
|
|
343
|
-
updateBlockingMaxParallelTasksSetting,
|
|
344
|
-
updateStatefulLimitSetting,
|
|
345
|
-
updateConsultResourceSetting,
|
|
346
|
-
updateCwdPolicySetting,
|
|
347
|
-
updateAgentToolsSetting,
|
|
348
|
-
updateAgentSettingsPatch,
|
|
349
|
-
uniqueToolNames,
|
|
350
|
-
sameToolSet,
|
|
351
|
-
resolveSubagentThinkingLevel
|
|
352
|
-
};
|
|
353
|
-
//# sourceMappingURL=chunk-D4CR7T73.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/settings.ts"],
|
|
4
|
-
"sourcesContent": ["import { randomUUID } from \"node:crypto\";\nimport * as fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport * as path from \"node:path\";\nimport { getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport type {\n\tAgentConfig,\n\tCompletionDelivery,\n\tConsultationCwdPolicy,\n\tConsultResourcePolicy,\n\tDelegationCwdPolicy,\n\tSubagentAgentConfig,\n\tSubagentSettings,\n\tSubagentThinkingLevel,\n\tSubagentTransportKind,\n} from \"./agents/types.js\";\nimport { MAX_CONFIGURABLE_PARALLEL_TASKS } from \"./limits.js\";\nimport type { DelegationWorkflow } from \"./settings/inspection.js\";\nimport {\n\thasOwn,\n\tisPlainObject,\n\tisPositiveInteger,\n\tnormalizeSubagentSettings,\n} from \"./settings/schema.js\";\nimport {\n\tpathEntryExists,\n\tresolveSubagentSettingsPaths,\n\tSUBAGENT_SETTINGS_FILE,\n} from \"./settings-reader.js\";\nimport {\n\tisValidStatefulLimit,\n\tresolveStatefulLimits,\n\tSTATEFUL_LIMIT_FIELDS,\n\ttype StatefulLimitField,\n\ttype StatefulLimits,\n\tstatefulLimitDefinition,\n} from \"./stateful-limits.js\";\n\nexport {\n\ttype BlockingParallelLimitSettingsSnapshot,\n\ttype CompletionDeliverySettingsSnapshot,\n\ttype ConsultResourceSettingsSnapshot,\n\ttype CwdPolicyFieldSnapshot,\n\ttype CwdPolicySettingsSnapshot,\n\tconsumeSubagentSettingsNotice,\n\tDEFAULT_CONSULT_RESOURCE_POLICY,\n\tDEFAULT_CONSULTATION_CWD_POLICY,\n\tDEFAULT_DELEGATION_CWD_POLICY,\n\ttype DelegationWorkflow,\n\ttype DelegationWorkflowSettingsSnapshot,\n\thasOwn,\n\tinspectBlockingParallelLimitSettings,\n\tinspectCompletionDeliverySettings,\n\tinspectConsultResourceSettings,\n\tinspectCwdPolicySettings,\n\tinspectDelegationWorkflowSettings,\n\tinspectStatefulLimitSettings,\n\tinspectStatefulTransportSettings,\n\tinspectSubagentSettings,\n\tinspectUsageRecordingSettings,\n\tnormalizeAgentSettings,\n\tnormalizeSubagentSettings,\n\treadSubagentSettings,\n\tresolveBlockingMaxParallelTasks,\n\tresolveDelegationWorkflow,\n\ttype StatefulLimitFieldSnapshot,\n\ttype StatefulLimitSettingsSnapshot,\n\ttype StatefulTransportSettingsSnapshot,\n\ttype SubagentSettingsSnapshot,\n\tsubagentSettingsFilePath,\n\ttype UsageRecordingSettingsSnapshot,\n} from \"./settings-reader.js\";\n\nconst SETTINGS_FILE = SUBAGENT_SETTINGS_FILE;\nconst require = createRequire(import.meta.url);\n\nconst SETTINGS_LOCK_FS_ADAPTER = {\n\tmkdir: fs.mkdir,\n\tmkdirSync: fs.mkdirSync,\n\trealpath: fs.realpath,\n\trealpathSync: fs.realpathSync,\n\trmdir: fs.rmdir,\n\trmdirSync: fs.rmdirSync,\n\tstat: fs.stat,\n\tstatSync: fs.statSync,\n\tutimes: fs.utimes,\n\tutimesSync: fs.utimesSync,\n};\n\nexport function saveSubagentConfig(settings: SubagentSettings): void {\n\twriteSettingsObject(settings);\n}\n\nexport function updateDelegationWorkflowSetting(\n\tvalue: Exclude<DelegationWorkflow, \"disabled\">,\n): void {\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst blocking = raw.blocking;\n\t\tif (blocking !== undefined && !isPlainObject(blocking)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} blocking settings`);\n\t\t}\n\t\tconst stateful = raw.stateful;\n\t\tif (stateful !== undefined && !isPlainObject(stateful)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tblocking: {\n\t\t\t\t\t...(blocking ?? {}),\n\t\t\t\t\tenabled: value !== \"async-only\",\n\t\t\t\t},\n\t\t\t\tstateful: {\n\t\t\t\t\t...(stateful ?? {}),\n\t\t\t\t\tenabled: value !== \"blocking-only\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateStatefulTransportSetting(value: SubagentTransportKind): void {\n\tif (![\"subprocess\", \"in-process\", \"rpc\", \"auto\"].includes(value)) {\n\t\tthrow new Error(`Unsupported stateful transport: ${value}`);\n\t}\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst stateful = raw.stateful;\n\t\tif (stateful !== undefined && !isPlainObject(stateful)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tstateful: { ...(stateful ?? {}), transport: value },\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateCompletionDeliverySetting(value: CompletionDelivery): void {\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst stateful = raw.stateful;\n\t\tif (stateful !== undefined && !isPlainObject(stateful)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tstateful: {\n\t\t\t\t\t...(stateful ?? {}),\n\t\t\t\t\tcompletionDelivery: value,\n\t\t\t\t},\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateUsageRecordingSetting(enabled: boolean): void {\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst usageRecording = raw.usageRecording;\n\t\tif (usageRecording !== undefined && !isPlainObject(usageRecording)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} usageRecording settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tusageRecording: { ...(usageRecording ?? {}), enabled },\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateBlockingMaxParallelTasksSetting(value: number): void {\n\tif (!isPositiveInteger(value) || value > MAX_CONFIGURABLE_PARALLEL_TASKS) {\n\t\tthrow new Error(\n\t\t\t`Maximum parallel tasks must be an integer between 1 and ${MAX_CONFIGURABLE_PARALLEL_TASKS}`,\n\t\t);\n\t}\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst blocking = raw.blocking;\n\t\tif (blocking !== undefined && !isPlainObject(blocking)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} blocking settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tblocking: {\n\t\t\t\t\t...(blocking ?? {}),\n\t\t\t\t\tmaxParallelTasks: value,\n\t\t\t\t},\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateStatefulLimitSetting(\n\tfield: StatefulLimitField,\n\tvalue: number,\n\texpected?: StatefulLimits,\n): void {\n\tif (!isValidStatefulLimit(field, value)) {\n\t\tthrow new Error(\n\t\t\t`${field} must be a safe integer greater than or equal to ${statefulLimitDefinition(field).minimum}`,\n\t\t);\n\t}\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst stateful = raw.stateful;\n\t\tif (stateful !== undefined && !isPlainObject(stateful)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} stateful settings`);\n\t\t}\n\t\tconst normalized = normalizeSubagentSettings(raw);\n\t\tif (!normalized) throw new Error(`Cannot update invalid ${SETTINGS_FILE}`);\n\t\tif (expected && !sameStatefulLimits(resolveStatefulLimits(normalized.stateful), expected)) {\n\t\t\tthrow new Error(\"Detached limit settings changed; reopen settings and retry\");\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tstateful: { ...(stateful ?? {}), [field]: value },\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateConsultResourceSetting(value: ConsultResourcePolicy): void {\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst consult = raw.consult;\n\t\tif (consult !== undefined && !isPlainObject(consult)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} consult settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tconsult: {\n\t\t\t\t\t...(consult ?? {}),\n\t\t\t\t\tresources: value,\n\t\t\t\t},\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport function updateCwdPolicySetting(field: \"consultation\", value: ConsultationCwdPolicy): void;\nexport function updateCwdPolicySetting(field: \"delegation\", value: DelegationCwdPolicy): void;\nexport function updateCwdPolicySetting(\n\tfield: \"consultation\" | \"delegation\",\n\tvalue: ConsultationCwdPolicy | DelegationCwdPolicy,\n): void {\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst cwdPolicy = raw.cwdPolicy;\n\t\tif (cwdPolicy !== undefined && !isPlainObject(cwdPolicy)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} cwdPolicy settings`);\n\t\t}\n\t\twriteSettingsObjectUnlocked(\n\t\t\t{\n\t\t\t\t...raw,\n\t\t\t\tcwdPolicy: { ...(cwdPolicy ?? {}), [field]: value },\n\t\t\t},\n\t\t\tupdate.replaceCanonical,\n\t\t);\n\t});\n}\n\nexport type AgentSettingsPatch = {\n\ttools?: string[] | undefined;\n\tmodel?: string | null | undefined;\n\tthinkingLevel?: SubagentThinkingLevel | null | undefined;\n\ttimeoutMs?: number | null | undefined;\n};\n\nexport function updateAgentToolsSetting(name: string, tools: string[] | undefined): void {\n\tupdateAgentSettingsPatch({ [name]: { tools } });\n}\n\nexport function updateAgentSettingsPatch(patches: Record<string, AgentSettingsPatch>): void {\n\twithSettingsMutationLock(() => {\n\t\tconst update = readSettingsObjectForUpdate();\n\t\tconst raw = update.document;\n\t\tconst rawAgents = raw.agents;\n\t\tif (rawAgents !== undefined && !isPlainObject(rawAgents)) {\n\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} agent settings`);\n\t\t}\n\t\tconst agents = { ...(rawAgents ?? {}) };\n\t\tfor (const [name, patch] of Object.entries(patches)) {\n\t\t\tconst rawAgent = hasOwn(agents, name) ? agents[name] : undefined;\n\t\t\tif (rawAgent !== undefined && !isPlainObject(rawAgent)) {\n\t\t\t\tthrow new Error(`Cannot update invalid ${SETTINGS_FILE} settings for ${name}`);\n\t\t\t}\n\t\t\tconst agent = { ...(rawAgent ?? {}) };\n\t\t\tfor (const field of [\"tools\", \"model\", \"thinkingLevel\", \"timeoutMs\"] as const) {\n\t\t\t\tif (!hasOwn(patch, field)) continue;\n\t\t\t\tconst value = patch[field];\n\t\t\t\tif (value === undefined) delete agent[field];\n\t\t\t\telse\n\t\t\t\t\tObject.defineProperty(agent, field, {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\twritable: true,\n\t\t\t\t\t});\n\t\t\t}\n\t\t\tif (Object.keys(agent).length > 0) {\n\t\t\t\tObject.defineProperty(agents, name, {\n\t\t\t\t\tvalue: agent,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tdelete agents[name];\n\t\t\t}\n\t\t}\n\n\t\tconst normalized = normalizeSubagentSettings({\n\t\t\t...raw,\n\t\t\t...(Object.keys(agents).length > 0 ? { agents } : {}),\n\t\t});\n\t\tif (!normalized) throw new Error(`Cannot update invalid ${SETTINGS_FILE} agent settings`);\n\t\tconst updated = { ...raw };\n\t\tif (Object.keys(agents).length > 0) updated.agents = agents;\n\t\telse delete updated.agents;\n\t\twriteSettingsObjectUnlocked(updated, update.replaceCanonical);\n\t});\n}\n\ninterface SettingsObjectForUpdate {\n\tdocument: Record<string, unknown>;\n\treplaceCanonical: boolean;\n}\n\nfunction readSettingsObjectForUpdate(): SettingsObjectForUpdate {\n\tconst { canonicalPath, activePath } = resolveSubagentSettingsPaths();\n\tif (activePath === undefined) return { document: {}, replaceCanonical: false };\n\tconst activeFile = path.basename(activePath);\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(fs.readFileSync(activePath, \"utf8\"));\n\t} catch {\n\t\tthrow new Error(`Cannot update malformed ${activeFile}`);\n\t}\n\tif (!isPlainObject(parsed) || !normalizeSubagentSettings(parsed)) {\n\t\tthrow new Error(`Cannot update invalid ${activeFile}`);\n\t}\n\treturn { document: parsed, replaceCanonical: activePath === canonicalPath };\n}\n\nfunction writeSettingsObject(settings: object, replaceCanonical?: boolean): void {\n\twithSettingsMutationLock(() => writeSettingsObjectUnlocked(settings, replaceCanonical));\n}\n\nfunction writeSettingsObjectUnlocked(settings: object, replaceCanonical?: boolean): void {\n\tconst agentDir = getAgentDir();\n\tfs.mkdirSync(agentDir, { recursive: true });\n\tconst configPath = path.join(agentDir, SETTINGS_FILE);\n\tconst tempFile = path.join(agentDir, `.${SETTINGS_FILE}.${randomUUID()}.tmp`);\n\t// Updates seeded from a missing or legacy document must remain exclusive even if the\n\t// canonical path appears after the read and before publication.\n\tconst firstCanonicalPublication = !(replaceCanonical ?? pathEntryExists(configPath));\n\ttry {\n\t\tfs.writeFileSync(tempFile, `${JSON.stringify(settings, null, \"\\t\")}\\n`, {\n\t\t\tencoding: \"utf8\",\n\t\t\tflag: \"wx\",\n\t\t});\n\t\tif (firstCanonicalPublication && pathEntryExists(configPath)) {\n\t\t\tthrow new Error(`${SETTINGS_FILE} was created concurrently; reopen settings and retry`);\n\t\t}\n\t\tfs.renameSync(tempFile, configPath);\n\t} finally {\n\t\ttry {\n\t\t\tfs.rmSync(tempFile, { force: true });\n\t\t} catch {\n\t\t\t// Preserve the save result if best-effort temp cleanup fails.\n\t\t}\n\t}\n}\n\nfunction withSettingsMutationLock<T>(mutate: () => T): T {\n\tconst lockfile = require(\"proper-lockfile\") as typeof import(\"proper-lockfile\");\n\tconst agentDir = getAgentDir();\n\tfs.mkdirSync(agentDir, { recursive: true });\n\tconst configPath = path.join(agentDir, SETTINGS_FILE);\n\tconst release = lockfile.lockSync(configPath, {\n\t\tfs: SETTINGS_LOCK_FS_ADAPTER,\n\t\tlockfilePath: `${configPath}.mutation-lock`,\n\t\trealpath: false,\n\t});\n\ttry {\n\t\treturn mutate();\n\t} finally {\n\t\trelease();\n\t}\n}\n\nfunction sameStatefulLimits(left: StatefulLimits, right: StatefulLimits): boolean {\n\treturn STATEFUL_LIMIT_FIELDS.every((field) => left[field] === right[field]);\n}\n\nexport function uniqueToolNames(tools: string[]): string[] {\n\treturn [...new Set(tools)];\n}\n\nexport function sameToolSet(left: string[], right: string[]): boolean {\n\tconst leftSet = new Set(left);\n\tconst rightSet = new Set(right);\n\tif (leftSet.size !== rightSet.size) return false;\n\treturn [...leftSet].every((tool) => rightSet.has(tool));\n}\n\nexport function resolveSubagentThinkingLevel(\n\tagents: readonly Pick<AgentConfig, \"name\" | \"thinkingLevel\">[],\n\tagentName: string,\n\ttopLevelThinkingLevel?: SubagentThinkingLevel,\n\tlocalThinkingLevel?: SubagentThinkingLevel,\n): SubagentThinkingLevel | undefined {\n\treturn (\n\t\tlocalThinkingLevel ??\n\t\ttopLevelThinkingLevel ??\n\t\tagents.find((agent) => agent.name === agentName)?.thinkingLevel\n\t);\n}\n\nexport function hasAnyAgentOverride(config: SubagentAgentConfig): boolean {\n\treturn (\n\t\thasOwn(config, \"tools\") ||\n\t\thasOwn(config, \"model\") ||\n\t\thasOwn(config, \"thinkingLevel\") ||\n\t\thasOwn(config, \"timeoutMs\")\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,YAAY,QAAQ;AACpB,SAAS,q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