@caupulican/pi-adaptative 0.93.1 → 0.93.3
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 +16 -0
- package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +6 -6
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session-contracts.d.ts +2 -2
- 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.map +1 -1
- package/dist/core/agent-session.js +1 -2
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/subagent-prompt.d.ts +1 -1
- package/dist/core/autonomy/subagent-prompt.js.map +1 -1
- package/dist/core/compaction-controller.d.ts.map +1 -1
- package/dist/core/compaction-controller.js +9 -3
- package/dist/core/compaction-controller.js.map +1 -1
- package/dist/core/cost-guard.js +1 -1
- package/dist/core/cost-guard.js.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
- package/dist/core/delegation/worker-attempt-executor.js +7 -5
- package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
- package/dist/core/delegation/worker-conversation-store.d.ts.map +1 -1
- package/dist/core/delegation/worker-conversation-store.js +3 -45
- package/dist/core/delegation/worker-conversation-store.js.map +1 -1
- package/dist/core/delegation/worker-delegation-request.d.ts +5 -2
- package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-request.js +1 -1
- package/dist/core/delegation/worker-delegation-request.js.map +1 -1
- package/dist/core/extensions/bundled-virtual-modules.js +2 -0
- package/dist/core/extensions/bundled-virtual-modules.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts +1 -0
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +1 -0
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/goals/goal-session-controller.js +1 -1
- package/dist/core/goals/goal-session-controller.js.map +1 -1
- package/dist/core/model-router-controller.js +2 -2
- package/dist/core/model-router-controller.js.map +1 -1
- package/dist/core/orchestration/risk-budget.d.ts +0 -10
- package/dist/core/orchestration/risk-budget.d.ts.map +1 -1
- package/dist/core/orchestration/risk-budget.js +0 -14
- package/dist/core/orchestration/risk-budget.js.map +1 -1
- package/dist/core/provider-prompt-contracts.d.ts +1 -0
- package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
- package/dist/core/provider-prompt-contracts.js +6 -5
- package/dist/core/provider-prompt-contracts.js.map +1 -1
- package/dist/core/provider-request-runtime-controller.js +2 -2
- package/dist/core/provider-request-runtime-controller.js.map +1 -1
- package/dist/core/reflection-controller.js +1 -1
- package/dist/core/reflection-controller.js.map +1 -1
- package/dist/core/settings-manager.d.ts +5 -6
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +8 -13
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/system-prompt-builder.d.ts +1 -4
- package/dist/core/system-prompt-builder.d.ts.map +1 -1
- package/dist/core/system-prompt-builder.js +10 -10
- package/dist/core/system-prompt-builder.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +0 -16
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +21 -11
- package/dist/core/tools/delegate.js.map +1 -1
- package/dist/core/tools/edit.js +1 -1
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/profile-writer.d.ts +0 -9
- package/dist/core/tools/profile-writer.d.ts.map +1 -1
- package/dist/core/tools/profile-writer.js +0 -3
- package/dist/core/tools/profile-writer.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +7 -16
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +2 -11
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/local-model-commands.d.ts.map +1 -1
- package/dist/modes/interactive/local-model-commands.js +1 -10
- package/dist/modes/interactive/local-model-commands.js.map +1 -1
- package/dist/modes/interactive/thinking-level-descriptions.d.ts +4 -0
- package/dist/modes/interactive/thinking-level-descriptions.d.ts.map +1 -0
- package/dist/modes/interactive/thinking-level-descriptions.js +12 -0
- package/dist/modes/interactive/thinking-level-descriptions.js.map +1 -0
- package/docs/resources.md +1 -1
- package/docs/settings.md +7 -5
- package/docs/worker-profiles.md +3 -3
- 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
|
@@ -15,7 +15,10 @@ export interface WorkerDelegationModelRequest {
|
|
|
15
15
|
provider: string;
|
|
16
16
|
modelId: string;
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Trusted caller execution preferences compiled into an immutable, inherited runtime grant.
|
|
20
|
+
* The model-facing `delegate` adapter intentionally exposes a budget-free subset.
|
|
21
|
+
*/
|
|
19
22
|
export interface WorkerDelegationAuthorityRequest {
|
|
20
23
|
role?: WorkerRole;
|
|
21
24
|
model?: WorkerDelegationModelRequest;
|
|
@@ -29,7 +32,7 @@ export interface WorkerDelegationAuthorityRequest {
|
|
|
29
32
|
export declare class WorkerDelegationRequestError extends Error {
|
|
30
33
|
constructor(message: string);
|
|
31
34
|
}
|
|
32
|
-
/** Parse
|
|
35
|
+
/** Parse a caller authority request before it reaches admission or durable state. */
|
|
33
36
|
export declare function parseWorkerDelegationAuthorityRequest(value: unknown): WorkerDelegationAuthorityRequest;
|
|
34
37
|
/** A profile is an optional preset; authority is compiled and persisted by the host. */
|
|
35
38
|
export interface WorkerDelegationRequest {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-delegation-request.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,iBAAiB,EAOtB,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,MAAM,+BAA+B,CAAC;AAIvC,oGAAoG;AACpG,MAAM,WAAW,2BAA2B;IAC3C,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,sBAAsB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;;OAIG;IACH,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED
|
|
1
|
+
{"version":3,"file":"worker-delegation-request.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,iBAAiB,EAOtB,KAAK,0BAA0B,EAC/B,KAAK,UAAU,EAEf,KAAK,UAAU,EACf,MAAM,+BAA+B,CAAC;AAIvC,oGAAoG;AACpG,MAAM,WAAW,2BAA2B;IAC3C,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,sBAAsB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C;;;;OAIG;IACH,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAChD,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,KAAK,CAAC,EAAE,4BAA4B,CAAC;IACrC,aAAa,CAAC,EAAE,0BAA0B,CAAC;IAC3C,YAAY,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACtD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACD;AAYD,qFAAqF;AACrF,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,gCAAgC,CA4EtG;AAED,wFAAwF;AACxF,MAAM,WAAW,uBAAuB;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,gCAAgC,CAAC;IAC7C,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qGAAqG;IACrG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gGAAgG;IAChG,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,iGAAiG;IACjG,WAAW,CAAC,EAAE,2BAA2B,CAAC;CAC1C"}
|
|
@@ -17,7 +17,7 @@ function uniqueStringArray(value, label, options = {}) {
|
|
|
17
17
|
createError: (message) => new WorkerDelegationRequestError(message),
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
/** Parse
|
|
20
|
+
/** Parse a caller authority request before it reaches admission or durable state. */
|
|
21
21
|
export function parseWorkerDelegationAuthorityRequest(value) {
|
|
22
22
|
if (!isPlainRecord(value))
|
|
23
23
|
throw new WorkerDelegationRequestError("Delegation authority must be an object.");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-delegation-request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C,CAAC,CAAC;IAChG,CAAC;IACD,OAAO;QACN,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,aAA2C,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7B,CAAC;AACH,CAAC","sourcesContent":["import { parseBoundedStringArray } from \"../orchestration/bounded-string-array.ts\";\nimport {\n\ttype HarnessCapability,\n\tisHarnessCapability,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATHS,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationThinkingLevel,\n\ttype RiskBudget,\n\tWORKER_ROLES,\n\ttype WorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { parseRiskBudget } from \"../orchestration/risk-budget.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\n\n/** Runtime-owned task correlation retained with a durable worker dispatch. Never model-settable. */\nexport interface WorkerDelegationTaskContext {\n\trequirementIds: readonly string[];\n\tdependsOnTaskIds: readonly string[];\n\tacceptanceCriterionIds: readonly string[];\n\t/**\n\t * Optional runtime narrowing of the owner-admitted profile resources. An empty list does not\n\t * suppress owner resources: admission expands it to the immutable profile pointer set and\n\t * persists that exact selection with the attempt.\n\t */\n\tresourcePointerIds: readonly string[];\n}\n\nexport interface WorkerDelegationModelRequest {\n\tprovider: string;\n\tmodelId: string;\n}\n\n/** Model-authored execution preferences compiled into an immutable, inherited runtime grant. */\nexport interface WorkerDelegationAuthorityRequest {\n\trole?: WorkerRole;\n\tmodel?: WorkerDelegationModelRequest;\n\tthinkingLevel?: OrchestrationThinkingLevel;\n\tcapabilities?: readonly HarnessCapability[];\n\ttoolNames?: readonly string[];\n\treadPaths?: readonly string[];\n\twritePaths?: readonly string[];\n\tbudget?: RiskBudget;\n}\n\nexport class WorkerDelegationRequestError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WorkerDelegationRequestError\";\n\t}\n}\n\nfunction uniqueStringArray(value: unknown, label: string, options: { maxEntries?: number; maxLength?: number } = {}) {\n\treturn parseBoundedStringArray(value, {\n\t\t...options,\n\t\ttrim: true,\n\t\tinvalidMessage: `${label} must contain bounded, non-empty strings.`,\n\t\tduplicateMessage: `${label} must contain unique strings.`,\n\t\tcreateError: (message) => new WorkerDelegationRequestError(message),\n\t});\n}\n\n/** Parse the model-facing authority request before it reaches admission or durable state. */\nexport function parseWorkerDelegationAuthorityRequest(value: unknown): WorkerDelegationAuthorityRequest {\n\tif (!isPlainRecord(value)) throw new WorkerDelegationRequestError(\"Delegation authority must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"role\",\n\t\t\t\"model\",\n\t\t\t\"thinkingLevel\",\n\t\t\t\"capabilities\",\n\t\t\t\"toolNames\",\n\t\t\t\"readPaths\",\n\t\t\t\"writePaths\",\n\t\t\t\"budget\",\n\t\t])\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unsupported field.\");\n\t}\n\tif (value.role !== undefined && !WORKER_ROLES.includes(value.role as WorkerRole)) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority role is invalid.\");\n\t}\n\tif (\n\t\tvalue.thinkingLevel !== undefined &&\n\t\t!ORCHESTRATION_THINKING_LEVELS.includes(value.thinkingLevel as OrchestrationThinkingLevel)\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority thinkingLevel is invalid.\");\n\t}\n\tlet model: WorkerDelegationModelRequest | undefined;\n\tif (value.model !== undefined) {\n\t\tif (\n\t\t\t!isPlainRecord(value.model) ||\n\t\t\t!hasOnlyKeys(value.model, [\"provider\", \"modelId\"]) ||\n\t\t\ttypeof value.model.provider !== \"string\" ||\n\t\t\t!value.model.provider.trim() ||\n\t\t\tvalue.model.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof value.model.modelId !== \"string\" ||\n\t\t\t!value.model.modelId.trim() ||\n\t\t\tvalue.model.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH\n\t\t) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority model is invalid.\");\n\t\t}\n\t\tmodel = { provider: value.model.provider.trim(), modelId: value.model.modelId.trim() };\n\t}\n\tlet capabilities: HarnessCapability[] | undefined;\n\tif (value.capabilities !== undefined) {\n\t\tconst parsed = uniqueStringArray(value.capabilities, \"Delegation authority capabilities\");\n\t\tif (!parsed.every(isHarnessCapability)) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unknown capability.\");\n\t\t}\n\t\tcapabilities = parsed;\n\t}\n\tconst toolNames =\n\t\tvalue.toolNames === undefined ? undefined : uniqueStringArray(value.toolNames, \"Delegation authority toolNames\");\n\tconst pathOptions = { maxEntries: MAX_WORKER_AUTHORITY_PATHS, maxLength: MAX_WORKER_AUTHORITY_PATH_LENGTH };\n\tconst readPaths =\n\t\tvalue.readPaths === undefined\n\t\t\t? undefined\n\t\t\t: uniqueStringArray(value.readPaths, \"Delegation authority readPaths\", pathOptions);\n\tconst writePaths =\n\t\tvalue.writePaths === undefined\n\t\t\t? undefined\n\t\t\t: uniqueStringArray(value.writePaths, \"Delegation authority writePaths\", pathOptions);\n\tlet budget: RiskBudget | undefined;\n\ttry {\n\t\tbudget = value.budget === undefined ? undefined : parseRiskBudget(value.budget, \"Delegation authority budget\");\n\t} catch (error) {\n\t\tthrow new WorkerDelegationRequestError(error instanceof Error ? error.message : String(error));\n\t}\n\treturn {\n\t\t...(value.role ? { role: value.role as WorkerRole } : {}),\n\t\t...(model ? { model } : {}),\n\t\t...(value.thinkingLevel ? { thinkingLevel: value.thinkingLevel as OrchestrationThinkingLevel } : {}),\n\t\t...(capabilities ? { capabilities } : {}),\n\t\t...(toolNames ? { toolNames } : {}),\n\t\t...(readPaths ? { readPaths } : {}),\n\t\t...(writePaths ? { writePaths } : {}),\n\t\t...(budget ? { budget } : {}),\n\t};\n}\n\n/** A profile is an optional preset; authority is compiled and persisted by the host. */\nexport interface WorkerDelegationRequest {\n\tinstructions: string;\n\tprofileId?: string;\n\tauthority?: WorkerDelegationAuthorityRequest;\n\t/** Tool-facing immutable birth-context selection for a newly admitted logical worker. */\n\tforkTurns?: string;\n\t/** Runtime-owned creator identity for recursive delegation; never accepted from a model argument. */\n\tparentAgentId?: string;\n\t/** Runtime-owned correlation for an automatically dispatched verifier; never model-settable. */\n\tverificationOfTaskId?: string;\n\t/** Runtime-owned durable task correlation; the delegate tool schema intentionally omits this. */\n\ttaskContext?: WorkerDelegationTaskContext;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-delegation-request.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-delegation-request.ts"],"names":[],"mappings":"AAAA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AAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,aAA2C,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7B,CAAC;AACH,CAAC","sourcesContent":["import { parseBoundedStringArray } from \"../orchestration/bounded-string-array.ts\";\nimport {\n\ttype HarnessCapability,\n\tisHarnessCapability,\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATH_LENGTH,\n\tMAX_WORKER_AUTHORITY_PATHS,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationThinkingLevel,\n\ttype RiskBudget,\n\tWORKER_ROLES,\n\ttype WorkerRole,\n} from \"../orchestration/contracts.ts\";\nimport { parseRiskBudget } from \"../orchestration/risk-budget.ts\";\nimport { hasOnlyKeys, isPlainRecord } from \"../util/value-guards.ts\";\n\n/** Runtime-owned task correlation retained with a durable worker dispatch. Never model-settable. */\nexport interface WorkerDelegationTaskContext {\n\trequirementIds: readonly string[];\n\tdependsOnTaskIds: readonly string[];\n\tacceptanceCriterionIds: readonly string[];\n\t/**\n\t * Optional runtime narrowing of the owner-admitted profile resources. An empty list does not\n\t * suppress owner resources: admission expands it to the immutable profile pointer set and\n\t * persists that exact selection with the attempt.\n\t */\n\tresourcePointerIds: readonly string[];\n}\n\nexport interface WorkerDelegationModelRequest {\n\tprovider: string;\n\tmodelId: string;\n}\n\n/**\n * Trusted caller execution preferences compiled into an immutable, inherited runtime grant.\n * The model-facing `delegate` adapter intentionally exposes a budget-free subset.\n */\nexport interface WorkerDelegationAuthorityRequest {\n\trole?: WorkerRole;\n\tmodel?: WorkerDelegationModelRequest;\n\tthinkingLevel?: OrchestrationThinkingLevel;\n\tcapabilities?: readonly HarnessCapability[];\n\ttoolNames?: readonly string[];\n\treadPaths?: readonly string[];\n\twritePaths?: readonly string[];\n\tbudget?: RiskBudget;\n}\n\nexport class WorkerDelegationRequestError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"WorkerDelegationRequestError\";\n\t}\n}\n\nfunction uniqueStringArray(value: unknown, label: string, options: { maxEntries?: number; maxLength?: number } = {}) {\n\treturn parseBoundedStringArray(value, {\n\t\t...options,\n\t\ttrim: true,\n\t\tinvalidMessage: `${label} must contain bounded, non-empty strings.`,\n\t\tduplicateMessage: `${label} must contain unique strings.`,\n\t\tcreateError: (message) => new WorkerDelegationRequestError(message),\n\t});\n}\n\n/** Parse a caller authority request before it reaches admission or durable state. */\nexport function parseWorkerDelegationAuthorityRequest(value: unknown): WorkerDelegationAuthorityRequest {\n\tif (!isPlainRecord(value)) throw new WorkerDelegationRequestError(\"Delegation authority must be an object.\");\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"role\",\n\t\t\t\"model\",\n\t\t\t\"thinkingLevel\",\n\t\t\t\"capabilities\",\n\t\t\t\"toolNames\",\n\t\t\t\"readPaths\",\n\t\t\t\"writePaths\",\n\t\t\t\"budget\",\n\t\t])\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unsupported field.\");\n\t}\n\tif (value.role !== undefined && !WORKER_ROLES.includes(value.role as WorkerRole)) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority role is invalid.\");\n\t}\n\tif (\n\t\tvalue.thinkingLevel !== undefined &&\n\t\t!ORCHESTRATION_THINKING_LEVELS.includes(value.thinkingLevel as OrchestrationThinkingLevel)\n\t) {\n\t\tthrow new WorkerDelegationRequestError(\"Delegation authority thinkingLevel is invalid.\");\n\t}\n\tlet model: WorkerDelegationModelRequest | undefined;\n\tif (value.model !== undefined) {\n\t\tif (\n\t\t\t!isPlainRecord(value.model) ||\n\t\t\t!hasOnlyKeys(value.model, [\"provider\", \"modelId\"]) ||\n\t\t\ttypeof value.model.provider !== \"string\" ||\n\t\t\t!value.model.provider.trim() ||\n\t\t\tvalue.model.provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH ||\n\t\t\ttypeof value.model.modelId !== \"string\" ||\n\t\t\t!value.model.modelId.trim() ||\n\t\t\tvalue.model.modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH\n\t\t) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority model is invalid.\");\n\t\t}\n\t\tmodel = { provider: value.model.provider.trim(), modelId: value.model.modelId.trim() };\n\t}\n\tlet capabilities: HarnessCapability[] | undefined;\n\tif (value.capabilities !== undefined) {\n\t\tconst parsed = uniqueStringArray(value.capabilities, \"Delegation authority capabilities\");\n\t\tif (!parsed.every(isHarnessCapability)) {\n\t\t\tthrow new WorkerDelegationRequestError(\"Delegation authority contains an unknown capability.\");\n\t\t}\n\t\tcapabilities = parsed;\n\t}\n\tconst toolNames =\n\t\tvalue.toolNames === undefined ? undefined : uniqueStringArray(value.toolNames, \"Delegation authority toolNames\");\n\tconst pathOptions = { maxEntries: MAX_WORKER_AUTHORITY_PATHS, maxLength: MAX_WORKER_AUTHORITY_PATH_LENGTH };\n\tconst readPaths =\n\t\tvalue.readPaths === undefined\n\t\t\t? undefined\n\t\t\t: uniqueStringArray(value.readPaths, \"Delegation authority readPaths\", pathOptions);\n\tconst writePaths =\n\t\tvalue.writePaths === undefined\n\t\t\t? undefined\n\t\t\t: uniqueStringArray(value.writePaths, \"Delegation authority writePaths\", pathOptions);\n\tlet budget: RiskBudget | undefined;\n\ttry {\n\t\tbudget = value.budget === undefined ? undefined : parseRiskBudget(value.budget, \"Delegation authority budget\");\n\t} catch (error) {\n\t\tthrow new WorkerDelegationRequestError(error instanceof Error ? error.message : String(error));\n\t}\n\treturn {\n\t\t...(value.role ? { role: value.role as WorkerRole } : {}),\n\t\t...(model ? { model } : {}),\n\t\t...(value.thinkingLevel ? { thinkingLevel: value.thinkingLevel as OrchestrationThinkingLevel } : {}),\n\t\t...(capabilities ? { capabilities } : {}),\n\t\t...(toolNames ? { toolNames } : {}),\n\t\t...(readPaths ? { readPaths } : {}),\n\t\t...(writePaths ? { writePaths } : {}),\n\t\t...(budget ? { budget } : {}),\n\t};\n}\n\n/** A profile is an optional preset; authority is compiled and persisted by the host. */\nexport interface WorkerDelegationRequest {\n\tinstructions: string;\n\tprofileId?: string;\n\tauthority?: WorkerDelegationAuthorityRequest;\n\t/** Tool-facing immutable birth-context selection for a newly admitted logical worker. */\n\tforkTurns?: string;\n\t/** Runtime-owned creator identity for recursive delegation; never accepted from a model argument. */\n\tparentAgentId?: string;\n\t/** Runtime-owned correlation for an automatically dispatched verifier; never model-settable. */\n\tverificationOfTaskId?: string;\n\t/** Runtime-owned durable task correlation; the delegate tool schema intentionally omits this. */\n\ttaskContext?: WorkerDelegationTaskContext;\n}\n"]}
|
|
@@ -12,6 +12,7 @@ import * as bundledPiAgentCoreNode from "@caupulican/pi-agent-core/node";
|
|
|
12
12
|
import * as bundledPiAgentCorePaths from "@caupulican/pi-agent-core/paths";
|
|
13
13
|
import * as bundledPiAgentCoreProcessTree from "@caupulican/pi-agent-core/process-tree";
|
|
14
14
|
import * as bundledPiAgentCoreProviderRequestEstimator from "@caupulican/pi-agent-core/provider-request-estimator";
|
|
15
|
+
import * as bundledPiAgentCoreProviderRequestImageBudget from "@caupulican/pi-agent-core/provider-request-image-budget";
|
|
15
16
|
import * as bundledPiAgentCoreProviderRequestPlanner from "@caupulican/pi-agent-core/provider-request-planner";
|
|
16
17
|
import * as bundledPiAgentCoreProviderToolProjection from "@caupulican/pi-agent-core/provider-tool-projection";
|
|
17
18
|
import * as bundledPiAgentCoreReliability from "@caupulican/pi-agent-core/reliability";
|
|
@@ -66,6 +67,7 @@ const piAgentCoreVirtualSubpaths = {
|
|
|
66
67
|
paths: bundledPiAgentCorePaths,
|
|
67
68
|
"process-tree": bundledPiAgentCoreProcessTree,
|
|
68
69
|
"provider-request-estimator": bundledPiAgentCoreProviderRequestEstimator,
|
|
70
|
+
"provider-request-image-budget": bundledPiAgentCoreProviderRequestImageBudget,
|
|
69
71
|
"provider-request-planner": bundledPiAgentCoreProviderRequestPlanner,
|
|
70
72
|
"provider-tool-projection": bundledPiAgentCoreProviderToolProjection,
|
|
71
73
|
reliability: bundledPiAgentCoreReliability,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundled-virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/bundled-virtual-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,uBAAuB,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,2BAA2B,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,4BAA4B,MAAM,sCAAsC,CAAC;AACrF,OAAO,KAAK,qCAAqC,MAAM,2DAA2D,CAAC;AACnH,OAAO,KAAK,gCAAgC,MAAM,iDAAiD,CAAC;AACpG,OAAO,KAAK,gCAAgC,MAAM,2CAA2C,CAAC;AAC9F,O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M,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,WAAW,IAAI,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;KACxG,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,WAAmB;IACrD,OAAO,MAAM,CAAC,WAAW,CAAC;QACzB,CAAC,WAAW,EAAE,kBAAkB,CAAC;QACjC,GAAG,MAAM,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,WAAW,IAAI,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;KAC/G,CAAC,CAAC;AACJ,CAAC;AAED,sCAAsC,CAAC;IACtC,OAAO,EAAE,cAAc;IACvB,iBAAiB,EAAE,qBAAqB;IACxC,eAAe,EAAE,mBAAmB;IACpC,mBAAmB,EAAE,cAAc;IACnC,2BAA2B,EAAE,qBAAqB;IAClD,yBAAyB,EAAE,mBAAmB;IAC9C,GAAG,yBAAyB,CAAC,2BAA2B,CAAC;IACzD,oBAAoB,EAAE,YAAY;IAClC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC;IAC1C,2BAA2B,EAAE,oBAAoB;IACjD,GAAG,yBAAyB,CAAC,+BAA+B,CAAC;IAC7D,wBAAwB,EAAE,YAAY;IACtC,GAAG,kBAAkB,CAAC,uBAAuB,CAAC;IAC9C,iCAAiC,EAAE,oBAAoB;IACvD,GAAG,yBAAyB,CAAC,6BAA6B,CAAC;IAC3D,sBAAsB,EAAE,YAAY;IACpC,GAAG,kBAAkB,CAAC,qBAAqB,CAAC;IAC5C,+BAA+B,EAAE,oBAAoB;CACrD,CAAC,CAAC","sourcesContent":["import * as bundledPiAgentCore from \"@caupulican/pi-agent-core\";\nimport * as bundledPiAgentCoreAgent from \"@caupulican/pi-agent-core/agent\";\nimport * as bundledPiAgentCoreAgentLoop from \"@caupulican/pi-agent-core/agent-loop\";\nimport * as bundledPiAgentCoreCompaction from \"@caupulican/pi-agent-core/compaction\";\nimport * as bundledPiAgentCoreBranchSummarization from \"@caupulican/pi-agent-core/compaction/branch-summarization\";\nimport * as bundledPiAgentCoreCompactionCore from \"@caupulican/pi-agent-core/compaction/compaction\";\nimport * as bundledPiAgentCoreCompactionLoop from \"@caupulican/pi-agent-core/compaction/loop\";\nimport * as bundledPiAgentCoreTokenBudget from \"@caupulican/pi-agent-core/compaction/token-budget\";\nimport * as bundledPiAgentCoreMessageRetention from \"@caupulican/pi-agent-core/message-retention\";\nimport * as bundledPiAgentCoreMessages from \"@caupulican/pi-agent-core/messages\";\nimport * as bundledPiAgentCoreNode from \"@caupulican/pi-agent-core/node\";\nimport * as bundledPiAgentCorePaths from \"@caupulican/pi-agent-core/paths\";\nimport * as bundledPiAgentCoreProcessTree from \"@caupulican/pi-agent-core/process-tree\";\nimport * as bundledPiAgentCoreProviderRequestEstimator from \"@caupulican/pi-agent-core/provider-request-estimator\";\nimport * as bundledPiAgentCoreProviderRequestPlanner from \"@caupulican/pi-agent-core/provider-request-planner\";\nimport * as bundledPiAgentCoreProviderToolProjection from \"@caupulican/pi-agent-core/provider-tool-projection\";\nimport * as bundledPiAgentCoreReliability from \"@caupulican/pi-agent-core/reliability\";\nimport * as bundledPiAgentCoreSession from \"@caupulican/pi-agent-core/session\";\nimport * as bundledPiAgentCoreShellOutput from \"@caupulican/pi-agent-core/shell-output\";\nimport * as bundledPiAgentCoreToolFailureMemory from \"@caupulican/pi-agent-core/tool-failure-memory\";\nimport * as bundledPiAgentCoreToolProtocolResidue from \"@caupulican/pi-agent-core/tool-protocol-residue\";\nimport * as bundledPiAgentCoreTruncate from \"@caupulican/pi-agent-core/truncate\";\nimport * as bundledPiAgentCoreTypes from \"@caupulican/pi-agent-core/types\";\nimport * as bundledPiAgentCoreUsage from \"@caupulican/pi-agent-core/usage\";\nimport * as bundledPiAi from \"@caupulican/pi-ai\";\nimport * as bundledPiAiAbortSignals from \"@caupulican/pi-ai/abort-signals\";\nimport * as bundledPiAiApiRegistry from \"@caupulican/pi-ai/api-registry\";\nimport * as bundledPiAiBedrockProvider from \"@caupulican/pi-ai/bedrock-provider\";\nimport * as bundledPiAiEnvApiKeys from \"@caupulican/pi-ai/env-api-keys\";\nimport * as bundledPiAiEventStream from \"@caupulican/pi-ai/event-stream\";\nimport * as bundledPiAiFaux from \"@caupulican/pi-ai/faux\";\nimport * as bundledPiAiJsonParse from \"@caupulican/pi-ai/json-parse\";\nimport * as bundledPiAiModels from \"@caupulican/pi-ai/models\";\nimport * as bundledPiAiOauth from \"@caupulican/pi-ai/oauth\";\nimport * as bundledPiAiOverflow from \"@caupulican/pi-ai/overflow\";\nimport * as bundledPiAiProviderRetry from \"@caupulican/pi-ai/provider-retry\";\nimport * as bundledPiAiRegisterBuiltins from \"@caupulican/pi-ai/register-builtins\";\nimport * as bundledPiAiSessionResources from \"@caupulican/pi-ai/session-resources\";\nimport * as bundledPiAiStream from \"@caupulican/pi-ai/stream\";\nimport * as bundledPiAiStreamingLines from \"@caupulican/pi-ai/streaming-lines\";\nimport * as bundledPiAiTextToolProtocol from \"@caupulican/pi-ai/text-tool-protocol\";\nimport * as bundledPiAiToolRepairRegistry from \"@caupulican/pi-ai/tool-repair-registry\";\nimport * as bundledPiAiTypeboxHelpers from \"@caupulican/pi-ai/typebox-helpers\";\nimport * as bundledPiAiTypes from \"@caupulican/pi-ai/types\";\nimport * as bundledPiAiUsage from \"@caupulican/pi-ai/usage\";\nimport * as bundledPiAiUuid from \"@caupulican/pi-ai/uuid\";\nimport * as bundledPiAiValidation from \"@caupulican/pi-ai/validation\";\nimport * as bundledPiAiValidationPath from \"@caupulican/pi-ai/validation-path\";\nimport * as bundledPiTui from \"@caupulican/pi-tui\";\nimport * as bundledTypebox from \"typebox\";\nimport * as bundledTypeboxCompile from \"typebox/compile\";\nimport * as bundledTypeboxValue from \"typebox/value\";\nimport * as bundledPiCodingAgent from \"../../index.ts\";\nimport {\n\ttype PiAgentCoreExtensionSubpath,\n\ttype PiAiExtensionSubpath,\n\tregisterBundledExtensionVirtualModules,\n} from \"./virtual-modules.ts\";\n\nconst piAgentCoreVirtualSubpaths: Record<PiAgentCoreExtensionSubpath, unknown> = {\n\tagent: bundledPiAgentCoreAgent,\n\t\"agent-loop\": bundledPiAgentCoreAgentLoop,\n\tcompaction: bundledPiAgentCoreCompaction,\n\t\"compaction/branch-summarization\": bundledPiAgentCoreBranchSummarization,\n\t\"compaction/compaction\": bundledPiAgentCoreCompactionCore,\n\t\"compaction/loop\": bundledPiAgentCoreCompactionLoop,\n\t\"compaction/token-budget\": bundledPiAgentCoreTokenBudget,\n\t\"message-retention\": bundledPiAgentCoreMessageRetention,\n\tmessages: bundledPiAgentCoreMessages,\n\tnode: bundledPiAgentCoreNode,\n\tpaths: bundledPiAgentCorePaths,\n\t\"process-tree\": bundledPiAgentCoreProcessTree,\n\t\"provider-request-estimator\": bundledPiAgentCoreProviderRequestEstimator,\n\t\"provider-request-planner\": bundledPiAgentCoreProviderRequestPlanner,\n\t\"provider-tool-projection\": bundledPiAgentCoreProviderToolProjection,\n\treliability: bundledPiAgentCoreReliability,\n\tsession: bundledPiAgentCoreSession,\n\t\"shell-output\": bundledPiAgentCoreShellOutput,\n\t\"tool-failure-memory\": bundledPiAgentCoreToolFailureMemory,\n\t\"tool-protocol-residue\": bundledPiAgentCoreToolProtocolResidue,\n\ttruncate: bundledPiAgentCoreTruncate,\n\ttypes: bundledPiAgentCoreTypes,\n\tusage: bundledPiAgentCoreUsage,\n};\n\nconst piAiVirtualSubpaths: Record<PiAiExtensionSubpath, unknown> = {\n\t\"api-registry\": bundledPiAiApiRegistry,\n\t\"abort-signals\": bundledPiAiAbortSignals,\n\t\"bedrock-provider\": bundledPiAiBedrockProvider,\n\t\"event-stream\": bundledPiAiEventStream,\n\t\"env-api-keys\": bundledPiAiEnvApiKeys,\n\tfaux: bundledPiAiFaux,\n\t\"json-parse\": bundledPiAiJsonParse,\n\tmodels: bundledPiAiModels,\n\toauth: bundledPiAiOauth,\n\toverflow: bundledPiAiOverflow,\n\t\"provider-retry\": bundledPiAiProviderRetry,\n\t\"register-builtins\": bundledPiAiRegisterBuiltins,\n\tstream: bundledPiAiStream,\n\t\"session-resources\": bundledPiAiSessionResources,\n\t\"streaming-lines\": bundledPiAiStreamingLines,\n\t\"text-tool-protocol\": bundledPiAiTextToolProtocol,\n\t\"tool-repair-registry\": bundledPiAiToolRepairRegistry,\n\t\"typebox-helpers\": bundledPiAiTypeboxHelpers,\n\ttypes: bundledPiAiTypes,\n\tusage: bundledPiAiUsage,\n\tuuid: bundledPiAiUuid,\n\tvalidation: bundledPiAiValidation,\n\t\"validation-path\": bundledPiAiValidationPath,\n};\n\nfunction piAiVirtualModules(packageName: string): Record<string, unknown> {\n\treturn Object.fromEntries([\n\t\t[packageName, bundledPiAi],\n\t\t...Object.entries(piAiVirtualSubpaths).map(([subpath, module]) => [`${packageName}/${subpath}`, module]),\n\t]);\n}\n\nfunction piAgentCoreVirtualModules(packageName: string): Record<string, unknown> {\n\treturn Object.fromEntries([\n\t\t[packageName, bundledPiAgentCore],\n\t\t...Object.entries(piAgentCoreVirtualSubpaths).map(([subpath, module]) => [`${packageName}/${subpath}`, module]),\n\t]);\n}\n\nregisterBundledExtensionVirtualModules({\n\ttypebox: bundledTypebox,\n\t\"typebox/compile\": bundledTypeboxCompile,\n\t\"typebox/value\": bundledTypeboxValue,\n\t\"@sinclair/typebox\": bundledTypebox,\n\t\"@sinclair/typebox/compile\": bundledTypeboxCompile,\n\t\"@sinclair/typebox/value\": bundledTypeboxValue,\n\t...piAgentCoreVirtualModules(\"@caupulican/pi-agent-core\"),\n\t\"@caupulican/pi-tui\": bundledPiTui,\n\t...piAiVirtualModules(\"@caupulican/pi-ai\"),\n\t\"@caupulican/pi-adaptative\": bundledPiCodingAgent,\n\t...piAgentCoreVirtualModules(\"@earendil-works/pi-agent-core\"),\n\t\"@earendil-works/pi-tui\": bundledPiTui,\n\t...piAiVirtualModules(\"@earendil-works/pi-ai\"),\n\t\"@earendil-works/pi-coding-agent\": bundledPiCodingAgent,\n\t...piAgentCoreVirtualModules(\"@mariozechner/pi-agent-core\"),\n\t\"@mariozechner/pi-tui\": bundledPiTui,\n\t...piAiVirtualModules(\"@mariozechner/pi-ai\"),\n\t\"@mariozechner/pi-coding-agent\": bundledPiCodingAgent,\n});\n"]}
|
|
1
|
+
{"version":3,"file":"bundled-virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/bundled-virtual-modules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,kBAAkB,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,uBAAuB,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,2BAA2B,MAAM,sCAAsC,CAAC;AACpF,OAAO,KAAK,4BAA4B,MAAM,sCAAsC,CAAC;AACrF,OAAO,KAAK,qCAAqC,MAAM,2DAA2D,CAAC;AACnH,OAAO,KAAK,gCAAgC,MAAM,iDAAiD,CAAC;AACpG,OAAO,KAAK,gCAAgC,MAAM,2CAA2C,CAAC;AAC9F,OAAO,KAAK,6BAA6B,MAAM,mDAAmD,CAAC;AACnG,OAAO,KAAK,kCAAkC,MAAM,6CAA6C,CAAC;AAClG,OAAO,KAAK,0BAA0B,MAAM,oCAAoC,CAAC;AACjF,OAAO,KAAK,sBAAsB,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,uBAAuB,MAAM,iCAAiC,CAAC;AAC3E,OAAO,KAAK,6BAA6B,MAAM,wCAAwC,CAAC;AACxF,OAAO,KAAK,0CAA0C,MAAM,sDAAsD,CAAC;AACnH,OAAO,KAAK,4CAA4C,MAAM,yDAAyD,CAAC;AACxH,OAAO,KAAK,wCAAwC,MAAM,oDAAoD,CAAC;AAC/G,OAAO,KAAK,wCAAwC,MAAM,oDAAoD,CAAC;AAC/G,OAAO,KAAK,6BAA6B,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EAAE,CAAC,CAAC,GAAG,WAAW,IAAI,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;KAC/G,CAAC,CAAC;AACJ,CAAC;AAED,sCAAsC,CAAC;IACtC,OAAO,EAAE,cAAc;IACvB,iBAAiB,EAAE,qBAAqB;IACxC,eAAe,EAAE,mBAAmB;IACpC,mBAAmB,EAAE,cAAc;IACnC,2BAA2B,EAAE,qBAAqB;IAClD,yBAAyB,EAAE,mBAAmB;IAC9C,GAAG,yBAAyB,CAAC,2BAA2B,CAAC;IACzD,oBAAoB,EAAE,YAAY;IAClC,GAAG,kBAAkB,CAAC,mBAAmB,CAAC;IAC1C,2BAA2B,EAAE,oBAAoB;IACjD,GAAG,yBAAyB,CAAC,+BAA+B,CAAC;IAC7D,wBAAwB,EAAE,YAAY;IACtC,GAAG,kBAAkB,CAAC,uBAAuB,CAAC;IAC9C,iCAAiC,EAAE,oBAAoB;IACvD,GAAG,yBAAyB,CAAC,6BAA6B,CAAC;IAC3D,sBAAsB,EAAE,YAAY;IACpC,GAAG,kBAAkB,CAAC,qBAAqB,CAAC;IAC5C,+BAA+B,EAAE,oBAAoB;CACrD,CAAC,CAAC","sourcesContent":["import * as bundledPiAgentCore from \"@caupulican/pi-agent-core\";\nimport * as bundledPiAgentCoreAgent from \"@caupulican/pi-agent-core/agent\";\nimport * as bundledPiAgentCoreAgentLoop from \"@caupulican/pi-agent-core/agent-loop\";\nimport * as bundledPiAgentCoreCompaction from \"@caupulican/pi-agent-core/compaction\";\nimport * as bundledPiAgentCoreBranchSummarization from \"@caupulican/pi-agent-core/compaction/branch-summarization\";\nimport * as bundledPiAgentCoreCompactionCore from \"@caupulican/pi-agent-core/compaction/compaction\";\nimport * as bundledPiAgentCoreCompactionLoop from \"@caupulican/pi-agent-core/compaction/loop\";\nimport * as bundledPiAgentCoreTokenBudget from \"@caupulican/pi-agent-core/compaction/token-budget\";\nimport * as bundledPiAgentCoreMessageRetention from \"@caupulican/pi-agent-core/message-retention\";\nimport * as bundledPiAgentCoreMessages from \"@caupulican/pi-agent-core/messages\";\nimport * as bundledPiAgentCoreNode from \"@caupulican/pi-agent-core/node\";\nimport * as bundledPiAgentCorePaths from \"@caupulican/pi-agent-core/paths\";\nimport * as bundledPiAgentCoreProcessTree from \"@caupulican/pi-agent-core/process-tree\";\nimport * as bundledPiAgentCoreProviderRequestEstimator from \"@caupulican/pi-agent-core/provider-request-estimator\";\nimport * as bundledPiAgentCoreProviderRequestImageBudget from \"@caupulican/pi-agent-core/provider-request-image-budget\";\nimport * as bundledPiAgentCoreProviderRequestPlanner from \"@caupulican/pi-agent-core/provider-request-planner\";\nimport * as bundledPiAgentCoreProviderToolProjection from \"@caupulican/pi-agent-core/provider-tool-projection\";\nimport * as bundledPiAgentCoreReliability from \"@caupulican/pi-agent-core/reliability\";\nimport * as bundledPiAgentCoreSession from \"@caupulican/pi-agent-core/session\";\nimport * as bundledPiAgentCoreShellOutput from \"@caupulican/pi-agent-core/shell-output\";\nimport * as bundledPiAgentCoreToolFailureMemory from \"@caupulican/pi-agent-core/tool-failure-memory\";\nimport * as bundledPiAgentCoreToolProtocolResidue from \"@caupulican/pi-agent-core/tool-protocol-residue\";\nimport * as bundledPiAgentCoreTruncate from \"@caupulican/pi-agent-core/truncate\";\nimport * as bundledPiAgentCoreTypes from \"@caupulican/pi-agent-core/types\";\nimport * as bundledPiAgentCoreUsage from \"@caupulican/pi-agent-core/usage\";\nimport * as bundledPiAi from \"@caupulican/pi-ai\";\nimport * as bundledPiAiAbortSignals from \"@caupulican/pi-ai/abort-signals\";\nimport * as bundledPiAiApiRegistry from \"@caupulican/pi-ai/api-registry\";\nimport * as bundledPiAiBedrockProvider from \"@caupulican/pi-ai/bedrock-provider\";\nimport * as bundledPiAiEnvApiKeys from \"@caupulican/pi-ai/env-api-keys\";\nimport * as bundledPiAiEventStream from \"@caupulican/pi-ai/event-stream\";\nimport * as bundledPiAiFaux from \"@caupulican/pi-ai/faux\";\nimport * as bundledPiAiJsonParse from \"@caupulican/pi-ai/json-parse\";\nimport * as bundledPiAiModels from \"@caupulican/pi-ai/models\";\nimport * as bundledPiAiOauth from \"@caupulican/pi-ai/oauth\";\nimport * as bundledPiAiOverflow from \"@caupulican/pi-ai/overflow\";\nimport * as bundledPiAiProviderRetry from \"@caupulican/pi-ai/provider-retry\";\nimport * as bundledPiAiRegisterBuiltins from \"@caupulican/pi-ai/register-builtins\";\nimport * as bundledPiAiSessionResources from \"@caupulican/pi-ai/session-resources\";\nimport * as bundledPiAiStream from \"@caupulican/pi-ai/stream\";\nimport * as bundledPiAiStreamingLines from \"@caupulican/pi-ai/streaming-lines\";\nimport * as bundledPiAiTextToolProtocol from \"@caupulican/pi-ai/text-tool-protocol\";\nimport * as bundledPiAiToolRepairRegistry from \"@caupulican/pi-ai/tool-repair-registry\";\nimport * as bundledPiAiTypeboxHelpers from \"@caupulican/pi-ai/typebox-helpers\";\nimport * as bundledPiAiTypes from \"@caupulican/pi-ai/types\";\nimport * as bundledPiAiUsage from \"@caupulican/pi-ai/usage\";\nimport * as bundledPiAiUuid from \"@caupulican/pi-ai/uuid\";\nimport * as bundledPiAiValidation from \"@caupulican/pi-ai/validation\";\nimport * as bundledPiAiValidationPath from \"@caupulican/pi-ai/validation-path\";\nimport * as bundledPiTui from \"@caupulican/pi-tui\";\nimport * as bundledTypebox from \"typebox\";\nimport * as bundledTypeboxCompile from \"typebox/compile\";\nimport * as bundledTypeboxValue from \"typebox/value\";\nimport * as bundledPiCodingAgent from \"../../index.ts\";\nimport {\n\ttype PiAgentCoreExtensionSubpath,\n\ttype PiAiExtensionSubpath,\n\tregisterBundledExtensionVirtualModules,\n} from \"./virtual-modules.ts\";\n\nconst piAgentCoreVirtualSubpaths: Record<PiAgentCoreExtensionSubpath, unknown> = {\n\tagent: bundledPiAgentCoreAgent,\n\t\"agent-loop\": bundledPiAgentCoreAgentLoop,\n\tcompaction: bundledPiAgentCoreCompaction,\n\t\"compaction/branch-summarization\": bundledPiAgentCoreBranchSummarization,\n\t\"compaction/compaction\": bundledPiAgentCoreCompactionCore,\n\t\"compaction/loop\": bundledPiAgentCoreCompactionLoop,\n\t\"compaction/token-budget\": bundledPiAgentCoreTokenBudget,\n\t\"message-retention\": bundledPiAgentCoreMessageRetention,\n\tmessages: bundledPiAgentCoreMessages,\n\tnode: bundledPiAgentCoreNode,\n\tpaths: bundledPiAgentCorePaths,\n\t\"process-tree\": bundledPiAgentCoreProcessTree,\n\t\"provider-request-estimator\": bundledPiAgentCoreProviderRequestEstimator,\n\t\"provider-request-image-budget\": bundledPiAgentCoreProviderRequestImageBudget,\n\t\"provider-request-planner\": bundledPiAgentCoreProviderRequestPlanner,\n\t\"provider-tool-projection\": bundledPiAgentCoreProviderToolProjection,\n\treliability: bundledPiAgentCoreReliability,\n\tsession: bundledPiAgentCoreSession,\n\t\"shell-output\": bundledPiAgentCoreShellOutput,\n\t\"tool-failure-memory\": bundledPiAgentCoreToolFailureMemory,\n\t\"tool-protocol-residue\": bundledPiAgentCoreToolProtocolResidue,\n\ttruncate: bundledPiAgentCoreTruncate,\n\ttypes: bundledPiAgentCoreTypes,\n\tusage: bundledPiAgentCoreUsage,\n};\n\nconst piAiVirtualSubpaths: Record<PiAiExtensionSubpath, unknown> = {\n\t\"api-registry\": bundledPiAiApiRegistry,\n\t\"abort-signals\": bundledPiAiAbortSignals,\n\t\"bedrock-provider\": bundledPiAiBedrockProvider,\n\t\"event-stream\": bundledPiAiEventStream,\n\t\"env-api-keys\": bundledPiAiEnvApiKeys,\n\tfaux: bundledPiAiFaux,\n\t\"json-parse\": bundledPiAiJsonParse,\n\tmodels: bundledPiAiModels,\n\toauth: bundledPiAiOauth,\n\toverflow: bundledPiAiOverflow,\n\t\"provider-retry\": bundledPiAiProviderRetry,\n\t\"register-builtins\": bundledPiAiRegisterBuiltins,\n\tstream: bundledPiAiStream,\n\t\"session-resources\": bundledPiAiSessionResources,\n\t\"streaming-lines\": bundledPiAiStreamingLines,\n\t\"text-tool-protocol\": bundledPiAiTextToolProtocol,\n\t\"tool-repair-registry\": bundledPiAiToolRepairRegistry,\n\t\"typebox-helpers\": bundledPiAiTypeboxHelpers,\n\ttypes: bundledPiAiTypes,\n\tusage: bundledPiAiUsage,\n\tuuid: bundledPiAiUuid,\n\tvalidation: bundledPiAiValidation,\n\t\"validation-path\": bundledPiAiValidationPath,\n};\n\nfunction piAiVirtualModules(packageName: string): Record<string, unknown> {\n\treturn Object.fromEntries([\n\t\t[packageName, bundledPiAi],\n\t\t...Object.entries(piAiVirtualSubpaths).map(([subpath, module]) => [`${packageName}/${subpath}`, module]),\n\t]);\n}\n\nfunction piAgentCoreVirtualModules(packageName: string): Record<string, unknown> {\n\treturn Object.fromEntries([\n\t\t[packageName, bundledPiAgentCore],\n\t\t...Object.entries(piAgentCoreVirtualSubpaths).map(([subpath, module]) => [`${packageName}/${subpath}`, module]),\n\t]);\n}\n\nregisterBundledExtensionVirtualModules({\n\ttypebox: bundledTypebox,\n\t\"typebox/compile\": bundledTypeboxCompile,\n\t\"typebox/value\": bundledTypeboxValue,\n\t\"@sinclair/typebox\": bundledTypebox,\n\t\"@sinclair/typebox/compile\": bundledTypeboxCompile,\n\t\"@sinclair/typebox/value\": bundledTypeboxValue,\n\t...piAgentCoreVirtualModules(\"@caupulican/pi-agent-core\"),\n\t\"@caupulican/pi-tui\": bundledPiTui,\n\t...piAiVirtualModules(\"@caupulican/pi-ai\"),\n\t\"@caupulican/pi-adaptative\": bundledPiCodingAgent,\n\t...piAgentCoreVirtualModules(\"@earendil-works/pi-agent-core\"),\n\t\"@earendil-works/pi-tui\": bundledPiTui,\n\t...piAiVirtualModules(\"@earendil-works/pi-ai\"),\n\t\"@earendil-works/pi-coding-agent\": bundledPiCodingAgent,\n\t...piAgentCoreVirtualModules(\"@mariozechner/pi-agent-core\"),\n\t\"@mariozechner/pi-tui\": bundledPiTui,\n\t...piAiVirtualModules(\"@mariozechner/pi-ai\"),\n\t\"@mariozechner/pi-coding-agent\": bundledPiCodingAgent,\n});\n"]}
|
|
@@ -12,6 +12,7 @@ export declare const PI_AGENT_CORE_EXTENSION_SUBPATHS: {
|
|
|
12
12
|
readonly paths: "agent/src/utils/paths.ts";
|
|
13
13
|
readonly "process-tree": "agent/src/reliability/process-tree.ts";
|
|
14
14
|
readonly "provider-request-estimator": "agent/src/provider-request-estimator.ts";
|
|
15
|
+
readonly "provider-request-image-budget": "agent/src/provider-request-image-budget.ts";
|
|
15
16
|
readonly "provider-request-planner": "agent/src/provider-request-planner.ts";
|
|
16
17
|
readonly "provider-tool-projection": "agent/src/provider-tool-projection.ts";
|
|
17
18
|
readonly reliability: "agent/src/reliability/index.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules.d.ts","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gCAAgC;aAC5C,KAAK,EAAE,oBAAoB;aAC3B,YAAY,EAAE,yBAAyB;aACvC,UAAU,EAAE,+BAA+B;aAC3C,iCAAiC,EAAE,8CAA8C;aACjF,uBAAuB,EAAE,oCAAoC;aAC7D,iBAAiB,EAAE,8BAA8B;aACjD,yBAAyB,EAAE,sCAAsC;aACjE,mBAAmB,EAAE,wCAAwC;aAC7D,QAAQ,EAAE,uBAAuB;aACjC,IAAI,EAAE,mBAAmB;aACzB,KAAK,EAAE,0BAA0B;aACjC,cAAc,EAAE,uCAAuC;aACvD,4BAA4B,EAAE,yCAAyC;aACvE,0BAA0B,EAAE,uCAAuC;aACnE,0BAA0B,EAAE,uCAAuC;aACnE,WAAW,EAAE,gCAAgC;aAC7C,OAAO,EAAE,sCAAsC;aAC/C,cAAc,EAAE,iCAAiC;aACjD,qBAAqB,EAAE,kCAAkC;aACzD,uBAAuB,EAAE,oCAAoC;aAC7D,QAAQ,EAAE,6BAA6B;aACvC,KAAK,EAAE,oBAAoB;aAC3B,KAAK,EAAE,oBAAoB;CAClB,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,MAAM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AAiB,EAAE,iCAAiC;CAC3C,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,wBAAwB,CAAC;AAIzE,wBAAgB,sCAAsC,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAG7F;AAED,wBAAgB,iCAAiC,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAKrF"}
|
|
@@ -12,6 +12,7 @@ export const PI_AGENT_CORE_EXTENSION_SUBPATHS = {
|
|
|
12
12
|
paths: "agent/src/utils/paths.ts",
|
|
13
13
|
"process-tree": "agent/src/reliability/process-tree.ts",
|
|
14
14
|
"provider-request-estimator": "agent/src/provider-request-estimator.ts",
|
|
15
|
+
"provider-request-image-budget": "agent/src/provider-request-image-budget.ts",
|
|
15
16
|
"provider-request-planner": "agent/src/provider-request-planner.ts",
|
|
16
17
|
"provider-tool-projection": "agent/src/provider-tool-projection.ts",
|
|
17
18
|
reliability: "agent/src/reliability/index.ts",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC/C,KAAK,EAAE,oBAAoB;IAC3B,YAAY,EAAE,yBAAyB;IACvC,UAAU,EAAE,+BAA+B;IAC3C,iCAAiC,EAAE,8CAA8C;IACjF,uBAAuB,EAAE,oCAAoC;IAC7D,iBAAiB,EAAE,8BAA8B;IACjD,yBAAyB,EAAE,sCAAsC;IACjE,mBAAmB,EAAE,wCAAwC;IAC7D,QAAQ,EAAE,uBAAuB;IACjC,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE,0BAA0B;IACjC,cAAc,EAAE,uCAAuC;IACvD,4BAA4B,EAAE,yCAAyC;IACvE,0BAA0B,EAAE,uCAAuC;IACnE,0BAA0B,EAAE,uCAAuC;IACnE,WAAW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AK,CAAC,4EAA4E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC9B,CAAC","sourcesContent":["export const PI_AGENT_CORE_EXTENSION_SUBPATHS = {\n\tagent: \"agent/src/agent.ts\",\n\t\"agent-loop\": \"agent/src/agent-loop.ts\",\n\tcompaction: \"agent/src/compaction/index.ts\",\n\t\"compaction/branch-summarization\": \"agent/src/compaction/branch-summarization.ts\",\n\t\"compaction/compaction\": \"agent/src/compaction/compaction.ts\",\n\t\"compaction/loop\": \"agent/src/compaction/loop.ts\",\n\t\"compaction/token-budget\": \"agent/src/compaction/token-budget.ts\",\n\t\"message-retention\": \"agent/src/session/message-retention.ts\",\n\tmessages: \"agent/src/messages.ts\",\n\tnode: \"agent/src/node.ts\",\n\tpaths: \"agent/src/utils/paths.ts\",\n\t\"process-tree\": \"agent/src/reliability/process-tree.ts\",\n\t\"provider-request-estimator\": \"agent/src/provider-request-estimator.ts\",\n\t\"provider-request-planner\": \"agent/src/provider-request-planner.ts\",\n\t\"provider-tool-projection\": \"agent/src/provider-tool-projection.ts\",\n\treliability: \"agent/src/reliability/index.ts\",\n\tsession: \"agent/src/session/session-manager.ts\",\n\t\"shell-output\": \"agent/src/utils/shell-output.ts\",\n\t\"tool-failure-memory\": \"agent/src/tool-failure-memory.ts\",\n\t\"tool-protocol-residue\": \"agent/src/tool-protocol-residue.ts\",\n\ttruncate: \"agent/src/utils/truncate.ts\",\n\ttypes: \"agent/src/types.ts\",\n\tusage: \"agent/src/usage.ts\",\n} as const;\n\nexport type PiAgentCoreExtensionSubpath = keyof typeof PI_AGENT_CORE_EXTENSION_SUBPATHS;\n\nexport const PI_AI_EXTENSION_SUBPATHS = {\n\t\"api-registry\": \"ai/src/api-registry.ts\",\n\t\"abort-signals\": \"ai/src/utils/abort-signals.ts\",\n\t\"bedrock-provider\": \"ai/src/bedrock-provider.ts\",\n\t\"event-stream\": \"ai/src/utils/event-stream.ts\",\n\t\"env-api-keys\": \"ai/src/env-api-keys.ts\",\n\tfaux: \"ai/src/providers/faux.ts\",\n\t\"json-parse\": \"ai/src/utils/json-parse.ts\",\n\tmodels: \"ai/src/models.ts\",\n\toauth: \"ai/src/oauth.ts\",\n\toverflow: \"ai/src/utils/overflow.ts\",\n\t\"provider-retry\": \"ai/src/utils/provider-retry.ts\",\n\t\"register-builtins\": \"ai/src/providers/register-builtins.ts\",\n\tstream: \"ai/src/stream.ts\",\n\t\"session-resources\": \"ai/src/session-resources.ts\",\n\t\"streaming-lines\": \"ai/src/utils/streaming-lines.ts\",\n\t\"text-tool-protocol\": \"ai/src/utils/tool-repair/text-protocol.ts\",\n\t\"tool-repair-registry\": \"ai/src/utils/tool-repair/registry.ts\",\n\t\"typebox-helpers\": \"ai/src/utils/typebox-helpers.ts\",\n\ttypes: \"ai/src/types.ts\",\n\tusage: \"ai/src/usage.ts\",\n\tuuid: \"ai/src/utils/uuid.ts\",\n\tvalidation: \"ai/src/utils/validation.ts\",\n\t\"validation-path\": \"ai/src/utils/validation-path.ts\",\n} as const;\n\nexport type PiAiExtensionSubpath = keyof typeof PI_AI_EXTENSION_SUBPATHS;\n\nlet bundledVirtualModules: Readonly<Record<string, unknown>> | undefined;\n\nexport function registerBundledExtensionVirtualModules(modules: Record<string, unknown>): void {\n\tif (bundledVirtualModules) throw new Error(\"Bundled extension virtual modules are already registered\");\n\tbundledVirtualModules = Object.freeze({ ...modules });\n}\n\nexport function getBundledExtensionVirtualModules(): Readonly<Record<string, unknown>> {\n\tif (!bundledVirtualModules) {\n\t\tthrow new Error(\"Bun extension virtual modules were not registered by the binary entrypoint\");\n\t}\n\treturn bundledVirtualModules;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"virtual-modules.js","sourceRoot":"","sources":["../../../src/core/extensions/virtual-modules.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC/C,KAAK,EAAE,oBAAoB;IAC3B,YAAY,EAAE,yBAAyB;IACvC,UAAU,EAAE,+BAA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IAC5B,UAAU,EAAE,4BAA4B;IACxC,iBAAiB,EAAE,iCAAiC;CAC3C,CAAC;AAIX,IAAI,qBAAoE,CAAC;AAEzE,MAAM,UAAU,sCAAsC,CAAC,OAAgC;IACtF,IAAI,qBAAqB;QAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IACvG,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,iCAAiC;IAChD,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IAC/F,CAAC;IACD,OAAO,qBAAqB,CAAC;AAC9B,CAAC","sourcesContent":["export const PI_AGENT_CORE_EXTENSION_SUBPATHS = {\n\tagent: \"agent/src/agent.ts\",\n\t\"agent-loop\": \"agent/src/agent-loop.ts\",\n\tcompaction: \"agent/src/compaction/index.ts\",\n\t\"compaction/branch-summarization\": \"agent/src/compaction/branch-summarization.ts\",\n\t\"compaction/compaction\": \"agent/src/compaction/compaction.ts\",\n\t\"compaction/loop\": \"agent/src/compaction/loop.ts\",\n\t\"compaction/token-budget\": \"agent/src/compaction/token-budget.ts\",\n\t\"message-retention\": \"agent/src/session/message-retention.ts\",\n\tmessages: \"agent/src/messages.ts\",\n\tnode: \"agent/src/node.ts\",\n\tpaths: \"agent/src/utils/paths.ts\",\n\t\"process-tree\": \"agent/src/reliability/process-tree.ts\",\n\t\"provider-request-estimator\": \"agent/src/provider-request-estimator.ts\",\n\t\"provider-request-image-budget\": \"agent/src/provider-request-image-budget.ts\",\n\t\"provider-request-planner\": \"agent/src/provider-request-planner.ts\",\n\t\"provider-tool-projection\": \"agent/src/provider-tool-projection.ts\",\n\treliability: \"agent/src/reliability/index.ts\",\n\tsession: \"agent/src/session/session-manager.ts\",\n\t\"shell-output\": \"agent/src/utils/shell-output.ts\",\n\t\"tool-failure-memory\": \"agent/src/tool-failure-memory.ts\",\n\t\"tool-protocol-residue\": \"agent/src/tool-protocol-residue.ts\",\n\ttruncate: \"agent/src/utils/truncate.ts\",\n\ttypes: \"agent/src/types.ts\",\n\tusage: \"agent/src/usage.ts\",\n} as const;\n\nexport type PiAgentCoreExtensionSubpath = keyof typeof PI_AGENT_CORE_EXTENSION_SUBPATHS;\n\nexport const PI_AI_EXTENSION_SUBPATHS = {\n\t\"api-registry\": \"ai/src/api-registry.ts\",\n\t\"abort-signals\": \"ai/src/utils/abort-signals.ts\",\n\t\"bedrock-provider\": \"ai/src/bedrock-provider.ts\",\n\t\"event-stream\": \"ai/src/utils/event-stream.ts\",\n\t\"env-api-keys\": \"ai/src/env-api-keys.ts\",\n\tfaux: \"ai/src/providers/faux.ts\",\n\t\"json-parse\": \"ai/src/utils/json-parse.ts\",\n\tmodels: \"ai/src/models.ts\",\n\toauth: \"ai/src/oauth.ts\",\n\toverflow: \"ai/src/utils/overflow.ts\",\n\t\"provider-retry\": \"ai/src/utils/provider-retry.ts\",\n\t\"register-builtins\": \"ai/src/providers/register-builtins.ts\",\n\tstream: \"ai/src/stream.ts\",\n\t\"session-resources\": \"ai/src/session-resources.ts\",\n\t\"streaming-lines\": \"ai/src/utils/streaming-lines.ts\",\n\t\"text-tool-protocol\": \"ai/src/utils/tool-repair/text-protocol.ts\",\n\t\"tool-repair-registry\": \"ai/src/utils/tool-repair/registry.ts\",\n\t\"typebox-helpers\": \"ai/src/utils/typebox-helpers.ts\",\n\ttypes: \"ai/src/types.ts\",\n\tusage: \"ai/src/usage.ts\",\n\tuuid: \"ai/src/utils/uuid.ts\",\n\tvalidation: \"ai/src/utils/validation.ts\",\n\t\"validation-path\": \"ai/src/utils/validation-path.ts\",\n} as const;\n\nexport type PiAiExtensionSubpath = keyof typeof PI_AI_EXTENSION_SUBPATHS;\n\nlet bundledVirtualModules: Readonly<Record<string, unknown>> | undefined;\n\nexport function registerBundledExtensionVirtualModules(modules: Record<string, unknown>): void {\n\tif (bundledVirtualModules) throw new Error(\"Bundled extension virtual modules are already registered\");\n\tbundledVirtualModules = Object.freeze({ ...modules });\n}\n\nexport function getBundledExtensionVirtualModules(): Readonly<Record<string, unknown>> {\n\tif (!bundledVirtualModules) {\n\t\tthrow new Error(\"Bun extension virtual modules were not registered by the binary entrypoint\");\n\t}\n\treturn bundledVirtualModules;\n}\n"]}
|
|
@@ -367,7 +367,7 @@ export class GoalSessionController {
|
|
|
367
367
|
}
|
|
368
368
|
markHarnessGuardBlocked(info) {
|
|
369
369
|
const reason = info.reason === "provider_turn_limit"
|
|
370
|
-
? `provider_turn_limit: reached the ${info.repeats}-request provider-turn
|
|
370
|
+
? `provider_turn_limit: reached the explicit ${info.repeats}-request provider-turn limit`
|
|
371
371
|
: `runaway_tool_loop: repeated tool-call signature ${info.signature} ${info.repeats} times without progress`;
|
|
372
372
|
return this.stopActiveGoal("blocked", reason);
|
|
373
373
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-session-controller.js","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAaxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAA0B,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EACN,wBAAwB,GAGxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAkB,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAEN,qBAAqB,EACrB,mBAAmB,GACn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AC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACxF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,KAAK,kBAAkB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;QACtF,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACvC,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAEO,cAAc,CAAC,MAAsD,EAAE,MAAc;QAC5F,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { classifyFailure } from \"@caupulican/pi-agent-core/reliability\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/session\";\nimport type { AgentMessage, AgentRunawayStopInfo } from \"@caupulican/pi-agent-core/types\";\nimport type { AssistantMessage } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tGoalContinuationOnceOptions,\n\tGoalContinuationOnceResult,\n\tPromptOptions,\n} from \"../agent-session-contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { BackgroundToolTaskRef } from \"../background-tool-task-controller.ts\";\nimport { GoalLoopController } from \"../goal-loop-controller.ts\";\nimport { budgetedTokens } from \"../orchestration/capability-gateway.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { GoalBudgetExhaustedError } from \"./goal-execution-errors.ts\";\nimport { type GoalStateRevision, getGoalStateRevision, stopGoalFromSystem } from \"./goal-lifecycle.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goal-runtime-snapshot.ts\";\nimport { applyGoalEvent, type GoalState, isGoalExecutionActive, isGoalUnfinishedStatus } from \"./goal-state.ts\";\nimport { applyGoalAction } from \"./goal-tool-core.ts\";\nimport {\n\ttype ExplicitGoalStartAuthority,\n\tparseExplicitChatGoal,\n\tpriorUserPromptText,\n} from \"./natural-language-goal.ts\";\nimport {\n\tappendGoalClearedSnapshot,\n\tappendGoalStateSnapshot,\n\tgetLatestGoalStateSnapshot,\n} from \"./session-goal-state.ts\";\n\nexport interface GoalSessionControllerDeps {\n\tgetSessionManager(): SessionManager;\n\tgetModelProvider(): string | undefined;\n\tgetLaneRecords(): readonly LaneRecord[];\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;\n\tgetBackgroundToolTasks(): readonly BackgroundToolTaskRef[];\n\tsynchronizeGoalState(state: GoalState): void;\n\tscheduleGoalAutoContinueFromIdle(): void;\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\temitWarning(message: string): void;\n}\n\nexport type ChatGoalAdmission =\n\t| { status: \"not_explicit\" }\n\t| { status: \"started\"; state: GoalState }\n\t| { status: \"unfinished_goal_exists\"; state: GoalState };\n\n/**\n * Smallest remaining goal budget worth handing to the provider as one more request's OUTPUT cap.\n * `admitProviderRequest` returns the goal's remaining TOTAL budget (input+output, cache-weighted) as\n * that cap — correct only because it also narrows further downstream against the model's real output\n * limit. When remaining drops below this floor (e.g. 200k budget, 199.4k used → 600 remaining), handing\n * 600 to the provider as maxTokens produces a request that pays the FULL input cost of the turn only to\n * get cut off mid-generation (`stopReason: \"length\"`) — a doomed, wasted turn. Below the floor, stop\n * the goal cleanly BEFORE sending instead of gambling on a truncated one. Above it, the remaining-total\n * value is a generous (imprecise but safe) protective ceiling — a modest final-turn overrun is\n * acceptable; a truncated turn is not.\n */\nconst MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS = 1_000;\n\nconst goalExecutionLeaseMarker: unique symbol = Symbol(\"goalExecutionLease\");\n\n/** Identity-bound attribution for one goal-owned foreground execution. */\nexport interface GoalExecutionLease {\n\treadonly goalId?: string;\n\treadonly [goalExecutionLeaseMarker]: true;\n}\n\ninterface MutableGoalExecutionLease extends GoalExecutionLease {\n\tgoalId?: string;\n\tadoptNewGoal: boolean;\n\tadoptionBaselineGoalId?: string;\n\tprovisionalTokenBudget?: number;\n\tpendingTokens: number;\n\tpendingSpendUsd: number;\n\t/** Set once this lease has admitted a provider request while its goal was still active. Lets a\n\t * later admission on the SAME still-held lease recognize \"the goal ended mid-turn\" (drain the\n\t * in-flight turn's wrap-up response) instead of \"a new turn is starting against a dead goal\"\n\t * (which stays denied). */\n\tadmittedWhileActive: boolean;\n}\n\ninterface QueuedOwnerChatGoal {\n\ttext: string;\n\tauthority: ExplicitGoalStartAuthority;\n}\n\n/**\n * Owns durable goal state, exact continuation accounting, and the raw continuation loop. The\n * AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.\n */\nexport class GoalSessionController {\n\tprivate readonly deps: GoalSessionControllerDeps;\n\tprivate readonly loop: GoalLoopController;\n\tprivate executionLease: MutableGoalExecutionLease | undefined;\n\tprivate startAuthority: ExplicitGoalStartAuthority | undefined;\n\tprivate readonly queuedOwnerChatGoals = new WeakMap<AgentMessage, QueuedOwnerChatGoal>();\n\tprivate queuedOwnerChatExecutionLease: GoalExecutionLease | undefined;\n\n\tconstructor(deps: GoalSessionControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis.loop = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.deps.prompt(text, options),\n\t\t\trecordGoalContinuationPass: (pass) => this.recordContinuationPass(pass),\n\t\t\trecordGoalContinuationFailure: (error) => this.recordContinuationFailure(error),\n\t\t\tmarkGoalBudgetLimited: (reason) => this.markBudgetLimited(reason),\n\t\t});\n\t}\n\n\tsaveState(state: GoalState, expected?: GoalStateRevision): string {\n\t\tconst current = this.getState();\n\t\tif (\n\t\t\texpected &&\n\t\t\t(!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Goal state changed concurrently; expected ${expected.goalId}@${expected.revision}, found ${current ? `${current.goalId}@${current.revision ?? 0}` : \"none\"}. Retry against the latest state.`,\n\t\t\t);\n\t\t}\n\t\tconst entryId = appendGoalStateSnapshot(this.deps.getSessionManager(), state, current);\n\t\ttry {\n\t\t\tthis.deps.synchronizeGoalState(state);\n\t\t} catch (error) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal state persisted but durable worker reconciliation failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\treturn entryId;\n\t}\n\n\tclearState(state: GoalState, now: string): string {\n\t\tconst current = this.getState();\n\t\tconst expected = getGoalStateRevision(state);\n\t\tif (!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision) {\n\t\t\tthrow new Error(\"Goal state changed concurrently; retry clear against the latest state.\");\n\t\t}\n\t\tif (state.status !== \"completed\" && state.status !== \"cancelled\") {\n\t\t\tthis.deps.synchronizeGoalState(applyGoalEvent(state, { type: \"cancel_goal\", now }));\n\t\t}\n\t\treturn appendGoalClearedSnapshot(this.deps.getSessionManager(), state, now);\n\t}\n\n\tgetState(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.deps.getSessionManager());\n\t}\n\n\t/**\n\t * Promote high-confidence natural-language persistence into the same durable state written by the\n\t * goal tool. This is intentionally narrower than task detection: ordinary work never starts a\n\t * goal, and an unfinished goal is never replaced implicitly.\n\t */\n\tadmitOwnerChatGoal(text: string, messages: readonly { role: string; content?: unknown }[]): ChatGoalAdmission {\n\t\treturn this.admitExplicitChatGoal(text, undefined, priorUserPromptText(messages, text));\n\t}\n\n\tstartOwnerChatGoal(text: string, messages: readonly { role: string; content?: unknown }[]): string | undefined {\n\t\tconst admission = this.admitOwnerChatGoal(text, messages);\n\t\tif (admission.status === \"started\") return admission.state.goalId;\n\t\tif (admission.status === \"unfinished_goal_exists\") {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Explicit chat goal was not started because unfinished goal '${admission.state.goalId}' is ${admission.state.status}. Complete, clear, or explicitly replace it first.`,\n\t\t\t);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tqueueOwnerChatGoal(message: AgentMessage, text: string, authority: ExplicitGoalStartAuthority): void {\n\t\tthis.queuedOwnerChatGoals.set(message, { text, authority });\n\t}\n\n\tactivateQueuedOwnerChatGoal(message: AgentMessage, messages: readonly { role: string; content?: unknown }[]): void {\n\t\tconst queued = this.queuedOwnerChatGoals.get(message);\n\t\tif (!queued) return;\n\t\tthis.queuedOwnerChatGoals.delete(message);\n\t\tconst goalId = this.startOwnerChatGoal(queued.text, messages);\n\t\tif (!goalId) return;\n\t\tthis.setStartAuthority(queued.authority);\n\t\tconst lease = this.beginExecution(goalId);\n\t\tif (!lease) {\n\t\t\tthis.setStartAuthority(undefined);\n\t\t\treturn;\n\t\t}\n\t\tthis.queuedOwnerChatExecutionLease = lease;\n\t}\n\n\tendQueuedOwnerChatGoalExecution(): void {\n\t\tconst lease = this.queuedOwnerChatExecutionLease;\n\t\tif (!lease) return;\n\t\tthis.queuedOwnerChatExecutionLease = undefined;\n\t\tthis.setStartAuthority(undefined);\n\t\tthis.endExecution(lease);\n\t}\n\n\tadmitExplicitChatGoal(text: string, now?: string, priorUserText?: string): ChatGoalAdmission {\n\t\tconst admittedAt = now ?? new Date().toISOString();\n\t\tconst parsed = parseExplicitChatGoal(text, priorUserText);\n\t\tif (!parsed) return { status: \"not_explicit\" };\n\t\tconst current = this.getState();\n\t\tif (current && isGoalUnfinishedStatus(current.status)) {\n\t\t\treturn { status: \"unfinished_goal_exists\", state: current };\n\t\t}\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(`${admittedAt}\\0${current?.goalId ?? \"none\"}\\0${parsed.objective}`)\n\t\t\t.digest(\"hex\")\n\t\t\t.slice(0, 20);\n\t\tconst result = applyGoalAction(\n\t\t\tcurrent,\n\t\t\t{\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: `chat-${digest}`,\n\t\t\t\tuserGoal: parsed.objective,\n\t\t\t\ttokenBudget: parsed.tokenBudget,\n\t\t\t},\n\t\t\tadmittedAt,\n\t\t);\n\t\tif (!result.ok) throw new Error(result.error);\n\t\tthis.saveState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\treturn { status: \"started\", state: result.state };\n\t}\n\n\t/** Attribute turn/wall-clock telemetry without inferring progress (public/manual accounting seam). */\n\trecordContinuationTelemetry(pass: { turns: number; wallClockMs: number }): void {\n\t\tthis.persistContinuationPass(pass);\n\t}\n\n\t/** Attribute one host-driven pass and derive stall state from the authoritative revision. */\n\tprivate recordContinuationPass(pass: {\n\t\tturns: number;\n\t\twallClockMs: number;\n\t\tgoalId: string;\n\t\tprogressRevision: number;\n\t\tstallTurns: number;\n\t}): void {\n\t\tthis.persistContinuationPass(pass);\n\t}\n\n\tprivate persistContinuationPass(\n\t\tpass: { turns: number; wallClockMs: number } & Partial<\n\t\t\tPick<GoalState, \"goalId\" | \"progressRevision\" | \"stallTurns\">\n\t\t>,\n\t): void {\n\t\tconst state = this.getState();\n\t\tif (!state) return;\n\t\tif (pass.goalId !== undefined && state.goalId !== pass.goalId) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal continuation accounting skipped because goal '${pass.goalId}' was replaced by '${state.goalId}' during the pass.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst now = new Date().toISOString();\n\t\tlet updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: pass.turns,\n\t\t\twallClockMs: pass.wallClockMs,\n\t\t\ttokens: 0,\n\t\t\tspendUsd: 0,\n\t\t\tnow,\n\t\t});\n\t\tif (\n\t\t\tpass.progressRevision !== undefined &&\n\t\t\tpass.stallTurns !== undefined &&\n\t\t\tisGoalExecutionActive(state.status) &&\n\t\t\t(state.progressRevision ?? 0) <= pass.progressRevision &&\n\t\t\tstate.stallTurns <= pass.stallTurns\n\t\t) {\n\t\t\tupdated = applyGoalEvent(updated, { type: \"no_progress\", now });\n\t\t}\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t}\n\n\t/** Begin one foreground execution whose provider usage belongs to the specified active goal. */\n\tbeginExecution(\n\t\tgoalId: string | undefined,\n\t\toptions: { adoptNewGoal?: boolean; provisionalTokenBudget?: number } = {},\n\t): GoalExecutionLease | undefined {\n\t\tif (!goalId && !options.adoptNewGoal) return undefined;\n\t\tif (this.executionLease) throw new Error(\"Goal execution attribution is already active\");\n\t\tconst state = this.getState();\n\t\tif (goalId && (!state || state.goalId !== goalId || !isGoalExecutionActive(state.status))) return undefined;\n\t\tconst lease: MutableGoalExecutionLease = {\n\t\t\t...(goalId ? { goalId } : {}),\n\t\t\t[goalExecutionLeaseMarker]: true,\n\t\t\tadoptNewGoal: options.adoptNewGoal === true,\n\t\t\t...(options.adoptNewGoal && state ? { adoptionBaselineGoalId: state.goalId } : {}),\n\t\t\t...(options.provisionalTokenBudget !== undefined\n\t\t\t\t? { provisionalTokenBudget: options.provisionalTokenBudget }\n\t\t\t\t: {}),\n\t\t\tpendingTokens: 0,\n\t\t\tpendingSpendUsd: 0,\n\t\t\tadmittedWhileActive: false,\n\t\t};\n\t\tthis.executionLease = lease;\n\t\treturn lease;\n\t}\n\n\tendExecution(lease: GoalExecutionLease | undefined): void {\n\t\tif (!lease) return;\n\t\tif (this.executionLease !== lease) throw new Error(\"Cannot end goal execution attribution owned by another run\");\n\t\tthis.flushPendingExecutionUsage(this.executionLease);\n\t\tthis.executionLease = undefined;\n\t}\n\n\t/** Charge one observed assistant response exactly once, including routed responses buffered from persistence. */\n\trecordExecutionUsage(message: AssistantMessage): void {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return;\n\t\tconst tokens = budgetedTokens({\n\t\t\tinputTokens: Math.max(0, message.usage.input),\n\t\t\toutputTokens: Math.max(0, message.usage.output),\n\t\t\tcacheReadTokens: Math.max(0, message.usage.cacheRead),\n\t\t\tcacheWriteTokens: Math.max(0, message.usage.cacheWrite),\n\t\t\ttotalTokens: Math.max(0, message.usage.totalTokens),\n\t\t});\n\t\tconst spendUsd = Math.max(0, message.usage.cost.total);\n\t\tif (tokens === 0 && spendUsd === 0) return;\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (!state) {\n\t\t\tlease.pendingTokens += tokens;\n\t\t\tlease.pendingSpendUsd += spendUsd;\n\t\t\treturn;\n\t\t}\n\t\tthis.chargeExecutionUsage(lease, state, tokens, spendUsd);\n\t}\n\n\tprivate chargeExecutionUsage(\n\t\tlease: MutableGoalExecutionLease,\n\t\tstate: GoalState,\n\t\ttokens: number,\n\t\tspendUsd: number,\n\t): void {\n\t\tconst updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: 0,\n\t\t\twallClockMs: 0,\n\t\t\ttokens,\n\t\t\tspendUsd,\n\t\t\tnow: new Date().toISOString(),\n\t\t});\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t\tlease.pendingTokens = 0;\n\t\tlease.pendingSpendUsd = 0;\n\t\tif (\n\t\t\tisGoalExecutionActive(updated.status) &&\n\t\t\tupdated.tokenBudget !== undefined &&\n\t\t\t(updated.tokensUsed ?? 0) >= updated.tokenBudget\n\t\t) {\n\t\t\tthis.markBudgetLimited(\n\t\t\t\t`token budget exhausted (${updated.tokensUsed ?? 0}/${updated.tokenBudget}) during goal execution`,\n\t\t\t);\n\t\t}\n\t}\n\n\tmarkProtocolFailureBlocked(errorMessage: string): boolean {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return false;\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (!state || !isGoalExecutionActive(state.status)) return false;\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{ status: \"blocked\", reason: errorMessage.slice(0, 500) },\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (!stopped.ok) return false;\n\t\tthis.saveState(stopped.state, getGoalStateRevision(state));\n\t\treturn true;\n\t}\n\n\tsetStartAuthority(authority: ExplicitGoalStartAuthority | undefined): void {\n\t\tthis.startAuthority = authority;\n\t}\n\n\tauthorizeStartFromTool(input: { tokenBudget?: number }): string | undefined {\n\t\tconst authority = this.startAuthority;\n\t\tif (!authority) return \"goal start requires explicit owner authorization in the current prompt.\";\n\t\tif (authority.tokenBudget === undefined && input.tokenBudget !== undefined) {\n\t\t\treturn \"tokenBudget requires an exact numeric token ceiling in the current owner prompt.\";\n\t\t}\n\t\tif (authority.tokenBudget !== undefined && input.tokenBudget !== authority.tokenBudget) {\n\t\t\treturn `tokenBudget must equal the owner-requested ceiling ${authority.tokenBudget}.`;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * True once the currently held execution lease's goal has crossed into `budget_limited` — set\n\t * synchronously by `chargeExecutionUsage` as soon as a just-charged response crosses the ceiling.\n\t * Wired to the agent's `shouldStopAfterTurn` hook so a mid-turn budget stop ends the loop\n\t * gracefully BEFORE the next provider request is even planned, instead of only being caught by\n\t * `admitProviderRequest`'s throw — which still exists as the backstop for a fresh turn or an\n\t * external admission starting against an already budget_limited goal, but would otherwise also\n\t * fire for a request this same lease was already mid-flight for, surfacing a synthetic error\n\t * message where a clean turn end belongs.\n\t */\n\thasExecutionLeaseCrossedBudgetLimit(): boolean {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return false;\n\t\treturn this.resolveExecutionState(lease)?.status === \"budget_limited\";\n\t}\n\n\t/** Reserve only remaining output capacity; actual provider usage is charged on response. */\n\tadmitProviderRequest(): number | undefined {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return undefined;\n\t\tthis.flushPendingExecutionUsage(lease);\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (state?.status === \"budget_limited\") {\n\t\t\tthrow new GoalBudgetExhaustedError(`goal_token_budget_exhausted: ${state.blockedReason ?? lease.goalId}`);\n\t\t}\n\t\tif (state && !isGoalExecutionActive(state.status)) {\n\t\t\tif (!lease.admittedWhileActive) {\n\t\t\t\t// A fresh turn/continuation is being started against a goal that is already done —\n\t\t\t\t// keep this denied so a dead goal cannot restart itself.\n\t\t\t\tthrow new Error(`goal_execution_not_active: ${state.goalId} is ${state.status}`);\n\t\t\t}\n\t\t\t// This lease already admitted at least one request while the goal was active, so the\n\t\t\t// goal ended mid-turn (e.g. the model itself just called `goal complete`/`block`). Let\n\t\t\t// the already-in-flight turn drain to its closing response instead of throwing an error\n\t\t\t// at the user right after a successful stop.\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!state && lease.goalId !== undefined) {\n\t\t\tthrow new Error(`goal_execution_not_active: ${lease.goalId} no longer exists`);\n\t\t}\n\t\tlease.admittedWhileActive = true;\n\t\tconst tokenBudget = state?.tokenBudget ?? lease.provisionalTokenBudget;\n\t\tif (tokenBudget === undefined) return undefined;\n\t\tconst tokensUsed = state?.tokensUsed ?? lease.pendingTokens;\n\t\tconst remaining = Math.max(0, tokenBudget - tokensUsed);\n\t\tif (remaining < MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS) {\n\t\t\t// Below the floor, remaining is too small to hand to the provider as an output cap without\n\t\t\t// dooming the turn to a mid-generation truncation that still burns the full input cost.\n\t\t\t// Stop cleanly now instead of sending a request that cannot possibly complete.\n\t\t\tif (state) {\n\t\t\t\tthis.markBudgetLimited(\n\t\t\t\t\t`token budget nearly exhausted (${tokensUsed}/${tokenBudget}, ${remaining} remaining is below the ` +\n\t\t\t\t\t\t`${MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS}-token minimum viable turn) before provider request`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new GoalBudgetExhaustedError(\n\t\t\t\t`goal_token_budget_exhausted: ${remaining} tokens remain, below the ${MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS}-token minimum viable turn`,\n\t\t\t);\n\t\t}\n\t\treturn remaining;\n\t}\n\n\tprivate resolveExecutionState(lease: MutableGoalExecutionLease): GoalState | undefined {\n\t\tconst state = this.getState();\n\t\tif (!state) return undefined;\n\t\tif (lease.goalId === state.goalId) return state;\n\t\tif (lease.goalId !== undefined || !lease.adoptNewGoal) return undefined;\n\t\tif (lease.adoptionBaselineGoalId === state.goalId) return undefined;\n\t\tlease.goalId = state.goalId;\n\t\treturn state;\n\t}\n\n\tprivate flushPendingExecutionUsage(lease: MutableGoalExecutionLease): void {\n\t\tif (lease.pendingTokens === 0 && lease.pendingSpendUsd === 0) return;\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (!state) {\n\t\t\t// A speculative adopt-new-goal lease (lease.goalId still undefined) that never actually\n\t\t\t// adopted a goal this turn has nowhere to attribute usage — that is normal, not a loss.\n\t\t\t// A lease that WAS bound to a real goal but can no longer resolve it is a genuine loss of\n\t\t\t// buffered spend; fail loudly instead of silently discarding it (matches the cursor-based\n\t\t\t// accounting this replaced, which stopped the goal on `goal_usage_cursor_lost`).\n\t\t\tif (lease.goalId !== undefined) {\n\t\t\t\tthis.deps.emitWarning(\n\t\t\t\t\t`Goal usage cursor is no longer resolvable for '${lease.goalId}'; ${lease.pendingTokens} pending tokens and $${lease.pendingSpendUsd.toFixed(6)} pending spend could not be attributed and were dropped.`,\n\t\t\t\t);\n\t\t\t\tthis.recordContinuationFailure(new Error(\"goal_usage_cursor_lost\"));\n\t\t\t}\n\t\t\tlease.pendingTokens = 0;\n\t\t\tlease.pendingSpendUsd = 0;\n\t\t\treturn;\n\t\t}\n\t\tthis.chargeExecutionUsage(lease, state, lease.pendingTokens, lease.pendingSpendUsd);\n\t}\n\n\tmarkToolUnavailable(): void {\n\t\tthis.stopActiveGoal(\n\t\t\t\"blocked\",\n\t\t\t\"goal_tool_unavailable: the active capability surface cannot update durable goal state\",\n\t\t);\n\t}\n\n\tmarkHarnessGuardBlocked(info: AgentRunawayStopInfo): boolean {\n\t\tconst reason =\n\t\t\tinfo.reason === \"provider_turn_limit\"\n\t\t\t\t? `provider_turn_limit: reached the ${info.repeats}-request provider-turn cost fuse`\n\t\t\t\t: `runaway_tool_loop: repeated tool-call signature ${info.signature} ${info.repeats} times without progress`;\n\t\treturn this.stopActiveGoal(\"blocked\", reason);\n\t}\n\n\tmarkTerminalToolFailureBlocked(toolName: string): boolean {\n\t\treturn this.stopActiveGoal(\n\t\t\t\"blocked\",\n\t\t\t`terminal_tool_failure: ${toolName} reported an unrecoverable error and terminated the run`,\n\t\t);\n\t}\n\n\tgetRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tsessionManager: this.deps.getSessionManager(),\n\t\t\tsettings,\n\t\t\tlaneRecords: this.deps.getLaneRecords(),\n\t\t\ttaskRuntime: this.deps.getTaskRuntimeSnapshot(),\n\t\t\tbackgroundToolTasks: this.deps.getBackgroundToolTasks(),\n\t\t});\n\t}\n\n\tcontinueOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this.loop.continueGoalOnce(options);\n\t}\n\n\tcontinueLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this.loop.continueGoalLoop(options);\n\t}\n\n\trestoreAfterResume(): void {\n\t\tthis.deps.scheduleGoalAutoContinueFromIdle();\n\t}\n\n\tprivate recordContinuationFailure(error: unknown): void {\n\t\tconst state = this.getState();\n\t\tif (!state || !isGoalExecutionActive(state.status)) return;\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconst classified = classifyFailure({ message, provider: this.deps.getModelProvider() });\n\t\tconst status = classified.reason === \"billing_or_quota\" ? \"usage_limited\" : \"blocked\";\n\t\tthis.stopActiveGoal(status, `${classified.reason}: ${message}`);\n\t}\n\n\tprivate markBudgetLimited(reason: string): void {\n\t\tthis.stopActiveGoal(\"budget_limited\", reason);\n\t}\n\n\tprivate stopActiveGoal(status: \"blocked\" | \"usage_limited\" | \"budget_limited\", reason: string): boolean {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(state, { status, reason }, new Date().toISOString());\n\t\tif (!stopped.ok || !state) return false;\n\t\tthis.saveState(stopped.state, getGoalStateRevision(state));\n\t\treturn true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"goal-session-controller.js","sourceRoot":"","sources":["../../../src/core/goals/goal-session-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAaxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAA0B,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACvG,OAAO,EACN,wBAAwB,GAGxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAkB,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAChH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,O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AAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,eAAe,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACxF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,KAAK,kBAAkB,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;QACtF,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACvC,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IAEO,cAAc,CAAC,MAAsD,EAAE,MAAc;QAC5F,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;QACxF,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACb,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { classifyFailure } from \"@caupulican/pi-agent-core/reliability\";\nimport type { SessionManager } from \"@caupulican/pi-agent-core/session\";\nimport type { AgentMessage, AgentRunawayStopInfo } from \"@caupulican/pi-agent-core/types\";\nimport type { AssistantMessage } from \"@caupulican/pi-ai\";\nimport type {\n\tGoalContinuationLoopOptions,\n\tGoalContinuationLoopResult,\n\tGoalContinuationOnceOptions,\n\tGoalContinuationOnceResult,\n\tPromptOptions,\n} from \"../agent-session-contracts.ts\";\nimport type { LaneRecord } from \"../autonomy/lane-tracker.ts\";\nimport type { BackgroundToolTaskRef } from \"../background-tool-task-controller.ts\";\nimport { GoalLoopController } from \"../goal-loop-controller.ts\";\nimport { budgetedTokens } from \"../orchestration/capability-gateway.ts\";\nimport type { TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { GoalBudgetExhaustedError } from \"./goal-execution-errors.ts\";\nimport { type GoalStateRevision, getGoalStateRevision, stopGoalFromSystem } from \"./goal-lifecycle.ts\";\nimport {\n\tbuildGoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshot,\n\ttype GoalRuntimeSnapshotSettings,\n} from \"./goal-runtime-snapshot.ts\";\nimport { applyGoalEvent, type GoalState, isGoalExecutionActive, isGoalUnfinishedStatus } from \"./goal-state.ts\";\nimport { applyGoalAction } from \"./goal-tool-core.ts\";\nimport {\n\ttype ExplicitGoalStartAuthority,\n\tparseExplicitChatGoal,\n\tpriorUserPromptText,\n} from \"./natural-language-goal.ts\";\nimport {\n\tappendGoalClearedSnapshot,\n\tappendGoalStateSnapshot,\n\tgetLatestGoalStateSnapshot,\n} from \"./session-goal-state.ts\";\n\nexport interface GoalSessionControllerDeps {\n\tgetSessionManager(): SessionManager;\n\tgetModelProvider(): string | undefined;\n\tgetLaneRecords(): readonly LaneRecord[];\n\tgetTaskRuntimeSnapshot(): TaskRuntimeProjection | undefined;\n\tgetBackgroundToolTasks(): readonly BackgroundToolTaskRef[];\n\tsynchronizeGoalState(state: GoalState): void;\n\tscheduleGoalAutoContinueFromIdle(): void;\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\temitWarning(message: string): void;\n}\n\nexport type ChatGoalAdmission =\n\t| { status: \"not_explicit\" }\n\t| { status: \"started\"; state: GoalState }\n\t| { status: \"unfinished_goal_exists\"; state: GoalState };\n\n/**\n * Smallest remaining goal budget worth handing to the provider as one more request's OUTPUT cap.\n * `admitProviderRequest` returns the goal's remaining TOTAL budget (input+output, cache-weighted) as\n * that cap — correct only because it also narrows further downstream against the model's real output\n * limit. When remaining drops below this floor (e.g. 200k budget, 199.4k used → 600 remaining), handing\n * 600 to the provider as maxTokens produces a request that pays the FULL input cost of the turn only to\n * get cut off mid-generation (`stopReason: \"length\"`) — a doomed, wasted turn. Below the floor, stop\n * the goal cleanly BEFORE sending instead of gambling on a truncated one. Above it, the remaining-total\n * value is a generous (imprecise but safe) protective ceiling — a modest final-turn overrun is\n * acceptable; a truncated turn is not.\n */\nconst MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS = 1_000;\n\nconst goalExecutionLeaseMarker: unique symbol = Symbol(\"goalExecutionLease\");\n\n/** Identity-bound attribution for one goal-owned foreground execution. */\nexport interface GoalExecutionLease {\n\treadonly goalId?: string;\n\treadonly [goalExecutionLeaseMarker]: true;\n}\n\ninterface MutableGoalExecutionLease extends GoalExecutionLease {\n\tgoalId?: string;\n\tadoptNewGoal: boolean;\n\tadoptionBaselineGoalId?: string;\n\tprovisionalTokenBudget?: number;\n\tpendingTokens: number;\n\tpendingSpendUsd: number;\n\t/** Set once this lease has admitted a provider request while its goal was still active. Lets a\n\t * later admission on the SAME still-held lease recognize \"the goal ended mid-turn\" (drain the\n\t * in-flight turn's wrap-up response) instead of \"a new turn is starting against a dead goal\"\n\t * (which stays denied). */\n\tadmittedWhileActive: boolean;\n}\n\ninterface QueuedOwnerChatGoal {\n\ttext: string;\n\tauthority: ExplicitGoalStartAuthority;\n}\n\n/**\n * Owns durable goal state, exact continuation accounting, and the raw continuation loop. The\n * AgentSession facade supplies process collaborators but no longer implements goal lifecycle rules.\n */\nexport class GoalSessionController {\n\tprivate readonly deps: GoalSessionControllerDeps;\n\tprivate readonly loop: GoalLoopController;\n\tprivate executionLease: MutableGoalExecutionLease | undefined;\n\tprivate startAuthority: ExplicitGoalStartAuthority | undefined;\n\tprivate readonly queuedOwnerChatGoals = new WeakMap<AgentMessage, QueuedOwnerChatGoal>();\n\tprivate queuedOwnerChatExecutionLease: GoalExecutionLease | undefined;\n\n\tconstructor(deps: GoalSessionControllerDeps) {\n\t\tthis.deps = deps;\n\t\tthis.loop = new GoalLoopController({\n\t\t\tgetGoalRuntimeSnapshot: (settings) => this.getRuntimeSnapshot(settings),\n\t\t\tprompt: (text, options) => this.deps.prompt(text, options),\n\t\t\trecordGoalContinuationPass: (pass) => this.recordContinuationPass(pass),\n\t\t\trecordGoalContinuationFailure: (error) => this.recordContinuationFailure(error),\n\t\t\tmarkGoalBudgetLimited: (reason) => this.markBudgetLimited(reason),\n\t\t});\n\t}\n\n\tsaveState(state: GoalState, expected?: GoalStateRevision): string {\n\t\tconst current = this.getState();\n\t\tif (\n\t\t\texpected &&\n\t\t\t(!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Goal state changed concurrently; expected ${expected.goalId}@${expected.revision}, found ${current ? `${current.goalId}@${current.revision ?? 0}` : \"none\"}. Retry against the latest state.`,\n\t\t\t);\n\t\t}\n\t\tconst entryId = appendGoalStateSnapshot(this.deps.getSessionManager(), state, current);\n\t\ttry {\n\t\t\tthis.deps.synchronizeGoalState(state);\n\t\t} catch (error) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal state persisted but durable worker reconciliation failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t\treturn entryId;\n\t}\n\n\tclearState(state: GoalState, now: string): string {\n\t\tconst current = this.getState();\n\t\tconst expected = getGoalStateRevision(state);\n\t\tif (!current || current.goalId !== expected.goalId || (current.revision ?? 0) !== expected.revision) {\n\t\t\tthrow new Error(\"Goal state changed concurrently; retry clear against the latest state.\");\n\t\t}\n\t\tif (state.status !== \"completed\" && state.status !== \"cancelled\") {\n\t\t\tthis.deps.synchronizeGoalState(applyGoalEvent(state, { type: \"cancel_goal\", now }));\n\t\t}\n\t\treturn appendGoalClearedSnapshot(this.deps.getSessionManager(), state, now);\n\t}\n\n\tgetState(): GoalState | undefined {\n\t\treturn getLatestGoalStateSnapshot(this.deps.getSessionManager());\n\t}\n\n\t/**\n\t * Promote high-confidence natural-language persistence into the same durable state written by the\n\t * goal tool. This is intentionally narrower than task detection: ordinary work never starts a\n\t * goal, and an unfinished goal is never replaced implicitly.\n\t */\n\tadmitOwnerChatGoal(text: string, messages: readonly { role: string; content?: unknown }[]): ChatGoalAdmission {\n\t\treturn this.admitExplicitChatGoal(text, undefined, priorUserPromptText(messages, text));\n\t}\n\n\tstartOwnerChatGoal(text: string, messages: readonly { role: string; content?: unknown }[]): string | undefined {\n\t\tconst admission = this.admitOwnerChatGoal(text, messages);\n\t\tif (admission.status === \"started\") return admission.state.goalId;\n\t\tif (admission.status === \"unfinished_goal_exists\") {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Explicit chat goal was not started because unfinished goal '${admission.state.goalId}' is ${admission.state.status}. Complete, clear, or explicitly replace it first.`,\n\t\t\t);\n\t\t}\n\t\treturn undefined;\n\t}\n\n\tqueueOwnerChatGoal(message: AgentMessage, text: string, authority: ExplicitGoalStartAuthority): void {\n\t\tthis.queuedOwnerChatGoals.set(message, { text, authority });\n\t}\n\n\tactivateQueuedOwnerChatGoal(message: AgentMessage, messages: readonly { role: string; content?: unknown }[]): void {\n\t\tconst queued = this.queuedOwnerChatGoals.get(message);\n\t\tif (!queued) return;\n\t\tthis.queuedOwnerChatGoals.delete(message);\n\t\tconst goalId = this.startOwnerChatGoal(queued.text, messages);\n\t\tif (!goalId) return;\n\t\tthis.setStartAuthority(queued.authority);\n\t\tconst lease = this.beginExecution(goalId);\n\t\tif (!lease) {\n\t\t\tthis.setStartAuthority(undefined);\n\t\t\treturn;\n\t\t}\n\t\tthis.queuedOwnerChatExecutionLease = lease;\n\t}\n\n\tendQueuedOwnerChatGoalExecution(): void {\n\t\tconst lease = this.queuedOwnerChatExecutionLease;\n\t\tif (!lease) return;\n\t\tthis.queuedOwnerChatExecutionLease = undefined;\n\t\tthis.setStartAuthority(undefined);\n\t\tthis.endExecution(lease);\n\t}\n\n\tadmitExplicitChatGoal(text: string, now?: string, priorUserText?: string): ChatGoalAdmission {\n\t\tconst admittedAt = now ?? new Date().toISOString();\n\t\tconst parsed = parseExplicitChatGoal(text, priorUserText);\n\t\tif (!parsed) return { status: \"not_explicit\" };\n\t\tconst current = this.getState();\n\t\tif (current && isGoalUnfinishedStatus(current.status)) {\n\t\t\treturn { status: \"unfinished_goal_exists\", state: current };\n\t\t}\n\t\tconst digest = createHash(\"sha256\")\n\t\t\t.update(`${admittedAt}\\0${current?.goalId ?? \"none\"}\\0${parsed.objective}`)\n\t\t\t.digest(\"hex\")\n\t\t\t.slice(0, 20);\n\t\tconst result = applyGoalAction(\n\t\t\tcurrent,\n\t\t\t{\n\t\t\t\taction: \"start\",\n\t\t\t\tgoalId: `chat-${digest}`,\n\t\t\t\tuserGoal: parsed.objective,\n\t\t\t\ttokenBudget: parsed.tokenBudget,\n\t\t\t},\n\t\t\tadmittedAt,\n\t\t);\n\t\tif (!result.ok) throw new Error(result.error);\n\t\tthis.saveState(result.state, current ? getGoalStateRevision(current) : undefined);\n\t\treturn { status: \"started\", state: result.state };\n\t}\n\n\t/** Attribute turn/wall-clock telemetry without inferring progress (public/manual accounting seam). */\n\trecordContinuationTelemetry(pass: { turns: number; wallClockMs: number }): void {\n\t\tthis.persistContinuationPass(pass);\n\t}\n\n\t/** Attribute one host-driven pass and derive stall state from the authoritative revision. */\n\tprivate recordContinuationPass(pass: {\n\t\tturns: number;\n\t\twallClockMs: number;\n\t\tgoalId: string;\n\t\tprogressRevision: number;\n\t\tstallTurns: number;\n\t}): void {\n\t\tthis.persistContinuationPass(pass);\n\t}\n\n\tprivate persistContinuationPass(\n\t\tpass: { turns: number; wallClockMs: number } & Partial<\n\t\t\tPick<GoalState, \"goalId\" | \"progressRevision\" | \"stallTurns\">\n\t\t>,\n\t): void {\n\t\tconst state = this.getState();\n\t\tif (!state) return;\n\t\tif (pass.goalId !== undefined && state.goalId !== pass.goalId) {\n\t\t\tthis.deps.emitWarning(\n\t\t\t\t`Goal continuation accounting skipped because goal '${pass.goalId}' was replaced by '${state.goalId}' during the pass.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst now = new Date().toISOString();\n\t\tlet updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: pass.turns,\n\t\t\twallClockMs: pass.wallClockMs,\n\t\t\ttokens: 0,\n\t\t\tspendUsd: 0,\n\t\t\tnow,\n\t\t});\n\t\tif (\n\t\t\tpass.progressRevision !== undefined &&\n\t\t\tpass.stallTurns !== undefined &&\n\t\t\tisGoalExecutionActive(state.status) &&\n\t\t\t(state.progressRevision ?? 0) <= pass.progressRevision &&\n\t\t\tstate.stallTurns <= pass.stallTurns\n\t\t) {\n\t\t\tupdated = applyGoalEvent(updated, { type: \"no_progress\", now });\n\t\t}\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t}\n\n\t/** Begin one foreground execution whose provider usage belongs to the specified active goal. */\n\tbeginExecution(\n\t\tgoalId: string | undefined,\n\t\toptions: { adoptNewGoal?: boolean; provisionalTokenBudget?: number } = {},\n\t): GoalExecutionLease | undefined {\n\t\tif (!goalId && !options.adoptNewGoal) return undefined;\n\t\tif (this.executionLease) throw new Error(\"Goal execution attribution is already active\");\n\t\tconst state = this.getState();\n\t\tif (goalId && (!state || state.goalId !== goalId || !isGoalExecutionActive(state.status))) return undefined;\n\t\tconst lease: MutableGoalExecutionLease = {\n\t\t\t...(goalId ? { goalId } : {}),\n\t\t\t[goalExecutionLeaseMarker]: true,\n\t\t\tadoptNewGoal: options.adoptNewGoal === true,\n\t\t\t...(options.adoptNewGoal && state ? { adoptionBaselineGoalId: state.goalId } : {}),\n\t\t\t...(options.provisionalTokenBudget !== undefined\n\t\t\t\t? { provisionalTokenBudget: options.provisionalTokenBudget }\n\t\t\t\t: {}),\n\t\t\tpendingTokens: 0,\n\t\t\tpendingSpendUsd: 0,\n\t\t\tadmittedWhileActive: false,\n\t\t};\n\t\tthis.executionLease = lease;\n\t\treturn lease;\n\t}\n\n\tendExecution(lease: GoalExecutionLease | undefined): void {\n\t\tif (!lease) return;\n\t\tif (this.executionLease !== lease) throw new Error(\"Cannot end goal execution attribution owned by another run\");\n\t\tthis.flushPendingExecutionUsage(this.executionLease);\n\t\tthis.executionLease = undefined;\n\t}\n\n\t/** Charge one observed assistant response exactly once, including routed responses buffered from persistence. */\n\trecordExecutionUsage(message: AssistantMessage): void {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return;\n\t\tconst tokens = budgetedTokens({\n\t\t\tinputTokens: Math.max(0, message.usage.input),\n\t\t\toutputTokens: Math.max(0, message.usage.output),\n\t\t\tcacheReadTokens: Math.max(0, message.usage.cacheRead),\n\t\t\tcacheWriteTokens: Math.max(0, message.usage.cacheWrite),\n\t\t\ttotalTokens: Math.max(0, message.usage.totalTokens),\n\t\t});\n\t\tconst spendUsd = Math.max(0, message.usage.cost.total);\n\t\tif (tokens === 0 && spendUsd === 0) return;\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (!state) {\n\t\t\tlease.pendingTokens += tokens;\n\t\t\tlease.pendingSpendUsd += spendUsd;\n\t\t\treturn;\n\t\t}\n\t\tthis.chargeExecutionUsage(lease, state, tokens, spendUsd);\n\t}\n\n\tprivate chargeExecutionUsage(\n\t\tlease: MutableGoalExecutionLease,\n\t\tstate: GoalState,\n\t\ttokens: number,\n\t\tspendUsd: number,\n\t): void {\n\t\tconst updated = applyGoalEvent(state, {\n\t\t\ttype: \"record_continuation_budget\",\n\t\t\tturns: 0,\n\t\t\twallClockMs: 0,\n\t\t\ttokens,\n\t\t\tspendUsd,\n\t\t\tnow: new Date().toISOString(),\n\t\t});\n\t\tthis.saveState(updated, getGoalStateRevision(state));\n\t\tlease.pendingTokens = 0;\n\t\tlease.pendingSpendUsd = 0;\n\t\tif (\n\t\t\tisGoalExecutionActive(updated.status) &&\n\t\t\tupdated.tokenBudget !== undefined &&\n\t\t\t(updated.tokensUsed ?? 0) >= updated.tokenBudget\n\t\t) {\n\t\t\tthis.markBudgetLimited(\n\t\t\t\t`token budget exhausted (${updated.tokensUsed ?? 0}/${updated.tokenBudget}) during goal execution`,\n\t\t\t);\n\t\t}\n\t}\n\n\tmarkProtocolFailureBlocked(errorMessage: string): boolean {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return false;\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (!state || !isGoalExecutionActive(state.status)) return false;\n\t\tconst stopped = stopGoalFromSystem(\n\t\t\tstate,\n\t\t\t{ status: \"blocked\", reason: errorMessage.slice(0, 500) },\n\t\t\tnew Date().toISOString(),\n\t\t);\n\t\tif (!stopped.ok) return false;\n\t\tthis.saveState(stopped.state, getGoalStateRevision(state));\n\t\treturn true;\n\t}\n\n\tsetStartAuthority(authority: ExplicitGoalStartAuthority | undefined): void {\n\t\tthis.startAuthority = authority;\n\t}\n\n\tauthorizeStartFromTool(input: { tokenBudget?: number }): string | undefined {\n\t\tconst authority = this.startAuthority;\n\t\tif (!authority) return \"goal start requires explicit owner authorization in the current prompt.\";\n\t\tif (authority.tokenBudget === undefined && input.tokenBudget !== undefined) {\n\t\t\treturn \"tokenBudget requires an exact numeric token ceiling in the current owner prompt.\";\n\t\t}\n\t\tif (authority.tokenBudget !== undefined && input.tokenBudget !== authority.tokenBudget) {\n\t\t\treturn `tokenBudget must equal the owner-requested ceiling ${authority.tokenBudget}.`;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * True once the currently held execution lease's goal has crossed into `budget_limited` — set\n\t * synchronously by `chargeExecutionUsage` as soon as a just-charged response crosses the ceiling.\n\t * Wired to the agent's `shouldStopAfterTurn` hook so a mid-turn budget stop ends the loop\n\t * gracefully BEFORE the next provider request is even planned, instead of only being caught by\n\t * `admitProviderRequest`'s throw — which still exists as the backstop for a fresh turn or an\n\t * external admission starting against an already budget_limited goal, but would otherwise also\n\t * fire for a request this same lease was already mid-flight for, surfacing a synthetic error\n\t * message where a clean turn end belongs.\n\t */\n\thasExecutionLeaseCrossedBudgetLimit(): boolean {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return false;\n\t\treturn this.resolveExecutionState(lease)?.status === \"budget_limited\";\n\t}\n\n\t/** Reserve only remaining output capacity; actual provider usage is charged on response. */\n\tadmitProviderRequest(): number | undefined {\n\t\tconst lease = this.executionLease;\n\t\tif (!lease) return undefined;\n\t\tthis.flushPendingExecutionUsage(lease);\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (state?.status === \"budget_limited\") {\n\t\t\tthrow new GoalBudgetExhaustedError(`goal_token_budget_exhausted: ${state.blockedReason ?? lease.goalId}`);\n\t\t}\n\t\tif (state && !isGoalExecutionActive(state.status)) {\n\t\t\tif (!lease.admittedWhileActive) {\n\t\t\t\t// A fresh turn/continuation is being started against a goal that is already done —\n\t\t\t\t// keep this denied so a dead goal cannot restart itself.\n\t\t\t\tthrow new Error(`goal_execution_not_active: ${state.goalId} is ${state.status}`);\n\t\t\t}\n\t\t\t// This lease already admitted at least one request while the goal was active, so the\n\t\t\t// goal ended mid-turn (e.g. the model itself just called `goal complete`/`block`). Let\n\t\t\t// the already-in-flight turn drain to its closing response instead of throwing an error\n\t\t\t// at the user right after a successful stop.\n\t\t\treturn undefined;\n\t\t}\n\t\tif (!state && lease.goalId !== undefined) {\n\t\t\tthrow new Error(`goal_execution_not_active: ${lease.goalId} no longer exists`);\n\t\t}\n\t\tlease.admittedWhileActive = true;\n\t\tconst tokenBudget = state?.tokenBudget ?? lease.provisionalTokenBudget;\n\t\tif (tokenBudget === undefined) return undefined;\n\t\tconst tokensUsed = state?.tokensUsed ?? lease.pendingTokens;\n\t\tconst remaining = Math.max(0, tokenBudget - tokensUsed);\n\t\tif (remaining < MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS) {\n\t\t\t// Below the floor, remaining is too small to hand to the provider as an output cap without\n\t\t\t// dooming the turn to a mid-generation truncation that still burns the full input cost.\n\t\t\t// Stop cleanly now instead of sending a request that cannot possibly complete.\n\t\t\tif (state) {\n\t\t\t\tthis.markBudgetLimited(\n\t\t\t\t\t`token budget nearly exhausted (${tokensUsed}/${tokenBudget}, ${remaining} remaining is below the ` +\n\t\t\t\t\t\t`${MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS}-token minimum viable turn) before provider request`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new GoalBudgetExhaustedError(\n\t\t\t\t`goal_token_budget_exhausted: ${remaining} tokens remain, below the ${MIN_VIABLE_GOAL_TURN_OUTPUT_TOKENS}-token minimum viable turn`,\n\t\t\t);\n\t\t}\n\t\treturn remaining;\n\t}\n\n\tprivate resolveExecutionState(lease: MutableGoalExecutionLease): GoalState | undefined {\n\t\tconst state = this.getState();\n\t\tif (!state) return undefined;\n\t\tif (lease.goalId === state.goalId) return state;\n\t\tif (lease.goalId !== undefined || !lease.adoptNewGoal) return undefined;\n\t\tif (lease.adoptionBaselineGoalId === state.goalId) return undefined;\n\t\tlease.goalId = state.goalId;\n\t\treturn state;\n\t}\n\n\tprivate flushPendingExecutionUsage(lease: MutableGoalExecutionLease): void {\n\t\tif (lease.pendingTokens === 0 && lease.pendingSpendUsd === 0) return;\n\t\tconst state = this.resolveExecutionState(lease);\n\t\tif (!state) {\n\t\t\t// A speculative adopt-new-goal lease (lease.goalId still undefined) that never actually\n\t\t\t// adopted a goal this turn has nowhere to attribute usage — that is normal, not a loss.\n\t\t\t// A lease that WAS bound to a real goal but can no longer resolve it is a genuine loss of\n\t\t\t// buffered spend; fail loudly instead of silently discarding it (matches the cursor-based\n\t\t\t// accounting this replaced, which stopped the goal on `goal_usage_cursor_lost`).\n\t\t\tif (lease.goalId !== undefined) {\n\t\t\t\tthis.deps.emitWarning(\n\t\t\t\t\t`Goal usage cursor is no longer resolvable for '${lease.goalId}'; ${lease.pendingTokens} pending tokens and $${lease.pendingSpendUsd.toFixed(6)} pending spend could not be attributed and were dropped.`,\n\t\t\t\t);\n\t\t\t\tthis.recordContinuationFailure(new Error(\"goal_usage_cursor_lost\"));\n\t\t\t}\n\t\t\tlease.pendingTokens = 0;\n\t\t\tlease.pendingSpendUsd = 0;\n\t\t\treturn;\n\t\t}\n\t\tthis.chargeExecutionUsage(lease, state, lease.pendingTokens, lease.pendingSpendUsd);\n\t}\n\n\tmarkToolUnavailable(): void {\n\t\tthis.stopActiveGoal(\n\t\t\t\"blocked\",\n\t\t\t\"goal_tool_unavailable: the active capability surface cannot update durable goal state\",\n\t\t);\n\t}\n\n\tmarkHarnessGuardBlocked(info: AgentRunawayStopInfo): boolean {\n\t\tconst reason =\n\t\t\tinfo.reason === \"provider_turn_limit\"\n\t\t\t\t? `provider_turn_limit: reached the explicit ${info.repeats}-request provider-turn limit`\n\t\t\t\t: `runaway_tool_loop: repeated tool-call signature ${info.signature} ${info.repeats} times without progress`;\n\t\treturn this.stopActiveGoal(\"blocked\", reason);\n\t}\n\n\tmarkTerminalToolFailureBlocked(toolName: string): boolean {\n\t\treturn this.stopActiveGoal(\n\t\t\t\"blocked\",\n\t\t\t`terminal_tool_failure: ${toolName} reported an unrecoverable error and terminated the run`,\n\t\t);\n\t}\n\n\tgetRuntimeSnapshot(settings: GoalRuntimeSnapshotSettings): GoalRuntimeSnapshot {\n\t\treturn buildGoalRuntimeSnapshot({\n\t\t\tsessionManager: this.deps.getSessionManager(),\n\t\t\tsettings,\n\t\t\tlaneRecords: this.deps.getLaneRecords(),\n\t\t\ttaskRuntime: this.deps.getTaskRuntimeSnapshot(),\n\t\t\tbackgroundToolTasks: this.deps.getBackgroundToolTasks(),\n\t\t});\n\t}\n\n\tcontinueOnce(options: GoalContinuationOnceOptions): Promise<GoalContinuationOnceResult> {\n\t\treturn this.loop.continueGoalOnce(options);\n\t}\n\n\tcontinueLoop(options: GoalContinuationLoopOptions): Promise<GoalContinuationLoopResult> {\n\t\treturn this.loop.continueGoalLoop(options);\n\t}\n\n\trestoreAfterResume(): void {\n\t\tthis.deps.scheduleGoalAutoContinueFromIdle();\n\t}\n\n\tprivate recordContinuationFailure(error: unknown): void {\n\t\tconst state = this.getState();\n\t\tif (!state || !isGoalExecutionActive(state.status)) return;\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tconst classified = classifyFailure({ message, provider: this.deps.getModelProvider() });\n\t\tconst status = classified.reason === \"billing_or_quota\" ? \"usage_limited\" : \"blocked\";\n\t\tthis.stopActiveGoal(status, `${classified.reason}: ${message}`);\n\t}\n\n\tprivate markBudgetLimited(reason: string): void {\n\t\tthis.stopActiveGoal(\"budget_limited\", reason);\n\t}\n\n\tprivate stopActiveGoal(status: \"blocked\" | \"usage_limited\" | \"budget_limited\", reason: string): boolean {\n\t\tconst state = this.getState();\n\t\tconst stopped = stopGoalFromSystem(state, { status, reason }, new Date().toISOString());\n\t\tif (!stopped.ok || !state) return false;\n\t\tthis.saveState(stopped.state, getGoalStateRevision(state));\n\t\treturn true;\n\t}\n}\n"]}
|
|
@@ -617,8 +617,8 @@ export class ModelRouterController {
|
|
|
617
617
|
agent.state.tools = swappedTools;
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
-
// The routed prompt follows
|
|
621
|
-
//
|
|
620
|
+
// The routed prompt follows the routed tool surface and keeps provider-neutral delegation
|
|
621
|
+
// guidance whenever delegate remains active, including same-model thinking overrides.
|
|
622
622
|
// Per-turn only; a live extension override is preserved rather than silently replaced.
|
|
623
623
|
if (agent.state.systemPrompt === this.deps.getBaseSystemPrompt()) {
|
|
624
624
|
swappedSystemPrompt = this.deps.buildSystemPromptForToolNames(agent.state.tools.map((tool) => tool.name));
|