@narumitw/pi-subagents 2.0.1 → 2.0.2

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.
Files changed (148) hide show
  1. package/README.md +21 -8
  2. package/dist/chunks/auto-transport-SY2VHUFH.ts +109 -0
  3. package/dist/chunks/auto-transport-SY2VHUFH.ts.map +7 -0
  4. package/dist/chunks/capability-grant-CGEWOEKE.ts +19 -0
  5. package/dist/chunks/capability-grant-CGEWOEKE.ts.map +7 -0
  6. package/dist/chunks/chunk-434NII74.ts +282 -0
  7. package/dist/chunks/chunk-434NII74.ts.map +7 -0
  8. package/dist/chunks/chunk-47SK2QYC.ts +56 -0
  9. package/dist/chunks/chunk-47SK2QYC.ts.map +7 -0
  10. package/dist/chunks/chunk-6KJ34M6S.ts +159 -0
  11. package/dist/chunks/chunk-6KJ34M6S.ts.map +7 -0
  12. package/dist/chunks/chunk-7OBINKFM.ts +80 -0
  13. package/dist/chunks/chunk-7OBINKFM.ts.map +7 -0
  14. package/dist/chunks/chunk-7QPPBBXZ.ts +335 -0
  15. package/dist/chunks/chunk-7QPPBBXZ.ts.map +7 -0
  16. package/dist/chunks/chunk-AEUYS7JC.ts +73 -0
  17. package/dist/chunks/chunk-AEUYS7JC.ts.map +7 -0
  18. package/dist/chunks/chunk-BFK2Z4ZF.ts +189 -0
  19. package/dist/chunks/chunk-BFK2Z4ZF.ts.map +7 -0
  20. package/dist/chunks/chunk-BOAXY55Y.ts +153 -0
  21. package/dist/chunks/chunk-BOAXY55Y.ts.map +7 -0
  22. package/dist/chunks/chunk-C4L6P266.ts +22 -0
  23. package/dist/chunks/chunk-C4L6P266.ts.map +7 -0
  24. package/dist/chunks/chunk-DPPVEQAM.ts +29 -0
  25. package/dist/chunks/chunk-DPPVEQAM.ts.map +7 -0
  26. package/dist/chunks/chunk-DQMN4OYM.ts +913 -0
  27. package/dist/chunks/chunk-DQMN4OYM.ts.map +7 -0
  28. package/dist/chunks/chunk-DSOOH73Y.ts +238 -0
  29. package/dist/chunks/chunk-DSOOH73Y.ts.map +7 -0
  30. package/dist/chunks/chunk-EFBPISNT.ts +421 -0
  31. package/dist/chunks/chunk-EFBPISNT.ts.map +7 -0
  32. package/dist/chunks/chunk-EWWXFU7N.ts +150 -0
  33. package/dist/chunks/chunk-EWWXFU7N.ts.map +7 -0
  34. package/dist/chunks/chunk-F4L2UVSK.ts +380 -0
  35. package/dist/chunks/chunk-F4L2UVSK.ts.map +7 -0
  36. package/dist/chunks/chunk-F5YWVHQX.ts +1543 -0
  37. package/dist/chunks/chunk-F5YWVHQX.ts.map +7 -0
  38. package/dist/chunks/chunk-G3RSMSXJ.ts +63 -0
  39. package/dist/chunks/chunk-G3RSMSXJ.ts.map +7 -0
  40. package/dist/chunks/chunk-G6VZTCFH.ts +70 -0
  41. package/dist/chunks/chunk-G6VZTCFH.ts.map +7 -0
  42. package/dist/chunks/chunk-H3FP6DLR.ts +160 -0
  43. package/dist/chunks/chunk-H3FP6DLR.ts.map +7 -0
  44. package/dist/chunks/chunk-HA36LPCO.ts +130 -0
  45. package/dist/chunks/chunk-HA36LPCO.ts.map +7 -0
  46. package/dist/chunks/chunk-HKC4ES4B.ts +65 -0
  47. package/dist/chunks/chunk-HKC4ES4B.ts.map +7 -0
  48. package/dist/chunks/chunk-HOP5FXDT.ts +27 -0
  49. package/dist/chunks/chunk-HOP5FXDT.ts.map +7 -0
  50. package/dist/chunks/chunk-I2FAK44T.ts +324 -0
  51. package/dist/chunks/chunk-I2FAK44T.ts.map +7 -0
  52. package/dist/chunks/chunk-IGAMVWFN.ts +139 -0
  53. package/dist/chunks/chunk-IGAMVWFN.ts.map +7 -0
  54. package/dist/chunks/chunk-KMGKCEO4.ts +38 -0
  55. package/dist/chunks/chunk-KMGKCEO4.ts.map +7 -0
  56. package/dist/chunks/chunk-N7BLVXKK.ts +73 -0
  57. package/dist/chunks/chunk-N7BLVXKK.ts.map +7 -0
  58. package/dist/chunks/chunk-NIF42QMF.ts +297 -0
  59. package/dist/chunks/chunk-NIF42QMF.ts.map +7 -0
  60. package/dist/chunks/chunk-O4VO6JUJ.ts +52 -0
  61. package/dist/chunks/chunk-O4VO6JUJ.ts.map +7 -0
  62. package/dist/chunks/chunk-ONDTY4EL.ts +91 -0
  63. package/dist/chunks/chunk-ONDTY4EL.ts.map +7 -0
  64. package/dist/chunks/chunk-OVPHFGKO.ts +1769 -0
  65. package/dist/chunks/chunk-OVPHFGKO.ts.map +7 -0
  66. package/dist/chunks/chunk-P7OH4XMF.ts +60 -0
  67. package/dist/chunks/chunk-P7OH4XMF.ts.map +7 -0
  68. package/dist/chunks/chunk-PSK43Y6A.ts +339 -0
  69. package/dist/chunks/chunk-PSK43Y6A.ts.map +7 -0
  70. package/dist/chunks/chunk-QBORTI4W.ts +468 -0
  71. package/dist/chunks/chunk-QBORTI4W.ts.map +7 -0
  72. package/dist/chunks/chunk-QDVGH2X7.ts +171 -0
  73. package/dist/chunks/chunk-QDVGH2X7.ts.map +7 -0
  74. package/dist/chunks/chunk-RHRQMT7Q.ts +490 -0
  75. package/dist/chunks/chunk-RHRQMT7Q.ts.map +7 -0
  76. package/dist/chunks/chunk-RRR66UWR.ts +28 -0
  77. package/dist/chunks/chunk-RRR66UWR.ts.map +7 -0
  78. package/dist/chunks/chunk-RSUXZD6S.ts +275 -0
  79. package/dist/chunks/chunk-RSUXZD6S.ts.map +7 -0
  80. package/dist/chunks/chunk-RTCVYIZA.ts +221 -0
  81. package/dist/chunks/chunk-RTCVYIZA.ts.map +7 -0
  82. package/dist/chunks/chunk-S2IWVK3J.ts +44 -0
  83. package/dist/chunks/chunk-S2IWVK3J.ts.map +7 -0
  84. package/dist/chunks/chunk-SCZ33MYW.ts +52 -0
  85. package/dist/chunks/chunk-SCZ33MYW.ts.map +7 -0
  86. package/dist/chunks/chunk-SWGQLFSD.ts +60 -0
  87. package/dist/chunks/chunk-SWGQLFSD.ts.map +7 -0
  88. package/dist/chunks/chunk-UMBPMVJW.ts +22 -0
  89. package/dist/chunks/chunk-UMBPMVJW.ts.map +7 -0
  90. package/dist/chunks/chunk-UVFVHIOP.ts +735 -0
  91. package/dist/chunks/chunk-UVFVHIOP.ts.map +7 -0
  92. package/dist/chunks/completion-delivery-YPOWSSV3.ts +16 -0
  93. package/dist/chunks/completion-delivery-YPOWSSV3.ts.map +7 -0
  94. package/dist/chunks/config-status-J4GPWP46.ts +34 -0
  95. package/dist/chunks/config-status-J4GPWP46.ts.map +7 -0
  96. package/dist/chunks/config-ui-3IBMHTQB.ts +1146 -0
  97. package/dist/chunks/config-ui-3IBMHTQB.ts.map +7 -0
  98. package/dist/chunks/consult-NYXVDN5G.ts +518 -0
  99. package/dist/chunks/consult-NYXVDN5G.ts.map +7 -0
  100. package/dist/chunks/context-QDKLVQXE.ts +11 -0
  101. package/dist/chunks/context-QDKLVQXE.ts.map +7 -0
  102. package/dist/chunks/create-stateful-transport-4WKZHRSI.ts +130 -0
  103. package/dist/chunks/create-stateful-transport-4WKZHRSI.ts.map +7 -0
  104. package/dist/chunks/cwd-policy-NB6XZ5GF.ts +17 -0
  105. package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +7 -0
  106. package/dist/chunks/delegation-contract-WJPT4FVS.ts +24 -0
  107. package/dist/chunks/delegation-contract-WJPT4FVS.ts.map +7 -0
  108. package/dist/chunks/discovery-K25T3SH4.ts +12 -0
  109. package/dist/chunks/discovery-K25T3SH4.ts.map +7 -0
  110. package/dist/chunks/execution-DS2DEIQZ.ts +4034 -0
  111. package/dist/chunks/execution-DS2DEIQZ.ts.map +7 -0
  112. package/dist/chunks/in-process-transport-TEYAWSEC.ts +38 -0
  113. package/dist/chunks/in-process-transport-TEYAWSEC.ts.map +7 -0
  114. package/dist/chunks/inspect-UOQQ3KNL.ts +619 -0
  115. package/dist/chunks/inspect-UOQQ3KNL.ts.map +7 -0
  116. package/dist/chunks/peer-communication-KL36Z6CO.ts +294 -0
  117. package/dist/chunks/peer-communication-KL36Z6CO.ts.map +7 -0
  118. package/dist/chunks/persistence-VSGXAW4P.ts +344 -0
  119. package/dist/chunks/persistence-VSGXAW4P.ts.map +7 -0
  120. package/dist/chunks/registry-E6XPJB7L.ts +1324 -0
  121. package/dist/chunks/registry-E6XPJB7L.ts.map +7 -0
  122. package/dist/chunks/retained-semantic-state-7WXSGRJU.ts +81 -0
  123. package/dist/chunks/retained-semantic-state-7WXSGRJU.ts.map +7 -0
  124. package/dist/chunks/rpc-transport-Y6LA5BOP.ts +1154 -0
  125. package/dist/chunks/rpc-transport-Y6LA5BOP.ts.map +7 -0
  126. package/dist/chunks/runtime-policy-5YELCOVC.ts +15 -0
  127. package/dist/chunks/runtime-policy-5YELCOVC.ts.map +7 -0
  128. package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +19 -0
  129. package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +7 -0
  130. package/dist/chunks/spawn-idempotency-QGHO2WKC.ts +13 -0
  131. package/dist/chunks/spawn-idempotency-QGHO2WKC.ts.map +7 -0
  132. package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +15 -0
  133. package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +7 -0
  134. package/dist/chunks/subprocess-transport-C2XVR25R.ts +158 -0
  135. package/dist/chunks/subprocess-transport-C2XVR25R.ts.map +7 -0
  136. package/dist/chunks/workspace-WDKLN72J.ts +11 -0
  137. package/dist/chunks/workspace-WDKLN72J.ts.map +7 -0
  138. package/dist/index.ts +1057 -0
  139. package/dist/index.ts.map +7 -0
  140. package/package.json +7 -3
  141. package/src/index.ts +1 -1
  142. package/src/settings-reader.ts +208 -0
  143. package/src/settings.ts +22 -187
  144. package/src/stateful-registration.ts +1230 -0
  145. package/src/stateful-safety.ts +1 -1
  146. package/src/stateful.ts +2 -1234
  147. package/src/subagents-extension.ts +307 -0
  148. package/src/subagents.ts +1 -308
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/protocol.ts", "../../src/runner.ts", "../../src/pi-args.ts", "../../src/runner-usage.ts"],
4
+ "sourcesContent": ["import { StringDecoder } from \"node:string_decoder\";\n\nconst DEFAULT_MAX_LINE_BYTES = 256 * 1024;\n\nexport interface JsonLineDecoderOptions {\n\tmaxLineBytes?: number;\n\tonValue: (value: unknown) => void;\n\tonMalformed?: (line: string) => void;\n\tonOversized?: (bytes: number) => void;\n}\n\n/** Bounded newline-delimited JSON decoder for child Pi event streams. */\nexport class JsonLineDecoder {\n\tprivate buffer = \"\";\n\tprivate droppingOversizedLine = false;\n\tprivate readonly maxLineBytes: number;\n\tprivate readonly decoder = new StringDecoder(\"utf8\");\n\n\tconstructor(private readonly options: JsonLineDecoderOptions) {\n\t\tconst maxLineBytes = options.maxLineBytes ?? DEFAULT_MAX_LINE_BYTES;\n\t\tif (!Number.isSafeInteger(maxLineBytes) || maxLineBytes < 1) {\n\t\t\tthrow new Error(\"JSON line limit must be a positive safe integer\");\n\t\t}\n\t\tthis.maxLineBytes = maxLineBytes;\n\t}\n\n\tpush(chunk: string | Buffer): void {\n\t\tthis.buffer += typeof chunk === \"string\" ? chunk : this.decoder.write(chunk);\n\t\tthis.drain(false);\n\t}\n\n\tfinish(): void {\n\t\tthis.buffer += this.decoder.end();\n\t\tthis.drain(true);\n\t\tthis.buffer = \"\";\n\t\tthis.droppingOversizedLine = false;\n\t}\n\n\tprivate drain(flush: boolean): void {\n\t\twhile (true) {\n\t\t\tconst newline = this.buffer.indexOf(\"\\n\");\n\t\t\tif (newline < 0) break;\n\t\t\tconst line = this.buffer.slice(0, newline).replace(/\\r$/, \"\");\n\t\t\tthis.buffer = this.buffer.slice(newline + 1);\n\t\t\tif (this.droppingOversizedLine) {\n\t\t\t\tthis.droppingOversizedLine = false;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthis.processLine(line);\n\t\t}\n\n\t\tif (!flush && Buffer.byteLength(this.buffer, \"utf8\") > this.maxLineBytes) {\n\t\t\tthis.options.onOversized?.(Buffer.byteLength(this.buffer, \"utf8\"));\n\t\t\tthis.buffer = \"\";\n\t\t\tthis.droppingOversizedLine = true;\n\t\t}\n\n\t\tif (flush && this.buffer.length > 0 && !this.droppingOversizedLine) {\n\t\t\tthis.processLine(this.buffer.replace(/\\r$/, \"\"));\n\t\t}\n\t}\n\n\tprivate processLine(line: string): void {\n\t\tif (!line.trim()) return;\n\t\tconst bytes = Buffer.byteLength(line, \"utf8\");\n\t\tif (bytes > this.maxLineBytes) {\n\t\t\tthis.options.onOversized?.(bytes);\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tthis.options.onValue(JSON.parse(line));\n\t\t} catch {\n\t\t\tthis.options.onMalformed?.(line);\n\t\t}\n\t}\n}\n", "import { spawn } from \"node:child_process\";\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport * as path from \"node:path\";\nimport type { AgentToolResult } from \"@earendil-works/pi-agent-core\";\nimport type { Message } from \"@earendil-works/pi-ai\";\nimport { withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport type { SchedulingDecision } from \"./adaptive-scheduler.js\";\nimport type {\n\tAgentConfig,\n\tAgentScope,\n\tAgentSource,\n\tSubagentThinkingLevel,\n} from \"./agents/types.js\";\nimport { type CapabilityGrant, revokeCapabilityGrant } from \"./capability-grant.js\";\nimport type { TargetPolicyAudit } from \"./cwd-policy.js\";\nimport type { DelegationContract } from \"./delegation-contract.js\";\nimport type { ExecutionPlan } from \"./execution-plan.js\";\nimport {\n\tappendBounded,\n\tDEFAULT_MAX_CONTEXT_BYTES,\n\tDEFAULT_MAX_MESSAGES,\n\tDEFAULT_MAX_OUTPUT_BYTES,\n\tDEFAULT_MAX_STDERR_BYTES,\n\tMAX_SUBAGENT_TIMEOUT_MS,\n\ttruncateUtf8,\n} from \"./limits.js\";\nimport type { OrchestrationMetrics } from \"./orchestration-metrics.js\";\nimport { type ClassifiedSubagentOutcome, classifyStructuredOutcome } from \"./outcome.js\";\nimport type { PanelSynthesis } from \"./panel-contract.js\";\nimport type { PanelEvidenceArtifact } from \"./panel-evidence.js\";\nimport type { PanelFailure } from \"./panel-failure.js\";\nimport type { PanelPhaseBudgets, PanelPreset } from \"./panel-planning.js\";\nimport { buildPiArgs } from \"./pi-args.js\";\nimport { resolvePiInvocation } from \"./pi-invocation.js\";\nimport { JsonLineDecoder } from \"./protocol.js\";\nimport {\n\ttype AnyStructuredSubagentResult,\n\tparseAnyStructuredSubagentResult,\n\ttype SubagentResultFormat,\n} from \"./result-contract.js\";\nimport { formatResultFailure, getResultFinalOutput, isResultError } from \"./runner-outcome.js\";\nimport { getFinalOutput } from \"./runner-result.js\";\nimport {\n\taddUsageValue,\n\tmergeUsageStats,\n\tprotocolUsageCost,\n\tprotocolUsageCount,\n\ttype UsageStats,\n} from \"./runner-usage.js\";\nimport {\n\tformatTimeoutCheckpoint,\n\tformatTurnTerminationMessage,\n\tjournalMessages,\n\tTimeoutProgressJournal,\n\tTURN_TERMINATION_VERSION,\n\ttype TurnTerminationReport,\n} from \"./timeout-checkpoint.js\";\nimport {\n\tbuildTimeoutFinalizationPrompt,\n\tresolveTimeoutFinalizationMs,\n} from \"./timeout-finalization.js\";\nimport { TurnBudgetMonitor, type TurnBudgetStop, type TurnLimits } from \"./turn-budget.js\";\nimport type { WorkItemLedgerSnapshot } from \"./work-item-ledger.js\";\n\nexport const KILL_GRACE_MS = 5000;\n\nexport type { PiArgsOptions } from \"./pi-args.js\";\nexport { buildPiArgs } from \"./pi-args.js\";\nexport {\n\tformatResultFailure,\n\tgetResultFinalOutput,\n\tisResultError,\n} from \"./runner-outcome.js\";\nexport type { UsageStats } from \"./runner-usage.js\";\nexport type RecentActivityItem =\n\t| { type: \"text\"; text: string }\n\t| { type: \"toolCall\"; name: string; args: Record<string, unknown> };\n\nconst MAX_RECENT_ACTIVITY_ITEMS = 10;\nconst MAX_RECENT_ACTIVITY_BYTES = 8 * 1024;\nconst MAX_RECENT_ACTIVITY_ARGUMENT_BYTES = 1024;\n\nexport interface SingleResult {\n\tagent: string;\n\tagentSource: AgentSource | \"unknown\";\n\ttask: string;\n\texitCode: number;\n\tmessages: Message[];\n\tstderr: string;\n\tusage: UsageStats;\n\tmodel?: string;\n\tactualProvider?: string;\n\tactualModel?: string;\n\trecentActivity?: RecentActivityItem[];\n\trecentActivityTotal?: number;\n\tthinkingLevel?: SubagentThinkingLevel;\n\tstopReason?: string;\n\terrorMessage?: string;\n\tstep?: number;\n\tfinalOutput?: string;\n\tpartialOutput?: string;\n\ttimeoutSummary?: string;\n\ttimeoutSummaryError?: string;\n\ttermination?: TurnTerminationReport;\n\ttimedOut?: boolean;\n\ttimeoutMs?: number;\n\taborted?: boolean;\n\ttruncated?: boolean;\n\tmalformedEvents?: number;\n\tlaunchFailed?: boolean;\n\tprocessStarted?: boolean;\n\ttarget?: TargetPolicyAudit;\n\tpolicy?: {\n\t\tinherited: string[];\n\t\toverridden: string[];\n\t\tunsupported: string[];\n\t};\n\tcontract?: DelegationContract;\n\tresultFormat?: SubagentResultFormat;\n\tstructuredResult?: AnyStructuredSubagentResult;\n\tresultContractInvalid?: boolean;\n\toutcome?: ClassifiedSubagentOutcome;\n\tattemptCount?: number;\n\thedged?: boolean;\n\texecutionPlan?: ExecutionPlan;\n\tcapabilityGrant?: CapabilityGrant;\n}\n\nexport interface PanelDetails {\n\tid: string;\n\tpreset: PanelPreset;\n\tsharedTaskPreview: string;\n\tstate: \"running\" | \"completed\" | \"degraded\" | \"insufficient-panel\" | \"failed\" | \"cancelled\";\n\treviewerIds: string[];\n\tvalidReviewCount: number;\n\tfailedReviewCount: number;\n\tblockingObjectionCount: number;\n\tdissentCount: number;\n\tbudgets: PanelPhaseBudgets;\n\tevidence: PanelEvidenceArtifact[];\n\tfailures: PanelFailure[];\n\tsynthesis?: PanelSynthesis;\n\tsynthesizerResult?: SingleResult;\n\tcleanupComplete: boolean;\n}\n\nexport interface SubagentDetails {\n\tmode: \"single\" | \"parallel\" | \"chain\" | \"workflow\" | \"panel\";\n\tagentScope: AgentScope;\n\tprojectAgentsDir: string | null;\n\tresults: SingleResult[];\n\taggregator?: SingleResult;\n\tworkflow?: WorkItemLedgerSnapshot;\n\tschedulerDecisions?: SchedulingDecision[];\n\tmetrics?: OrchestrationMetrics;\n\tpanel?: PanelDetails;\n\tisError?: boolean;\n}\n\nfunction boundMessageText(\n\tmessage: Message,\n\tmaxBytes: number,\n): { message?: Message; bytes: number; truncated: boolean } {\n\tconst originalBytes = Buffer.byteLength(JSON.stringify(message), \"utf8\");\n\tif (Number.isSafeInteger(maxBytes) && maxBytes >= 0 && originalBytes <= maxBytes) {\n\t\treturn { message, bytes: originalBytes, truncated: false };\n\t}\n\tif (!Number.isSafeInteger(maxBytes) || maxBytes < 0) return { bytes: 0, truncated: true };\n\n\tconst content: Array<\n\t\t| { type: \"text\"; text: string }\n\t\t| { type: \"toolCall\"; id: string; name: string; arguments: Record<string, unknown> }\n\t> = [];\n\tconst bounded = () => ({ ...message, content }) as Message;\n\tconst fits = () => Buffer.byteLength(JSON.stringify(bounded()), \"utf8\") <= maxBytes;\n\tconst addText = (text: string, prepend = false) => {\n\t\tif (!text.trim()) return;\n\t\tconst part = { type: \"text\" as const, text: \"\" };\n\t\tif (prepend) content.unshift(part);\n\t\telse content.push(part);\n\t\tif (!fits()) {\n\t\t\tcontent.splice(content.indexOf(part), 1);\n\t\t\treturn;\n\t\t}\n\t\tlet low = 0;\n\t\tlet high = Buffer.byteLength(text, \"utf8\");\n\t\twhile (low < high) {\n\t\t\tconst middle = Math.ceil((low + high) / 2);\n\t\t\tpart.text = truncateUtf8(text, middle).text;\n\t\t\tif (fits()) low = middle;\n\t\t\telse high = middle - 1;\n\t\t}\n\t\tpart.text = truncateUtf8(text, low).text;\n\t\tif (!part.text.trim()) content.splice(content.indexOf(part), 1);\n\t};\n\tconst addToolCall = (part: Extract<Message[\"content\"][number], { type: \"toolCall\" }>) => {\n\t\tconst toolCall = {\n\t\t\ttype: \"toolCall\" as const,\n\t\t\tid: part.id,\n\t\t\tname: part.name,\n\t\t\targuments: part.arguments,\n\t\t};\n\t\tcontent.unshift(toolCall);\n\t\tif (fits()) return;\n\t\tconst arguments_: Record<string, unknown> = {};\n\t\tfor (const key of [\"command\", \"path\", \"file_path\", \"pattern\", \"url\"]) {\n\t\t\tconst value = part.arguments[key];\n\t\t\tif (typeof value === \"string\") arguments_[key] = truncateUtf8(value, 256).text;\n\t\t}\n\t\ttoolCall.arguments = arguments_;\n\t\tif (fits()) return;\n\t\ttoolCall.arguments = {};\n\t\tif (!fits()) content.shift();\n\t};\n\n\tif (message.role === \"assistant\") {\n\t\tfor (let index = message.content.length - 1; index >= 0; index--) {\n\t\t\tconst part = message.content[index];\n\t\t\tif (part.type === \"text\") addText(part.text, true);\n\t\t\telse if (part.type === \"toolCall\") addToolCall(part);\n\t\t}\n\t} else {\n\t\tfor (const part of message.content) {\n\t\t\tif (typeof part === \"object\" && part && part.type === \"text\") addText(part.text);\n\t\t}\n\t}\n\n\tif (content.length === 0) return { bytes: 0, truncated: true };\n\tconst result = bounded();\n\tconst bytes = Buffer.byteLength(JSON.stringify(result), \"utf8\");\n\treturn { message: result, bytes, truncated: true };\n}\nfunction compactRecentActivityArguments(args: Record<string, unknown>): Record<string, unknown> {\n\tif (Buffer.byteLength(JSON.stringify(args), \"utf8\") <= MAX_RECENT_ACTIVITY_ARGUMENT_BYTES)\n\t\treturn args;\n\tconst compact: Record<string, unknown> = {};\n\tfor (const key of [\"command\", \"path\", \"file_path\", \"pattern\", \"url\", \"selector\"]) {\n\t\tconst value = args[key];\n\t\tif (typeof value === \"string\") compact[key] = truncateUtf8(value, 256).text;\n\t\telse if (typeof value === \"number\" || typeof value === \"boolean\") compact[key] = value;\n\t}\n\treturn compact;\n}\n\nfunction appendRecentActivity(result: SingleResult, message: Message): void {\n\tif (message.role !== \"assistant\") return;\n\tconst append = (item: RecentActivityItem) => {\n\t\tresult.recentActivity ??= [];\n\t\tresult.recentActivityTotal = (result.recentActivityTotal ?? 0) + 1;\n\t\tresult.recentActivity.push(item);\n\t\tif (result.recentActivity.length > MAX_RECENT_ACTIVITY_ITEMS) {\n\t\t\tresult.recentActivity.splice(0, result.recentActivity.length - MAX_RECENT_ACTIVITY_ITEMS);\n\t\t}\n\t\twhile (\n\t\t\tBuffer.byteLength(JSON.stringify(result.recentActivity), \"utf8\") > MAX_RECENT_ACTIVITY_BYTES\n\t\t) {\n\t\t\tresult.recentActivity.shift();\n\t\t}\n\t};\n\tfor (const part of message.content) {\n\t\tif (part.type === \"text\") {\n\t\t\tconst text = part.text.trim();\n\t\t\tif (text) append({ type: \"text\", text: truncateUtf8(text, 1024).text });\n\t\t} else if (part.type === \"toolCall\") {\n\t\t\tappend({\n\t\t\t\ttype: \"toolCall\",\n\t\t\t\tname: part.name,\n\t\t\t\targs: compactRecentActivityArguments(part.arguments),\n\t\t\t});\n\t\t}\n\t}\n}\n\nexport function buildFanInContext(\n\tresults: SingleResult[],\n\tmaxBytes = DEFAULT_MAX_CONTEXT_BYTES,\n): string {\n\tconst text = results\n\t\t.map((result, index) => {\n\t\t\tconst failed = isResultError(result);\n\t\t\tconst status = result.exitCode === -1 ? \"running\" : failed ? \"failed\" : \"completed\";\n\t\t\tconst output = getResultFinalOutput(result);\n\t\t\tconst error = result.errorMessage || result.stderr.trim();\n\t\t\tconst resultText = failed\n\t\t\t\t? `${error ? \"Error\" : output ? \"Partial output\" : \"Error\"}:\\n${formatResultFailure(result)}`\n\t\t\t\t: result.structuredResult\n\t\t\t\t\t? `Structured result:\\n${JSON.stringify(result.structuredResult)}`\n\t\t\t\t\t: output\n\t\t\t\t\t\t? `Output:\\n${output}`\n\t\t\t\t\t\t: \"Output: (no output)\";\n\t\t\treturn [\n\t\t\t\t`## Result ${index + 1}: ${result.agent} (${status})`,\n\t\t\t\t`Task: ${result.task}`,\n\t\t\t\tresultText,\n\t\t\t].join(\"\\n\\n\");\n\t\t})\n\t\t.join(\"\\n\\n---\\n\\n\");\n\treturn truncateUtf8(text, maxBytes).text;\n}\n\nexport async function mapWithConcurrencyLimit<TIn, TOut>(\n\titems: TIn[],\n\tconcurrency: number,\n\tfn: (item: TIn, index: number) => Promise<TOut>,\n\tsignal?: AbortSignal,\n\tonSkipped?: (item: TIn, index: number) => TOut,\n): Promise<TOut[]> {\n\tif (items.length === 0) return [];\n\tconst limit = Math.max(1, Math.min(concurrency, items.length));\n\tconst results: TOut[] = new Array(items.length);\n\tlet nextIndex = 0;\n\tconst workers = new Array(limit).fill(null).map(async () => {\n\t\twhile (true) {\n\t\t\tconst current = nextIndex++;\n\t\t\tif (current >= items.length) return;\n\t\t\tif (signal?.aborted && onSkipped) {\n\t\t\t\tresults[current] = onSkipped(items[current], current);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tresults[current] = await fn(items[current], current);\n\t\t}\n\t});\n\tawait Promise.all(workers);\n\treturn results;\n}\n\nasync function writePromptToTempFile(\n\tagentName: string,\n\tprompt: string,\n): Promise<{ dir: string; filePath: string }> {\n\tconst tmpDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), \"pi-subagent-\"));\n\tconst safeName = agentName.replace(/[^\\w.-]+/g, \"_\");\n\tconst filePath = path.join(tmpDir, `prompt-${safeName}.md`);\n\tawait withFileMutationQueue(filePath, async () => {\n\t\tawait fs.promises.writeFile(filePath, prompt, { encoding: \"utf-8\", mode: 0o600 });\n\t});\n\treturn { dir: tmpDir, filePath };\n}\n\nfunction signalProcess(proc: ReturnType<typeof spawn>, signal: NodeJS.Signals): void {\n\tif (process.platform !== \"win32\" && proc.pid) {\n\t\ttry {\n\t\t\tprocess.kill(-proc.pid, signal);\n\t\t\treturn;\n\t\t} catch {\n\t\t\t// Fall back to signaling the immediate child when process-group signaling is unavailable.\n\t\t}\n\t}\n\ttry {\n\t\tproc.kill(signal);\n\t} catch {\n\t\t// The process may already have exited.\n\t}\n}\n\nexport function terminateProcess(\n\tproc: ReturnType<typeof spawn>,\n\tgraceMs = KILL_GRACE_MS,\n): () => void {\n\tconst leaderExited = proc.exitCode !== null || proc.signalCode !== null;\n\tconst capturedOutputClosed = [proc.stdout, proc.stderr].every(\n\t\t(stream) => !stream || stream.readableEnded || stream.destroyed,\n\t);\n\tlet closed = leaderExited && capturedOutputClosed;\n\tconst onClose = () => {\n\t\tclosed = true;\n\t};\n\tproc.once(\"close\", onClose);\n\tif (!closed) signalProcess(proc, \"SIGTERM\");\n\tconst escalation = setTimeout(() => {\n\t\tif (!closed) signalProcess(proc, \"SIGKILL\");\n\t}, graceMs);\n\tescalation.unref();\n\treturn () => {\n\t\tclearTimeout(escalation);\n\t\tproc.off(\"close\", onClose);\n\t};\n}\n\nexport type OnUpdateCallback = (partial: AgentToolResult<SubagentDetails>) => void;\n\nexport interface ChildLaunchPolicy {\n\ttools?: string[];\n\tdisableExtensions?: boolean;\n\tdisableSkills?: boolean;\n\tdisablePromptTemplates?: boolean;\n\tdisableContextFiles?: boolean;\n\tprojectTrust?: boolean;\n\tbaseSystemPrompt?: string;\n\tappendSystemPromptPaths?: string[];\n\t/** Package-owned explicit child extensions loaded even when unrelated extensions are disabled. */\n\textensionPaths?: string[];\n\t/** Package-owned tools added to the child allowlist without changing delegated execution tools. */\n\tadditionalTools?: string[];\n\t/** Ephemeral child-process environment consumed and cleared by a package-owned bridge. */\n\tenv?: NodeJS.ProcessEnv;\n\t/** Internal timeout recovery control; omitted means enabled. */\n\tfinalizeOnTimeout?: boolean;\n\t/** Internal hard deadline for the summary attempt. */\n\ttimeoutFinalizationMs?: number;\n\t/** Optional stateful result contract retained during timeout finalization. */\n\ttimeoutResultFormat?: SubagentResultFormat;\n\t/** Optional non-wall-clock limits for this turn. */\n\tturnLimits?: TurnLimits;\n\t/** Override the timeout reason when an orchestration deadline caps this child. */\n\tworkTimeoutReason?: \"work_timeout\" | \"orchestration_timeout\";\n\t/** Public limit value reported when the effective child timeout is only the remaining budget. */\n\tworkTimeoutReportLimit?: number;\n\t/** Absolute blocking-workflow deadline that also caps model finalization. */\n\torchestrationDeadlineAt?: number;\n\t/** Completion contract requested for this turn. */\n\tresultFormat?: SubagentResultFormat;\n\t/** Normalized request contract retained in result details. */\n\tcontract?: DelegationContract;\n\t/** Original task summary shown in result details when the executed prompt has contract metadata. */\n\tdisplayTask?: string;\n\t/** Immutable audit or enforcement decision made before launch. */\n\texecutionPlan?: ExecutionPlan;\n\t/** Executor-owned authority lifetime bound to the accepted plan generation. */\n\tcapabilityGrant?: CapabilityGrant;\n}\n\nexport async function runSingleAgent(\n\tdefaultCwd: string,\n\tagents: AgentConfig[],\n\tagentName: string,\n\ttask: string,\n\tcwd: string | undefined,\n\tstep: number | undefined,\n\tsignal: AbortSignal | undefined,\n\tthinkingLevel: SubagentThinkingLevel | undefined,\n\ttimeoutMs: number,\n\tonUpdate: OnUpdateCallback | undefined,\n\tmakeDetails: (results: SingleResult[]) => SubagentDetails,\n\tinvocationOverride?: { command: string; argsPrefix?: string[] },\n\tlaunchPolicy?: ChildLaunchPolicy,\n): Promise<SingleResult> {\n\tconst agent = agents.find((a) => a.name === agentName);\n\n\tif (!agent) {\n\t\tconst available = agents.map((a) => `\"${a.name}\"`).join(\", \") || \"none\";\n\t\treturn {\n\t\t\tagent: agentName,\n\t\t\tagentSource: \"unknown\",\n\t\t\ttask,\n\t\t\texitCode: 1,\n\t\t\tmessages: [],\n\t\t\tstderr: `Unknown agent: \"${agentName}\". Available agents: ${available}.`,\n\t\t\tusage: {\n\t\t\t\tinput: 0,\n\t\t\t\toutput: 0,\n\t\t\t\tcacheRead: 0,\n\t\t\t\tcacheWrite: 0,\n\t\t\t\tcost: 0,\n\t\t\t\tcontextTokens: 0,\n\t\t\t\tturns: 0,\n\t\t\t},\n\t\t\tthinkingLevel,\n\t\t\tstep,\n\t\t\tfinalOutput: \"\",\n\t\t};\n\t}\n\n\tconst temporaryPrompts: Array<{ dir: string; filePath: string }> = [];\n\tlet tmpPromptPath: string | null = null;\n\tlet baseSystemPromptPath: string | null = null;\n\n\tlet latestAssistantOutput = \"\";\n\tlet terminalAssistantOutput: string | undefined;\n\n\tconst progressJournal = new TimeoutProgressJournal();\n\tconst currentResult: SingleResult = {\n\t\tagent: agentName,\n\t\tagentSource: agent.source,\n\t\ttask: launchPolicy?.displayTask ?? task,\n\t\texitCode: 0,\n\t\tmessages: [],\n\t\tstderr: \"\",\n\t\tusage: {\n\t\t\tinput: 0,\n\t\t\toutput: 0,\n\t\t\tcacheRead: 0,\n\t\t\tcacheWrite: 0,\n\t\t\tcost: 0,\n\t\t\tcontextTokens: 0,\n\t\t\tturns: 0,\n\t\t},\n\t\tmodel: agent.model ?? undefined,\n\t\tthinkingLevel,\n\t\tstep,\n\t\ttimeoutMs,\n\t\tcontract: launchPolicy?.contract,\n\t\tresultFormat: launchPolicy?.resultFormat,\n\t\texecutionPlan: launchPolicy?.executionPlan,\n\t\tcapabilityGrant: launchPolicy?.capabilityGrant,\n\t};\n\tconst selectedAssistantOutput = () =>\n\t\tterminalAssistantOutput !== undefined\n\t\t\t? terminalAssistantOutput\n\t\t\t: latestAssistantOutput || getFinalOutput(currentResult.messages);\n\tconst setErrorMessage = (message: string) => {\n\t\tconst bounded = truncateUtf8(message, DEFAULT_MAX_STDERR_BYTES);\n\t\tcurrentResult.errorMessage = bounded.text;\n\t\tcurrentResult.truncated ||= bounded.truncated;\n\t\treturn bounded.text;\n\t};\n\n\tconst emitUpdate = () => {\n\t\tconst latest = truncateUtf8(selectedAssistantOutput(), DEFAULT_MAX_OUTPUT_BYTES);\n\t\tcurrentResult.finalOutput = latest.text;\n\t\tcurrentResult.truncated ||= latest.truncated;\n\t\tif (onUpdate) {\n\t\t\tonUpdate({\n\t\t\t\tcontent: [{ type: \"text\", text: currentResult.finalOutput || \"(running...)\" }],\n\t\t\t\tdetails: makeDetails([currentResult]),\n\t\t\t});\n\t\t}\n\t};\n\n\ttry {\n\t\tconst effectiveCwd = cwd ?? defaultCwd;\n\t\ttry {\n\t\t\tif (!fs.statSync(effectiveCwd).isDirectory()) throw new Error(\"not a directory\");\n\t\t} catch (error) {\n\t\t\tcurrentResult.exitCode = 1;\n\t\t\tcurrentResult.stopReason = \"error\";\n\t\t\tconst reason = error instanceof Error ? error.message : String(error);\n\t\t\tcurrentResult.stderr = setErrorMessage(`Invalid subagent cwd: ${effectiveCwd} (${reason})`);\n\t\t\treturn currentResult;\n\t\t}\n\n\t\tif (signal?.aborted) {\n\t\t\tcurrentResult.exitCode = 130;\n\t\t\tcurrentResult.aborted = true;\n\t\t\tcurrentResult.stopReason = \"aborted\";\n\t\t\tsetErrorMessage(\"Subagent was aborted before start\");\n\t\t\treturn currentResult;\n\t\t}\n\t\tif (!Number.isFinite(timeoutMs) || timeoutMs < 1 || timeoutMs > MAX_SUBAGENT_TIMEOUT_MS) {\n\t\t\tcurrentResult.exitCode = 1;\n\t\t\tcurrentResult.stopReason = \"error\";\n\t\t\tsetErrorMessage(\n\t\t\t\t`Invalid subagent timeout: expected 1-${MAX_SUBAGENT_TIMEOUT_MS}ms, received ${timeoutMs}`,\n\t\t\t);\n\t\t\treturn currentResult;\n\t\t}\n\n\t\tif (launchPolicy?.baseSystemPrompt?.trim()) {\n\t\t\tconst tmp = await writePromptToTempFile(`${agent.name}-base`, launchPolicy.baseSystemPrompt);\n\t\t\ttemporaryPrompts.push(tmp);\n\t\t\tbaseSystemPromptPath = tmp.filePath;\n\t\t}\n\t\tif (agent.systemPrompt.trim()) {\n\t\t\tconst tmp = await writePromptToTempFile(agent.name, agent.systemPrompt);\n\t\t\ttemporaryPrompts.push(tmp);\n\t\t\ttmpPromptPath = tmp.filePath;\n\t\t}\n\t\tif (signal?.aborted) {\n\t\t\tcurrentResult.exitCode = 130;\n\t\t\tcurrentResult.aborted = true;\n\t\t\tcurrentResult.stopReason = \"aborted\";\n\t\t\tsetErrorMessage(\"Subagent was aborted before launch\");\n\t\t\treturn currentResult;\n\t\t}\n\n\t\tconst effectiveTools =\n\t\t\tlaunchPolicy && Object.hasOwn(launchPolicy, \"tools\") ? launchPolicy.tools : agent.tools;\n\t\tconst selectedTools =\n\t\t\teffectiveTools === undefined\n\t\t\t\t? undefined\n\t\t\t\t: [...new Set([...effectiveTools, ...(launchPolicy?.additionalTools ?? [])])];\n\t\tconst args = buildPiArgs({\n\t\t\tmodel: agent.model,\n\t\t\tthinkingLevel,\n\t\t\ttools: selectedTools,\n\t\t\tdisableExtensions: launchPolicy?.disableExtensions,\n\t\t\tdisableSkills: launchPolicy?.disableSkills,\n\t\t\tdisablePromptTemplates: launchPolicy?.disablePromptTemplates,\n\t\t\tdisableContextFiles: launchPolicy?.disableContextFiles,\n\t\t\tprojectTrust: launchPolicy?.projectTrust,\n\t\t\tbaseSystemPromptPath: baseSystemPromptPath ?? undefined,\n\t\t\tappendSystemPromptPaths: launchPolicy?.appendSystemPromptPaths,\n\t\t\textensionPaths: launchPolicy?.extensionPaths,\n\t\t\tsystemPromptPath: tmpPromptPath ?? undefined,\n\t\t\ttask,\n\t\t});\n\t\tlet invocation: { command: string; args: string[] };\n\t\ttry {\n\t\t\tinvocation = invocationOverride\n\t\t\t\t? {\n\t\t\t\t\t\tcommand: invocationOverride.command,\n\t\t\t\t\t\targs: [...(invocationOverride.argsPrefix ?? []), ...args],\n\t\t\t\t\t}\n\t\t\t\t: resolvePiInvocation(args);\n\t\t} catch (error) {\n\t\t\tcurrentResult.launchFailed = true;\n\t\t\tcurrentResult.exitCode = 1;\n\t\t\tcurrentResult.stderr = setErrorMessage(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t\treturn currentResult;\n\t\t}\n\t\tlet wasAborted = false;\n\t\tlet timedOut = false;\n\t\tlet budgetStop:\n\t\t\t| TurnBudgetStop\n\t\t\t| { reason: \"work_timeout\" | \"orchestration_timeout\"; limit: number }\n\t\t\t| undefined;\n\n\t\tconst exitCode = await new Promise<number>((resolve) => {\n\t\t\tlet settled = false;\n\t\t\tlet cleanupTermination: (() => void) | undefined;\n\t\t\tlet timeout: NodeJS.Timeout | undefined;\n\t\t\tlet terminationDeadline: NodeJS.Timeout | undefined;\n\t\t\tlet abortHandler: (() => void) | undefined;\n\t\t\tlet budgetMonitor: TurnBudgetMonitor | undefined;\n\t\t\tconst finish = (code: number) => {\n\t\t\t\tif (settled) return;\n\t\t\t\tsettled = true;\n\t\t\t\tif (timeout) clearTimeout(timeout);\n\t\t\t\tif (terminationDeadline) clearTimeout(terminationDeadline);\n\t\t\t\tcleanupTermination?.();\n\t\t\t\tbudgetMonitor?.dispose();\n\t\t\t\tif (signal && abortHandler) signal.removeEventListener(\"abort\", abortHandler);\n\t\t\t\tresolve(code);\n\t\t\t};\n\t\t\tlet proc: ReturnType<typeof spawn>;\n\t\t\ttry {\n\t\t\t\tproc = spawn(invocation.command, invocation.args, {\n\t\t\t\t\tcwd: effectiveCwd,\n\t\t\t\t\tdetached: process.platform !== \"win32\",\n\t\t\t\t\tshell: false,\n\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\tenv: {\n\t\t\t\t\t\t...process.env,\n\t\t\t\t\t\t...launchPolicy?.env,\n\t\t\t\t\t\tPI_SUBAGENT_DEPTH: String(\n\t\t\t\t\t\t\t(Number.parseInt(process.env.PI_SUBAGENT_DEPTH ?? \"0\", 10) || 0) + 1,\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tcurrentResult.launchFailed = true;\n\t\t\t\tcurrentResult.stderr = setErrorMessage(\n\t\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t\t);\n\t\t\t\tfinish(1);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst addMessage = (msg: Message) => {\n\t\t\t\tconst boundedMessage = boundMessageText(msg, DEFAULT_MAX_OUTPUT_BYTES - 2);\n\t\t\t\tcurrentResult.truncated ||= boundedMessage.truncated;\n\t\t\t\tif (!boundedMessage.message) return;\n\t\t\t\twhile (\n\t\t\t\t\tcurrentResult.messages.length >= DEFAULT_MAX_MESSAGES ||\n\t\t\t\t\tBuffer.byteLength(\n\t\t\t\t\t\tJSON.stringify([...currentResult.messages, boundedMessage.message]),\n\t\t\t\t\t\t\"utf8\",\n\t\t\t\t\t) > DEFAULT_MAX_OUTPUT_BYTES\n\t\t\t\t) {\n\t\t\t\t\tconst removed = currentResult.messages.shift();\n\t\t\t\t\tif (!removed) break;\n\t\t\t\t\tcurrentResult.truncated = true;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\tBuffer.byteLength(\n\t\t\t\t\t\tJSON.stringify([...currentResult.messages, boundedMessage.message]),\n\t\t\t\t\t\t\"utf8\",\n\t\t\t\t\t) > DEFAULT_MAX_OUTPUT_BYTES\n\t\t\t\t) {\n\t\t\t\t\tcurrentResult.truncated = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcurrentResult.messages.push(boundedMessage.message);\n\t\t\t};\n\t\t\tconst processEvent = (raw: unknown) => {\n\t\t\t\tif (!raw || typeof raw !== \"object\") return;\n\t\t\t\tconst event = raw as { type?: string; message?: Message };\n\t\t\t\tif (event.type === \"message_end\" && event.message) {\n\t\t\t\t\tconst msg = event.message;\n\t\t\t\t\tjournalMessages(progressJournal, [msg]);\n\t\t\t\t\tif (msg.role === \"assistant\") {\n\t\t\t\t\t\tconst output = truncateUtf8(getFinalOutput([msg]), DEFAULT_MAX_OUTPUT_BYTES);\n\t\t\t\t\t\tcurrentResult.truncated ||= output.truncated;\n\t\t\t\t\t\tif (output.text) latestAssistantOutput = output.text;\n\t\t\t\t\t\tif (msg.stopReason === \"stop\" || msg.stopReason === \"length\") {\n\t\t\t\t\t\t\tterminalAssistantOutput = output.text;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tappendRecentActivity(currentResult, msg);\n\t\t\t\t\taddMessage(msg);\n\t\t\t\t\tif (msg.role === \"assistant\") {\n\t\t\t\t\t\tcurrentResult.usage.turns++;\n\t\t\t\t\t\tbudgetMonitor?.recordToolCalls(\n\t\t\t\t\t\t\tmsg.content.filter((part) => part.type === \"toolCall\").length,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbudgetMonitor?.recordAssistantTurn(msg.stopReason);\n\t\t\t\t\t\tconst usage = msg.usage;\n\t\t\t\t\t\tif (usage && typeof usage === \"object\") {\n\t\t\t\t\t\t\tconst input = protocolUsageCount(usage.input);\n\t\t\t\t\t\t\tconst output = protocolUsageCount(usage.output);\n\t\t\t\t\t\t\tconst cacheRead = protocolUsageCount(usage.cacheRead);\n\t\t\t\t\t\t\tconst cacheWrite = protocolUsageCount(usage.cacheWrite);\n\t\t\t\t\t\t\tconst reportedTotal = protocolUsageCount(usage.totalTokens);\n\t\t\t\t\t\t\tconst turnTotal =\n\t\t\t\t\t\t\t\treportedTotal ||\n\t\t\t\t\t\t\t\taddUsageValue(addUsageValue(input, output), addUsageValue(cacheRead, cacheWrite));\n\t\t\t\t\t\t\tconst cost = usage.cost && typeof usage.cost === \"object\" ? usage.cost : undefined;\n\t\t\t\t\t\t\tcurrentResult.usage.input = addUsageValue(currentResult.usage.input, input);\n\t\t\t\t\t\t\tcurrentResult.usage.output = addUsageValue(currentResult.usage.output, output);\n\t\t\t\t\t\t\tcurrentResult.usage.cacheRead = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.cacheRead,\n\t\t\t\t\t\t\t\tcacheRead,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.cacheWrite = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.cacheWrite,\n\t\t\t\t\t\t\t\tcacheWrite,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.cost = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.cost,\n\t\t\t\t\t\t\t\tprotocolUsageCost(cost?.total),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.costInput = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.costInput ?? 0,\n\t\t\t\t\t\t\t\tprotocolUsageCost(cost?.input),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.costOutput = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.costOutput ?? 0,\n\t\t\t\t\t\t\t\tprotocolUsageCost(cost?.output),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.costCacheRead = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.costCacheRead ?? 0,\n\t\t\t\t\t\t\t\tprotocolUsageCost(cost?.cacheRead),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.costCacheWrite = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.costCacheWrite ?? 0,\n\t\t\t\t\t\t\t\tprotocolUsageCost(cost?.cacheWrite),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.totalTokens = addUsageValue(\n\t\t\t\t\t\t\t\tcurrentResult.usage.totalTokens ?? 0,\n\t\t\t\t\t\t\t\tturnTotal,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tcurrentResult.usage.contextTokens = turnTotal;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (typeof msg.provider === \"string\") currentResult.actualProvider = msg.provider;\n\t\t\t\t\t\tconst actualModel =\n\t\t\t\t\t\t\ttypeof msg.responseModel === \"string\"\n\t\t\t\t\t\t\t\t? msg.responseModel\n\t\t\t\t\t\t\t\t: typeof msg.model === \"string\"\n\t\t\t\t\t\t\t\t\t? msg.model\n\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\tif (actualModel) currentResult.actualModel = actualModel;\n\t\t\t\t\t\tif (typeof msg.stopReason === \"string\") currentResult.stopReason = msg.stopReason;\n\t\t\t\t\t\tif (typeof msg.errorMessage === \"string\") setErrorMessage(msg.errorMessage);\n\t\t\t\t\t}\n\t\t\t\t\temitUpdate();\n\t\t\t\t} else if (event.type === \"tool_result_end\" && event.message) {\n\t\t\t\t\tjournalMessages(progressJournal, [event.message]);\n\t\t\t\t\tbudgetMonitor?.recordActivity();\n\t\t\t\t\taddMessage(event.message);\n\t\t\t\t\temitUpdate();\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst decoder = new JsonLineDecoder({\n\t\t\t\tonValue: processEvent,\n\t\t\t\tonMalformed: () => {\n\t\t\t\t\tcurrentResult.malformedEvents = (currentResult.malformedEvents ?? 0) + 1;\n\t\t\t\t},\n\t\t\t\tonOversized: () => {\n\t\t\t\t\tcurrentResult.truncated = true;\n\t\t\t\t},\n\t\t\t});\n\t\t\tconst beginTermination = (exitCode: number) => {\n\t\t\t\tif (cleanupTermination || settled) return;\n\t\t\t\tcleanupTermination = terminateProcess(proc);\n\t\t\t\tterminationDeadline = setTimeout(() => {\n\t\t\t\t\tdecoder.finish();\n\t\t\t\t\tproc.stdin?.destroy();\n\t\t\t\t\tproc.stdout?.destroy();\n\t\t\t\t\tproc.stderr?.destroy();\n\t\t\t\t\tfinish(exitCode);\n\t\t\t\t}, KILL_GRACE_MS + 1_000);\n\t\t\t};\n\t\t\tconst stopForBudget = (\n\t\t\t\tstop: TurnBudgetStop | { reason: \"work_timeout\" | \"orchestration_timeout\"; limit: number },\n\t\t\t) => {\n\t\t\t\tif (budgetStop || settled || wasAborted) return;\n\t\t\t\tbudgetStop = stop;\n\t\t\t\ttimedOut = stop.reason.endsWith(\"timeout\");\n\t\t\t\tcurrentResult.timedOut = timedOut || undefined;\n\t\t\t\tcurrentResult.stopReason = timedOut ? \"timeout\" : \"limit\";\n\t\t\t\tconst message = formatTurnTerminationMessage(stop.reason, stop.limit);\n\t\t\t\tsetErrorMessage(message);\n\t\t\t\tconst bounded = appendBounded(\n\t\t\t\t\tcurrentResult.stderr,\n\t\t\t\t\t`\\n${message}.`,\n\t\t\t\t\tDEFAULT_MAX_STDERR_BYTES,\n\t\t\t\t);\n\t\t\t\tcurrentResult.stderr = bounded.text;\n\t\t\t\tcurrentResult.truncated ||= bounded.truncated;\n\t\t\t\temitUpdate();\n\t\t\t\tbeginTermination(124);\n\t\t\t};\n\t\t\tbudgetMonitor = new TurnBudgetMonitor({\n\t\t\t\t...launchPolicy?.turnLimits,\n\t\t\t\tonExceeded: stopForBudget,\n\t\t\t});\n\n\t\t\tproc.once(\"spawn\", () => {\n\t\t\t\tcurrentResult.processStarted = true;\n\t\t\t\tif (settled || budgetStop || wasAborted) return;\n\t\t\t\ttimeout = setTimeout(() => {\n\t\t\t\t\tstopForBudget({\n\t\t\t\t\t\treason: launchPolicy?.workTimeoutReason ?? \"work_timeout\",\n\t\t\t\t\t\tlimit: launchPolicy?.workTimeoutReportLimit ?? timeoutMs,\n\t\t\t\t\t});\n\t\t\t\t}, timeoutMs);\n\t\t\t\ttimeout.unref();\n\t\t\t});\n\t\t\tproc.stdout?.on(\"data\", (data) => decoder.push(data));\n\t\t\tproc.stderr?.on(\"data\", (data) => {\n\t\t\t\tconst bounded = appendBounded(\n\t\t\t\t\tcurrentResult.stderr,\n\t\t\t\t\tdata.toString(),\n\t\t\t\t\tDEFAULT_MAX_STDERR_BYTES,\n\t\t\t\t);\n\t\t\t\tcurrentResult.stderr = bounded.text;\n\t\t\t\tcurrentResult.truncated ||= bounded.truncated;\n\t\t\t});\n\t\t\tproc.on(\"close\", (code) => {\n\t\t\t\tdecoder.finish();\n\t\t\t\tfinish(budgetStop ? 124 : wasAborted ? 130 : (code ?? 0));\n\t\t\t});\n\t\t\tproc.on(\"error\", (error) => {\n\t\t\t\tcurrentResult.launchFailed = currentResult.processStarted ? undefined : true;\n\t\t\t\tconst message = setErrorMessage(error.message);\n\t\t\t\tconst bounded = appendBounded(\n\t\t\t\t\tcurrentResult.stderr,\n\t\t\t\t\t`${currentResult.stderr ? \"\\n\" : \"\"}${message}`,\n\t\t\t\t\tDEFAULT_MAX_STDERR_BYTES,\n\t\t\t\t);\n\t\t\t\tcurrentResult.stderr = bounded.text;\n\t\t\t\tcurrentResult.truncated ||= bounded.truncated;\n\t\t\t\tif (currentResult.processStarted) beginTermination(1);\n\t\t\t\telse finish(1);\n\t\t\t});\n\n\t\t\tif (signal) {\n\t\t\t\tabortHandler = () => {\n\t\t\t\t\tif (budgetStop || settled) return;\n\t\t\t\t\twasAborted = true;\n\t\t\t\t\tcurrentResult.aborted = true;\n\t\t\t\t\tcurrentResult.stopReason = \"aborted\";\n\t\t\t\t\tsetErrorMessage(\"Subagent was aborted\");\n\t\t\t\t\tbeginTermination(130);\n\t\t\t\t};\n\t\t\t\tif (signal.aborted) abortHandler();\n\t\t\t\telse signal.addEventListener(\"abort\", abortHandler, { once: true });\n\t\t\t}\n\t\t});\n\n\t\tif (signal?.aborted && budgetStop) {\n\t\t\tbudgetStop = undefined;\n\t\t\ttimedOut = false;\n\t\t\tcurrentResult.timedOut = undefined;\n\t\t\tcurrentResult.aborted = true;\n\t\t\tcurrentResult.stopReason = \"aborted\";\n\t\t\tsetErrorMessage(\"Subagent was aborted\");\n\t\t}\n\t\tcurrentResult.exitCode = currentResult.aborted ? 130 : exitCode;\n\t\tconst final = truncateUtf8(selectedAssistantOutput(), DEFAULT_MAX_OUTPUT_BYTES);\n\t\tcurrentResult.finalOutput = final.text;\n\t\tcurrentResult.truncated ||= final.truncated;\n\t\tif (budgetStop) {\n\t\t\tcurrentResult.partialOutput = currentResult.finalOutput || undefined;\n\t\t\tcurrentResult.termination = {\n\t\t\t\tversion: TURN_TERMINATION_VERSION,\n\t\t\t\treason: budgetStop.reason,\n\t\t\t\tlimit: budgetStop.limit,\n\t\t\t\tcheckpoint: progressJournal.checkpoint(task, currentResult.partialOutput),\n\t\t\t\tfinalization: { attempted: false, status: \"skipped\", durationMs: 0 },\n\t\t\t};\n\t\t}\n\t\tconst remainingFinalizationMs = launchPolicy?.orchestrationDeadlineAt\n\t\t\t? Math.floor(launchPolicy.orchestrationDeadlineAt - Date.now())\n\t\t\t: undefined;\n\t\tif (\n\t\t\tbudgetStop &&\n\t\t\tbudgetStop.reason !== \"orchestration_timeout\" &&\n\t\t\tlaunchPolicy?.finalizeOnTimeout !== false &&\n\t\t\t!signal?.aborted &&\n\t\t\t(remainingFinalizationMs === undefined || remainingFinalizationMs > 0)\n\t\t) {\n\t\t\tconst finalizationStartedAt = Date.now();\n\t\t\tconst requestedFinalizationMs = resolveTimeoutFinalizationMs(\n\t\t\t\ttimeoutMs,\n\t\t\t\tlaunchPolicy?.timeoutFinalizationMs,\n\t\t\t);\n\t\t\tconst finalizationMs = Math.min(\n\t\t\t\trequestedFinalizationMs,\n\t\t\t\tremainingFinalizationMs ?? requestedFinalizationMs,\n\t\t\t);\n\t\t\tconst summary = await runSingleAgent(\n\t\t\t\tdefaultCwd,\n\t\t\t\tagents,\n\t\t\t\tagentName,\n\t\t\t\tbuildTimeoutFinalizationPrompt({\n\t\t\t\t\ttask,\n\t\t\t\t\tpartialOutput: currentResult.partialOutput,\n\t\t\t\t\trecentActivity: currentResult.recentActivity,\n\t\t\t\t\tcheckpoint: currentResult.termination?.checkpoint,\n\t\t\t\t\tterminationReason: budgetStop.reason,\n\t\t\t\t\tresultFormat: launchPolicy?.timeoutResultFormat,\n\t\t\t\t}),\n\t\t\t\tcwd,\n\t\t\t\tstep,\n\t\t\t\tsignal,\n\t\t\t\tthinkingLevel,\n\t\t\t\tfinalizationMs,\n\t\t\t\tundefined,\n\t\t\t\tmakeDetails,\n\t\t\t\tinvocationOverride,\n\t\t\t\t{\n\t\t\t\t\t...launchPolicy,\n\t\t\t\t\ttools: [],\n\t\t\t\t\tdisableExtensions: true,\n\t\t\t\t\tdisableSkills: true,\n\t\t\t\t\tdisablePromptTemplates: true,\n\t\t\t\t\tdisableContextFiles: true,\n\t\t\t\t\tappendSystemPromptPaths: undefined,\n\t\t\t\t\tfinalizeOnTimeout: false,\n\t\t\t\t\tturnLimits: undefined,\n\t\t\t\t\tworkTimeoutReason: \"work_timeout\",\n\t\t\t\t\tworkTimeoutReportLimit: finalizationMs,\n\t\t\t\t\torchestrationDeadlineAt: undefined,\n\t\t\t\t},\n\t\t\t);\n\t\t\tmergeUsageStats(currentResult.usage, summary.usage);\n\t\t\tconst summaryOutput = getResultFinalOutput(summary).trim();\n\t\t\tif (summary.exitCode === 0 && summaryOutput) {\n\t\t\t\tcurrentResult.timeoutSummary = summaryOutput;\n\t\t\t\tcurrentResult.finalOutput = summaryOutput;\n\t\t\t\tif (currentResult.termination) {\n\t\t\t\t\tcurrentResult.termination.finalization = {\n\t\t\t\t\t\tattempted: true,\n\t\t\t\t\t\tstatus: \"completed\",\n\t\t\t\t\t\tdurationMs: Date.now() - finalizationStartedAt,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tcurrentResult.timeoutSummaryError =\n\t\t\t\t\tsummary.errorMessage || summary.stderr.trim() || \"Summary produced no final text\";\n\t\t\t\tif (currentResult.termination) {\n\t\t\t\t\tcurrentResult.termination.finalization = {\n\t\t\t\t\t\tattempted: true,\n\t\t\t\t\t\tstatus: summary.timedOut ? \"timed_out\" : \"failed\",\n\t\t\t\t\t\tdurationMs: Date.now() - finalizationStartedAt,\n\t\t\t\t\t\terror: currentResult.timeoutSummaryError,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurrentResult.truncated ||= summary.truncated;\n\t\t}\n\t\tif (currentResult.termination && !currentResult.finalOutput.trim()) {\n\t\t\tcurrentResult.finalOutput = formatTimeoutCheckpoint(currentResult.termination.checkpoint);\n\t\t}\n\t\tif (currentResult.exitCode === 0 && launchPolicy?.resultFormat !== undefined) {\n\t\t\tcurrentResult.structuredResult = parseAnyStructuredSubagentResult(\n\t\t\t\tcurrentResult.finalOutput ?? \"\",\n\t\t\t\tlaunchPolicy.resultFormat,\n\t\t\t);\n\t\t\tcurrentResult.resultContractInvalid =\n\t\t\t\tlaunchPolicy.resultFormat !== \"text\" && currentResult.structuredResult === undefined;\n\t\t\tif (\n\t\t\t\tcurrentResult.structuredResult?.version === \"pi-subagents:result:v2\" &&\n\t\t\t\tlaunchPolicy.executionPlan\n\t\t\t) {\n\t\t\t\tcurrentResult.structuredResult.provenance = {\n\t\t\t\t\t...currentResult.structuredResult.provenance,\n\t\t\t\t\t...(launchPolicy.executionPlan.taskId\n\t\t\t\t\t\t? { taskId: launchPolicy.executionPlan.taskId }\n\t\t\t\t\t\t: {}),\n\t\t\t\t\ttaskGeneration: launchPolicy.executionPlan.taskGeneration,\n\t\t\t\t\texecutionPlanId: launchPolicy.executionPlan.id,\n\t\t\t\t\tcancellationLineage: [...launchPolicy.executionPlan.cancellationLineage],\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (currentResult.structuredResult?.version === \"pi-subagents:result:v2\") {\n\t\t\t\tcurrentResult.outcome = classifyStructuredOutcome(\n\t\t\t\t\tcurrentResult.structuredResult.status,\n\t\t\t\t\tcurrentResult.structuredResult.reasonCode,\n\t\t\t\t);\n\t\t\t} else if (currentResult.resultContractInvalid) {\n\t\t\t\tcurrentResult.outcome = classifyStructuredOutcome(\n\t\t\t\t\t\"contract-invalid\",\n\t\t\t\t\t\"malformed-structured-result\",\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tcurrentResult.exitCode === 0 &&\n\t\t\tcurrentResult.stopReason !== \"error\" &&\n\t\t\t(currentResult.stopReason === \"toolUse\" || !currentResult.finalOutput.trim())\n\t\t) {\n\t\t\tcurrentResult.exitCode = 1;\n\t\t\tcurrentResult.stopReason = \"error\";\n\t\t\tsetErrorMessage(\"Subagent completed without final text\");\n\t\t}\n\t\tif (currentResult.capabilityGrant?.state === \"active\") {\n\t\t\tcurrentResult.capabilityGrant = revokeCapabilityGrant(\n\t\t\t\tcurrentResult.capabilityGrant,\n\t\t\t\t\"turn-settled\",\n\t\t\t\tDate.now(),\n\t\t\t);\n\t\t}\n\t\tcurrentResult.policy = {\n\t\t\tinherited: [\"environment\"],\n\t\t\toverridden: [\n\t\t\t\t\"cwd\",\n\t\t\t\t...(agent.model ? [\"model\"] : []),\n\t\t\t\t...(thinkingLevel ? [\"thinkingLevel\"] : []),\n\t\t\t\t...(effectiveTools !== undefined ? [\"tools\"] : []),\n\t\t\t\t...(launchPolicy?.disableExtensions ? [\"extensions\"] : []),\n\t\t\t\t...(launchPolicy?.disableSkills ? [\"skills\"] : []),\n\t\t\t\t...(launchPolicy?.disablePromptTemplates ? [\"promptTemplates\"] : []),\n\t\t\t\t...(launchPolicy?.disableContextFiles ? [\"contextFiles\"] : []),\n\t\t\t],\n\t\t\tunsupported: [\"approvalPolicy\", \"sandboxProfile\", \"providerHeaders\"],\n\t\t};\n\t\treturn currentResult;\n\t} finally {\n\t\tfor (const temporary of temporaryPrompts.reverse()) {\n\t\t\ttry {\n\t\t\t\tfs.unlinkSync(temporary.filePath);\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tfs.rmdirSync(temporary.dir);\n\t\t\t} catch {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t}\n\t}\n}\n", "import type { SubagentThinkingLevel } from \"./agents/types.js\";\n\nexport interface PiArgsOptions {\n\tmodel?: string;\n\tthinkingLevel?: SubagentThinkingLevel;\n\ttools?: string[];\n\tdisableExtensions?: boolean;\n\tdisableSkills?: boolean;\n\tdisablePromptTemplates?: boolean;\n\tdisableContextFiles?: boolean;\n\tprojectTrust?: boolean;\n\tbaseSystemPromptPath?: string;\n\tappendSystemPromptPaths?: string[];\n\textensionPaths?: string[];\n\t/** Existing single append prompt path retained for compatibility. */\n\tsystemPromptPath?: string;\n\ttask: string;\n}\n\nexport function buildPiArgs(options: PiArgsOptions): string[] {\n\tconst args: string[] = [\"--mode\", \"json\", \"-p\", \"--no-session\"];\n\tif (options.model) args.push(\"--model\", options.model);\n\tif (options.thinkingLevel) args.push(\"--thinking\", options.thinkingLevel);\n\tif (options.disableExtensions) args.push(\"--no-extensions\");\n\tfor (const extensionPath of options.extensionPaths ?? []) args.push(\"-e\", extensionPath);\n\tif (options.disableSkills) args.push(\"--no-skills\");\n\tif (options.disablePromptTemplates) args.push(\"--no-prompt-templates\");\n\tif (options.disableContextFiles) args.push(\"--no-context-files\");\n\tif (options.projectTrust !== undefined) {\n\t\targs.push(options.projectTrust ? \"--approve\" : \"--no-approve\");\n\t}\n\tif (Array.isArray(options.tools)) {\n\t\tif (options.tools.length > 0) args.push(\"--tools\", options.tools.join(\",\"));\n\t\telse args.push(\"--no-tools\");\n\t}\n\tif (options.baseSystemPromptPath) args.push(\"--system-prompt\", options.baseSystemPromptPath);\n\tfor (const promptPath of options.appendSystemPromptPaths ?? []) {\n\t\targs.push(\"--append-system-prompt\", promptPath);\n\t}\n\tif (options.systemPromptPath) args.push(\"--append-system-prompt\", options.systemPromptPath);\n\targs.push(`Task: ${options.task}`);\n\treturn args;\n}\n", "export interface UsageStats {\n\tinput: number;\n\toutput: number;\n\tcacheRead: number;\n\tcacheWrite: number;\n\tcost: number;\n\tcostInput?: number;\n\tcostOutput?: number;\n\tcostCacheRead?: number;\n\tcostCacheWrite?: number;\n\ttotalTokens?: number;\n\tcontextTokens: number;\n\tturns: number;\n}\n\nconst MAX_USAGE_VALUE = Number.MAX_SAFE_INTEGER;\n\nexport function protocolUsageCount(value: unknown): number {\n\treturn typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : 0;\n}\n\nexport function protocolUsageCost(value: unknown): number {\n\treturn typeof value === \"number\" && Number.isFinite(value) && value >= 0\n\t\t? Math.min(value, MAX_USAGE_VALUE)\n\t\t: 0;\n}\n\nexport function addUsageValue(current: number, addition: number): number {\n\treturn Math.min(MAX_USAGE_VALUE, current + addition);\n}\n\nexport function mergeUsageStats(target: UsageStats, addition: UsageStats): void {\n\tfor (const key of [\"input\", \"output\", \"cacheRead\", \"cacheWrite\", \"cost\", \"turns\"] as const) {\n\t\ttarget[key] = addUsageValue(target[key], addition[key]);\n\t}\n\tfor (const key of [\n\t\t\"costInput\",\n\t\t\"costOutput\",\n\t\t\"costCacheRead\",\n\t\t\"costCacheWrite\",\n\t\t\"totalTokens\",\n\t] as const) {\n\t\tif (addition[key] !== undefined) {\n\t\t\ttarget[key] = addUsageValue(target[key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;AAAA,QAClE,GAAI,cAAc,sBAAsB,CAAC,cAAc,IAAI,CAAC;AAAA,MAC7D;AAAA,MACA,aAAa,CAAC,kBAAkB,kBAAkB,iBAAiB;AAAA,IACpE;AACA,WAAO;AAAA,EACR,UAAE;AACD,eAAW,aAAa,iBAAiB,QAAQ,GAAG;AACnD,UAAI;AACH,QAAG,cAAW,UAAU,QAAQ;AAAA,MACjC,QAAQ;AAAA,MAER;AACA,UAAI;AACH,QAAG,aAAU,UAAU,GAAG;AAAA,MAC3B,QAAQ;AAAA,MAER;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": ["exitCode"]
7
+ }
@@ -0,0 +1,238 @@
1
+ // @generated by scripts/build-runtime.mjs; do not edit.
2
+ // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
+ import {
4
+ resolveAgentToolNames
5
+ } from "./chunk-DPPVEQAM.js";
6
+
7
+ // src/admission-policy.ts
8
+ var DELEGATION_ADMISSION_VERSION = "pi-subagents:admission:v1";
9
+ function evaluateDelegationAdmission(input) {
10
+ if (!input.generationCurrent)
11
+ return decision("abstain-insufficient-evidence", ["stale-generation"]);
12
+ if (!input.requirementsComplete) {
13
+ return decision("abstain-insufficient-evidence", ["requirements-incomplete"]);
14
+ }
15
+ if (!input.capabilitiesSupported) {
16
+ return decision("abstain-insufficient-evidence", ["capability-unsupported"]);
17
+ }
18
+ if (!input.budgetAllowsChildren) {
19
+ return decision("parent-owned-direct", ["child-budget-insufficient"]);
20
+ }
21
+ if (input.independentWorkItems >= 2 && input.coupling === "sparse") {
22
+ return decision(
23
+ "bounded-two-child",
24
+ ["declared-independent-work"],
25
+ "parallel-critical-path-reduction"
26
+ );
27
+ }
28
+ if (input.verificationRequired) {
29
+ return input.verificationAvailable ? decision(
30
+ "one-child-plus-verification",
31
+ ["independent-verification-required"],
32
+ "independent-error-detection"
33
+ ) : decision("abstain-insufficient-evidence", ["verification-unavailable"]);
34
+ }
35
+ if (input.contextPressure === "high") {
36
+ return decision("one-child", ["declared-context-pressure"], "context-isolation");
37
+ }
38
+ return decision("parent-owned-direct", ["delegation-benefit-not-established"]);
39
+ }
40
+ function decision(recommendation, reasonCodes, benefitHypothesis = "none") {
41
+ return {
42
+ version: DELEGATION_ADMISSION_VERSION,
43
+ recommendation,
44
+ reasonCodes,
45
+ benefitHypothesis,
46
+ auditOnly: true
47
+ };
48
+ }
49
+
50
+ // src/execution-plan.ts
51
+ import { createHash } from "node:crypto";
52
+ var EXECUTION_PLAN_VERSION = "pi-subagents:execution-plan:v1";
53
+ var EXECUTION_ACKNOWLEDGEMENT_VERSION = "pi-subagents:acknowledgement:v1";
54
+ function createExecutionPlan(input) {
55
+ const manifest = input.agent.capabilityManifest;
56
+ const requestedCapabilities = unique(input.contract?.requestedAuthority?.capabilities ?? []);
57
+ const declaredCapabilities = unique(manifest?.capabilities ?? []);
58
+ const missingCapabilities = requestedCapabilities.filter(
59
+ (capability) => !declaredCapabilities.includes(capability)
60
+ );
61
+ const capabilityFit = manifest ? missingCapabilities.length > 0 ? "mismatch" : "match" : "unknown";
62
+ const requestedTools = unique(input.contract?.requestedAuthority?.tools ?? []);
63
+ const effectiveTools = input.effectiveTools ? unique(input.effectiveTools) : void 0;
64
+ const missingTools = requestedTools.filter((tool) => !(effectiveTools ?? []).includes(tool));
65
+ const overgrantedTools = requestedTools.length === 0 ? [] : (effectiveTools ?? []).filter((tool) => !requestedTools.includes(tool));
66
+ const resultFormatSupported = manifest ? manifest.resultFormats.includes(input.resultFormat) : "unknown";
67
+ const unsupportedGuarantees = unsupported(input.contract);
68
+ const taskGeneration = input.taskGeneration ?? 0;
69
+ const cancellationLineage = [...input.cancellationLineage ?? []];
70
+ const admissionRequest = input.contract?.admission;
71
+ const admission = evaluateDelegationAdmission({
72
+ contextPressure: admissionRequest?.contextPressure ?? "low",
73
+ independentWorkItems: admissionRequest?.independentWorkItems ?? 1,
74
+ coupling: admissionRequest?.coupling ?? "dense",
75
+ verificationRequired: admissionRequest?.verificationRequired ?? false,
76
+ verificationAvailable: admissionRequest?.verificationAvailable ?? false,
77
+ capabilitiesSupported: capabilityFit === "match" && missingTools.length === 0,
78
+ budgetAllowsChildren: admissionRequest?.budgetAllowsChildren ?? true,
79
+ generationCurrent: true,
80
+ requirementsComplete: admissionRequest?.requirementsComplete ?? false
81
+ });
82
+ const warnings = [];
83
+ if (!manifest) warnings.push("agent-capabilities-unknown");
84
+ if (missingCapabilities.length > 0) warnings.push("capability-mismatch");
85
+ if (missingTools.length > 0) warnings.push("requested-tools-missing");
86
+ if (overgrantedTools.length > 0) warnings.push("tools-overgranted");
87
+ if (resultFormatSupported === false) warnings.push("result-format-unsupported");
88
+ if (unsupportedGuarantees.length > 0) warnings.push("unsupported-guarantees");
89
+ const planWithoutId = {
90
+ version: EXECUTION_PLAN_VERSION,
91
+ mode: input.contract?.enforcement ?? "audit",
92
+ ...input.contract?.taskId ? { taskId: input.contract.taskId } : {},
93
+ agent: {
94
+ name: input.agent.name,
95
+ source: input.agent.source,
96
+ capabilitiesKnown: manifest !== void 0
97
+ },
98
+ capabilityFit,
99
+ missingCapabilities,
100
+ requestedCapabilities,
101
+ declaredCapabilities,
102
+ requestedTools,
103
+ ...effectiveTools === void 0 ? {} : { effectiveTools },
104
+ missingTools,
105
+ overgrantedTools,
106
+ resultFormat: input.resultFormat,
107
+ sideEffectPolicy: input.contract?.sideEffectPolicy ?? "mutating",
108
+ resultFormatSupported,
109
+ target: structuredClone(input.target),
110
+ workspaceMode: input.workspaceMode,
111
+ transport: input.transport,
112
+ ...input.model === void 0 ? {} : { model: input.model },
113
+ ...input.thinkingLevel === void 0 ? {} : { thinkingLevel: input.thinkingLevel },
114
+ ...input.timeoutMs === void 0 ? {} : { timeoutMs: input.timeoutMs },
115
+ unsupportedGuarantees,
116
+ warnings,
117
+ taskGeneration,
118
+ cancellationLineage,
119
+ admission
120
+ };
121
+ return { ...planWithoutId, id: executionPlanId(planWithoutId) };
122
+ }
123
+ function resolveContractTools(configuredTools, contract) {
124
+ const requested = contract?.requestedAuthority?.tools;
125
+ if (contract?.enforcement !== "enforce" || requested === void 0) {
126
+ return configuredTools ? unique(configuredTools) : void 0;
127
+ }
128
+ const availableTools = resolveAgentToolNames(configuredTools);
129
+ return unique(requested.filter((tool) => availableTools.includes(tool)));
130
+ }
131
+ function acknowledgeExecutionPlan(plan) {
132
+ if (plan.mode === "audit") {
133
+ return {
134
+ version: EXECUTION_ACKNOWLEDGEMENT_VERSION,
135
+ status: "accepted",
136
+ reasonCodes: [],
137
+ recoveryActions: []
138
+ };
139
+ }
140
+ const reasonCodes = [];
141
+ const recoveryActions = [];
142
+ if (plan.capabilityFit === "unknown") {
143
+ reasonCodes.push("capabilities-unknown");
144
+ recoveryActions.push("declare-capabilities", "reroute");
145
+ }
146
+ if (plan.missingCapabilities.length > 0) {
147
+ reasonCodes.push("capability-mismatch");
148
+ recoveryActions.push("reroute");
149
+ }
150
+ if (plan.missingTools.length > 0) {
151
+ reasonCodes.push("authority-missing");
152
+ recoveryActions.push("grant-authority", "reroute");
153
+ }
154
+ if (plan.overgrantedTools.length > 0) {
155
+ reasonCodes.push("authority-overgranted");
156
+ recoveryActions.push("narrow-authority");
157
+ }
158
+ if (plan.resultFormatSupported !== true) {
159
+ reasonCodes.push("result-format-unsupported");
160
+ recoveryActions.push("reroute", "change-result-format");
161
+ }
162
+ if (plan.unsupportedGuarantees.length > 0) {
163
+ reasonCodes.push("unsupported-guarantee");
164
+ recoveryActions.push("stop");
165
+ }
166
+ return {
167
+ version: EXECUTION_ACKNOWLEDGEMENT_VERSION,
168
+ status: reasonCodes.length === 0 ? "accepted" : "rejected",
169
+ reasonCodes: unique(reasonCodes),
170
+ recoveryActions: unique(recoveryActions)
171
+ };
172
+ }
173
+ function copyExecutionPlan(plan) {
174
+ const { id: _storedId, ...cloned } = structuredClone(plan);
175
+ const legacyAdmission = evaluateDelegationAdmission({
176
+ contextPressure: "low",
177
+ independentWorkItems: 1,
178
+ coupling: "dense",
179
+ verificationRequired: false,
180
+ verificationAvailable: false,
181
+ capabilitiesSupported: false,
182
+ budgetAllowsChildren: true,
183
+ generationCurrent: true,
184
+ requirementsComplete: false
185
+ });
186
+ const normalized = {
187
+ ...cloned,
188
+ sideEffectPolicy: plan.sideEffectPolicy ?? "mutating",
189
+ taskGeneration: plan.taskGeneration ?? 0,
190
+ cancellationLineage: plan.cancellationLineage ?? [],
191
+ admission: plan.admission ?? legacyAdmission
192
+ };
193
+ return { ...normalized, id: executionPlanId(normalized) };
194
+ }
195
+ function rotateExecutionPlanGeneration(plan) {
196
+ const normalized = copyExecutionPlan(plan);
197
+ const { id: previousId, ...withoutId } = normalized;
198
+ const rotated = {
199
+ ...withoutId,
200
+ taskGeneration: normalized.taskGeneration + 1,
201
+ cancellationLineage: [...normalized.cancellationLineage, previousId]
202
+ };
203
+ return { ...rotated, id: executionPlanId(rotated) };
204
+ }
205
+ function isExecutionPlan(value) {
206
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
207
+ const plan = value;
208
+ return plan.version === EXECUTION_PLAN_VERSION && (plan.mode === "audit" || plan.mode === "enforce") && Boolean(plan.agent) && typeof plan.agent?.name === "string" && ["built-in", "user", "project"].includes(String(plan.agent?.source)) && ["match", "mismatch", "unknown"].includes(String(plan.capabilityFit)) && Array.isArray(plan.missingCapabilities) && plan.missingCapabilities.every((item) => typeof item === "string") && Array.isArray(plan.requestedCapabilities) && plan.requestedCapabilities.every((item) => typeof item === "string") && Array.isArray(plan.declaredCapabilities) && plan.declaredCapabilities.every((item) => typeof item === "string") && Array.isArray(plan.missingTools) && plan.missingTools.every((item) => typeof item === "string") && Array.isArray(plan.requestedTools) && plan.requestedTools.every((item) => typeof item === "string") && (plan.effectiveTools === void 0 || Array.isArray(plan.effectiveTools) && plan.effectiveTools.every((item) => typeof item === "string")) && Array.isArray(plan.overgrantedTools) && plan.overgrantedTools.every((item) => typeof item === "string") && ["text", "structured-v1", "structured-v2"].includes(String(plan.resultFormat)) && (typeof plan.resultFormatSupported === "boolean" || plan.resultFormatSupported === "unknown") && Boolean(plan.target) && typeof plan.target?.cwd === "string" && ["current-workspace", "external"].includes(String(plan.target?.boundary)) && (plan.workspaceMode === "shared" || plan.workspaceMode === "worktree") && ["subprocess", "in-process", "rpc", "auto"].includes(String(plan.transport)) && typeof plan.id === "string" && /^[a-f0-9]{64}$/u.test(plan.id) && (plan.taskGeneration === void 0 || Number.isSafeInteger(plan.taskGeneration) && Number(plan.taskGeneration) >= 0) && (plan.cancellationLineage === void 0 || Array.isArray(plan.cancellationLineage) && plan.cancellationLineage.every((item) => typeof item === "string")) && (plan.admission === void 0 || typeof plan.admission === "object" && plan.admission.auditOnly === true && typeof plan.admission.recommendation === "string" && Array.isArray(plan.admission.reasonCodes) && plan.admission.reasonCodes.every((item) => typeof item === "string")) && (plan.sideEffectPolicy === void 0 || ["read-only", "idempotent", "mutating"].includes(String(plan.sideEffectPolicy))) && Array.isArray(plan.unsupportedGuarantees) && plan.unsupportedGuarantees.every((item) => typeof item === "string") && Array.isArray(plan.warnings) && plan.warnings.every((item) => typeof item === "string") && copyExecutionPlan(plan).id === plan.id;
209
+ }
210
+ function executionPlanId(plan) {
211
+ return createHash("sha256").update(JSON.stringify(plan)).digest("hex");
212
+ }
213
+ function unsupported(contract) {
214
+ if (!contract?.requestedAuthority) return [];
215
+ const authority = contract.requestedAuthority;
216
+ const result = [];
217
+ if (authority.readPaths && authority.readPaths.length > 0) result.push("read-path-scope");
218
+ if (authority.writePaths && authority.writePaths.length > 0) result.push("write-path-scope");
219
+ if (authority.network === "denied") result.push("network-denial");
220
+ if (authority.network === "required") result.push("network-availability");
221
+ if (authority.secrets === "denied") result.push("secret-denial");
222
+ if (authority.secrets === "required") result.push("secret-availability");
223
+ return result;
224
+ }
225
+ function unique(values) {
226
+ return [...new Set(values)];
227
+ }
228
+
229
+ export {
230
+ evaluateDelegationAdmission,
231
+ createExecutionPlan,
232
+ resolveContractTools,
233
+ acknowledgeExecutionPlan,
234
+ copyExecutionPlan,
235
+ rotateExecutionPlanGeneration,
236
+ isExecutionPlan
237
+ };
238
+ //# sourceMappingURL=chunk-DSOOH73Y.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/admission-policy.ts", "../../src/execution-plan.ts"],
4
+ "sourcesContent": ["export const DELEGATION_ADMISSION_VERSION = \"pi-subagents:admission:v1\" as const;\n\nexport type DelegationAdmissionRecommendation =\n\t| \"parent-owned-direct\"\n\t| \"one-child\"\n\t| \"one-child-plus-verification\"\n\t| \"bounded-two-child\"\n\t| \"abstain-insufficient-evidence\";\n\nexport interface DelegationAdmissionInput {\n\tcontextPressure: \"low\" | \"medium\" | \"high\";\n\tindependentWorkItems: number;\n\tcoupling: \"dense\" | \"sparse\";\n\tverificationRequired: boolean;\n\tverificationAvailable: boolean;\n\tcapabilitiesSupported: boolean;\n\tbudgetAllowsChildren: boolean;\n\tgenerationCurrent: boolean;\n\trequirementsComplete: boolean;\n}\n\nexport interface DelegationAdmissionDecision {\n\tversion: typeof DELEGATION_ADMISSION_VERSION;\n\trecommendation: DelegationAdmissionRecommendation;\n\treasonCodes: string[];\n\tbenefitHypothesis: string;\n\tauditOnly: true;\n}\n\nexport function evaluateDelegationAdmission(\n\tinput: DelegationAdmissionInput,\n): DelegationAdmissionDecision {\n\tif (!input.generationCurrent)\n\t\treturn decision(\"abstain-insufficient-evidence\", [\"stale-generation\"]);\n\tif (!input.requirementsComplete) {\n\t\treturn decision(\"abstain-insufficient-evidence\", [\"requirements-incomplete\"]);\n\t}\n\tif (!input.capabilitiesSupported) {\n\t\treturn decision(\"abstain-insufficient-evidence\", [\"capability-unsupported\"]);\n\t}\n\tif (!input.budgetAllowsChildren) {\n\t\treturn decision(\"parent-owned-direct\", [\"child-budget-insufficient\"]);\n\t}\n\tif (input.independentWorkItems >= 2 && input.coupling === \"sparse\") {\n\t\treturn decision(\n\t\t\t\"bounded-two-child\",\n\t\t\t[\"declared-independent-work\"],\n\t\t\t\"parallel-critical-path-reduction\",\n\t\t);\n\t}\n\tif (input.verificationRequired) {\n\t\treturn input.verificationAvailable\n\t\t\t? decision(\n\t\t\t\t\t\"one-child-plus-verification\",\n\t\t\t\t\t[\"independent-verification-required\"],\n\t\t\t\t\t\"independent-error-detection\",\n\t\t\t\t)\n\t\t\t: decision(\"abstain-insufficient-evidence\", [\"verification-unavailable\"]);\n\t}\n\tif (input.contextPressure === \"high\") {\n\t\treturn decision(\"one-child\", [\"declared-context-pressure\"], \"context-isolation\");\n\t}\n\treturn decision(\"parent-owned-direct\", [\"delegation-benefit-not-established\"]);\n}\n\nfunction decision(\n\trecommendation: DelegationAdmissionRecommendation,\n\treasonCodes: string[],\n\tbenefitHypothesis = \"none\",\n): DelegationAdmissionDecision {\n\treturn {\n\t\tversion: DELEGATION_ADMISSION_VERSION,\n\t\trecommendation,\n\t\treasonCodes,\n\t\tbenefitHypothesis,\n\t\tauditOnly: true,\n\t};\n}\n", "import { createHash } from \"node:crypto\";\nimport {\n\ttype DelegationAdmissionDecision,\n\tevaluateDelegationAdmission,\n} from \"./admission-policy.js\";\nimport {\n\ttype AgentConfig,\n\ttype AgentSource,\n\tresolveAgentToolNames,\n\ttype SubagentThinkingLevel,\n} from \"./agents/types.js\";\nimport type { TargetPolicyAudit } from \"./cwd-policy.js\";\nimport type { DelegationContract } from \"./delegation-contract.js\";\nimport type { SubagentResultFormat } from \"./result-contract.js\";\n\nexport const EXECUTION_PLAN_VERSION = \"pi-subagents:execution-plan:v1\" as const;\nexport const EXECUTION_ACKNOWLEDGEMENT_VERSION = \"pi-subagents:acknowledgement:v1\" as const;\n\nexport type CapabilityFit = \"match\" | \"mismatch\" | \"unknown\";\nexport type ExecutionPlanTransport = \"subprocess\" | \"in-process\" | \"rpc\" | \"auto\";\n\nexport interface ExecutionPlanAgentProjection {\n\tname: string;\n\tsource: AgentSource;\n\tcapabilitiesKnown: boolean;\n}\n\nexport interface ExecutionPlan {\n\tversion: typeof EXECUTION_PLAN_VERSION;\n\tid: string;\n\tmode: \"audit\" | \"enforce\";\n\ttaskId?: string;\n\ttaskGeneration: number;\n\tcancellationLineage: string[];\n\tadmission: DelegationAdmissionDecision;\n\tagent: ExecutionPlanAgentProjection;\n\tcapabilityFit: CapabilityFit;\n\tmissingCapabilities: string[];\n\trequestedCapabilities: string[];\n\tdeclaredCapabilities: string[];\n\trequestedTools: string[];\n\teffectiveTools?: string[];\n\tmissingTools: string[];\n\tovergrantedTools: string[];\n\tresultFormat: SubagentResultFormat;\n\tsideEffectPolicy: \"read-only\" | \"idempotent\" | \"mutating\";\n\tresultFormatSupported: boolean | \"unknown\";\n\ttarget: TargetPolicyAudit;\n\tworkspaceMode: \"shared\" | \"worktree\";\n\ttransport: ExecutionPlanTransport;\n\tmodel?: string;\n\tthinkingLevel?: SubagentThinkingLevel;\n\ttimeoutMs?: number;\n\tunsupportedGuarantees: string[];\n\twarnings: string[];\n}\n\nexport interface ExecutionAcknowledgement {\n\tversion: typeof EXECUTION_ACKNOWLEDGEMENT_VERSION;\n\tstatus: \"accepted\" | \"rejected\";\n\treasonCodes: string[];\n\trecoveryActions: string[];\n}\n\nexport interface CreateExecutionPlanInput {\n\tcontract?: DelegationContract;\n\tagent: AgentConfig;\n\teffectiveTools?: string[];\n\ttarget: TargetPolicyAudit;\n\tworkspaceMode: \"shared\" | \"worktree\";\n\ttransport: ExecutionPlanTransport;\n\tresultFormat: SubagentResultFormat;\n\tmodel?: string;\n\tthinkingLevel?: SubagentThinkingLevel;\n\ttimeoutMs?: number;\n\ttaskGeneration?: number;\n\tcancellationLineage?: string[];\n}\n\nexport function createExecutionPlan(input: CreateExecutionPlanInput): ExecutionPlan {\n\tconst manifest = input.agent.capabilityManifest;\n\tconst requestedCapabilities = unique(input.contract?.requestedAuthority?.capabilities ?? []);\n\tconst declaredCapabilities = unique(manifest?.capabilities ?? []);\n\tconst missingCapabilities = requestedCapabilities.filter(\n\t\t(capability) => !declaredCapabilities.includes(capability),\n\t);\n\tconst capabilityFit: CapabilityFit = manifest\n\t\t? missingCapabilities.length > 0\n\t\t\t? \"mismatch\"\n\t\t\t: \"match\"\n\t\t: \"unknown\";\n\tconst requestedTools = unique(input.contract?.requestedAuthority?.tools ?? []);\n\tconst effectiveTools = input.effectiveTools ? unique(input.effectiveTools) : undefined;\n\tconst missingTools = requestedTools.filter((tool) => !(effectiveTools ?? []).includes(tool));\n\tconst overgrantedTools =\n\t\trequestedTools.length === 0\n\t\t\t? []\n\t\t\t: (effectiveTools ?? []).filter((tool) => !requestedTools.includes(tool));\n\tconst resultFormatSupported = manifest\n\t\t? manifest.resultFormats.includes(input.resultFormat)\n\t\t: \"unknown\";\n\tconst unsupportedGuarantees = unsupported(input.contract);\n\tconst taskGeneration = input.taskGeneration ?? 0;\n\tconst cancellationLineage = [...(input.cancellationLineage ?? [])];\n\tconst admissionRequest = input.contract?.admission;\n\tconst admission = evaluateDelegationAdmission({\n\t\tcontextPressure: admissionRequest?.contextPressure ?? \"low\",\n\t\tindependentWorkItems: admissionRequest?.independentWorkItems ?? 1,\n\t\tcoupling: admissionRequest?.coupling ?? \"dense\",\n\t\tverificationRequired: admissionRequest?.verificationRequired ?? false,\n\t\tverificationAvailable: admissionRequest?.verificationAvailable ?? false,\n\t\tcapabilitiesSupported: capabilityFit === \"match\" && missingTools.length === 0,\n\t\tbudgetAllowsChildren: admissionRequest?.budgetAllowsChildren ?? true,\n\t\tgenerationCurrent: true,\n\t\trequirementsComplete: admissionRequest?.requirementsComplete ?? false,\n\t});\n\tconst warnings: string[] = [];\n\tif (!manifest) warnings.push(\"agent-capabilities-unknown\");\n\tif (missingCapabilities.length > 0) warnings.push(\"capability-mismatch\");\n\tif (missingTools.length > 0) warnings.push(\"requested-tools-missing\");\n\tif (overgrantedTools.length > 0) warnings.push(\"tools-overgranted\");\n\tif (resultFormatSupported === false) warnings.push(\"result-format-unsupported\");\n\tif (unsupportedGuarantees.length > 0) warnings.push(\"unsupported-guarantees\");\n\tconst planWithoutId: Omit<ExecutionPlan, \"id\"> = {\n\t\tversion: EXECUTION_PLAN_VERSION,\n\t\tmode: input.contract?.enforcement ?? \"audit\",\n\t\t...(input.contract?.taskId ? { taskId: input.contract.taskId } : {}),\n\t\tagent: {\n\t\t\tname: input.agent.name,\n\t\t\tsource: input.agent.source,\n\t\t\tcapabilitiesKnown: manifest !== undefined,\n\t\t},\n\t\tcapabilityFit,\n\t\tmissingCapabilities,\n\t\trequestedCapabilities,\n\t\tdeclaredCapabilities,\n\t\trequestedTools,\n\t\t...(effectiveTools === undefined ? {} : { effectiveTools }),\n\t\tmissingTools,\n\t\tovergrantedTools,\n\t\tresultFormat: input.resultFormat,\n\t\tsideEffectPolicy: input.contract?.sideEffectPolicy ?? \"mutating\",\n\t\tresultFormatSupported,\n\t\ttarget: structuredClone(input.target),\n\t\tworkspaceMode: input.workspaceMode,\n\t\ttransport: input.transport,\n\t\t...(input.model === undefined ? {} : { model: input.model }),\n\t\t...(input.thinkingLevel === undefined ? {} : { thinkingLevel: input.thinkingLevel }),\n\t\t...(input.timeoutMs === undefined ? {} : { timeoutMs: input.timeoutMs }),\n\t\tunsupportedGuarantees,\n\t\twarnings,\n\t\ttaskGeneration,\n\t\tcancellationLineage,\n\t\tadmission,\n\t};\n\treturn { ...planWithoutId, id: executionPlanId(planWithoutId) };\n}\n\nexport function resolveContractTools(\n\tconfiguredTools: string[] | undefined,\n\tcontract: DelegationContract | undefined,\n): string[] | undefined {\n\tconst requested = contract?.requestedAuthority?.tools;\n\tif (contract?.enforcement !== \"enforce\" || requested === undefined) {\n\t\treturn configuredTools ? unique(configuredTools) : undefined;\n\t}\n\tconst availableTools = resolveAgentToolNames(configuredTools);\n\treturn unique(requested.filter((tool) => availableTools.includes(tool)));\n}\n\nexport function acknowledgeExecutionPlan(plan: ExecutionPlan): ExecutionAcknowledgement {\n\tif (plan.mode === \"audit\") {\n\t\treturn {\n\t\t\tversion: EXECUTION_ACKNOWLEDGEMENT_VERSION,\n\t\t\tstatus: \"accepted\",\n\t\t\treasonCodes: [],\n\t\t\trecoveryActions: [],\n\t\t};\n\t}\n\tconst reasonCodes: string[] = [];\n\tconst recoveryActions: string[] = [];\n\tif (plan.capabilityFit === \"unknown\") {\n\t\treasonCodes.push(\"capabilities-unknown\");\n\t\trecoveryActions.push(\"declare-capabilities\", \"reroute\");\n\t}\n\tif (plan.missingCapabilities.length > 0) {\n\t\treasonCodes.push(\"capability-mismatch\");\n\t\trecoveryActions.push(\"reroute\");\n\t}\n\tif (plan.missingTools.length > 0) {\n\t\treasonCodes.push(\"authority-missing\");\n\t\trecoveryActions.push(\"grant-authority\", \"reroute\");\n\t}\n\tif (plan.overgrantedTools.length > 0) {\n\t\treasonCodes.push(\"authority-overgranted\");\n\t\trecoveryActions.push(\"narrow-authority\");\n\t}\n\tif (plan.resultFormatSupported !== true) {\n\t\treasonCodes.push(\"result-format-unsupported\");\n\t\trecoveryActions.push(\"reroute\", \"change-result-format\");\n\t}\n\tif (plan.unsupportedGuarantees.length > 0) {\n\t\treasonCodes.push(\"unsupported-guarantee\");\n\t\trecoveryActions.push(\"stop\");\n\t}\n\treturn {\n\t\tversion: EXECUTION_ACKNOWLEDGEMENT_VERSION,\n\t\tstatus: reasonCodes.length === 0 ? \"accepted\" : \"rejected\",\n\t\treasonCodes: unique(reasonCodes),\n\t\trecoveryActions: unique(recoveryActions),\n\t};\n}\n\nexport function copyExecutionPlan(plan: ExecutionPlan): ExecutionPlan {\n\tconst { id: _storedId, ...cloned } = structuredClone(plan);\n\tconst legacyAdmission = evaluateDelegationAdmission({\n\t\tcontextPressure: \"low\",\n\t\tindependentWorkItems: 1,\n\t\tcoupling: \"dense\",\n\t\tverificationRequired: false,\n\t\tverificationAvailable: false,\n\t\tcapabilitiesSupported: false,\n\t\tbudgetAllowsChildren: true,\n\t\tgenerationCurrent: true,\n\t\trequirementsComplete: false,\n\t});\n\tconst normalized = {\n\t\t...cloned,\n\t\tsideEffectPolicy: plan.sideEffectPolicy ?? \"mutating\",\n\t\ttaskGeneration: plan.taskGeneration ?? 0,\n\t\tcancellationLineage: plan.cancellationLineage ?? [],\n\t\tadmission: plan.admission ?? legacyAdmission,\n\t};\n\treturn { ...normalized, id: executionPlanId(normalized) };\n}\n\nexport function rotateExecutionPlanGeneration(plan: ExecutionPlan): ExecutionPlan {\n\tconst normalized = copyExecutionPlan(plan);\n\tconst { id: previousId, ...withoutId } = normalized;\n\tconst rotated = {\n\t\t...withoutId,\n\t\ttaskGeneration: normalized.taskGeneration + 1,\n\t\tcancellationLineage: [...normalized.cancellationLineage, previousId],\n\t};\n\treturn { ...rotated, id: executionPlanId(rotated) };\n}\n\nexport function isExecutionPlan(value: unknown): value is ExecutionPlan {\n\tif (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n\tconst plan = value as Partial<ExecutionPlan>;\n\treturn (\n\t\tplan.version === EXECUTION_PLAN_VERSION &&\n\t\t(plan.mode === \"audit\" || plan.mode === \"enforce\") &&\n\t\tBoolean(plan.agent) &&\n\t\ttypeof plan.agent?.name === \"string\" &&\n\t\t[\"built-in\", \"user\", \"project\"].includes(String(plan.agent?.source)) &&\n\t\t[\"match\", \"mismatch\", \"unknown\"].includes(String(plan.capabilityFit)) &&\n\t\tArray.isArray(plan.missingCapabilities) &&\n\t\tplan.missingCapabilities.every((item) => typeof item === \"string\") &&\n\t\tArray.isArray(plan.requestedCapabilities) &&\n\t\tplan.requestedCapabilities.every((item) => typeof item === \"string\") &&\n\t\tArray.isArray(plan.declaredCapabilities) &&\n\t\tplan.declaredCapabilities.every((item) => typeof item === \"string\") &&\n\t\tArray.isArray(plan.missingTools) &&\n\t\tplan.missingTools.every((item) => typeof item === \"string\") &&\n\t\tArray.isArray(plan.requestedTools) &&\n\t\tplan.requestedTools.every((item) => typeof item === \"string\") &&\n\t\t(plan.effectiveTools === undefined ||\n\t\t\t(Array.isArray(plan.effectiveTools) &&\n\t\t\t\tplan.effectiveTools.every((item) => typeof item === \"string\"))) &&\n\t\tArray.isArray(plan.overgrantedTools) &&\n\t\tplan.overgrantedTools.every((item) => typeof item === \"string\") &&\n\t\t[\"text\", \"structured-v1\", \"structured-v2\"].includes(String(plan.resultFormat)) &&\n\t\t(typeof plan.resultFormatSupported === \"boolean\" || plan.resultFormatSupported === \"unknown\") &&\n\t\tBoolean(plan.target) &&\n\t\ttypeof plan.target?.cwd === \"string\" &&\n\t\t[\"current-workspace\", \"external\"].includes(String(plan.target?.boundary)) &&\n\t\t(plan.workspaceMode === \"shared\" || plan.workspaceMode === \"worktree\") &&\n\t\t[\"subprocess\", \"in-process\", \"rpc\", \"auto\"].includes(String(plan.transport)) &&\n\t\ttypeof plan.id === \"string\" &&\n\t\t/^[a-f0-9]{64}$/u.test(plan.id) &&\n\t\t(plan.taskGeneration === undefined ||\n\t\t\t(Number.isSafeInteger(plan.taskGeneration) && Number(plan.taskGeneration) >= 0)) &&\n\t\t(plan.cancellationLineage === undefined ||\n\t\t\t(Array.isArray(plan.cancellationLineage) &&\n\t\t\t\tplan.cancellationLineage.every((item) => typeof item === \"string\"))) &&\n\t\t(plan.admission === undefined ||\n\t\t\t(typeof plan.admission === \"object\" &&\n\t\t\t\tplan.admission.auditOnly === true &&\n\t\t\t\ttypeof plan.admission.recommendation === \"string\" &&\n\t\t\t\tArray.isArray(plan.admission.reasonCodes) &&\n\t\t\t\tplan.admission.reasonCodes.every((item) => typeof item === \"string\"))) &&\n\t\t(plan.sideEffectPolicy === undefined ||\n\t\t\t[\"read-only\", \"idempotent\", \"mutating\"].includes(String(plan.sideEffectPolicy))) &&\n\t\tArray.isArray(plan.unsupportedGuarantees) &&\n\t\tplan.unsupportedGuarantees.every((item) => typeof item === \"string\") &&\n\t\tArray.isArray(plan.warnings) &&\n\t\tplan.warnings.every((item) => typeof item === \"string\") &&\n\t\tcopyExecutionPlan(plan as ExecutionPlan).id === plan.id\n\t);\n}\n\nfunction executionPlanId(plan: Omit<ExecutionPlan, \"id\"> | Record<string, unknown>): string {\n\treturn createHash(\"sha256\").update(JSON.stringify(plan)).digest(\"hex\");\n}\n\nfunction unsupported(contract: DelegationContract | undefined): string[] {\n\tif (!contract?.requestedAuthority) return [];\n\tconst authority = contract.requestedAuthority;\n\tconst result: string[] = [];\n\tif (authority.readPaths && authority.readPaths.length > 0) result.push(\"read-path-scope\");\n\tif (authority.writePaths && authority.writePaths.length > 0) result.push(\"write-path-scope\");\n\tif (authority.network === \"denied\") result.push(\"network-denial\");\n\tif (authority.network === \"required\") result.push(\"network-availability\");\n\tif (authority.secrets === \"denied\") result.push(\"secret-denial\");\n\tif (authority.secrets === \"required\") result.push(\"secret-availability\");\n\treturn result;\n}\n\nfunction unique(values: readonly string[]): string[] {\n\treturn [...new Set(values)];\n}\n"],
5
+ "mappings": ";;;;;;;AAAO,IAAM,+BAA+B;AA6BrC,SAAS,4BACf,OAC8B;AAC9B,MAAI,CAAC,MAAM;AACV,WAAO,SAAS,iCAAiC,CAAC,kBAAkB,CAAC;AACtE,MAAI,CAAC,MAAM,sBAAsB;AAChC,WAAO,SAAS,iCAAiC,CAAC,yBAAyB,CAAC;AAAA,EAC7E;AACA,MAAI,CAAC,MAAM,uBAAuB;AACjC,WAAO,SAAS,iCAAiC,CAAC,wBAAwB,CAAC;AAAA,EAC5E;AACA,MAAI,CAAC,MAAM,sBAAsB;AAChC,WAAO,SAAS,uBAAuB,CAAC,2BAA2B,CAAC;AAAA,EACrE;AACA,MAAI,MAAM,wBAAwB,KAAK,MAAM,aAAa,UAAU;AACnE,WAAO;AAAA,MACN;AAAA,MACA,CAAC,2BAA2B;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AACA,MAAI,MAAM,sBAAsB;AAC/B,WAAO,MAAM,wBACV;AAAA,MACA;AAAA,MACA,CAAC,mCAAmC;AAAA,MACpC;AAAA,IACD,IACC,SAAS,iCAAiC,CAAC,0BAA0B,CAAC;AAAA,EAC1E;AACA,MAAI,MAAM,oBAAoB,QAAQ;AACrC,WAAO,SAAS,aAAa,CAAC,2BAA2B,GAAG,mBAAmB;AAAA,EAChF;AACA,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