@narumitw/pi-subagents 2.1.3 → 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 +181 -1250
- 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 -1598
- 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 -153
- package/docs/pi-subagents-diagrams.md +0 -183
- package/src/adaptive-scheduler.ts +0 -224
- package/src/admission-benchmark.ts +0 -95
- 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/async-subagent-benchmark.ts +0 -532
- 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 -355
- 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
package/src/inspect.ts
DELETED
|
@@ -1,769 +0,0 @@
|
|
|
1
|
-
import * as path from "node:path";
|
|
2
|
-
import { CONFIG_DIR_NAME, type ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { discoverAgents } from "./agents/discovery.js";
|
|
4
|
-
import type {
|
|
5
|
-
AgentConfig,
|
|
6
|
-
AgentScope,
|
|
7
|
-
ConsultationCwdPolicy,
|
|
8
|
-
DelegationCwdPolicy,
|
|
9
|
-
} from "./agents/types.js";
|
|
10
|
-
import { projectCapabilityManifest } from "./capabilities.js";
|
|
11
|
-
import { resolveConsultTools } from "./consult-policy.js";
|
|
12
|
-
import { buildContextSnapshot, type ContextMode } from "./context.js";
|
|
13
|
-
import { INSPECT_ACTIONS } from "./inspect-tool.js";
|
|
14
|
-
import { DEFAULT_MAX_CONTEXT_BYTES } from "./limits.js";
|
|
15
|
-
import { resolvePiInvocation } from "./pi-invocation.js";
|
|
16
|
-
import type { AgentRunInspectionDetail, AgentRunInspectionSummary } from "./registry.js";
|
|
17
|
-
import { boundedPrivateText, boundText, safeDisplayPath, safeTerminalLine } from "./safe-text.js";
|
|
18
|
-
import { resolveDelegationWorkflow } from "./settings/inspection.js";
|
|
19
|
-
import {
|
|
20
|
-
inspectBlockingParallelLimitSettings,
|
|
21
|
-
inspectCompletionDeliverySettings,
|
|
22
|
-
inspectConsultResourceSettings,
|
|
23
|
-
inspectCwdPolicySettings,
|
|
24
|
-
inspectDelegationWorkflowSettings,
|
|
25
|
-
inspectStatefulLimitSettings,
|
|
26
|
-
inspectStatefulTransportSettings,
|
|
27
|
-
inspectSubagentSettings,
|
|
28
|
-
inspectUsageRecordingSettings,
|
|
29
|
-
} from "./settings.js";
|
|
30
|
-
import type { StatefulSubagentRuntimeStatus } from "./stateful.js";
|
|
31
|
-
import type { UsageRecordingStatus } from "./usage-recording.js";
|
|
32
|
-
import type { WorkItemLedgerSnapshot } from "./work-item-ledger.js";
|
|
33
|
-
import { inspectSessionWorkflows } from "./work-item-persistence.js";
|
|
34
|
-
|
|
35
|
-
const MAX_DETAILS_LIST_BYTES = 40 * 1024;
|
|
36
|
-
|
|
37
|
-
export { registerSubagentInspect } from "./inspect-registration.js";
|
|
38
|
-
export { SubagentInspectParams } from "./inspect-tool.js";
|
|
39
|
-
|
|
40
|
-
export interface SubagentInspectRuntime {
|
|
41
|
-
getBlockingEnabled(): boolean;
|
|
42
|
-
getMaxParallelTasks(): number;
|
|
43
|
-
getConsultResourcePolicy(): "project-context" | "none" | "all";
|
|
44
|
-
getConsultationCwdPolicy(): ConsultationCwdPolicy;
|
|
45
|
-
getDelegationCwdPolicy(): DelegationCwdPolicy;
|
|
46
|
-
getUsageRecordingStatus?(): UsageRecordingStatus;
|
|
47
|
-
getRuntimeStatus(): StatefulSubagentRuntimeStatus;
|
|
48
|
-
listRunInspection(includeClosed?: boolean): AgentRunInspectionSummary[];
|
|
49
|
-
getRunInspection(agentId: string): AgentRunInspectionDetail | undefined;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface InspectToolResult {
|
|
53
|
-
content: Array<{ type: "text"; text: string }>;
|
|
54
|
-
details: Record<string, unknown>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type ValidatedInspectOperation =
|
|
58
|
-
| { action: "list_agents"; agentScope: AgentScope; limit: number }
|
|
59
|
-
| { action: "get_agent"; agent: string; agentScope: AgentScope }
|
|
60
|
-
| { action: "list_runs"; includeClosed: boolean; limit: number }
|
|
61
|
-
| { action: "get_run"; agentId: string }
|
|
62
|
-
| { action: "list_workflows"; limit: number }
|
|
63
|
-
| { action: "get_workflow"; workflowId: string }
|
|
64
|
-
| { action: "list_models"; limit: number }
|
|
65
|
-
| { action: "preview_context"; context: ContextMode; contextEntryIds?: string[] }
|
|
66
|
-
| { action: "status" }
|
|
67
|
-
| { action: "diagnose" };
|
|
68
|
-
|
|
69
|
-
export function validateInspectParams(params: unknown): ValidatedInspectOperation {
|
|
70
|
-
const values = parameterRecord(params);
|
|
71
|
-
const rawAction = values.action;
|
|
72
|
-
if (
|
|
73
|
-
typeof rawAction !== "string" ||
|
|
74
|
-
!INSPECT_ACTIONS.includes(rawAction as (typeof INSPECT_ACTIONS)[number])
|
|
75
|
-
) {
|
|
76
|
-
throw new Error(`subagent_inspect action must be one of: ${INSPECT_ACTIONS.join(", ")}`);
|
|
77
|
-
}
|
|
78
|
-
const action = rawAction as (typeof INSPECT_ACTIONS)[number];
|
|
79
|
-
const allowed: Record<(typeof INSPECT_ACTIONS)[number], readonly string[]> = {
|
|
80
|
-
list_agents: ["action", "agentScope", "limit"],
|
|
81
|
-
get_agent: ["action", "agent", "agentScope"],
|
|
82
|
-
list_runs: ["action", "includeClosed", "limit"],
|
|
83
|
-
get_run: ["action", "agentId"],
|
|
84
|
-
list_workflows: ["action", "limit"],
|
|
85
|
-
get_workflow: ["action", "workflowId"],
|
|
86
|
-
list_models: ["action", "limit"],
|
|
87
|
-
preview_context: ["action", "context", "contextEntryIds"],
|
|
88
|
-
status: ["action"],
|
|
89
|
-
diagnose: ["action"],
|
|
90
|
-
};
|
|
91
|
-
const unexpected = Object.keys(values).find(
|
|
92
|
-
(key) => values[key] !== undefined && !allowed[action].includes(key),
|
|
93
|
-
);
|
|
94
|
-
if (unexpected)
|
|
95
|
-
throw new Error(`subagent_inspect action "${action}" does not accept ${unexpected}`);
|
|
96
|
-
|
|
97
|
-
if (action === "list_agents" || action === "get_agent") {
|
|
98
|
-
const agentScope = optionalAgentScope(values.agentScope);
|
|
99
|
-
if (action === "get_agent") {
|
|
100
|
-
return { action, agent: requiredString(values.agent, action, "agent"), agentScope };
|
|
101
|
-
}
|
|
102
|
-
return { action, agentScope, limit: optionalLimit(values.limit, 32) };
|
|
103
|
-
}
|
|
104
|
-
if (action === "list_runs") {
|
|
105
|
-
if (values.includeClosed !== undefined && typeof values.includeClosed !== "boolean") {
|
|
106
|
-
throw new Error('subagent_inspect action "list_runs" requires includeClosed to be boolean');
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
action,
|
|
110
|
-
includeClosed: values.includeClosed === true,
|
|
111
|
-
limit: optionalLimit(values.limit, 50),
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
if (action === "get_run") {
|
|
115
|
-
return { action, agentId: requiredString(values.agentId, action, "agentId") };
|
|
116
|
-
}
|
|
117
|
-
if (action === "list_workflows") {
|
|
118
|
-
return { action, limit: optionalLimit(values.limit, 50) };
|
|
119
|
-
}
|
|
120
|
-
if (action === "get_workflow") {
|
|
121
|
-
return { action, workflowId: requiredString(values.workflowId, action, "workflowId") };
|
|
122
|
-
}
|
|
123
|
-
if (action === "list_models") {
|
|
124
|
-
return { action, limit: optionalLimit(values.limit, 50) };
|
|
125
|
-
}
|
|
126
|
-
if (action === "preview_context") {
|
|
127
|
-
const context = optionalContextMode(values.context);
|
|
128
|
-
const contextEntryIds = optionalStringArray(values.contextEntryIds, "contextEntryIds");
|
|
129
|
-
return {
|
|
130
|
-
action,
|
|
131
|
-
context: values.context === undefined && contextEntryIds ? "all" : context,
|
|
132
|
-
...(contextEntryIds ? { contextEntryIds } : {}),
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
return { action };
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export async function executeSubagentInspect(
|
|
139
|
-
params: unknown,
|
|
140
|
-
ctx: ExtensionContext,
|
|
141
|
-
runtime: SubagentInspectRuntime,
|
|
142
|
-
): Promise<InspectToolResult> {
|
|
143
|
-
const operation = validateInspectParams(params);
|
|
144
|
-
if (operation.action === "list_agents" || operation.action === "get_agent") {
|
|
145
|
-
assertTrustedScope(operation.agentScope, ctx);
|
|
146
|
-
const settings = inspectSubagentSettings().settings;
|
|
147
|
-
const discovery = discoverAgents(ctx.cwd, operation.agentScope, settings);
|
|
148
|
-
const agents = [...discovery.agents].sort((left, right) =>
|
|
149
|
-
left.name === right.name
|
|
150
|
-
? left.source.localeCompare(right.source)
|
|
151
|
-
: left.name.localeCompare(right.name),
|
|
152
|
-
);
|
|
153
|
-
if (operation.action === "list_agents") {
|
|
154
|
-
const selected = boundedProjection(agents, operation.limit, (agent) =>
|
|
155
|
-
projectAgent(agent, ctx, false),
|
|
156
|
-
);
|
|
157
|
-
return inspectResult({
|
|
158
|
-
action: operation.action,
|
|
159
|
-
agents: selected.items,
|
|
160
|
-
returned: selected.items.length,
|
|
161
|
-
omitted: selected.omitted + (discovery.omittedAgentDefinitions ?? 0),
|
|
162
|
-
discoveryIncomplete: discovery.metadataDiscoveryIncomplete === true,
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
const agent = agents.find((candidate) => candidate.name === operation.agent);
|
|
166
|
-
if (!agent) {
|
|
167
|
-
throw new Error(`Unknown subagent definition: ${boundedPrivateText(operation.agent, 256)}`);
|
|
168
|
-
}
|
|
169
|
-
return inspectResult({ action: operation.action, agent: projectAgent(agent, ctx) });
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (operation.action === "list_runs") {
|
|
173
|
-
const runs = runtime.listRunInspection(operation.includeClosed);
|
|
174
|
-
const selected = boundedProjection(runs, operation.limit, projectRunSummary);
|
|
175
|
-
return inspectResult({
|
|
176
|
-
action: operation.action,
|
|
177
|
-
runs: selected.items,
|
|
178
|
-
returned: selected.items.length,
|
|
179
|
-
omitted: selected.omitted,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
if (operation.action === "get_run") {
|
|
183
|
-
const run = runtime.getRunInspection(operation.agentId);
|
|
184
|
-
if (!run) {
|
|
185
|
-
throw new Error(`Unknown retained run: ${boundedPrivateText(operation.agentId, 256)}`);
|
|
186
|
-
}
|
|
187
|
-
return inspectResult({ action: operation.action, run: projectRun(run, ctx) });
|
|
188
|
-
}
|
|
189
|
-
if (operation.action === "list_workflows" || operation.action === "get_workflow") {
|
|
190
|
-
const owner =
|
|
191
|
-
ctx.sessionManager.getSessionId?.() ??
|
|
192
|
-
ctx.sessionManager.getSessionFile?.() ??
|
|
193
|
-
`ephemeral:${ctx.cwd}`;
|
|
194
|
-
const inspected = inspectSessionWorkflows(owner, {
|
|
195
|
-
maxStoredWorkflows: operation.action === "list_workflows" ? operation.limit : 64,
|
|
196
|
-
});
|
|
197
|
-
if (operation.action === "list_workflows") {
|
|
198
|
-
const selected = boundedProjection(
|
|
199
|
-
inspected.workflows,
|
|
200
|
-
operation.limit,
|
|
201
|
-
projectWorkflowSummary,
|
|
202
|
-
);
|
|
203
|
-
return inspectResult({
|
|
204
|
-
action: operation.action,
|
|
205
|
-
workflows: selected.items,
|
|
206
|
-
returned: selected.items.length,
|
|
207
|
-
omitted: inspected.omitted + selected.omitted,
|
|
208
|
-
invalid: inspected.invalid,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
const workflow = inspected.workflows.find(
|
|
212
|
-
(candidate) => candidate.workflowId === operation.workflowId,
|
|
213
|
-
);
|
|
214
|
-
if (!workflow) {
|
|
215
|
-
throw new Error(
|
|
216
|
-
`Unknown persisted workflow: ${boundedPrivateText(operation.workflowId, 256)}`,
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
return inspectResult({ action: operation.action, workflow: projectWorkflow(workflow) });
|
|
220
|
-
}
|
|
221
|
-
if (operation.action === "list_models") {
|
|
222
|
-
return inspectResult({ action: operation.action, ...projectModels(ctx, operation.limit) });
|
|
223
|
-
}
|
|
224
|
-
if (operation.action === "preview_context") {
|
|
225
|
-
const snapshot = buildContextSnapshot(
|
|
226
|
-
ctx.sessionManager.getBranch(),
|
|
227
|
-
operation.context,
|
|
228
|
-
DEFAULT_MAX_CONTEXT_BYTES,
|
|
229
|
-
operation.contextEntryIds,
|
|
230
|
-
);
|
|
231
|
-
return inspectResult({
|
|
232
|
-
action: operation.action,
|
|
233
|
-
preview: {
|
|
234
|
-
mode: operation.context,
|
|
235
|
-
turns: snapshot.turns,
|
|
236
|
-
sourceCount: snapshot.sourceIds.length,
|
|
237
|
-
bytes: Buffer.byteLength(snapshot.text, "utf8"),
|
|
238
|
-
truncated: snapshot.truncated,
|
|
239
|
-
},
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
if (operation.action === "status") {
|
|
243
|
-
return inspectResult({ action: operation.action, status: projectStatus(runtime) });
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const settings = inspectSubagentSettings();
|
|
247
|
-
const userDiscovery = discoverAgents(ctx.cwd, "user", settings.settings);
|
|
248
|
-
const modelCount = availableModelCount(ctx);
|
|
249
|
-
const runtimeStatus = runtime.getRuntimeStatus();
|
|
250
|
-
const rpcCapability = inspectRpcCapability();
|
|
251
|
-
const inProcessCapability = await inspectInProcessCapability();
|
|
252
|
-
const checks = [
|
|
253
|
-
{
|
|
254
|
-
name: "settings",
|
|
255
|
-
status: settings.error ? "fail" : "pass",
|
|
256
|
-
message: settings.error
|
|
257
|
-
? boundedPrivateText(settings.error, 2 * 1024)
|
|
258
|
-
: "Settings are valid or absent.",
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
name: "agent-discovery",
|
|
262
|
-
status:
|
|
263
|
-
userDiscovery.metadataDiscoveryIncomplete ||
|
|
264
|
-
(userDiscovery.omittedAgentDefinitions ?? 0) > 0
|
|
265
|
-
? "warning"
|
|
266
|
-
: "pass",
|
|
267
|
-
message: `${userDiscovery.agents.length} user-scope definitions available.`,
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
name: "models",
|
|
271
|
-
status: modelCount > 0 ? "pass" : "fail",
|
|
272
|
-
message: `${modelCount} session-usable models available.`,
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: "runtime",
|
|
276
|
-
status: runtimeStatus.enabled && !runtimeStatus.initialized ? "warning" : "pass",
|
|
277
|
-
message: runtimeStatus.initialized
|
|
278
|
-
? "Stateful runtime initialized."
|
|
279
|
-
: "Stateful runtime not initialized.",
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
name: "in-process-sdk",
|
|
283
|
-
status: inProcessCapability.error ? "fail" : "pass",
|
|
284
|
-
message: inProcessCapability.error
|
|
285
|
-
? boundedPrivateText(inProcessCapability.error, 2 * 1024)
|
|
286
|
-
: "Required public Pi in-process session APIs are available.",
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
name: "rpc-cli",
|
|
290
|
-
status: rpcCapability.error ? "fail" : "pass",
|
|
291
|
-
message: rpcCapability.error
|
|
292
|
-
? boundedPrivateText(rpcCapability.error, 2 * 1024)
|
|
293
|
-
: "The exact loaded Pi CLI is available for persistent RPC transport.",
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
name: "consultation",
|
|
297
|
-
status: runtime.getBlockingEnabled() && modelCount > 0 ? "pass" : "fail",
|
|
298
|
-
message: runtime.getBlockingEnabled()
|
|
299
|
-
? modelCount > 0
|
|
300
|
-
? "Read-only consultation is supported."
|
|
301
|
-
: "Consultation has no available model."
|
|
302
|
-
: "Blocking delegation is disabled, so consultation is not registered.",
|
|
303
|
-
},
|
|
304
|
-
] as const;
|
|
305
|
-
return inspectResult({
|
|
306
|
-
action: operation.action,
|
|
307
|
-
checks,
|
|
308
|
-
ok: checks.every((check) => check.status !== "fail"),
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
function projectAgent(
|
|
313
|
-
agent: AgentConfig,
|
|
314
|
-
ctx: ExtensionContext,
|
|
315
|
-
includeTools = true,
|
|
316
|
-
): Record<string, unknown> {
|
|
317
|
-
const tools = agent.tools === undefined ? undefined : projectToolNames(agent.tools);
|
|
318
|
-
return {
|
|
319
|
-
name: boundedPrivateText(agent.name, 256),
|
|
320
|
-
description: boundedPrivateText(agent.description, 256),
|
|
321
|
-
source: agent.source,
|
|
322
|
-
scope: agent.source === "project" ? "project" : "user",
|
|
323
|
-
path:
|
|
324
|
-
agent.source === "project"
|
|
325
|
-
? safeTerminalLine(
|
|
326
|
-
path.posix.join(CONFIG_DIR_NAME, "agents", path.basename(agent.filePath)),
|
|
327
|
-
)
|
|
328
|
-
: safeDisplayPath(agent.filePath, ctx.cwd),
|
|
329
|
-
model: agent.model ? boundedPrivateText(agent.model, 256) : undefined,
|
|
330
|
-
thinkingLevel: agent.thinkingLevel,
|
|
331
|
-
capabilityManifest: projectCapabilityManifest(agent.capabilityManifest),
|
|
332
|
-
...(includeTools
|
|
333
|
-
? { tools, toolCount: agent.tools?.length }
|
|
334
|
-
: { toolCount: agent.tools?.length }),
|
|
335
|
-
consultTools: resolveConsultTools(agent.tools),
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function projectRunSummary(run: AgentRunInspectionSummary): Record<string, unknown> {
|
|
340
|
-
return {
|
|
341
|
-
id: boundedPrivateText(run.id, 256),
|
|
342
|
-
agent: boundedPrivateText(run.agent, 256),
|
|
343
|
-
state: run.state,
|
|
344
|
-
createdAt: run.createdAt,
|
|
345
|
-
updatedAt: run.updatedAt,
|
|
346
|
-
historyCount: run.historyCount,
|
|
347
|
-
unreadMessages: run.unreadMessages,
|
|
348
|
-
turnGeneration: run.turnGeneration,
|
|
349
|
-
pendingCompletionCount: run.pendingCompletionCount,
|
|
350
|
-
...(run.pendingRequiredCompletionCount === undefined
|
|
351
|
-
? {}
|
|
352
|
-
: { pendingRequiredCompletionCount: run.pendingRequiredCompletionCount }),
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
function projectRun(run: AgentRunInspectionDetail, ctx: ExtensionContext): Record<string, unknown> {
|
|
357
|
-
return {
|
|
358
|
-
...projectRunSummary(run),
|
|
359
|
-
cwd: safeDisplayPath(run.cwd, ctx.cwd),
|
|
360
|
-
workspaceMode: run.workspaceMode ?? "shared",
|
|
361
|
-
thinkingLevel: run.thinkingLevel,
|
|
362
|
-
timeoutMs: run.timeoutMs,
|
|
363
|
-
currentTimeoutMs: run.currentTimeoutMs,
|
|
364
|
-
idleTimeoutMs: run.idleTimeoutMs,
|
|
365
|
-
currentIdleTimeoutMs: run.currentIdleTimeoutMs,
|
|
366
|
-
maxTurns: run.maxTurns,
|
|
367
|
-
currentMaxTurns: run.currentMaxTurns,
|
|
368
|
-
maxToolCalls: run.maxToolCalls,
|
|
369
|
-
currentMaxToolCalls: run.currentMaxToolCalls,
|
|
370
|
-
context: {
|
|
371
|
-
turns: run.contextTurns ?? 0,
|
|
372
|
-
sources: run.contextSources ?? 0,
|
|
373
|
-
bytes: run.contextBytes ?? 0,
|
|
374
|
-
truncated: run.contextTruncated === true,
|
|
375
|
-
},
|
|
376
|
-
contract: run.contract
|
|
377
|
-
? {
|
|
378
|
-
version: run.contract.version,
|
|
379
|
-
level: run.contract.level,
|
|
380
|
-
taskId: boundedPrivateText(run.contract.taskId, 256),
|
|
381
|
-
enforcement: run.contract.enforcement,
|
|
382
|
-
dependencies: run.contract.dependencies.length,
|
|
383
|
-
acceptanceCriteria: run.contract.acceptanceCriteria.length,
|
|
384
|
-
requiredEvidence: run.contract.requiredEvidence.length,
|
|
385
|
-
}
|
|
386
|
-
: undefined,
|
|
387
|
-
resultFormat: run.resultFormat ?? "text",
|
|
388
|
-
completionRequirements: (run.completionRequirements ?? []).map((requirement) => ({
|
|
389
|
-
...requirement,
|
|
390
|
-
})),
|
|
391
|
-
structuredResult: run.structuredResult,
|
|
392
|
-
termination: run.termination,
|
|
393
|
-
outcome: run.outcome,
|
|
394
|
-
capabilityGrant: run.capabilityGrant
|
|
395
|
-
? {
|
|
396
|
-
version: run.capabilityGrant.version,
|
|
397
|
-
id: run.capabilityGrant.id,
|
|
398
|
-
executionPlanId: run.capabilityGrant.executionPlanId,
|
|
399
|
-
taskGeneration: run.capabilityGrant.taskGeneration,
|
|
400
|
-
issuedAt: run.capabilityGrant.issuedAt,
|
|
401
|
-
expiresAt: run.capabilityGrant.expiresAt,
|
|
402
|
-
state: run.capabilityGrant.state,
|
|
403
|
-
revokedAt: run.capabilityGrant.revokedAt,
|
|
404
|
-
revocationReason: run.capabilityGrant.revocationReason,
|
|
405
|
-
}
|
|
406
|
-
: undefined,
|
|
407
|
-
executionPlan: run.executionPlan
|
|
408
|
-
? {
|
|
409
|
-
...run.executionPlan,
|
|
410
|
-
target: {
|
|
411
|
-
...run.executionPlan.target,
|
|
412
|
-
cwd: safeDisplayPath(run.executionPlan.target.cwd, ctx.cwd),
|
|
413
|
-
trust: { ...run.executionPlan.target.trust, sourcePath: undefined },
|
|
414
|
-
},
|
|
415
|
-
}
|
|
416
|
-
: undefined,
|
|
417
|
-
semanticSnapshot: run.semanticSnapshot
|
|
418
|
-
? {
|
|
419
|
-
version: run.semanticSnapshot.version,
|
|
420
|
-
digest: run.semanticSnapshot.digest,
|
|
421
|
-
components: { ...run.semanticSnapshot.components },
|
|
422
|
-
}
|
|
423
|
-
: undefined,
|
|
424
|
-
semanticCompatibility: run.semanticCompatibility,
|
|
425
|
-
telemetry: run.telemetry,
|
|
426
|
-
currentRunId: run.currentRunId,
|
|
427
|
-
currentTurnGeneration: run.currentTurnGeneration,
|
|
428
|
-
currentTask: run.currentTask ? boundedPrivateText(run.currentTask, 2 * 1024) : undefined,
|
|
429
|
-
error: run.error ? boundedPrivateText(run.error, 2 * 1024) : undefined,
|
|
430
|
-
target: run.target
|
|
431
|
-
? {
|
|
432
|
-
cwd: safeDisplayPath(run.target.cwd, ctx.cwd),
|
|
433
|
-
boundary: run.target.boundary,
|
|
434
|
-
trust: {
|
|
435
|
-
kind: run.target.trust.kind,
|
|
436
|
-
projectTrusted: run.target.trust.projectTrusted,
|
|
437
|
-
sourcePath: run.target.trust.sourcePath
|
|
438
|
-
? safeDisplayPath(run.target.trust.sourcePath, ctx.cwd)
|
|
439
|
-
: undefined,
|
|
440
|
-
warning: run.target.trust.warning
|
|
441
|
-
? boundedPrivateText(run.target.trust.warning, 512)
|
|
442
|
-
: undefined,
|
|
443
|
-
},
|
|
444
|
-
}
|
|
445
|
-
: undefined,
|
|
446
|
-
policy: run.policy
|
|
447
|
-
? {
|
|
448
|
-
inherited: projectToolNames(run.policy.inherited),
|
|
449
|
-
overridden: projectToolNames(run.policy.overridden),
|
|
450
|
-
unsupported: projectToolNames(run.policy.unsupported),
|
|
451
|
-
}
|
|
452
|
-
: undefined,
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function projectWorkflowSummary(workflow: WorkItemLedgerSnapshot): Record<string, unknown> {
|
|
457
|
-
return {
|
|
458
|
-
workflowId: boundedPrivateText(workflow.workflowId, 256),
|
|
459
|
-
generation: workflow.generation,
|
|
460
|
-
itemCount: workflow.items.length,
|
|
461
|
-
states: Object.fromEntries(
|
|
462
|
-
[...new Set(workflow.items.map((item) => item.state))]
|
|
463
|
-
.sort()
|
|
464
|
-
.map((state) => [state, workflow.items.filter((item) => item.state === state).length]),
|
|
465
|
-
),
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
function projectWorkflow(workflow: WorkItemLedgerSnapshot): Record<string, unknown> {
|
|
470
|
-
const projected = boundedProjection(workflow.items, 64, (item) => ({
|
|
471
|
-
id: boundedPrivateText(item.id, 256),
|
|
472
|
-
state: item.state,
|
|
473
|
-
generation: item.generation,
|
|
474
|
-
taskGeneration: item.taskGeneration,
|
|
475
|
-
dependencies: item.dependencies.map((value) => boundedPrivateText(value, 256)),
|
|
476
|
-
assignedAgentId: item.assignedAgentId
|
|
477
|
-
? boundedPrivateText(item.assignedAgentId, 256)
|
|
478
|
-
: undefined,
|
|
479
|
-
acceptedExecutionPlanId: item.acceptedExecutionPlanId,
|
|
480
|
-
artifacts: item.artifacts.map((artifact) => ({
|
|
481
|
-
id: boundedPrivateText(artifact.id, 256),
|
|
482
|
-
kind: boundedPrivateText(artifact.kind, 256),
|
|
483
|
-
version: boundedPrivateText(artifact.version, 256),
|
|
484
|
-
producerTaskId: artifact.producerTaskId
|
|
485
|
-
? boundedPrivateText(artifact.producerTaskId, 256)
|
|
486
|
-
: undefined,
|
|
487
|
-
generation: artifact.generation,
|
|
488
|
-
verified: artifact.verified,
|
|
489
|
-
})),
|
|
490
|
-
verificationAccepted: item.verificationAccepted,
|
|
491
|
-
acceptanceStateVersion: item.acceptanceStateVersion,
|
|
492
|
-
acceptanceRequired: item.acceptanceRequired,
|
|
493
|
-
acceptanceState: item.acceptanceState,
|
|
494
|
-
reworkCount: item.reworkCount,
|
|
495
|
-
maxReworkCycles: item.maxReworkCycles,
|
|
496
|
-
acceptanceReceipt: item.acceptanceReceipt
|
|
497
|
-
? {
|
|
498
|
-
version: item.acceptanceReceipt.version,
|
|
499
|
-
decision: item.acceptanceReceipt.decision,
|
|
500
|
-
targetTaskId: boundedPrivateText(item.acceptanceReceipt.targetTaskId, 256),
|
|
501
|
-
targetTaskGeneration: item.acceptanceReceipt.targetTaskGeneration,
|
|
502
|
-
targetExecutionPlanId: item.acceptanceReceipt.targetExecutionPlanId,
|
|
503
|
-
verifierTaskId: boundedPrivateText(item.acceptanceReceipt.verifierTaskId, 256),
|
|
504
|
-
verifierTaskGeneration: item.acceptanceReceipt.verifierTaskGeneration,
|
|
505
|
-
verifierExecutionPlanId: item.acceptanceReceipt.verifierExecutionPlanId,
|
|
506
|
-
verifierAgent: boundedPrivateText(item.acceptanceReceipt.verifierAgent, 256),
|
|
507
|
-
beforeTreeIdentity: item.acceptanceReceipt.beforeTreeIdentity,
|
|
508
|
-
afterTreeIdentity: item.acceptanceReceipt.afterTreeIdentity,
|
|
509
|
-
patchDigest: item.acceptanceReceipt.patchDigest,
|
|
510
|
-
changedPathCount: item.acceptanceReceipt.changedPaths.length,
|
|
511
|
-
checkCount: item.acceptanceReceipt.checks.length,
|
|
512
|
-
requiredEvidenceCount: item.acceptanceReceipt.requiredEvidenceIds.length,
|
|
513
|
-
createdAt: item.acceptanceReceipt.createdAt,
|
|
514
|
-
sourceTruncated: item.acceptanceReceipt.sourceTruncated,
|
|
515
|
-
}
|
|
516
|
-
: undefined,
|
|
517
|
-
acceptanceReceiptHistoryCount: item.acceptanceReceiptHistory.length,
|
|
518
|
-
stagedTreeIdentity: item.stagedTreeIdentity
|
|
519
|
-
? {
|
|
520
|
-
version: item.stagedTreeIdentity.version,
|
|
521
|
-
kind: item.stagedTreeIdentity.kind,
|
|
522
|
-
digest: item.stagedTreeIdentity.digest,
|
|
523
|
-
}
|
|
524
|
-
: undefined,
|
|
525
|
-
verificationReceipt: item.verificationReceipt
|
|
526
|
-
? {
|
|
527
|
-
version: item.verificationReceipt.version,
|
|
528
|
-
decision: item.verificationReceipt.decision,
|
|
529
|
-
targetTaskId: boundedPrivateText(item.verificationReceipt.targetTaskId, 256),
|
|
530
|
-
targetTaskGeneration: item.verificationReceipt.targetTaskGeneration,
|
|
531
|
-
targetExecutionPlanId: item.verificationReceipt.targetExecutionPlanId,
|
|
532
|
-
verifierTaskId: boundedPrivateText(item.verificationReceipt.verifierTaskId, 256),
|
|
533
|
-
verifierTaskGeneration: item.verificationReceipt.verifierTaskGeneration,
|
|
534
|
-
verifierExecutionPlanId: item.verificationReceipt.verifierExecutionPlanId,
|
|
535
|
-
treeIdentity: item.verificationReceipt.treeIdentity,
|
|
536
|
-
summary: boundedPrivateText(item.verificationReceipt.summary, 8 * 1024),
|
|
537
|
-
evidenceCount: item.verificationReceipt.evidence.length,
|
|
538
|
-
limitationCount: item.verificationReceipt.limitations.length,
|
|
539
|
-
createdAt: item.verificationReceipt.createdAt,
|
|
540
|
-
truncated: item.verificationReceipt.truncated,
|
|
541
|
-
}
|
|
542
|
-
: undefined,
|
|
543
|
-
outcomeReason: item.outcomeReason
|
|
544
|
-
? boundedPrivateText(item.outcomeReason, 2 * 1024)
|
|
545
|
-
: undefined,
|
|
546
|
-
}));
|
|
547
|
-
return {
|
|
548
|
-
...projectWorkflowSummary(workflow),
|
|
549
|
-
items: projected.items,
|
|
550
|
-
omittedItems: projected.omitted,
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
function projectModels(ctx: ExtensionContext, limit: number): Record<string, unknown> {
|
|
555
|
-
const scoped = ctx.scopedModels ?? [];
|
|
556
|
-
const candidates =
|
|
557
|
-
scoped.length > 0
|
|
558
|
-
? scoped
|
|
559
|
-
: ctx.modelRegistry.getAvailable().map((model) => ({ model, thinkingLevel: undefined }));
|
|
560
|
-
const selected = boundedProjection(candidates, limit, ({ model, thinkingLevel }) => ({
|
|
561
|
-
provider: boundedPrivateText(model.provider, 256),
|
|
562
|
-
id: boundedPrivateText(model.id, 256),
|
|
563
|
-
name: boundedPrivateText(model.name, 256),
|
|
564
|
-
reasoning: model.reasoning,
|
|
565
|
-
input: [...model.input],
|
|
566
|
-
contextWindow: model.contextWindow,
|
|
567
|
-
maxTokens: model.maxTokens,
|
|
568
|
-
thinkingLevel,
|
|
569
|
-
current: ctx.model?.provider === model.provider && ctx.model?.id === model.id,
|
|
570
|
-
}));
|
|
571
|
-
return {
|
|
572
|
-
models: selected.items,
|
|
573
|
-
returned: selected.items.length,
|
|
574
|
-
omitted: selected.omitted,
|
|
575
|
-
source: scoped.length > 0 ? "session scope" : "available snapshot",
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
|
|
579
|
-
function projectStatus(runtime: SubagentInspectRuntime): Record<string, unknown> {
|
|
580
|
-
const stateful = runtime.getRuntimeStatus();
|
|
581
|
-
const workflow = resolveDelegationWorkflow(runtime.getBlockingEnabled(), stateful.enabled);
|
|
582
|
-
const configured = inspectDelegationWorkflowSettings();
|
|
583
|
-
const resources = inspectConsultResourceSettings();
|
|
584
|
-
const cwdPolicy = inspectCwdPolicySettings();
|
|
585
|
-
const completion = inspectCompletionDeliverySettings();
|
|
586
|
-
const parallelLimit = inspectBlockingParallelLimitSettings();
|
|
587
|
-
const detachedLimits = inspectStatefulLimitSettings();
|
|
588
|
-
const transport = inspectStatefulTransportSettings();
|
|
589
|
-
const usageRecording = inspectUsageRecordingSettings();
|
|
590
|
-
const usageStatus = runtime.getUsageRecordingStatus?.();
|
|
591
|
-
const configuredDetachedLimits = detachedLimits.values
|
|
592
|
-
? Object.fromEntries(
|
|
593
|
-
Object.entries(detachedLimits.values).map(([field, snapshot]) => [field, snapshot.value]),
|
|
594
|
-
)
|
|
595
|
-
: undefined;
|
|
596
|
-
const configuredDetachedLimitSources = detachedLimits.values
|
|
597
|
-
? Object.fromEntries(
|
|
598
|
-
Object.entries(detachedLimits.values).map(([field, snapshot]) => [field, snapshot.source]),
|
|
599
|
-
)
|
|
600
|
-
: undefined;
|
|
601
|
-
return {
|
|
602
|
-
workflow,
|
|
603
|
-
configuredWorkflow: configured.value,
|
|
604
|
-
configuredWorkflowSource: configured.source,
|
|
605
|
-
stateful,
|
|
606
|
-
statefulLimits: stateful.limits,
|
|
607
|
-
configuredTransport: transport.value,
|
|
608
|
-
configuredTransportSource: transport.source,
|
|
609
|
-
configuredStatefulLimits: configuredDetachedLimits,
|
|
610
|
-
configuredStatefulLimitSources: configuredDetachedLimitSources,
|
|
611
|
-
configuredCompletionDelivery: completion.value,
|
|
612
|
-
configuredCompletionDeliverySource: completion.source,
|
|
613
|
-
usageRecording: usageStatus
|
|
614
|
-
? {
|
|
615
|
-
enabled: usageStatus.enabled,
|
|
616
|
-
retentionDays: usageStatus.retentionDays,
|
|
617
|
-
recordedEvents: usageStatus.recordedEvents,
|
|
618
|
-
writeFailure: usageStatus.writeFailure,
|
|
619
|
-
}
|
|
620
|
-
: { enabled: false },
|
|
621
|
-
configuredUsageRecording: usageRecording.enabled,
|
|
622
|
-
configuredUsageRecordingSource: usageRecording.source,
|
|
623
|
-
maxParallelTasks: runtime.getMaxParallelTasks(),
|
|
624
|
-
configuredMaxParallelTasks: parallelLimit.value,
|
|
625
|
-
configuredMaxParallelTasksSource: parallelLimit.source,
|
|
626
|
-
consultResources: runtime.getConsultResourcePolicy(),
|
|
627
|
-
consultationCwdPolicy: runtime.getConsultationCwdPolicy(),
|
|
628
|
-
configuredConsultationCwdPolicy: cwdPolicy.consultation.value,
|
|
629
|
-
consultationCwdPolicySource: cwdPolicy.consultation.source,
|
|
630
|
-
delegationCwdPolicy: runtime.getDelegationCwdPolicy(),
|
|
631
|
-
configuredDelegationCwdPolicy: cwdPolicy.delegation.value,
|
|
632
|
-
delegationCwdPolicySource: cwdPolicy.delegation.source,
|
|
633
|
-
configuredConsultResources: resources.value,
|
|
634
|
-
consultResourcesSource: resources.source,
|
|
635
|
-
settingsPath: safeDisplayPath(resources.path, process.cwd()),
|
|
636
|
-
settingsError:
|
|
637
|
-
configured.error ||
|
|
638
|
-
resources.error ||
|
|
639
|
-
cwdPolicy.error ||
|
|
640
|
-
completion.error ||
|
|
641
|
-
parallelLimit.error ||
|
|
642
|
-
detachedLimits.error ||
|
|
643
|
-
transport.error ||
|
|
644
|
-
usageRecording.error
|
|
645
|
-
? boundedPrivateText(
|
|
646
|
-
configured.error ??
|
|
647
|
-
resources.error ??
|
|
648
|
-
cwdPolicy.error ??
|
|
649
|
-
completion.error ??
|
|
650
|
-
parallelLimit.error ??
|
|
651
|
-
detachedLimits.error ??
|
|
652
|
-
transport.error ??
|
|
653
|
-
usageRecording.error ??
|
|
654
|
-
"",
|
|
655
|
-
2 * 1024,
|
|
656
|
-
)
|
|
657
|
-
: undefined,
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
async function inspectInProcessCapability(): Promise<{ error?: string }> {
|
|
662
|
-
try {
|
|
663
|
-
const moduleSpecifier = "@earendil-works/pi-coding-agent";
|
|
664
|
-
const core = await import(moduleSpecifier);
|
|
665
|
-
for (const name of [
|
|
666
|
-
"createAgentSessionServices",
|
|
667
|
-
"createAgentSessionFromServices",
|
|
668
|
-
"resolveCliModel",
|
|
669
|
-
] as const) {
|
|
670
|
-
if (typeof core[name] !== "function") return { error: `Pi core does not export ${name}()` };
|
|
671
|
-
}
|
|
672
|
-
return {};
|
|
673
|
-
} catch (error) {
|
|
674
|
-
return { error: error instanceof Error ? error.message : String(error) };
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
function inspectRpcCapability(): { error?: string } {
|
|
679
|
-
try {
|
|
680
|
-
resolvePiInvocation(["--mode", "rpc", "--no-session"]);
|
|
681
|
-
return {};
|
|
682
|
-
} catch (error) {
|
|
683
|
-
return { error: error instanceof Error ? error.message : String(error) };
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
function availableModelCount(ctx: ExtensionContext): number {
|
|
688
|
-
return (ctx.scopedModels?.length ?? 0) > 0
|
|
689
|
-
? ctx.scopedModels.length
|
|
690
|
-
: ctx.modelRegistry.getAvailable().length;
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
function projectToolNames(tools: readonly string[]): string[] {
|
|
694
|
-
return tools.slice(0, 100).map((tool) => boundedPrivateText(tool, 256));
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
function boundedProjection<T, TProjected>(
|
|
698
|
-
values: readonly T[],
|
|
699
|
-
limit: number,
|
|
700
|
-
project: (value: T) => TProjected,
|
|
701
|
-
): { items: TProjected[]; omitted: number } {
|
|
702
|
-
const items: TProjected[] = [];
|
|
703
|
-
for (const value of values.slice(0, limit)) {
|
|
704
|
-
const next = project(value);
|
|
705
|
-
if (Buffer.byteLength(JSON.stringify([...items, next]), "utf8") > MAX_DETAILS_LIST_BYTES) break;
|
|
706
|
-
items.push(next);
|
|
707
|
-
}
|
|
708
|
-
return { items, omitted: Math.max(0, values.length - items.length) };
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
function inspectResult(details: Record<string, unknown>): InspectToolResult {
|
|
712
|
-
const rendered = boundText(JSON.stringify(details, null, 2));
|
|
713
|
-
return {
|
|
714
|
-
content: [{ type: "text", text: rendered.text }],
|
|
715
|
-
details: { ...details, ...(rendered.truncated ? { truncated: true } : {}) },
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
function assertTrustedScope(scope: AgentScope, ctx: ExtensionContext): void {
|
|
720
|
-
if ((scope === "project" || scope === "both") && !ctx.isProjectTrusted()) {
|
|
721
|
-
throw new Error("Project-local subagent definitions require a trusted project");
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
function parameterRecord(params: unknown): Record<string, unknown> {
|
|
726
|
-
if (!params || typeof params !== "object" || Array.isArray(params)) {
|
|
727
|
-
throw new Error("subagent_inspect parameters must be an object");
|
|
728
|
-
}
|
|
729
|
-
return params as Record<string, unknown>;
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
function optionalAgentScope(value: unknown): AgentScope {
|
|
733
|
-
if (value === undefined) return "user";
|
|
734
|
-
if (value === "user" || value === "project" || value === "both") return value;
|
|
735
|
-
throw new Error("subagent_inspect agentScope must be user, project, or both");
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
function requiredString(value: unknown, action: string, field: string): string {
|
|
739
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
740
|
-
throw new Error(`subagent_inspect action "${action}" requires ${field}`);
|
|
741
|
-
}
|
|
742
|
-
return value;
|
|
743
|
-
}
|
|
744
|
-
|
|
745
|
-
function optionalContextMode(value: unknown): ContextMode {
|
|
746
|
-
if (value === undefined) return "none";
|
|
747
|
-
if (value === "none" || value === "all" || value === "summary") return value;
|
|
748
|
-
if (typeof value === "number" && Number.isSafeInteger(value) && value >= 1) return value;
|
|
749
|
-
throw new Error("subagent_inspect context must be none, all, summary, or a positive integer");
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
function optionalStringArray(value: unknown, field: string): string[] | undefined {
|
|
753
|
-
if (value === undefined) return undefined;
|
|
754
|
-
if (
|
|
755
|
-
!Array.isArray(value) ||
|
|
756
|
-
!value.every((item) => typeof item === "string" && item.length > 0)
|
|
757
|
-
) {
|
|
758
|
-
throw new Error(`subagent_inspect ${field} must be an array of non-empty strings`);
|
|
759
|
-
}
|
|
760
|
-
return [...value];
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
function optionalLimit(value: unknown, defaultValue: number): number {
|
|
764
|
-
if (value === undefined) return defaultValue;
|
|
765
|
-
if (!Number.isSafeInteger(value) || (value as number) < 1 || (value as number) > 100) {
|
|
766
|
-
throw new Error("subagent_inspect limit must be an integer between 1 and 100");
|
|
767
|
-
}
|
|
768
|
-
return value as number;
|
|
769
|
-
}
|