@narumitw/pi-subagents 2.0.0 → 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.
- package/README.md +21 -8
- package/dist/chunks/auto-transport-SY2VHUFH.ts +109 -0
- package/dist/chunks/auto-transport-SY2VHUFH.ts.map +7 -0
- package/dist/chunks/capability-grant-CGEWOEKE.ts +19 -0
- package/dist/chunks/capability-grant-CGEWOEKE.ts.map +7 -0
- package/dist/chunks/chunk-434NII74.ts +282 -0
- package/dist/chunks/chunk-434NII74.ts.map +7 -0
- package/dist/chunks/chunk-47SK2QYC.ts +56 -0
- package/dist/chunks/chunk-47SK2QYC.ts.map +7 -0
- package/dist/chunks/chunk-6KJ34M6S.ts +159 -0
- package/dist/chunks/chunk-6KJ34M6S.ts.map +7 -0
- package/dist/chunks/chunk-7OBINKFM.ts +80 -0
- package/dist/chunks/chunk-7OBINKFM.ts.map +7 -0
- package/dist/chunks/chunk-7QPPBBXZ.ts +335 -0
- package/dist/chunks/chunk-7QPPBBXZ.ts.map +7 -0
- package/dist/chunks/chunk-AEUYS7JC.ts +73 -0
- package/dist/chunks/chunk-AEUYS7JC.ts.map +7 -0
- package/dist/chunks/chunk-BFK2Z4ZF.ts +189 -0
- package/dist/chunks/chunk-BFK2Z4ZF.ts.map +7 -0
- package/dist/chunks/chunk-BOAXY55Y.ts +153 -0
- package/dist/chunks/chunk-BOAXY55Y.ts.map +7 -0
- package/dist/chunks/chunk-C4L6P266.ts +22 -0
- package/dist/chunks/chunk-C4L6P266.ts.map +7 -0
- package/dist/chunks/chunk-DPPVEQAM.ts +29 -0
- package/dist/chunks/chunk-DPPVEQAM.ts.map +7 -0
- package/dist/chunks/chunk-DQMN4OYM.ts +913 -0
- package/dist/chunks/chunk-DQMN4OYM.ts.map +7 -0
- package/dist/chunks/chunk-DSOOH73Y.ts +238 -0
- package/dist/chunks/chunk-DSOOH73Y.ts.map +7 -0
- package/dist/chunks/chunk-EFBPISNT.ts +421 -0
- package/dist/chunks/chunk-EFBPISNT.ts.map +7 -0
- package/dist/chunks/chunk-EWWXFU7N.ts +150 -0
- package/dist/chunks/chunk-EWWXFU7N.ts.map +7 -0
- package/dist/chunks/chunk-F4L2UVSK.ts +380 -0
- package/dist/chunks/chunk-F4L2UVSK.ts.map +7 -0
- package/dist/chunks/chunk-F5YWVHQX.ts +1543 -0
- package/dist/chunks/chunk-F5YWVHQX.ts.map +7 -0
- package/dist/chunks/chunk-G3RSMSXJ.ts +63 -0
- package/dist/chunks/chunk-G3RSMSXJ.ts.map +7 -0
- package/dist/chunks/chunk-G6VZTCFH.ts +70 -0
- package/dist/chunks/chunk-G6VZTCFH.ts.map +7 -0
- package/dist/chunks/chunk-H3FP6DLR.ts +160 -0
- package/dist/chunks/chunk-H3FP6DLR.ts.map +7 -0
- package/dist/chunks/chunk-HA36LPCO.ts +130 -0
- package/dist/chunks/chunk-HA36LPCO.ts.map +7 -0
- package/dist/chunks/chunk-HKC4ES4B.ts +65 -0
- package/dist/chunks/chunk-HKC4ES4B.ts.map +7 -0
- package/dist/chunks/chunk-HOP5FXDT.ts +27 -0
- package/dist/chunks/chunk-HOP5FXDT.ts.map +7 -0
- package/dist/chunks/chunk-I2FAK44T.ts +324 -0
- package/dist/chunks/chunk-I2FAK44T.ts.map +7 -0
- package/dist/chunks/chunk-IGAMVWFN.ts +139 -0
- package/dist/chunks/chunk-IGAMVWFN.ts.map +7 -0
- package/dist/chunks/chunk-KMGKCEO4.ts +38 -0
- package/dist/chunks/chunk-KMGKCEO4.ts.map +7 -0
- package/dist/chunks/chunk-N7BLVXKK.ts +73 -0
- package/dist/chunks/chunk-N7BLVXKK.ts.map +7 -0
- package/dist/chunks/chunk-NIF42QMF.ts +297 -0
- package/dist/chunks/chunk-NIF42QMF.ts.map +7 -0
- package/dist/chunks/chunk-O4VO6JUJ.ts +52 -0
- package/dist/chunks/chunk-O4VO6JUJ.ts.map +7 -0
- package/dist/chunks/chunk-ONDTY4EL.ts +91 -0
- package/dist/chunks/chunk-ONDTY4EL.ts.map +7 -0
- package/dist/chunks/chunk-OVPHFGKO.ts +1769 -0
- package/dist/chunks/chunk-OVPHFGKO.ts.map +7 -0
- package/dist/chunks/chunk-P7OH4XMF.ts +60 -0
- package/dist/chunks/chunk-P7OH4XMF.ts.map +7 -0
- package/dist/chunks/chunk-PSK43Y6A.ts +339 -0
- package/dist/chunks/chunk-PSK43Y6A.ts.map +7 -0
- package/dist/chunks/chunk-QBORTI4W.ts +468 -0
- package/dist/chunks/chunk-QBORTI4W.ts.map +7 -0
- package/dist/chunks/chunk-QDVGH2X7.ts +171 -0
- package/dist/chunks/chunk-QDVGH2X7.ts.map +7 -0
- package/dist/chunks/chunk-RHRQMT7Q.ts +490 -0
- package/dist/chunks/chunk-RHRQMT7Q.ts.map +7 -0
- package/dist/chunks/chunk-RRR66UWR.ts +28 -0
- package/dist/chunks/chunk-RRR66UWR.ts.map +7 -0
- package/dist/chunks/chunk-RSUXZD6S.ts +275 -0
- package/dist/chunks/chunk-RSUXZD6S.ts.map +7 -0
- package/dist/chunks/chunk-RTCVYIZA.ts +221 -0
- package/dist/chunks/chunk-RTCVYIZA.ts.map +7 -0
- package/dist/chunks/chunk-S2IWVK3J.ts +44 -0
- package/dist/chunks/chunk-S2IWVK3J.ts.map +7 -0
- package/dist/chunks/chunk-SCZ33MYW.ts +52 -0
- package/dist/chunks/chunk-SCZ33MYW.ts.map +7 -0
- package/dist/chunks/chunk-SWGQLFSD.ts +60 -0
- package/dist/chunks/chunk-SWGQLFSD.ts.map +7 -0
- package/dist/chunks/chunk-UMBPMVJW.ts +22 -0
- package/dist/chunks/chunk-UMBPMVJW.ts.map +7 -0
- package/dist/chunks/chunk-UVFVHIOP.ts +735 -0
- package/dist/chunks/chunk-UVFVHIOP.ts.map +7 -0
- package/dist/chunks/completion-delivery-YPOWSSV3.ts +16 -0
- package/dist/chunks/completion-delivery-YPOWSSV3.ts.map +7 -0
- package/dist/chunks/config-status-J4GPWP46.ts +34 -0
- package/dist/chunks/config-status-J4GPWP46.ts.map +7 -0
- package/dist/chunks/config-ui-3IBMHTQB.ts +1146 -0
- package/dist/chunks/config-ui-3IBMHTQB.ts.map +7 -0
- package/dist/chunks/consult-NYXVDN5G.ts +518 -0
- package/dist/chunks/consult-NYXVDN5G.ts.map +7 -0
- package/dist/chunks/context-QDKLVQXE.ts +11 -0
- package/dist/chunks/context-QDKLVQXE.ts.map +7 -0
- package/dist/chunks/create-stateful-transport-4WKZHRSI.ts +130 -0
- package/dist/chunks/create-stateful-transport-4WKZHRSI.ts.map +7 -0
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts +17 -0
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +7 -0
- package/dist/chunks/delegation-contract-WJPT4FVS.ts +24 -0
- package/dist/chunks/delegation-contract-WJPT4FVS.ts.map +7 -0
- package/dist/chunks/discovery-K25T3SH4.ts +12 -0
- package/dist/chunks/discovery-K25T3SH4.ts.map +7 -0
- package/dist/chunks/execution-DS2DEIQZ.ts +4034 -0
- package/dist/chunks/execution-DS2DEIQZ.ts.map +7 -0
- package/dist/chunks/in-process-transport-TEYAWSEC.ts +38 -0
- package/dist/chunks/in-process-transport-TEYAWSEC.ts.map +7 -0
- package/dist/chunks/inspect-UOQQ3KNL.ts +619 -0
- package/dist/chunks/inspect-UOQQ3KNL.ts.map +7 -0
- package/dist/chunks/peer-communication-KL36Z6CO.ts +294 -0
- package/dist/chunks/peer-communication-KL36Z6CO.ts.map +7 -0
- package/dist/chunks/persistence-VSGXAW4P.ts +344 -0
- package/dist/chunks/persistence-VSGXAW4P.ts.map +7 -0
- package/dist/chunks/registry-E6XPJB7L.ts +1324 -0
- package/dist/chunks/registry-E6XPJB7L.ts.map +7 -0
- package/dist/chunks/retained-semantic-state-7WXSGRJU.ts +81 -0
- package/dist/chunks/retained-semantic-state-7WXSGRJU.ts.map +7 -0
- package/dist/chunks/rpc-transport-Y6LA5BOP.ts +1154 -0
- package/dist/chunks/rpc-transport-Y6LA5BOP.ts.map +7 -0
- package/dist/chunks/runtime-policy-5YELCOVC.ts +15 -0
- package/dist/chunks/runtime-policy-5YELCOVC.ts.map +7 -0
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +19 -0
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +7 -0
- package/dist/chunks/spawn-idempotency-QGHO2WKC.ts +13 -0
- package/dist/chunks/spawn-idempotency-QGHO2WKC.ts.map +7 -0
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +15 -0
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +7 -0
- package/dist/chunks/subprocess-transport-C2XVR25R.ts +158 -0
- package/dist/chunks/subprocess-transport-C2XVR25R.ts.map +7 -0
- package/dist/chunks/workspace-WDKLN72J.ts +11 -0
- package/dist/chunks/workspace-WDKLN72J.ts.map +7 -0
- package/dist/index.ts +1057 -0
- package/dist/index.ts.map +7 -0
- package/package.json +8 -4
- package/src/index.ts +1 -1
- package/src/settings-reader.ts +208 -0
- package/src/settings.ts +22 -187
- package/src/stateful-registration.ts +1230 -0
- package/src/stateful-safety.ts +1 -1
- package/src/stateful.ts +2 -1234
- package/src/subagents-extension.ts +307 -0
- package/src/subagents.ts +1 -308
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/delegation-contract.ts"],
|
|
4
|
+
"sourcesContent": ["import { StringEnum } from \"@earendil-works/pi-ai\";\nimport { Type } from \"typebox\";\nimport { redactPrivateText } from \"./context.js\";\nimport { DEFAULT_MAX_CONTEXT_BYTES, MAX_SUBAGENT_TIMEOUT_MS, truncateUtf8 } from \"./limits.js\";\n\nexport const DELEGATION_CONTRACT_VERSION = \"pi-subagents:delegation:v2\" as const;\nexport const DELEGATION_CONTRACT_LEVELS = [\"minimal\", \"full\"] as const;\nexport const DELEGATION_ENFORCEMENT_MODES = [\"audit\", \"enforce\"] as const;\nexport const AUTHORITY_REQUIREMENTS = [\"unspecified\", \"denied\", \"required\"] as const;\nexport const DELEGATION_SIDE_EFFECT_POLICIES = [\"read-only\", \"idempotent\", \"mutating\"] as const;\n\nconst MAX_IDENTIFIER_BYTES = 256;\nconst MAX_TEXT_BYTES = 16 * 1024;\nconst MAX_ITEM_BYTES = 4 * 1024;\nconst MAX_ITEMS = 50;\nconst MAX_TURNS_OR_TOOLS = 1_000_000;\n\nconst BoundedString = Type.String({ maxLength: MAX_TEXT_BYTES });\nconst BoundedItem = Type.String({ maxLength: MAX_ITEM_BYTES });\nconst BoundedItems = Type.Array(BoundedItem, { maxItems: MAX_ITEMS });\nconst DependencySchema = Type.Object(\n\t{\n\t\ttaskId: Type.String({ minLength: 1, maxLength: MAX_IDENTIFIER_BYTES }),\n\t\tartifactId: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_IDENTIFIER_BYTES })),\n\t\tversion: Type.Optional(Type.String({ minLength: 1, maxLength: MAX_IDENTIFIER_BYTES })),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport const DelegationContractSchema = Type.Object(\n\t{\n\t\tversion: Type.Literal(DELEGATION_CONTRACT_VERSION),\n\t\tlevel: StringEnum(DELEGATION_CONTRACT_LEVELS),\n\t\ttaskId: Type.String({ minLength: 1, maxLength: MAX_IDENTIFIER_BYTES }),\n\t\tobjective: BoundedString,\n\t\tnonGoals: Type.Optional(BoundedItems),\n\t\tdependencies: Type.Optional(Type.Array(DependencySchema, { maxItems: MAX_ITEMS })),\n\t\trequiredInputs: Type.Optional(BoundedItems),\n\t\trequestedAuthority: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tcapabilities: Type.Optional(BoundedItems),\n\t\t\t\t\ttools: Type.Optional(BoundedItems),\n\t\t\t\t\treadPaths: Type.Optional(BoundedItems),\n\t\t\t\t\twritePaths: Type.Optional(BoundedItems),\n\t\t\t\t\tnetwork: Type.Optional(StringEnum(AUTHORITY_REQUIREMENTS)),\n\t\t\t\t\tsecrets: Type.Optional(StringEnum(AUTHORITY_REQUIREMENTS)),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\tacceptanceCriteria: Type.Optional(BoundedItems),\n\t\trequiredEvidence: Type.Optional(BoundedItems),\n\t\tbudget: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\ttimeoutMs: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_SUBAGENT_TIMEOUT_MS })),\n\t\t\t\t\tmaxTurns: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TURNS_OR_TOOLS })),\n\t\t\t\t\tmaxToolCalls: Type.Optional(Type.Integer({ minimum: 1, maximum: MAX_TURNS_OR_TOOLS })),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\tadmission: Type.Optional(\n\t\t\tType.Object(\n\t\t\t\t{\n\t\t\t\t\tcontextPressure: StringEnum([\"low\", \"medium\", \"high\"] as const),\n\t\t\t\t\tindependentWorkItems: Type.Integer({ minimum: 1, maximum: 2 }),\n\t\t\t\t\tcoupling: StringEnum([\"dense\", \"sparse\"] as const),\n\t\t\t\t\tverificationRequired: Type.Boolean(),\n\t\t\t\t\tverificationAvailable: Type.Boolean(),\n\t\t\t\t\tbudgetAllowsChildren: Type.Boolean(),\n\t\t\t\t\trequirementsComplete: Type.Boolean(),\n\t\t\t\t},\n\t\t\t\t{ additionalProperties: false },\n\t\t\t),\n\t\t),\n\t\tsideEffectPolicy: Type.Optional(StringEnum(DELEGATION_SIDE_EFFECT_POLICIES)),\n\t\tenforcement: Type.Optional(StringEnum(DELEGATION_ENFORCEMENT_MODES)),\n\t},\n\t{ additionalProperties: false },\n);\n\nexport interface DelegationDependency {\n\ttaskId: string;\n\tartifactId?: string;\n\tversion?: string;\n}\n\nexport interface DelegationAuthorityRequest {\n\tcapabilities?: string[];\n\ttools?: string[];\n\treadPaths?: string[];\n\twritePaths?: string[];\n\tnetwork?: (typeof AUTHORITY_REQUIREMENTS)[number];\n\tsecrets?: (typeof AUTHORITY_REQUIREMENTS)[number];\n}\n\nexport interface DelegationBudgetRequest {\n\ttimeoutMs?: number;\n\tmaxTurns?: number;\n\tmaxToolCalls?: number;\n}\n\nexport interface DelegationAdmissionRequest {\n\tcontextPressure: \"low\" | \"medium\" | \"high\";\n\tindependentWorkItems: number;\n\tcoupling: \"dense\" | \"sparse\";\n\tverificationRequired: boolean;\n\tverificationAvailable: boolean;\n\tbudgetAllowsChildren: boolean;\n\trequirementsComplete: boolean;\n}\n\nexport interface DelegationContract {\n\tversion: typeof DELEGATION_CONTRACT_VERSION;\n\tlevel: (typeof DELEGATION_CONTRACT_LEVELS)[number];\n\ttaskId: string;\n\tobjective: string;\n\tnonGoals: string[];\n\tdependencies: DelegationDependency[];\n\trequiredInputs: string[];\n\trequestedAuthority?: DelegationAuthorityRequest;\n\tacceptanceCriteria: string[];\n\trequiredEvidence: string[];\n\tbudget?: DelegationBudgetRequest;\n\tadmission?: DelegationAdmissionRequest;\n\tsideEffectPolicy: (typeof DELEGATION_SIDE_EFFECT_POLICIES)[number];\n\tenforcement: (typeof DELEGATION_ENFORCEMENT_MODES)[number];\n}\n\nexport interface AppendedDelegationContract {\n\ttext: string;\n\tcontract?: DelegationContract;\n\ttruncated: boolean;\n}\n\nexport function normalizeDelegationContract(value: unknown): DelegationContract | undefined {\n\tif (!isPlainObject(value)) return undefined;\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"version\",\n\t\t\t\"level\",\n\t\t\t\"taskId\",\n\t\t\t\"objective\",\n\t\t\t\"nonGoals\",\n\t\t\t\"dependencies\",\n\t\t\t\"requiredInputs\",\n\t\t\t\"requestedAuthority\",\n\t\t\t\"acceptanceCriteria\",\n\t\t\t\"requiredEvidence\",\n\t\t\t\"budget\",\n\t\t\t\"admission\",\n\t\t\t\"sideEffectPolicy\",\n\t\t\t\"enforcement\",\n\t\t])\n\t) {\n\t\treturn undefined;\n\t}\n\tif (\n\t\tvalue.version !== DELEGATION_CONTRACT_VERSION ||\n\t\ttypeof value.level !== \"string\" ||\n\t\t!DELEGATION_CONTRACT_LEVELS.includes(\n\t\t\tvalue.level as (typeof DELEGATION_CONTRACT_LEVELS)[number],\n\t\t) ||\n\t\ttypeof value.taskId !== \"string\" ||\n\t\t!value.taskId.trim() ||\n\t\ttypeof value.objective !== \"string\"\n\t) {\n\t\treturn undefined;\n\t}\n\tconst taskId = bounded(value.taskId, MAX_IDENTIFIER_BYTES);\n\tconst objective = bounded(value.objective, MAX_TEXT_BYTES);\n\tif (!taskId || !objective) return undefined;\n\tconst nonGoals = normalizeStrings(value.nonGoals);\n\tconst requiredInputs = normalizeStrings(value.requiredInputs);\n\tconst acceptanceCriteria = normalizeStrings(value.acceptanceCriteria);\n\tconst requiredEvidence = normalizeStrings(value.requiredEvidence);\n\tif (!nonGoals || !requiredInputs || !acceptanceCriteria || !requiredEvidence) return undefined;\n\tconst dependencies = normalizeDependencies(value.dependencies);\n\tif (!dependencies) return undefined;\n\tconst authority = normalizeAuthority(value.requestedAuthority);\n\tif (authority === false) return undefined;\n\tconst budget = normalizeBudget(value.budget);\n\tif (budget === false) return undefined;\n\tconst admission = normalizeAdmission(value.admission);\n\tif (admission === false) return undefined;\n\tconst sideEffectPolicy = value.sideEffectPolicy ?? \"mutating\";\n\tif (\n\t\ttypeof sideEffectPolicy !== \"string\" ||\n\t\t!DELEGATION_SIDE_EFFECT_POLICIES.includes(\n\t\t\tsideEffectPolicy as (typeof DELEGATION_SIDE_EFFECT_POLICIES)[number],\n\t\t)\n\t) {\n\t\treturn undefined;\n\t}\n\tconst enforcement = value.enforcement ?? \"audit\";\n\tif (\n\t\ttypeof enforcement !== \"string\" ||\n\t\t!DELEGATION_ENFORCEMENT_MODES.includes(\n\t\t\tenforcement as (typeof DELEGATION_ENFORCEMENT_MODES)[number],\n\t\t)\n\t) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tversion: DELEGATION_CONTRACT_VERSION,\n\t\tlevel: value.level as DelegationContract[\"level\"],\n\t\ttaskId,\n\t\tobjective,\n\t\tnonGoals,\n\t\tdependencies,\n\t\trequiredInputs,\n\t\t...(authority === undefined ? {} : { requestedAuthority: authority }),\n\t\tacceptanceCriteria,\n\t\trequiredEvidence,\n\t\t...(budget === undefined ? {} : { budget }),\n\t\t...(admission === undefined ? {} : { admission }),\n\t\tsideEffectPolicy: sideEffectPolicy as DelegationContract[\"sideEffectPolicy\"],\n\t\tenforcement: enforcement as DelegationContract[\"enforcement\"],\n\t};\n}\n\nexport function appendDelegationContract(\n\tprompt: string,\n\tvalue: unknown,\n\tmaxBytes = DEFAULT_MAX_CONTEXT_BYTES,\n): AppendedDelegationContract {\n\tconst contract = normalizeDelegationContract(value);\n\tif (!contract) return { text: prompt, truncated: false };\n\tconst suffix = [\n\t\t\"\",\n\t\t\"Delegation contract:\",\n\t\tJSON.stringify(contract),\n\t\t\"The requested authority is advisory until an executor-owned ExecutionPlan confirms which controls are enforceable and effective.\",\n\t\t\"Acknowledge missing inputs, authority, capabilities, or verification instead of guessing.\",\n\t].join(\"\\n\");\n\tconst suffixBytes = Buffer.byteLength(suffix, \"utf8\");\n\tconst boundedPrompt = truncateUtf8(\n\t\tredactPrivateText(prompt),\n\t\tMath.max(0, maxBytes - suffixBytes),\n\t);\n\tconst text = truncateUtf8(`${boundedPrompt.text}${suffix}`, maxBytes);\n\treturn {\n\t\ttext: text.text,\n\t\tcontract,\n\t\ttruncated: boundedPrompt.truncated || text.truncated,\n\t};\n}\n\nfunction normalizeAdmission(value: unknown): DelegationAdmissionRequest | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (!isPlainObject(value)) return false;\n\tif (\n\t\t!hasOnlyKeys(value, [\n\t\t\t\"contextPressure\",\n\t\t\t\"independentWorkItems\",\n\t\t\t\"coupling\",\n\t\t\t\"verificationRequired\",\n\t\t\t\"verificationAvailable\",\n\t\t\t\"budgetAllowsChildren\",\n\t\t\t\"requirementsComplete\",\n\t\t]) ||\n\t\t![\"low\", \"medium\", \"high\"].includes(String(value.contextPressure)) ||\n\t\t!Number.isSafeInteger(value.independentWorkItems) ||\n\t\tNumber(value.independentWorkItems) < 1 ||\n\t\tNumber(value.independentWorkItems) > 2 ||\n\t\t![\"dense\", \"sparse\"].includes(String(value.coupling)) ||\n\t\ttypeof value.verificationRequired !== \"boolean\" ||\n\t\ttypeof value.verificationAvailable !== \"boolean\" ||\n\t\ttypeof value.budgetAllowsChildren !== \"boolean\" ||\n\t\ttypeof value.requirementsComplete !== \"boolean\"\n\t) {\n\t\treturn false;\n\t}\n\treturn {\n\t\tcontextPressure: value.contextPressure as DelegationAdmissionRequest[\"contextPressure\"],\n\t\tindependentWorkItems: Number(value.independentWorkItems),\n\t\tcoupling: value.coupling as DelegationAdmissionRequest[\"coupling\"],\n\t\tverificationRequired: value.verificationRequired,\n\t\tverificationAvailable: value.verificationAvailable,\n\t\tbudgetAllowsChildren: value.budgetAllowsChildren,\n\t\trequirementsComplete: value.requirementsComplete,\n\t};\n}\n\nfunction normalizeDependencies(value: unknown): DelegationDependency[] | undefined {\n\tif (value === undefined) return [];\n\tif (!Array.isArray(value) || value.length > MAX_ITEMS) return undefined;\n\tconst result: DelegationDependency[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of value) {\n\t\tif (\n\t\t\t!isPlainObject(item) ||\n\t\t\t!hasOnlyKeys(item, [\"taskId\", \"artifactId\", \"version\"]) ||\n\t\t\ttypeof item.taskId !== \"string\"\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst taskId = bounded(item.taskId, MAX_IDENTIFIER_BYTES);\n\t\tif (!taskId || seen.has(taskId)) return undefined;\n\t\tseen.add(taskId);\n\t\tconst artifactId = optionalString(item.artifactId, MAX_IDENTIFIER_BYTES);\n\t\tconst version = optionalString(item.version, MAX_IDENTIFIER_BYTES);\n\t\tif (artifactId === false || version === false) return undefined;\n\t\tresult.push({\n\t\t\ttaskId,\n\t\t\t...(artifactId === undefined ? {} : { artifactId }),\n\t\t\t...(version === undefined ? {} : { version }),\n\t\t});\n\t}\n\treturn result;\n}\n\nfunction normalizeAuthority(value: unknown): DelegationAuthorityRequest | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (!isPlainObject(value)) return false;\n\tif (\n\t\t!hasOnlyKeys(value, [\"capabilities\", \"tools\", \"readPaths\", \"writePaths\", \"network\", \"secrets\"])\n\t) {\n\t\treturn false;\n\t}\n\tconst capabilities = normalizeOptionalStrings(value.capabilities);\n\tconst tools = normalizeOptionalStrings(value.tools);\n\tconst readPaths = normalizeOptionalStrings(value.readPaths);\n\tconst writePaths = normalizeOptionalStrings(value.writePaths);\n\tif (capabilities === false || tools === false || readPaths === false || writePaths === false) {\n\t\treturn false;\n\t}\n\tconst network = normalizeAuthorityRequirement(value.network);\n\tconst secrets = normalizeAuthorityRequirement(value.secrets);\n\tif (network === false || secrets === false) return false;\n\treturn {\n\t\t...(capabilities === undefined ? {} : { capabilities }),\n\t\t...(tools === undefined ? {} : { tools }),\n\t\t...(readPaths === undefined ? {} : { readPaths }),\n\t\t...(writePaths === undefined ? {} : { writePaths }),\n\t\t...(network === undefined ? {} : { network }),\n\t\t...(secrets === undefined ? {} : { secrets }),\n\t};\n}\n\nfunction normalizeBudget(value: unknown): DelegationBudgetRequest | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (!isPlainObject(value) || !hasOnlyKeys(value, [\"timeoutMs\", \"maxTurns\", \"maxToolCalls\"])) {\n\t\treturn false;\n\t}\n\tconst timeoutMs = optionalInteger(value.timeoutMs, MAX_SUBAGENT_TIMEOUT_MS);\n\tconst maxTurns = optionalInteger(value.maxTurns, MAX_TURNS_OR_TOOLS);\n\tconst maxToolCalls = optionalInteger(value.maxToolCalls, MAX_TURNS_OR_TOOLS);\n\tif (timeoutMs === false || maxTurns === false || maxToolCalls === false) return false;\n\treturn {\n\t\t...(timeoutMs === undefined ? {} : { timeoutMs }),\n\t\t...(maxTurns === undefined ? {} : { maxTurns }),\n\t\t...(maxToolCalls === undefined ? {} : { maxToolCalls }),\n\t};\n}\n\nfunction normalizeStrings(value: unknown): string[] | undefined {\n\tif (value === undefined) return [];\n\tconst normalized = normalizeOptionalStrings(value);\n\treturn normalized === false ? undefined : normalized;\n}\n\nfunction normalizeOptionalStrings(value: unknown): string[] | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (!Array.isArray(value) || value.length > MAX_ITEMS) return false;\n\tconst result: string[] = [];\n\tconst seen = new Set<string>();\n\tfor (const item of value) {\n\t\tif (typeof item !== \"string\") return false;\n\t\tconst normalized = bounded(item, MAX_ITEM_BYTES);\n\t\tif (!normalized || seen.has(normalized)) continue;\n\t\tseen.add(normalized);\n\t\tresult.push(normalized);\n\t}\n\treturn result;\n}\n\nfunction normalizeAuthorityRequirement(\n\tvalue: unknown,\n): (typeof AUTHORITY_REQUIREMENTS)[number] | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (\n\t\ttypeof value !== \"string\" ||\n\t\t!AUTHORITY_REQUIREMENTS.includes(value as (typeof AUTHORITY_REQUIREMENTS)[number])\n\t) {\n\t\treturn false;\n\t}\n\treturn value as (typeof AUTHORITY_REQUIREMENTS)[number];\n}\n\nfunction optionalString(value: unknown, maxBytes: number): string | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (typeof value !== \"string\") return false;\n\tconst normalized = bounded(value, maxBytes);\n\treturn normalized || false;\n}\n\nfunction optionalInteger(value: unknown, max: number): number | undefined | false {\n\tif (value === undefined) return undefined;\n\tif (!Number.isSafeInteger(value) || (value as number) < 1 || (value as number) > max)\n\t\treturn false;\n\treturn value as number;\n}\n\nfunction bounded(value: string, maxBytes: number): string {\n\treturn truncateUtf8(redactPrivateText(value), maxBytes).text.trim();\n}\n\nfunction hasOnlyKeys(value: Record<string, unknown>, allowed: readonly string[]): boolean {\n\treturn Object.keys(value).every((key) => allowed.includes(key));\n}\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n\treturn Boolean(value) && typeof value === \"object\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AA,EACvB;AACA,SAAO;AACR;AAEA,SAAS,8BACR,OAC8D;AAC9D,MAAI,UAAU,OAAW,QAAO;AAChC,MACC,OAAO,UAAU,YACjB,CAAC,uBAAuB,SAAS,KAAgD,GAChF;AACD,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAEA,SAAS,eAAe,OAAgB,UAA8C;AACrF,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,aAAa,QAAQ,OAAO,QAAQ;AAC1C,SAAO,cAAc;AACtB;AAEA,SAAS,gBAAgB,OAAgB,KAAyC;AACjF,MAAI,UAAU,OAAW,QAAO;AAChC,MAAI,CAAC,OAAO,cAAc,KAAK,KAAM,QAAmB,KAAM,QAAmB;AAChF,WAAO;AACR,SAAO;AACR;AAEA,SAAS,QAAQ,OAAe,UAA0B;AACzD,SAAO,aAAa,kBAAkB,KAAK,GAAG,QAAQ,EAAE,KAAK,KAAK;AACnE;AAEA,SAAS,YAAY,OAAgC,SAAqC;AACzF,SAAO,OAAO,KAAK,KAAK,EAAE,MAAM,CAAC,QAAQ,QAAQ,SAAS,GAAG,CAAC;AAC/D;AAEA,SAAS,cAAc,OAAkD;AACxE,SAAO,QAAQ,KAAK,KAAK,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK;AAC3E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/pi-invocation.ts
|
|
5
|
+
import * as fs from "node:fs";
|
|
6
|
+
import * as path from "node:path";
|
|
7
|
+
import { getPackageDir } from "@earendil-works/pi-coding-agent";
|
|
8
|
+
var CORE_PACKAGE_NAME = "@earendil-works/pi-coding-agent";
|
|
9
|
+
var MAX_DISPLAY_PATH_LENGTH = 500;
|
|
10
|
+
var PiInvocationError = class extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "PiInvocationError";
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function displayPath(value) {
|
|
17
|
+
const suffix = value.length > MAX_DISPLAY_PATH_LENGTH ? "\u2026" : "";
|
|
18
|
+
return JSON.stringify(`${value.slice(0, MAX_DISPLAY_PATH_LENGTH)}${suffix}`);
|
|
19
|
+
}
|
|
20
|
+
function resolutionError(packageDir, reason) {
|
|
21
|
+
return new PiInvocationError(
|
|
22
|
+
`Unable to resolve the Pi CLI from the loaded ${CORE_PACKAGE_NAME} package at ${displayPath(packageDir)}: ${reason}. Reinstall the matching Pi core package before using the subprocess transport.`
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
function currentRuntime() {
|
|
26
|
+
let packageDir;
|
|
27
|
+
try {
|
|
28
|
+
packageDir = getPackageDir();
|
|
29
|
+
} catch {
|
|
30
|
+
throw resolutionError("<unavailable>", "Pi core did not provide its package directory");
|
|
31
|
+
}
|
|
32
|
+
const runtimeKind = process.versions.bun ? "bun" : process.release.name === "node" && !process.versions.electron ? "node" : "unsupported";
|
|
33
|
+
return {
|
|
34
|
+
execPath: process.execPath,
|
|
35
|
+
packageDir,
|
|
36
|
+
runtimeKind
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function isRecord(value) {
|
|
40
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
41
|
+
}
|
|
42
|
+
function isWithinDirectory(parent, candidate) {
|
|
43
|
+
const relative2 = path.relative(parent, candidate);
|
|
44
|
+
return relative2 === "" || !relative2.startsWith(`..${path.sep}`) && relative2 !== ".." && !path.isAbsolute(relative2);
|
|
45
|
+
}
|
|
46
|
+
function readCoreManifest(packageDir) {
|
|
47
|
+
const manifestPath = path.join(packageDir, "package.json");
|
|
48
|
+
let source;
|
|
49
|
+
try {
|
|
50
|
+
source = fs.readFileSync(manifestPath, "utf8");
|
|
51
|
+
} catch {
|
|
52
|
+
throw resolutionError(packageDir, "the package manifest is unavailable");
|
|
53
|
+
}
|
|
54
|
+
let manifest;
|
|
55
|
+
try {
|
|
56
|
+
manifest = JSON.parse(source);
|
|
57
|
+
} catch {
|
|
58
|
+
throw resolutionError(packageDir, "the package manifest is invalid JSON");
|
|
59
|
+
}
|
|
60
|
+
if (!isRecord(manifest)) {
|
|
61
|
+
throw resolutionError(packageDir, "the package manifest is invalid");
|
|
62
|
+
}
|
|
63
|
+
if (manifest.name !== CORE_PACKAGE_NAME) {
|
|
64
|
+
throw resolutionError(packageDir, "the package manifest has an unexpected package name");
|
|
65
|
+
}
|
|
66
|
+
return manifest;
|
|
67
|
+
}
|
|
68
|
+
function resolveDeclaredBin(packageDir, manifest) {
|
|
69
|
+
const bin = manifest.bin;
|
|
70
|
+
const piBin = isRecord(bin) ? bin.pi : void 0;
|
|
71
|
+
if (typeof piBin !== "string" || !piBin.trim()) {
|
|
72
|
+
throw resolutionError(packageDir, "package.json bin.pi must be a non-empty string");
|
|
73
|
+
}
|
|
74
|
+
const candidate = path.resolve(packageDir, piBin);
|
|
75
|
+
if (path.isAbsolute(piBin) || !isWithinDirectory(packageDir, candidate)) {
|
|
76
|
+
throw resolutionError(packageDir, "the declared bin.pi target escapes the package directory");
|
|
77
|
+
}
|
|
78
|
+
return candidate;
|
|
79
|
+
}
|
|
80
|
+
function resolveExistingFile(packageDir, candidate, reason) {
|
|
81
|
+
let resolved;
|
|
82
|
+
try {
|
|
83
|
+
resolved = fs.realpathSync(candidate);
|
|
84
|
+
if (!fs.statSync(resolved).isFile()) throw new Error("not a file");
|
|
85
|
+
} catch {
|
|
86
|
+
throw resolutionError(packageDir, reason);
|
|
87
|
+
}
|
|
88
|
+
if (!isWithinDirectory(packageDir, resolved)) {
|
|
89
|
+
throw resolutionError(packageDir, "the declared bin.pi target escapes the package directory");
|
|
90
|
+
}
|
|
91
|
+
return resolved;
|
|
92
|
+
}
|
|
93
|
+
function resolveStandaloneExecutable(packageDir, runtime) {
|
|
94
|
+
if (runtime.runtimeKind !== "bun") return void 0;
|
|
95
|
+
const { execPath } = runtime;
|
|
96
|
+
if (!/^pi(?:\.exe)?$/i.test(path.basename(execPath))) return void 0;
|
|
97
|
+
let resolved;
|
|
98
|
+
let mode;
|
|
99
|
+
try {
|
|
100
|
+
resolved = fs.realpathSync(execPath);
|
|
101
|
+
const stat = fs.statSync(resolved);
|
|
102
|
+
if (!stat.isFile()) throw new Error("not a file");
|
|
103
|
+
mode = stat.mode;
|
|
104
|
+
} catch {
|
|
105
|
+
throw resolutionError(packageDir, "the standalone Pi executable is unavailable");
|
|
106
|
+
}
|
|
107
|
+
if (path.dirname(resolved) !== packageDir) return void 0;
|
|
108
|
+
if (process.platform !== "win32" && (mode & 73) === 0) {
|
|
109
|
+
throw resolutionError(packageDir, "the standalone Pi executable is not executable");
|
|
110
|
+
}
|
|
111
|
+
return resolved;
|
|
112
|
+
}
|
|
113
|
+
function resolvePiInvocation(args, runtime = currentRuntime()) {
|
|
114
|
+
let packageDir;
|
|
115
|
+
try {
|
|
116
|
+
packageDir = fs.realpathSync(runtime.packageDir);
|
|
117
|
+
if (!fs.statSync(packageDir).isDirectory()) throw new Error("not a directory");
|
|
118
|
+
} catch {
|
|
119
|
+
throw resolutionError(runtime.packageDir, "the package directory is unavailable");
|
|
120
|
+
}
|
|
121
|
+
const manifest = readCoreManifest(packageDir);
|
|
122
|
+
const declaredBin = resolveDeclaredBin(packageDir, manifest);
|
|
123
|
+
const standalone = resolveStandaloneExecutable(packageDir, runtime);
|
|
124
|
+
if (standalone) return { command: standalone, args: [...args] };
|
|
125
|
+
if (runtime.runtimeKind !== "node" && runtime.runtimeKind !== "bun") {
|
|
126
|
+
throw resolutionError(packageDir, "the host does not provide a supported Node or Bun runtime");
|
|
127
|
+
}
|
|
128
|
+
const cliPath = resolveExistingFile(
|
|
129
|
+
packageDir,
|
|
130
|
+
declaredBin,
|
|
131
|
+
"the declared bin.pi target is unavailable"
|
|
132
|
+
);
|
|
133
|
+
return { command: runtime.execPath, args: [cliPath, ...args] };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export {
|
|
137
|
+
resolvePiInvocation
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=chunk-IGAMVWFN.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pi-invocation.ts"],
|
|
4
|
+
"sourcesContent": ["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { getPackageDir } from \"@earendil-works/pi-coding-agent\";\n\nconst CORE_PACKAGE_NAME = \"@earendil-works/pi-coding-agent\";\nconst MAX_DISPLAY_PATH_LENGTH = 500;\n\nexport interface PiInvocation {\n\tcommand: string;\n\targs: string[];\n}\n\nexport interface PiInvocationRuntime {\n\texecPath: string;\n\tpackageDir: string;\n\truntimeKind: \"node\" | \"bun\" | \"unsupported\";\n}\n\nexport class PiInvocationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"PiInvocationError\";\n\t}\n}\n\nfunction displayPath(value: string): string {\n\tconst suffix = value.length > MAX_DISPLAY_PATH_LENGTH ? \"\u2026\" : \"\";\n\treturn JSON.stringify(`${value.slice(0, MAX_DISPLAY_PATH_LENGTH)}${suffix}`);\n}\n\nfunction resolutionError(packageDir: string, reason: string): PiInvocationError {\n\treturn new PiInvocationError(\n\t\t`Unable to resolve the Pi CLI from the loaded ${CORE_PACKAGE_NAME} package at ${displayPath(packageDir)}: ${reason}. Reinstall the matching Pi core package before using the subprocess transport.`,\n\t);\n}\n\nfunction currentRuntime(): PiInvocationRuntime {\n\tlet packageDir: string;\n\ttry {\n\t\tpackageDir = getPackageDir();\n\t} catch {\n\t\tthrow resolutionError(\"<unavailable>\", \"Pi core did not provide its package directory\");\n\t}\n\tconst runtimeKind = process.versions.bun\n\t\t? \"bun\"\n\t\t: process.release.name === \"node\" && !process.versions.electron\n\t\t\t? \"node\"\n\t\t\t: \"unsupported\";\n\treturn {\n\t\texecPath: process.execPath,\n\t\tpackageDir,\n\t\truntimeKind,\n\t};\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isWithinDirectory(parent: string, candidate: string): boolean {\n\tconst relative = path.relative(parent, candidate);\n\treturn (\n\t\trelative === \"\" ||\n\t\t(!relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative))\n\t);\n}\n\nfunction readCoreManifest(packageDir: string): Record<string, unknown> {\n\tconst manifestPath = path.join(packageDir, \"package.json\");\n\tlet source: string;\n\ttry {\n\t\tsource = fs.readFileSync(manifestPath, \"utf8\");\n\t} catch {\n\t\tthrow resolutionError(packageDir, \"the package manifest is unavailable\");\n\t}\n\tlet manifest: unknown;\n\ttry {\n\t\tmanifest = JSON.parse(source);\n\t} catch {\n\t\tthrow resolutionError(packageDir, \"the package manifest is invalid JSON\");\n\t}\n\tif (!isRecord(manifest)) {\n\t\tthrow resolutionError(packageDir, \"the package manifest is invalid\");\n\t}\n\tif (manifest.name !== CORE_PACKAGE_NAME) {\n\t\tthrow resolutionError(packageDir, \"the package manifest has an unexpected package name\");\n\t}\n\treturn manifest;\n}\n\nfunction resolveDeclaredBin(packageDir: string, manifest: Record<string, unknown>): string {\n\tconst bin = manifest.bin;\n\tconst piBin = isRecord(bin) ? bin.pi : undefined;\n\tif (typeof piBin !== \"string\" || !piBin.trim()) {\n\t\tthrow resolutionError(packageDir, \"package.json bin.pi must be a non-empty string\");\n\t}\n\tconst candidate = path.resolve(packageDir, piBin);\n\tif (path.isAbsolute(piBin) || !isWithinDirectory(packageDir, candidate)) {\n\t\tthrow resolutionError(packageDir, \"the declared bin.pi target escapes the package directory\");\n\t}\n\treturn candidate;\n}\n\nfunction resolveExistingFile(packageDir: string, candidate: string, reason: string): string {\n\tlet resolved: string;\n\ttry {\n\t\tresolved = fs.realpathSync(candidate);\n\t\tif (!fs.statSync(resolved).isFile()) throw new Error(\"not a file\");\n\t} catch {\n\t\tthrow resolutionError(packageDir, reason);\n\t}\n\tif (!isWithinDirectory(packageDir, resolved)) {\n\t\tthrow resolutionError(packageDir, \"the declared bin.pi target escapes the package directory\");\n\t}\n\treturn resolved;\n}\n\nfunction resolveStandaloneExecutable(\n\tpackageDir: string,\n\truntime: PiInvocationRuntime,\n): string | undefined {\n\tif (runtime.runtimeKind !== \"bun\") return undefined;\n\tconst { execPath } = runtime;\n\tif (!/^pi(?:\\.exe)?$/i.test(path.basename(execPath))) return undefined;\n\tlet resolved: string;\n\tlet mode: number;\n\ttry {\n\t\tresolved = fs.realpathSync(execPath);\n\t\tconst stat = fs.statSync(resolved);\n\t\tif (!stat.isFile()) throw new Error(\"not a file\");\n\t\tmode = stat.mode;\n\t} catch {\n\t\tthrow resolutionError(packageDir, \"the standalone Pi executable is unavailable\");\n\t}\n\tif (path.dirname(resolved) !== packageDir) return undefined;\n\tif (process.platform !== \"win32\" && (mode & 0o111) === 0) {\n\t\tthrow resolutionError(packageDir, \"the standalone Pi executable is not executable\");\n\t}\n\treturn resolved;\n}\n\nexport function resolvePiInvocation(\n\targs: string[],\n\truntime: PiInvocationRuntime = currentRuntime(),\n): PiInvocation {\n\tlet packageDir: string;\n\ttry {\n\t\tpackageDir = fs.realpathSync(runtime.packageDir);\n\t\tif (!fs.statSync(packageDir).isDirectory()) throw new Error(\"not a directory\");\n\t} catch {\n\t\tthrow resolutionError(runtime.packageDir, \"the package directory is unavailable\");\n\t}\n\n\tconst manifest = readCoreManifest(packageDir);\n\tconst declaredBin = resolveDeclaredBin(packageDir, manifest);\n\tconst standalone = resolveStandaloneExecutable(packageDir, runtime);\n\tif (standalone) return { command: standalone, args: [...args] };\n\n\tif (runtime.runtimeKind !== \"node\" && runtime.runtimeKind !== \"bun\") {\n\t\tthrow resolutionError(packageDir, \"the host does not provide a supported Node or Bun runtime\");\n\t}\n\tconst cliPath = resolveExistingFile(\n\t\tpackageDir,\n\t\tdeclaredBin,\n\t\t\"the declared bin.pi target is unavailable\",\n\t);\n\treturn { command: runtime.execPath, args: [cliPath, ...args] };\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,qBAAqB;AAE9B,IAAM,oBAAoB;AAC1B,IAAM,0BAA0B;AAazB,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAC5C,YAAY,SAAiB;AAC5B,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACb;AACD;AAEA,SAAS,YAAY,OAAuB;AAC3C,QAAM,SAAS,MAAM,SAAS,0BAA0B,WAAM;AAC9D,SAAO,KAAK,UAAU,GAAG,MAAM,MAAM,GAAG,uBAAuB,CAAC,GAAG,MAAM,EAAE;AAC5E;AAEA,SAAS,gBAAgB,YAAoB,QAAmC;AAC/E,SAAO,IAAI;AAAA,IACV,gDAAgD,iBAAiB,eAAe,YAAY,UAAU,CAAC,KAAK,MAAM;AAAA,EACnH;AACD;AAEA,SAAS,iBAAsC;AAC9C,MAAI;AACJ,MAAI;AACH,iBAAa,cAAc;AAAA,EAC5B,QAAQ;AACP,UAAM,gBAAgB,iBAAiB,+CAA+C;AAAA,EACvF;AACA,QAAM,cAAc,QAAQ,SAAS,MAClC,QACA,QAAQ,QAAQ,SAAS,UAAU,CAAC,QAAQ,SAAS,WACpD,SACA;AACJ,SAAO;AAAA,IACN,UAAU,QAAQ;AAAA,IAClB;AAAA,IACA;AAAA,EACD;AACD;AAEA,SAAS,SAAS,OAAkD;AACnE,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E;AAEA,SAAS,kBAAkB,QAAgB,WAA4B;AACtE,QAAMA,YAAgB,cAAS,QAAQ,SAAS;AAChD,SACCA,cAAa,MACZ,CAACA,UAAS,WAAW,KAAU,QAAG,EAAE,KAAKA,cAAa,QAAQ,CAAM,gBAAWA,SAAQ;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
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/agent-projection.ts
|
|
5
|
+
function projectAgentRecords(agents, limits) {
|
|
6
|
+
const byId = new Map(agents.map((agent) => [agent.id, agent]));
|
|
7
|
+
const selected = /* @__PURE__ */ new Set();
|
|
8
|
+
const maxDepth = limits.maxDepth ?? Number.MAX_SAFE_INTEGER;
|
|
9
|
+
const newestFirst = agents.map((agent, index) => ({ agent, index })).sort(
|
|
10
|
+
(left, right) => right.agent.updatedAt - left.agent.updatedAt || right.index - left.index
|
|
11
|
+
);
|
|
12
|
+
for (const { agent } of newestFirst) {
|
|
13
|
+
const chain = ancestorChain(agent, byId);
|
|
14
|
+
if (!chain || chain.length - 1 > maxDepth) continue;
|
|
15
|
+
const missing = chain.filter((candidate) => !selected.has(candidate.id));
|
|
16
|
+
if (selected.size + missing.length > limits.maxAgents) continue;
|
|
17
|
+
for (const candidate of missing) selected.add(candidate.id);
|
|
18
|
+
}
|
|
19
|
+
return agents.filter((agent) => selected.has(agent.id));
|
|
20
|
+
}
|
|
21
|
+
function ancestorChain(agent, byId) {
|
|
22
|
+
const chain = [];
|
|
23
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24
|
+
let current = agent;
|
|
25
|
+
while (current) {
|
|
26
|
+
if (seen.has(current.id)) return void 0;
|
|
27
|
+
seen.add(current.id);
|
|
28
|
+
chain.unshift(current);
|
|
29
|
+
if (!current.parentId) return chain;
|
|
30
|
+
current = byId.get(current.parentId);
|
|
31
|
+
}
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
projectAgentRecords
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=chunk-KMGKCEO4.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/agent-projection.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ManagedAgent } from \"./registry.js\";\n\nexport interface AgentProjectionLimits {\n\tmaxAgents: number;\n\tmaxDepth?: number;\n}\n\n/**\n * Select the newest restorable agent trees without orphaning child records.\n *\n * Complete ancestor chains are selected together, then returned in their original\n * order so persistence and restore behavior stay deterministic.\n */\nexport function projectAgentRecords(\n\tagents: readonly ManagedAgent[],\n\tlimits: AgentProjectionLimits,\n): ManagedAgent[] {\n\tconst byId = new Map(agents.map((agent) => [agent.id, agent]));\n\tconst selected = new Set<string>();\n\tconst maxDepth = limits.maxDepth ?? Number.MAX_SAFE_INTEGER;\n\tconst newestFirst = agents\n\t\t.map((agent, index) => ({ agent, index }))\n\t\t.sort(\n\t\t\t(left, right) => right.agent.updatedAt - left.agent.updatedAt || right.index - left.index,\n\t\t);\n\n\tfor (const { agent } of newestFirst) {\n\t\tconst chain = ancestorChain(agent, byId);\n\t\tif (!chain || chain.length - 1 > maxDepth) continue;\n\t\tconst missing = chain.filter((candidate) => !selected.has(candidate.id));\n\t\tif (selected.size + missing.length > limits.maxAgents) continue;\n\t\tfor (const candidate of missing) selected.add(candidate.id);\n\t}\n\n\treturn agents.filter((agent) => selected.has(agent.id));\n}\n\nfunction ancestorChain(\n\tagent: ManagedAgent,\n\tbyId: ReadonlyMap<string, ManagedAgent>,\n): ManagedAgent[] | undefined {\n\tconst chain: ManagedAgent[] = [];\n\tconst seen = new Set<string>();\n\tlet current: ManagedAgent | undefined = agent;\n\twhile (current) {\n\t\tif (seen.has(current.id)) return undefined;\n\t\tseen.add(current.id);\n\t\tchain.unshift(current);\n\t\tif (!current.parentId) return chain;\n\t\tcurrent = byId.get(current.parentId);\n\t}\n\treturn undefined;\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAaO,SAAS,oBACf,QACA,QACiB;AACjB,QAAM,OAAO,IAAI,IAAI,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;AAC7D,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,WAAW,OAAO,YAAY,OAAO;AAC3C,QAAM,cAAc,OAClB,IAAI,CAAC,OAAO,WAAW,EAAE,OAAO,MAAM,EAAE,EACxC;AAAA,IACA,CAAC,MAAM,UAAU,MAAM,MAAM,YAAY,KAAK,MAAM,aAAa,MAAM,QAAQ,KAAK;AAAA,EACrF;AAED,aAAW,EAAE,MAAM,KAAK,aAAa;AACpC,UAAM,QAAQ,cAAc,OAAO,IAAI;AACvC,QAAI,CAAC,SAAS,MAAM,SAAS,IAAI,SAAU;AAC3C,UAAM,UAAU,MAAM,OAAO,CAAC,cAAc,CAAC,SAAS,IAAI,UAAU,EAAE,CAAC;AACvE,QAAI,SAAS,OAAO,QAAQ,SAAS,OAAO,UAAW;AACvD,eAAW,aAAa,QAAS,UAAS,IAAI,UAAU,EAAE;AAAA,EAC3D;AAEA,SAAO,OAAO,OAAO,CAAC,UAAU,SAAS,IAAI,MAAM,EAAE,CAAC;AACvD;AAEA,SAAS,cACR,OACA,MAC6B;AAC7B,QAAM,QAAwB,CAAC;AAC/B,QAAM,OAAO,oBAAI,IAAY;AAC7B,MAAI,UAAoC;AACxC,SAAO,SAAS;AACf,QAAI,KAAK,IAAI,QAAQ,EAAE,EAAG,QAAO;AACjC,SAAK,IAAI,QAAQ,EAAE;AACnB,UAAM,QAAQ,OAAO;AACrB,QAAI,CAAC,QAAQ,SAAU,QAAO;AAC9B,cAAU,KAAK,IAAI,QAAQ,QAAQ;AAAA,EACpC;AACA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/task-path.ts
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
var ROOT_TASK_PATH = "/root";
|
|
7
|
+
var MAX_TASK_NAME_LENGTH = 128;
|
|
8
|
+
var MAX_TASK_PATH_LENGTH = 2048;
|
|
9
|
+
var TASK_NAME_PATTERN = /^[a-z0-9_]+$/u;
|
|
10
|
+
function validateTaskName(value) {
|
|
11
|
+
if (!value) throw new Error("Subagent taskName must not be empty");
|
|
12
|
+
if (value === "root" || value === "." || value === "..") {
|
|
13
|
+
throw new Error(`Subagent taskName ${JSON.stringify(value)} is reserved`);
|
|
14
|
+
}
|
|
15
|
+
if (value.length > MAX_TASK_NAME_LENGTH) {
|
|
16
|
+
throw new Error(`Subagent taskName cannot exceed ${MAX_TASK_NAME_LENGTH} characters`);
|
|
17
|
+
}
|
|
18
|
+
if (value.includes("/")) throw new Error("Subagent taskName must not contain `/`");
|
|
19
|
+
if (!TASK_NAME_PATTERN.test(value)) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"Subagent taskName must use only lowercase ASCII letters, digits, and underscores"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function validateTaskPath(value) {
|
|
27
|
+
if (!value.startsWith(`${ROOT_TASK_PATH}/`) && value !== ROOT_TASK_PATH) {
|
|
28
|
+
throw new Error("Canonical subagent task paths must start with `/root`");
|
|
29
|
+
}
|
|
30
|
+
if (value.length > MAX_TASK_PATH_LENGTH) {
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Canonical subagent task paths cannot exceed ${MAX_TASK_PATH_LENGTH} characters`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (value.endsWith("/") || value.includes("//")) {
|
|
36
|
+
throw new Error("Canonical subagent task paths must not contain empty segments");
|
|
37
|
+
}
|
|
38
|
+
for (const segment of value.slice(ROOT_TASK_PATH.length + 1).split("/")) {
|
|
39
|
+
if (segment) validateTaskName(segment);
|
|
40
|
+
}
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
function joinTaskPath(parentPath, taskName) {
|
|
44
|
+
const parent = validateTaskPath(parentPath);
|
|
45
|
+
const name = validateTaskName(taskName);
|
|
46
|
+
return validateTaskPath(`${parent}/${name}`);
|
|
47
|
+
}
|
|
48
|
+
function resolveTaskPath(senderPath, reference) {
|
|
49
|
+
if (!reference) throw new Error("Subagent task path reference must not be empty");
|
|
50
|
+
if (reference.startsWith("/")) return validateTaskPath(reference);
|
|
51
|
+
const sender = validateTaskPath(senderPath);
|
|
52
|
+
if (reference.endsWith("/")) {
|
|
53
|
+
throw new Error("Relative subagent task paths must not end with `/`");
|
|
54
|
+
}
|
|
55
|
+
let path = sender;
|
|
56
|
+
for (const segment of reference.split("/")) path = joinTaskPath(path, segment);
|
|
57
|
+
return path;
|
|
58
|
+
}
|
|
59
|
+
function deriveTaskName(agentId) {
|
|
60
|
+
const digest = createHash("sha256").update(agentId).digest("hex").slice(0, 32);
|
|
61
|
+
return `agent_${digest}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
ROOT_TASK_PATH,
|
|
66
|
+
MAX_TASK_NAME_LENGTH,
|
|
67
|
+
validateTaskName,
|
|
68
|
+
validateTaskPath,
|
|
69
|
+
joinTaskPath,
|
|
70
|
+
resolveTaskPath,
|
|
71
|
+
deriveTaskName
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=chunk-N7BLVXKK.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/task-path.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash } from \"node:crypto\";\n\nexport const ROOT_TASK_PATH = \"/root\";\nexport const MAX_TASK_NAME_LENGTH = 128;\nexport const MAX_TASK_PATH_LENGTH = 2_048;\n\nconst TASK_NAME_PATTERN = /^[a-z0-9_]+$/u;\n\nexport function validateTaskName(value: string): string {\n\tif (!value) throw new Error(\"Subagent taskName must not be empty\");\n\tif (value === \"root\" || value === \".\" || value === \"..\") {\n\t\tthrow new Error(`Subagent taskName ${JSON.stringify(value)} is reserved`);\n\t}\n\tif (value.length > MAX_TASK_NAME_LENGTH) {\n\t\tthrow new Error(`Subagent taskName cannot exceed ${MAX_TASK_NAME_LENGTH} characters`);\n\t}\n\tif (value.includes(\"/\")) throw new Error(\"Subagent taskName must not contain `/`\");\n\tif (!TASK_NAME_PATTERN.test(value)) {\n\t\tthrow new Error(\n\t\t\t\"Subagent taskName must use only lowercase ASCII letters, digits, and underscores\",\n\t\t);\n\t}\n\treturn value;\n}\n\nexport function validateTaskPath(value: string): string {\n\tif (!value.startsWith(`${ROOT_TASK_PATH}/`) && value !== ROOT_TASK_PATH) {\n\t\tthrow new Error(\"Canonical subagent task paths must start with `/root`\");\n\t}\n\tif (value.length > MAX_TASK_PATH_LENGTH) {\n\t\tthrow new Error(\n\t\t\t`Canonical subagent task paths cannot exceed ${MAX_TASK_PATH_LENGTH} characters`,\n\t\t);\n\t}\n\tif (value.endsWith(\"/\") || value.includes(\"//\")) {\n\t\tthrow new Error(\"Canonical subagent task paths must not contain empty segments\");\n\t}\n\tfor (const segment of value.slice(ROOT_TASK_PATH.length + 1).split(\"/\")) {\n\t\tif (segment) validateTaskName(segment);\n\t}\n\treturn value;\n}\n\nexport function joinTaskPath(parentPath: string, taskName: string): string {\n\tconst parent = validateTaskPath(parentPath);\n\tconst name = validateTaskName(taskName);\n\treturn validateTaskPath(`${parent}/${name}`);\n}\n\nexport function resolveTaskPath(senderPath: string, reference: string): string {\n\tif (!reference) throw new Error(\"Subagent task path reference must not be empty\");\n\tif (reference.startsWith(\"/\")) return validateTaskPath(reference);\n\tconst sender = validateTaskPath(senderPath);\n\tif (reference.endsWith(\"/\")) {\n\t\tthrow new Error(\"Relative subagent task paths must not end with `/`\");\n\t}\n\tlet path = sender;\n\tfor (const segment of reference.split(\"/\")) path = joinTaskPath(path, segment);\n\treturn path;\n}\n\nexport function deriveTaskName(agentId: string): string {\n\tconst digest = createHash(\"sha256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tC,SAAO,iBAAiB,GAAG,MAAM,IAAI,IAAI,EAAE;AAC5C;AAEO,SAAS,gBAAgB,YAAoB,WAA2B;AAC9E,MAAI,CAAC,UAAW,OAAM,IAAI,MAAM,gDAAgD;AAChF,MAAI,UAAU,WAAW,GAAG,EAAG,QAAO,iBAAiB,SAAS;AAChE,QAAM,SAAS,iBAAiB,UAAU;AAC1C,MAAI,UAAU,SAAS,GAAG,GAAG;AAC5B,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACrE;AACA,MAAI,OAAO;AACX,aAAW,WAAW,UAAU,MAAM,GAAG,EAAG,QAAO,aAAa,MAAM,OAAO;AAC7E,SAAO;AACR;AAEO,SAAS,eAAe,SAAyB;AACvD,QAAM,SAAS,WAAW,QAAQ,EAAE,OAAO,OAAO,EAAE,OAAO,KAAK,EAAE,MAAM,GAAG,EAAE;AAC7E,SAAO,SAAS,MAAM;AACvB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
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
|
+
MAX_SUBAGENT_TOOL_CALLS,
|
|
5
|
+
MAX_SUBAGENT_TURNS
|
|
6
|
+
} from "./chunk-ONDTY4EL.js";
|
|
7
|
+
import {
|
|
8
|
+
SUBAGENT_RESULT_FORMATS
|
|
9
|
+
} from "./chunk-RSUXZD6S.js";
|
|
10
|
+
import {
|
|
11
|
+
THINKING_LEVELS
|
|
12
|
+
} from "./chunk-DPPVEQAM.js";
|
|
13
|
+
import {
|
|
14
|
+
DelegationContractSchema
|
|
15
|
+
} from "./chunk-I2FAK44T.js";
|
|
16
|
+
import {
|
|
17
|
+
MAX_CONFIGURABLE_PARALLEL_TASKS,
|
|
18
|
+
MAX_SUBAGENT_TIMEOUT_MS
|
|
19
|
+
} from "./chunk-H3FP6DLR.js";
|
|
20
|
+
|
|
21
|
+
// src/params.ts
|
|
22
|
+
import { StringEnum as StringEnum2 } from "@earendil-works/pi-ai";
|
|
23
|
+
import { Type as Type2 } from "typebox";
|
|
24
|
+
|
|
25
|
+
// src/panel-presets.ts
|
|
26
|
+
var PANEL_PRESETS = ["code-review", "research", "security-review", "custom"];
|
|
27
|
+
|
|
28
|
+
// src/verified-execution-schema.ts
|
|
29
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
30
|
+
import { Type } from "typebox";
|
|
31
|
+
var VerificationCheckSchema = Type.Object(
|
|
32
|
+
{
|
|
33
|
+
id: Type.String({
|
|
34
|
+
minLength: 1,
|
|
35
|
+
maxLength: 256,
|
|
36
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$"
|
|
37
|
+
}),
|
|
38
|
+
command: StringEnum(["git", "node", "npm", "npx"]),
|
|
39
|
+
args: Type.Optional(Type.Array(Type.String({ maxLength: 4096 }), { maxItems: 64 })),
|
|
40
|
+
cwd: Type.Optional(Type.String({ minLength: 1, maxLength: 4096 })),
|
|
41
|
+
timeoutMs: Type.Optional(Type.Integer({ minimum: 1, maximum: 6e5 }))
|
|
42
|
+
},
|
|
43
|
+
{ additionalProperties: false }
|
|
44
|
+
);
|
|
45
|
+
var VerifiedExecutionContractSchema = Type.Object(
|
|
46
|
+
{
|
|
47
|
+
verifierAgent: Type.String({ minLength: 1, maxLength: 256 }),
|
|
48
|
+
maxReworkCycles: Type.Optional(Type.Integer({ minimum: 0, maximum: 1, default: 1 })),
|
|
49
|
+
checks: Type.Optional(Type.Array(VerificationCheckSchema, { maxItems: 32 }))
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
additionalProperties: false,
|
|
53
|
+
description: "Explicitly gate mutating workflow success on executor-owned deterministic checks, one least-authority independent verifier, exact submitted-state identity, and managed integration acceptance."
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
// src/params.ts
|
|
58
|
+
var TimeoutMs = Type2.Number({
|
|
59
|
+
description: "Work deadline in milliseconds selected for the task difficulty. On expiry, Pi aborts the work and makes one separately bounded summary attempt. Defaults to PI_SUBAGENT_TIMEOUT_MS or 600000.",
|
|
60
|
+
minimum: 1,
|
|
61
|
+
maximum: MAX_SUBAGENT_TIMEOUT_MS
|
|
62
|
+
});
|
|
63
|
+
var TurnLimitFields = {
|
|
64
|
+
idleTimeoutMs: Type2.Optional(
|
|
65
|
+
Type2.Integer({
|
|
66
|
+
description: "Maximum milliseconds without a completed assistant turn or tool result before Pi aborts work and preserves a checkpoint.",
|
|
67
|
+
minimum: 1,
|
|
68
|
+
maximum: MAX_SUBAGENT_TIMEOUT_MS
|
|
69
|
+
})
|
|
70
|
+
),
|
|
71
|
+
maxTurns: Type2.Optional(
|
|
72
|
+
Type2.Integer({
|
|
73
|
+
description: "Maximum assistant turns before unfinished work is stopped and checkpointed.",
|
|
74
|
+
minimum: 1,
|
|
75
|
+
maximum: MAX_SUBAGENT_TURNS
|
|
76
|
+
})
|
|
77
|
+
),
|
|
78
|
+
maxToolCalls: Type2.Optional(
|
|
79
|
+
Type2.Integer({
|
|
80
|
+
description: "Maximum tool calls before additional tool work is stopped and checkpointed.",
|
|
81
|
+
minimum: 1,
|
|
82
|
+
maximum: MAX_SUBAGENT_TOOL_CALLS
|
|
83
|
+
})
|
|
84
|
+
)
|
|
85
|
+
};
|
|
86
|
+
var ThinkingLevelSchema = StringEnum2(THINKING_LEVELS, {
|
|
87
|
+
description: "Pi thinking level for the subagent process: off, minimal, low, medium, high, xhigh, or max."
|
|
88
|
+
});
|
|
89
|
+
var ResultFormatSchema = StringEnum2(SUBAGENT_RESULT_FORMATS, {
|
|
90
|
+
description: "Optional completion contract. Text preserves ordinary output; structured-v1 and structured-v2 request versioned JSON with bounded text fallback."
|
|
91
|
+
});
|
|
92
|
+
var ContractFields = {
|
|
93
|
+
contract: Type2.Optional(DelegationContractSchema),
|
|
94
|
+
resultFormat: Type2.Optional(ResultFormatSchema),
|
|
95
|
+
retryPolicy: Type2.Optional(
|
|
96
|
+
Type2.Object(
|
|
97
|
+
{
|
|
98
|
+
maxAttempts: Type2.Integer({ minimum: 1, maximum: 3 }),
|
|
99
|
+
backoffMs: Type2.Optional(Type2.Integer({ minimum: 0, maximum: 3e4 }))
|
|
100
|
+
},
|
|
101
|
+
{ additionalProperties: false }
|
|
102
|
+
)
|
|
103
|
+
),
|
|
104
|
+
hedgeAfterMs: Type2.Optional(Type2.Integer({ minimum: 1, maximum: 3e4 }))
|
|
105
|
+
};
|
|
106
|
+
var TaskItem = Type2.Object({
|
|
107
|
+
agent: Type2.String({ description: "Name of the agent to invoke" }),
|
|
108
|
+
task: Type2.String({ description: "Task to delegate to the agent" }),
|
|
109
|
+
cwd: Type2.Optional(Type2.String({ description: "Working directory for the agent process" })),
|
|
110
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
111
|
+
...TurnLimitFields,
|
|
112
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema),
|
|
113
|
+
...ContractFields
|
|
114
|
+
});
|
|
115
|
+
var WorkflowTaskItem = Type2.Object({
|
|
116
|
+
id: Type2.String({ minLength: 1, maxLength: 256 }),
|
|
117
|
+
agent: Type2.Optional(
|
|
118
|
+
Type2.String({ description: "Optional explicit agent; omit to route by capability manifest" })
|
|
119
|
+
),
|
|
120
|
+
requiredCapabilities: Type2.Optional(
|
|
121
|
+
Type2.Array(Type2.String({ minLength: 1, maxLength: 256 }), { maxItems: 50 })
|
|
122
|
+
),
|
|
123
|
+
requiredTools: Type2.Optional(
|
|
124
|
+
Type2.Array(Type2.String({ minLength: 1, maxLength: 256 }), { maxItems: 50 })
|
|
125
|
+
),
|
|
126
|
+
requiredVerificationRole: Type2.Optional(Type2.String({ minLength: 1, maxLength: 256 })),
|
|
127
|
+
preferredCostHint: Type2.Optional(StringEnum2(["low", "medium", "high"])),
|
|
128
|
+
preferredLatencyHint: Type2.Optional(StringEnum2(["low", "medium", "high"])),
|
|
129
|
+
task: Type2.String({ description: "Task to delegate to the agent" }),
|
|
130
|
+
dependsOn: Type2.Optional(
|
|
131
|
+
Type2.Array(Type2.String({ minLength: 1, maxLength: 256 }), { maxItems: 64 })
|
|
132
|
+
),
|
|
133
|
+
inputArtifacts: Type2.Optional(
|
|
134
|
+
Type2.Array(Type2.String({ minLength: 1, maxLength: 256 }), { maxItems: 50 })
|
|
135
|
+
),
|
|
136
|
+
inputArtifactVersions: Type2.Optional(
|
|
137
|
+
Type2.Record(
|
|
138
|
+
Type2.String({ minLength: 1, maxLength: 256 }),
|
|
139
|
+
Type2.String({ minLength: 1, maxLength: 256 })
|
|
140
|
+
)
|
|
141
|
+
),
|
|
142
|
+
readPaths: Type2.Optional(Type2.Array(Type2.String({ maxLength: 4096 }), { maxItems: 50 })),
|
|
143
|
+
writePaths: Type2.Optional(Type2.Array(Type2.String({ maxLength: 4096 }), { maxItems: 50 })),
|
|
144
|
+
ownershipKeys: Type2.Optional(Type2.Array(Type2.String({ maxLength: 256 }), { maxItems: 50 })),
|
|
145
|
+
acceptanceCriteria: Type2.Optional(Type2.Array(Type2.String({ maxLength: 4096 }), { maxItems: 50 })),
|
|
146
|
+
integrationOwner: Type2.Optional(Type2.Boolean()),
|
|
147
|
+
verifierFor: Type2.Optional(
|
|
148
|
+
Type2.String({
|
|
149
|
+
minLength: 1,
|
|
150
|
+
maxLength: 256,
|
|
151
|
+
description: "Target task ID for one distinct direct-dependent structured-v2 verifier. The executor gates target acceptance on a current exact-tree receipt."
|
|
152
|
+
})
|
|
153
|
+
),
|
|
154
|
+
cwd: Type2.Optional(Type2.String({ description: "Working directory for the agent process" })),
|
|
155
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
156
|
+
...TurnLimitFields,
|
|
157
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema),
|
|
158
|
+
...ContractFields
|
|
159
|
+
});
|
|
160
|
+
var ChainItem = Type2.Object({
|
|
161
|
+
agent: Type2.String({ description: "Name of the agent to invoke" }),
|
|
162
|
+
task: Type2.String({ description: "Task with optional {previous} placeholder for prior output" }),
|
|
163
|
+
cwd: Type2.Optional(Type2.String({ description: "Working directory for the agent process" })),
|
|
164
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
165
|
+
...TurnLimitFields,
|
|
166
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema),
|
|
167
|
+
...ContractFields
|
|
168
|
+
});
|
|
169
|
+
var AggregatorItem = Type2.Object(
|
|
170
|
+
{
|
|
171
|
+
agent: Type2.String({
|
|
172
|
+
description: "Name of the fan-in agent to invoke after parallel tasks complete"
|
|
173
|
+
}),
|
|
174
|
+
task: Type2.String({
|
|
175
|
+
description: "Fan-in task. Use {previous} to include all parallel outputs."
|
|
176
|
+
}),
|
|
177
|
+
cwd: Type2.Optional(
|
|
178
|
+
Type2.String({ description: "Working directory for the aggregator process" })
|
|
179
|
+
),
|
|
180
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
181
|
+
...TurnLimitFields,
|
|
182
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema),
|
|
183
|
+
...ContractFields
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
description: "Optional fan-in step for parallel mode. Omit this key entirely when no aggregation is needed; empty or whitespace-only agent/task values are treated as absent."
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
var PanelReviewerItem = Type2.Object(
|
|
190
|
+
{
|
|
191
|
+
id: Type2.String({ minLength: 1, maxLength: 256 }),
|
|
192
|
+
agent: Type2.String({ minLength: 1 }),
|
|
193
|
+
focus: Type2.Optional(Type2.String({ maxLength: 8 * 1024 })),
|
|
194
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
195
|
+
...TurnLimitFields,
|
|
196
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema)
|
|
197
|
+
},
|
|
198
|
+
{ additionalProperties: false }
|
|
199
|
+
);
|
|
200
|
+
var PanelSynthesizerItem = Type2.Object(
|
|
201
|
+
{
|
|
202
|
+
agent: Type2.String({ minLength: 1 }),
|
|
203
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
204
|
+
...TurnLimitFields,
|
|
205
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema)
|
|
206
|
+
},
|
|
207
|
+
{ additionalProperties: false }
|
|
208
|
+
);
|
|
209
|
+
var PanelItem = Type2.Object(
|
|
210
|
+
{
|
|
211
|
+
id: Type2.Optional(Type2.String({ minLength: 1, maxLength: 256 })),
|
|
212
|
+
preset: Type2.Optional(StringEnum2(PANEL_PRESETS, { default: "custom" })),
|
|
213
|
+
task: Type2.String({ minLength: 1, maxLength: 50 * 1024 }),
|
|
214
|
+
context: Type2.Optional(Type2.String({ maxLength: 50 * 1024 })),
|
|
215
|
+
reviewers: Type2.Array(PanelReviewerItem, {
|
|
216
|
+
minItems: 2,
|
|
217
|
+
maxItems: MAX_CONFIGURABLE_PARALLEL_TASKS
|
|
218
|
+
}),
|
|
219
|
+
synthesizer: PanelSynthesizerItem,
|
|
220
|
+
minValidReviews: Type2.Optional(Type2.Integer({ minimum: 2 }))
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
additionalProperties: false,
|
|
224
|
+
description: "One bounded independent review round followed by one evidence-preserving synthesis when enough valid reviews remain."
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
var AgentScopeSchema = StringEnum2(["user", "project", "both"], {
|
|
228
|
+
description: 'Per-invocation custom agent scope. Default: "user". Use "project" for project-local agents or "both" for user and project agents; this is a tool argument, not a pi-subagents.json setting.',
|
|
229
|
+
default: "user"
|
|
230
|
+
});
|
|
231
|
+
var SubagentParams = Type2.Object({
|
|
232
|
+
agent: Type2.Optional(
|
|
233
|
+
Type2.String({ description: "Name of the agent to invoke (for single mode)" })
|
|
234
|
+
),
|
|
235
|
+
task: Type2.Optional(Type2.String({ description: "Task to delegate (for single mode)" })),
|
|
236
|
+
tasks: Type2.Optional(
|
|
237
|
+
Type2.Array(TaskItem, {
|
|
238
|
+
description: "Array of {agent, task} for parallel execution",
|
|
239
|
+
maxItems: MAX_CONFIGURABLE_PARALLEL_TASKS
|
|
240
|
+
})
|
|
241
|
+
),
|
|
242
|
+
chain: Type2.Optional(
|
|
243
|
+
Type2.Array(ChainItem, { description: "Array of {agent, task} for sequential execution" })
|
|
244
|
+
),
|
|
245
|
+
aggregator: Type2.Optional(AggregatorItem),
|
|
246
|
+
panel: Type2.Optional(PanelItem),
|
|
247
|
+
workflow: Type2.Optional(
|
|
248
|
+
Type2.Object(
|
|
249
|
+
{
|
|
250
|
+
id: Type2.Optional(Type2.String({ minLength: 1, maxLength: 256 })),
|
|
251
|
+
verifiedExecution: Type2.Optional(VerifiedExecutionContractSchema),
|
|
252
|
+
honorAdmission: Type2.Optional(
|
|
253
|
+
Type2.Boolean({
|
|
254
|
+
description: "Opt in to declining workflow tasks whose explicit audit metadata recommends parent-owned work or abstention."
|
|
255
|
+
})
|
|
256
|
+
),
|
|
257
|
+
tasks: Type2.Array(WorkflowTaskItem, {
|
|
258
|
+
minItems: 1,
|
|
259
|
+
maxItems: MAX_CONFIGURABLE_PARALLEL_TASKS
|
|
260
|
+
})
|
|
261
|
+
},
|
|
262
|
+
{ additionalProperties: false }
|
|
263
|
+
)
|
|
264
|
+
),
|
|
265
|
+
agentScope: Type2.Optional(AgentScopeSchema),
|
|
266
|
+
confirmProjectAgents: Type2.Optional(
|
|
267
|
+
Type2.Boolean({
|
|
268
|
+
description: "Prompt before running project-local agents. Default: true.",
|
|
269
|
+
default: true
|
|
270
|
+
})
|
|
271
|
+
),
|
|
272
|
+
cwd: Type2.Optional(
|
|
273
|
+
Type2.String({ description: "Working directory for the agent process (single mode)" })
|
|
274
|
+
),
|
|
275
|
+
timeoutMs: Type2.Optional(TimeoutMs),
|
|
276
|
+
totalTimeoutMs: Type2.Optional(
|
|
277
|
+
Type2.Number({
|
|
278
|
+
description: "Overall blocking-workflow deadline in milliseconds, including queued work, workflow tasks, panel phases, chain steps, and fan-in.",
|
|
279
|
+
minimum: 1,
|
|
280
|
+
maximum: MAX_SUBAGENT_TIMEOUT_MS
|
|
281
|
+
})
|
|
282
|
+
),
|
|
283
|
+
...TurnLimitFields,
|
|
284
|
+
thinkingLevel: Type2.Optional(ThinkingLevelSchema),
|
|
285
|
+
...ContractFields
|
|
286
|
+
});
|
|
287
|
+
function hasUsableAggregator(aggregator) {
|
|
288
|
+
if (!aggregator || typeof aggregator !== "object") return false;
|
|
289
|
+
const candidate = aggregator;
|
|
290
|
+
return typeof candidate.agent === "string" && candidate.agent.trim().length > 0 && typeof candidate.task === "string" && candidate.task.trim().length > 0;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export {
|
|
294
|
+
SubagentParams,
|
|
295
|
+
hasUsableAggregator
|
|
296
|
+
};
|
|
297
|
+
//# sourceMappingURL=chunk-NIF42QMF.ts.map
|