@narumitw/pi-subagents 2.1.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -1228
- package/dist/child-communication-bridge.ts +136 -0
- package/dist/child-communication-bridge.ts.map +7 -0
- package/dist/chunks/chunk-UKTWUQRM.js +667 -0
- package/dist/chunks/chunk-UKTWUQRM.js.map +7 -0
- package/dist/index.ts +1448 -1614
- package/dist/index.ts.map +4 -4
- package/docs/design-principles.md +31 -0
- package/docs/ipc-transport-idea.md +103 -0
- package/docs/tools.md +109 -0
- package/package.json +11 -19
- package/src/broker-credentials.ts +71 -0
- package/src/child-communication-bridge.ts +153 -0
- package/src/child-communication-tools.ts +147 -0
- package/src/completion-renderer.ts +60 -0
- package/src/index.ts +1 -1
- package/src/message-broker.ts +628 -0
- package/src/model-output.ts +42 -0
- package/src/process.ts +688 -0
- package/src/runtime.ts +538 -0
- package/src/subagents.ts +33 -34
- package/src/tools.ts +416 -0
- package/src/types.ts +85 -0
- package/src/widget.ts +130 -0
- package/dist/chunks/auto-transport-FUUKFDIG.ts +0 -109
- package/dist/chunks/auto-transport-FUUKFDIG.ts.map +0 -7
- package/dist/chunks/capability-grant-PR72SWWS.ts +0 -19
- package/dist/chunks/capability-grant-PR72SWWS.ts.map +0 -7
- package/dist/chunks/child-peer-bridge.ts +0 -108
- package/dist/chunks/child-peer-bridge.ts.map +0 -7
- package/dist/chunks/chunk-2LMJU25E.ts +0 -1641
- package/dist/chunks/chunk-2LMJU25E.ts.map +0 -7
- package/dist/chunks/chunk-47SK2QYC.ts +0 -56
- package/dist/chunks/chunk-47SK2QYC.ts.map +0 -7
- package/dist/chunks/chunk-4AQSF7AS.ts +0 -29
- package/dist/chunks/chunk-4AQSF7AS.ts.map +0 -7
- package/dist/chunks/chunk-5DGRMKNV.ts +0 -126
- package/dist/chunks/chunk-5DGRMKNV.ts.map +0 -7
- package/dist/chunks/chunk-6H6TBBED.ts +0 -108
- package/dist/chunks/chunk-6H6TBBED.ts.map +0 -7
- package/dist/chunks/chunk-6KJ34M6S.ts +0 -159
- package/dist/chunks/chunk-6KJ34M6S.ts.map +0 -7
- package/dist/chunks/chunk-6NSJVPXX.ts +0 -480
- package/dist/chunks/chunk-6NSJVPXX.ts.map +0 -7
- package/dist/chunks/chunk-7AAJEUSL.ts +0 -238
- package/dist/chunks/chunk-7AAJEUSL.ts.map +0 -7
- package/dist/chunks/chunk-BFK2Z4ZF.ts +0 -189
- package/dist/chunks/chunk-BFK2Z4ZF.ts.map +0 -7
- package/dist/chunks/chunk-BOAXY55Y.ts +0 -153
- package/dist/chunks/chunk-BOAXY55Y.ts.map +0 -7
- package/dist/chunks/chunk-D4CR7T73.ts +0 -353
- package/dist/chunks/chunk-D4CR7T73.ts.map +0 -7
- package/dist/chunks/chunk-FEVPWRMU.ts +0 -300
- package/dist/chunks/chunk-FEVPWRMU.ts.map +0 -7
- package/dist/chunks/chunk-G6VZTCFH.ts +0 -70
- package/dist/chunks/chunk-G6VZTCFH.ts.map +0 -7
- package/dist/chunks/chunk-H3FP6DLR.ts +0 -160
- package/dist/chunks/chunk-H3FP6DLR.ts.map +0 -7
- package/dist/chunks/chunk-HA36LPCO.ts +0 -130
- package/dist/chunks/chunk-HA36LPCO.ts.map +0 -7
- package/dist/chunks/chunk-HOP5FXDT.ts +0 -27
- package/dist/chunks/chunk-HOP5FXDT.ts.map +0 -7
- package/dist/chunks/chunk-IGAMVWFN.ts +0 -139
- package/dist/chunks/chunk-IGAMVWFN.ts.map +0 -7
- package/dist/chunks/chunk-ILEQ27AL.ts +0 -45
- package/dist/chunks/chunk-ILEQ27AL.ts.map +0 -7
- package/dist/chunks/chunk-ITVWPNU4.ts +0 -819
- package/dist/chunks/chunk-ITVWPNU4.ts.map +0 -7
- package/dist/chunks/chunk-IWC32VPY.ts +0 -172
- package/dist/chunks/chunk-IWC32VPY.ts.map +0 -7
- package/dist/chunks/chunk-JSZIP73U.ts +0 -362
- package/dist/chunks/chunk-JSZIP73U.ts.map +0 -7
- package/dist/chunks/chunk-JU6LUNLP.ts +0 -380
- package/dist/chunks/chunk-JU6LUNLP.ts.map +0 -7
- package/dist/chunks/chunk-KMGKCEO4.ts +0 -38
- package/dist/chunks/chunk-KMGKCEO4.ts.map +0 -7
- package/dist/chunks/chunk-LASD73CM.ts +0 -339
- package/dist/chunks/chunk-LASD73CM.ts.map +0 -7
- package/dist/chunks/chunk-LEOYDZI3.ts +0 -22
- package/dist/chunks/chunk-LEOYDZI3.ts.map +0 -7
- package/dist/chunks/chunk-LL4LP2T7.ts +0 -737
- package/dist/chunks/chunk-LL4LP2T7.ts.map +0 -7
- package/dist/chunks/chunk-N2T5IN4X.ts +0 -18
- package/dist/chunks/chunk-N2T5IN4X.ts.map +0 -7
- package/dist/chunks/chunk-N7BLVXKK.ts +0 -73
- package/dist/chunks/chunk-N7BLVXKK.ts.map +0 -7
- package/dist/chunks/chunk-NLT67IZS.ts +0 -322
- package/dist/chunks/chunk-NLT67IZS.ts.map +0 -7
- package/dist/chunks/chunk-NTRPLF46.ts +0 -63
- package/dist/chunks/chunk-NTRPLF46.ts.map +0 -7
- package/dist/chunks/chunk-ONDTY4EL.ts +0 -91
- package/dist/chunks/chunk-ONDTY4EL.ts.map +0 -7
- package/dist/chunks/chunk-OVPHFGKO.ts +0 -1769
- package/dist/chunks/chunk-OVPHFGKO.ts.map +0 -7
- package/dist/chunks/chunk-P7OH4XMF.ts +0 -60
- package/dist/chunks/chunk-P7OH4XMF.ts.map +0 -7
- package/dist/chunks/chunk-PBZMBTNJ.ts +0 -422
- package/dist/chunks/chunk-PBZMBTNJ.ts.map +0 -7
- package/dist/chunks/chunk-PGLSFLYW.ts +0 -52
- package/dist/chunks/chunk-PGLSFLYW.ts.map +0 -7
- package/dist/chunks/chunk-RRR66UWR.ts +0 -28
- package/dist/chunks/chunk-RRR66UWR.ts.map +0 -7
- package/dist/chunks/chunk-RSUXZD6S.ts +0 -275
- package/dist/chunks/chunk-RSUXZD6S.ts.map +0 -7
- package/dist/chunks/chunk-RTCVYIZA.ts +0 -221
- package/dist/chunks/chunk-RTCVYIZA.ts.map +0 -7
- package/dist/chunks/chunk-RY2AEGMZ.ts +0 -34
- package/dist/chunks/chunk-RY2AEGMZ.ts.map +0 -7
- package/dist/chunks/chunk-SWGQLFSD.ts +0 -60
- package/dist/chunks/chunk-SWGQLFSD.ts.map +0 -7
- package/dist/chunks/chunk-TM2R67J3.ts +0 -52
- package/dist/chunks/chunk-TM2R67J3.ts.map +0 -7
- package/dist/chunks/chunk-TMZRHIIK.ts +0 -497
- package/dist/chunks/chunk-TMZRHIIK.ts.map +0 -7
- package/dist/chunks/chunk-TZ34IQ3M.ts +0 -59
- package/dist/chunks/chunk-TZ34IQ3M.ts.map +0 -7
- package/dist/chunks/chunk-UMBPMVJW.ts +0 -22
- package/dist/chunks/chunk-UMBPMVJW.ts.map +0 -7
- package/dist/chunks/chunk-VDG7LTYE.ts +0 -80
- package/dist/chunks/chunk-VDG7LTYE.ts.map +0 -7
- package/dist/chunks/chunk-X4NMONPE.ts +0 -73
- package/dist/chunks/chunk-X4NMONPE.ts.map +0 -7
- package/dist/chunks/chunk-YPJEN6NU.ts +0 -65
- package/dist/chunks/chunk-YPJEN6NU.ts.map +0 -7
- package/dist/chunks/chunk-YU53SHA7.ts +0 -328
- package/dist/chunks/chunk-YU53SHA7.ts.map +0 -7
- package/dist/chunks/completion-delivery-RSJU6BXL.ts +0 -17
- package/dist/chunks/completion-delivery-RSJU6BXL.ts.map +0 -7
- package/dist/chunks/config-status-FKGDECZ3.ts +0 -35
- package/dist/chunks/config-status-FKGDECZ3.ts.map +0 -7
- package/dist/chunks/config-ui-ABHYNGQ7.ts +0 -1212
- package/dist/chunks/config-ui-ABHYNGQ7.ts.map +0 -7
- package/dist/chunks/consult-LJU3IQY5.ts +0 -519
- package/dist/chunks/consult-LJU3IQY5.ts.map +0 -7
- package/dist/chunks/context-QDKLVQXE.ts +0 -11
- package/dist/chunks/context-QDKLVQXE.ts.map +0 -7
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts +0 -130
- package/dist/chunks/create-stateful-transport-JWC2EFYL.ts.map +0 -7
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts +0 -17
- package/dist/chunks/cwd-policy-NB6XZ5GF.ts.map +0 -7
- package/dist/chunks/delegation-contract-LA56I5DT.ts +0 -24
- package/dist/chunks/delegation-contract-LA56I5DT.ts.map +0 -7
- package/dist/chunks/discovery-MIFB2U4Y.ts +0 -12
- package/dist/chunks/discovery-MIFB2U4Y.ts.map +0 -7
- package/dist/chunks/execution-Q2JZLKJA.ts +0 -4037
- package/dist/chunks/execution-Q2JZLKJA.ts.map +0 -7
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts +0 -39
- package/dist/chunks/in-process-transport-HJ6TZXC3.ts.map +0 -7
- package/dist/chunks/inspect-UH2TKH6E.ts +0 -634
- package/dist/chunks/inspect-UH2TKH6E.ts.map +0 -7
- package/dist/chunks/peer-communication-KL36Z6CO.ts +0 -294
- package/dist/chunks/peer-communication-KL36Z6CO.ts.map +0 -7
- package/dist/chunks/persistence-UY3PY6E5.ts +0 -348
- package/dist/chunks/persistence-UY3PY6E5.ts.map +0 -7
- package/dist/chunks/registry-BT54L6CY.ts +0 -1445
- package/dist/chunks/registry-BT54L6CY.ts.map +0 -7
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts +0 -81
- package/dist/chunks/retained-semantic-state-GM75FZGE.ts.map +0 -7
- package/dist/chunks/rpc-transport-7R7DVCEB.ts +0 -1222
- package/dist/chunks/rpc-transport-7R7DVCEB.ts.map +0 -7
- package/dist/chunks/runtime-policy-5YELCOVC.ts +0 -15
- package/dist/chunks/runtime-policy-5YELCOVC.ts.map +0 -7
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts +0 -19
- package/dist/chunks/semantic-snapshot-WPJ3UAFW.ts.map +0 -7
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts +0 -13
- package/dist/chunks/spawn-idempotency-BNHOSMZW.ts.map +0 -7
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts +0 -15
- package/dist/chunks/stateful-lifecycle-JAR6K55H.ts.map +0 -7
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts +0 -160
- package/dist/chunks/subprocess-transport-VHZJRBTW.ts.map +0 -7
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts +0 -164
- package/dist/chunks/usage-recording-store-CW3EH2SZ.ts.map +0 -7
- package/dist/chunks/workspace-WDKLN72J.ts +0 -11
- package/dist/chunks/workspace-WDKLN72J.ts.map +0 -7
- package/docs/async-runtime-protocol.md +0 -84
- package/docs/implementation-notes/pi-subagents-capability-matrix.md +0 -62
- package/docs/implementation-notes/pi-subagents-current-direction.md +0 -99
- package/docs/implementation-notes/pi-subagents-rpc-v1.md +0 -139
- package/docs/pi-subagents-diagrams.md +0 -183
- package/src/adaptive-scheduler.ts +0 -224
- package/src/admission-policy.ts +0 -78
- package/src/agent-projection.ts +0 -53
- package/src/agents/built-ins.ts +0 -71
- package/src/agents/catalog.ts +0 -241
- package/src/agents/discovery.ts +0 -265
- package/src/agents/types.ts +0 -100
- package/src/agents.ts +0 -51
- package/src/auto-transport.ts +0 -121
- package/src/blocking-status.ts +0 -63
- package/src/cached-module-loader.ts +0 -18
- package/src/capabilities.ts +0 -145
- package/src/capability-grant.ts +0 -115
- package/src/capability-router.ts +0 -107
- package/src/child-peer-bridge.ts +0 -124
- package/src/child-peer-tools.ts +0 -132
- package/src/completion-delivery.ts +0 -409
- package/src/completion-render.ts +0 -190
- package/src/completion-requirement.ts +0 -479
- package/src/completion-routing.ts +0 -24
- package/src/config-registration.ts +0 -114
- package/src/config-status.ts +0 -217
- package/src/config-ui.ts +0 -983
- package/src/consult-policy.ts +0 -15
- package/src/consult-registration.ts +0 -125
- package/src/consult-render.ts +0 -194
- package/src/consult-resources.ts +0 -51
- package/src/consult-tool.ts +0 -95
- package/src/consult.ts +0 -566
- package/src/context.ts +0 -126
- package/src/create-stateful-transport.ts +0 -157
- package/src/cwd-policy.ts +0 -183
- package/src/delegation-contract.ts +0 -463
- package/src/execution/budget.ts +0 -56
- package/src/execution/runtime-policy.ts +0 -19
- package/src/execution-plan.ts +0 -322
- package/src/execution-ui.ts +0 -259
- package/src/execution.ts +0 -1679
- package/src/in-process-transport.ts +0 -941
- package/src/inspect-registration.ts +0 -64
- package/src/inspect-render.ts +0 -334
- package/src/inspect-tool.ts +0 -45
- package/src/inspect.ts +0 -769
- package/src/integration-controller.ts +0 -98
- package/src/limits.ts +0 -75
- package/src/orchestration-metrics.ts +0 -116
- package/src/outcome.ts +0 -61
- package/src/panel-child-group.ts +0 -35
- package/src/panel-contract.ts +0 -343
- package/src/panel-evidence.ts +0 -59
- package/src/panel-execution.ts +0 -769
- package/src/panel-failure.ts +0 -56
- package/src/panel-planning.ts +0 -175
- package/src/panel-presets.ts +0 -3
- package/src/panel-prompts.ts +0 -132
- package/src/panel-reconciliation.ts +0 -57
- package/src/panel-render.ts +0 -103
- package/src/parallel-limit-ui.ts +0 -113
- package/src/params.ts +0 -278
- package/src/peer-communication.ts +0 -352
- package/src/peer-transport.ts +0 -49
- package/src/persistence.ts +0 -522
- package/src/pi-args.ts +0 -43
- package/src/pi-invocation.ts +0 -168
- package/src/process-control.ts +0 -43
- package/src/prompt-resources.ts +0 -38
- package/src/prompt-source-safety.ts +0 -48
- package/src/protocol.ts +0 -76
- package/src/registry-types.ts +0 -204
- package/src/registry.ts +0 -1698
- package/src/render-common.ts +0 -252
- package/src/render.ts +0 -704
- package/src/result-contract.ts +0 -431
- package/src/retained-semantic-state.ts +0 -100
- package/src/rpc-timeout-finalization.ts +0 -207
- package/src/rpc-transport-metadata.ts +0 -65
- package/src/rpc-transport.ts +0 -1035
- package/src/rpc-turn-capture.ts +0 -217
- package/src/runner-outcome.ts +0 -31
- package/src/runner-result.ts +0 -55
- package/src/runner-types.ts +0 -102
- package/src/runner-usage.ts +0 -48
- package/src/runner.ts +0 -866
- package/src/safe-text.ts +0 -67
- package/src/semantic-snapshot.ts +0 -214
- package/src/session-guidance-contract.ts +0 -399
- package/src/settings/inspection.ts +0 -302
- package/src/settings/schema.ts +0 -195
- package/src/settings-reader.ts +0 -215
- package/src/settings.ts +0 -452
- package/src/spawn-idempotency.ts +0 -68
- package/src/stateful-agent-view.ts +0 -85
- package/src/stateful-config.ts +0 -13
- package/src/stateful-guidance.ts +0 -29
- package/src/stateful-lifecycle.ts +0 -74
- package/src/stateful-limit-ui.ts +0 -249
- package/src/stateful-limits.ts +0 -96
- package/src/stateful-prompt.ts +0 -49
- package/src/stateful-registration.ts +0 -1320
- package/src/stateful-render.ts +0 -318
- package/src/stateful-safety.ts +0 -47
- package/src/stateful-tool-params.ts +0 -215
- package/src/stateful.ts +0 -12
- package/src/subagent-details.ts +0 -43
- package/src/subagents-extension.ts +0 -372
- package/src/subprocess-transport.ts +0 -145
- package/src/supervision.ts +0 -104
- package/src/task-path.ts +0 -65
- package/src/timeout-checkpoint.ts +0 -305
- package/src/timeout-finalization.ts +0 -75
- package/src/tool-schema-compatibility.ts +0 -73
- package/src/transport-types.ts +0 -74
- package/src/transport-ui.ts +0 -135
- package/src/transport.ts +0 -43
- package/src/turn-budget.ts +0 -109
- package/src/usage-format.ts +0 -42
- package/src/usage-recording-config.ts +0 -13
- package/src/usage-recording-store.ts +0 -183
- package/src/usage-recording.ts +0 -478
- package/src/verification-harness.ts +0 -516
- package/src/verification-policy.ts +0 -67
- package/src/verification-receipt.ts +0 -275
- package/src/verified-execution-benchmark.ts +0 -86
- package/src/verified-execution-contract.ts +0 -191
- package/src/verified-execution-schema.ts +0 -32
- package/src/work-item-ledger.ts +0 -1404
- package/src/work-item-persistence.ts +0 -254
- package/src/workflow-completion-controller.ts +0 -397
- package/src/workflow-planning.ts +0 -172
- package/src/workflow-tree-identity.ts +0 -289
- package/src/workflow-ui.ts +0 -69
- package/src/workflow-verification.ts +0 -296
- package/src/workspace.ts +0 -174
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
|
|
3
|
-
export interface ManagedIntegrationExpectation {
|
|
4
|
-
taskId: string;
|
|
5
|
-
taskGeneration: number;
|
|
6
|
-
baseRepositoryGeneration: string;
|
|
7
|
-
dependencyVersions: Record<string, string>;
|
|
8
|
-
readSetVersions: Record<string, string>;
|
|
9
|
-
executionPlanId: string;
|
|
10
|
-
allowedScopes: string[];
|
|
11
|
-
patchDigest: string;
|
|
12
|
-
requiredEvidence: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ManagedIntegrationCandidate extends ManagedIntegrationExpectation {
|
|
16
|
-
changedPaths: string[];
|
|
17
|
-
evidence: Record<string, string>;
|
|
18
|
-
verifier: {
|
|
19
|
-
freshContext: boolean;
|
|
20
|
-
exactIntegratedTree: boolean;
|
|
21
|
-
status: "accepted" | "rework" | "rejected";
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface ManagedIntegrationAcceptance {
|
|
26
|
-
status: "accepted";
|
|
27
|
-
taskId: string;
|
|
28
|
-
taskGeneration: number;
|
|
29
|
-
patchDigest: string;
|
|
30
|
-
executionPlanId: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function verifyManagedIntegration(
|
|
34
|
-
expected: ManagedIntegrationExpectation,
|
|
35
|
-
candidate: ManagedIntegrationCandidate,
|
|
36
|
-
): ManagedIntegrationAcceptance {
|
|
37
|
-
if (
|
|
38
|
-
candidate.taskId !== expected.taskId ||
|
|
39
|
-
candidate.taskGeneration !== expected.taskGeneration
|
|
40
|
-
) {
|
|
41
|
-
throw new Error("Managed integration rejected stale task generation");
|
|
42
|
-
}
|
|
43
|
-
if (candidate.baseRepositoryGeneration !== expected.baseRepositoryGeneration) {
|
|
44
|
-
throw new Error("Managed integration rejected stale base repository generation");
|
|
45
|
-
}
|
|
46
|
-
if (candidate.executionPlanId !== expected.executionPlanId) {
|
|
47
|
-
throw new Error("Managed integration rejected stale execution plan identity");
|
|
48
|
-
}
|
|
49
|
-
if (!sameRecord(candidate.dependencyVersions, expected.dependencyVersions)) {
|
|
50
|
-
throw new Error("Managed integration rejected stale dependency versions");
|
|
51
|
-
}
|
|
52
|
-
if (!sameRecord(candidate.readSetVersions, expected.readSetVersions)) {
|
|
53
|
-
throw new Error("Managed integration rejected stale read-set versions");
|
|
54
|
-
}
|
|
55
|
-
if (candidate.patchDigest !== expected.patchDigest) {
|
|
56
|
-
throw new Error("Managed integration rejected patch digest mismatch");
|
|
57
|
-
}
|
|
58
|
-
const allowedScopes = expected.allowedScopes.map(normalizedPath);
|
|
59
|
-
if (
|
|
60
|
-
!candidate.changedPaths.every((changedPath) => {
|
|
61
|
-
const normalizedChangedPath = normalizedPath(changedPath);
|
|
62
|
-
return allowedScopes.some(
|
|
63
|
-
(scope) =>
|
|
64
|
-
normalizedChangedPath === scope ||
|
|
65
|
-
normalizedChangedPath.startsWith(`${scope}${path.sep}`),
|
|
66
|
-
);
|
|
67
|
-
})
|
|
68
|
-
) {
|
|
69
|
-
throw new Error("Managed integration rejected a path outside the accepted scope");
|
|
70
|
-
}
|
|
71
|
-
if (expected.requiredEvidence.some((id) => !candidate.evidence[id])) {
|
|
72
|
-
throw new Error("Managed integration rejected missing required evidence");
|
|
73
|
-
}
|
|
74
|
-
if (!candidate.verifier.freshContext || !candidate.verifier.exactIntegratedTree) {
|
|
75
|
-
throw new Error("Managed integration requires a fresh verifier on the exact integrated tree");
|
|
76
|
-
}
|
|
77
|
-
if (candidate.verifier.status !== "accepted") {
|
|
78
|
-
throw new Error(`Managed integration verifier returned ${candidate.verifier.status}`);
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
status: "accepted",
|
|
82
|
-
taskId: expected.taskId,
|
|
83
|
-
taskGeneration: expected.taskGeneration,
|
|
84
|
-
patchDigest: expected.patchDigest,
|
|
85
|
-
executionPlanId: expected.executionPlanId,
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function normalizedPath(value: string): string {
|
|
90
|
-
if (!value || value.includes("\0")) throw new Error("Managed integration scope is invalid");
|
|
91
|
-
return path.resolve(path.sep, value.replaceAll("\\", path.sep));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function sameRecord(left: Record<string, string>, right: Record<string, string>): boolean {
|
|
95
|
-
const leftEntries = Object.entries(left).sort(([a], [b]) => a.localeCompare(b));
|
|
96
|
-
const rightEntries = Object.entries(right).sort(([a], [b]) => a.localeCompare(b));
|
|
97
|
-
return JSON.stringify(leftEntries) === JSON.stringify(rightEntries);
|
|
98
|
-
}
|
package/src/limits.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_MAX_BYTES } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
|
|
3
|
-
export const DEFAULT_MAX_OUTPUT_BYTES = DEFAULT_MAX_BYTES;
|
|
4
|
-
export const DEFAULT_MAX_STDERR_BYTES = 16 * 1024;
|
|
5
|
-
export const DEFAULT_MAX_CONTEXT_BYTES = DEFAULT_MAX_BYTES;
|
|
6
|
-
export const MAX_SUBAGENT_TIMEOUT_MS = 2_147_483_647;
|
|
7
|
-
export const DEFAULT_MAX_PARALLEL_TASKS = 8;
|
|
8
|
-
export const MAX_CONFIGURABLE_PARALLEL_TASKS = 64;
|
|
9
|
-
export const MAX_BLOCKING_PARALLEL_CONCURRENCY = 4;
|
|
10
|
-
export const DEFAULT_MAX_MESSAGES = 200;
|
|
11
|
-
export const MAX_TOOL_MESSAGE_BYTES = 2 * 1024;
|
|
12
|
-
export const TRUNCATION_MARKER = "\n… [truncated by pi-subagents]";
|
|
13
|
-
export const TAIL_TRUNCATION_MARKER = "… [truncated by pi-subagents]\n";
|
|
14
|
-
|
|
15
|
-
export interface BoundedText {
|
|
16
|
-
text: string;
|
|
17
|
-
truncated: boolean;
|
|
18
|
-
originalBytes: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function normalizeByteLimit(maxBytes: number): number {
|
|
22
|
-
if (maxBytes === Number.POSITIVE_INFINITY) return Number.MAX_SAFE_INTEGER;
|
|
23
|
-
if (!Number.isFinite(maxBytes)) return 0;
|
|
24
|
-
return Math.max(0, Math.floor(maxBytes));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function truncateUtf8(text: string, maxBytes: number): BoundedText {
|
|
28
|
-
const limit = normalizeByteLimit(maxBytes);
|
|
29
|
-
const originalBytes = Buffer.byteLength(text, "utf8");
|
|
30
|
-
if (originalBytes <= limit) return { text, truncated: false, originalBytes };
|
|
31
|
-
if (limit === 0) return { text: "", truncated: true, originalBytes };
|
|
32
|
-
|
|
33
|
-
const marker = Buffer.from(TRUNCATION_MARKER, "utf8");
|
|
34
|
-
if (marker.length >= limit) {
|
|
35
|
-
return {
|
|
36
|
-
text: Buffer.from(text, "utf8").subarray(0, limit).toString("utf8").replace(/�+$/g, ""),
|
|
37
|
-
truncated: true,
|
|
38
|
-
originalBytes,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const prefix = Buffer.from(text, "utf8")
|
|
42
|
-
.subarray(0, limit - marker.length)
|
|
43
|
-
.toString("utf8")
|
|
44
|
-
.replace(/�+$/g, "");
|
|
45
|
-
return { text: `${prefix}${TRUNCATION_MARKER}`, truncated: true, originalBytes };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function truncateUtf8Tail(text: string, maxBytes: number): BoundedText {
|
|
49
|
-
const limit = normalizeByteLimit(maxBytes);
|
|
50
|
-
const bytes = Buffer.from(text, "utf8");
|
|
51
|
-
const originalBytes = bytes.length;
|
|
52
|
-
if (originalBytes <= limit) return { text, truncated: false, originalBytes };
|
|
53
|
-
if (limit === 0) return { text: "", truncated: true, originalBytes };
|
|
54
|
-
|
|
55
|
-
const marker = Buffer.from(TAIL_TRUNCATION_MARKER, "utf8");
|
|
56
|
-
if (marker.length >= limit) {
|
|
57
|
-
return {
|
|
58
|
-
text: bytes
|
|
59
|
-
.subarray(originalBytes - limit)
|
|
60
|
-
.toString("utf8")
|
|
61
|
-
.replace(/^�+/g, ""),
|
|
62
|
-
truncated: true,
|
|
63
|
-
originalBytes,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const suffix = bytes
|
|
67
|
-
.subarray(originalBytes - (limit - marker.length))
|
|
68
|
-
.toString("utf8")
|
|
69
|
-
.replace(/^�+/g, "");
|
|
70
|
-
return { text: `${TAIL_TRUNCATION_MARKER}${suffix}`, truncated: true, originalBytes };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function appendBounded(current: string, addition: string, maxBytes: number): BoundedText {
|
|
74
|
-
return truncateUtf8(current + addition, maxBytes);
|
|
75
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { SingleResult } from "./runner-types.js";
|
|
2
|
-
import type { WorkItemLedgerSnapshot } from "./work-item-ledger.js";
|
|
3
|
-
|
|
4
|
-
export interface OrchestrationMetrics {
|
|
5
|
-
workItems: number;
|
|
6
|
-
completed: number;
|
|
7
|
-
failedOrBlocked: number;
|
|
8
|
-
invalidated: number;
|
|
9
|
-
requiredTransfers: number;
|
|
10
|
-
resolvedTransfers: number;
|
|
11
|
-
transferCoverage: number;
|
|
12
|
-
attempts: number;
|
|
13
|
-
hedgedTasks: number;
|
|
14
|
-
requestedTools: number;
|
|
15
|
-
effectiveRequestedTools: number;
|
|
16
|
-
permissionPrecision: number;
|
|
17
|
-
workerReportedVerification: number;
|
|
18
|
-
executorAcceptedVerification: number;
|
|
19
|
-
verificationRework: number;
|
|
20
|
-
verificationRejected: number;
|
|
21
|
-
verificationInvalid: number;
|
|
22
|
-
verificationTreeMismatch: number;
|
|
23
|
-
panelValidReviews?: number;
|
|
24
|
-
panelFailedReviews?: number;
|
|
25
|
-
panelBlockingObjections?: number;
|
|
26
|
-
panelDissent?: number;
|
|
27
|
-
panelSynthesisState?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function calculateOrchestrationMetrics(
|
|
31
|
-
workflow: WorkItemLedgerSnapshot | undefined,
|
|
32
|
-
results: SingleResult[],
|
|
33
|
-
panel?: {
|
|
34
|
-
validReviewCount: number;
|
|
35
|
-
failedReviewCount: number;
|
|
36
|
-
blockingObjectionCount: number;
|
|
37
|
-
dissentCount: number;
|
|
38
|
-
state: string;
|
|
39
|
-
},
|
|
40
|
-
): OrchestrationMetrics {
|
|
41
|
-
const items = workflow?.items ?? [];
|
|
42
|
-
const requiredTransfers = items.reduce((sum, item) => sum + item.inputArtifacts.length, 0);
|
|
43
|
-
const resolvedTransfers = items.reduce(
|
|
44
|
-
(sum, item) => sum + Object.keys(item.inputArtifactVersions).length,
|
|
45
|
-
0,
|
|
46
|
-
);
|
|
47
|
-
const requestedTools = results.reduce(
|
|
48
|
-
(sum, result) => sum + (result.executionPlan?.requestedTools.length ?? 0),
|
|
49
|
-
0,
|
|
50
|
-
);
|
|
51
|
-
const effectiveRequestedTools = results.reduce((sum, result) => {
|
|
52
|
-
const plan = result.executionPlan;
|
|
53
|
-
if (!plan) return sum;
|
|
54
|
-
return (
|
|
55
|
-
sum +
|
|
56
|
-
plan.requestedTools.filter((tool) => plan.effectiveTools?.includes(tool) === true).length
|
|
57
|
-
);
|
|
58
|
-
}, 0);
|
|
59
|
-
return {
|
|
60
|
-
workItems: items.length,
|
|
61
|
-
completed: items.filter((item) => item.state === "completed").length,
|
|
62
|
-
failedOrBlocked: items.filter((item) =>
|
|
63
|
-
["failed", "blocked", "needs-input", "interrupted"].includes(item.state),
|
|
64
|
-
).length,
|
|
65
|
-
invalidated: items.filter((item) => ["stale", "invalidated"].includes(item.state)).length,
|
|
66
|
-
requiredTransfers,
|
|
67
|
-
resolvedTransfers,
|
|
68
|
-
transferCoverage: requiredTransfers === 0 ? 1 : resolvedTransfers / requiredTransfers,
|
|
69
|
-
attempts: results.reduce((sum, result) => sum + (result.attemptCount ?? 1), 0),
|
|
70
|
-
hedgedTasks: results.filter((result) => result.hedged).length,
|
|
71
|
-
requestedTools,
|
|
72
|
-
effectiveRequestedTools,
|
|
73
|
-
permissionPrecision: requestedTools === 0 ? 1 : effectiveRequestedTools / requestedTools,
|
|
74
|
-
workerReportedVerification: results.filter(
|
|
75
|
-
(result, index) =>
|
|
76
|
-
!items[index]?.verifierFor &&
|
|
77
|
-
result.structuredResult?.version === "pi-subagents:result:v2" &&
|
|
78
|
-
result.structuredResult.verification.some(
|
|
79
|
-
(verification) => verification.status === "passed",
|
|
80
|
-
),
|
|
81
|
-
).length,
|
|
82
|
-
executorAcceptedVerification: items.filter((item) => item.verificationAccepted).length,
|
|
83
|
-
verificationRework: items.filter(
|
|
84
|
-
(item) =>
|
|
85
|
-
!item.verifierFor &&
|
|
86
|
-
(item.verificationReceipt?.decision === "rework" ||
|
|
87
|
-
item.acceptanceReceiptHistory.some((receipt) => receipt.decision === "rework")),
|
|
88
|
-
).length,
|
|
89
|
-
verificationRejected: items.filter(
|
|
90
|
-
(item) =>
|
|
91
|
-
!item.verifierFor &&
|
|
92
|
-
(item.verificationReceipt?.decision === "reject" || item.acceptanceState === "rejected"),
|
|
93
|
-
).length,
|
|
94
|
-
verificationInvalid: items.filter(
|
|
95
|
-
(item) => !item.verifierFor && item.outcomeReason === "verification-receipt-invalid",
|
|
96
|
-
).length,
|
|
97
|
-
verificationTreeMismatch: items.filter(
|
|
98
|
-
(item) =>
|
|
99
|
-
!item.verifierFor &&
|
|
100
|
-
[
|
|
101
|
-
"verification-tree-mismatch",
|
|
102
|
-
"verification-tree-unavailable",
|
|
103
|
-
"verification-tree-drift",
|
|
104
|
-
].includes(item.outcomeReason ?? ""),
|
|
105
|
-
).length,
|
|
106
|
-
...(panel
|
|
107
|
-
? {
|
|
108
|
-
panelValidReviews: panel.validReviewCount,
|
|
109
|
-
panelFailedReviews: panel.failedReviewCount,
|
|
110
|
-
panelBlockingObjections: panel.blockingObjectionCount,
|
|
111
|
-
panelDissent: panel.dissentCount,
|
|
112
|
-
panelSynthesisState: panel.state,
|
|
113
|
-
}
|
|
114
|
-
: {}),
|
|
115
|
-
};
|
|
116
|
-
}
|
package/src/outcome.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { SubagentOutcomeStatus } from "./result-contract.js";
|
|
2
|
-
|
|
3
|
-
export interface ClassifiedSubagentOutcome {
|
|
4
|
-
status: SubagentOutcomeStatus;
|
|
5
|
-
reasonCode?: string;
|
|
6
|
-
recoveryActions: string[];
|
|
7
|
-
retryable: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const TRANSIENT_REASONS = new Set(["transient-transport", "transient-tool"]);
|
|
11
|
-
|
|
12
|
-
export function classifyStructuredOutcome(
|
|
13
|
-
status: SubagentOutcomeStatus,
|
|
14
|
-
reasonCode?: string,
|
|
15
|
-
): ClassifiedSubagentOutcome {
|
|
16
|
-
if (TRANSIENT_REASONS.has(reasonCode ?? "") && status === "failed") {
|
|
17
|
-
return {
|
|
18
|
-
status,
|
|
19
|
-
...(reasonCode ? { reasonCode } : {}),
|
|
20
|
-
recoveryActions: ["retry"],
|
|
21
|
-
retryable: true,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
const recoveryActions = recoveryFor(status, reasonCode);
|
|
25
|
-
return {
|
|
26
|
-
status,
|
|
27
|
-
...(reasonCode ? { reasonCode } : {}),
|
|
28
|
-
recoveryActions,
|
|
29
|
-
retryable: false,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function recoveryFor(status: SubagentOutcomeStatus, reasonCode?: string): string[] {
|
|
34
|
-
if (reasonCode === "missing-dependency" || reasonCode === "missing-context") {
|
|
35
|
-
return ["supply-input"];
|
|
36
|
-
}
|
|
37
|
-
if (reasonCode === "ambiguous-task") return ["clarify"];
|
|
38
|
-
if (reasonCode === "capability-mismatch" || reasonCode === "authority-missing") {
|
|
39
|
-
return ["reroute"];
|
|
40
|
-
}
|
|
41
|
-
if (reasonCode === "dependency-superseded" || status === "stale") return ["revalidate"];
|
|
42
|
-
if (reasonCode === "verification-failed") return ["replan", "verify"];
|
|
43
|
-
if (reasonCode === "unsupported-guarantee") return ["stop"];
|
|
44
|
-
switch (status) {
|
|
45
|
-
case "completed":
|
|
46
|
-
case "partial":
|
|
47
|
-
return [];
|
|
48
|
-
case "needs-input":
|
|
49
|
-
return ["supply-input"];
|
|
50
|
-
case "blocked":
|
|
51
|
-
return ["clarify"];
|
|
52
|
-
case "abstained":
|
|
53
|
-
return ["reroute"];
|
|
54
|
-
case "contract-invalid":
|
|
55
|
-
return ["repair-contract"];
|
|
56
|
-
case "interrupted":
|
|
57
|
-
return ["stop"];
|
|
58
|
-
case "failed":
|
|
59
|
-
return ["stop"];
|
|
60
|
-
}
|
|
61
|
-
}
|
package/src/panel-child-group.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { IsolatedWorkspace } from "./workspace.js";
|
|
2
|
-
import { WorkspaceManager } from "./workspace.js";
|
|
3
|
-
|
|
4
|
-
export class PanelChildGroup {
|
|
5
|
-
private readonly controller = new AbortController();
|
|
6
|
-
private readonly workspaces = new WorkspaceManager();
|
|
7
|
-
private closingStarted = false;
|
|
8
|
-
private cleanupComplete = false;
|
|
9
|
-
private readonly onParentAbort = () => this.controller.abort(this.parentSignal?.reason);
|
|
10
|
-
|
|
11
|
-
constructor(private readonly parentSignal?: AbortSignal) {
|
|
12
|
-
if (parentSignal?.aborted) this.controller.abort(parentSignal.reason);
|
|
13
|
-
else parentSignal?.addEventListener("abort", this.onParentAbort, { once: true });
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
get signal(): AbortSignal {
|
|
17
|
-
return this.controller.signal;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async createWorkspace(ownerId: string, cwd: string): Promise<IsolatedWorkspace> {
|
|
21
|
-
if (this.closingStarted) throw new Error("Panel child group is closing or closed");
|
|
22
|
-
return this.workspaces.create(ownerId, cwd);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async close(): Promise<void> {
|
|
26
|
-
if (this.cleanupComplete) return;
|
|
27
|
-
if (!this.closingStarted) {
|
|
28
|
-
this.closingStarted = true;
|
|
29
|
-
this.parentSignal?.removeEventListener("abort", this.onParentAbort);
|
|
30
|
-
if (!this.controller.signal.aborted) this.controller.abort("panel-settled");
|
|
31
|
-
}
|
|
32
|
-
await this.workspaces.cleanupAll();
|
|
33
|
-
this.cleanupComplete = true;
|
|
34
|
-
}
|
|
35
|
-
}
|