@mrclrchtr/supi-review 11.0.0 → 11.1.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 +3 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/README.md +45 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/api.ts +9 -4
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/auxiliary-models.ts +86 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/debug-retrospective.ts +64 -0
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/provider-authority.ts +176 -60
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/run.ts +139 -15
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/session/agent-run-registry.ts +7 -2
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/types.ts +27 -2
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer-render.ts +2 -1
- package/node_modules/@mrclrchtr/supi-agent-runtime/src/ui/agents-run-viewer.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/README.md +41 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/README.md +48 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/build.sh +73 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/lib/gradle-tooling-api-9.4.0.jar +0 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/lib/slf4j-api-2.0.17.jar +0 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/lib/slf4j-simple-2.0.17.jar +0 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/lib/supi-gradle-observation.jar +0 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/licenses/DEPENDENCIES.md +11 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/licenses/LICENSE-gradle-tooling-api.txt +422 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/licenses/LICENSE-slf4j.txt +21 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/licenses/NOTICE-gradle.txt +21 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/gradle-helper/src/GradleObservation.java +597 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/README.md +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/README.md +5 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/browser/ril.js +8 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/connection.js +7 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/common/ral.d.ts +8 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.d.ts +14 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/main.js +6 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/lib/node/ril.js +5 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-jsonrpc/package.json +4 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-protocol/package.json +4 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/esm/main.js +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/lib/umd/main.js +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/vscode-languageserver-types/package.json +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +6 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +21 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +5 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +19 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +19 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/ignore/README.md +95 -14
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/ignore/index.d.ts +56 -20
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/ignore/index.js +150 -120
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/ignore/legacy.js +159 -131
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/ignore/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +11 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/gradle/query.ts +273 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/gradle/runtime.ts +173 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/gradle/types.ts +65 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/read-next.ts +1 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/refactor/apply.ts +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/refactor/mutation-authority.ts +4 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/ast-scan.ts +143 -18
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/workspace/safe-path.ts +14 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/workspace/types.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/extension.ts +10 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/gradle/consent.ts +279 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/headless.ts +3 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/overview/collect.ts +11 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation/workspace-context.ts +49 -28
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-types.ts +11 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-workflow.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/session.ts +8 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/execute.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/markdown.ts +24 -17
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/result.ts +18 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/spec.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_find/structured.ts +161 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_graph/result.ts +32 -15
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_graph/spec.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_graph/structured.ts +142 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_health/markdown.ts +5 -15
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_inspect/markdown.ts +19 -11
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_inspect/result.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/directory-navigation.ts +66 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/gradle-sections.ts +68 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/markdown.ts +19 -8
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/result.ts +89 -11
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/workspace-format.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/workspace-output.ts +40 -13
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/workspace-projects.ts +170 -50
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_orientation/workspace-sections.ts +3 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_resolve/markdown.ts +4 -10
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_resolve/result.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_resolve/spec.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/code_resolve/structured.ts +103 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/infra/truncate.ts +12 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/register.ts +10 -6
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/result/display.ts +17 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/result/model-budget.ts +195 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/result/structured.ts +62 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/result/types.ts +10 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/specs.ts +2 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/types/execution.ts +5 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/tui/display.ts +10 -4
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +41 -1
- package/package.json +4 -4
- package/src/config.ts +14 -0
- package/src/tool/review_run/child-resources.ts +12 -3
- package/src/tool/review_run/child-session.ts +18 -1
- package/src/tool/review_run/child-tools.ts +2 -0
- package/src/tool/review_run/execute.ts +1 -0
- package/src/tool/review_run/execution.ts +8 -0
- package/src/tool/review_run/planner.ts +6 -2
- package/src/tool/review_run/runner.ts +97 -35
- package/src/tool/review_run/system-prompt.ts +15 -3
- package/src/tool/review_run/workflow.ts +26 -0
- package/src/tui/review-command.ts +2 -0
- package/src/types.ts +7 -0
package/README.md
CHANGED
|
@@ -93,6 +93,8 @@ Workspaces are marked and locked in the Git worktree list. Normal cleanup remove
|
|
|
93
93
|
|
|
94
94
|
`review.agentModel` selects the reviewer model for agent-started Reviews. `review.plannerModel` selects the model for the optional Planner Draft in `/supi-review`. Both default to `current`, which uses the active session model.
|
|
95
95
|
|
|
96
|
+
`review.reviewerCodemodeEnabled` defaults to `false`. When enabled, both `review_run` and `/supi-review` give Reviewer investigation PI codemode scripting and the invocation's scoped classifier/image-model catalogue. This does not enable codemode for Planner Drafts or Submission Recovery, inherit parent codemode settings, add MCP servers, load ambient extensions, or expand Reviewer tool permissions. Auxiliary-model calls may transmit supplied inputs, including repository evidence, to external providers and may incur provider costs; availability does not guarantee provider entitlement or success.
|
|
97
|
+
|
|
96
98
|
`review.reviewerThinkingLevel` selects the PI reasoning level for Reviewer Sessions. It defaults to `max`. `review.plannerThinkingLevel` selects the level for Planner Drafts. It defaults to `low`. Both settings use `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`. Project and global values are independent. The selected level is clamped to the selected model's capabilities. Invalid hand-written values stop the affected Review flow with a role-specific error.
|
|
97
99
|
|
|
98
100
|
`review.recoveryModel` selects one optional explicit model for Submission Recovery. It defaults to `disabled`. `current` is not a valid implicit Recovery Model. If the configured model is unavailable, the original review still runs. Recovery records the failed model switch only if the chain reaches that model.
|
|
@@ -101,7 +103,7 @@ Workspaces are marked and locked in the Git worktree list. Normal cleanup remove
|
|
|
101
103
|
|
|
102
104
|
## Reviewer Protocol
|
|
103
105
|
|
|
104
|
-
Reviewer Sessions have `read`, `bash`, `grep`, headless Code Intelligence tools, and `submit_review` during inspection.
|
|
106
|
+
Reviewer Sessions have `read`, `bash`, `grep`, `find`, `ls`, headless Code Intelligence tools, and `submit_review` during investigation. With `review.reviewerCodemodeEnabled`, they also have PI codemode in `on` mode: direct tools remain visible, and scripts can call only the permitted Reviewer inspection tools. Classifier and image-model access is limited to the frozen catalogue captured once for that Review and shared by its Reviewer children. Use codemode only for investigation; it does not change the Inspection-only protocol or make the Review Workspace a sandbox. Reviewers inspect one shared frozen Review Workspace. They do not run tests, builds, linters, services, runtime experiments, nested Pi sessions, or nested reviews. They do not intentionally change Target Evidence or Git history.
|
|
105
107
|
|
|
106
108
|
The Reviewer Protocol owns finding eligibility:
|
|
107
109
|
|
|
@@ -12,11 +12,12 @@ import {
|
|
|
12
12
|
startAgentRun,
|
|
13
13
|
} from "@mrclrchtr/supi-agent-runtime/api";
|
|
14
14
|
|
|
15
|
+
const providerAuthority = createAgentRunProviderAuthority(ctx.modelRegistry);
|
|
15
16
|
const run = startAgentRun({
|
|
16
17
|
inputs: {
|
|
17
18
|
cwd,
|
|
18
19
|
model,
|
|
19
|
-
providerAuthority
|
|
20
|
+
providerAuthority,
|
|
20
21
|
thinkingLevel,
|
|
21
22
|
tools,
|
|
22
23
|
customTools,
|
|
@@ -33,6 +34,37 @@ const outcome = await run.result;
|
|
|
33
34
|
|
|
34
35
|
Agent Runs share the containing process's permissions and external sandbox; context isolation is not filesystem or security isolation.
|
|
35
36
|
|
|
37
|
+
## Auxiliary model authority
|
|
38
|
+
|
|
39
|
+
Only callers that explicitly enable PI codemode for an invocation should grant its classifier and image-model access. Capture the containing session's available catalogue once per top-level invocation, then pass the same frozen snapshot to each child run in that invocation:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import {
|
|
43
|
+
captureAgentRunAuxiliaryModels,
|
|
44
|
+
createAgentRunProviderAuthority,
|
|
45
|
+
startAgentRun,
|
|
46
|
+
} from "@mrclrchtr/supi-agent-runtime/api";
|
|
47
|
+
|
|
48
|
+
const providerAuthority = createAgentRunProviderAuthority(ctx.modelRegistry);
|
|
49
|
+
const authorizedAuxiliaryModels = await captureAgentRunAuxiliaryModels(providerAuthority);
|
|
50
|
+
const run = startAgentRun({
|
|
51
|
+
inputs: {
|
|
52
|
+
cwd,
|
|
53
|
+
model,
|
|
54
|
+
providerAuthority,
|
|
55
|
+
authorizedAuxiliaryModels,
|
|
56
|
+
thinkingLevel,
|
|
57
|
+
tools: ["read", "codemode"],
|
|
58
|
+
resourceLoader,
|
|
59
|
+
settingsManager,
|
|
60
|
+
},
|
|
61
|
+
prompt,
|
|
62
|
+
completionResolver,
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Omit `authorizedAuxiliaryModels` for children that did not opt in; their auxiliary catalogue stays empty. The snapshot contains the model catalogue available when captured, not resolved credentials, and does not expand if the parent catalogue changes mid-run. PI codemode omits model headers when exposing that catalogue to scripts. Capture a new snapshot for a later invocation. Auxiliary requests resolve through the containing PI registry at request time, so model-specific headers and endpoints remain scoped to the requested model. An empty or unavailable catalogue does not disable codemode's tool scripting.
|
|
67
|
+
|
|
36
68
|
## Restored conversation context
|
|
37
69
|
|
|
38
70
|
Callers can set `captureContext: true` on a run to receive finalized native Pi entries and their active leaf in `outcome.context`. Pass that plain data as `inputs.context` on a later run. Each run creates and disposes its own session; the runtime does not keep an idle worker or persist the context itself.
|
|
@@ -50,6 +82,18 @@ A package can add a bounded same-session continuation for a required structured
|
|
|
50
82
|
|
|
51
83
|
Pi must report `"started"` for the initial prompt before continuation can start. SuPi fails the Agent Run with `prompt-rejected` if Pi reports `"handled"` or `"queued"`, if the prompt rejects before `"started"`, or if it resolves without a disposition. This code means that the Agent Run did not start. It does not mean that Pi rejected input that it handled or queued. SuPi does not call the completion resolver or start continuation after one of these failures. A continuation step is settled only when Pi reports `"started"`. SuPi does not call the completion resolver for another disposition, a rejection, or a missing disposition. Continuation can handle `missing-completion` and an accepted `unexpected-runner-failure`. `AgentRunSessionView` and `AgentRunHandle` do not expose session controls. The runtime disposes the session once after the final outcome.
|
|
52
84
|
|
|
85
|
+
## Optional post-result retrospectives
|
|
86
|
+
|
|
87
|
+
Enable **Debug → Enabled** and **Debug → Agent Run Retrospectives** in `/supi-settings` to collect assessments from Delegation and Reviewer Runs. The shared setting is `debug.agentRunRetrospectivesEnabled`, off by default. Collection also requires the loaded Debug extension's persistence sink and the caller's run registry; Planner Drafts are excluded.
|
|
88
|
+
|
|
89
|
+
- `handle.taskResult` returns the frozen task outcome, task-only Usage, and optional follow-up context before the retrospective.
|
|
90
|
+
- `handle.result` remains terminal: it waits for disposal and includes Usage from both phases. For registered runs it also waits for transcript writes.
|
|
91
|
+
- The same child performs one tool-free assessment with no retry, repair, or custom token/time budget. The task timeout ends at readiness; normal cancellation and session ownership remain in force.
|
|
92
|
+
- The Debug event uses category `agent-run-retrospective`, with assessment prose and separately measured Usage in sanitized `data`. Retrospective costs are not retroactively added to the parent tool's task Usage.
|
|
93
|
+
- Retrospective messages never enter saved follow-up context or task-only Review audit evidence. Failures or cancellation after result readiness cannot invalidate task success.
|
|
94
|
+
|
|
95
|
+
Runtime consumers opt in explicitly through `createDebugAgentRunRetrospective()` or a caller-owned `retrospective` policy. A retained Handle remains stoppable until disposal; `retrospecting` is active but cannot be steered. See the [retrospective contract](../../docs/conventions/agent-run-retrospectives.md).
|
|
96
|
+
|
|
53
97
|
## Shared `/agents` viewer
|
|
54
98
|
|
|
55
99
|
Agent and Review call `registerAgentsCommand(pi)` from the public API. The helper finds one shared registry for the containing Pi runtime through `pi.events`. Bundled runtime copies use the same registry and register one `/agents` command for that runtime. The runtime package does not register itself as a Pi extension.
|
|
@@ -14,6 +14,8 @@ export interface DebugRegistryConfig {
|
|
|
14
14
|
enabled: boolean;
|
|
15
15
|
/** What the agent-callable debug tool may return. */
|
|
16
16
|
agentAccess: DebugAgentAccess;
|
|
17
|
+
/** Whether Agent Run retrospective capture is explicitly enabled. */
|
|
18
|
+
agentRunRetrospectivesEnabled: boolean;
|
|
17
19
|
/** Maximum number of session-local events to keep in memory. */
|
|
18
20
|
maxEvents: number;
|
|
19
21
|
}
|
|
@@ -21,6 +23,7 @@ export interface DebugRegistryConfig {
|
|
|
21
23
|
export const DEBUG_REGISTRY_DEFAULTS: DebugRegistryConfig = {
|
|
22
24
|
enabled: false,
|
|
23
25
|
agentAccess: "sanitized",
|
|
26
|
+
agentRunRetrospectivesEnabled: false,
|
|
24
27
|
maxEvents: 100,
|
|
25
28
|
};
|
|
26
29
|
|
|
@@ -75,6 +78,9 @@ export interface DebugEventQueryResult {
|
|
|
75
78
|
/** Receives a sanitized event whenever the registry records one. */
|
|
76
79
|
export type DebugEventListener = (event: DebugEventView) => void;
|
|
77
80
|
|
|
81
|
+
/** Receives sanitized events for persistence; separate from ordinary event subscriptions. */
|
|
82
|
+
export type DebugPersistenceSink = (event: DebugEventView) => void;
|
|
83
|
+
|
|
78
84
|
export interface DebugSummary {
|
|
79
85
|
total: number;
|
|
80
86
|
byLevel: Partial<Record<DebugLevel, number>>;
|
|
@@ -85,6 +91,7 @@ interface DebugRegistryState {
|
|
|
85
91
|
config: DebugRegistryConfig;
|
|
86
92
|
events: DebugEvent[];
|
|
87
93
|
listeners: Set<DebugEventListener>;
|
|
94
|
+
persistenceSinks: Set<DebugPersistenceSink>;
|
|
88
95
|
nextId: number;
|
|
89
96
|
}
|
|
90
97
|
|
|
@@ -111,13 +118,15 @@ function getState(): DebugRegistryState {
|
|
|
111
118
|
config: cloneConfig(DEBUG_REGISTRY_DEFAULTS),
|
|
112
119
|
events: [],
|
|
113
120
|
listeners: new Set(),
|
|
121
|
+
persistenceSinks: new Set(),
|
|
114
122
|
nextId: 1,
|
|
115
123
|
};
|
|
116
124
|
(globalThis as Record<symbol, unknown>)[REGISTRY_KEY] = state;
|
|
117
125
|
}
|
|
118
126
|
// Keep the shared registry compatible with extension reloads that reuse an
|
|
119
|
-
// instance created before
|
|
127
|
+
// instance created before listener sets existed.
|
|
120
128
|
if (!state.listeners) state.listeners = new Set();
|
|
129
|
+
if (!state.persistenceSinks) state.persistenceSinks = new Set();
|
|
121
130
|
return state;
|
|
122
131
|
}
|
|
123
132
|
|
|
@@ -200,6 +209,19 @@ export function isDebugRegistryEnabled(): boolean {
|
|
|
200
209
|
return getState().config.enabled;
|
|
201
210
|
}
|
|
202
211
|
|
|
212
|
+
/**
|
|
213
|
+
* Return whether a retrospective can be captured: Debug and its explicit opt-in
|
|
214
|
+
* must be enabled, and at least one persistence sink must be registered.
|
|
215
|
+
*/
|
|
216
|
+
export function canRecordAgentRunRetrospective(): boolean {
|
|
217
|
+
const state = getState();
|
|
218
|
+
return (
|
|
219
|
+
state.config.enabled &&
|
|
220
|
+
state.config.agentRunRetrospectivesEnabled &&
|
|
221
|
+
state.persistenceSinks.size > 0
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
203
225
|
/** Best-effort redaction helper for data exposed through sanitized debug views. */
|
|
204
226
|
export function redactDebugData<T>(value: T): T {
|
|
205
227
|
return redactValue(value, 8) as T;
|
|
@@ -226,6 +248,16 @@ export function subscribeDebugEvents(listener: DebugEventListener): () => void {
|
|
|
226
248
|
return () => state.listeners.delete(listener);
|
|
227
249
|
}
|
|
228
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Register a sanitized event persistence sink. Sinks are tracked separately from
|
|
253
|
+
* ordinary listeners so eligibility checks only succeed when logging is active.
|
|
254
|
+
*/
|
|
255
|
+
export function subscribeDebugPersistence(sink: DebugPersistenceSink): () => void {
|
|
256
|
+
const state = getState();
|
|
257
|
+
state.persistenceSinks.add(sink);
|
|
258
|
+
return () => state.persistenceSinks.delete(sink);
|
|
259
|
+
}
|
|
260
|
+
|
|
229
261
|
/** Record a session-local debug event if debugging is enabled. */
|
|
230
262
|
export function recordDebugEvent(input: DebugEventInput): DebugEvent | null {
|
|
231
263
|
const state = getState();
|
|
@@ -251,6 +283,13 @@ export function recordDebugEvent(input: DebugEventInput): DebugEvent | null {
|
|
|
251
283
|
// Debug-event consumers must not alter producer behavior.
|
|
252
284
|
}
|
|
253
285
|
}
|
|
286
|
+
for (const sink of state.persistenceSinks) {
|
|
287
|
+
try {
|
|
288
|
+
sink(toSanitizedView(event));
|
|
289
|
+
} catch {
|
|
290
|
+
// Persistence failures must not alter producer behavior.
|
|
291
|
+
}
|
|
292
|
+
}
|
|
254
293
|
return {
|
|
255
294
|
...event,
|
|
256
295
|
data: event.data === undefined ? undefined : redactDebugData(event.data),
|
|
@@ -309,5 +348,6 @@ export function resetDebugRegistry(): void {
|
|
|
309
348
|
state.config = cloneConfig(DEBUG_REGISTRY_DEFAULTS);
|
|
310
349
|
state.events = [];
|
|
311
350
|
state.listeners.clear();
|
|
351
|
+
state.persistenceSinks.clear();
|
|
312
352
|
state.nextId = 1;
|
|
313
353
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-agent-runtime",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.1.0",
|
|
4
4
|
"description": "SuPi Agent Run runtime — neutral lifecycle management for in-process pi sessions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"!__tests__"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@mrclrchtr/supi-core": "11.
|
|
31
|
+
"@mrclrchtr/supi-core": "11.1.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@earendil-works/pi-ai": "*",
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/** Public API for @mrclrchtr/supi-agent-runtime. */
|
|
2
2
|
|
|
3
|
+
export type {
|
|
4
|
+
AgentRunAuxiliaryModelSnapshot,
|
|
5
|
+
AgentRunStartupRace,
|
|
6
|
+
} from "./auxiliary-models.ts";
|
|
7
|
+
export { captureAgentRunAuxiliaryModels, raceAgentRunStartup } from "./auxiliary-models.ts";
|
|
3
8
|
export { cloneAgentRunContext } from "./context.ts";
|
|
9
|
+
export { createDebugAgentRunRetrospective } from "./debug-retrospective.ts";
|
|
4
10
|
export type { AgentRunDiagnosticErrorRow } from "./diagnostics.ts";
|
|
5
11
|
export {
|
|
6
12
|
createEarlyCancellationDiagnostics,
|
|
@@ -8,10 +14,7 @@ export {
|
|
|
8
14
|
formatAgentRunDiagnostics,
|
|
9
15
|
getAgentRunDiagnosticErrorRows,
|
|
10
16
|
} from "./diagnostics.ts";
|
|
11
|
-
export type {
|
|
12
|
-
AgentRunProviderAuthority,
|
|
13
|
-
AgentRunRequestAuth,
|
|
14
|
-
} from "./provider-authority.ts";
|
|
17
|
+
export type { AgentRunProviderAuthority, AgentRunRequestAuth } from "./provider-authority.ts";
|
|
15
18
|
export { createAgentRunProviderAuthority } from "./provider-authority.ts";
|
|
16
19
|
export { startAgentRun, startRegisteredAgentRun } from "./run.ts";
|
|
17
20
|
export { AgentRunRegistry } from "./session/agent-run-registry.ts";
|
|
@@ -53,6 +56,8 @@ export type {
|
|
|
53
56
|
AgentRunOutcome,
|
|
54
57
|
AgentRunProgress,
|
|
55
58
|
AgentRunProgressListener,
|
|
59
|
+
AgentRunRetrospective,
|
|
60
|
+
AgentRunRetrospectiveResult,
|
|
56
61
|
AgentRunSessionView,
|
|
57
62
|
AgentRunStatus,
|
|
58
63
|
AgentRunSteerResult,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ClassifierApi, ClassifierModel, ImageApi, ImageModel } from "@earendil-works/pi-ai";
|
|
2
|
+
import type { AgentRunProviderAuthority } from "./provider-authority.ts";
|
|
3
|
+
|
|
4
|
+
/** Immutable catalogue of classifier and image models authorized for one invocation. */
|
|
5
|
+
export interface AgentRunAuxiliaryModelSnapshot {
|
|
6
|
+
readonly classifiers: readonly ClassifierModel<ClassifierApi>[];
|
|
7
|
+
readonly images: readonly ImageModel<ImageApi>[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Caller-visible startup result and settlement for an underlying uncancelable operation. */
|
|
11
|
+
export interface AgentRunStartupRace<T> {
|
|
12
|
+
/** Settles on the first of startup completion or caller cancellation. */
|
|
13
|
+
readonly result: Promise<T>;
|
|
14
|
+
/** Settles only when the underlying startup operation itself has settled. */
|
|
15
|
+
readonly settled: Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Race an uncancelable startup operation against invocation cancellation while retaining an
|
|
20
|
+
* explicit settlement signal for its owner. The underlying operation is not canceled; any late
|
|
21
|
+
* value is ignored by `result` and callers must await `settled` before releasing ownership.
|
|
22
|
+
*/
|
|
23
|
+
export function raceAgentRunStartup<T>(
|
|
24
|
+
startup: Promise<T>,
|
|
25
|
+
signal?: AbortSignal,
|
|
26
|
+
): AgentRunStartupRace<T> {
|
|
27
|
+
const settled = startup.then(
|
|
28
|
+
() => undefined,
|
|
29
|
+
() => undefined,
|
|
30
|
+
);
|
|
31
|
+
if (!signal) return { result: startup, settled };
|
|
32
|
+
|
|
33
|
+
let removeAbortListener: () => void = () => {};
|
|
34
|
+
const canceled = new Promise<never>((_resolve, reject) => {
|
|
35
|
+
const abort = () => reject(signal.reason ?? new Error("Agent Run startup canceled."));
|
|
36
|
+
if (signal.aborted) {
|
|
37
|
+
abort();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
41
|
+
removeAbortListener = () => signal.removeEventListener("abort", abort);
|
|
42
|
+
});
|
|
43
|
+
const result = Promise.race([startup, canceled]).finally(removeAbortListener);
|
|
44
|
+
return { result, settled };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Capture a fixed, caller-owned snapshot of currently available classifiers and image models.
|
|
49
|
+
* Missing catalogue support or a catalogue lookup failure yields an empty snapshot, never broader
|
|
50
|
+
* access. Call once per top-level invocation and pass the result through `AgentSessionInputs`.
|
|
51
|
+
*/
|
|
52
|
+
export async function captureAgentRunAuxiliaryModels(
|
|
53
|
+
authority: AgentRunProviderAuthority,
|
|
54
|
+
): Promise<AgentRunAuxiliaryModelSnapshot> {
|
|
55
|
+
if (!authority.getAvailableAuxiliaryModels)
|
|
56
|
+
return freezeAuxiliaryModels({ classifiers: [], images: [] });
|
|
57
|
+
try {
|
|
58
|
+
const available = await authority.getAvailableAuxiliaryModels();
|
|
59
|
+
return freezeAuxiliaryModels({
|
|
60
|
+
classifiers: authority.classify ? available.classifiers : [],
|
|
61
|
+
images: authority.generateImages ? available.images : [],
|
|
62
|
+
});
|
|
63
|
+
} catch {
|
|
64
|
+
return freezeAuxiliaryModels({ classifiers: [], images: [] });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Clone and freeze an auxiliary catalogue before it is retained by a runtime. */
|
|
69
|
+
export function freezeAuxiliaryModels(
|
|
70
|
+
models: AgentRunAuxiliaryModelSnapshot,
|
|
71
|
+
): AgentRunAuxiliaryModelSnapshot {
|
|
72
|
+
return Object.freeze({
|
|
73
|
+
classifiers: Object.freeze(models.classifiers.map(cloneAndFreeze)),
|
|
74
|
+
images: Object.freeze(models.images.map(cloneAndFreeze)),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function cloneAndFreeze<T>(value: T): T {
|
|
79
|
+
if (Array.isArray(value)) return Object.freeze(value.map(cloneAndFreeze)) as T;
|
|
80
|
+
if (typeof value === "object" && value !== null) {
|
|
81
|
+
return Object.freeze(
|
|
82
|
+
Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, cloneAndFreeze(entry)])),
|
|
83
|
+
) as T;
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { canRecordAgentRunRetrospective, recordDebugEvent } from "@mrclrchtr/supi-core/debug";
|
|
2
|
+
import type { AgentRunRetrospective } from "./types.ts";
|
|
3
|
+
|
|
4
|
+
// Compact, tool-free adaptation of supi-debug's interactive /supi-tooling-retro prompt.
|
|
5
|
+
const RETROSPECTIVE_PROMPT = `Reflect briefly on the task you just completed. Based only on the context available from this run, what would have made it more token/time efficient or more effective?
|
|
6
|
+
|
|
7
|
+
Focus on missing or unnecessary context from the parent, unclear tool guidance, suboptimal tool results, and tool failures or misuse. For each useful finding, name the observed friction and the specific change that might help. Clearly distinguish observations from untested suggestions. Do not invent savings estimates or generic recommendations. If nothing notable occurred, say so.
|
|
8
|
+
|
|
9
|
+
The task result has already been published. Do not continue the task, submit another result, use tools, or repeat sensitive task content unnecessarily. Return only this retrospective.`;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Opt a caller into the existing Debug evidence path only when capture, explicit
|
|
13
|
+
* retrospective permission, and a persistence sink are active. The runtime
|
|
14
|
+
* rechecks that permission before publishing a result and beginning assessment.
|
|
15
|
+
* Caller identifiers and display labels are recorded in sanitized Debug data only;
|
|
16
|
+
* never supply task instructions or inspected evidence as correlation metadata.
|
|
17
|
+
*/
|
|
18
|
+
export function createDebugAgentRunRetrospective(input: {
|
|
19
|
+
readonly source: string;
|
|
20
|
+
readonly runKey: string;
|
|
21
|
+
readonly batchId: string;
|
|
22
|
+
readonly taskId: string;
|
|
23
|
+
readonly label: string;
|
|
24
|
+
readonly conversationId?: string;
|
|
25
|
+
readonly cwd: string;
|
|
26
|
+
}): AgentRunRetrospective | undefined {
|
|
27
|
+
if (!canRecordAgentRunRetrospective()) return undefined;
|
|
28
|
+
return {
|
|
29
|
+
prompt: RETROSPECTIVE_PROMPT,
|
|
30
|
+
isEnabled: canRecordAgentRunRetrospective,
|
|
31
|
+
onResult: (result) => {
|
|
32
|
+
const { usage, ...assessment } = result;
|
|
33
|
+
recordDebugEvent({
|
|
34
|
+
source: input.source,
|
|
35
|
+
cwd: input.cwd,
|
|
36
|
+
category: "agent-run-retrospective",
|
|
37
|
+
level: result.status === "completed" ? "info" : "warning",
|
|
38
|
+
message: "Agent Run retrospective",
|
|
39
|
+
data: {
|
|
40
|
+
runKey: input.runKey,
|
|
41
|
+
caller: input.source,
|
|
42
|
+
batchId: input.batchId,
|
|
43
|
+
taskId: input.taskId,
|
|
44
|
+
label: input.label,
|
|
45
|
+
...(input.conversationId === undefined ? {} : { conversationId: input.conversationId }),
|
|
46
|
+
...assessment,
|
|
47
|
+
// Avoid secret-like "token" keys in the shared Debug sanitizer.
|
|
48
|
+
...(usage
|
|
49
|
+
? {
|
|
50
|
+
usage: {
|
|
51
|
+
input: usage.input,
|
|
52
|
+
output: usage.output,
|
|
53
|
+
cacheRead: usage.cacheRead,
|
|
54
|
+
cacheWrite: usage.cacheWrite,
|
|
55
|
+
total: usage.totalTokens,
|
|
56
|
+
cost: usage.cost,
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
: {}),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|