@caupulican/pi-adaptative 0.90.6 → 0.90.7
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 +8 -0
- package/dist/core/agent-session-contracts.d.ts +2 -0
- package/dist/core/agent-session-contracts.d.ts.map +1 -1
- package/dist/core/agent-session-contracts.js.map +1 -1
- package/dist/core/agent-session.d.ts +5 -10
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +33 -10
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +3 -7
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.d.ts +2 -0
- package/dist/core/delegation/worker-notification-coordinator.d.ts.map +1 -1
- package/dist/core/delegation/worker-notification-coordinator.js +9 -20
- package/dist/core/delegation/worker-notification-coordinator.js.map +1 -1
- package/dist/core/durable-custom-message-turn-controller.d.ts +24 -0
- package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -0
- package/dist/core/durable-custom-message-turn-controller.js +60 -0
- package/dist/core/durable-custom-message-turn-controller.js.map +1 -0
- package/dist/core/foreground-terminal-handoff-controller.d.ts +13 -7
- package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
- package/dist/core/foreground-terminal-handoff-controller.js +48 -10
- package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
- package/dist/core/goal-loop-controller.d.ts +5 -9
- package/dist/core/goal-loop-controller.d.ts.map +1 -1
- package/dist/core/goal-loop-controller.js +9 -6
- package/dist/core/goal-loop-controller.js.map +1 -1
- package/dist/core/goals/goal-session-controller.d.ts +30 -1
- package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
- package/dist/core/goals/goal-session-controller.js +155 -18
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/goals/goal-state.d.ts +6 -7
- package/dist/core/goals/goal-state.d.ts.map +1 -1
- package/dist/core/goals/goal-state.js.map +1 -1
- package/dist/core/goals/natural-language-goal.d.ts +6 -0
- package/dist/core/goals/natural-language-goal.d.ts.map +1 -1
- package/dist/core/goals/natural-language-goal.js +36 -1
- package/dist/core/goals/natural-language-goal.js.map +1 -1
- package/dist/core/provider-request-runtime-controller.d.ts +1 -0
- package/dist/core/provider-request-runtime-controller.d.ts.map +1 -1
- package/dist/core/provider-request-runtime-controller.js +10 -2
- package/dist/core/provider-request-runtime-controller.js.map +1 -1
- package/dist/core/runtime-builder.d.ts +3 -0
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +3 -0
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/tool-recovery-logger.d.ts +2 -0
- package/dist/core/tool-recovery-logger.d.ts.map +1 -1
- package/dist/core/tool-recovery-logger.js +11 -0
- package/dist/core/tool-recovery-logger.js.map +1 -1
- package/dist/core/tools/goal.d.ts +2 -0
- package/dist/core/tools/goal.d.ts.map +1 -1
- package/dist/core/tools/goal.js +9 -0
- package/dist/core/tools/goal.js.map +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -61,6 +61,8 @@ export declare class ToolRecoveryLogger {
|
|
|
61
61
|
}): ToolExecutionFailureLogRecord | undefined;
|
|
62
62
|
getStats(): ToolRecoveryLoggerStats;
|
|
63
63
|
flush(timeoutMs?: number): Promise<void>;
|
|
64
|
+
drain(): Promise<void>;
|
|
65
|
+
private waitForIdle;
|
|
64
66
|
shutdown(timeoutMs?: number): Promise<void>;
|
|
65
67
|
private enqueue;
|
|
66
68
|
private pump;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-recovery-logger.d.ts","sourceRoot":"","sources":["../../src/core/tool-recovery-logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAGN,KAAK,+BAA+B,EACpC,KAAK,6BAA6B,EAElC,MAAM,gCAAgC,CAAC;AASxC,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,yBAAyB;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CAC/B;AAyBD,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;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AAQ,IAAI,uBAAuB,CAalC;IAED,KAAK,CAAC,SAAS,GAAE,MAAiC,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjE;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;IAED,OAAO,CAAC,WAAW;IAgCb,QAAQ,CAAC,SAAS,GAAE,MAAiC,GAAG,OAAO,CAAC,IAAI,CAAC,CAU1E;IAED,OAAO,CAAC,OAAO;IAUf,OAAO,CAAC,IAAI;IAiBZ,OAAO,CAAC,YAAY;IAuBpB,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,yBAAyB;CAKjC"}
|
|
@@ -88,11 +88,22 @@ export class ToolRecoveryLogger {
|
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
flush(timeoutMs = DEFAULT_FLUSH_TIMEOUT_MS) {
|
|
91
|
+
return this.waitForIdle(timeoutMs);
|
|
92
|
+
}
|
|
93
|
+
drain() {
|
|
94
|
+
return this.waitForIdle();
|
|
95
|
+
}
|
|
96
|
+
waitForIdle(timeoutMs) {
|
|
91
97
|
if (!this.enabled || (!this.worker && this.queue.length === 0 && this.inFlight.length === 0)) {
|
|
92
98
|
return Promise.resolve();
|
|
93
99
|
}
|
|
94
100
|
this.pump();
|
|
95
101
|
return new Promise((resolve) => {
|
|
102
|
+
if (timeoutMs === undefined) {
|
|
103
|
+
this.flushWaiters.push(resolve);
|
|
104
|
+
this.resolveFlushWaitersIfIdle();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
96
107
|
let settled = false;
|
|
97
108
|
let timeout;
|
|
98
109
|
const finish = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-recovery-logger.js","sourceRoot":"","sources":["../../src/core/tool-recovery-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CA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AI,IAAI,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO;QACnC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,IAAI,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACrC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;YACnB,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,uCAAuC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACnE,IAAI,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC;QACD,IAAI,CAAC,yBAAyB,EAAE,CAAC;IAClC,CAAC;IAEO,yBAAyB;QAChC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5C,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,MAAM,EAAE,CAAC;IACxC,CAAC;CACD","sourcesContent":["import { Worker } from \"node:worker_threads\";\nimport { readToolFailureTelemetry } from \"@caupulican/pi-agent-core/tool-failure-memory\";\nimport type { ToolArgumentValidationTelemetryEvent } from \"@caupulican/pi-ai\";\nimport type { ToolFailurePhase } from \"@caupulican/pi-ai/tool-repair-registry\";\nimport {\n\tcreateToolArgumentValidationLogRecord,\n\tcreateToolExecutionFailureLogRecord,\n\ttype ToolArgumentValidationLogRecord,\n\ttype ToolExecutionFailureLogRecord,\n\ttype ToolRecoveryLogWorkerRecord,\n} from \"./tool-recovery-log-records.ts\";\n\ninterface ToolRecoveryLogAckMessage {\n\ttype: \"ack\";\n\tbatchId: number;\n\twritten: number;\n\tfailed: number;\n}\n\nexport interface ToolRecoveryLoggerStats {\n\tenabled: boolean;\n\tqueued: number;\n\tinFlight: number;\n\tdropped: number;\n\tfailures: number;\n\tworkerStarts: number;\n\tworkerCrashes: number;\n\trespawns: number;\n\texecutionFailures: number;\n\tfailurePhases: Partial<Record<ToolFailurePhase, number>>;\n}\n\nexport interface ToolRecoveryLoggerOptions {\n\tenabled: boolean;\n\tsessionId: string;\n\teventLogPath: string;\n\tfailureCorpusPath: string;\n\tmaxQueue?: number;\n\tbatchSize?: number;\n\tnow?: () => Date;\n\tdebug?: (message: string) => void;\n\tworkerSpecifier?: string | URL;\n}\n\nconst DEFAULT_MAX_QUEUE = 1000;\nconst DEFAULT_BATCH_SIZE = 50;\nconst DEFAULT_FLUSH_TIMEOUT_MS = 200;\n\nfunction isToolRecoveryLogAckMessage(value: unknown): value is ToolRecoveryLogAckMessage {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst message = value as Partial<ToolRecoveryLogAckMessage>;\n\treturn (\n\t\tmessage.type === \"ack\" &&\n\t\ttypeof message.batchId === \"number\" &&\n\t\ttypeof message.written === \"number\" &&\n\t\ttypeof message.failed === \"number\"\n\t);\n}\n\nfunction createDefaultWorkerSpecifier(): URL {\n\tconst isTypeScriptRuntime = import.meta.url.endsWith(\".ts\");\n\treturn new URL(\n\t\tisTypeScriptRuntime ? \"./tool-recovery-log-worker.ts\" : \"./tool-recovery-log-worker.js\",\n\t\timport.meta.url,\n\t);\n}\n\nexport class ToolRecoveryLogger {\n\tprivate readonly enabled: boolean;\n\tprivate readonly sessionId: string;\n\tprivate readonly eventLogPath: string;\n\tprivate readonly failureCorpusPath: string;\n\tprivate readonly maxQueue: number;\n\tprivate readonly batchSize: number;\n\tprivate readonly now: () => Date;\n\tprivate readonly debug: (message: string) => void;\n\tprivate readonly workerSpecifier: string | URL;\n\tprivate readonly queue: ToolRecoveryLogWorkerRecord[] = [];\n\tprivate readonly flushWaiters: Array<() => void> = [];\n\tprivate worker: Worker | undefined;\n\tprivate inFlight: ToolRecoveryLogWorkerRecord[] = [];\n\tprivate inFlightBatchId: number | undefined;\n\tprivate inFlightWorker: Worker | undefined;\n\tprivate batchId = 0;\n\tprivate recordSequence = 0;\n\tprivate dropped = 0;\n\tprivate failures = 0;\n\tprivate workerStarts = 0;\n\tprivate workerCrashes = 0;\n\tprivate respawns = 0;\n\tprivate executionFailures = 0;\n\tprivate readonly failurePhases: Partial<Record<ToolFailurePhase, number>> = {};\n\tprivate respawnAttempted = false;\n\tprivate shuttingDown = false;\n\n\tconstructor(options: ToolRecoveryLoggerOptions) {\n\t\tthis.enabled = options.enabled;\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.eventLogPath = options.eventLogPath;\n\t\tthis.failureCorpusPath = options.failureCorpusPath;\n\t\tthis.maxQueue = options.maxQueue ?? DEFAULT_MAX_QUEUE;\n\t\tthis.batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;\n\t\tthis.now = options.now ?? (() => new Date());\n\t\tthis.debug = options.debug ?? (() => {});\n\t\tthis.workerSpecifier = options.workerSpecifier ?? createDefaultWorkerSpecifier();\n\t}\n\n\trecordToolArgumentValidation(\n\t\tevent: ToolArgumentValidationTelemetryEvent,\n\t): ToolArgumentValidationLogRecord | undefined {\n\t\tif (!this.enabled || event.outcome === \"clean\") return undefined;\n\t\tconst record = createToolArgumentValidationLogRecord({\n\t\t\tevent,\n\t\t\trecordId: `${this.sessionId}:${this.recordSequence++}`,\n\t\t\tsessionId: this.sessionId,\n\t\t\tts: this.now().toISOString(),\n\t\t});\n\t\tthis.enqueue({ eventLogPath: this.eventLogPath, failureCorpusPath: this.failureCorpusPath, record });\n\t\treturn record;\n\t}\n\n\trecordToolExecutionFailure(args: {\n\t\tprovider?: string;\n\t\tmodel?: string;\n\t\ttool: string;\n\t\tdetails: unknown;\n\t}): ToolExecutionFailureLogRecord | undefined {\n\t\tif (!this.enabled) return undefined;\n\t\tconst failure = readToolFailureTelemetry(args.details);\n\t\tif (!failure) return undefined;\n\t\tconst record = createToolExecutionFailureLogRecord({\n\t\t\t...args,\n\t\t\t...failure,\n\t\t\trecordId: `${this.sessionId}:${this.recordSequence++}`,\n\t\t\tsessionId: this.sessionId,\n\t\t\tts: this.now().toISOString(),\n\t\t});\n\t\tthis.executionFailures++;\n\t\tthis.failurePhases[failure.phase] = (this.failurePhases[failure.phase] ?? 0) + 1;\n\t\tthis.enqueue({ eventLogPath: this.eventLogPath, failureCorpusPath: this.failureCorpusPath, record });\n\t\treturn record;\n\t}\n\n\tgetStats(): ToolRecoveryLoggerStats {\n\t\treturn {\n\t\t\tenabled: this.enabled,\n\t\t\tqueued: this.queue.length,\n\t\t\tinFlight: this.inFlight.length,\n\t\t\tdropped: this.dropped,\n\t\t\tfailures: this.failures,\n\t\t\tworkerStarts: this.workerStarts,\n\t\t\tworkerCrashes: this.workerCrashes,\n\t\t\trespawns: this.respawns,\n\t\t\texecutionFailures: this.executionFailures,\n\t\t\tfailurePhases: { ...this.failurePhases },\n\t\t};\n\t}\n\n\tflush(timeoutMs: number = DEFAULT_FLUSH_TIMEOUT_MS): Promise<void> {\n\t\tif (!this.enabled || (!this.worker && this.queue.length === 0 && this.inFlight.length === 0)) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.pump();\n\t\treturn new Promise((resolve) => {\n\t\t\tlet settled = false;\n\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\tconst finish = (): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tconst waiter = (): void => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tfinish();\n\t\t\t};\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\tconst index = this.flushWaiters.indexOf(waiter);\n\t\t\t\tif (index !== -1) this.flushWaiters.splice(index, 1);\n\t\t\t\tfinish();\n\t\t\t}, timeoutMs);\n\t\t\tthis.flushWaiters.push(waiter);\n\t\t\tthis.resolveFlushWaitersIfIdle();\n\t\t});\n\t}\n\n\tasync shutdown(timeoutMs: number = DEFAULT_FLUSH_TIMEOUT_MS): Promise<void> {\n\t\tawait this.flush(timeoutMs);\n\t\tthis.shuttingDown = true;\n\t\tconst worker = this.worker;\n\t\tthis.worker = undefined;\n\t\tif (!worker) return;\n\t\ttry {\n\t\t\tworker.postMessage({ type: \"shutdown\" });\n\t\t} catch {}\n\t\tvoid worker.terminate().catch(() => undefined);\n\t}\n\n\tprivate enqueue(record: ToolRecoveryLogWorkerRecord): void {\n\t\tif (!this.enabled) return;\n\t\tthis.queue.push(record);\n\t\twhile (this.queue.length > this.maxQueue) {\n\t\t\tthis.queue.shift();\n\t\t\tthis.dropped++;\n\t\t}\n\t\tthis.pump();\n\t}\n\n\tprivate pump(): void {\n\t\tif (!this.enabled || this.shuttingDown || this.inFlight.length > 0 || this.queue.length === 0) return;\n\t\tconst worker = this.ensureWorker();\n\t\tif (!worker) return;\n\t\tconst records = this.queue.splice(0, this.batchSize);\n\t\tthis.inFlight = records;\n\t\tconst batchId = this.batchId++;\n\t\tthis.inFlightBatchId = batchId;\n\t\tthis.inFlightWorker = worker;\n\t\ttry {\n\t\t\tworker.postMessage({ type: \"records\", batchId, records });\n\t\t} catch (error) {\n\t\t\tthis.debug(`tool recovery logger post failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\tthis.handleWorkerFailure(worker, error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n\n\tprivate ensureWorker(): Worker | undefined {\n\t\tif (this.worker) return this.worker;\n\t\ttry {\n\t\t\tconst worker = new Worker(this.workerSpecifier);\n\t\t\tworker.unref();\n\t\t\tthis.worker = worker;\n\t\t\tthis.workerStarts++;\n\t\t\tworker.on(\"message\", (message: unknown) => this.handleWorkerMessage(worker, message));\n\t\t\tworker.on(\"error\", (error) => this.handleWorkerFailure(worker, error));\n\t\t\tworker.on(\"exit\", (code) => {\n\t\t\t\tif (this.shuttingDown || this.worker !== worker) return;\n\t\t\t\tthis.handleWorkerFailure(worker, new Error(`tool recovery logger worker exited with code ${code}`));\n\t\t\t});\n\t\t\treturn worker;\n\t\t} catch (error) {\n\t\t\tthis.failures++;\n\t\t\tthis.debug(\n\t\t\t\t`tool recovery logger worker start failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate handleWorkerMessage(worker: Worker, message: unknown): void {\n\t\tif (!isToolRecoveryLogAckMessage(message)) return;\n\t\tif (this.worker !== worker || this.inFlightWorker !== worker || this.inFlightBatchId !== message.batchId) {\n\t\t\treturn;\n\t\t}\n\t\tif (message.failed > 0) {\n\t\t\tthis.failures += message.failed;\n\t\t}\n\t\tthis.inFlight = [];\n\t\tthis.inFlightBatchId = undefined;\n\t\tthis.inFlightWorker = undefined;\n\t\tthis.respawnAttempted = false;\n\t\tthis.pump();\n\t\tthis.resolveFlushWaitersIfIdle();\n\t}\n\n\tprivate handleWorkerFailure(worker: Worker, error: Error): void {\n\t\tif (this.worker !== worker) return;\n\t\tthis.failures++;\n\t\tthis.workerCrashes++;\n\t\tif (this.inFlightWorker === worker) {\n\t\t\tthis.dropped += this.inFlight.length;\n\t\t\tthis.inFlight = [];\n\t\t\tthis.inFlightBatchId = undefined;\n\t\t\tthis.inFlightWorker = undefined;\n\t\t}\n\t\tthis.worker = undefined;\n\t\tthis.debug(`tool recovery logger worker failed: ${error.message}`);\n\t\tif (!this.respawnAttempted && !this.shuttingDown) {\n\t\t\tthis.respawnAttempted = true;\n\t\t\tthis.respawns++;\n\t\t\tthis.pump();\n\t\t}\n\t\tthis.resolveFlushWaitersIfIdle();\n\t}\n\n\tprivate resolveFlushWaitersIfIdle(): void {\n\t\tif (this.queue.length > 0 || this.inFlight.length > 0) return;\n\t\tconst waiters = this.flushWaiters.splice(0);\n\t\tfor (const waiter of waiters) waiter();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-recovery-logger.js","sourceRoot":"","sources":["../../src/core/tool-recovery-logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AAGzF,OAAO,EACN,qCAAqC,EACrC,mCAAmC,GAInC,MAAM,gCAAgC,CAAC;AAkCxC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAErC,SAAS,2BAA2B,CAAC,KAAc;IAClD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,OAAO,GAAG,KAA2C,CAAC;IAC5D,OAAO,CACN,OAAO,CAAC,IAAI,KAAK,KAAK;QACtB,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;QACnC,OAAO,OAAO,CAAC,OAAO,KAAK,QAAQ;QACnC,OAAO,OAAO,CAAC,MAAM,KAAK,QAAQ,CAClC,CAAC;AACH,CAAC;AAED,SAAS,4BAA4B;IACpC,MAAM,mBAAmB,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5D,OAAO,IAAI,GAAG,CACb,mBAAmB,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,+BAA+B,EACvF,OAAO,IAAI,CAAC,GAAG,CACf,CAAC;AACH,CAAC;AAED,MAAM,OAAO,kBAAkB;IA4B9B,YAAY,OAAkC;QAlB7B,UAAK,GAAkC,EAAE,CAAC;QAC1C,iBAAY,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Y,EAAE,CAAC;YAClD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,IAAI,EAAE,CAAC;QACb,CAAC;QACD,IAAI,CAAC,yBAAyB,EAAE,CAAC;IAClC,CAAC;IAEO,yBAAyB;QAChC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO;QAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC5C,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,MAAM,EAAE,CAAC;IACxC,CAAC;CACD","sourcesContent":["import { Worker } from \"node:worker_threads\";\nimport { readToolFailureTelemetry } from \"@caupulican/pi-agent-core/tool-failure-memory\";\nimport type { ToolArgumentValidationTelemetryEvent } from \"@caupulican/pi-ai\";\nimport type { ToolFailurePhase } from \"@caupulican/pi-ai/tool-repair-registry\";\nimport {\n\tcreateToolArgumentValidationLogRecord,\n\tcreateToolExecutionFailureLogRecord,\n\ttype ToolArgumentValidationLogRecord,\n\ttype ToolExecutionFailureLogRecord,\n\ttype ToolRecoveryLogWorkerRecord,\n} from \"./tool-recovery-log-records.ts\";\n\ninterface ToolRecoveryLogAckMessage {\n\ttype: \"ack\";\n\tbatchId: number;\n\twritten: number;\n\tfailed: number;\n}\n\nexport interface ToolRecoveryLoggerStats {\n\tenabled: boolean;\n\tqueued: number;\n\tinFlight: number;\n\tdropped: number;\n\tfailures: number;\n\tworkerStarts: number;\n\tworkerCrashes: number;\n\trespawns: number;\n\texecutionFailures: number;\n\tfailurePhases: Partial<Record<ToolFailurePhase, number>>;\n}\n\nexport interface ToolRecoveryLoggerOptions {\n\tenabled: boolean;\n\tsessionId: string;\n\teventLogPath: string;\n\tfailureCorpusPath: string;\n\tmaxQueue?: number;\n\tbatchSize?: number;\n\tnow?: () => Date;\n\tdebug?: (message: string) => void;\n\tworkerSpecifier?: string | URL;\n}\n\nconst DEFAULT_MAX_QUEUE = 1000;\nconst DEFAULT_BATCH_SIZE = 50;\nconst DEFAULT_FLUSH_TIMEOUT_MS = 200;\n\nfunction isToolRecoveryLogAckMessage(value: unknown): value is ToolRecoveryLogAckMessage {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst message = value as Partial<ToolRecoveryLogAckMessage>;\n\treturn (\n\t\tmessage.type === \"ack\" &&\n\t\ttypeof message.batchId === \"number\" &&\n\t\ttypeof message.written === \"number\" &&\n\t\ttypeof message.failed === \"number\"\n\t);\n}\n\nfunction createDefaultWorkerSpecifier(): URL {\n\tconst isTypeScriptRuntime = import.meta.url.endsWith(\".ts\");\n\treturn new URL(\n\t\tisTypeScriptRuntime ? \"./tool-recovery-log-worker.ts\" : \"./tool-recovery-log-worker.js\",\n\t\timport.meta.url,\n\t);\n}\n\nexport class ToolRecoveryLogger {\n\tprivate readonly enabled: boolean;\n\tprivate readonly sessionId: string;\n\tprivate readonly eventLogPath: string;\n\tprivate readonly failureCorpusPath: string;\n\tprivate readonly maxQueue: number;\n\tprivate readonly batchSize: number;\n\tprivate readonly now: () => Date;\n\tprivate readonly debug: (message: string) => void;\n\tprivate readonly workerSpecifier: string | URL;\n\tprivate readonly queue: ToolRecoveryLogWorkerRecord[] = [];\n\tprivate readonly flushWaiters: Array<() => void> = [];\n\tprivate worker: Worker | undefined;\n\tprivate inFlight: ToolRecoveryLogWorkerRecord[] = [];\n\tprivate inFlightBatchId: number | undefined;\n\tprivate inFlightWorker: Worker | undefined;\n\tprivate batchId = 0;\n\tprivate recordSequence = 0;\n\tprivate dropped = 0;\n\tprivate failures = 0;\n\tprivate workerStarts = 0;\n\tprivate workerCrashes = 0;\n\tprivate respawns = 0;\n\tprivate executionFailures = 0;\n\tprivate readonly failurePhases: Partial<Record<ToolFailurePhase, number>> = {};\n\tprivate respawnAttempted = false;\n\tprivate shuttingDown = false;\n\n\tconstructor(options: ToolRecoveryLoggerOptions) {\n\t\tthis.enabled = options.enabled;\n\t\tthis.sessionId = options.sessionId;\n\t\tthis.eventLogPath = options.eventLogPath;\n\t\tthis.failureCorpusPath = options.failureCorpusPath;\n\t\tthis.maxQueue = options.maxQueue ?? DEFAULT_MAX_QUEUE;\n\t\tthis.batchSize = options.batchSize ?? DEFAULT_BATCH_SIZE;\n\t\tthis.now = options.now ?? (() => new Date());\n\t\tthis.debug = options.debug ?? (() => {});\n\t\tthis.workerSpecifier = options.workerSpecifier ?? createDefaultWorkerSpecifier();\n\t}\n\n\trecordToolArgumentValidation(\n\t\tevent: ToolArgumentValidationTelemetryEvent,\n\t): ToolArgumentValidationLogRecord | undefined {\n\t\tif (!this.enabled || event.outcome === \"clean\") return undefined;\n\t\tconst record = createToolArgumentValidationLogRecord({\n\t\t\tevent,\n\t\t\trecordId: `${this.sessionId}:${this.recordSequence++}`,\n\t\t\tsessionId: this.sessionId,\n\t\t\tts: this.now().toISOString(),\n\t\t});\n\t\tthis.enqueue({ eventLogPath: this.eventLogPath, failureCorpusPath: this.failureCorpusPath, record });\n\t\treturn record;\n\t}\n\n\trecordToolExecutionFailure(args: {\n\t\tprovider?: string;\n\t\tmodel?: string;\n\t\ttool: string;\n\t\tdetails: unknown;\n\t}): ToolExecutionFailureLogRecord | undefined {\n\t\tif (!this.enabled) return undefined;\n\t\tconst failure = readToolFailureTelemetry(args.details);\n\t\tif (!failure) return undefined;\n\t\tconst record = createToolExecutionFailureLogRecord({\n\t\t\t...args,\n\t\t\t...failure,\n\t\t\trecordId: `${this.sessionId}:${this.recordSequence++}`,\n\t\t\tsessionId: this.sessionId,\n\t\t\tts: this.now().toISOString(),\n\t\t});\n\t\tthis.executionFailures++;\n\t\tthis.failurePhases[failure.phase] = (this.failurePhases[failure.phase] ?? 0) + 1;\n\t\tthis.enqueue({ eventLogPath: this.eventLogPath, failureCorpusPath: this.failureCorpusPath, record });\n\t\treturn record;\n\t}\n\n\tgetStats(): ToolRecoveryLoggerStats {\n\t\treturn {\n\t\t\tenabled: this.enabled,\n\t\t\tqueued: this.queue.length,\n\t\t\tinFlight: this.inFlight.length,\n\t\t\tdropped: this.dropped,\n\t\t\tfailures: this.failures,\n\t\t\tworkerStarts: this.workerStarts,\n\t\t\tworkerCrashes: this.workerCrashes,\n\t\t\trespawns: this.respawns,\n\t\t\texecutionFailures: this.executionFailures,\n\t\t\tfailurePhases: { ...this.failurePhases },\n\t\t};\n\t}\n\n\tflush(timeoutMs: number = DEFAULT_FLUSH_TIMEOUT_MS): Promise<void> {\n\t\treturn this.waitForIdle(timeoutMs);\n\t}\n\n\tdrain(): Promise<void> {\n\t\treturn this.waitForIdle();\n\t}\n\n\tprivate waitForIdle(timeoutMs?: number): Promise<void> {\n\t\tif (!this.enabled || (!this.worker && this.queue.length === 0 && this.inFlight.length === 0)) {\n\t\t\treturn Promise.resolve();\n\t\t}\n\t\tthis.pump();\n\t\treturn new Promise((resolve) => {\n\t\t\tif (timeoutMs === undefined) {\n\t\t\t\tthis.flushWaiters.push(resolve);\n\t\t\t\tthis.resolveFlushWaitersIfIdle();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet settled = false;\n\t\t\tlet timeout: NodeJS.Timeout;\n\t\t\tconst finish = (): void => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tconst waiter = (): void => {\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tfinish();\n\t\t\t};\n\t\t\ttimeout = setTimeout(() => {\n\t\t\t\tconst index = this.flushWaiters.indexOf(waiter);\n\t\t\t\tif (index !== -1) this.flushWaiters.splice(index, 1);\n\t\t\t\tfinish();\n\t\t\t}, timeoutMs);\n\t\t\tthis.flushWaiters.push(waiter);\n\t\t\tthis.resolveFlushWaitersIfIdle();\n\t\t});\n\t}\n\n\tasync shutdown(timeoutMs: number = DEFAULT_FLUSH_TIMEOUT_MS): Promise<void> {\n\t\tawait this.flush(timeoutMs);\n\t\tthis.shuttingDown = true;\n\t\tconst worker = this.worker;\n\t\tthis.worker = undefined;\n\t\tif (!worker) return;\n\t\ttry {\n\t\t\tworker.postMessage({ type: \"shutdown\" });\n\t\t} catch {}\n\t\tvoid worker.terminate().catch(() => undefined);\n\t}\n\n\tprivate enqueue(record: ToolRecoveryLogWorkerRecord): void {\n\t\tif (!this.enabled) return;\n\t\tthis.queue.push(record);\n\t\twhile (this.queue.length > this.maxQueue) {\n\t\t\tthis.queue.shift();\n\t\t\tthis.dropped++;\n\t\t}\n\t\tthis.pump();\n\t}\n\n\tprivate pump(): void {\n\t\tif (!this.enabled || this.shuttingDown || this.inFlight.length > 0 || this.queue.length === 0) return;\n\t\tconst worker = this.ensureWorker();\n\t\tif (!worker) return;\n\t\tconst records = this.queue.splice(0, this.batchSize);\n\t\tthis.inFlight = records;\n\t\tconst batchId = this.batchId++;\n\t\tthis.inFlightBatchId = batchId;\n\t\tthis.inFlightWorker = worker;\n\t\ttry {\n\t\t\tworker.postMessage({ type: \"records\", batchId, records });\n\t\t} catch (error) {\n\t\t\tthis.debug(`tool recovery logger post failed: ${error instanceof Error ? error.message : String(error)}`);\n\t\t\tthis.handleWorkerFailure(worker, error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n\n\tprivate ensureWorker(): Worker | undefined {\n\t\tif (this.worker) return this.worker;\n\t\ttry {\n\t\t\tconst worker = new Worker(this.workerSpecifier);\n\t\t\tworker.unref();\n\t\t\tthis.worker = worker;\n\t\t\tthis.workerStarts++;\n\t\t\tworker.on(\"message\", (message: unknown) => this.handleWorkerMessage(worker, message));\n\t\t\tworker.on(\"error\", (error) => this.handleWorkerFailure(worker, error));\n\t\t\tworker.on(\"exit\", (code) => {\n\t\t\t\tif (this.shuttingDown || this.worker !== worker) return;\n\t\t\t\tthis.handleWorkerFailure(worker, new Error(`tool recovery logger worker exited with code ${code}`));\n\t\t\t});\n\t\t\treturn worker;\n\t\t} catch (error) {\n\t\t\tthis.failures++;\n\t\t\tthis.debug(\n\t\t\t\t`tool recovery logger worker start failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tprivate handleWorkerMessage(worker: Worker, message: unknown): void {\n\t\tif (!isToolRecoveryLogAckMessage(message)) return;\n\t\tif (this.worker !== worker || this.inFlightWorker !== worker || this.inFlightBatchId !== message.batchId) {\n\t\t\treturn;\n\t\t}\n\t\tif (message.failed > 0) {\n\t\t\tthis.failures += message.failed;\n\t\t}\n\t\tthis.inFlight = [];\n\t\tthis.inFlightBatchId = undefined;\n\t\tthis.inFlightWorker = undefined;\n\t\tthis.respawnAttempted = false;\n\t\tthis.pump();\n\t\tthis.resolveFlushWaitersIfIdle();\n\t}\n\n\tprivate handleWorkerFailure(worker: Worker, error: Error): void {\n\t\tif (this.worker !== worker) return;\n\t\tthis.failures++;\n\t\tthis.workerCrashes++;\n\t\tif (this.inFlightWorker === worker) {\n\t\t\tthis.dropped += this.inFlight.length;\n\t\t\tthis.inFlight = [];\n\t\t\tthis.inFlightBatchId = undefined;\n\t\t\tthis.inFlightWorker = undefined;\n\t\t}\n\t\tthis.worker = undefined;\n\t\tthis.debug(`tool recovery logger worker failed: ${error.message}`);\n\t\tif (!this.respawnAttempted && !this.shuttingDown) {\n\t\t\tthis.respawnAttempted = true;\n\t\t\tthis.respawns++;\n\t\t\tthis.pump();\n\t\t}\n\t\tthis.resolveFlushWaitersIfIdle();\n\t}\n\n\tprivate resolveFlushWaitersIfIdle(): void {\n\t\tif (this.queue.length > 0 || this.inFlight.length > 0) return;\n\t\tconst waiters = this.flushWaiters.splice(0);\n\t\tfor (const waiter of waiters) waiter();\n\t}\n}\n"]}
|
|
@@ -123,6 +123,8 @@ export interface GoalToolDependencies {
|
|
|
123
123
|
* task state itself; this is the only place that supplies it.
|
|
124
124
|
*/
|
|
125
125
|
getOpenTaskSteps?: () => readonly OpenTaskStepRef[];
|
|
126
|
+
/** Model-facing start authority for the current foreground turn. Omitted by direct owner/test callers. */
|
|
127
|
+
authorizeStart?: (input: Pick<GoalToolInput, "userGoal" | "tokenBudget">) => string | undefined;
|
|
126
128
|
}
|
|
127
129
|
export declare function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition;
|
|
128
130
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.d.ts","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,KAAK,iBAAiB,EAAwB,MAAM,4BAA4B,CAAC;AAC1F,OAAO,KAAK,EAAoB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAGN,KAAK,cAAc,EACnB,KAAK,eAAe,EAEpB,MAAM,4BAA4B,CAAC;AAQpC,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;EAsEf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,cAAc,GAAG,KAAK,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;iHAE6G;IAC7G,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;uGAImG;IACnG,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,oBAAoB;IACpC,mEAAmE;IACnE,YAAY,EAAE,MAAM,SAAS,GAAG,SAAS,CAAC;IAC1C,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E,CAAC;IACvD;;;;;;;;;OASG;IACH,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC9B,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACrB,KAAK;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAC3D;;;;;;;;;;;;;;;;;OAiBG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE;QAC3B,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;KACrB,KAAK,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,mGAAmG;IACnG,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB;;;OAGG;IACH,oCAAoC,CAAC,EAAE,MAAM,OAAO,CAAC;IACrD;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,SAAS,eAAe,EAAE,CAAC;IACpD,0GAA0G;IAC1G,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,aAAa,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;CAChG;AAqKD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,cAAc,CA+LnF"}
|
package/dist/core/tools/goal.js
CHANGED
|
@@ -249,6 +249,15 @@ export function createGoalToolDefinition(deps) {
|
|
|
249
249
|
details: { action: "get", applied: false, state },
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
+
if (input.action === "start" && deps.authorizeStart) {
|
|
253
|
+
const error = deps.authorizeStart(input);
|
|
254
|
+
if (error) {
|
|
255
|
+
return {
|
|
256
|
+
content: [{ type: "text", text: `goal start failed: ${error}` }],
|
|
257
|
+
details: { action: "start", applied: false, error },
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
252
261
|
const mapped = toGoalAction(input);
|
|
253
262
|
if ("error" in mapped) {
|
|
254
263
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,sBAAsB,EAEtB,6BAA6B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAC7B;IACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;QACC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;KAC1B,EACD,EAAE,WAAW,EAAE,qBAAqB,EAAE,CACtC;IACD,MAAM,EAAE,IAAI,C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AAK,YAAY,EAAE;gBAC/D,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,eAAe,OAAO,EAAE,CAAC;YAChD,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;gBAC1C,OAAO,EAAE;oBACR,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,SAAS;oBAChB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpG,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACxF;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport {\n\temptyOrchestrationCall,\n\ttype OrchestrationPanelModel,\n\trenderOrchestrationToolResult,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Requirement id for requirement actions.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tdependencies: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Existing evidence ids for satisfy_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Optional file/URL, toolCallId, or laneId evidence locator.\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy target. Native is default; use tmux only for an owner-requested persistent pane.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n}\n\nfunction allowsNativeTmuxFallback(reason: string | undefined): boolean {\n\treturn reason === \"tmux_unavailable\" || reason === \"tmux_extension_not_loaded\";\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"add_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\ttext: input.text ?? \"\",\n\t\t\t\tdependencies: input.dependencies,\n\t\t\t};\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"goal\",\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the durable goal for explicitly persistent work. Use task_steps for plans and delegate for workers; owner or system controls lifecycle and budget stops.\",\n\t\tpromptSnippet: \"Read or update the durable goal.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Start only for explicit persistent chat/system goal. get if uncertain; never replace unfinished goal; tokenBudget only if requested.\",\n\t\t\t\"Plans: task_steps. Workers: delegate. Legacy actions only for legacy goals.\",\n\t\t\t\"complete needs current authoritative evidence, no remaining work. block_goal needs same real impasse for 3 goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tconst details = result.details as GoalToolDetails | undefined;\n\t\t\treturn renderOrchestrationToolResult(theme, goalPanelModel(details), {\n\t\t\t\tisPartial,\n\t\t\t\tcollapse: !expanded && details?.applied === true,\n\t\t\t\texpanded: true,\n\t\t\t});\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst tmuxRequested = input.dispatchTarget === \"tmux\";\n\t\t\t\tlet useTmux = tmuxRequested && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tlet tmuxFallbackReason: string | undefined;\n\t\t\t\tlet dispatched: { laneId?: string; skipReason?: string } | undefined;\n\t\t\t\tif (useTmux) {\n\t\t\t\t\tdispatched = await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t\tif (\n\t\t\t\t\t\t!dispatched?.laneId &&\n\t\t\t\t\t\tallowsNativeTmuxFallback(dispatched?.skipReason) &&\n\t\t\t\t\t\tdeps.startWorkerDelegation\n\t\t\t\t\t) {\n\t\t\t\t\t\ttmuxFallbackReason = dispatched?.skipReason;\n\t\t\t\t\t\tuseTmux = false;\n\t\t\t\t\t\tdispatched = deps.startWorkerDelegation({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (tmuxRequested) tmuxFallbackReason = \"tmux_extension_not_loaded\";\n\t\t\t\t\tdispatched = deps.startWorkerDelegation?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = tmuxFallbackReason\n\t\t\t\t\t\t? `Tmux route returned ${tmuxFallbackReason}; dispatched native fallback worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: useTmux\n\t\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (native default).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `${tmuxFallbackReason ? `Tmux route returned ${tmuxFallbackReason}; ` : \"\"}No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal.js","sourceRoot":"","sources":["../../../src/core/tools/goal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAI5C,OAAO,EAA0B,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,OAAO,EACN,eAAe,EAIf,kBAAkB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,sBAAsB,EAEtB,6BAA6B,GAC7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAC7B;IACC,MAAM,EAAE,IAAI,CAAC,KAAK,CACjB;QACC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACrB,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC;QACnC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAClC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;QAC/B,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;KAC1B,EACD,EAAE,WAAW,EAAE,qBAAqB,EAAE,CACtC;IACD,MAAM,EAAE,IAAI,CAAC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,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;gBACtF,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;YAC1B,CAAC;YAED,MAAM,OAAO,GAAG,kBAAkB,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,gBAAgB,EAAE,EAAE,EAAE,CAAC,CAAC;YACpG,MAAM,IAAI,GAAG,YAAY;gBACxB,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,eAAe,OAAO,KAAK,YAAY,EAAE;gBAC/D,CAAC,CAAC,QAAQ,KAAK,CAAC,MAAM,eAAe,OAAO,EAAE,CAAC;YAChD,OAAO;gBACN,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;gBAC1C,OAAO,EAAE;oBACR,MAAM,EAAE,KAAK,CAAC,MAAM;oBACpB,OAAO,EAAE,IAAI;oBACb,KAAK,EAAE,SAAS;oBAChB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;oBACpG,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,iBAAiB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBACxF;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["import { stat as fsStat } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport type { WorkerClaim } from \"../autonomy/contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport { type GoalStateRevision, getGoalStateRevision } from \"../goals/goal-lifecycle.ts\";\nimport type { GoalEvidenceKind, GoalState } from \"../goals/goal-state.ts\";\nimport {\n\tapplyGoalAction,\n\ttype GoalAction,\n\ttype GoalActionName,\n\ttype OpenTaskStepRef,\n\tsummarizeGoalState,\n} from \"../goals/goal-tool-core.ts\";\nimport {\n\temptyOrchestrationCall,\n\ttype OrchestrationPanelModel,\n\trenderOrchestrationToolResult,\n} from \"./orchestration-panel.ts\";\nimport { resolveToCwd } from \"./path-utils.ts\";\n\nconst goalSchema = Type.Object(\n\t{\n\t\taction: Type.Union(\n\t\t\t[\n\t\t\t\tType.Literal(\"get\"),\n\t\t\t\tType.Literal(\"start\"),\n\t\t\t\tType.Literal(\"add_requirement\"),\n\t\t\t\tType.Literal(\"satisfy_requirement\"),\n\t\t\t\tType.Literal(\"block_requirement\"),\n\t\t\t\tType.Literal(\"reopen_requirement\"),\n\t\t\t\tType.Literal(\"dispatch_worker\"),\n\t\t\t\tType.Literal(\"add_evidence\"),\n\t\t\t\tType.Literal(\"progress\"),\n\t\t\t\tType.Literal(\"no_progress\"),\n\t\t\t\tType.Literal(\"complete\"),\n\t\t\t\tType.Literal(\"block_goal\"),\n\t\t\t],\n\t\t\t{ description: \"Goal record action.\" },\n\t\t),\n\t\tgoalId: Type.Optional(Type.String({ description: \"Stable goal id. Required for action 'start'.\" })),\n\t\tuserGoal: Type.Optional(Type.String({ description: \"The goal statement. Required for action 'start'.\" })),\n\t\ttokenBudget: Type.Optional(\n\t\t\tType.Integer({ minimum: 1, description: \"Optional positive token budget for action 'start'.\" }),\n\t\t),\n\t\trequirementId: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Requirement id for requirement actions.\",\n\t\t\t}),\n\t\t),\n\t\ttext: Type.Optional(Type.String({ description: \"Requirement text. Required for add_requirement.\" })),\n\t\tdependencies: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Optional IDs of requirements that must be satisfied before this one. Valid for add_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tinstructions: Type.Optional(Type.String({ description: \"Worker instructions. Required for dispatch_worker.\" })),\n\t\tevidenceId: Type.Optional(Type.String({ description: \"Evidence id. Required for add_evidence.\" })),\n\t\tevidenceIds: Type.Optional(\n\t\t\tType.Array(Type.String(), {\n\t\t\t\tdescription: \"Existing evidence ids for satisfy_requirement.\",\n\t\t\t}),\n\t\t),\n\t\tkind: Type.Optional(\n\t\t\tType.Union(\n\t\t\t\t[\n\t\t\t\t\tType.Literal(\"file\"),\n\t\t\t\t\tType.Literal(\"test\"),\n\t\t\t\t\tType.Literal(\"tool\"),\n\t\t\t\t\tType.Literal(\"user\"),\n\t\t\t\t\tType.Literal(\"finding\"),\n\t\t\t\t\tType.Literal(\"worker\"),\n\t\t\t\t],\n\t\t\t\t{ description: \"Evidence kind. Required for add_evidence.\" },\n\t\t\t),\n\t\t),\n\t\tsummary: Type.Optional(Type.String({ description: \"Evidence summary. Required for add_evidence.\" })),\n\t\turi: Type.Optional(\n\t\t\tType.String({\n\t\t\t\tdescription: \"Optional file/URL, toolCallId, or laneId evidence locator.\",\n\t\t\t}),\n\t\t),\n\t\treason: Type.Optional(Type.String({ description: \"Reason for block_requirement or block_goal.\" })),\n\t\tdispatchTarget: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"in_process\"), Type.Literal(\"tmux\")], {\n\t\t\t\tdescription: \"Legacy target. Native is default; use tmux only for an owner-requested persistent pane.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport type GoalToolInput = Static<typeof goalSchema>;\n\nexport interface GoalToolDetails {\n\taction: GoalActionName | \"get\";\n\tapplied: boolean;\n\terror?: string;\n\tstate?: GoalState;\n\t/** Set on 'dispatch_worker' when a worker lane actually started; mirrors the requirement's\n\t * new `boundLaneId`. The in-process route by default, or a real persistent tmux lane when\n\t * `dispatchTarget:\"tmux\"` was selected and routed -- see {@link GoalToolDependencies.dispatchTmuxWorker}. */\n\tdispatchedLaneId?: string;\n\t/** Set on 'dispatch_worker' when no worker was dispatched: a wired dependency declined (e.g. worker\n\t * delegation disabled, already at capacity, or an honest tmux skip reason -- see\n\t * {@link GoalToolDependencies.dispatchTmuxWorker}), or the indeterminate-binding guard refused a\n\t * re-dispatch against an already-bound requirement (`requirement_already_bound`/`bound_lane_indeterminate`).\n\t * The binding is recorded (or, for a guard refusal, left exactly as it was) with no NEW laneId. */\n\tdispatchSkipReason?: string;\n}\n\nexport interface GoalToolDependencies {\n\t/** Read the latest persisted goal state for the active session. */\n\tgetGoalState: () => GoalState | undefined;\n\t/** Persist a new goal state snapshot to the active session. */\n\tsaveGoalState: (state: GoalState, expected?: GoalStateRevision) => void;\n\t/** Clock injection for deterministic tests. */\n\tnow?: () => string;\n\t/**\n\t * Check whether `toolCallId` exists in this session's records, for validating kind:\"tool\"\n\t * evidence refs at add_evidence time. When not wired, a \"tool\" ref cannot be proven and is\n\t * recorded as `verified: false` rather than assumed true.\n\t */\n\thasToolCallId?: (toolCallId: string) => boolean;\n\t/**\n\t * Read the session's live worker lane records, for validating kind:\"worker\" evidence refs\n\t * (the `uri` is a laneId) at add_evidence time. Read-defensive: when not wired -- exactly like\n\t * `hasToolCallId` -- a \"worker\" ref cannot be proven and is recorded as `verified: false` rather\n\t * than assumed true. Live wiring is added separately.\n\t */\n\tgetLaneRecords?: () => readonly LaneRecord[];\n\t/**\n\t * Read persisted worker claim snapshots (keyed by `WorkerClaim.requestId`, which is the same\n\t * id as the dispatching lane's laneId), for validating kind:\"worker\" evidence refs. See\n\t * {@link getLaneRecords}. A matching claim that is `parentReviewRequired && !parentReviewedAt`\n\t * verifies `false` -- an unreviewed worker completion must never ungate goal completion through\n\t * the existing verified/complete gate.\n\t */\n\tgetWorkerClaimSnapshots?: () => readonly WorkerClaim[];\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `dispatchTarget` is 'in_process'\n\t * (the default) or when {@link dispatchTmuxWorker} is not wired: dispatches a real in-process\n\t * worker lane for the given requirement and returns the resulting laneId to bind onto it. When\n\t * the dependency is present but the underlying delegation starter declines (disabled, already at\n\t * capacity, etc.), return `{ skipReason }` instead of a laneId -- a real, non-silent skip that\n\t * the tool response surfaces, distinct from this dependency being altogether unwired (`undefined`\n\t * dep, or the dep returning `undefined`), which records the binding attempt structurally with no\n\t * laneId (a no-op).\n\t */\n\tstartWorkerDelegation?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => { laneId?: string; skipReason?: string } | undefined;\n\t/**\n\t * Tool-layer side effect for a 'dispatch_worker' action when `input.dispatchTarget === \"tmux\"`:\n\t * dispatches a REAL persistent tmux worker via the tmux_agent_manager extension's `fire_task`\n\t * action (core structurally invokes the same tool call the model would make; no extension change,\n\t * no faked launch or laneId -- see `tmux-dispatch.ts`'s `dispatchTmuxWorker`). Selected ONLY when\n\t * BOTH `input.dispatchTarget === \"tmux\"` AND this dependency is present; otherwise the EXISTING\n\t * {@link startWorkerDelegation} in-process path runs, byte-identical to before this field existed.\n\t * The honest skip-reason vocabulary this can return: `tmux_extension_not_loaded`,\n\t * `no_standing_grant` (the owner has not authorized unattended tmux dispatch),\n\t * `tmux_dispatch_failed`, `tmux_dispatch_incomplete`, `lane_correlation_failed`,\n\t * `worktree_create_failed` (worktree-sync is enabled but the lane-first `create_lane` call was\n\t * refused -- e.g. max lanes reached -- so no fire_task call was ever attempted),\n\t * `worker_capability_insufficient` (the model is sub-full class, has an unknown context window,\n\t * does not advertise a native tool-call path, or is graded-demoted to text-protocol/none -- see\n\t * `model-capability.ts`'s `evaluateLaneWorkerRefusal`; this is the parent's best-effort check\n\t * only, refused before any lane/pane side effect -- the dispatched child still refuses\n\t * authoritatively at its own startup regardless).\n\t */\n\tdispatchTmuxWorker?: (args: {\n\t\trequirementId: string;\n\t\tinstructions: string;\n\t}) => Promise<{ laneId?: string; skipReason?: string }>;\n\t/** Working directory for resolving kind:\"file\" evidence ref paths. Defaults to `process.cwd()`. */\n\tcwd?: () => string;\n\t/**\n\t * Gate agent-facing 'complete' on verified/user evidence backing. Defaults to `true` (on)\n\t * when omitted -- the conservative default; set to a function returning `false` to opt out.\n\t */\n\trequireVerifiedEvidenceForCompletion?: () => boolean;\n\t/**\n\t * Read-only open (non-terminal) task_steps steps on the active branch, for the goal⇄task\n\t * cross-visibility nudge in the tool response. When omitted, `summarizeGoalState` gets\n\t * no task-step context and simply emits no nudge -- goal-tool-core stays pure and never reads\n\t * task state itself; this is the only place that supplies it.\n\t */\n\tgetOpenTaskSteps?: () => readonly OpenTaskStepRef[];\n\t/** Model-facing start authority for the current foreground turn. Omitted by direct owner/test callers. */\n\tauthorizeStart?: (input: Pick<GoalToolInput, \"userGoal\" | \"tokenBudget\">) => string | undefined;\n}\n\nfunction allowsNativeTmuxFallback(reason: string | undefined): boolean {\n\treturn reason === \"tmux_unavailable\" || reason === \"tmux_extension_not_loaded\";\n}\n\n/**\n * Validate an evidence ref's `uri` against session records (\"tool\") or the filesystem (\"file\").\n * Returns `undefined` for kinds/refs that carry nothing checkable (e.g. \"user\"/\"finding\"/\"test\",\n * or a missing `uri`) -- absence of a ref is not the same as a ref that failed to verify.\n */\nasync function resolveEvidenceVerified(\n\tkind: GoalEvidenceKind,\n\turi: string | undefined,\n\tdeps: GoalToolDependencies,\n): Promise<boolean | undefined> {\n\tconst trimmedUri = uri?.trim();\n\tif (!trimmedUri) return undefined;\n\tif (kind === \"tool\") {\n\t\treturn deps.hasToolCallId ? deps.hasToolCallId(trimmedUri) : false;\n\t}\n\tif (kind === \"file\") {\n\t\tconst cwd = deps.cwd?.() ?? process.cwd();\n\t\ttry {\n\t\t\tconst stats = await fsStat(resolveToCwd(trimmedUri, cwd));\n\t\t\treturn stats.isFile();\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\tif (kind === \"worker\") {\n\t\tif (!deps.getLaneRecords || !deps.getWorkerClaimSnapshots) return false;\n\t\tconst laneId = trimmedUri;\n\t\tconst record = deps.getLaneRecords().find((candidate) => candidate.laneId === laneId);\n\t\tif (!record) return false;\n\t\tconst claim = deps.getWorkerClaimSnapshots().find((candidate) => candidate.requestId === laneId);\n\t\tif (!claim) return false;\n\t\t// An unreviewed mutation (parentReviewRequired && no parentReviewedAt) can never verify true --\n\t\t// this is what stops an unreviewed worker completion from ungating goal completion through\n\t\t// the existing verified/complete gate (goal-tool-core's isVerifiedOrUserEvidence/complete).\n\t\tif (claim.parentReviewRequired === true && claim.parentReviewedAt === undefined) return false;\n\t\treturn claim.status === \"completed\";\n\t}\n\treturn undefined;\n}\n\nfunction toGoalAction(input: GoalToolInput): GoalAction | { error: string } {\n\tswitch (input.action) {\n\t\tcase \"start\":\n\t\t\treturn {\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: input.goalId ?? \"\",\n\t\t\t\tuserGoal: input.userGoal ?? \"\",\n\t\t\t\ttokenBudget: input.tokenBudget,\n\t\t\t};\n\t\tcase \"add_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"add_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\ttext: input.text ?? \"\",\n\t\t\t\tdependencies: input.dependencies,\n\t\t\t};\n\t\tcase \"satisfy_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"satisfy_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tevidenceIds: input.evidenceIds,\n\t\t\t};\n\t\tcase \"block_requirement\":\n\t\t\treturn {\n\t\t\t\taction: \"block_requirement\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\treason: input.reason ?? \"\",\n\t\t\t};\n\t\tcase \"reopen_requirement\":\n\t\t\treturn { action: \"reopen_requirement\", requirementId: input.requirementId ?? \"\" };\n\t\tcase \"dispatch_worker\":\n\t\t\treturn {\n\t\t\t\taction: \"dispatch_worker\",\n\t\t\t\trequirementId: input.requirementId ?? \"\",\n\t\t\t\tinstructions: input.instructions ?? \"\",\n\t\t\t};\n\t\tcase \"add_evidence\": {\n\t\t\tif (input.kind === undefined) {\n\t\t\t\treturn { error: \"add_evidence requires a kind.\" };\n\t\t\t}\n\t\t\tconst kind: GoalEvidenceKind = input.kind;\n\t\t\treturn {\n\t\t\t\taction: \"add_evidence\",\n\t\t\t\tevidenceId: input.evidenceId ?? \"\",\n\t\t\t\tkind,\n\t\t\t\tsummary: input.summary ?? \"\",\n\t\t\t\turi: input.uri,\n\t\t\t};\n\t\t}\n\t\tcase \"progress\":\n\t\t\treturn { action: \"progress\" };\n\t\tcase \"no_progress\":\n\t\t\treturn { action: \"no_progress\" };\n\t\tcase \"complete\":\n\t\t\treturn { action: \"complete\" };\n\t\tcase \"block_goal\":\n\t\t\treturn { action: \"block_goal\", reason: input.reason ?? \"\" };\n\t\tcase \"get\":\n\t\t\treturn { error: \"get is handled as a read-only action.\" };\n\t\tdefault:\n\t\t\treturn { error: \"Unknown goal action.\" };\n\t}\n}\n\nfunction goalPanelModel(details: GoalToolDetails | undefined): OrchestrationPanelModel {\n\tconst state = details?.state;\n\tif (!state) {\n\t\treturn {\n\t\t\tlabel: \"goal\",\n\t\t\taction: details?.action,\n\t\t\tstatus: details?.error ? \"error\" : \"idle\",\n\t\t\temptyText: details?.error ?? \"No goal state was returned.\",\n\t\t};\n\t}\n\tconst satisfied = state.requirements.filter((requirement) => requirement.status === \"satisfied\").length;\n\treturn {\n\t\tlabel: \"goal\",\n\t\taction: details.action,\n\t\tstatus:\n\t\t\tstate.status === \"completed\"\n\t\t\t\t? \"success\"\n\t\t\t\t: state.status === \"blocked\" ||\n\t\t\t\t\t\tstate.status === \"paused\" ||\n\t\t\t\t\t\tstate.status === \"usage_limited\" ||\n\t\t\t\t\t\tstate.status === \"budget_limited\"\n\t\t\t\t\t? \"warning\"\n\t\t\t\t\t: state.status === \"cancelled\"\n\t\t\t\t\t\t? \"idle\"\n\t\t\t\t\t\t: \"running\",\n\t\tsummary: [\n\t\t\t`${satisfied}/${state.requirements.length} requirements`,\n\t\t\t`${state.evidence.length} evidence`,\n\t\t\t...(state.tokenBudget !== undefined ? [`${state.tokensUsed ?? 0}/${state.tokenBudget} tokens`] : []),\n\t\t],\n\t\trows: state.requirements.map((requirement) => ({\n\t\t\tstatus:\n\t\t\t\trequirement.status === \"satisfied\"\n\t\t\t\t\t? (\"completed\" as const)\n\t\t\t\t\t: requirement.status === \"open\"\n\t\t\t\t\t\t? (\"pending\" as const)\n\t\t\t\t\t\t: (\"blocked\" as const),\n\t\t\tlabel: requirement.text,\n\t\t\tmeta: [\n\t\t\t\trequirement.id,\n\t\t\t\trequirement.evidenceIds.length > 0 ? `${requirement.evidenceIds.length} evidence` : undefined,\n\t\t\t\trequirement.boundLaneId ? `worker ${requirement.boundLaneId}` : undefined,\n\t\t\t].filter((value): value is string => value !== undefined),\n\t\t\tdetails: requirement.blockedReason ? [`blocked: ${requirement.blockedReason}`] : undefined,\n\t\t})),\n\t\tnotices: [\n\t\t\t...(details.dispatchSkipReason\n\t\t\t\t? [{ status: \"warning\" as const, text: `Worker dispatch skipped: ${details.dispatchSkipReason}` }]\n\t\t\t\t: []),\n\t\t\t...(state.blockedReason ? [{ status: \"warning\" as const, text: state.blockedReason }] : []),\n\t\t],\n\t\temptyText: \"No requirements recorded.\",\n\t};\n}\n\nexport function createGoalToolDefinition(deps: GoalToolDependencies): ToolDefinition {\n\tconst now = deps.now ?? (() => new Date().toISOString());\n\treturn {\n\t\tname: \"goal\",\n\t\tlabel: \"goal\",\n\t\tdescription:\n\t\t\t\"Read or update the durable goal for explicitly persistent work. Use task_steps for plans and delegate for workers; owner or system controls lifecycle and budget stops.\",\n\t\tpromptSnippet: \"Read or update the durable goal.\",\n\t\tpromptGuidelines: [\n\t\t\t\"Start only for explicit persistent chat/system goal. get if uncertain; never replace unfinished goal; tokenBudget only if requested.\",\n\t\t\t\"Plans: task_steps. Workers: delegate. Legacy actions only for legacy goals.\",\n\t\t\t\"complete needs current authoritative evidence, no remaining work. block_goal needs same real impasse for 3 goal turns.\",\n\t\t],\n\t\tparameters: goalSchema,\n\t\trenderShell: \"self\",\n\t\trenderCall() {\n\t\t\treturn emptyOrchestrationCall();\n\t\t},\n\t\trenderResult(result, { expanded, isPartial }, theme) {\n\t\t\tconst details = result.details as GoalToolDetails | undefined;\n\t\t\treturn renderOrchestrationToolResult(theme, goalPanelModel(details), {\n\t\t\t\tisPartial,\n\t\t\t\tcollapse: !expanded && details?.applied === true,\n\t\t\t\texpanded: true,\n\t\t\t});\n\t\t},\n\t\tasync execute(\n\t\t\t_toolCallId,\n\t\t\tinput: GoalToolInput,\n\t\t): Promise<{\n\t\t\tcontent: Array<{ type: \"text\"; text: string }>;\n\t\t\tdetails: GoalToolDetails;\n\t\t}> {\n\t\t\tif (input.action === \"get\") {\n\t\t\t\tconst state = deps.getGoalState();\n\t\t\t\tif (!state) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: \"No goal exists for this session.\" }],\n\t\t\t\t\t\tdetails: { action: \"get\", applied: false },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\", text: summarizeGoalState(state) }],\n\t\t\t\t\tdetails: { action: \"get\", applied: false, state },\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (input.action === \"start\" && deps.authorizeStart) {\n\t\t\t\tconst error = deps.authorizeStart(input);\n\t\t\t\tif (error) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\", text: `goal start failed: ${error}` }],\n\t\t\t\t\t\tdetails: { action: \"start\", applied: false, error },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst mapped = toGoalAction(input);\n\t\t\tif (\"error\" in mapped) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${mapped.error}` }],\n\t\t\t\t\tdetails: { action: input.action, applied: false, error: mapped.error },\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tlet action: GoalAction = mapped;\n\t\t\tif (action.action === \"add_evidence\") {\n\t\t\t\tconst verified = await resolveEvidenceVerified(action.kind, action.uri, deps);\n\t\t\t\taction = { ...action, verified };\n\t\t\t}\n\t\t\t// Honest dispatch reporting: distinguish \"dispatched\" (laneId), \"declined\" (skipReason --\n\t\t\t// the dependency IS wired but the underlying delegation starter refused, e.g. disabled or\n\t\t\t// already at capacity), and \"unwired\" (no dependency at all) -- never collapse a real\n\t\t\t// decline into a silent no-laneId no-op indistinguishable from the dep being absent.\n\t\t\tlet dispatchNote: string | undefined;\n\t\t\tlet dispatchSkipReason: string | undefined;\n\t\t\t// Indeterminate-binding dedupe guard: checked BEFORE any dispatch side effect, for BOTH\n\t\t\t// routes. A requirement already bound to a lane that is either still live (a plain\n\t\t\t// duplicate) or whose liveness/outcome cannot be determined at all (for example, a legacy\n\t\t\t// snapshot with no lane record or worker result) must never be\n\t\t\t// re-dispatched silently; only a CONFIRMED terminal outcome allows a legitimate retry.\n\t\t\tlet dispatchGuardRefused = false;\n\t\t\tif (action.action === \"dispatch_worker\") {\n\t\t\t\t// Captured into a `const` so the \"dispatch_worker\" narrowing survives into the closures\n\t\t\t\t// below -- TS does not narrow a `let`-bound outer variable across a callback boundary.\n\t\t\t\tconst dispatchAction = action;\n\t\t\t\tconst boundRequirement = deps\n\t\t\t\t\t.getGoalState()\n\t\t\t\t\t?.requirements.find((r) => r.id === dispatchAction.requirementId);\n\t\t\t\tconst bound = boundRequirement?.boundLaneId;\n\t\t\t\tif (bound !== undefined) {\n\t\t\t\t\tconst boundLaneRecord = deps.getLaneRecords?.().find((record) => record.laneId === bound);\n\t\t\t\t\tconst isLiveInFlight =\n\t\t\t\t\t\tboundLaneRecord !== undefined &&\n\t\t\t\t\t\t(boundLaneRecord.status === \"queued\" || boundLaneRecord.status === \"running\");\n\t\t\t\t\tif (isLiveInFlight) {\n\t\t\t\t\t\tdispatchSkipReason = \"requirement_already_bound\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// `boundLaneRecord` present here is necessarily terminal (isLiveInFlight was false).\n\t\t\t\t\t\tconst hasTerminalOutcome =\n\t\t\t\t\t\t\tboundLaneRecord !== undefined ||\n\t\t\t\t\t\t\t(deps.getWorkerClaimSnapshots?.().some((claim) => claim.requestId === bound) ?? false);\n\t\t\t\t\t\tif (!hasTerminalOutcome) dispatchSkipReason = \"bound_lane_indeterminate\";\n\t\t\t\t\t}\n\t\t\t\t\tif (dispatchSkipReason) {\n\t\t\t\t\t\tdispatchGuardRefused = true;\n\t\t\t\t\t\tdispatchNote = `No worker was dispatched (${dispatchSkipReason}); requirement '${dispatchAction.requirementId}' remains bound to lane '${bound}'.`;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (action.action === \"dispatch_worker\" && !dispatchGuardRefused) {\n\t\t\t\tconst tmuxRequested = input.dispatchTarget === \"tmux\";\n\t\t\t\tlet useTmux = tmuxRequested && deps.dispatchTmuxWorker !== undefined;\n\t\t\t\tlet tmuxFallbackReason: string | undefined;\n\t\t\t\tlet dispatched: { laneId?: string; skipReason?: string } | undefined;\n\t\t\t\tif (useTmux) {\n\t\t\t\t\tdispatched = await deps.dispatchTmuxWorker?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t\tif (\n\t\t\t\t\t\t!dispatched?.laneId &&\n\t\t\t\t\t\tallowsNativeTmuxFallback(dispatched?.skipReason) &&\n\t\t\t\t\t\tdeps.startWorkerDelegation\n\t\t\t\t\t) {\n\t\t\t\t\t\ttmuxFallbackReason = dispatched?.skipReason;\n\t\t\t\t\t\tuseTmux = false;\n\t\t\t\t\t\tdispatched = deps.startWorkerDelegation({\n\t\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (tmuxRequested) tmuxFallbackReason = \"tmux_extension_not_loaded\";\n\t\t\t\t\tdispatched = deps.startWorkerDelegation?.({\n\t\t\t\t\t\trequirementId: action.requirementId,\n\t\t\t\t\t\tinstructions: action.instructions,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\taction = { ...action, laneId: dispatched?.laneId };\n\t\t\t\tif (dispatched?.laneId) {\n\t\t\t\t\tdispatchNote = tmuxFallbackReason\n\t\t\t\t\t\t? `Tmux route returned ${tmuxFallbackReason}; dispatched native fallback worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t: useTmux\n\t\t\t\t\t\t\t? `Dispatched tmux worker lane '${dispatched.laneId}' for requirement '${action.requirementId}'.`\n\t\t\t\t\t\t\t: `Dispatched in-process worker lane '${dispatched.laneId}' for requirement '${action.requirementId}' (native default).`;\n\t\t\t\t} else {\n\t\t\t\t\tconst wired = useTmux ? deps.dispatchTmuxWorker : deps.startWorkerDelegation;\n\t\t\t\t\tdispatchSkipReason = dispatched?.skipReason ?? (wired ? \"declined\" : \"dependency_unwired\");\n\t\t\t\t\tdispatchNote = `${tmuxFallbackReason ? `Tmux route returned ${tmuxFallbackReason}; ` : \"\"}No worker was dispatched (${dispatchSkipReason}); requirement '${action.requirementId}' is recorded but not bound to a lane.`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst current = deps.getGoalState();\n\t\t\tlet nextState: GoalState;\n\t\t\tif (action.action === \"dispatch_worker\" && dispatchGuardRefused) {\n\t\t\t\t// Short-circuit: the guard refused before any dispatch attempt -- never call\n\t\t\t\t// applyGoalAction for this turn, so the requirement's existing `boundLaneId` is\n\t\t\t\t// preserved exactly as-is rather than clobbered to `undefined` by the reducer's\n\t\t\t\t// unconditional `boundLaneId: event.laneId` write (goal-state.ts's dispatch_worker case).\n\t\t\t\t// `current` is guaranteed defined here: the guard only refuses when a requirement with\n\t\t\t\t// a `boundLaneId` was found on it.\n\t\t\t\tnextState = current as GoalState;\n\t\t\t} else {\n\t\t\t\tconst result = applyGoalAction(current, action, now(), {\n\t\t\t\t\trequireVerifiedEvidenceForCompletion: deps.requireVerifiedEvidenceForCompletion?.() ?? true,\n\t\t\t\t});\n\t\t\t\tif (!result.ok) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tcontent: [{ type: \"text\" as const, text: `goal ${input.action} failed: ${result.error}` }],\n\t\t\t\t\t\tdetails: { action: input.action, applied: false, error: result.error, state: current },\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tdeps.saveGoalState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\t\t\tnextState = result.state;\n\t\t\t}\n\n\t\t\tconst summary = summarizeGoalState(nextState, { action, openTaskSteps: deps.getOpenTaskSteps?.() });\n\t\t\tconst text = dispatchNote\n\t\t\t\t? `goal ${input.action} recorded.\\n${summary}\\n${dispatchNote}`\n\t\t\t\t: `goal ${input.action} recorded.\\n${summary}`;\n\t\t\treturn {\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: {\n\t\t\t\t\taction: input.action,\n\t\t\t\t\tapplied: true,\n\t\t\t\t\tstate: nextState,\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && action.laneId ? { dispatchedLaneId: action.laneId } : {}),\n\t\t\t\t\t...(action.action === \"dispatch_worker\" && !action.laneId ? { dispatchSkipReason } : {}),\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.90.
|
|
9
|
+
"version": "0.90.7",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-sandbox",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-sandbox",
|
|
9
|
-
"version": "0.90.
|
|
9
|
+
"version": "0.90.7",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sandbox-runtime": "^0.0.26"
|
|
12
12
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-with-deps",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-with-deps",
|
|
9
|
-
"version": "0.90.
|
|
9
|
+
"version": "0.90.7",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"ms": "^2.1.3"
|
|
12
12
|
},
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-adaptative",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.7",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@caupulican/pi-adaptative",
|
|
9
|
-
"version": "0.90.
|
|
9
|
+
"version": "0.90.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@caupulican/pi-agent-core": "^0.90.
|
|
13
|
-
"@caupulican/pi-ai": "^0.90.
|
|
14
|
-
"@caupulican/pi-tui": "^0.90.
|
|
12
|
+
"@caupulican/pi-agent-core": "^0.90.7",
|
|
13
|
+
"@caupulican/pi-ai": "^0.90.7",
|
|
14
|
+
"@caupulican/pi-tui": "^0.90.7",
|
|
15
15
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
16
16
|
"chalk": "5.6.2",
|
|
17
17
|
"cross-spawn": "7.0.6",
|
|
@@ -547,11 +547,11 @@
|
|
|
547
547
|
}
|
|
548
548
|
},
|
|
549
549
|
"node_modules/@caupulican/pi-agent-core": {
|
|
550
|
-
"version": "0.90.
|
|
551
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.90.
|
|
550
|
+
"version": "0.90.7",
|
|
551
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-agent-core/-/pi-agent-core-0.90.7.tgz",
|
|
552
552
|
"license": "MIT",
|
|
553
553
|
"dependencies": {
|
|
554
|
-
"@caupulican/pi-ai": "^0.90.
|
|
554
|
+
"@caupulican/pi-ai": "^0.90.7",
|
|
555
555
|
"ignore": "7.0.5",
|
|
556
556
|
"typebox": "1.1.38",
|
|
557
557
|
"yaml": "2.9.0"
|
|
@@ -561,8 +561,8 @@
|
|
|
561
561
|
}
|
|
562
562
|
},
|
|
563
563
|
"node_modules/@caupulican/pi-ai": {
|
|
564
|
-
"version": "0.90.
|
|
565
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.90.
|
|
564
|
+
"version": "0.90.7",
|
|
565
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-ai/-/pi-ai-0.90.7.tgz",
|
|
566
566
|
"license": "MIT",
|
|
567
567
|
"dependencies": {
|
|
568
568
|
"@anthropic-ai/sdk": "0.91.1",
|
|
@@ -616,8 +616,8 @@
|
|
|
616
616
|
}
|
|
617
617
|
},
|
|
618
618
|
"node_modules/@caupulican/pi-tui": {
|
|
619
|
-
"version": "0.90.
|
|
620
|
-
"resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.90.
|
|
619
|
+
"version": "0.90.7",
|
|
620
|
+
"resolved": "https://registry.npmjs.org/@caupulican/pi-tui/-/pi-tui-0.90.7.tgz",
|
|
621
621
|
"license": "MIT",
|
|
622
622
|
"dependencies": {
|
|
623
623
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caupulican/pi-adaptative",
|
|
3
|
-
"version": "0.90.
|
|
3
|
+
"version": "0.90.7",
|
|
4
4
|
"description": "Adaptive fork of Pi coding agent for self-evolving agent harness experiments",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"postinstall": "node scripts/postinstall-python-runtime.mjs"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@caupulican/pi-agent-core": "^0.90.
|
|
88
|
-
"@caupulican/pi-ai": "^0.90.
|
|
89
|
-
"@caupulican/pi-tui": "^0.90.
|
|
87
|
+
"@caupulican/pi-agent-core": "^0.90.7",
|
|
88
|
+
"@caupulican/pi-ai": "^0.90.7",
|
|
89
|
+
"@caupulican/pi-tui": "^0.90.7",
|
|
90
90
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
91
91
|
"chalk": "5.6.2",
|
|
92
92
|
"cross-spawn": "7.0.6",
|