@hoilab/ada-cli 0.84.21 → 0.84.22
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 +20 -0
- package/README.es.md +163 -0
- package/README.md +99 -652
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/home-screen.d.ts.map +1 -1
- package/dist/cli/home-screen.js +2 -2
- package/dist/cli/home-screen.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +9 -3
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +57 -7
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +449 -73
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -3
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +41 -32
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/engine-personality.d.ts +12 -0
- package/dist/core/engine-personality.d.ts.map +1 -0
- package/dist/core/engine-personality.js +53 -0
- package/dist/core/engine-personality.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -5
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +23 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/memory-engine/audit-export.d.ts +54 -0
- package/dist/core/memory-engine/audit-export.d.ts.map +1 -0
- package/dist/core/memory-engine/audit-export.js +85 -0
- package/dist/core/memory-engine/audit-export.js.map +1 -0
- package/dist/core/memory-engine/audit.d.ts.map +1 -1
- package/dist/core/memory-engine/audit.js +7 -8
- package/dist/core/memory-engine/audit.js.map +1 -1
- package/dist/core/memory-engine/engine.d.ts +2 -3
- package/dist/core/memory-engine/engine.d.ts.map +1 -1
- package/dist/core/memory-engine/engine.js +148 -50
- package/dist/core/memory-engine/engine.js.map +1 -1
- package/dist/core/memory-engine/inverted-index.d.ts.map +1 -1
- package/dist/core/memory-engine/inverted-index.js +67 -10
- package/dist/core/memory-engine/inverted-index.js.map +1 -1
- package/dist/core/memory-engine/keychain.d.ts.map +1 -1
- package/dist/core/memory-engine/keychain.js +1 -6
- package/dist/core/memory-engine/keychain.js.map +1 -1
- package/dist/core/memory-engine/observation-store.d.ts +1 -0
- package/dist/core/memory-engine/observation-store.d.ts.map +1 -1
- package/dist/core/memory-engine/observation-store.js +37 -8
- package/dist/core/memory-engine/observation-store.js.map +1 -1
- package/dist/core/memory-engine/scanner.d.ts.map +1 -1
- package/dist/core/memory-engine/scanner.js +25 -5
- package/dist/core/memory-engine/scanner.js.map +1 -1
- package/dist/core/memory-engine/security.d.ts.map +1 -1
- package/dist/core/memory-engine/security.js +131 -23
- package/dist/core/memory-engine/security.js.map +1 -1
- package/dist/core/memory-engine/session-indexer.d.ts.map +1 -1
- package/dist/core/memory-engine/session-indexer.js +8 -2
- package/dist/core/memory-engine/session-indexer.js.map +1 -1
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.d.ts.map +1 -1
- package/dist/core/memory-engine/tools.js +14 -7
- package/dist/core/memory-engine/tools.js.map +1 -1
- package/dist/core/memory-engine/vault.d.ts.map +1 -1
- package/dist/core/memory-engine/vault.js +2 -2
- package/dist/core/memory-engine/vault.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +12 -6
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-optimizer.d.ts +53 -0
- package/dist/core/prompt-optimizer.d.ts.map +1 -0
- package/dist/core/prompt-optimizer.js +138 -0
- package/dist/core/prompt-optimizer.js.map +1 -0
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +50 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +233 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +8 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +11 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +52 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +204 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +2 -2
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/project-memory-tool.d.ts.map +1 -1
- package/dist/core/tools/project-memory-tool.js +4 -1
- package/dist/core/tools/project-memory-tool.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/workflows/agent-runner.d.ts +86 -0
- package/dist/core/workflows/agent-runner.d.ts.map +1 -0
- package/dist/core/workflows/agent-runner.js +225 -0
- package/dist/core/workflows/agent-runner.js.map +1 -0
- package/dist/core/workflows/builtins.d.ts +41 -0
- package/dist/core/workflows/builtins.d.ts.map +1 -0
- package/dist/core/workflows/builtins.js +282 -0
- package/dist/core/workflows/builtins.js.map +1 -0
- package/dist/core/workflows/goal-engine/engine.d.ts +134 -0
- package/dist/core/workflows/goal-engine/engine.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/engine.js +462 -0
- package/dist/core/workflows/goal-engine/engine.js.map +1 -0
- package/dist/core/workflows/goal-engine/errors.d.ts +7 -0
- package/dist/core/workflows/goal-engine/errors.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/errors.js +9 -0
- package/dist/core/workflows/goal-engine/errors.js.map +1 -0
- package/dist/core/workflows/goal-engine/index.d.ts +13 -0
- package/dist/core/workflows/goal-engine/index.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/index.js +8 -0
- package/dist/core/workflows/goal-engine/index.js.map +1 -0
- package/dist/core/workflows/goal-engine/persistence.d.ts +31 -0
- package/dist/core/workflows/goal-engine/persistence.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/persistence.js +145 -0
- package/dist/core/workflows/goal-engine/persistence.js.map +1 -0
- package/dist/core/workflows/goal-engine/prompts.d.ts +37 -0
- package/dist/core/workflows/goal-engine/prompts.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/prompts.js +131 -0
- package/dist/core/workflows/goal-engine/prompts.js.map +1 -0
- package/dist/core/workflows/goal-engine/state.d.ts +41 -0
- package/dist/core/workflows/goal-engine/state.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/state.js +397 -0
- package/dist/core/workflows/goal-engine/state.js.map +1 -0
- package/dist/core/workflows/goal-engine/tools.d.ts +31 -0
- package/dist/core/workflows/goal-engine/tools.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/tools.js +211 -0
- package/dist/core/workflows/goal-engine/tools.js.map +1 -0
- package/dist/core/workflows/goal-engine/types.d.ts +286 -0
- package/dist/core/workflows/goal-engine/types.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/types.js +17 -0
- package/dist/core/workflows/goal-engine/types.js.map +1 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts +23 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.js +72 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.js.map +1 -0
- package/dist/core/workflows/graph-sync.d.ts +67 -0
- package/dist/core/workflows/graph-sync.d.ts.map +1 -0
- package/dist/core/workflows/graph-sync.js +188 -0
- package/dist/core/workflows/graph-sync.js.map +1 -0
- package/dist/core/workflows/graph.d.ts +143 -0
- package/dist/core/workflows/graph.d.ts.map +1 -0
- package/dist/core/workflows/graph.js +319 -0
- package/dist/core/workflows/graph.js.map +1 -0
- package/dist/core/workflows/index.d.ts +18 -0
- package/dist/core/workflows/index.d.ts.map +1 -0
- package/dist/core/workflows/index.js +14 -0
- package/dist/core/workflows/index.js.map +1 -0
- package/dist/core/workflows/journal.d.ts +68 -0
- package/dist/core/workflows/journal.d.ts.map +1 -0
- package/dist/core/workflows/journal.js +83 -0
- package/dist/core/workflows/journal.js.map +1 -0
- package/dist/core/workflows/manager.d.ts +112 -0
- package/dist/core/workflows/manager.d.ts.map +1 -0
- package/dist/core/workflows/manager.js +327 -0
- package/dist/core/workflows/manager.js.map +1 -0
- package/dist/core/workflows/resolve-script.d.ts +35 -0
- package/dist/core/workflows/resolve-script.d.ts.map +1 -0
- package/dist/core/workflows/resolve-script.js +66 -0
- package/dist/core/workflows/resolve-script.js.map +1 -0
- package/dist/core/workflows/runtime.d.ts +49 -0
- package/dist/core/workflows/runtime.d.ts.map +1 -0
- package/dist/core/workflows/runtime.js +301 -0
- package/dist/core/workflows/runtime.js.map +1 -0
- package/dist/core/workflows/shared-store.d.ts +31 -0
- package/dist/core/workflows/shared-store.d.ts.map +1 -0
- package/dist/core/workflows/shared-store.js +80 -0
- package/dist/core/workflows/shared-store.js.map +1 -0
- package/dist/core/workflows/subagent-host.d.ts +50 -0
- package/dist/core/workflows/subagent-host.d.ts.map +1 -0
- package/dist/core/workflows/subagent-host.js +225 -0
- package/dist/core/workflows/subagent-host.js.map +1 -0
- package/dist/core/workflows/tool-workflow.d.ts +22 -0
- package/dist/core/workflows/tool-workflow.d.ts.map +1 -0
- package/dist/core/workflows/tool-workflow.js +120 -0
- package/dist/core/workflows/tool-workflow.js.map +1 -0
- package/dist/core/workflows/types.d.ts +142 -0
- package/dist/core/workflows/types.d.ts.map +1 -0
- package/dist/core/workflows/types.js +26 -0
- package/dist/core/workflows/types.js.map +1 -0
- package/dist/core/workflows/worktree.d.ts +42 -0
- package/dist/core/workflows/worktree.d.ts.map +1 -0
- package/dist/core/workflows/worktree.js +107 -0
- package/dist/core/workflows/worktree.js.map +1 -0
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -15
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/home-screen.d.ts.map +1 -1
- package/dist/modes/interactive/components/home-screen.js +2 -2
- package/dist/modes/interactive/components/home-screen.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +16 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/prompt-optimization.d.ts +16 -0
- package/dist/modes/interactive/components/prompt-optimization.d.ts.map +1 -0
- package/dist/modes/interactive/components/prompt-optimization.js +46 -0
- package/dist/modes/interactive/components/prompt-optimization.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +19 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +247 -46
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +8 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +29 -3
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +24 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +677 -34
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +4 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +173 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +29 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/skills/ada-engine/SKILL.md +153 -0
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/docs/compaction.md +15 -0
- package/docs/custom-provider.md +5 -2
- package/docs/extensions.md +11 -2
- package/docs/json.md +7 -2
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/rpc.md +9 -3
- package/docs/settings.md +2 -2
- package/docs/skills.md +4 -3
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/subagent/README.md +1 -1
- package/examples/extensions/subagent/index.ts +6 -1
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +2 -12
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/core/workflows/agent-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAiB,MAAM,eAAe,CAAC;AA+BhF,0FAA0F;AAC1F,MAAM,UAAU,iBAAiB,CAAC,OAOjC,EAAU;IACV,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO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B,SAAS,EACR,OACA,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE;gBAClC,cAAc,EAAE,SAAS,EAAE,MAAM;aACZ,CAAC;QACxB,CAAC;gBAAS,CAAC;YACV,IAAI,YAAY;gBAAE,YAAY,CAAC,YAAY,CAAC,CAAC;YAC7C,QAAQ,EAAE,OAAO,EAAE,CAAC;YACpB,wEAAuE;YACvE,sEAAqE;YACrE,8DAA4D;YAC5D,IAAI,QAAQ,IAAI,CAAC,SAAS,EAAE,CAAC;gBAC5B,SAAS,GAAG,MAAM,gBAAgB,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;YAC/D,CAAC;QACF,CAAC;IAAA,CACD;CACD;AAED,SAAS,YAAY,CAAC,KAAc,EAAW;IAC9C,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC;AAAA,CAC7D;AAED,SAAS,cAAc,CAAC,KAAc,EAAW;IAChD,OAAO,KAAK,YAAY,aAAa,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAwB,CAAC;AAAA,CACjF","sourcesContent":["/**\n * AgentRunner — subagente del Ada Intelligence Engine.\n *\n * Un subagente es una sesión del SDK (AgentSessionRuntime via createAgentSession)\n * con: modelo resuelto (spec/tier/fallback), tools configuradas, cwd (base o\n * worktree), instructions opcionales y límites (timeout, retries). El runner\n * captura la respuesta final, el structured output (schema typebox con fallback\n * a extracción de prosa) y el usage real (tokens/coste).\n *\n * La creación de la sesión es inyectable (createSession) para tests con fakes.\n */\n\nimport { createHash } from \"node:crypto\";\nimport type { TextContent } from \"@earendil-works/pi-ai\";\nimport type { TSchema } from \"typebox\";\nimport type { AgentSession, AgentSessionEvent } from \"../agent-session.ts\";\nimport type { ToolDefinition } from \"../extensions/types.ts\";\nimport type { AgentRunOptions, AgentRunResult, AgentUsage, WorkflowErrorCode } from \"./types.ts\";\nimport { WorkflowError } from \"./types.ts\";\nimport { createWorktree, finalizeWorktree, type Worktree } from \"./worktree.ts\";\n\nexport interface SubagentSession {\n\tsession: AgentSession;\n\tdispose(): void;\n\tgetUsage(): AgentUsage;\n}\n\nexport type CreateSubagentSession = (options: {\n\tcwd: string;\n\tagentDir: string;\n\tmodelSpec?: string;\n\ttools?: string[];\n\tcustomTools?: ToolDefinition[];\n\tsessionName?: string;\n\tinstructions?: string;\n}) => Promise<SubagentSession>;\n\nexport interface AgentRunnerOptions {\n\tagentDir: string;\n\tcreateSession: CreateSubagentSession;\n\t/** Limiter compartido del run (concurrency). */\n\tlimiter: <T>(fn: () => Promise<T>) => Promise<T>;\n\t/** Contador global de agentes del run (maxAgents). */\n\tagentCounter: { count: number };\n\t/** Techo de agentes por run (`workflows.maxAgentsPerRun`). */\n\tmaxAgents: number;\n\tretries?: number;\n\tagentTimeoutMs?: number | null;\n}\n\n/** Hash de identidad del agente para el journal (prompt+model+phase+schema+stableKey). */\nexport function agentIdentityHash(options: {\n\tprompt: string;\n\tmodel?: string;\n\ttier?: string;\n\tphase?: string;\n\tstableKey?: string;\n\tschema?: TSchema | undefined;\n}): string {\n\tconst canonical = JSON.stringify({\n\t\tprompt: options.prompt,\n\t\tmodel: options.model ?? null,\n\t\ttier: options.tier ?? null,\n\t\tphase: options.phase ?? null,\n\t\tstableKey: options.stableKey ?? null,\n\t\tschema: options.schema ? JSON.stringify(options.schema) : null,\n\t});\n\treturn createHash(\"sha256\").update(canonical).digest(\"hex\");\n}\n\n/** Extraer el texto de una respuesta (string o content array). */\nexport function messageText(content: unknown): string {\n\tif (typeof content === \"string\") return content;\n\tif (!Array.isArray(content)) return \"\";\n\treturn content\n\t\t.filter((b): b is TextContent => typeof b === \"object\" && b !== null && (b as { type?: string }).type === \"text\")\n\t\t.map((b) => b.text ?? \"\")\n\t\t.join(\"\\n\")\n\t\t.trim();\n}\n\n/** Extraer JSON del texto (para structured output fallback). */\nexport function extractJson(text: string): unknown | undefined {\n\tconst cleaned = text\n\t\t.replace(/```json\\s*/g, \"\")\n\t\t.replace(/```/g, \"\")\n\t\t.trim();\n\tconst start = cleaned.indexOf(\"{\");\n\tconst end = cleaned.lastIndexOf(\"}\");\n\tif (start === -1 || end === -1) return undefined;\n\ttry {\n\t\treturn JSON.parse(cleaned.slice(start, end + 1));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Tools por defecto de un subagente (espejo de sdk.ts:263). */\nconst SUBAGENT_DEFAULT_TOOLS = [\"read\", \"bash\", \"edit\", \"write\"];\n/** Mínimo privilegio: leer y buscar, nada de escribir ni ejecutar. */\nconst SUBAGENT_READONLY_TOOLS = [\"read\", \"grep\", \"find\", \"ls\"];\n\n/**\n * Allowlist de tools del subagente.\n *\n * Desenreda un bug latente: `options.tools` son tools EXTRA (web_search…) y se\n * pasaban a la vez como `customTools` y como allowlist, de modo que pedir una\n * tool extra ESTRECHABA el permiso en silencio a solo esa — un agente que pedía\n * `web_search` perdía `read`/`bash`/`edit`/`write` sin que nadie lo notara.\n * Ahora las extra se SUMAN a la base, que es lo que el nombre siempre prometió.\n */\nexport function resolveAllowedTools(options: { readOnly?: boolean; tools?: Array<{ name: string }> }): string[] {\n\tconst base = options.readOnly ? SUBAGENT_READONLY_TOOLS : SUBAGENT_DEFAULT_TOOLS;\n\tconst extras = (options.tools ?? []).map((t) => t.name);\n\treturn [...new Set([...base, ...extras])];\n}\n\nexport class AgentRunner {\n\tprivate agentDir: string;\n\tprivate createSession: CreateSubagentSession;\n\tprivate limiter: AgentRunnerOptions[\"limiter\"];\n\tprivate agentCounter: AgentRunnerOptions[\"agentCounter\"];\n\tprivate maxAgents: number;\n\tprivate retries: number;\n\tprivate agentTimeoutMs: number | null;\n\n\tconstructor(options: AgentRunnerOptions) {\n\t\tthis.agentDir = options.agentDir;\n\t\tthis.createSession = options.createSession;\n\t\tthis.limiter = options.limiter;\n\t\tthis.agentCounter = options.agentCounter;\n\t\tthis.maxAgents = options.maxAgents;\n\t\tthis.retries = options.retries ?? 3;\n\t\tthis.agentTimeoutMs = options.agentTimeoutMs ?? null;\n\t}\n\n\tasync run<T = unknown>(options: AgentRunOptions): Promise<AgentRunResult<T> | null> {\n\t\treturn this.limiter(async () => {\n\t\t\tif (this.agentCounter.count >= this.maxAgents) {\n\t\t\t\tthrow new WorkflowError(\n\t\t\t\t\t\"WORKFLOW_MAX_AGENTS\",\n\t\t\t\t\t`Límite de agentes del run alcanzado (${this.maxAgents}). Súbelo con el ajuste workflows.maxAgentsPerRun.`,\n\t\t\t\t\t{ recoverable: false },\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.agentCounter.count++;\n\n\t\t\tlet attempt = 0;\n\t\t\tlet lastError: Error | undefined;\n\t\t\tfor (; attempt <= this.retries; attempt++) {\n\t\t\t\tconst signal = options.signal;\n\t\t\t\tif (signal?.aborted) return null;\n\t\t\t\ttry {\n\t\t\t\t\treturn await this.runOnce<T>(options, signal);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (signal?.aborted) return null;\n\t\t\t\t\tif (isAbortError(error) || isTimeoutError(error)) throw error;\n\t\t\t\t\tlastError = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\tif (attempt >= this.retries) break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (lastError) throw lastError;\n\t\t\treturn null;\n\t\t});\n\t}\n\n\tprivate async runOnce<T>(options: AgentRunOptions, signal?: AbortSignal): Promise<AgentRunResult<T> | null> {\n\t\t// Timeout combinado: el del agente + el del run.\n\t\tconst timeoutMs = options.timeoutMs ?? this.agentTimeoutMs;\n\t\tlet timeoutTimer: ReturnType<typeof setTimeout> | undefined;\n\t\tconst timeout = new Promise<never>((_resolve, reject) => {\n\t\t\tif (timeoutMs === null) return;\n\t\t\ttimeoutTimer = setTimeout(() => {\n\t\t\t\treject(\n\t\t\t\t\tnew WorkflowError(\"WORKFLOW_AGENT_TIMEOUT\", `Agent timed out after ${timeoutMs}ms`, {\n\t\t\t\t\t\trecoverable: false,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}, timeoutMs);\n\t\t});\n\n\t\tconst baseCwd = options.cwd ?? process.cwd();\n\t\t// Aislamiento git: los agentes con escritura que corren en paralelo\n\t\t// editaban el MISMO checkout y se pisaban en silencio. El nombre es\n\t\t// determinista (isolationKey = runId:callIndex) para que un resume\n\t\t// reencuentre el mismo worktree. Fuera de un repo git hace no-op.\n\t\tlet worktree: Worktree | null = null;\n\t\tlet finalized: { branch?: string; kept: boolean } | undefined;\n\t\tconst worktreeMessage = `ada: ${options.label ?? options.isolationKey ?? \"agent\"}`;\n\t\tif (options.isolation === \"worktree\") {\n\t\t\tworktree = await createWorktree(baseCwd, options.isolationKey ?? options.label ?? \"agent\");\n\t\t}\n\n\t\tlet subagent: SubagentSession | null = null;\n\t\ttry {\n\t\t\tsubagent = await this.createSession({\n\t\t\t\tcwd: worktree?.cwd ?? baseCwd,\n\t\t\t\tagentDir: this.agentDir,\n\t\t\t\tmodelSpec: options.model ?? (options.tier ? `tier:${options.tier}` : undefined),\n\t\t\t\ttools: resolveAllowedTools(options),\n\t\t\t\tcustomTools: options.tools,\n\t\t\t\tsessionName: options.label ? `workflow:${options.label}` : undefined,\n\t\t\t\tinstructions: options.instructions,\n\t\t\t});\n\t\t\tconst session = subagent.session;\n\n\t\t\tconst lastAssistantText: string[] = [];\n\t\t\tconst unsubscribe = session.subscribe((event: AgentSessionEvent) => {\n\t\t\t\tif (event.type === \"message_end\" && event.message.role === \"assistant\") {\n\t\t\t\t\tconst text = messageText(event.message.content);\n\t\t\t\t\tif (text) lastAssistantText.push(text);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\ttry {\n\t\t\t\tawait Promise.race([session.sendUserMessage(options.prompt), timeout]);\n\t\t\t\tawait Promise.race([session.waitForIdle(), timeout]);\n\t\t\t} finally {\n\t\t\t\tunsubscribe();\n\t\t\t}\n\n\t\t\tif (signal?.aborted) return null;\n\n\t\t\tconst text = lastAssistantText.length > 0 ? lastAssistantText[lastAssistantText.length - 1] : \"\";\n\t\t\tlet result: T | null = null;\n\t\t\tlet _origin: \"structured\" | \"recovered\" = \"structured\";\n\n\t\t\tif (options.schema) {\n\t\t\t\tconst parsed = extractJson(text);\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tresult = parsed as T;\n\t\t\t\t} else {\n\t\t\t\t\t_origin = \"recovered\";\n\t\t\t\t\t// Fallback: devolver la prosa (el caller decide si sirve).\n\t\t\t\t\tresult = text as unknown as T;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tresult = (text.length > 0 ? text : null) as unknown as T;\n\t\t\t}\n\n\t\t\t// Consolidar el worktree ANTES de devolver: si solo lo retirásemos, los\n\t\t\t// cambios sin commitear del agente se perderían y el aislamiento no\n\t\t\t// habría servido de nada. La rama sobrevive para que un humano la\n\t\t\t// mergee; no hay auto-merge a propósito.\n\t\t\tif (worktree && !finalized) {\n\t\t\t\tfinalized = await finalizeWorktree(worktree, worktreeMessage);\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tresult,\n\t\t\t\ttext,\n\t\t\t\tusage: subagent.getUsage(),\n\t\t\t\tsessionId: (\n\t\t\t\t\tsession as { sessionManager?: { getSessionId?: () => string } }\n\t\t\t\t).sessionManager?.getSessionId?.(),\n\t\t\t\tworktreeBranch: finalized?.branch,\n\t\t\t} as AgentRunResult<T>;\n\t\t} finally {\n\t\t\tif (timeoutTimer) clearTimeout(timeoutTimer);\n\t\t\tsubagent?.dispose();\n\t\t\t// Camino de error/abort/timeout: el return no llegó a consolidar, pero\n\t\t\t// el trabajo parcial del agente también merece sobrevivir para poder\n\t\t\t// inspeccionarlo — y hay que soltar el worktree igualmente.\n\t\t\tif (worktree && !finalized) {\n\t\t\t\tfinalized = await finalizeWorktree(worktree, worktreeMessage);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction isAbortError(error: unknown): boolean {\n\treturn error instanceof Error && error.name === \"AbortError\";\n}\n\nfunction isTimeoutError(error: unknown): boolean {\n\treturn error instanceof WorkflowError && error.code === \"WORKFLOW_AGENT_TIMEOUT\";\n}\n\n/** Tipos re-exportados para el index. */\nexport type { WorkflowErrorCode };\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builtins — generadores de scripts de workflow (deep-research, code-review,
|
|
3
|
+
* product-build, codebase-audit, multi-perspective).
|
|
4
|
+
*
|
|
5
|
+
* Los builtins son versionados con el SDK y TESTEADOS — no scripts sueltos
|
|
6
|
+
* del usuario. Devuelven el script que ejecuta el runtime.
|
|
7
|
+
*
|
|
8
|
+
* Regla de oro: TODO fragmento estático de prompt se emite con q()
|
|
9
|
+
* (JSON.stringify) — el escapado queda garantizado por construcción y el
|
|
10
|
+
* script generado SIEMPRE es JS válido (verificado por tests vm-parse).
|
|
11
|
+
*/
|
|
12
|
+
/** Deep-research: plan → gather (parallel, con web tools) → verify → report. */
|
|
13
|
+
export declare function generateDeepResearchScript(options?: {
|
|
14
|
+
angles?: number;
|
|
15
|
+
minSupport?: number;
|
|
16
|
+
}): string;
|
|
17
|
+
/** Code-review: diff por módulo → reviewers paralelos → síntesis con severidad. */
|
|
18
|
+
export declare function generateCodeReviewScript(options?: {
|
|
19
|
+
reviewers?: number;
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* Product-build (Ada Intelligence, §4): acceptance criteria → fases TDD →
|
|
23
|
+
* verify ejecuta los tests → done con verified_by y evidencia.
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateProductBuildScript(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Codebase-audit (§4): módulos → auditoría paralela (seguridad, deuda, bugs,
|
|
28
|
+
* compliance) → informe + (opcional) nodos QA_FINDING/RISK del grafo.
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateCodebaseAuditScript(options?: {
|
|
31
|
+
angles?: number;
|
|
32
|
+
graph?: boolean;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* Multi-perspective (§4): el mismo problema desde N ángulos → síntesis con
|
|
36
|
+
* desacuerdos explícitos (no consenso falso).
|
|
37
|
+
*/
|
|
38
|
+
export declare function generateMultiPerspectiveScript(options?: {
|
|
39
|
+
perspectives?: number;
|
|
40
|
+
}): string;
|
|
41
|
+
//# sourceMappingURL=builtins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.d.ts","sourceRoot":"","sources":["../../../src/core/workflows/builtins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAOH,sFAAgF;AAChF,wBAAgB,0BAA0B,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAsDzG;AAED,yFAAmF;AACnF,wBAAgB,wBAAwB,CAAC,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CA8CrF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CA2DnD;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAiDtG;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAuC9F","sourcesContent":["/**\n * Builtins — generadores de scripts de workflow (deep-research, code-review,\n * product-build, codebase-audit, multi-perspective).\n *\n * Los builtins son versionados con el SDK y TESTEADOS — no scripts sueltos\n * del usuario. Devuelven el script que ejecuta el runtime.\n *\n * Regla de oro: TODO fragmento estático de prompt se emite con q()\n * (JSON.stringify) — el escapado queda garantizado por construcción y el\n * script generado SIEMPRE es JS válido (verificado por tests vm-parse).\n */\n\n/** Emite un literal string JS correctamente escapado. */\nfunction q(s: string): string {\n\treturn JSON.stringify(s);\n}\n\n/** Deep-research: plan → gather (parallel, con web tools) → verify → report. */\nexport function generateDeepResearchScript(options: { angles?: number; minSupport?: number } = {}): string {\n\tconst angles = Math.min(Math.max(options.angles ?? 4, 1), 12);\n\tconst minSupport = options.minSupport ?? 2;\n\treturn `export const meta = {\n \"name\": \"deep_research\",\n \"description\": \"Deep research con búsqueda web y verificación cruzada\",\n \"phases\": [\n { \"title\": \"Queries\" },\n { \"title\": \"Gather\" },\n { \"title\": \"Verify\" },\n { \"title\": \"Report\" }\n ]\n}\n\nphase(\"Queries\")\nconst plan = await agent({\n prompt: ${q(\"Planifica la investigación web para esta pregunta: \")} + (args.question ?? \"\") +\n ${q(`\\n\\nProduce ${angles} consultas diversas y específicas. Devuelve JSON {\"queries\": [\"...\"]}.`)},\n label: \"planificar consultas\",\n schema: { type: \"object\", properties: { queries: { type: \"array\", items: { type: \"string\" } } }, required: [\"queries\"] }\n})\nconst planned = plan && Array.isArray(plan.queries) ? plan.queries.filter((q) => typeof q === \"string\" && q.trim().length > 0) : []\nconst queries = (planned.length > 0 ? planned : [args.question ?? \"\"]).slice(0, ${angles})\n\nphase(\"Gather\")\nconst gathered = await parallel(queries.map((q, i) => () =>\n agent({\n prompt: ${q(\"Investiga esta consulta usando las tools web_search y web_fetch.\\nConsulta: \")} + q +\n ${q('\\n\\nPasos: (1) web_search; (2) web_fetch de las 2 URLs más relevantes; (3) extrae claims verificables, cada uno con su URL exacta. NO inventes fuentes. Devuelve JSON {\"sources\": [{\"url\": string, \"claims\": [string]}]}.')},\n label: \"investigar: \" + String(q).slice(0, 60),\n readOnly: true,\n schema: { type: \"object\", properties: { sources: { type: \"array\", items: { type: \"object\", properties: { url: { type: \"string\" }, claims: { type: \"array\", items: { type: \"string\" } } }, required: [\"url\", \"claims\"] } } }, required: [\"sources\"] }\n })\n))\nconst allSources = gathered.filter(Boolean).flatMap((g) => (g && g.sources) || [])\n\nphase(\"Verify\")\nconst verified = await agent({\n prompt: ${q(`Verifica los claims recopilados. Para cada claim, comprueba que tenga al menos ${minSupport} fuentes independientes que lo respalden. Devuelve JSON {\"verifiedClaims\": [{ \"claim\": string, \"sources\": [string] }], \"uncertain\": [string]}.`)},\n label: \"verificar claims (\" + allSources.length + \" fuentes)\",\n readOnly: true,\n schema: { type: \"object\", properties: { verifiedClaims: { type: \"array\", items: { type: \"object\", properties: { claim: { type: \"string\" }, sources: { type: \"array\", items: { type: \"string\" } } }, required: [\"claim\", \"sources\"] } }, uncertain: { type: \"array\", items: { type: \"string\" } } }, required: [\"verifiedClaims\", \"uncertain\"] }\n})\n\nphase(\"Report\")\nconst report = await agent({\n prompt: ${q(\"Escribe un informe en Markdown sobre: \")} + (args.question ?? \"\") +\n ${q('\\n\\nUsa SOLO los claims verificados, citando las fuentes como [1], [2]... con la lista de fuentes al final. Marca explícitamente lo incierto. Devuelve el informe en JSON {\"report\": string}.')},\n label: \"redactar informe\",\n schema: { type: \"object\", properties: { report: { type: \"string\" } }, required: [\"report\"] }\n})\n\nreturn report ? report.report : null\n`;\n}\n\n/** Code-review: diff por módulo → reviewers paralelos → síntesis con severidad. */\nexport function generateCodeReviewScript(options: { reviewers?: number } = {}): string {\n\tconst reviewers = Math.min(Math.max(options.reviewers ?? 3, 1), 6);\n\tconst perspectives = [\n\t\t\"bugs y errores lógicos\",\n\t\t\"seguridad y límites de confianza\",\n\t\t\"mantenibilidad y deuda técnica\",\n\t].slice(0, reviewers);\n\treturn `export const meta = {\n \"name\": \"code_review\",\n \"description\": \"Revisión de código con reviewers paralelos y síntesis por severidad\",\n \"phases\": [\n { \"title\": \"Diff\" },\n { \"title\": \"Review\" },\n { \"title\": \"Synthesize\" }\n ]\n}\n\nphase(\"Diff\")\nconst diff = await agent({\n prompt: ${q('Obtén el diff del cambio (git diff HEAD~1 o el rango indicado en args.diff). Devuelve JSON {\"diff\": string} con el diff completo (máx 10000 chars).')},\n label: \"obtener diff\",\n schema: { type: \"object\", properties: { diff: { type: \"string\" } }, required: [\"diff\"] }\n})\n\nphase(\"Review\")\nconst perspectives = ${JSON.stringify(perspectives)}\nconst reviews = await parallel(perspectives.map((p, i) => () =>\n agent({\n prompt: ${q(\"Revisa el siguiente diff desde la perspectiva: \")} + p +\n ${q(\"\\n\\nDIFF:\\n\")} + (diff ? diff.diff : \"(sin diff)\") +\n ${q('\\n\\nPara cada hallazgo cita archivo:línea. NO inventes. Devuelve JSON {\"findings\": [{\"severity\": \"critical|major|minor\", \"file\": string, \"line\": number, \"issue\": string, \"suggestion\": string}]}.')},\n label: \"revisar: \" + p,\n readOnly: true,\n schema: { type: \"object\", properties: { findings: { type: \"array\", items: { type: \"object\", properties: { severity: { type: \"string\" }, file: { type: \"string\" }, line: { type: \"number\" }, issue: { type: \"string\" }, suggestion: { type: \"string\" } }, required: [\"severity\", \"file\", \"issue\"] } } }, required: [\"findings\"] }\n })\n))\n\nphase(\"Synthesize\")\nconst synthesis = await agent({\n prompt: ${q('Sintetiza estos hallazgos de revisión en un informe final Markdown ordenado por severidad (crítico primero), sin duplicados y con las citas archivo:línea. Devuelve JSON {\"report\": string}.')},\n label: \"sintetizar hallazgos\",\n schema: { type: \"object\", properties: { report: { type: \"string\" } }, required: [\"report\"] }\n})\n\nreturn synthesis ? synthesis.report : null\n`;\n}\n\n/**\n * Product-build (Ada Intelligence, §4): acceptance criteria → fases TDD →\n * verify ejecuta los tests → done con verified_by y evidencia.\n */\nexport function generateProductBuildScript(): string {\n\treturn `export const meta = {\n \"name\": \"product_build\",\n \"description\": \"Construcción de producto con acceptance criteria y verify con evidencia\",\n \"phases\": [\n { \"title\": \"Frame\" },\n { \"title\": \"Plan\" },\n { \"title\": \"Build\" },\n { \"title\": \"Verify\" },\n { \"title\": \"Done\" }\n ]\n}\n\nphase(\"Frame\")\nconst framed = await agent({\n prompt: ${q(\"Enmarca el producto para este brief: \")} + ((args.brief ?? args.acceptanceCriteria) ?? \"\") +\n ${q('\\n\\nDefine acceptance criteria observables y medibles. Devuelve JSON {\"criteria\": [{\"id\": string, \"description\": string}]} (máx 6).')},\n label: \"definir criterios\",\n schema: { type: \"object\", properties: { criteria: { type: \"array\", items: { type: \"object\", properties: { id: { type: \"string\" }, description: { type: \"string\" } }, required: [\"id\", \"description\"] } } }, required: [\"criteria\"] }\n})\nconst criteria = (framed && framed.criteria) || []\n\nphase(\"Plan\")\nconst planned = await agent({\n prompt: ${q('Planifica las tareas para cumplir estos criterios. Por cada criterio indica el test que lo verifica. Devuelve JSON {\"tasks\": [{\"title\": string, \"criterion\": string, \"test\": string}]}.\\n\\nCriterios:\\n')} +\n JSON.stringify(criteria),\n label: \"planificar tareas\",\n schema: { type: \"object\", properties: { tasks: { type: \"array\", items: { type: \"object\", properties: { title: { type: \"string\" }, criterion: { type: \"string\" }, test: { type: \"string\" } }, required: [\"title\", \"criterion\"] } } }, required: [\"tasks\"] }\n})\n\nphase(\"Build\")\nconst built = await parallel((planned && planned.tasks || []).map((t, i) => () =>\n agent({\n prompt: ${q(\"Tarea: \")} + t.title + ${q(\"\\nCriterio que resuelve: \")} + t.criterion +\n ${q(\"\\nImplementa el mínimo y escribe el test: \")} + (t.test ?? \"\") +\n ${q('\\nEjecuta el test y confirma. Devuelve el archivo que cambiaste en {\"file\": string, \"verified\": boolean}.')},\n label: \"construir: \" + t.title,\n isolation: \"worktree\",\n schema: { type: \"object\", properties: { file: { type: \"string\" }, verified: { type: \"boolean\" } }, required: [\"file\", \"verified\"] }\n })\n))\nconst artifacts = built.filter(Boolean).filter((b) => b && b.verified)\n\nphase(\"Verify\")\nconst verification = await agent({\n prompt: ${q('Ejecuta el/los comando(s) de verificación del proyecto (args.verifyCommand o el test runner default). Para cada criterio, confirma con evidencia archivo:línea o salida de test. Devuelve JSON {\"results\": [{\"criterion\": string, \"verified_by\": string, \"evidence\": string}]}.')},\n label: \"verificar criterios (\" + criteria.length + \")\",\n schema: { type: \"object\", properties: { results: { type: \"array\", items: { type: \"object\", properties: { criterion: { type: \"string\" }, verified_by: { type: \"string\" }, evidence: { type: \"string\" } }, required: [\"criterion\", \"verified_by\", \"evidence\"] } } }, required: [\"results\"] }\n})\n\nphase(\"Done\")\nconst done = await agent({\n prompt: ${q('Redacta el informe final de build. Solo declara done si CADA criterio tiene verified_by y evidencia. Devuelve JSON {\"report\": string, \"done\": boolean, \"gaps\": [string]}.')},\n label: \"informe final\",\n schema: { type: \"object\", properties: { report: { type: \"string\" }, done: { type: \"boolean\" }, gaps: { type: \"array\", items: { type: \"string\" } } }, required: [\"report\", \"done\"] }\n})\n\nreturn done ? done.report || JSON.stringify(done) : null\n`;\n}\n\n/**\n * Codebase-audit (§4): módulos → auditoría paralela (seguridad, deuda, bugs,\n * compliance) → informe + (opcional) nodos QA_FINDING/RISK del grafo.\n */\nexport function generateCodebaseAuditScript(options: { angles?: number; graph?: boolean } = {}): string {\n\tconst angles = Math.min(Math.max(options.angles ?? 4, 1), 8);\n\tconst perspectives = [\n\t\t\"seguridad (injection, secrets, límites de confianza)\",\n\t\t\"deuda técnica y arquitectura\",\n\t\t\"bugs y correctitud\",\n\t\t\"cumplimiento / RGPD / datos personales\",\n\t].slice(0, angles);\n\tconst graphHooks = options.graph\n\t\t? \"\\n\\nTras el informe, usa la tool graph_add_nodes para registrar QA_FINDING y RISK con sus citas.\"\n\t\t: \"\";\n\treturn `export const meta = {\n \"name\": \"codebase_audit\",\n \"description\": \"Auditoría del codebase con ángulos paralelos y síntesis\",\n \"phases\": [\n { \"title\": \"Walk\" },\n { \"title\": \"Audit\" },\n { \"title\": \"Report\" }\n ]\n}\n\nphase(\"Walk\")\nconst modules = await agent({\n prompt: ${q(`Audita este repo: (args.path ?? \".\"). En qué módulos se dividiría la auditoría. Devuelve JSON {\"modules\": [string]} (máx ${angles}).`)},\n label: \"identificar módulos\",\n schema: { type: \"object\", properties: { modules: { type: \"array\", items: { type: \"string\" } } }, required: [\"modules\"] }\n})\n\nphase(\"Audit\")\nconst perspectives = ${JSON.stringify(perspectives)}\nconst audits = await parallel(perspectives.map((p, i) => () =>\n agent({\n prompt: ${q(\"Audita el módulo(s) desde la perspectiva: \")} + p +\n ${q(\"\\nMódulos: \")} + JSON.stringify((modules && modules.modules) || []) +\n ${q(`\\nPara cada hallazgo cita archivo:línea. Devuelve JSON {\"findings\": [{\"type\": \"RISK|QA_FINDING\", \"severity\": string, \"file\": string, \"line\": number, \"issue\": string}]}.${graphHooks}`)},\n label: \"auditar: \" + p,\n schema: { type: \"object\", properties: { findings: { type: \"array\", items: { type: \"object\", properties: { type: { type: \"string\" }, severity: { type: \"string\" }, file: { type: \"string\" }, issue: { type: \"string\" } }, required: [\"type\", \"severity\", \"file\", \"issue\"] } } }, required: [\"findings\"] }\n })\n))\n\nphase(\"Report\")\nconst report = await agent({\n prompt: ${q('Sintetiza los hallazgos de auditoría en un informe Markdown ordenado por severidad, agrupado por perspectiva, con citas archivo:línea y recomendaciones priorizadas. Devuelve JSON {\"report\": string}.')},\n label: \"sintetizar auditoría\",\n schema: { type: \"object\", properties: { report: { type: \"string\" } }, required: [\"report\"] }\n})\n\nreturn report ? report.report : null\n`;\n}\n\n/**\n * Multi-perspective (§4): el mismo problema desde N ángulos → síntesis con\n * desacuerdos explícitos (no consenso falso).\n */\nexport function generateMultiPerspectiveScript(options: { perspectives?: number } = {}): string {\n\tconst n = Math.min(Math.max(options.perspectives ?? 4, 2), 8);\n\tconst list = [\n\t\t\"correctitud e invariantes\",\n\t\t\"rendimiento y escalabilidad\",\n\t\t\"seguridad y confianza\",\n\t\t\"mantenibilidad y claridad\",\n\t\t\"producto y UX\",\n\t\t\"coste de operación\",\n\t].slice(0, n);\n\treturn `export const meta = {\n \"name\": \"multi_perspective\",\n \"description\": \"Análisis del mismo problema desde N perspectivas con desacuerdos explícitos\",\n \"phases\": [\n { \"title\": \"Perspectives\" },\n { \"title\": \"Synthesize\" }\n ]\n}\n\nphase(\"Perspectives\")\nconst views = await parallel(${JSON.stringify(list)}.map((p, i) => () =>\n agent({\n prompt: ${q(\"Analiza este problema: \")} + (args.problem ?? \"\") +\n ${q(\"\\nDesde la perspectiva: \")} + p +\n ${q('\\nDa tu análisis, recomendación y riesgos. Devuelve JSON {\"perspective\": string, \"recommendation\": string, \"risks\": [string]}.')},\n label: \"perspectiva: \" + p,\n schema: { type: \"object\", properties: { perspective: { type: \"string\" }, recommendation: { type: \"string\" }, risks: { type: \"array\", items: { type: \"string\" } } }, required: [\"perspective\", \"recommendation\"] }\n })\n))\n\nphase(\"Synthesize\")\nconst synthesis = await agent({\n prompt: ${q('Sintetiza los análisis. SEÑALA EXPLÍCITAMENTE los desacuerdos entre perspectivas (no creas consenso falso). Devuelve JSON {\"summary\": string, \"disagreements\": [string], \"recommended\": string}.')},\n label: \"sintetizar análisis\",\n schema: { type: \"object\", properties: { summary: { type: \"string\" }, disagreements: { type: \"array\", items: { type: \"string\" } }, recommended: { type: \"string\" } }, required: [\"summary\", \"recommended\"] }\n})\n\nreturn synthesis ? synthesis.summary || JSON.stringify(synthesis) : null\n`;\n}\n"]}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builtins — generadores de scripts de workflow (deep-research, code-review,
|
|
3
|
+
* product-build, codebase-audit, multi-perspective).
|
|
4
|
+
*
|
|
5
|
+
* Los builtins son versionados con el SDK y TESTEADOS — no scripts sueltos
|
|
6
|
+
* del usuario. Devuelven el script que ejecuta el runtime.
|
|
7
|
+
*
|
|
8
|
+
* Regla de oro: TODO fragmento estático de prompt se emite con q()
|
|
9
|
+
* (JSON.stringify) — el escapado queda garantizado por construcción y el
|
|
10
|
+
* script generado SIEMPRE es JS válido (verificado por tests vm-parse).
|
|
11
|
+
*/
|
|
12
|
+
/** Emite un literal string JS correctamente escapado. */
|
|
13
|
+
function q(s) {
|
|
14
|
+
return JSON.stringify(s);
|
|
15
|
+
}
|
|
16
|
+
/** Deep-research: plan → gather (parallel, con web tools) → verify → report. */
|
|
17
|
+
export function generateDeepResearchScript(options = {}) {
|
|
18
|
+
const angles = Math.min(Math.max(options.angles ?? 4, 1), 12);
|
|
19
|
+
const minSupport = options.minSupport ?? 2;
|
|
20
|
+
return `export const meta = {
|
|
21
|
+
"name": "deep_research",
|
|
22
|
+
"description": "Deep research con búsqueda web y verificación cruzada",
|
|
23
|
+
"phases": [
|
|
24
|
+
{ "title": "Queries" },
|
|
25
|
+
{ "title": "Gather" },
|
|
26
|
+
{ "title": "Verify" },
|
|
27
|
+
{ "title": "Report" }
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
phase("Queries")
|
|
32
|
+
const plan = await agent({
|
|
33
|
+
prompt: ${q("Planifica la investigación web para esta pregunta: ")} + (args.question ?? "") +
|
|
34
|
+
${q(`\n\nProduce ${angles} consultas diversas y específicas. Devuelve JSON {"queries": ["..."]}.`)},
|
|
35
|
+
label: "planificar consultas",
|
|
36
|
+
schema: { type: "object", properties: { queries: { type: "array", items: { type: "string" } } }, required: ["queries"] }
|
|
37
|
+
})
|
|
38
|
+
const planned = plan && Array.isArray(plan.queries) ? plan.queries.filter((q) => typeof q === "string" && q.trim().length > 0) : []
|
|
39
|
+
const queries = (planned.length > 0 ? planned : [args.question ?? ""]).slice(0, ${angles})
|
|
40
|
+
|
|
41
|
+
phase("Gather")
|
|
42
|
+
const gathered = await parallel(queries.map((q, i) => () =>
|
|
43
|
+
agent({
|
|
44
|
+
prompt: ${q("Investiga esta consulta usando las tools web_search y web_fetch.\nConsulta: ")} + q +
|
|
45
|
+
${q('\n\nPasos: (1) web_search; (2) web_fetch de las 2 URLs más relevantes; (3) extrae claims verificables, cada uno con su URL exacta. NO inventes fuentes. Devuelve JSON {"sources": [{"url": string, "claims": [string]}]}.')},
|
|
46
|
+
label: "investigar: " + String(q).slice(0, 60),
|
|
47
|
+
readOnly: true,
|
|
48
|
+
schema: { type: "object", properties: { sources: { type: "array", items: { type: "object", properties: { url: { type: "string" }, claims: { type: "array", items: { type: "string" } } }, required: ["url", "claims"] } } }, required: ["sources"] }
|
|
49
|
+
})
|
|
50
|
+
))
|
|
51
|
+
const allSources = gathered.filter(Boolean).flatMap((g) => (g && g.sources) || [])
|
|
52
|
+
|
|
53
|
+
phase("Verify")
|
|
54
|
+
const verified = await agent({
|
|
55
|
+
prompt: ${q(`Verifica los claims recopilados. Para cada claim, comprueba que tenga al menos ${minSupport} fuentes independientes que lo respalden. Devuelve JSON {"verifiedClaims": [{ "claim": string, "sources": [string] }], "uncertain": [string]}.`)},
|
|
56
|
+
label: "verificar claims (" + allSources.length + " fuentes)",
|
|
57
|
+
readOnly: true,
|
|
58
|
+
schema: { type: "object", properties: { verifiedClaims: { type: "array", items: { type: "object", properties: { claim: { type: "string" }, sources: { type: "array", items: { type: "string" } } }, required: ["claim", "sources"] } }, uncertain: { type: "array", items: { type: "string" } } }, required: ["verifiedClaims", "uncertain"] }
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
phase("Report")
|
|
62
|
+
const report = await agent({
|
|
63
|
+
prompt: ${q("Escribe un informe en Markdown sobre: ")} + (args.question ?? "") +
|
|
64
|
+
${q('\n\nUsa SOLO los claims verificados, citando las fuentes como [1], [2]... con la lista de fuentes al final. Marca explícitamente lo incierto. Devuelve el informe en JSON {"report": string}.')},
|
|
65
|
+
label: "redactar informe",
|
|
66
|
+
schema: { type: "object", properties: { report: { type: "string" } }, required: ["report"] }
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return report ? report.report : null
|
|
70
|
+
`;
|
|
71
|
+
}
|
|
72
|
+
/** Code-review: diff por módulo → reviewers paralelos → síntesis con severidad. */
|
|
73
|
+
export function generateCodeReviewScript(options = {}) {
|
|
74
|
+
const reviewers = Math.min(Math.max(options.reviewers ?? 3, 1), 6);
|
|
75
|
+
const perspectives = [
|
|
76
|
+
"bugs y errores lógicos",
|
|
77
|
+
"seguridad y límites de confianza",
|
|
78
|
+
"mantenibilidad y deuda técnica",
|
|
79
|
+
].slice(0, reviewers);
|
|
80
|
+
return `export const meta = {
|
|
81
|
+
"name": "code_review",
|
|
82
|
+
"description": "Revisión de código con reviewers paralelos y síntesis por severidad",
|
|
83
|
+
"phases": [
|
|
84
|
+
{ "title": "Diff" },
|
|
85
|
+
{ "title": "Review" },
|
|
86
|
+
{ "title": "Synthesize" }
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
phase("Diff")
|
|
91
|
+
const diff = await agent({
|
|
92
|
+
prompt: ${q('Obtén el diff del cambio (git diff HEAD~1 o el rango indicado en args.diff). Devuelve JSON {"diff": string} con el diff completo (máx 10000 chars).')},
|
|
93
|
+
label: "obtener diff",
|
|
94
|
+
schema: { type: "object", properties: { diff: { type: "string" } }, required: ["diff"] }
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
phase("Review")
|
|
98
|
+
const perspectives = ${JSON.stringify(perspectives)}
|
|
99
|
+
const reviews = await parallel(perspectives.map((p, i) => () =>
|
|
100
|
+
agent({
|
|
101
|
+
prompt: ${q("Revisa el siguiente diff desde la perspectiva: ")} + p +
|
|
102
|
+
${q("\n\nDIFF:\n")} + (diff ? diff.diff : "(sin diff)") +
|
|
103
|
+
${q('\n\nPara cada hallazgo cita archivo:línea. NO inventes. Devuelve JSON {"findings": [{"severity": "critical|major|minor", "file": string, "line": number, "issue": string, "suggestion": string}]}.')},
|
|
104
|
+
label: "revisar: " + p,
|
|
105
|
+
readOnly: true,
|
|
106
|
+
schema: { type: "object", properties: { findings: { type: "array", items: { type: "object", properties: { severity: { type: "string" }, file: { type: "string" }, line: { type: "number" }, issue: { type: "string" }, suggestion: { type: "string" } }, required: ["severity", "file", "issue"] } } }, required: ["findings"] }
|
|
107
|
+
})
|
|
108
|
+
))
|
|
109
|
+
|
|
110
|
+
phase("Synthesize")
|
|
111
|
+
const synthesis = await agent({
|
|
112
|
+
prompt: ${q('Sintetiza estos hallazgos de revisión en un informe final Markdown ordenado por severidad (crítico primero), sin duplicados y con las citas archivo:línea. Devuelve JSON {"report": string}.')},
|
|
113
|
+
label: "sintetizar hallazgos",
|
|
114
|
+
schema: { type: "object", properties: { report: { type: "string" } }, required: ["report"] }
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
return synthesis ? synthesis.report : null
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Product-build (Ada Intelligence, §4): acceptance criteria → fases TDD →
|
|
122
|
+
* verify ejecuta los tests → done con verified_by y evidencia.
|
|
123
|
+
*/
|
|
124
|
+
export function generateProductBuildScript() {
|
|
125
|
+
return `export const meta = {
|
|
126
|
+
"name": "product_build",
|
|
127
|
+
"description": "Construcción de producto con acceptance criteria y verify con evidencia",
|
|
128
|
+
"phases": [
|
|
129
|
+
{ "title": "Frame" },
|
|
130
|
+
{ "title": "Plan" },
|
|
131
|
+
{ "title": "Build" },
|
|
132
|
+
{ "title": "Verify" },
|
|
133
|
+
{ "title": "Done" }
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
phase("Frame")
|
|
138
|
+
const framed = await agent({
|
|
139
|
+
prompt: ${q("Enmarca el producto para este brief: ")} + ((args.brief ?? args.acceptanceCriteria) ?? "") +
|
|
140
|
+
${q('\n\nDefine acceptance criteria observables y medibles. Devuelve JSON {"criteria": [{"id": string, "description": string}]} (máx 6).')},
|
|
141
|
+
label: "definir criterios",
|
|
142
|
+
schema: { type: "object", properties: { criteria: { type: "array", items: { type: "object", properties: { id: { type: "string" }, description: { type: "string" } }, required: ["id", "description"] } } }, required: ["criteria"] }
|
|
143
|
+
})
|
|
144
|
+
const criteria = (framed && framed.criteria) || []
|
|
145
|
+
|
|
146
|
+
phase("Plan")
|
|
147
|
+
const planned = await agent({
|
|
148
|
+
prompt: ${q('Planifica las tareas para cumplir estos criterios. Por cada criterio indica el test que lo verifica. Devuelve JSON {"tasks": [{"title": string, "criterion": string, "test": string}]}.\n\nCriterios:\n')} +
|
|
149
|
+
JSON.stringify(criteria),
|
|
150
|
+
label: "planificar tareas",
|
|
151
|
+
schema: { type: "object", properties: { tasks: { type: "array", items: { type: "object", properties: { title: { type: "string" }, criterion: { type: "string" }, test: { type: "string" } }, required: ["title", "criterion"] } } }, required: ["tasks"] }
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
phase("Build")
|
|
155
|
+
const built = await parallel((planned && planned.tasks || []).map((t, i) => () =>
|
|
156
|
+
agent({
|
|
157
|
+
prompt: ${q("Tarea: ")} + t.title + ${q("\nCriterio que resuelve: ")} + t.criterion +
|
|
158
|
+
${q("\nImplementa el mínimo y escribe el test: ")} + (t.test ?? "") +
|
|
159
|
+
${q('\nEjecuta el test y confirma. Devuelve el archivo que cambiaste en {"file": string, "verified": boolean}.')},
|
|
160
|
+
label: "construir: " + t.title,
|
|
161
|
+
isolation: "worktree",
|
|
162
|
+
schema: { type: "object", properties: { file: { type: "string" }, verified: { type: "boolean" } }, required: ["file", "verified"] }
|
|
163
|
+
})
|
|
164
|
+
))
|
|
165
|
+
const artifacts = built.filter(Boolean).filter((b) => b && b.verified)
|
|
166
|
+
|
|
167
|
+
phase("Verify")
|
|
168
|
+
const verification = await agent({
|
|
169
|
+
prompt: ${q('Ejecuta el/los comando(s) de verificación del proyecto (args.verifyCommand o el test runner default). Para cada criterio, confirma con evidencia archivo:línea o salida de test. Devuelve JSON {"results": [{"criterion": string, "verified_by": string, "evidence": string}]}.')},
|
|
170
|
+
label: "verificar criterios (" + criteria.length + ")",
|
|
171
|
+
schema: { type: "object", properties: { results: { type: "array", items: { type: "object", properties: { criterion: { type: "string" }, verified_by: { type: "string" }, evidence: { type: "string" } }, required: ["criterion", "verified_by", "evidence"] } } }, required: ["results"] }
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
phase("Done")
|
|
175
|
+
const done = await agent({
|
|
176
|
+
prompt: ${q('Redacta el informe final de build. Solo declara done si CADA criterio tiene verified_by y evidencia. Devuelve JSON {"report": string, "done": boolean, "gaps": [string]}.')},
|
|
177
|
+
label: "informe final",
|
|
178
|
+
schema: { type: "object", properties: { report: { type: "string" }, done: { type: "boolean" }, gaps: { type: "array", items: { type: "string" } } }, required: ["report", "done"] }
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
return done ? done.report || JSON.stringify(done) : null
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Codebase-audit (§4): módulos → auditoría paralela (seguridad, deuda, bugs,
|
|
186
|
+
* compliance) → informe + (opcional) nodos QA_FINDING/RISK del grafo.
|
|
187
|
+
*/
|
|
188
|
+
export function generateCodebaseAuditScript(options = {}) {
|
|
189
|
+
const angles = Math.min(Math.max(options.angles ?? 4, 1), 8);
|
|
190
|
+
const perspectives = [
|
|
191
|
+
"seguridad (injection, secrets, límites de confianza)",
|
|
192
|
+
"deuda técnica y arquitectura",
|
|
193
|
+
"bugs y correctitud",
|
|
194
|
+
"cumplimiento / RGPD / datos personales",
|
|
195
|
+
].slice(0, angles);
|
|
196
|
+
const graphHooks = options.graph
|
|
197
|
+
? "\n\nTras el informe, usa la tool graph_add_nodes para registrar QA_FINDING y RISK con sus citas."
|
|
198
|
+
: "";
|
|
199
|
+
return `export const meta = {
|
|
200
|
+
"name": "codebase_audit",
|
|
201
|
+
"description": "Auditoría del codebase con ángulos paralelos y síntesis",
|
|
202
|
+
"phases": [
|
|
203
|
+
{ "title": "Walk" },
|
|
204
|
+
{ "title": "Audit" },
|
|
205
|
+
{ "title": "Report" }
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
phase("Walk")
|
|
210
|
+
const modules = await agent({
|
|
211
|
+
prompt: ${q(`Audita este repo: (args.path ?? "."). En qué módulos se dividiría la auditoría. Devuelve JSON {"modules": [string]} (máx ${angles}).`)},
|
|
212
|
+
label: "identificar módulos",
|
|
213
|
+
schema: { type: "object", properties: { modules: { type: "array", items: { type: "string" } } }, required: ["modules"] }
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
phase("Audit")
|
|
217
|
+
const perspectives = ${JSON.stringify(perspectives)}
|
|
218
|
+
const audits = await parallel(perspectives.map((p, i) => () =>
|
|
219
|
+
agent({
|
|
220
|
+
prompt: ${q("Audita el módulo(s) desde la perspectiva: ")} + p +
|
|
221
|
+
${q("\nMódulos: ")} + JSON.stringify((modules && modules.modules) || []) +
|
|
222
|
+
${q(`\nPara cada hallazgo cita archivo:línea. Devuelve JSON {"findings": [{"type": "RISK|QA_FINDING", "severity": string, "file": string, "line": number, "issue": string}]}.${graphHooks}`)},
|
|
223
|
+
label: "auditar: " + p,
|
|
224
|
+
schema: { type: "object", properties: { findings: { type: "array", items: { type: "object", properties: { type: { type: "string" }, severity: { type: "string" }, file: { type: "string" }, issue: { type: "string" } }, required: ["type", "severity", "file", "issue"] } } }, required: ["findings"] }
|
|
225
|
+
})
|
|
226
|
+
))
|
|
227
|
+
|
|
228
|
+
phase("Report")
|
|
229
|
+
const report = await agent({
|
|
230
|
+
prompt: ${q('Sintetiza los hallazgos de auditoría en un informe Markdown ordenado por severidad, agrupado por perspectiva, con citas archivo:línea y recomendaciones priorizadas. Devuelve JSON {"report": string}.')},
|
|
231
|
+
label: "sintetizar auditoría",
|
|
232
|
+
schema: { type: "object", properties: { report: { type: "string" } }, required: ["report"] }
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
return report ? report.report : null
|
|
236
|
+
`;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Multi-perspective (§4): el mismo problema desde N ángulos → síntesis con
|
|
240
|
+
* desacuerdos explícitos (no consenso falso).
|
|
241
|
+
*/
|
|
242
|
+
export function generateMultiPerspectiveScript(options = {}) {
|
|
243
|
+
const n = Math.min(Math.max(options.perspectives ?? 4, 2), 8);
|
|
244
|
+
const list = [
|
|
245
|
+
"correctitud e invariantes",
|
|
246
|
+
"rendimiento y escalabilidad",
|
|
247
|
+
"seguridad y confianza",
|
|
248
|
+
"mantenibilidad y claridad",
|
|
249
|
+
"producto y UX",
|
|
250
|
+
"coste de operación",
|
|
251
|
+
].slice(0, n);
|
|
252
|
+
return `export const meta = {
|
|
253
|
+
"name": "multi_perspective",
|
|
254
|
+
"description": "Análisis del mismo problema desde N perspectivas con desacuerdos explícitos",
|
|
255
|
+
"phases": [
|
|
256
|
+
{ "title": "Perspectives" },
|
|
257
|
+
{ "title": "Synthesize" }
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
phase("Perspectives")
|
|
262
|
+
const views = await parallel(${JSON.stringify(list)}.map((p, i) => () =>
|
|
263
|
+
agent({
|
|
264
|
+
prompt: ${q("Analiza este problema: ")} + (args.problem ?? "") +
|
|
265
|
+
${q("\nDesde la perspectiva: ")} + p +
|
|
266
|
+
${q('\nDa tu análisis, recomendación y riesgos. Devuelve JSON {"perspective": string, "recommendation": string, "risks": [string]}.')},
|
|
267
|
+
label: "perspectiva: " + p,
|
|
268
|
+
schema: { type: "object", properties: { perspective: { type: "string" }, recommendation: { type: "string" }, risks: { type: "array", items: { type: "string" } } }, required: ["perspective", "recommendation"] }
|
|
269
|
+
})
|
|
270
|
+
))
|
|
271
|
+
|
|
272
|
+
phase("Synthesize")
|
|
273
|
+
const synthesis = await agent({
|
|
274
|
+
prompt: ${q('Sintetiza los análisis. SEÑALA EXPLÍCITAMENTE los desacuerdos entre perspectivas (no creas consenso falso). Devuelve JSON {"summary": string, "disagreements": [string], "recommended": string}.')},
|
|
275
|
+
label: "sintetizar análisis",
|
|
276
|
+
schema: { type: "object", properties: { summary: { type: "string" }, disagreements: { type: "array", items: { type: "string" } }, recommended: { type: "string" } }, required: ["summary", "recommended"] }
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
return synthesis ? synthesis.summary || JSON.stringify(synthesis) : null
|
|
280
|
+
`;
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=builtins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins.js","sourceRoot":"","sources":["../../../src/core/workflows/builtins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,yDAAyD;AACzD,SAAS,CAAC,CAAC,CAAS,EAAU;IAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;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ED;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,OAAO,GAA8B,EAAE,EAAU;IAC/F,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9D,MAAM,IAAI,GAAG;QACZ,2BAA2B;QAC3B,6BAA6B;QAC7B,uBAAuB;QACvB,2BAA2B;QAC3B,eAAe;QACf,qBAAoB;KACpB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACd,OAAO;;;;;;;;;;+BAUuB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;cAErC,CAAC,CAAC,yBAAyB,CAAC;QAClC,CAAC,CAAC,0BAA0B,CAAC;QAC7B,CAAC,CAAC,kIAAgI,CAAC;;;;;;;;YAQ/H,CAAC,CAAC,qMAAkM,CAAC;;;;;;CAMhN,CAAC;AAAA,CACD","sourcesContent":["/**\n * Builtins — generadores de scripts de workflow (deep-research, code-review,\n * product-build, codebase-audit, multi-perspective).\n *\n * Los builtins son versionados con el SDK y TESTEADOS — no scripts sueltos\n * del usuario. Devuelven el script que ejecuta el runtime.\n *\n * Regla de oro: TODO fragmento estático de prompt se emite con q()\n * (JSON.stringify) — el escapado queda garantizado por construcción y el\n * script generado SIEMPRE es JS válido (verificado por tests vm-parse).\n */\n\n/** Emite un literal string JS correctamente escapado. */\nfunction q(s: string): string {\n\treturn JSON.stringify(s);\n}\n\n/** Deep-research: plan → gather (parallel, con web tools) → verify → report. */\nexport function generateDeepResearchScript(options: { angles?: number; minSupport?: number } = {}): string {\n\tconst angles = Math.min(Math.max(options.angles ?? 4, 1), 12);\n\tconst minSupport = options.minSupport ?? 2;\n\treturn `export const meta = {\n \"name\": \"deep_research\",\n \"description\": \"Deep research con búsqueda web y verificación cruzada\",\n \"phases\": [\n { \"title\": \"Queries\" },\n { \"title\": \"Gather\" },\n { \"title\": \"Verify\" },\n { \"title\": \"Report\" }\n ]\n}\n\nphase(\"Queries\")\nconst plan = await agent({\n prompt: ${q(\"Planifica la investigación web para esta pregunta: \")} + (args.question ?? \"\") +\n ${q(`\\n\\nProduce ${angles} consultas diversas y específicas. Devuelve JSON {\"queries\": [\"...\"]}.`)},\n label: \"planificar consultas\",\n schema: { type: \"object\", properties: { queries: { type: \"array\", items: { type: \"string\" } } }, required: [\"queries\"] }\n})\nconst planned = plan && Array.isArray(plan.queries) ? plan.queries.filter((q) => typeof q === \"string\" && q.trim().length > 0) : []\nconst queries = (planned.length > 0 ? planned : [args.question ?? \"\"]).slice(0, ${angles})\n\nphase(\"Gather\")\nconst gathered = await parallel(queries.map((q, i) => () =>\n agent({\n prompt: ${q(\"Investiga esta consulta usando las tools web_search y web_fetch.\\nConsulta: \")} + q +\n ${q('\\n\\nPasos: (1) web_search; (2) web_fetch de las 2 URLs más relevantes; (3) extrae claims verificables, cada uno con su URL exacta. NO inventes fuentes. Devuelve JSON {\"sources\": [{\"url\": string, \"claims\": [string]}]}.')},\n label: \"investigar: \" + String(q).slice(0, 60),\n readOnly: true,\n schema: { type: \"object\", properties: { sources: { type: \"array\", items: { type: \"object\", properties: { url: { type: \"string\" }, claims: { type: \"array\", items: { type: \"string\" } } }, required: [\"url\", \"claims\"] } } }, required: [\"sources\"] }\n })\n))\nconst allSources = gathered.filter(Boolean).flatMap((g) => (g && g.sources) || [])\n\nphase(\"Verify\")\nconst verified = await agent({\n prompt: ${q(`Verifica los claims recopilados. Para cada claim, comprueba que tenga al menos ${minSupport} fuentes independientes que lo respalden. Devuelve JSON {\"verifiedClaims\": [{ \"claim\": string, \"sources\": [string] }], \"uncertain\": [string]}.`)},\n label: \"verificar claims (\" + allSources.length + \" fuentes)\",\n readOnly: true,\n schema: { type: \"object\", properties: { verifiedClaims: { type: \"array\", items: { type: \"object\", properties: { claim: { type: \"string\" }, sources: { type: \"array\", items: { type: \"string\" } } }, required: [\"claim\", \"sources\"] } }, uncertain: { type: \"array\", items: { type: \"string\" } } }, required: [\"verifiedClaims\", \"uncertain\"] }\n})\n\nphase(\"Report\")\nconst report = await agent({\n prompt: ${q(\"Escribe un informe en Markdown sobre: \")} + (args.question ?? \"\") +\n ${q('\\n\\nUsa SOLO los claims verificados, citando las fuentes como [1], [2]... con la lista de fuentes al final. Marca explícitamente lo incierto. Devuelve el informe en JSON {\"report\": string}.')},\n label: \"redactar informe\",\n schema: { type: \"object\", properties: { report: { type: \"string\" } }, required: [\"report\"] }\n})\n\nreturn report ? report.report : null\n`;\n}\n\n/** Code-review: diff por módulo → reviewers paralelos → síntesis con severidad. */\nexport function generateCodeReviewScript(options: { reviewers?: number } = {}): string {\n\tconst reviewers = Math.min(Math.max(options.reviewers ?? 3, 1), 6);\n\tconst perspectives = [\n\t\t\"bugs y errores lógicos\",\n\t\t\"seguridad y límites de confianza\",\n\t\t\"mantenibilidad y deuda técnica\",\n\t].slice(0, reviewers);\n\treturn `export const meta = {\n \"name\": \"code_review\",\n \"description\": \"Revisión de código con reviewers paralelos y síntesis por severidad\",\n \"phases\": [\n { \"title\": \"Diff\" },\n { \"title\": \"Review\" },\n { \"title\": \"Synthesize\" }\n ]\n}\n\nphase(\"Diff\")\nconst diff = await agent({\n prompt: ${q('Obtén el diff del cambio (git diff HEAD~1 o el rango indicado en args.diff). Devuelve JSON {\"diff\": string} con el diff completo (máx 10000 chars).')},\n label: \"obtener diff\",\n schema: { type: \"object\", properties: { diff: { type: \"string\" } }, required: [\"diff\"] }\n})\n\nphase(\"Review\")\nconst perspectives = ${JSON.stringify(perspectives)}\nconst reviews = await parallel(perspectives.map((p, i) => () =>\n agent({\n prompt: ${q(\"Revisa el siguiente diff desde la perspectiva: \")} + p +\n ${q(\"\\n\\nDIFF:\\n\")} + (diff ? diff.diff : \"(sin diff)\") +\n ${q('\\n\\nPara cada hallazgo cita archivo:línea. NO inventes. Devuelve JSON {\"findings\": [{\"severity\": \"critical|major|minor\", \"file\": string, \"line\": number, \"issue\": string, \"suggestion\": string}]}.')},\n label: \"revisar: \" + p,\n readOnly: true,\n schema: { type: \"object\", properties: { findings: { type: \"array\", items: { type: \"object\", properties: { severity: { type: \"string\" }, file: { type: \"string\" }, line: { type: \"number\" }, issue: { type: \"string\" }, suggestion: { type: \"string\" } }, required: [\"severity\", \"file\", \"issue\"] } } }, required: [\"findings\"] }\n })\n))\n\nphase(\"Synthesize\")\nconst synthesis = await agent({\n prompt: ${q('Sintetiza estos hallazgos de revisión en un informe final Markdown ordenado por severidad (crítico primero), sin duplicados y con las citas archivo:línea. Devuelve JSON {\"report\": string}.')},\n label: \"sintetizar hallazgos\",\n schema: { type: \"object\", properties: { report: { type: \"string\" } }, required: [\"report\"] }\n})\n\nreturn synthesis ? synthesis.report : null\n`;\n}\n\n/**\n * Product-build (Ada Intelligence, §4): acceptance criteria → fases TDD →\n * verify ejecuta los tests → done con verified_by y evidencia.\n */\nexport function generateProductBuildScript(): string {\n\treturn `export const meta = {\n \"name\": \"product_build\",\n \"description\": \"Construcción de producto con acceptance criteria y verify con evidencia\",\n \"phases\": [\n { \"title\": \"Frame\" },\n { \"title\": \"Plan\" },\n { \"title\": \"Build\" },\n { \"title\": \"Verify\" },\n { \"title\": \"Done\" }\n ]\n}\n\nphase(\"Frame\")\nconst framed = await agent({\n prompt: ${q(\"Enmarca el producto para este brief: \")} + ((args.brief ?? args.acceptanceCriteria) ?? \"\") +\n ${q('\\n\\nDefine acceptance criteria observables y medibles. Devuelve JSON {\"criteria\": [{\"id\": string, \"description\": string}]} (máx 6).')},\n label: \"definir criterios\",\n schema: { type: \"object\", properties: { criteria: { type: \"array\", items: { type: \"object\", properties: { id: { type: \"string\" }, description: { type: \"string\" } }, required: [\"id\", \"description\"] } } }, required: [\"criteria\"] }\n})\nconst criteria = (framed && framed.criteria) || []\n\nphase(\"Plan\")\nconst planned = await agent({\n prompt: ${q('Planifica las tareas para cumplir estos criterios. Por cada criterio indica el test que lo verifica. Devuelve JSON {\"tasks\": [{\"title\": string, \"criterion\": string, \"test\": string}]}.\\n\\nCriterios:\\n')} +\n JSON.stringify(criteria),\n label: \"planificar tareas\",\n schema: { type: \"object\", properties: { tasks: { type: \"array\", items: { type: \"object\", properties: { title: { type: \"string\" }, criterion: { type: \"string\" }, test: { type: \"string\" } }, required: [\"title\", \"criterion\"] } } }, required: [\"tasks\"] }\n})\n\nphase(\"Build\")\nconst built = await parallel((planned && planned.tasks || []).map((t, i) => () =>\n agent({\n prompt: ${q(\"Tarea: \")} + t.title + ${q(\"\\nCriterio que resuelve: \")} + t.criterion +\n ${q(\"\\nImplementa el mínimo y escribe el test: \")} + (t.test ?? \"\") +\n ${q('\\nEjecuta el test y confirma. Devuelve el archivo que cambiaste en {\"file\": string, \"verified\": boolean}.')},\n label: \"construir: \" + t.title,\n isolation: \"worktree\",\n schema: { type: \"object\", properties: { file: { type: \"string\" }, verified: { type: \"boolean\" } }, required: [\"file\", \"verified\"] }\n })\n))\nconst artifacts = built.filter(Boolean).filter((b) => b && b.verified)\n\nphase(\"Verify\")\nconst verification = await agent({\n prompt: ${q('Ejecuta el/los comando(s) de verificación del proyecto (args.verifyCommand o el test runner default). Para cada criterio, confirma con evidencia archivo:línea o salida de test. Devuelve JSON {\"results\": [{\"criterion\": string, \"verified_by\": string, \"evidence\": string}]}.')},\n label: \"verificar criterios (\" + criteria.length + \")\",\n schema: { type: \"object\", properties: { results: { type: \"array\", items: { type: \"object\", properties: { criterion: { type: \"string\" }, verified_by: { type: \"string\" }, evidence: { type: \"string\" } }, required: [\"criterion\", \"verified_by\", \"evidence\"] } } }, required: [\"results\"] }\n})\n\nphase(\"Done\")\nconst done = await agent({\n prompt: ${q('Redacta el informe final de build. Solo declara done si CADA criterio tiene verified_by y evidencia. Devuelve JSON {\"report\": string, \"done\": boolean, \"gaps\": [string]}.')},\n label: \"informe final\",\n schema: { type: \"object\", properties: { report: { type: \"string\" }, done: { type: \"boolean\" }, gaps: { type: \"array\", items: { type: \"string\" } } }, required: [\"report\", \"done\"] }\n})\n\nreturn done ? done.report || JSON.stringify(done) : null\n`;\n}\n\n/**\n * Codebase-audit (§4): módulos → auditoría paralela (seguridad, deuda, bugs,\n * compliance) → informe + (opcional) nodos QA_FINDING/RISK del grafo.\n */\nexport function generateCodebaseAuditScript(options: { angles?: number; graph?: boolean } = {}): string {\n\tconst angles = Math.min(Math.max(options.angles ?? 4, 1), 8);\n\tconst perspectives = [\n\t\t\"seguridad (injection, secrets, límites de confianza)\",\n\t\t\"deuda técnica y arquitectura\",\n\t\t\"bugs y correctitud\",\n\t\t\"cumplimiento / RGPD / datos personales\",\n\t].slice(0, angles);\n\tconst graphHooks = options.graph\n\t\t? \"\\n\\nTras el informe, usa la tool graph_add_nodes para registrar QA_FINDING y RISK con sus citas.\"\n\t\t: \"\";\n\treturn `export const meta = {\n \"name\": \"codebase_audit\",\n \"description\": \"Auditoría del codebase con ángulos paralelos y síntesis\",\n \"phases\": [\n { \"title\": \"Walk\" },\n { \"title\": \"Audit\" },\n { \"title\": \"Report\" }\n ]\n}\n\nphase(\"Walk\")\nconst modules = await agent({\n prompt: ${q(`Audita este repo: (args.path ?? \".\"). En qué módulos se dividiría la auditoría. Devuelve JSON {\"modules\": [string]} (máx ${angles}).`)},\n label: \"identificar módulos\",\n schema: { type: \"object\", properties: { modules: { type: \"array\", items: { type: \"string\" } } }, required: [\"modules\"] }\n})\n\nphase(\"Audit\")\nconst perspectives = ${JSON.stringify(perspectives)}\nconst audits = await parallel(perspectives.map((p, i) => () =>\n agent({\n prompt: ${q(\"Audita el módulo(s) desde la perspectiva: \")} + p +\n ${q(\"\\nMódulos: \")} + JSON.stringify((modules && modules.modules) || []) +\n ${q(`\\nPara cada hallazgo cita archivo:línea. Devuelve JSON {\"findings\": [{\"type\": \"RISK|QA_FINDING\", \"severity\": string, \"file\": string, \"line\": number, \"issue\": string}]}.${graphHooks}`)},\n label: \"auditar: \" + p,\n schema: { type: \"object\", properties: { findings: { type: \"array\", items: { type: \"object\", properties: { type: { type: \"string\" }, severity: { type: \"string\" }, file: { type: \"string\" }, issue: { type: \"string\" } }, required: [\"type\", \"severity\", \"file\", \"issue\"] } } }, required: [\"findings\"] }\n })\n))\n\nphase(\"Report\")\nconst report = await agent({\n prompt: ${q('Sintetiza los hallazgos de auditoría en un informe Markdown ordenado por severidad, agrupado por perspectiva, con citas archivo:línea y recomendaciones priorizadas. Devuelve JSON {\"report\": string}.')},\n label: \"sintetizar auditoría\",\n schema: { type: \"object\", properties: { report: { type: \"string\" } }, required: [\"report\"] }\n})\n\nreturn report ? report.report : null\n`;\n}\n\n/**\n * Multi-perspective (§4): el mismo problema desde N ángulos → síntesis con\n * desacuerdos explícitos (no consenso falso).\n */\nexport function generateMultiPerspectiveScript(options: { perspectives?: number } = {}): string {\n\tconst n = Math.min(Math.max(options.perspectives ?? 4, 2), 8);\n\tconst list = [\n\t\t\"correctitud e invariantes\",\n\t\t\"rendimiento y escalabilidad\",\n\t\t\"seguridad y confianza\",\n\t\t\"mantenibilidad y claridad\",\n\t\t\"producto y UX\",\n\t\t\"coste de operación\",\n\t].slice(0, n);\n\treturn `export const meta = {\n \"name\": \"multi_perspective\",\n \"description\": \"Análisis del mismo problema desde N perspectivas con desacuerdos explícitos\",\n \"phases\": [\n { \"title\": \"Perspectives\" },\n { \"title\": \"Synthesize\" }\n ]\n}\n\nphase(\"Perspectives\")\nconst views = await parallel(${JSON.stringify(list)}.map((p, i) => () =>\n agent({\n prompt: ${q(\"Analiza este problema: \")} + (args.problem ?? \"\") +\n ${q(\"\\nDesde la perspectiva: \")} + p +\n ${q('\\nDa tu análisis, recomendación y riesgos. Devuelve JSON {\"perspective\": string, \"recommendation\": string, \"risks\": [string]}.')},\n label: \"perspectiva: \" + p,\n schema: { type: \"object\", properties: { perspective: { type: \"string\" }, recommendation: { type: \"string\" }, risks: { type: \"array\", items: { type: \"string\" } } }, required: [\"perspective\", \"recommendation\"] }\n })\n))\n\nphase(\"Synthesize\")\nconst synthesis = await agent({\n prompt: ${q('Sintetiza los análisis. SEÑALA EXPLÍCITAMENTE los desacuerdos entre perspectivas (no creas consenso falso). Devuelve JSON {\"summary\": string, \"disagreements\": [string], \"recommended\": string}.')},\n label: \"sintetizar análisis\",\n schema: { type: \"object\", properties: { summary: { type: \"string\" }, disagreements: { type: \"array\", items: { type: \"string\" } }, recommended: { type: \"string\" } }, required: [\"summary\", \"recommended\"] }\n})\n\nreturn synthesis ? synthesis.summary || JSON.stringify(synthesis) : null\n`;\n}\n"]}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ada Intelligence Engine — GoalEngine (modelo contenedor, estilo Claude Code).
|
|
3
|
+
*
|
|
4
|
+
* El goal es un CONTENEDOR de alto nivel: objetivo + doneCriteria + estado +
|
|
5
|
+
* frenos. NO tiene pasos propios — los pasos viven en los workflows dinámicos
|
|
6
|
+
* que desencadena. Cada sub-tarea del goal (tasks) lanza un workflow
|
|
7
|
+
* (`launchWorkflow` inyectable → WorkflowManager). Cuando todas las sub-tareas
|
|
8
|
+
* terminan, el juez verifica los doneCriteria y decide done/continue.
|
|
9
|
+
*
|
|
10
|
+
* Diseño: agnóstico del LLM — `launchWorkflow` (lanza el flujo dinámico de una
|
|
11
|
+
* sub-tarea) y `judge` (juez) son inyectables. Frenos integrados: maxTurns,
|
|
12
|
+
* repeat detector, stop-file (~/.ada-stop), budget, pausa ante decisiones
|
|
13
|
+
* irreversibles.
|
|
14
|
+
*/
|
|
15
|
+
import type { AskUserQuestion, EvidenceItem, GoalEventListener, GoalFrenos, GoalJudgeFn, GoalPersistence, GoalReplanFn, GoalState, Task } from "./types.ts";
|
|
16
|
+
export interface GoalEngineOptions {
|
|
17
|
+
persistence: GoalPersistence;
|
|
18
|
+
/** Lanza el workflow dinámico de una sub-tarea → runId (goal-contenedor). */
|
|
19
|
+
launchWorkflow: (input: {
|
|
20
|
+
goalId: string;
|
|
21
|
+
goal: string;
|
|
22
|
+
taskId: string;
|
|
23
|
+
taskTitle: string;
|
|
24
|
+
doneCriteria: string[];
|
|
25
|
+
verifyCommand: string;
|
|
26
|
+
sessionId?: string;
|
|
27
|
+
}) => Promise<{
|
|
28
|
+
runId: string;
|
|
29
|
+
}>;
|
|
30
|
+
judge: GoalJudgeFn;
|
|
31
|
+
/** P1: re-planificación completa tras veredicto continue (opcional). */
|
|
32
|
+
replanFn?: GoalReplanFn;
|
|
33
|
+
frenos?: Partial<GoalFrenos>;
|
|
34
|
+
onEvent?: GoalEventListener;
|
|
35
|
+
/** Comprobador del stop-file (inyectable para tests). */
|
|
36
|
+
stopFileExists?: (path: string) => boolean;
|
|
37
|
+
/** P5: modo plan-only — no lanzar workflows hasta approve del plan. */
|
|
38
|
+
planOnly?: boolean;
|
|
39
|
+
/** Raíz del proyecto para la huella anti-cheat. Default: process.cwd(). */
|
|
40
|
+
cwd?: string;
|
|
41
|
+
/** Huella del árbol de trabajo (inyectable para tests). */
|
|
42
|
+
fingerprint?: (cwd: string) => Promise<string | undefined>;
|
|
43
|
+
now?: () => string;
|
|
44
|
+
}
|
|
45
|
+
export declare class GoalEngine {
|
|
46
|
+
private persistence;
|
|
47
|
+
/** Lock por-goal: nunca dos ticks concurrentes del mismo goal. */
|
|
48
|
+
private _tickInFlight;
|
|
49
|
+
/** Auto-continuación en vuelo tras `onWorkflowFinished` (ver `settle`). */
|
|
50
|
+
private _autoTick;
|
|
51
|
+
private launchWorkflow;
|
|
52
|
+
private judge;
|
|
53
|
+
private replanFn?;
|
|
54
|
+
private frenos;
|
|
55
|
+
private onEvent?;
|
|
56
|
+
private stopFileExists;
|
|
57
|
+
private planOnly;
|
|
58
|
+
private cwd;
|
|
59
|
+
private fingerprint;
|
|
60
|
+
private now;
|
|
61
|
+
/** cache en memoria: id → estado (el disco es la fuente de verdad). */
|
|
62
|
+
private cache;
|
|
63
|
+
constructor(options: GoalEngineOptions);
|
|
64
|
+
/** Crea un goal en estado setup (contrato). Devuelve el id para aprobar. */
|
|
65
|
+
createGoal(input: {
|
|
66
|
+
goal: string;
|
|
67
|
+
doneCriteria: string[];
|
|
68
|
+
verifyCommand: string;
|
|
69
|
+
sessionId?: string;
|
|
70
|
+
}): Promise<GoalState>;
|
|
71
|
+
/** Añade una tarea al TODO del goal sin reemplazar el plan. */
|
|
72
|
+
addTask(goalId: string, title: string): Promise<GoalState>;
|
|
73
|
+
/** Aprueba el contrato → el bucle puede arrancar. */
|
|
74
|
+
approve(goalId: string): Promise<GoalState>;
|
|
75
|
+
/**
|
|
76
|
+
* Un tick del bucle: se llama cuando el agente principal se ha settleado.
|
|
77
|
+
* Solo avanza si: status active, sin waiting, sin stop-file, bajo los
|
|
78
|
+
* límites (maxTurns, budget, repeat tolerance).
|
|
79
|
+
*/
|
|
80
|
+
tick(goalId: string): Promise<{
|
|
81
|
+
advanced: boolean;
|
|
82
|
+
state: GoalState;
|
|
83
|
+
reason?: string;
|
|
84
|
+
}>;
|
|
85
|
+
private _tickInner;
|
|
86
|
+
/**
|
|
87
|
+
* Evento del WorkflowManager: una sub-tarea terminó su workflow.
|
|
88
|
+
* Marca la task done/failed, acumula tokens/coste del run en el presupuesto
|
|
89
|
+
* del goal (freno budgetTokens/costBudget), y aplica el repeat detector
|
|
90
|
+
* (sub-tareas fallidas consecutivas → pause). El siguiente tick decide.
|
|
91
|
+
*/
|
|
92
|
+
onWorkflowFinished(workflowRunId: string, ok: boolean, summary?: string, usage?: {
|
|
93
|
+
tokens?: number;
|
|
94
|
+
cost?: number;
|
|
95
|
+
}): Promise<GoalState | null>;
|
|
96
|
+
/**
|
|
97
|
+
* Espera a la auto-continuación en vuelo. Pensado para tests, que necesitan
|
|
98
|
+
* un punto determinista tras `onWorkflowFinished`; en producción el tick es
|
|
99
|
+
* fire-and-forget y nadie lo espera.
|
|
100
|
+
*/
|
|
101
|
+
settle(): Promise<void>;
|
|
102
|
+
/** Juez obligatorio: revisa SOLO goal + criteria + evidencia citada. */
|
|
103
|
+
runJudge(state: GoalState): Promise<GoalState>;
|
|
104
|
+
/** Completa el goal con evidencia — exige juez done y evidencia citada. */
|
|
105
|
+
complete(goalId: string, summary: string, evidence: EvidenceItem[]): Promise<GoalState>;
|
|
106
|
+
/** Reemplaza la checklist completa (tool `todo`). */
|
|
107
|
+
replaceTasks(goalId: string, tasks: Task[]): Promise<GoalState>;
|
|
108
|
+
/**
|
|
109
|
+
* P1: re-planificación completa. Genera un nuevo plan con el LLM
|
|
110
|
+
* (replanFn) aprendiendo de la evidencia y del último veredicto del juez,
|
|
111
|
+
* y arranca la iteración N+1. Sin replanFn → error suave (GoalError).
|
|
112
|
+
*/
|
|
113
|
+
replan(goalId: string): Promise<GoalState>;
|
|
114
|
+
private autoReplanAfterContinue;
|
|
115
|
+
pause(goalId: string, reason?: string): Promise<GoalState>;
|
|
116
|
+
resume(goalId: string): Promise<GoalState>;
|
|
117
|
+
blocked(goalId: string, reason: string): Promise<GoalState>;
|
|
118
|
+
askUser(goalId: string, reason: string, questions: AskUserQuestion[]): Promise<GoalState>;
|
|
119
|
+
answerQuestions(goalId: string, answers: Record<string, string[]>): Promise<GoalState>;
|
|
120
|
+
get(goalId: string): Promise<GoalState | null>;
|
|
121
|
+
list(): Promise<Array<{
|
|
122
|
+
id: string;
|
|
123
|
+
goal: string;
|
|
124
|
+
status: GoalState["status"];
|
|
125
|
+
phase: GoalState["phase"];
|
|
126
|
+
updatedAt: string;
|
|
127
|
+
}>>;
|
|
128
|
+
private checkBrakes;
|
|
129
|
+
private mustLoad;
|
|
130
|
+
private commit;
|
|
131
|
+
private emit;
|
|
132
|
+
}
|
|
133
|
+
export declare function isBrakeRelevant(reason: string): boolean;
|
|
134
|
+
//# sourceMappingURL=engine.d.ts.map
|