@orion-agents/orion-code 0.3.66 → 0.4.3
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/CHANGELOG.md +81 -0
- package/README.md +78 -361
- package/README.zh-CN.md +71 -262
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +34 -0
- package/dist/acp/session-updates.js +162 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +315 -0
- package/dist/acp/stdio.d.ts +3 -0
- package/dist/acp/stdio.js +59 -0
- package/dist/cli.js +136 -185
- package/dist/commands/context-tool-command-handlers.d.ts +1 -1
- package/dist/commands/context-tool-command-handlers.js +24 -3
- package/dist/commands/core-command-handlers.js +5 -1
- package/dist/commands/diagnostic-command-handlers.js +20 -6
- package/dist/commands/diagnostic-commands.js +0 -12
- package/dist/commands/init-command.d.ts +3 -0
- package/dist/commands/init-command.js +131 -0
- package/dist/commands/model-command-handlers.d.ts +1 -2
- package/dist/commands/model-command-handlers.js +15 -100
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/registry.js +0 -18
- package/dist/commands/rsi-command.d.ts +2 -0
- package/dist/commands/rsi-command.js +180 -0
- package/dist/commands/session-command-handlers.js +28 -19
- package/dist/commands/system-commands.js +0 -1
- package/dist/commands/tool-commands.js +1 -1
- package/dist/commands/types.d.ts +4 -10
- package/dist/commands/types.js +1 -21
- package/dist/commands/workflow-command-handlers.js +13 -4
- package/dist/framework/loop-budget-contract.d.ts +7 -2
- package/dist/framework/loop-budget-contract.js +4 -1
- package/dist/framework/loop-progress.d.ts +22 -0
- package/dist/framework/loop-progress.js +79 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +27 -20
- package/dist/framework/query.js +453 -153
- package/dist/framework/store.d.ts +6 -10
- package/dist/framework/store.js +2 -21
- package/dist/framework/tool-call-orchestrator.d.ts +7 -0
- package/dist/framework/tool-call-orchestrator.js +8 -3
- package/dist/framework/tool-state.d.ts +2 -0
- package/dist/framework/tool.d.ts +0 -23
- package/dist/framework/verification-command.d.ts +15 -0
- package/dist/framework/verification-command.js +32 -0
- package/dist/harness/assembler.d.ts +1 -0
- package/dist/harness/assembler.js +24 -0
- package/dist/harness/capsule.d.ts +1 -1
- package/dist/harness/capsule.js +33 -14
- package/dist/harness/context-harness.d.ts +31 -12
- package/dist/harness/context-harness.js +491 -35
- package/dist/harness/contract.js +1 -1
- package/dist/harness/drift-guard.d.ts +4 -0
- package/dist/harness/drift-guard.js +68 -16
- package/dist/harness/intent.js +21 -0
- package/dist/harness/ledger.d.ts +6 -11
- package/dist/harness/ledger.js +39 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +66 -21
- package/dist/harness/state.js +9 -1
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +95 -0
- package/dist/harness/types.d.ts +73 -1
- package/dist/harness/verification.d.ts +19 -1
- package/dist/harness/verification.js +116 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/print-ui/event-stream.d.ts +38 -0
- package/dist/print-ui/event-stream.js +187 -0
- package/dist/print-ui/launch.d.ts +12 -1
- package/dist/print-ui/launch.js +173 -11
- package/dist/product/environment.d.ts +1 -1
- package/dist/product/environment.js +1 -1
- package/dist/product/identity.d.ts +1 -1
- package/dist/product/identity.js +1 -1
- package/dist/product/paths.d.ts +3 -2
- package/dist/product/paths.js +6 -2
- package/dist/runtime/agent-loop.d.ts +11 -2
- package/dist/runtime/agent-loop.js +165 -25
- package/dist/runtime/agent-runtime-controller.d.ts +13 -3
- package/dist/runtime/agent-runtime-controller.js +347 -183
- package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
- package/dist/runtime/agent-runtime-runner.d.ts +10 -0
- package/dist/runtime/builtin-tool-provider.js +5 -1
- package/dist/runtime/capability-receipt-journal.js +1 -0
- package/dist/runtime/durable-tool-receipt-reader.js +2 -1
- package/dist/runtime/first-party-tool-services.d.ts +1 -0
- package/dist/runtime/first-party-tool-services.js +2 -12
- package/dist/runtime/first-party-tool-universe.d.ts +1 -0
- package/dist/runtime/first-party-tool-universe.js +1 -1
- package/dist/runtime/followup-queue-store.d.ts +16 -0
- package/dist/runtime/followup-queue-store.js +75 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +11 -1
- package/dist/runtime/goal-lifecycle-v2.js +85 -15
- package/dist/runtime/goal-runtime-coordinator.d.ts +10 -1
- package/dist/runtime/goal-runtime-coordinator.js +81 -24
- package/dist/runtime/loop-budget.js +7 -5
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
- package/dist/runtime/model-coordinator.js +2 -5
- package/dist/runtime/orion-runtime-v1.d.ts +18 -2
- package/dist/runtime/orion-runtime-v1.js +135 -39
- package/dist/runtime/orion-session-runner.d.ts +7 -0
- package/dist/runtime/orion-session-runner.js +82 -0
- package/dist/runtime/plan-review.d.ts +1 -0
- package/dist/runtime/plan-review.js +8 -4
- package/dist/runtime/product-bootstrap.d.ts +6 -0
- package/dist/runtime/product-bootstrap.js +41 -51
- package/dist/runtime/product-orion-runtime.js +128 -52
- package/dist/runtime/release-receipts.d.ts +24 -133
- package/dist/runtime/release-receipts.js +129 -693
- package/dist/runtime/rich-text/layout.js +108 -65
- package/dist/runtime/rsi/contracts.d.ts +50 -0
- package/dist/runtime/rsi/contracts.js +17 -0
- package/dist/runtime/rsi/diagnosis.d.ts +46 -0
- package/dist/runtime/rsi/diagnosis.js +98 -0
- package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
- package/dist/runtime/rsi/evaluation-suite.js +141 -0
- package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
- package/dist/runtime/rsi/evaluation-worker.js +64 -0
- package/dist/runtime/rsi/evaluation.d.ts +49 -0
- package/dist/runtime/rsi/evaluation.js +351 -0
- package/dist/runtime/rsi/lifecycle.d.ts +54 -0
- package/dist/runtime/rsi/lifecycle.js +279 -0
- package/dist/runtime/rsi/proposal.d.ts +39 -0
- package/dist/runtime/rsi/proposal.js +312 -0
- package/dist/runtime/rsi/receipt.d.ts +28 -0
- package/dist/runtime/rsi/receipt.js +138 -0
- package/dist/runtime/rsi/skill-state.d.ts +7 -0
- package/dist/runtime/rsi/skill-state.js +50 -0
- package/dist/runtime/rsi/trajectory.d.ts +19 -0
- package/dist/runtime/rsi/trajectory.js +314 -0
- package/dist/runtime/rsi/triage.d.ts +274 -0
- package/dist/runtime/rsi/triage.js +58 -0
- package/dist/runtime/session-composer-control.d.ts +5 -24
- package/dist/runtime/session-composer-control.js +27 -189
- package/dist/runtime/step-snapshot.d.ts +1 -0
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -1
- package/dist/runtime/subagents/runtime-integration.js +2 -4
- package/dist/runtime/subagents/types.d.ts +0 -5
- package/dist/runtime/subagents/types.js +0 -2
- package/dist/runtime/task-context-recovery.d.ts +55 -0
- package/dist/runtime/task-context-recovery.js +342 -0
- package/dist/runtime/task-context-service.d.ts +16 -10
- package/dist/runtime/task-context-service.js +35 -4
- package/dist/runtime/thread-admission.d.ts +1 -1
- package/dist/runtime/thread-admission.js +12 -6
- package/dist/runtime/thread-event-store.d.ts +2 -2
- package/dist/runtime/thread-event-store.js +7 -2
- package/dist/runtime/thread-projection.js +4 -2
- package/dist/runtime/thread-runtime.d.ts +7 -0
- package/dist/runtime/thread-runtime.js +43 -0
- package/dist/runtime/thread-session-index.d.ts +8 -0
- package/dist/runtime/thread-session-index.js +50 -1
- package/dist/runtime/thread-session-view.d.ts +2 -1
- package/dist/runtime/thread-session-view.js +4 -0
- package/dist/runtime/thread-tool-journal.d.ts +1 -0
- package/dist/runtime/thread-tool-journal.js +6 -2
- package/dist/runtime/thread-ui-adapter.d.ts +1 -0
- package/dist/runtime/thread-ui-adapter.js +88 -11
- package/dist/runtime/tool-gateway.d.ts +7 -0
- package/dist/runtime/tool-gateway.js +20 -0
- package/dist/runtime/tool-transcript-entry.d.ts +16 -0
- package/dist/runtime/tool-transcript-entry.js +73 -0
- package/dist/runtime/turn-commit.d.ts +4 -1
- package/dist/runtime/turn-commit.js +19 -15
- package/dist/runtime/ui-events.d.ts +12 -0
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +33 -19
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- package/dist/services/atomic-write.d.ts +2 -0
- package/dist/services/atomic-write.js +12 -1
- package/dist/services/code-review/format.d.ts +4 -1
- package/dist/services/code-review/format.js +5 -1
- package/dist/services/code-review/runner.d.ts +2 -2
- package/dist/services/code-review/runner.js +86 -64
- package/dist/services/code-review/snapshot.d.ts +9 -9
- package/dist/services/code-review/snapshot.js +182 -166
- package/dist/services/compact/auto-compact.d.ts +21 -6
- package/dist/services/compact/auto-compact.js +148 -22
- package/dist/services/compact/background-candidate.d.ts +33 -0
- package/dist/services/compact/background-candidate.js +184 -0
- package/dist/services/compact/compact.d.ts +4 -1
- package/dist/services/compact/compact.js +30 -3
- package/dist/services/compact/coordinator.d.ts +10 -4
- package/dist/services/compact/coordinator.js +17 -7
- package/dist/services/compact/summary-generator.d.ts +4 -2
- package/dist/services/compact/summary-generator.js +17 -3
- package/dist/services/config.d.ts +5 -5
- package/dist/services/config.js +30 -45
- package/dist/services/doctor.js +85 -13
- package/dist/services/effort.d.ts +5 -5
- package/dist/services/effort.js +5 -11
- package/dist/services/file-lock.d.ts +9 -3
- package/dist/services/file-lock.js +92 -26
- package/dist/services/global-config.d.ts +26 -56
- package/dist/services/global-config.js +213 -183
- package/dist/services/llm.d.ts +40 -4
- package/dist/services/llm.js +164 -45
- package/dist/services/model-client-pool.d.ts +15 -9
- package/dist/services/model-client-pool.js +62 -33
- package/dist/services/model-context.d.ts +2 -1
- package/dist/services/model-context.js +15 -9
- package/dist/services/model-registry.d.ts +4 -15
- package/dist/services/model-registry.js +32 -101
- package/dist/services/provider-diagnostics.d.ts +7 -0
- package/dist/services/provider-diagnostics.js +9 -10
- package/dist/services/provider-resilience/coordinator.d.ts +1 -1
- package/dist/services/provider-resilience/coordinator.js +10 -6
- package/dist/services/provider-resilience/request-gate.d.ts +3 -0
- package/dist/services/provider-resilience/request-gate.js +29 -18
- package/dist/services/provider-resilience/types.d.ts +2 -0
- package/dist/services/session-storage.d.ts +7 -10
- package/dist/services/session-storage.js +57 -30
- package/dist/services/settings-coordinator.d.ts +0 -6
- package/dist/services/settings-coordinator.js +19 -56
- package/dist/services/settings-document-repository.d.ts +3 -10
- package/dist/services/settings-document-repository.js +7 -85
- package/dist/services/usage-state.d.ts +3 -3
- package/dist/services/usage-state.js +11 -42
- package/dist/terminal-ui/answer-format.d.ts +14 -0
- package/dist/terminal-ui/answer-format.js +119 -0
- package/dist/terminal-ui/launch.d.ts +7 -6
- package/dist/terminal-ui/launch.js +160 -70
- package/dist/terminal-ui/output-queue.d.ts +2 -1
- package/dist/terminal-ui/output-queue.js +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +2 -1
- package/dist/terminal-ui/raw-editor.js +56 -15
- package/dist/tools/core/edit-file.js +2 -0
- package/dist/tools/core/write-file.js +5 -0
- package/dist/tools/lsp.d.ts +16 -1
- package/dist/tools/lsp.js +60 -19
- package/dist/tools/sandbox.d.ts +1 -1
- package/dist/tools/sandbox.js +3 -16
- package/dist/tools/todo.d.ts +4 -2
- package/dist/tools/todo.js +76 -31
- package/dist/tui-core/input-parser.d.ts +1 -0
- package/dist/tui-core/input-parser.js +6 -0
- package/dist/tui-core/style.d.ts +1 -8
- package/dist/tui-core/style.js +3 -110
- package/dist/tui-ui/chrome-view-model.d.ts +1 -1
- package/dist/tui-ui/chrome-view-model.js +22 -27
- package/dist/tui-ui/launch.js +14 -14
- package/dist/tui-ui/layout.d.ts +5 -7
- package/dist/tui-ui/layout.js +129 -124
- package/dist/tui-ui/runner.d.ts +11 -12
- package/dist/tui-ui/runner.js +88 -67
- package/dist/tui-ui/state.d.ts +0 -11
- package/dist/tui-ui/state.js +22 -33
- package/dist/tui-ui/terminal-image.js +22 -4
- package/dist/tui-ui/transcript-inspector-layout.js +6 -3
- package/dist/tui-ui/transcript-inspector.d.ts +1 -0
- package/dist/tui-ui/transcript-inspector.js +7 -1
- package/dist/tui-ui/transcript-layout.js +42 -6
- package/dist/utils/terminal-text.d.ts +11 -0
- package/dist/utils/terminal-text.js +114 -0
- package/docs/cli-guide.md +562 -0
- package/docs/orion.example.yaml +42 -0
- package/docs/readme.md +12 -57
- package/npm-shrinkwrap.json +484 -1855
- package/package.json +13 -63
- package/dist/migration/command.d.ts +0 -9
- package/dist/migration/command.js +0 -100
- package/dist/migration/index.d.ts +0 -7
- package/dist/migration/index.js +0 -14
- package/dist/migration/migrate.d.ts +0 -19
- package/dist/migration/migrate.js +0 -406
- package/dist/migration/types.d.ts +0 -55
- package/dist/migration/types.js +0 -6
- package/dist/services/tool-allowlist.d.ts +0 -110
- package/dist/services/tool-allowlist.js +0 -299
- package/dist/services/yaml-config.d.ts +0 -57
- package/dist/services/yaml-config.js +0 -178
- package/dist/web/cli-options.d.ts +0 -17
- package/dist/web/cli-options.js +0 -51
- package/dist/web/code-review-run-service.d.ts +0 -68
- package/dist/web/code-review-run-service.js +0 -228
- package/dist/web/context-text.d.ts +0 -17
- package/dist/web/context-text.js +0 -40
- package/dist/web/errors.d.ts +0 -6
- package/dist/web/errors.js +0 -13
- package/dist/web/event-hub.d.ts +0 -45
- package/dist/web/event-hub.js +0 -370
- package/dist/web/file-read-service.d.ts +0 -101
- package/dist/web/file-read-service.js +0 -593
- package/dist/web/file-write-service.d.ts +0 -16
- package/dist/web/file-write-service.js +0 -103
- package/dist/web/git-compare-service.d.ts +0 -45
- package/dist/web/git-compare-service.js +0 -160
- package/dist/web/git-diff-document.d.ts +0 -102
- package/dist/web/git-diff-document.js +0 -258
- package/dist/web/git-file-source.d.ts +0 -25
- package/dist/web/git-file-source.js +0 -21
- package/dist/web/git-history-service.d.ts +0 -151
- package/dist/web/git-history-service.js +0 -619
- package/dist/web/git-index-transaction.d.ts +0 -45
- package/dist/web/git-index-transaction.js +0 -174
- package/dist/web/git-patch-builder.d.ts +0 -30
- package/dist/web/git-patch-builder.js +0 -138
- package/dist/web/git-read-model-service.d.ts +0 -452
- package/dist/web/git-read-model-service.js +0 -1833
- package/dist/web/git-version-service.d.ts +0 -79
- package/dist/web/git-version-service.js +0 -279
- package/dist/web/host-daemon.d.ts +0 -70
- package/dist/web/host-daemon.js +0 -237
- package/dist/web/index.d.ts +0 -6
- package/dist/web/index.js +0 -28
- package/dist/web/launch.d.ts +0 -12
- package/dist/web/launch.js +0 -89
- package/dist/web/native-directory-picker.d.ts +0 -63
- package/dist/web/native-directory-picker.js +0 -169
- package/dist/web/protocol.d.ts +0 -705
- package/dist/web/protocol.js +0 -639
- package/dist/web/review-service.d.ts +0 -22
- package/dist/web/review-service.js +0 -68
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -1453
- package/dist/web/session-runtime-registry.d.ts +0 -138
- package/dist/web/session-runtime-registry.js +0 -471
- package/dist/web/terminal-manager.d.ts +0 -156
- package/dist/web/terminal-manager.js +0 -779
- package/dist/web/terminal-server.d.ts +0 -8
- package/dist/web/terminal-server.js +0 -304
- package/dist/web/workbench-controller.d.ts +0 -395
- package/dist/web/workbench-controller.js +0 -3077
- package/dist/web/workspace-discovery.d.ts +0 -92
- package/dist/web/workspace-discovery.js +0 -324
- package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
- package/dist/web/workspace-mutation-arbiter.js +0 -267
- package/dist/web/workspace-open-telemetry.d.ts +0 -55
- package/dist/web/workspace-open-telemetry.js +0 -73
- package/dist/web-client/assets/FilesPanel-CPDovK_K.js +0 -1
- package/dist/web-client/assets/GitPanel-DtU_TD61.js +0 -4
- package/dist/web-client/assets/ReviewPanel-vMO7BEA3.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C9vDTAlS.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-CABdwh4l.css +0 -1
- package/dist/web-client/assets/index-KvshfEbl.js +0 -20
- package/dist/web-client/assets/useAutoNotice-IE1g2wcb.js +0 -1
- package/dist/web-client/favicon.svg +0 -9
- package/dist/web-client/index.html +0 -17
- package/docs/architecture/agent-mode-permission-contract.md +0 -87
- package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
- package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
- package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
- package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
- package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
- package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
- package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
- package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
- package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
- package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
- package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
- package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
- package/docs/orion.example.json +0 -86
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
- package/docs/plan/v0.2.0-release-checklist.md +0 -91
- package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
- package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
- package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
- package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
- package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
- package/docs/plan/v0.3.3-plan.md +0 -1113
- package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
- package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
- package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
- package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
- package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
|
@@ -12,7 +12,17 @@ const style_1 = require("../../tui-core/style");
|
|
|
12
12
|
function layoutRichText(doc, options) {
|
|
13
13
|
const width = normalizeWidth(options.width);
|
|
14
14
|
const indent = normalizeIndent(options.indent ?? 0, width);
|
|
15
|
-
|
|
15
|
+
const rows = [];
|
|
16
|
+
for (const block of doc.blocks) {
|
|
17
|
+
const blockRows = layoutBlock(block, width, options.theme, indent);
|
|
18
|
+
if (blockRows.length === 0)
|
|
19
|
+
continue;
|
|
20
|
+
if (rows.length > 0)
|
|
21
|
+
rows.push([]);
|
|
22
|
+
for (const row of blockRows)
|
|
23
|
+
rows.push(row);
|
|
24
|
+
}
|
|
25
|
+
return rows;
|
|
16
26
|
}
|
|
17
27
|
function layoutBlock(block, width, theme, indent) {
|
|
18
28
|
switch (block.type) {
|
|
@@ -47,7 +57,7 @@ function layoutInline(spans, width, theme, baseStyle, indent) {
|
|
|
47
57
|
text: span.text,
|
|
48
58
|
style: resolveSpanStyle(span, baseStyle, theme),
|
|
49
59
|
}));
|
|
50
|
-
return layoutPrefixedSpans(styled, width, prefix, prefix,
|
|
60
|
+
return layoutPrefixedSpans(styled, width, prefix, prefix, 'word');
|
|
51
61
|
}
|
|
52
62
|
function layoutList(block, width, theme, indent) {
|
|
53
63
|
const rows = [];
|
|
@@ -69,7 +79,7 @@ function layoutList(block, width, theme, indent) {
|
|
|
69
79
|
text: span.text,
|
|
70
80
|
style: resolveSpanStyle(span, base, theme),
|
|
71
81
|
}));
|
|
72
|
-
rows.push(...layoutPrefixedSpans(styled, width, firstPrefix, continuationPrefix,
|
|
82
|
+
rows.push(...layoutPrefixedSpans(styled, width, firstPrefix, continuationPrefix, 'word'));
|
|
73
83
|
return;
|
|
74
84
|
}
|
|
75
85
|
if (blockIndex === 0) {
|
|
@@ -114,10 +124,14 @@ function layoutCode(lines, width, theme, indent, language) {
|
|
|
114
124
|
rows.push(clampRow([...labelPrefix, ...padRow([{ text: label, style: labelStyle }], available, labelStyle)], width));
|
|
115
125
|
}
|
|
116
126
|
for (const line of lines.length > 0 ? lines : ['']) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
127
|
+
const gutter = available >= 6 && (0, string_width_1.default)(line) > available ? 2 : 0;
|
|
128
|
+
const wrapped = wrapStyledSpans([{ text: line, style }], available - gutter, 'code');
|
|
129
|
+
wrapped.forEach((row, index) => {
|
|
130
|
+
const continuation = gutter > 0
|
|
131
|
+
? [{ text: index === 0 ? ' ' : '↳ ', style: mergeStyles(style, theme('muted')) }]
|
|
132
|
+
: [];
|
|
133
|
+
rows.push([...prefix, ...padRow([...continuation, ...row], available, style)]);
|
|
134
|
+
});
|
|
121
135
|
}
|
|
122
136
|
return rows;
|
|
123
137
|
}
|
|
@@ -129,7 +143,7 @@ function layoutDiff(lines, width, theme, indent) {
|
|
|
129
143
|
const style = diffLineStyle(line.kind, theme);
|
|
130
144
|
const firstPrefix = [{ text: `${' '.repeat(safeIndent)}${prefix}`, style }];
|
|
131
145
|
const continuationPrefix = [{ text: `${' '.repeat(safeIndent)}↳`, style }];
|
|
132
|
-
rows.push(...layoutPrefixedSpans([{ text: line.content, style }], width, firstPrefix, continuationPrefix,
|
|
146
|
+
rows.push(...layoutPrefixedSpans([{ text: line.content, style }], width, firstPrefix, continuationPrefix, 'hard'));
|
|
133
147
|
}
|
|
134
148
|
return rows;
|
|
135
149
|
}
|
|
@@ -152,44 +166,69 @@ function layoutTable(block, width, theme, indent) {
|
|
|
152
166
|
const columnCount = Math.max(block.headers.length, ...block.rows.map(row => row.length));
|
|
153
167
|
if (columnCount === 0)
|
|
154
168
|
return [];
|
|
155
|
-
const
|
|
156
|
-
|
|
169
|
+
const gap = 2;
|
|
170
|
+
const cellBudget = available - gap * (columnCount - 1);
|
|
171
|
+
const tableRows = [block.headers, ...block.rows];
|
|
172
|
+
const natural = Array.from({ length: columnCount }, (_, index) => Math.max(1, ...tableRows.map(row => cellWidth(row[index] ?? []))));
|
|
173
|
+
const widths = natural.map(cells => Math.min(4, cells));
|
|
174
|
+
let remaining = cellBudget - widths.reduce((sum, cells) => sum + cells, 0);
|
|
175
|
+
if (remaining < 0)
|
|
157
176
|
return layoutTableAsKeyValue(block, width, theme, safeIndent);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
177
|
+
while (remaining > 0) {
|
|
178
|
+
const growable = widths.map((used, index) => natural[index] - used).filter(value => value > 0);
|
|
179
|
+
if (growable.length === 0)
|
|
180
|
+
break;
|
|
181
|
+
const share = Math.max(1, Math.floor(remaining / growable.length));
|
|
182
|
+
widths.forEach((used, index) => {
|
|
183
|
+
const growth = Math.min(share, remaining, natural[index] - used);
|
|
184
|
+
widths[index] += growth;
|
|
185
|
+
remaining -= growth;
|
|
166
186
|
});
|
|
167
187
|
}
|
|
168
|
-
|
|
169
|
-
|
|
188
|
+
const indentSpan = safeIndent > 0 ? [{ text: ' '.repeat(safeIndent), style: theme('assistantText') }] : [];
|
|
189
|
+
const separator = [
|
|
170
190
|
...indentSpan,
|
|
171
|
-
{ text: '─'.repeat(
|
|
172
|
-
]
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
191
|
+
{ text: widths.map(cells => '─'.repeat(cells)).join(' '.repeat(gap)), style: theme('muted') },
|
|
192
|
+
];
|
|
193
|
+
return tableRows.flatMap((row, index) => {
|
|
194
|
+
const baseStyle = theme(index === 0 ? 'heading' : 'assistantText');
|
|
195
|
+
const columns = widths.map((cells, column) => layoutInline(row[column] ?? [], cells, theme, baseStyle, 0));
|
|
196
|
+
const height = Math.max(...columns.map(column => column.length));
|
|
197
|
+
const rendered = Array.from({ length: height }, (_, line) => [
|
|
198
|
+
...indentSpan,
|
|
199
|
+
...columns.flatMap((column, cell) => {
|
|
200
|
+
const part = column[line] ?? [];
|
|
201
|
+
return cell === columnCount - 1 ? part : padRow(part, widths[cell] + gap, baseStyle);
|
|
202
|
+
}),
|
|
203
|
+
]);
|
|
204
|
+
return index === 0 ? [...rendered, separator] : rendered;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
function cellWidth(spans) {
|
|
208
|
+
return spans
|
|
209
|
+
.map(span => span.text)
|
|
210
|
+
.join('')
|
|
211
|
+
.split('\n')
|
|
212
|
+
.reduce((width, line) => Math.max(width, (0, string_width_1.default)(line)), 0);
|
|
185
213
|
}
|
|
186
214
|
function layoutTableAsKeyValue(block, width, theme, indent) {
|
|
187
215
|
const rows = [];
|
|
188
216
|
const prefixIndent = ' '.repeat(normalizeIndent(indent, width));
|
|
217
|
+
if (block.rows.length === 0) {
|
|
218
|
+
return block.headers.flatMap(cell => layoutInline(cell, width, theme, theme('heading'), indent));
|
|
219
|
+
}
|
|
189
220
|
for (const sourceRow of block.rows) {
|
|
190
|
-
|
|
221
|
+
const columnCount = Math.max(block.headers.length, sourceRow.length);
|
|
222
|
+
for (let column = 0; column < columnCount; column++) {
|
|
191
223
|
const key = block.headers[column]?.map(span => span.text).join('') || `col${column + 1}`;
|
|
192
224
|
const value = sourceRow[column] ?? [];
|
|
225
|
+
if (width - (0, string_width_1.default)(prefixIndent + key) < 5) {
|
|
226
|
+
const keyRows = layoutInline([{ text: `${key}:` }], width, theme, theme('heading'), indent);
|
|
227
|
+
const valueRows = layoutInline(value, width, theme, theme('assistantText'), indent);
|
|
228
|
+
for (const row of [...keyRows, ...valueRows])
|
|
229
|
+
rows.push(row);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
193
232
|
const prefix = [{ text: `${prefixIndent}${key}: `, style: theme('heading') }];
|
|
194
233
|
const safePrefix = clampRow(prefix, Math.max(1, width - 1));
|
|
195
234
|
const continuation = [
|
|
@@ -199,23 +238,25 @@ function layoutTableAsKeyValue(block, width, theme, indent) {
|
|
|
199
238
|
text: span.text,
|
|
200
239
|
style: resolveSpanStyle(span, theme('assistantText'), theme),
|
|
201
240
|
}));
|
|
202
|
-
|
|
241
|
+
for (const row of layoutPrefixedSpans(styledValue, width, safePrefix, continuation, 'word')) {
|
|
242
|
+
rows.push(row);
|
|
243
|
+
}
|
|
203
244
|
}
|
|
204
245
|
}
|
|
205
246
|
return rows;
|
|
206
247
|
}
|
|
207
|
-
function layoutPrefixedSpans(spans, width, firstPrefix, continuationPrefix,
|
|
248
|
+
function layoutPrefixedSpans(spans, width, firstPrefix, continuationPrefix, mode) {
|
|
208
249
|
const prefixWidth = Math.max(rowWidth(firstPrefix), rowWidth(continuationPrefix));
|
|
209
250
|
if (prefixWidth >= width) {
|
|
210
251
|
const prefixRow = clampRow(firstPrefix, width);
|
|
211
|
-
const body = wrapStyledSpans(spans, width,
|
|
252
|
+
const body = wrapStyledSpans(spans, width, mode);
|
|
212
253
|
const hasContent = spans.some(span => span.text.length > 0);
|
|
213
254
|
return hasContent ? [prefixRow, ...body.map(row => clampRow(row, width))] : [prefixRow];
|
|
214
255
|
}
|
|
215
|
-
const bodyRows = wrapStyledSpans(spans, width - prefixWidth,
|
|
256
|
+
const bodyRows = wrapStyledSpans(spans, width - prefixWidth, mode);
|
|
216
257
|
return bodyRows.map((row, index) => clampRow([...(index === 0 ? firstPrefix : continuationPrefix), ...row], width));
|
|
217
258
|
}
|
|
218
|
-
function wrapStyledSpans(spans, width,
|
|
259
|
+
function wrapStyledSpans(spans, width, mode) {
|
|
219
260
|
const safeWidth = normalizeWidth(width);
|
|
220
261
|
const lines = splitStyledUnitsIntoLines(spans);
|
|
221
262
|
const rows = [];
|
|
@@ -224,35 +265,40 @@ function wrapStyledSpans(spans, width, softWrap) {
|
|
|
224
265
|
rows.push([]);
|
|
225
266
|
continue;
|
|
226
267
|
}
|
|
227
|
-
let
|
|
228
|
-
while (
|
|
268
|
+
let start = 0;
|
|
269
|
+
while (start < units.length) {
|
|
229
270
|
let used = 0;
|
|
230
|
-
let
|
|
231
|
-
let
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
271
|
+
let end = start;
|
|
272
|
+
let whitespace = -1;
|
|
273
|
+
let seenWord = false;
|
|
274
|
+
while (end < units.length && used + units[end].width <= safeWidth) {
|
|
275
|
+
used += units[end].width;
|
|
276
|
+
if (/^\s+$/u.test(units[end].text)) {
|
|
277
|
+
if (seenWord)
|
|
278
|
+
whitespace = end;
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
seenWord = true;
|
|
282
|
+
}
|
|
283
|
+
end += 1;
|
|
237
284
|
}
|
|
238
|
-
if (
|
|
239
|
-
rows.push(unitsToRow(
|
|
285
|
+
if (end === units.length) {
|
|
286
|
+
rows.push(unitsToRow(units.slice(start)));
|
|
240
287
|
break;
|
|
241
288
|
}
|
|
242
|
-
if (
|
|
243
|
-
rows.push([{ text: '…', style:
|
|
244
|
-
|
|
289
|
+
if (end === start) {
|
|
290
|
+
rows.push([{ text: '…', style: units[start].style }]);
|
|
291
|
+
start += 1;
|
|
245
292
|
continue;
|
|
246
293
|
}
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
294
|
+
const wordBreak = mode !== 'hard' && whitespace !== -1;
|
|
295
|
+
const breakAt = wordBreak ? whitespace + Number(mode === 'code') : end;
|
|
296
|
+
rows.push(unitsToRow(units.slice(start, breakAt)));
|
|
297
|
+
start = breakAt;
|
|
298
|
+
if (mode === 'word') {
|
|
299
|
+
while (start < units.length && /^\s+$/u.test(units[start].text))
|
|
300
|
+
start += 1;
|
|
254
301
|
}
|
|
255
|
-
remaining = remaining.slice(consumed);
|
|
256
302
|
}
|
|
257
303
|
}
|
|
258
304
|
return rows.length > 0 ? rows : [[]];
|
|
@@ -342,9 +388,6 @@ function truncateToWidth(text, maxWidth) {
|
|
|
342
388
|
}
|
|
343
389
|
return `${result}…`;
|
|
344
390
|
}
|
|
345
|
-
function padText(text, width) {
|
|
346
|
-
return text + ' '.repeat(Math.max(0, width - (0, string_width_1.default)(text)));
|
|
347
|
-
}
|
|
348
391
|
function rowWidth(row) {
|
|
349
392
|
return (0, string_width_1.default)(row.map(span => span.text).join(''));
|
|
350
393
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export declare const RSI_CATEGORIES: readonly ["cross_module_callers", "local_edit_cost", "missing_verification", "missing_tool"];
|
|
2
|
+
export type RsiCategory = (typeof RSI_CATEGORIES)[number];
|
|
3
|
+
export type RsiFeedbackResult = 'corrected' | 'failed' | 'accepted';
|
|
4
|
+
export type RsiDiagnosticCode = 'adaptive_no_progress' | 'request_safety_limit' | 'automatic_compaction_paused' | 'provider_empty_output' | 'request_budget_reached' | 'capability_not_exposed' | 'tool_gate_denied' | 'tool_execution_failed' | 'completion_needs_verification' | 'unclassified_failure';
|
|
5
|
+
export interface RsiSelectedTurnV1 {
|
|
6
|
+
readonly sessionId: string;
|
|
7
|
+
readonly turnId: string;
|
|
8
|
+
readonly category: RsiCategory;
|
|
9
|
+
readonly result: RsiFeedbackResult;
|
|
10
|
+
readonly skill?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface RsiSelectionV1 {
|
|
13
|
+
readonly version: 1;
|
|
14
|
+
readonly repository: string;
|
|
15
|
+
readonly baseCommit: string;
|
|
16
|
+
readonly turns: readonly RsiSelectedTurnV1[];
|
|
17
|
+
}
|
|
18
|
+
/** Shareable metadata. Prompt text, tool arguments, and raw outputs are excluded. */
|
|
19
|
+
export interface RsiTurnEvidenceV1 extends RsiSelectedTurnV1 {
|
|
20
|
+
readonly threadId: string;
|
|
21
|
+
readonly turnCommitDigest: string;
|
|
22
|
+
readonly terminal: 'completed' | 'failed' | 'interrupted';
|
|
23
|
+
readonly toolReceipts: readonly {
|
|
24
|
+
readonly digest: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly success: boolean;
|
|
27
|
+
}[];
|
|
28
|
+
readonly loadedSkillDigests: readonly string[];
|
|
29
|
+
readonly diagnosis?: {
|
|
30
|
+
readonly code: RsiDiagnosticCode;
|
|
31
|
+
readonly at: number;
|
|
32
|
+
};
|
|
33
|
+
readonly skillProof?: {
|
|
34
|
+
readonly verified: boolean;
|
|
35
|
+
readonly startedAt: number;
|
|
36
|
+
readonly elapsedMs: number;
|
|
37
|
+
readonly descriptorDigest: string | null;
|
|
38
|
+
readonly capabilityReceiptDigests: readonly string[];
|
|
39
|
+
readonly promptDigests: readonly string[];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare const RSI_POLICY_PATH = ".orion-code/rsi-policy.json";
|
|
43
|
+
export interface RsiPolicyV1 {
|
|
44
|
+
readonly version: 1;
|
|
45
|
+
readonly callerScope: 'public-interface' | 'all-edits';
|
|
46
|
+
readonly priority: readonly RsiCategory[];
|
|
47
|
+
readonly minimumRepeat: number;
|
|
48
|
+
}
|
|
49
|
+
export declare const DEFAULT_RSI_POLICY: RsiPolicyV1;
|
|
50
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_RSI_POLICY = exports.RSI_POLICY_PATH = exports.RSI_CATEGORIES = void 0;
|
|
4
|
+
exports.RSI_CATEGORIES = [
|
|
5
|
+
'cross_module_callers',
|
|
6
|
+
'local_edit_cost',
|
|
7
|
+
'missing_verification',
|
|
8
|
+
'missing_tool',
|
|
9
|
+
];
|
|
10
|
+
exports.RSI_POLICY_PATH = '.orion-code/rsi-policy.json';
|
|
11
|
+
exports.DEFAULT_RSI_POLICY = Object.freeze({
|
|
12
|
+
version: 1,
|
|
13
|
+
callerScope: 'public-interface',
|
|
14
|
+
priority: Object.freeze([...exports.RSI_CATEGORIES]),
|
|
15
|
+
minimumRepeat: 2,
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TurnCommitV1 } from '../turn-commit';
|
|
2
|
+
import type { RsiDiagnosticCode } from './contracts';
|
|
3
|
+
export declare const RSI_DIAGNOSES: {
|
|
4
|
+
readonly adaptive_no_progress: {
|
|
5
|
+
readonly route: "harness";
|
|
6
|
+
readonly verify: "Replay the stopped loop with its tool-result sequence. Verify useful progress resumes and a genuinely stagnant loop still stops.";
|
|
7
|
+
};
|
|
8
|
+
readonly request_safety_limit: {
|
|
9
|
+
readonly route: "harness";
|
|
10
|
+
readonly verify: "Replay the trajectory against the same task and inspect how many requests show measurable progress before deciding if the safety limit is appropriate.";
|
|
11
|
+
};
|
|
12
|
+
readonly automatic_compaction_paused: {
|
|
13
|
+
readonly route: "harness";
|
|
14
|
+
readonly verify: "Reproduce the pause with an equivalent context-pressure fixture. Verify compaction plus durable suffix preservation and resume.";
|
|
15
|
+
};
|
|
16
|
+
readonly capability_not_exposed: {
|
|
17
|
+
readonly route: "harness";
|
|
18
|
+
readonly verify: "Replay tool selection and verify whether the tool was registered, permitted, and exposed in the corresponding Step Snapshot.";
|
|
19
|
+
};
|
|
20
|
+
readonly provider_empty_output: {
|
|
21
|
+
readonly route: "operator";
|
|
22
|
+
readonly verify: "Replay a provider response with no visible answer and compare provider/Runtime outcomes before attributing the failure.";
|
|
23
|
+
};
|
|
24
|
+
readonly request_budget_reached: {
|
|
25
|
+
readonly route: "operator";
|
|
26
|
+
readonly verify: "Check whether this task had an explicit request or time budget before treating the stop as a harness regression.";
|
|
27
|
+
};
|
|
28
|
+
readonly tool_gate_denied: {
|
|
29
|
+
readonly route: "operator";
|
|
30
|
+
readonly verify: "Inspect the recorded policy, approval, or sandbox decision for this task.";
|
|
31
|
+
};
|
|
32
|
+
readonly tool_execution_failed: {
|
|
33
|
+
readonly route: "needs_feedback";
|
|
34
|
+
readonly verify: "Check whether the task recovered after the failed tool call; report the actual unmet outcome before proposing a change.";
|
|
35
|
+
};
|
|
36
|
+
readonly completion_needs_verification: {
|
|
37
|
+
readonly route: "needs_feedback";
|
|
38
|
+
readonly verify: "Confirm which completion criterion was unmet and whether a project Skill could have directed the agent to the missing check.";
|
|
39
|
+
};
|
|
40
|
+
readonly unclassified_failure: {
|
|
41
|
+
readonly route: "needs_feedback";
|
|
42
|
+
readonly verify: "Review the failed turn and record the expected outcome and independently reproduced cause.";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare function diagnoseRsiTurn(commit: Pick<TurnCommitV1, 'terminal' | 'outcome' | 'stopDecision'>, failures: ReadonlySet<string>): RsiDiagnosticCode | undefined;
|
|
46
|
+
//# sourceMappingURL=diagnosis.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RSI_DIAGNOSES = void 0;
|
|
4
|
+
exports.diagnoseRsiTurn = diagnoseRsiTurn;
|
|
5
|
+
exports.RSI_DIAGNOSES = {
|
|
6
|
+
adaptive_no_progress: {
|
|
7
|
+
route: 'harness',
|
|
8
|
+
verify: 'Replay the stopped loop with its tool-result sequence. Verify useful progress resumes and a genuinely stagnant loop still stops.',
|
|
9
|
+
},
|
|
10
|
+
request_safety_limit: {
|
|
11
|
+
route: 'harness',
|
|
12
|
+
verify: 'Replay the trajectory against the same task and inspect how many requests show measurable progress before deciding if the safety limit is appropriate.',
|
|
13
|
+
},
|
|
14
|
+
automatic_compaction_paused: {
|
|
15
|
+
route: 'harness',
|
|
16
|
+
verify: 'Reproduce the pause with an equivalent context-pressure fixture. Verify compaction plus durable suffix preservation and resume.',
|
|
17
|
+
},
|
|
18
|
+
capability_not_exposed: {
|
|
19
|
+
route: 'harness',
|
|
20
|
+
verify: 'Replay tool selection and verify whether the tool was registered, permitted, and exposed in the corresponding Step Snapshot.',
|
|
21
|
+
},
|
|
22
|
+
provider_empty_output: {
|
|
23
|
+
route: 'operator',
|
|
24
|
+
verify: 'Replay a provider response with no visible answer and compare provider/Runtime outcomes before attributing the failure.',
|
|
25
|
+
},
|
|
26
|
+
request_budget_reached: {
|
|
27
|
+
route: 'operator',
|
|
28
|
+
verify: 'Check whether this task had an explicit request or time budget before treating the stop as a harness regression.',
|
|
29
|
+
},
|
|
30
|
+
tool_gate_denied: {
|
|
31
|
+
route: 'operator',
|
|
32
|
+
verify: 'Inspect the recorded policy, approval, or sandbox decision for this task.',
|
|
33
|
+
},
|
|
34
|
+
tool_execution_failed: {
|
|
35
|
+
route: 'needs_feedback',
|
|
36
|
+
verify: 'Check whether the task recovered after the failed tool call; report the actual unmet outcome before proposing a change.',
|
|
37
|
+
},
|
|
38
|
+
completion_needs_verification: {
|
|
39
|
+
route: 'needs_feedback',
|
|
40
|
+
verify: 'Confirm which completion criterion was unmet and whether a project Skill could have directed the agent to the missing check.',
|
|
41
|
+
},
|
|
42
|
+
unclassified_failure: {
|
|
43
|
+
route: 'needs_feedback',
|
|
44
|
+
verify: 'Review the failed turn and record the expected outcome and independently reproduced cause.',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const STOP_CODES = new Map([
|
|
48
|
+
['no_progress_after_recovery', 'adaptive_no_progress'],
|
|
49
|
+
['request_safety_limit', 'request_safety_limit'],
|
|
50
|
+
['budget_paused_compact_pending', 'request_budget_reached'],
|
|
51
|
+
['empty_output', 'provider_empty_output'],
|
|
52
|
+
['no_visible_output', 'provider_empty_output'],
|
|
53
|
+
['llm_request_budget', 'request_budget_reached'],
|
|
54
|
+
['budget_exhausted_without_progress', 'request_budget_reached'],
|
|
55
|
+
['user_hard_budget_reached', 'request_budget_reached'],
|
|
56
|
+
]);
|
|
57
|
+
function parseObject(value) {
|
|
58
|
+
try {
|
|
59
|
+
const parsed = value ? JSON.parse(value) : undefined;
|
|
60
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
61
|
+
? parsed
|
|
62
|
+
: undefined;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Legacy TurnCommit outcomes may be plain text. Only typed facts drive diagnosis.
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function reasonCode(decision) {
|
|
70
|
+
const reason = decision?.reason;
|
|
71
|
+
return typeof reason?.code === 'string' ? reason.code : undefined;
|
|
72
|
+
}
|
|
73
|
+
function diagnoseRsiTurn(commit, failures) {
|
|
74
|
+
const outcome = parseObject(commit.outcome);
|
|
75
|
+
const reason = reasonCode(outcome?.stopDecision) ?? reasonCode(parseObject(commit.stopDecision));
|
|
76
|
+
const known = reason === undefined ? undefined : STOP_CODES.get(reason);
|
|
77
|
+
if (known)
|
|
78
|
+
return known;
|
|
79
|
+
if (outcome?.finishReason === 'compact_paused')
|
|
80
|
+
return 'automatic_compaction_paused';
|
|
81
|
+
if (outcome?.finishReason === 'budget_exceeded')
|
|
82
|
+
return 'request_budget_reached';
|
|
83
|
+
if (outcome?.finishReason === 'completion_gate' || reason === 'completion_gate') {
|
|
84
|
+
return 'completion_needs_verification';
|
|
85
|
+
}
|
|
86
|
+
// A tool can be denied or fail during an otherwise successful turn that recovered.
|
|
87
|
+
if (commit.terminal === 'completed' && outcome?.finishReason !== 'blocked')
|
|
88
|
+
return undefined;
|
|
89
|
+
if (failures.has('approval') || failures.has('policy') || failures.has('sandbox')) {
|
|
90
|
+
return 'tool_gate_denied';
|
|
91
|
+
}
|
|
92
|
+
if (failures.has('capability'))
|
|
93
|
+
return 'capability_not_exposed';
|
|
94
|
+
if (failures.has('execute'))
|
|
95
|
+
return 'tool_execution_failed';
|
|
96
|
+
return 'unclassified_failure';
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=diagnosis.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type RsiCategory } from './contracts';
|
|
2
|
+
export interface RsiEvaluationTask {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly split: 'development' | 'holdout';
|
|
5
|
+
readonly category: RsiCategory;
|
|
6
|
+
readonly prompt: string;
|
|
7
|
+
readonly files: Readonly<Record<string, string>>;
|
|
8
|
+
/** Exact expected bytes for permitted changes. All other fixture files stay unchanged. */
|
|
9
|
+
readonly expected: Readonly<Record<string, string>>;
|
|
10
|
+
}
|
|
11
|
+
export interface RsiEvaluationSuite {
|
|
12
|
+
readonly version: 1;
|
|
13
|
+
readonly model: string;
|
|
14
|
+
readonly endpoint: string;
|
|
15
|
+
readonly repeats: number;
|
|
16
|
+
readonly maxRequests: number;
|
|
17
|
+
readonly maxTools: number;
|
|
18
|
+
readonly maxTokens: number;
|
|
19
|
+
readonly timeoutMs: number;
|
|
20
|
+
readonly tasks: readonly RsiEvaluationTask[];
|
|
21
|
+
}
|
|
22
|
+
export declare const RSI_EVALUATION_TOOLS: readonly string[];
|
|
23
|
+
/** Fixtures and checks are supplied independently from proposal generation. */
|
|
24
|
+
export declare function parseRsiSuite(value: unknown): RsiEvaluationSuite;
|
|
25
|
+
//# sourceMappingURL=evaluation-suite.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RSI_EVALUATION_TOOLS = void 0;
|
|
4
|
+
exports.parseRsiSuite = parseRsiSuite;
|
|
5
|
+
const contracts_1 = require("./contracts");
|
|
6
|
+
exports.RSI_EVALUATION_TOOLS = Object.freeze([
|
|
7
|
+
'read_file',
|
|
8
|
+
'list_files',
|
|
9
|
+
'glob',
|
|
10
|
+
'grep',
|
|
11
|
+
'batch_read',
|
|
12
|
+
'edit_file',
|
|
13
|
+
'write_file',
|
|
14
|
+
]);
|
|
15
|
+
function object(value, keys) {
|
|
16
|
+
if (!value ||
|
|
17
|
+
typeof value !== 'object' ||
|
|
18
|
+
Array.isArray(value) ||
|
|
19
|
+
(keys && Object.keys(value).some(key => !keys.includes(key)))) {
|
|
20
|
+
throw new Error('Invalid RSI suite object.');
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function limit(value, min, max, field) {
|
|
25
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < min || value > max) {
|
|
26
|
+
throw new Error(`RSI suite ${field} must be between ${min} and ${max}.`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function fileMap(value) {
|
|
31
|
+
const files = object(value);
|
|
32
|
+
const entries = Object.entries(files);
|
|
33
|
+
if (entries.length > 24 ||
|
|
34
|
+
entries.some(([path, content]) => !/^[a-z0-9][a-z0-9_.-]*(?:\/[a-z0-9][a-z0-9_.-]*)*$/u.test(path) ||
|
|
35
|
+
path.length > 180 ||
|
|
36
|
+
path.split('/').length > 8 ||
|
|
37
|
+
path
|
|
38
|
+
.split('/')
|
|
39
|
+
.some(segment => ['node_modules', 'orion.md', 'agents.md'].includes(segment)) ||
|
|
40
|
+
typeof content !== 'string' ||
|
|
41
|
+
Buffer.byteLength(content) > 16384 ||
|
|
42
|
+
content.includes('\0'))) {
|
|
43
|
+
throw new Error('RSI fixture files must be small regular text paths without project configuration.');
|
|
44
|
+
}
|
|
45
|
+
return files;
|
|
46
|
+
}
|
|
47
|
+
function parseTask(value) {
|
|
48
|
+
const { id, split, category, prompt, files, expected } = object(value, [
|
|
49
|
+
'id',
|
|
50
|
+
'split',
|
|
51
|
+
'category',
|
|
52
|
+
'prompt',
|
|
53
|
+
'files',
|
|
54
|
+
'expected',
|
|
55
|
+
]);
|
|
56
|
+
if (typeof id !== 'string' ||
|
|
57
|
+
!/^[a-z][a-z0-9-]{0,63}$/u.test(id) ||
|
|
58
|
+
(split !== 'development' && split !== 'holdout') ||
|
|
59
|
+
!contracts_1.RSI_CATEGORIES.includes(category) ||
|
|
60
|
+
typeof prompt !== 'string' ||
|
|
61
|
+
!prompt.trim() ||
|
|
62
|
+
Buffer.byteLength(prompt) > 4096 ||
|
|
63
|
+
prompt.includes('\0')) {
|
|
64
|
+
throw new Error('Invalid RSI task ID, split, category, or prompt.');
|
|
65
|
+
}
|
|
66
|
+
const initial = fileMap(files);
|
|
67
|
+
const checks = fileMap(expected);
|
|
68
|
+
if (Object.entries(checks).some(([path, content]) => initial[path] === content)) {
|
|
69
|
+
throw new Error('RSI expected changes must differ from the initial fixture.');
|
|
70
|
+
}
|
|
71
|
+
const paths = [...new Set([...Object.keys(initial), ...Object.keys(checks)])].sort();
|
|
72
|
+
if (paths.some((path, index) => paths.slice(index + 1).some(other => other.startsWith(`${path}/`)))) {
|
|
73
|
+
throw new Error('RSI fixture contains conflicting file paths.');
|
|
74
|
+
}
|
|
75
|
+
if ((category === 'cross_module_callers' && Object.keys(checks).length < 2) ||
|
|
76
|
+
(category === 'local_edit_cost' && Object.keys(checks).length !== 1) ||
|
|
77
|
+
((category === 'missing_tool' || category === 'missing_verification') &&
|
|
78
|
+
Object.keys(checks).length)) {
|
|
79
|
+
throw new Error('RSI task checks must match its category.');
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
id,
|
|
83
|
+
split,
|
|
84
|
+
category: category,
|
|
85
|
+
prompt: prompt.trim(),
|
|
86
|
+
files: initial,
|
|
87
|
+
expected: checks,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Fixtures and checks are supplied independently from proposal generation. */
|
|
91
|
+
function parseRsiSuite(value) {
|
|
92
|
+
const { version, model, endpoint, repeats, maxRequests, maxTools, maxTokens, timeoutMs, tasks } = object(value, [
|
|
93
|
+
'version',
|
|
94
|
+
'model',
|
|
95
|
+
'endpoint',
|
|
96
|
+
'repeats',
|
|
97
|
+
'maxRequests',
|
|
98
|
+
'maxTools',
|
|
99
|
+
'maxTokens',
|
|
100
|
+
'timeoutMs',
|
|
101
|
+
'tasks',
|
|
102
|
+
]);
|
|
103
|
+
if (version !== 1 ||
|
|
104
|
+
typeof model !== 'string' ||
|
|
105
|
+
!/^[a-z0-9][a-z0-9._:/-]{0,100}$/iu.test(model) ||
|
|
106
|
+
typeof endpoint !== 'string' ||
|
|
107
|
+
!/^http:\/\/127\.0\.0\.1:\d{1,5}\/v1\/?$/u.test(endpoint)) {
|
|
108
|
+
throw new Error('RSI needs one model and an explicitly selected local OpenAI-compatible endpoint.');
|
|
109
|
+
}
|
|
110
|
+
const url = new URL(endpoint);
|
|
111
|
+
if (!url.port)
|
|
112
|
+
throw new Error('RSI requires an explicit non-default endpoint port.');
|
|
113
|
+
if (!Array.isArray(tasks) || tasks.length < 5 || tasks.length > 12) {
|
|
114
|
+
throw new Error('RSI needs between five and twelve evaluation tasks.');
|
|
115
|
+
}
|
|
116
|
+
const parsed = tasks.map(parseTask);
|
|
117
|
+
if (new Set(parsed.map(task => task.id)).size !== parsed.length ||
|
|
118
|
+
!parsed.some(task => task.split === 'development') ||
|
|
119
|
+
!contracts_1.RSI_CATEGORIES.every(category => parsed.some(task => task.split === 'holdout' && task.category === category))) {
|
|
120
|
+
throw new Error('RSI needs distinct task IDs, development samples, and all four holdout categories.');
|
|
121
|
+
}
|
|
122
|
+
const dev = parsed.filter(task => task.split === 'development');
|
|
123
|
+
if (parsed.some(task => task.split === 'holdout' &&
|
|
124
|
+
dev.some(other => other.prompt === task.prompt ||
|
|
125
|
+
JSON.stringify(Object.entries(other.files).sort()) ===
|
|
126
|
+
JSON.stringify(Object.entries(task.files).sort())))) {
|
|
127
|
+
throw new Error('RSI development and holdout samples must use distinct prompts and fixtures.');
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
version,
|
|
131
|
+
model,
|
|
132
|
+
endpoint: url.origin + '/v1',
|
|
133
|
+
repeats: limit(repeats, 1, 3, 'repeats'),
|
|
134
|
+
maxRequests: limit(maxRequests, 2, 12, 'maxRequests'),
|
|
135
|
+
maxTools: limit(maxTools, 1, 24, 'maxTools'),
|
|
136
|
+
maxTokens: limit(maxTokens, 128, 64000, 'maxTokens'),
|
|
137
|
+
timeoutMs: limit(timeoutMs, 1000, 120000, 'timeoutMs'),
|
|
138
|
+
tasks: [...dev, ...parsed.filter(task => task.split === 'holdout')],
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=evaluation-suite.js.map
|