@nodetool-ai/cli 0.7.0-rc.23 → 0.8.1
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 +79 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/ExecutionTree.d.ts +2 -1
- package/dist/ExecutionTree.d.ts.map +1 -1
- package/dist/ExecutionTree.js +1 -1
- package/dist/ExecutionTree.js.map +1 -1
- package/dist/affected/affected.d.ts +50 -0
- package/dist/affected/affected.d.ts.map +1 -0
- package/dist/affected/affected.js +118 -0
- package/dist/affected/affected.js.map +1 -0
- package/dist/agent-toolbelt.d.ts +15 -0
- package/dist/agent-toolbelt.d.ts.map +1 -0
- package/dist/agent-toolbelt.js +28 -0
- package/dist/agent-toolbelt.js.map +1 -0
- package/dist/api-client.d.ts +12 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +21 -0
- package/dist/api-client.js.map +1 -0
- package/dist/app-build/bundle.d.ts +15 -0
- package/dist/app-build/bundle.d.ts.map +1 -0
- package/dist/app-build/bundle.js +45 -0
- package/dist/app-build/bundle.js.map +1 -0
- package/dist/app-build/watch.d.ts +13 -0
- package/dist/app-build/watch.d.ts.map +1 -0
- package/dist/app-build/watch.js +25 -0
- package/dist/app-build/watch.js.map +1 -0
- package/dist/app-debug/app-target.d.ts +14 -0
- package/dist/app-debug/app-target.d.ts.map +1 -0
- package/dist/app-debug/app-target.js +120 -0
- package/dist/app-debug/app-target.js.map +1 -0
- package/dist/app-debug/harness.d.ts +27 -0
- package/dist/app-debug/harness.d.ts.map +1 -0
- package/dist/app-debug/harness.js +93 -0
- package/dist/app-debug/harness.js.map +1 -0
- package/dist/app-debug/index.d.ts +12 -0
- package/dist/app-debug/index.d.ts.map +1 -0
- package/dist/app-debug/index.js +9 -0
- package/dist/app-debug/index.js.map +1 -0
- package/dist/app.d.ts +38 -48
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +979 -677
- package/dist/app.js.map +1 -1
- package/dist/bash-tool.d.ts +13 -0
- package/dist/bash-tool.d.ts.map +1 -0
- package/dist/bash-tool.js +85 -0
- package/dist/bash-tool.js.map +1 -0
- package/dist/chat-codeact.d.ts +85 -0
- package/dist/chat-codeact.d.ts.map +1 -0
- package/dist/chat-codeact.js +141 -0
- package/dist/chat-codeact.js.map +1 -0
- package/dist/chat-context.d.ts +18 -0
- package/dist/chat-context.d.ts.map +1 -0
- package/dist/chat-context.js +27 -0
- package/dist/chat-context.js.map +1 -0
- package/dist/chat-media.d.ts +3 -0
- package/dist/chat-media.d.ts.map +1 -0
- package/dist/chat-media.js +46 -0
- package/dist/chat-media.js.map +1 -0
- package/dist/chat-prompts.d.ts +20 -0
- package/dist/chat-prompts.d.ts.map +1 -0
- package/dist/chat-prompts.js +42 -0
- package/dist/chat-prompts.js.map +1 -0
- package/dist/chat-sessions.d.ts +25 -0
- package/dist/chat-sessions.d.ts.map +1 -0
- package/dist/chat-sessions.js +153 -0
- package/dist/chat-sessions.js.map +1 -0
- package/dist/command-errors.d.ts +10 -0
- package/dist/command-errors.d.ts.map +1 -0
- package/dist/command-errors.js +15 -0
- package/dist/command-errors.js.map +1 -0
- package/dist/commands/__tests__/jtbd.test.d.ts +2 -0
- package/dist/commands/__tests__/jtbd.test.d.ts.map +1 -0
- package/dist/commands/__tests__/jtbd.test.js +120 -0
- package/dist/commands/__tests__/jtbd.test.js.map +1 -0
- package/dist/commands/__tests__/timeline-render-audio.test.d.ts +2 -0
- package/dist/commands/__tests__/timeline-render-audio.test.d.ts.map +1 -0
- package/dist/commands/__tests__/timeline-render-audio.test.js +53 -0
- package/dist/commands/__tests__/timeline-render-audio.test.js.map +1 -0
- package/dist/commands/__tests__/timeline-render.test.d.ts +2 -0
- package/dist/commands/__tests__/timeline-render.test.d.ts.map +1 -0
- package/dist/commands/__tests__/timeline-render.test.js +115 -0
- package/dist/commands/__tests__/timeline-render.test.js.map +1 -0
- package/dist/commands/affected.d.ts +9 -0
- package/dist/commands/affected.d.ts.map +1 -0
- package/dist/commands/affected.js +122 -0
- package/dist/commands/affected.js.map +1 -0
- package/dist/commands/agent.d.ts +26 -4
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +327 -306
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/app.d.ts +3 -0
- package/dist/commands/app.d.ts.map +1 -0
- package/dist/commands/app.js +381 -0
- package/dist/commands/app.js.map +1 -0
- package/dist/commands/apps.d.ts +15 -0
- package/dist/commands/apps.d.ts.map +1 -0
- package/dist/commands/apps.js +180 -0
- package/dist/commands/apps.js.map +1 -0
- package/dist/commands/auth.d.ts +12 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +154 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/collections.d.ts +10 -0
- package/dist/commands/collections.d.ts.map +1 -0
- package/dist/commands/collections.js +257 -0
- package/dist/commands/collections.js.map +1 -0
- package/dist/commands/costs.d.ts +15 -0
- package/dist/commands/costs.d.ts.map +1 -0
- package/dist/commands/costs.js +201 -0
- package/dist/commands/costs.js.map +1 -0
- package/dist/commands/db.d.ts +3 -0
- package/dist/commands/db.d.ts.map +1 -0
- package/dist/commands/db.js +176 -0
- package/dist/commands/db.js.map +1 -0
- package/dist/commands/debug.d.ts +13 -0
- package/dist/commands/debug.d.ts.map +1 -0
- package/dist/commands/debug.js +138 -0
- package/dist/commands/debug.js.map +1 -0
- package/dist/commands/deploy-helpers.d.ts +49 -18
- package/dist/commands/deploy-helpers.d.ts.map +1 -1
- package/dist/commands/deploy-helpers.js +10 -276
- package/dist/commands/deploy-helpers.js.map +1 -1
- package/dist/commands/deploy.d.ts +0 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +21 -217
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/eval.d.ts +152 -0
- package/dist/commands/eval.d.ts.map +1 -0
- package/dist/commands/eval.js +688 -0
- package/dist/commands/eval.js.map +1 -0
- package/dist/commands/game.d.ts +4 -0
- package/dist/commands/game.d.ts.map +1 -0
- package/dist/commands/game.js +395 -0
- package/dist/commands/game.js.map +1 -0
- package/dist/commands/generate.d.ts +17 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +324 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/generations.d.ts +17 -0
- package/dist/commands/generations.d.ts.map +1 -0
- package/dist/commands/generations.js +408 -0
- package/dist/commands/generations.js.map +1 -0
- package/dist/commands/harness.d.ts +19 -0
- package/dist/commands/harness.d.ts.map +1 -0
- package/dist/commands/harness.js +361 -0
- package/dist/commands/harness.js.map +1 -0
- package/dist/commands/js-script-validation-output.d.ts +7 -0
- package/dist/commands/js-script-validation-output.d.ts.map +1 -0
- package/dist/commands/js-script-validation-output.js +5 -0
- package/dist/commands/js-script-validation-output.js.map +1 -0
- package/dist/commands/js-script-versions.d.ts +53 -0
- package/dist/commands/js-script-versions.d.ts.map +1 -0
- package/dist/commands/js-script-versions.js +89 -0
- package/dist/commands/js-script-versions.js.map +1 -0
- package/dist/commands/js-script.d.ts +29 -0
- package/dist/commands/js-script.d.ts.map +1 -0
- package/dist/commands/js-script.js +227 -0
- package/dist/commands/js-script.js.map +1 -0
- package/dist/commands/jtbd.d.ts +38 -0
- package/dist/commands/jtbd.d.ts.map +1 -0
- package/dist/commands/jtbd.js +261 -0
- package/dist/commands/jtbd.js.map +1 -0
- package/dist/commands/local-db.d.ts +16 -0
- package/dist/commands/local-db.d.ts.map +1 -0
- package/dist/commands/local-db.js +33 -0
- package/dist/commands/local-db.js.map +1 -0
- package/dist/commands/migrate-code-inputs.d.ts +24 -0
- package/dist/commands/migrate-code-inputs.d.ts.map +1 -0
- package/dist/commands/migrate-code-inputs.js +120 -0
- package/dist/commands/migrate-code-inputs.js.map +1 -0
- package/dist/commands/models-hf.js +4 -4
- package/dist/commands/models-hf.js.map +1 -1
- package/dist/commands/models-recommended.d.ts.map +1 -1
- package/dist/commands/models-recommended.js +16 -24
- package/dist/commands/models-recommended.js.map +1 -1
- package/dist/commands/node.d.ts +10 -0
- package/dist/commands/node.d.ts.map +1 -0
- package/dist/commands/node.js +72 -0
- package/dist/commands/node.js.map +1 -0
- package/dist/commands/output.d.ts +24 -0
- package/dist/commands/output.d.ts.map +1 -0
- package/dist/commands/output.js +132 -0
- package/dist/commands/output.js.map +1 -0
- package/dist/commands/package-helpers.d.ts +1 -7
- package/dist/commands/package-helpers.d.ts.map +1 -1
- package/dist/commands/package-helpers.js +3 -26
- package/dist/commands/package-helpers.js.map +1 -1
- package/dist/commands/package.js +2 -2
- package/dist/commands/package.js.map +1 -1
- package/dist/commands/packs.d.ts +13 -0
- package/dist/commands/packs.d.ts.map +1 -0
- package/dist/commands/packs.js +60 -0
- package/dist/commands/packs.js.map +1 -0
- package/dist/commands/reliability.d.ts +14 -0
- package/dist/commands/reliability.d.ts.map +1 -0
- package/dist/commands/reliability.js +80 -0
- package/dist/commands/reliability.js.map +1 -0
- package/dist/commands/resource-read.d.ts +28 -0
- package/dist/commands/resource-read.d.ts.map +1 -0
- package/dist/commands/resource-read.js +316 -0
- package/dist/commands/resource-read.js.map +1 -0
- package/dist/commands/sketch-validation-output.d.ts +7 -0
- package/dist/commands/sketch-validation-output.d.ts.map +1 -0
- package/dist/commands/sketch-validation-output.js +5 -0
- package/dist/commands/sketch-validation-output.js.map +1 -0
- package/dist/commands/sketch-versions.d.ts +66 -0
- package/dist/commands/sketch-versions.d.ts.map +1 -0
- package/dist/commands/sketch-versions.js +108 -0
- package/dist/commands/sketch-versions.js.map +1 -0
- package/dist/commands/sketch.d.ts +21 -0
- package/dist/commands/sketch.d.ts.map +1 -0
- package/dist/commands/sketch.js +117 -0
- package/dist/commands/sketch.js.map +1 -0
- package/dist/commands/storage.d.ts +24 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +112 -0
- package/dist/commands/storage.js.map +1 -0
- package/dist/commands/telegram.d.ts +11 -0
- package/dist/commands/telegram.d.ts.map +1 -0
- package/dist/commands/telegram.js +66 -0
- package/dist/commands/telegram.js.map +1 -0
- package/dist/commands/timeline-render.d.ts +80 -0
- package/dist/commands/timeline-render.d.ts.map +1 -0
- package/dist/commands/timeline-render.js +465 -0
- package/dist/commands/timeline-render.js.map +1 -0
- package/dist/commands/timeline-validation-output.d.ts +7 -0
- package/dist/commands/timeline-validation-output.d.ts.map +1 -0
- package/dist/commands/timeline-validation-output.js +9 -0
- package/dist/commands/timeline-validation-output.js.map +1 -0
- package/dist/commands/timeline-versions.d.ts +72 -0
- package/dist/commands/timeline-versions.d.ts.map +1 -0
- package/dist/commands/timeline-versions.js +108 -0
- package/dist/commands/timeline-versions.js.map +1 -0
- package/dist/commands/timeline.d.ts +22 -0
- package/dist/commands/timeline.d.ts.map +1 -0
- package/dist/commands/timeline.js +119 -0
- package/dist/commands/timeline.js.map +1 -0
- package/dist/commands/validate.d.ts +22 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +127 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/commands/validation-output.d.ts +25 -0
- package/dist/commands/validation-output.d.ts.map +1 -0
- package/dist/commands/validation-output.js +29 -0
- package/dist/commands/validation-output.js.map +1 -0
- package/dist/commands/version-commands.d.ts +94 -0
- package/dist/commands/version-commands.d.ts.map +1 -0
- package/dist/commands/version-commands.js +227 -0
- package/dist/commands/version-commands.js.map +1 -0
- package/dist/commands/worker-models.d.ts +13 -0
- package/dist/commands/worker-models.d.ts.map +1 -0
- package/dist/commands/worker-models.js +207 -0
- package/dist/commands/worker-models.js.map +1 -0
- package/dist/commands/worker.d.ts +23 -0
- package/dist/commands/worker.d.ts.map +1 -0
- package/dist/commands/worker.js +374 -0
- package/dist/commands/worker.js.map +1 -0
- package/dist/debug/browser-runner.d.ts +21 -0
- package/dist/debug/browser-runner.d.ts.map +1 -0
- package/dist/debug/browser-runner.js +196 -0
- package/dist/debug/browser-runner.js.map +1 -0
- package/dist/debug/collector.d.ts +9 -0
- package/dist/debug/collector.d.ts.map +1 -0
- package/dist/debug/collector.js +9 -0
- package/dist/debug/collector.js.map +1 -0
- package/dist/debug/diff.d.ts +48 -0
- package/dist/debug/diff.d.ts.map +1 -0
- package/dist/debug/diff.js +68 -0
- package/dist/debug/diff.js.map +1 -0
- package/dist/debug/harness.d.ts +11 -0
- package/dist/debug/harness.d.ts.map +1 -0
- package/dist/debug/harness.js +103 -0
- package/dist/debug/harness.js.map +1 -0
- package/dist/debug/index.d.ts +17 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +16 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/markdown.d.ts +3 -0
- package/dist/debug/markdown.d.ts.map +1 -0
- package/dist/debug/markdown.js +127 -0
- package/dist/debug/markdown.js.map +1 -0
- package/dist/debug/server-runner.d.ts +22 -0
- package/dist/debug/server-runner.d.ts.map +1 -0
- package/dist/debug/server-runner.js +164 -0
- package/dist/debug/server-runner.js.map +1 -0
- package/dist/debug/target.d.ts +34 -0
- package/dist/debug/target.d.ts.map +1 -0
- package/dist/debug/target.js +104 -0
- package/dist/debug/target.js.map +1 -0
- package/dist/debug/trace.d.ts +30 -0
- package/dist/debug/trace.d.ts.map +1 -0
- package/dist/debug/trace.js +87 -0
- package/dist/debug/trace.js.map +1 -0
- package/dist/debug/types.d.ts +82 -0
- package/dist/debug/types.d.ts.map +1 -0
- package/dist/debug/types.js +13 -0
- package/dist/debug/types.js.map +1 -0
- package/dist/debug/verdict.d.ts +3 -0
- package/dist/debug/verdict.d.ts.map +1 -0
- package/dist/debug/verdict.js +78 -0
- package/dist/debug/verdict.js.map +1 -0
- package/dist/debug/watch.d.ts +23 -0
- package/dist/debug/watch.d.ts.map +1 -0
- package/dist/debug/watch.js +68 -0
- package/dist/debug/watch.js.map +1 -0
- package/dist/diagnose.d.ts +139 -0
- package/dist/diagnose.d.ts.map +1 -0
- package/dist/diagnose.js +418 -0
- package/dist/diagnose.js.map +1 -0
- package/dist/evals/graph-runner.d.ts +8 -0
- package/dist/evals/graph-runner.d.ts.map +1 -0
- package/dist/evals/graph-runner.js +136 -0
- package/dist/evals/graph-runner.js.map +1 -0
- package/dist/harness/capability-coverage.d.ts +161 -0
- package/dist/harness/capability-coverage.d.ts.map +1 -0
- package/dist/harness/capability-coverage.js +266 -0
- package/dist/harness/capability-coverage.js.map +1 -0
- package/dist/harness/capability-table.d.ts +17 -0
- package/dist/harness/capability-table.d.ts.map +1 -0
- package/dist/harness/capability-table.js +3576 -0
- package/dist/harness/capability-table.js.map +1 -0
- package/dist/harness/changed-files.d.ts +18 -0
- package/dist/harness/changed-files.d.ts.map +1 -0
- package/dist/harness/changed-files.js +76 -0
- package/dist/harness/changed-files.js.map +1 -0
- package/dist/harness/declared-capabilities.d.ts +12 -0
- package/dist/harness/declared-capabilities.d.ts.map +1 -0
- package/dist/harness/declared-capabilities.js +21 -0
- package/dist/harness/declared-capabilities.js.map +1 -0
- package/dist/harness/registry.d.ts +162 -0
- package/dist/harness/registry.d.ts.map +1 -0
- package/dist/harness/registry.js +1738 -0
- package/dist/harness/registry.js.map +1 -0
- package/dist/index.js +121 -130
- package/dist/index.js.map +1 -1
- package/dist/interaction-script.d.ts +17 -0
- package/dist/interaction-script.d.ts.map +1 -0
- package/dist/interaction-script.js +47 -0
- package/dist/interaction-script.js.map +1 -0
- package/dist/js-script-debug/harness.d.ts +114 -0
- package/dist/js-script-debug/harness.d.ts.map +1 -0
- package/dist/js-script-debug/harness.js +252 -0
- package/dist/js-script-debug/harness.js.map +1 -0
- package/dist/js-script-debug/index.d.ts +9 -0
- package/dist/js-script-debug/index.d.ts.map +1 -0
- package/dist/js-script-debug/index.js +9 -0
- package/dist/js-script-debug/index.js.map +1 -0
- package/dist/js-script-debug/interactions.d.ts +19 -0
- package/dist/js-script-debug/interactions.d.ts.map +1 -0
- package/dist/js-script-debug/interactions.js +17 -0
- package/dist/js-script-debug/interactions.js.map +1 -0
- package/dist/js-script-debug/target.d.ts +20 -0
- package/dist/js-script-debug/target.d.ts.map +1 -0
- package/dist/js-script-debug/target.js +78 -0
- package/dist/js-script-debug/target.js.map +1 -0
- package/dist/local-model-interfaces.d.ts +20 -0
- package/dist/local-model-interfaces.d.ts.map +1 -0
- package/dist/local-model-interfaces.js +64 -0
- package/dist/local-model-interfaces.js.map +1 -0
- package/dist/local-secrets.d.ts +3 -0
- package/dist/local-secrets.d.ts.map +1 -0
- package/dist/local-secrets.js +16 -0
- package/dist/local-secrets.js.map +1 -0
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +7 -2
- package/dist/markdown.js.map +1 -1
- package/dist/node/run-node.d.ts +28 -0
- package/dist/node/run-node.d.ts.map +1 -0
- package/dist/node/run-node.js +76 -0
- package/dist/node/run-node.js.map +1 -0
- package/dist/node-registry.d.ts +13 -0
- package/dist/node-registry.d.ts.map +1 -0
- package/dist/node-registry.js +36 -0
- package/dist/node-registry.js.map +1 -0
- package/dist/nodetool.js +845 -309
- package/dist/nodetool.js.map +1 -1
- package/dist/numeric-options.d.ts +22 -0
- package/dist/numeric-options.d.ts.map +1 -0
- package/dist/numeric-options.js +45 -0
- package/dist/numeric-options.js.map +1 -0
- package/dist/permission-gate.d.ts +55 -0
- package/dist/permission-gate.d.ts.map +1 -0
- package/dist/permission-gate.js +118 -0
- package/dist/permission-gate.js.map +1 -0
- package/dist/predicates.d.ts +6 -0
- package/dist/predicates.d.ts.map +1 -0
- package/dist/predicates.js +6 -0
- package/dist/predicates.js.map +1 -0
- package/dist/providers.d.ts +73 -10
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +329 -97
- package/dist/providers.js.map +1 -1
- package/dist/readline-input.d.ts +13 -19
- package/dist/readline-input.d.ts.map +1 -1
- package/dist/readline-input.js +201 -190
- package/dist/readline-input.js.map +1 -1
- package/dist/run-budget.d.ts +40 -0
- package/dist/run-budget.d.ts.map +1 -0
- package/dist/run-budget.js +119 -0
- package/dist/run-budget.js.map +1 -0
- package/dist/run-dsl-supervised.d.ts +11 -0
- package/dist/run-dsl-supervised.d.ts.map +1 -0
- package/dist/run-dsl-supervised.js +82 -0
- package/dist/run-dsl-supervised.js.map +1 -0
- package/dist/run-dsl.d.ts +23 -0
- package/dist/run-dsl.d.ts.map +1 -1
- package/dist/run-dsl.js +40 -9
- package/dist/run-dsl.js.map +1 -1
- package/dist/run-json.d.ts +24 -0
- package/dist/run-json.d.ts.map +1 -0
- package/dist/run-json.js +132 -0
- package/dist/run-json.js.map +1 -0
- package/dist/sandbox-catalog.d.ts +12 -0
- package/dist/sandbox-catalog.d.ts.map +1 -0
- package/dist/sandbox-catalog.js +27 -0
- package/dist/sandbox-catalog.js.map +1 -0
- package/dist/settings.d.ts +11 -10
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +71 -13
- package/dist/settings.js.map +1 -1
- package/dist/sketch-debug/harness.d.ts +87 -0
- package/dist/sketch-debug/harness.d.ts.map +1 -0
- package/dist/sketch-debug/harness.js +178 -0
- package/dist/sketch-debug/harness.js.map +1 -0
- package/dist/sketch-debug/index.d.ts +9 -0
- package/dist/sketch-debug/index.d.ts.map +1 -0
- package/dist/sketch-debug/index.js +9 -0
- package/dist/sketch-debug/index.js.map +1 -0
- package/dist/sketch-debug/interactions.d.ts +19 -0
- package/dist/sketch-debug/interactions.d.ts.map +1 -0
- package/dist/sketch-debug/interactions.js +17 -0
- package/dist/sketch-debug/interactions.js.map +1 -0
- package/dist/sketch-debug/target.d.ts +48 -0
- package/dist/sketch-debug/target.d.ts.map +1 -0
- package/dist/sketch-debug/target.js +138 -0
- package/dist/sketch-debug/target.js.map +1 -0
- package/dist/stdin.d.ts +18 -19
- package/dist/stdin.d.ts.map +1 -1
- package/dist/stdin.js +159 -157
- package/dist/stdin.js.map +1 -1
- package/dist/supervisor.d.ts +97 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +194 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/terminal-clipboard.d.ts +3 -0
- package/dist/terminal-clipboard.d.ts.map +1 -0
- package/dist/terminal-clipboard.js +24 -0
- package/dist/terminal-clipboard.js.map +1 -0
- package/dist/terminal-mouse.d.ts +24 -0
- package/dist/terminal-mouse.d.ts.map +1 -0
- package/dist/terminal-mouse.js +84 -0
- package/dist/terminal-mouse.js.map +1 -0
- package/dist/terminal-screen.d.ts +41 -0
- package/dist/terminal-screen.d.ts.map +1 -0
- package/dist/terminal-screen.js +228 -0
- package/dist/terminal-screen.js.map +1 -0
- package/dist/timeline-debug/harness.d.ts +79 -0
- package/dist/timeline-debug/harness.d.ts.map +1 -0
- package/dist/timeline-debug/harness.js +155 -0
- package/dist/timeline-debug/harness.js.map +1 -0
- package/dist/timeline-debug/index.d.ts +9 -0
- package/dist/timeline-debug/index.d.ts.map +1 -0
- package/dist/timeline-debug/index.js +9 -0
- package/dist/timeline-debug/index.js.map +1 -0
- package/dist/timeline-debug/interactions.d.ts +19 -0
- package/dist/timeline-debug/interactions.d.ts.map +1 -0
- package/dist/timeline-debug/interactions.js +17 -0
- package/dist/timeline-debug/interactions.js.map +1 -0
- package/dist/timeline-debug/target.d.ts +34 -0
- package/dist/timeline-debug/target.d.ts.map +1 -0
- package/dist/timeline-debug/target.js +132 -0
- package/dist/timeline-debug/target.js.map +1 -0
- package/dist/tool-format.d.ts +54 -0
- package/dist/tool-format.d.ts.map +1 -0
- package/dist/tool-format.js +360 -0
- package/dist/tool-format.js.map +1 -0
- package/dist/useExecutionState.d.ts.map +1 -1
- package/dist/useExecutionState.js +8 -4
- package/dist/useExecutionState.js.map +1 -1
- package/dist/validate/index.d.ts +28 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +51 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/websocket-client.d.ts +78 -15
- package/dist/websocket-client.d.ts.map +1 -1
- package/dist/websocket-client.js +497 -171
- package/dist/websocket-client.js.map +1 -1
- package/package.json +62 -31
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verdict.js","sourceRoot":"","sources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9C,CAAC;IAED,wEAAwE;IACxE,0EAA0E;IAC1E,wCAAwC;IACxC,MAAM,QAAQ,GAAG,MAAM;QACrB,CAAC,CAAC,2BAA2B,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;QACvD,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,OAAO,GAAiB;QAC5B,EAAE;QACF,QAAQ,EAAE,EAAE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,eAAe,CAAC,CAAC,CAAC,QAAQ;QAC3E,MAAM;KACP,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC9B,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type RunSnapshot } from "./diff.js";
|
|
2
|
+
/** Minimal shape of `fs.watch`, narrowed to what the loop uses. */
|
|
3
|
+
export type FileWatcher = (path: string, onChange: () => void) => {
|
|
4
|
+
close: () => void;
|
|
5
|
+
};
|
|
6
|
+
export interface WatchLoopInit<T> {
|
|
7
|
+
/** The file whose saves trigger a re-run. */
|
|
8
|
+
file: string;
|
|
9
|
+
/** The run already performed, so the first diff has something to compare to. */
|
|
10
|
+
first: T;
|
|
11
|
+
run: () => Promise<T>;
|
|
12
|
+
snapshot: (result: T) => RunSnapshot;
|
|
13
|
+
/** Label for the status transition line, e.g. `server` or `stage`. */
|
|
14
|
+
statusLabel?: string;
|
|
15
|
+
log: (line: string) => void;
|
|
16
|
+
/** Resolves to stop watching. Defaults to the first SIGINT. */
|
|
17
|
+
stop?: Promise<void>;
|
|
18
|
+
debounceMs?: number;
|
|
19
|
+
watchFile?: FileWatcher;
|
|
20
|
+
}
|
|
21
|
+
/** Watch `file`, re-running and diffing until the stop signal resolves. */
|
|
22
|
+
export declare function runWatchLoop<T>(init: WatchLoopInit<T>): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=watch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/debug/watch.ts"],"names":[],"mappings":"AAaA,OAAO,EAAwB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnE,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,IAAI,KACjB;IAAE,KAAK,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC;AAE3B,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IACtB,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,WAAW,CAAC;IACrC,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,+DAA+D;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAaD,2EAA2E;AAC3E,wBAAsB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0C3E"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The watch loop `nodetool debug --watch` and `nodetool app build --watch`
|
|
3
|
+
* share: re-run on save, diff the new run against the last one, print only what
|
|
4
|
+
* moved.
|
|
5
|
+
*
|
|
6
|
+
* The loop owns the awkward parts — debouncing an editor's write burst, never
|
|
7
|
+
* running two passes at once, surviving a run that throws — and nothing else.
|
|
8
|
+
* What a run means is the caller's: it supplies `run` and a projection into
|
|
9
|
+
* {@link RunSnapshot}, which is what the differ compares. The watcher and the
|
|
10
|
+
* stop signal are injectable so the loop is testable without touching the file
|
|
11
|
+
* system or the process.
|
|
12
|
+
*/
|
|
13
|
+
import { watch } from "node:fs";
|
|
14
|
+
import { diffRuns, formatDiff } from "./diff.js";
|
|
15
|
+
const defaultWatcher = (path, onChange) => watch(path, onChange);
|
|
16
|
+
function sigintStop(log) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
process.on("SIGINT", () => {
|
|
19
|
+
log("\nStopped watching.");
|
|
20
|
+
resolve();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** Watch `file`, re-running and diffing until the stop signal resolves. */
|
|
25
|
+
export async function runWatchLoop(init) {
|
|
26
|
+
const log = init.log;
|
|
27
|
+
log(`\nWatching ${init.file} — edit to re-run, Ctrl-C to stop.`);
|
|
28
|
+
let previous = init.snapshot(init.first);
|
|
29
|
+
let running = false;
|
|
30
|
+
let pending = false;
|
|
31
|
+
let timer = null;
|
|
32
|
+
const rerun = async () => {
|
|
33
|
+
if (running) {
|
|
34
|
+
pending = true;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
running = true;
|
|
38
|
+
try {
|
|
39
|
+
const next = init.snapshot(await init.run());
|
|
40
|
+
const diff = diffRuns(previous, next);
|
|
41
|
+
previous = next;
|
|
42
|
+
log(`\n── re-run @ ${new Date().toLocaleTimeString()} ──`);
|
|
43
|
+
log(formatDiff(diff, init.statusLabel));
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
log(`Re-run failed: ${String(e)}`);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
running = false;
|
|
50
|
+
if (pending) {
|
|
51
|
+
pending = false;
|
|
52
|
+
await rerun();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const debounceMs = init.debounceMs ?? 200;
|
|
57
|
+
const watcher = (init.watchFile ?? defaultWatcher)(init.file, () => {
|
|
58
|
+
// Debounce editor write bursts (one save → several change events).
|
|
59
|
+
if (timer)
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
timer = setTimeout(() => void rerun(), debounceMs);
|
|
62
|
+
});
|
|
63
|
+
await (init.stop ?? sigintStop(log));
|
|
64
|
+
if (timer)
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
watcher.close();
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch.js","sourceRoot":"","sources":["../../src/debug/watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAoB,MAAM,WAAW,CAAC;AAwBnE,MAAM,cAAc,GAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAE9E,SAAS,UAAU,CAAC,GAA2B;IAC7C,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QACnC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;YACxB,GAAG,CAAC,qBAAqB,CAAC,CAAC;YAC3B,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,IAAsB;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACrB,GAAG,CAAC,cAAc,IAAI,CAAC,IAAI,oCAAoC,CAAC,CAAC;IAEjE,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC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,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACrC,IAAI,KAAK;QAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure failure-diagnosis aggregator for `nodetool agent diagnose <job_id>`.
|
|
3
|
+
*
|
|
4
|
+
* When a run fails the cause is scattered across the job record, the structured
|
|
5
|
+
* processing-message stream, and the OpenTelemetry trace. `diagnoseRun` folds
|
|
6
|
+
* those three sources into one `DiagnosisReport` that names the failing
|
|
7
|
+
* node/step, the error, the last `llm.chat`/`llm.stream` span at or before the
|
|
8
|
+
* failure (with tokens, model, and a truncated response), a memory snapshot, and
|
|
9
|
+
* a deterministic "likely fix locus" pointing at where to start.
|
|
10
|
+
*
|
|
11
|
+
* The function is pure and deterministic — it only reads its inputs and never
|
|
12
|
+
* touches the filesystem, env, or clock. The CLI wiring in
|
|
13
|
+
* `commands/agent.ts` gathers the real inputs and calls it. Keep all I/O out of
|
|
14
|
+
* this module so it stays unit-testable under the CLI vitest stub setup, which
|
|
15
|
+
* stubs every `@nodetool-ai/*` runtime package — only `import type` is used.
|
|
16
|
+
*/
|
|
17
|
+
import type { ProcessingMessage } from "@nodetool-ai/protocol";
|
|
18
|
+
/** A failed run/job record, as returned by `jobs.get` (subset we read). */
|
|
19
|
+
export interface DiagnoseJob {
|
|
20
|
+
id: string;
|
|
21
|
+
status?: string;
|
|
22
|
+
error?: string | null;
|
|
23
|
+
workflowId?: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* One OpenTelemetry span, loosely typed. Structurally compatible with the debug
|
|
27
|
+
* harness `TraceSpan`, but only the fields the diagnoser reads are required so
|
|
28
|
+
* callers can pass either parsed JSONL lines or richer span objects.
|
|
29
|
+
*/
|
|
30
|
+
/** An OpenTelemetry attribute value, as the trace JSONL carries it. */
|
|
31
|
+
export type SpanAttributeValue = string | number | boolean | null | Array<string | number | boolean | null>;
|
|
32
|
+
export interface TraceSpanLite {
|
|
33
|
+
name: string;
|
|
34
|
+
span_id?: string;
|
|
35
|
+
parent_span_id?: string | null;
|
|
36
|
+
start_time_ms?: number;
|
|
37
|
+
end_time_ms?: number;
|
|
38
|
+
attributes?: Record<string, SpanAttributeValue>;
|
|
39
|
+
status?: {
|
|
40
|
+
code?: string;
|
|
41
|
+
message?: string;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Everything `diagnoseRun` needs. Every field is optional so the diagnoser
|
|
46
|
+
* degrades gracefully when a source is unavailable (it reports what was
|
|
47
|
+
* missing rather than crashing).
|
|
48
|
+
*/
|
|
49
|
+
export interface DiagnoseInputs {
|
|
50
|
+
job?: DiagnoseJob;
|
|
51
|
+
/** Processing messages from the run (e.g. a bundle's messages.jsonl). */
|
|
52
|
+
messages?: ReadonlyArray<ProcessingMessage | Record<string, unknown>>;
|
|
53
|
+
/** Trace spans (e.g. a parsed trace.jsonl). */
|
|
54
|
+
spans?: ReadonlyArray<TraceSpanLite>;
|
|
55
|
+
/** A memory/state snapshot captured at failure. */
|
|
56
|
+
memory?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
/** The node or step the run failed on. */
|
|
59
|
+
interface FailureSite {
|
|
60
|
+
/** Where the failure was identified. */
|
|
61
|
+
kind: "node" | "step" | "job" | "unknown";
|
|
62
|
+
/** Node id, when a failing node was found. */
|
|
63
|
+
nodeId: string | null;
|
|
64
|
+
/** Node type, when known (e.g. "nodetool.text.Concatenate"). */
|
|
65
|
+
nodeType: string | null;
|
|
66
|
+
/** Node display name, when known. */
|
|
67
|
+
nodeName: string | null;
|
|
68
|
+
/** Step id, when the failure came from an agent step. */
|
|
69
|
+
stepId: string | null;
|
|
70
|
+
/** Step instructions/title, when known. */
|
|
71
|
+
stepLabel: string | null;
|
|
72
|
+
}
|
|
73
|
+
/** Summary of the last LLM call before the failure. */
|
|
74
|
+
interface LastLlmSummary {
|
|
75
|
+
/** Span name — "llm.chat" or "llm.stream". */
|
|
76
|
+
name: string;
|
|
77
|
+
provider: string | null;
|
|
78
|
+
model: string | null;
|
|
79
|
+
inputTokens: number | null;
|
|
80
|
+
outputTokens: number | null;
|
|
81
|
+
totalTokens: number | null;
|
|
82
|
+
costUsd: number | null;
|
|
83
|
+
/** Truncated `llm.response.content` from the span attributes. */
|
|
84
|
+
responsePreview: string | null;
|
|
85
|
+
durationMs: number | null;
|
|
86
|
+
/** Span status code, when present (e.g. "ERROR"). */
|
|
87
|
+
statusCode: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** Compact view of the memory/state snapshot at failure. */
|
|
90
|
+
interface MemorySnapshot {
|
|
91
|
+
/** Number of top-level keys. */
|
|
92
|
+
keyCount: number;
|
|
93
|
+
/** Top-level keys (capped). */
|
|
94
|
+
keys: string[];
|
|
95
|
+
/** Per-key one-line value previews (capped, truncated). */
|
|
96
|
+
preview: Record<string, string>;
|
|
97
|
+
}
|
|
98
|
+
/** A heuristic pointer at where to start fixing. */
|
|
99
|
+
interface FixLocus {
|
|
100
|
+
/** One-line, human-readable starting point. */
|
|
101
|
+
summary: string;
|
|
102
|
+
/** Failing node type, when derivable. */
|
|
103
|
+
nodeType: string | null;
|
|
104
|
+
/** Model implicated by the last LLM call, when derivable. */
|
|
105
|
+
model: string | null;
|
|
106
|
+
/** Concrete hints (prompt/model/file references) extracted from the error. */
|
|
107
|
+
hints: string[];
|
|
108
|
+
}
|
|
109
|
+
export interface DiagnosisReport {
|
|
110
|
+
/** True when no failure could be identified from any source. */
|
|
111
|
+
ok: boolean;
|
|
112
|
+
jobId: string | null;
|
|
113
|
+
jobStatus: string | null;
|
|
114
|
+
/** The node/step the run failed on. */
|
|
115
|
+
failure: FailureSite;
|
|
116
|
+
/** The failure message, normalized to a single string. */
|
|
117
|
+
error: string | null;
|
|
118
|
+
/** The last llm.chat/llm.stream span at or before the failure. */
|
|
119
|
+
lastLlm: LastLlmSummary | null;
|
|
120
|
+
/** Memory/state snapshot summary, when a snapshot was supplied. */
|
|
121
|
+
memory: MemorySnapshot | null;
|
|
122
|
+
/** Where to start fixing. Null only when there's no failure. */
|
|
123
|
+
fixLocus: FixLocus | null;
|
|
124
|
+
/** Sources that were absent — surfaced so callers see partial coverage. */
|
|
125
|
+
missing: string[];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Aggregate a failed run's job record, message stream, and trace spans into a
|
|
129
|
+
* single `DiagnosisReport`. Deterministic and side-effect-free.
|
|
130
|
+
*/
|
|
131
|
+
export declare function diagnoseRun(inputs: DiagnoseInputs): DiagnosisReport;
|
|
132
|
+
/**
|
|
133
|
+
* Render a `DiagnosisReport` as a plain-text block for the terminal. Kept here
|
|
134
|
+
* (not in the CLI command) so the formatting is unit-testable and dependency-
|
|
135
|
+
* free; the command adds color separately if desired.
|
|
136
|
+
*/
|
|
137
|
+
export declare function renderDiagnosis(report: DiagnosisReport): string;
|
|
138
|
+
export {};
|
|
139
|
+
//# sourceMappingURL=diagnose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnose.d.ts","sourceRoot":"","sources":["../src/diagnose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAW/D,2EAA2E;AAC3E,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,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AC;IACrB,kEAAkE;IAClE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,mEAAmE;IACnE,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,gEAAgE;IAChE,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,2EAA2E;IAC3E,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAwUD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,eAAe,CAgEnE;AAMD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAwD/D"}
|
package/dist/diagnose.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure failure-diagnosis aggregator for `nodetool agent diagnose <job_id>`.
|
|
3
|
+
*
|
|
4
|
+
* When a run fails the cause is scattered across the job record, the structured
|
|
5
|
+
* processing-message stream, and the OpenTelemetry trace. `diagnoseRun` folds
|
|
6
|
+
* those three sources into one `DiagnosisReport` that names the failing
|
|
7
|
+
* node/step, the error, the last `llm.chat`/`llm.stream` span at or before the
|
|
8
|
+
* failure (with tokens, model, and a truncated response), a memory snapshot, and
|
|
9
|
+
* a deterministic "likely fix locus" pointing at where to start.
|
|
10
|
+
*
|
|
11
|
+
* The function is pure and deterministic — it only reads its inputs and never
|
|
12
|
+
* touches the filesystem, env, or clock. The CLI wiring in
|
|
13
|
+
* `commands/agent.ts` gathers the real inputs and calls it. Keep all I/O out of
|
|
14
|
+
* this module so it stays unit-testable under the CLI vitest stub setup, which
|
|
15
|
+
* stubs every `@nodetool-ai/*` runtime package — only `import type` is used.
|
|
16
|
+
*/
|
|
17
|
+
import { isFiniteNumber, isObjectLike, isString } from "./predicates.js";
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Helpers
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
const RESPONSE_PREVIEW_MAX = 500;
|
|
22
|
+
const VALUE_PREVIEW_MAX = 120;
|
|
23
|
+
const MEMORY_KEY_LIMIT = 40;
|
|
24
|
+
const FAILED_NODE_STATUSES = new Set(["error", "failed"]);
|
|
25
|
+
/** Job statuses that mean the run did not succeed. */
|
|
26
|
+
const FAILED_JOB_STATUSES = new Set(["failed", "error", "cancelled"]);
|
|
27
|
+
const LLM_SPAN_NAMES = new Set(["llm.chat", "llm.stream"]);
|
|
28
|
+
function str(v) {
|
|
29
|
+
return isString(v) ? v : null;
|
|
30
|
+
}
|
|
31
|
+
function num(v) {
|
|
32
|
+
return isFiniteNumber(v) ? v : null;
|
|
33
|
+
}
|
|
34
|
+
function truncate(s, max) {
|
|
35
|
+
const oneLine = s.replace(/\s+/g, " ").trim();
|
|
36
|
+
return oneLine.length > max ? `${oneLine.slice(0, max)}…[${oneLine.length} chars]` : oneLine;
|
|
37
|
+
}
|
|
38
|
+
/** First non-empty string among the candidates. */
|
|
39
|
+
function firstString(...candidates) {
|
|
40
|
+
for (const c of candidates) {
|
|
41
|
+
const s = str(c);
|
|
42
|
+
if (s && s.trim().length > 0)
|
|
43
|
+
return s;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const NO_SITE = {
|
|
48
|
+
kind: "unknown",
|
|
49
|
+
nodeId: null,
|
|
50
|
+
nodeType: null,
|
|
51
|
+
nodeName: null,
|
|
52
|
+
stepId: null,
|
|
53
|
+
stepLabel: null
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Scan the message stream for the first failure. A failing `node_update`
|
|
57
|
+
* (status error/failed) wins; otherwise a failed `task_update`/`step_result`
|
|
58
|
+
* (an agent step); otherwise a top-level `error` message. The scan keeps the
|
|
59
|
+
* earliest failure so the report points at the root cause, not a downstream
|
|
60
|
+
* cascade.
|
|
61
|
+
*/
|
|
62
|
+
function scanMessages(messages) {
|
|
63
|
+
let nodeFailure = null;
|
|
64
|
+
let nodeError = null;
|
|
65
|
+
let stepFailure = null;
|
|
66
|
+
let stepError = null;
|
|
67
|
+
let topError = null;
|
|
68
|
+
let jobError = null;
|
|
69
|
+
for (const raw of messages) {
|
|
70
|
+
const msg = raw;
|
|
71
|
+
switch (msg.type) {
|
|
72
|
+
case "node_update": {
|
|
73
|
+
const status = str(msg.status);
|
|
74
|
+
if (status && FAILED_NODE_STATUSES.has(status) && !nodeFailure) {
|
|
75
|
+
nodeFailure = {
|
|
76
|
+
kind: "node",
|
|
77
|
+
nodeId: str(msg.node_id),
|
|
78
|
+
nodeType: str(msg.node_type),
|
|
79
|
+
nodeName: str(msg.node_name),
|
|
80
|
+
stepId: null,
|
|
81
|
+
stepLabel: null
|
|
82
|
+
};
|
|
83
|
+
nodeError = firstString(msg.error) ?? status;
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "task_update": {
|
|
88
|
+
const event = str(msg.event);
|
|
89
|
+
const task = msg.task ?? {};
|
|
90
|
+
const step = msg.step ?? {};
|
|
91
|
+
const failed = event === "step_failed" ||
|
|
92
|
+
str(step.status) === "failed" ||
|
|
93
|
+
str(task.status) === "failed";
|
|
94
|
+
if (failed && !stepFailure) {
|
|
95
|
+
stepFailure = {
|
|
96
|
+
kind: "step",
|
|
97
|
+
nodeId: str(msg.node_id),
|
|
98
|
+
nodeType: null,
|
|
99
|
+
nodeName: firstString(task.title, task.name),
|
|
100
|
+
stepId: firstString(step.id),
|
|
101
|
+
stepLabel: firstString(step.instructions, step.name, task.title)
|
|
102
|
+
};
|
|
103
|
+
stepError = firstString(step.error, task.error);
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "step_result": {
|
|
108
|
+
const stepErr = firstString(msg.error);
|
|
109
|
+
if (stepErr && !stepFailure) {
|
|
110
|
+
const step = msg.step ?? {};
|
|
111
|
+
stepFailure = {
|
|
112
|
+
kind: "step",
|
|
113
|
+
nodeId: null,
|
|
114
|
+
nodeType: null,
|
|
115
|
+
nodeName: null,
|
|
116
|
+
stepId: firstString(step.id),
|
|
117
|
+
stepLabel: firstString(step.instructions, step.name)
|
|
118
|
+
};
|
|
119
|
+
stepError = stepErr;
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
case "job_update": {
|
|
124
|
+
const status = str(msg.status);
|
|
125
|
+
if (status && FAILED_JOB_STATUSES.has(status)) {
|
|
126
|
+
jobError ??= firstString(msg.error, msg.message);
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "error": {
|
|
131
|
+
topError ??= firstString(msg.message);
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
default:
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Precedence: a failing node is the most specific locus, then an agent step,
|
|
139
|
+
// then a job/top-level error with no attributable node.
|
|
140
|
+
if (nodeFailure) {
|
|
141
|
+
return {
|
|
142
|
+
failure: nodeFailure,
|
|
143
|
+
error: nodeError ?? stepError ?? topError ?? jobError,
|
|
144
|
+
failedAtMs: null,
|
|
145
|
+
found: true
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
if (stepFailure) {
|
|
149
|
+
return {
|
|
150
|
+
failure: stepFailure,
|
|
151
|
+
error: stepError ?? topError ?? jobError,
|
|
152
|
+
failedAtMs: null,
|
|
153
|
+
found: true
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const looseError = topError ?? jobError;
|
|
157
|
+
if (looseError) {
|
|
158
|
+
return {
|
|
159
|
+
failure: { ...NO_SITE, kind: "job" },
|
|
160
|
+
error: looseError,
|
|
161
|
+
failedAtMs: null,
|
|
162
|
+
found: true
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
return { failure: NO_SITE, error: null, failedAtMs: null, found: false };
|
|
166
|
+
}
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
// Last LLM span at/before the failure
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
function spanAttr(span, key) {
|
|
171
|
+
return span.attributes ? span.attributes[key] : undefined;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Pick the last `llm.chat`/`llm.stream` span that started at or before the
|
|
175
|
+
* failure. When no failure time is known, the last LLM span in trace order is
|
|
176
|
+
* used. Ties on start time resolve to the later end time (and otherwise the
|
|
177
|
+
* later position in the array), so the most recent call wins deterministically.
|
|
178
|
+
*/
|
|
179
|
+
function selectLastLlmSpan(spans, failedAtMs) {
|
|
180
|
+
let best = null;
|
|
181
|
+
let bestStart = Number.NEGATIVE_INFINITY;
|
|
182
|
+
let bestEnd = Number.NEGATIVE_INFINITY;
|
|
183
|
+
for (const span of spans) {
|
|
184
|
+
if (!LLM_SPAN_NAMES.has(span.name))
|
|
185
|
+
continue;
|
|
186
|
+
const start = num(span.start_time_ms);
|
|
187
|
+
if (failedAtMs !== null && start !== null && start > failedAtMs)
|
|
188
|
+
continue;
|
|
189
|
+
const startKey = start ?? Number.NEGATIVE_INFINITY;
|
|
190
|
+
const endKey = num(span.end_time_ms) ?? startKey;
|
|
191
|
+
// `>=` so a later array position with an equal key still wins (trace order).
|
|
192
|
+
if (best === null || startKey > bestStart || (startKey === bestStart && endKey >= bestEnd)) {
|
|
193
|
+
best = span;
|
|
194
|
+
bestStart = startKey;
|
|
195
|
+
bestEnd = endKey;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return best;
|
|
199
|
+
}
|
|
200
|
+
function summarizeLlmSpan(span) {
|
|
201
|
+
const provider = firstString(spanAttr(span, "gen_ai.system"), spanAttr(span, "agent.provider")) ?? null;
|
|
202
|
+
const model = firstString(spanAttr(span, "gen_ai.request.model"), spanAttr(span, "gen_ai.response.model"), spanAttr(span, "agent.model")) ?? null;
|
|
203
|
+
const responseRaw = str(spanAttr(span, "llm.response.content"));
|
|
204
|
+
const start = num(span.start_time_ms);
|
|
205
|
+
const end = num(span.end_time_ms);
|
|
206
|
+
return {
|
|
207
|
+
name: span.name,
|
|
208
|
+
provider,
|
|
209
|
+
model,
|
|
210
|
+
inputTokens: num(spanAttr(span, "gen_ai.usage.input_tokens")),
|
|
211
|
+
outputTokens: num(spanAttr(span, "gen_ai.usage.output_tokens")),
|
|
212
|
+
totalTokens: num(spanAttr(span, "gen_ai.usage.total_tokens")),
|
|
213
|
+
costUsd: num(spanAttr(span, "gen_ai.usage.cost_usd")),
|
|
214
|
+
responsePreview: responseRaw ? truncate(responseRaw, RESPONSE_PREVIEW_MAX) : null,
|
|
215
|
+
durationMs: start !== null && end !== null ? end - start : null,
|
|
216
|
+
statusCode: span.status?.code ?? null
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// ---------------------------------------------------------------------------
|
|
220
|
+
// Memory snapshot
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
function summarizeMemory(memory) {
|
|
223
|
+
const keys = Object.keys(memory);
|
|
224
|
+
const shown = keys.slice(0, MEMORY_KEY_LIMIT);
|
|
225
|
+
const preview = {};
|
|
226
|
+
for (const k of shown) {
|
|
227
|
+
const v = memory[k];
|
|
228
|
+
let s;
|
|
229
|
+
if (isString(v))
|
|
230
|
+
s = v;
|
|
231
|
+
else if (v === null || v === undefined)
|
|
232
|
+
s = String(v);
|
|
233
|
+
else if (isObjectLike(v))
|
|
234
|
+
s = Array.isArray(v) ? `array(${v.length})` : "{…}";
|
|
235
|
+
else
|
|
236
|
+
s = String(v);
|
|
237
|
+
preview[k] = truncate(s, VALUE_PREVIEW_MAX);
|
|
238
|
+
}
|
|
239
|
+
return { keyCount: keys.length, keys: shown, preview };
|
|
240
|
+
}
|
|
241
|
+
// ---------------------------------------------------------------------------
|
|
242
|
+
// Fix locus heuristic
|
|
243
|
+
// ---------------------------------------------------------------------------
|
|
244
|
+
/** Extract concrete file/prompt/model hints from an error string. */
|
|
245
|
+
function extractHints(error, model) {
|
|
246
|
+
const hints = [];
|
|
247
|
+
if (!error)
|
|
248
|
+
return hints;
|
|
249
|
+
const lower = error.toLowerCase();
|
|
250
|
+
// File path references (./foo.ts, /abs/path, src/x.json).
|
|
251
|
+
const fileMatch = error.match(/(?:\.{0,2}\/)?[\w.-]+\/[\w./-]+\.\w+/);
|
|
252
|
+
if (fileMatch)
|
|
253
|
+
hints.push(`file: ${fileMatch[0]}`);
|
|
254
|
+
if (/\bprompt\b/.test(lower) || /system\s*prompt/.test(lower)) {
|
|
255
|
+
hints.push("prompt: review the node/agent prompt");
|
|
256
|
+
}
|
|
257
|
+
if (/\bmodel\b/.test(lower) || /\bcontext\s*length\b/.test(lower) || /\btoken/.test(lower)) {
|
|
258
|
+
hints.push(model ? `model: ${model}` : "model: check the model id/limits");
|
|
259
|
+
}
|
|
260
|
+
if (/\bapi[\s_-]?key\b/.test(lower) || /unauthorized|401|forbidden|403/.test(lower)) {
|
|
261
|
+
hints.push("auth: missing/invalid API key or permissions");
|
|
262
|
+
}
|
|
263
|
+
if (/timeout|timed out|etimedout/.test(lower)) {
|
|
264
|
+
hints.push("timeout: increase the run/request timeout or retry");
|
|
265
|
+
}
|
|
266
|
+
if (/rate.?limit|429/.test(lower)) {
|
|
267
|
+
hints.push("rate-limit: back off or lower concurrency");
|
|
268
|
+
}
|
|
269
|
+
return hints;
|
|
270
|
+
}
|
|
271
|
+
function buildFixLocus(failure, error, lastLlm) {
|
|
272
|
+
const model = lastLlm?.model ?? null;
|
|
273
|
+
const hints = extractHints(error, model);
|
|
274
|
+
const where = failure.kind === "node"
|
|
275
|
+
? `node ${failure.nodeName ?? failure.nodeId ?? "?"}` +
|
|
276
|
+
(failure.nodeType ? ` (${failure.nodeType})` : "")
|
|
277
|
+
: failure.kind === "step"
|
|
278
|
+
? `agent step ${failure.stepLabel ?? failure.stepId ?? "?"}`
|
|
279
|
+
: failure.kind === "job"
|
|
280
|
+
? "the job (no node attributed)"
|
|
281
|
+
: "the run";
|
|
282
|
+
const errPart = error ? ` — ${truncate(error, 160)}` : "";
|
|
283
|
+
const summary = `Start at ${where}${errPart}`;
|
|
284
|
+
return {
|
|
285
|
+
summary,
|
|
286
|
+
nodeType: failure.nodeType,
|
|
287
|
+
model,
|
|
288
|
+
hints
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
// ---------------------------------------------------------------------------
|
|
292
|
+
// diagnoseRun
|
|
293
|
+
// ---------------------------------------------------------------------------
|
|
294
|
+
/**
|
|
295
|
+
* Aggregate a failed run's job record, message stream, and trace spans into a
|
|
296
|
+
* single `DiagnosisReport`. Deterministic and side-effect-free.
|
|
297
|
+
*/
|
|
298
|
+
export function diagnoseRun(inputs) {
|
|
299
|
+
const { job, messages, spans, memory } = inputs;
|
|
300
|
+
const missing = [];
|
|
301
|
+
// ---- Failure site + error -------------------------------------------------
|
|
302
|
+
let findings = { failure: NO_SITE, error: null, failedAtMs: null, found: false };
|
|
303
|
+
if (messages && messages.length > 0) {
|
|
304
|
+
findings = scanMessages(messages);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
missing.push("messages");
|
|
308
|
+
}
|
|
309
|
+
// The job record can supply (or override-fill) the error and status even when
|
|
310
|
+
// the message stream named the failing node.
|
|
311
|
+
const jobStatus = job?.status ?? null;
|
|
312
|
+
const jobError = firstString(job?.error);
|
|
313
|
+
const jobFailed = jobStatus ? FAILED_JOB_STATUSES.has(jobStatus) : false;
|
|
314
|
+
let { failure, error } = findings;
|
|
315
|
+
let found = findings.found;
|
|
316
|
+
if (!found && (jobFailed || jobError)) {
|
|
317
|
+
failure = { ...NO_SITE, kind: "job" };
|
|
318
|
+
error = jobError;
|
|
319
|
+
found = true;
|
|
320
|
+
}
|
|
321
|
+
else if (found && !error && jobError) {
|
|
322
|
+
error = jobError;
|
|
323
|
+
}
|
|
324
|
+
if (!job)
|
|
325
|
+
missing.push("job");
|
|
326
|
+
// ---- Last LLM span --------------------------------------------------------
|
|
327
|
+
let lastLlm = null;
|
|
328
|
+
if (spans && spans.length > 0) {
|
|
329
|
+
const span = selectLastLlmSpan(spans, findings.failedAtMs);
|
|
330
|
+
if (span)
|
|
331
|
+
lastLlm = summarizeLlmSpan(span);
|
|
332
|
+
else
|
|
333
|
+
missing.push("llm-span");
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
missing.push("trace");
|
|
337
|
+
}
|
|
338
|
+
// ---- Memory snapshot ------------------------------------------------------
|
|
339
|
+
let memorySnapshot = null;
|
|
340
|
+
if (memory && Object.keys(memory).length > 0) {
|
|
341
|
+
memorySnapshot = summarizeMemory(memory);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
missing.push("memory");
|
|
345
|
+
}
|
|
346
|
+
// ---- Verdict --------------------------------------------------------------
|
|
347
|
+
const ok = !found;
|
|
348
|
+
const fixLocus = ok ? null : buildFixLocus(failure, error, lastLlm);
|
|
349
|
+
return {
|
|
350
|
+
ok,
|
|
351
|
+
jobId: job?.id ?? null,
|
|
352
|
+
jobStatus,
|
|
353
|
+
failure: ok ? NO_SITE : failure,
|
|
354
|
+
error: ok ? null : error,
|
|
355
|
+
lastLlm,
|
|
356
|
+
memory: memorySnapshot,
|
|
357
|
+
fixLocus,
|
|
358
|
+
missing
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
// ---------------------------------------------------------------------------
|
|
362
|
+
// Human-readable rendering
|
|
363
|
+
// ---------------------------------------------------------------------------
|
|
364
|
+
/**
|
|
365
|
+
* Render a `DiagnosisReport` as a plain-text block for the terminal. Kept here
|
|
366
|
+
* (not in the CLI command) so the formatting is unit-testable and dependency-
|
|
367
|
+
* free; the command adds color separately if desired.
|
|
368
|
+
*/
|
|
369
|
+
export function renderDiagnosis(report) {
|
|
370
|
+
const lines = [];
|
|
371
|
+
const id = report.jobId ?? "(unknown job)";
|
|
372
|
+
if (report.ok) {
|
|
373
|
+
lines.push(`✓ No failure detected for ${id}.`);
|
|
374
|
+
if (report.jobStatus)
|
|
375
|
+
lines.push(` status: ${report.jobStatus}`);
|
|
376
|
+
if (report.missing.length > 0) {
|
|
377
|
+
lines.push(` sources missing: ${report.missing.join(", ")}`);
|
|
378
|
+
}
|
|
379
|
+
return lines.join("\n");
|
|
380
|
+
}
|
|
381
|
+
lines.push(`✗ Diagnosis for ${id}${report.jobStatus ? ` (${report.jobStatus})` : ""}`);
|
|
382
|
+
const f = report.failure;
|
|
383
|
+
const site = f.kind === "node"
|
|
384
|
+
? `node ${f.nodeName ?? f.nodeId ?? "?"}${f.nodeType ? ` [${f.nodeType}]` : ""}`
|
|
385
|
+
: f.kind === "step"
|
|
386
|
+
? `step ${f.stepLabel ?? f.stepId ?? "?"}`
|
|
387
|
+
: f.kind === "job"
|
|
388
|
+
? "job (no node attributed)"
|
|
389
|
+
: "unknown";
|
|
390
|
+
lines.push(` failure: ${site}`);
|
|
391
|
+
lines.push(` error: ${report.error ?? "(none reported)"}`);
|
|
392
|
+
if (report.lastLlm) {
|
|
393
|
+
const l = report.lastLlm;
|
|
394
|
+
const tok = l.inputTokens !== null || l.outputTokens !== null
|
|
395
|
+
? ` tokens=${l.inputTokens ?? "?"}/${l.outputTokens ?? "?"}`
|
|
396
|
+
: "";
|
|
397
|
+
lines.push(` last LLM (${l.name}): ${l.provider ?? "?"}/${l.model ?? "?"}${tok}` +
|
|
398
|
+
(l.statusCode ? ` status=${l.statusCode}` : ""));
|
|
399
|
+
if (l.responsePreview)
|
|
400
|
+
lines.push(` response: ${l.responsePreview}`);
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
lines.push(" last LLM: (no trace span available)");
|
|
404
|
+
}
|
|
405
|
+
if (report.memory) {
|
|
406
|
+
lines.push(` memory: ${report.memory.keyCount} key(s): ${report.memory.keys.join(", ")}`);
|
|
407
|
+
}
|
|
408
|
+
if (report.fixLocus) {
|
|
409
|
+
lines.push(` → ${report.fixLocus.summary}`);
|
|
410
|
+
for (const hint of report.fixLocus.hints)
|
|
411
|
+
lines.push(` • ${hint}`);
|
|
412
|
+
}
|
|
413
|
+
if (report.missing.length > 0) {
|
|
414
|
+
lines.push(` sources missing: ${report.missing.join(", ")}`);
|
|
415
|
+
}
|
|
416
|
+
return lines.join("\n");
|
|
417
|
+
}
|
|
418
|
+
//# sourceMappingURL=diagnose.js.map
|