@pentoshi/clai 3.6.0 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/compaction-summary.d.ts +17 -0
- package/dist/agent/compaction-summary.js +64 -0
- package/dist/agent/compaction-summary.js.map +1 -0
- package/dist/agent/confirm-port.d.ts +3 -1
- package/dist/agent/confirm-port.js +5 -1
- package/dist/agent/confirm-port.js.map +1 -1
- package/dist/agent/context-manager.js +45 -22
- package/dist/agent/context-manager.js.map +1 -1
- package/dist/agent/events.d.ts +6 -0
- package/dist/agent/evidence-governor.d.ts +37 -0
- package/dist/agent/evidence-governor.js +70 -0
- package/dist/agent/evidence-governor.js.map +1 -0
- package/dist/agent/loop-guard.d.ts +29 -11
- package/dist/agent/loop-guard.js +93 -39
- package/dist/agent/loop-guard.js.map +1 -1
- package/dist/agent/must-continue.d.ts +56 -0
- package/dist/agent/must-continue.js +240 -0
- package/dist/agent/must-continue.js.map +1 -0
- package/dist/agent/outcomes.d.ts +101 -0
- package/dist/agent/outcomes.js +359 -0
- package/dist/agent/outcomes.js.map +1 -0
- package/dist/agent/plan-decision.d.ts +33 -0
- package/dist/agent/plan-decision.js +104 -0
- package/dist/agent/plan-decision.js.map +1 -0
- package/dist/agent/plan-tool.d.ts +12 -0
- package/dist/agent/plan-tool.js +312 -104
- package/dist/agent/plan-tool.js.map +1 -1
- package/dist/agent/project-root.js +3 -0
- package/dist/agent/project-root.js.map +1 -1
- package/dist/agent/prompt-composer.d.ts +21 -0
- package/dist/agent/prompt-composer.js +46 -0
- package/dist/agent/prompt-composer.js.map +1 -0
- package/dist/agent/runner.d.ts +11 -1
- package/dist/agent/runner.js +1226 -971
- package/dist/agent/runner.js.map +1 -1
- package/dist/agent/scope-context.d.ts +3 -0
- package/dist/agent/scope-context.js +24 -0
- package/dist/agent/scope-context.js.map +1 -0
- package/dist/agent/scratch-write.d.ts +4 -0
- package/dist/agent/scratch-write.js +54 -0
- package/dist/agent/scratch-write.js.map +1 -0
- package/dist/agent/session-policy.d.ts +7 -0
- package/dist/agent/session-policy.js +61 -0
- package/dist/agent/session-policy.js.map +1 -1
- package/dist/agent/session-state.d.ts +41 -0
- package/dist/agent/session-state.js +107 -0
- package/dist/agent/session-state.js.map +1 -0
- package/dist/agent/step-budget.d.ts +14 -0
- package/dist/agent/step-budget.js +26 -0
- package/dist/agent/step-budget.js.map +1 -0
- package/dist/agent/task-analyzer.d.ts +12 -3
- package/dist/agent/task-analyzer.js +263 -23
- package/dist/agent/task-analyzer.js.map +1 -1
- package/dist/agent/task-evidence.d.ts +111 -29
- package/dist/agent/task-evidence.js +519 -91
- package/dist/agent/task-evidence.js.map +1 -1
- package/dist/agent/task-plan.d.ts +57 -0
- package/dist/agent/task-plan.js +147 -1
- package/dist/agent/task-plan.js.map +1 -1
- package/dist/agent/tool-call-parser.d.ts +4 -12
- package/dist/agent/tool-call-parser.js +34 -67
- package/dist/agent/tool-call-parser.js.map +1 -1
- package/dist/agent/tool-history.d.ts +7 -0
- package/dist/agent/tool-history.js +50 -0
- package/dist/agent/tool-history.js.map +1 -1
- package/dist/agent/tool-output-formatting.d.ts +13 -1
- package/dist/agent/tool-output-formatting.js +75 -22
- package/dist/agent/tool-output-formatting.js.map +1 -1
- package/dist/agent/turn-outcome.d.ts +11 -0
- package/dist/agent/turn-outcome.js +17 -0
- package/dist/agent/turn-outcome.js.map +1 -0
- package/dist/agent/turn-state.d.ts +11 -0
- package/dist/agent/turn-state.js +28 -0
- package/dist/agent/turn-state.js.map +1 -0
- package/dist/agent/workspace-orient.d.ts +11 -0
- package/dist/agent/workspace-orient.js +103 -12
- package/dist/agent/workspace-orient.js.map +1 -1
- package/dist/app/adapters/agent-event-adapter.d.ts +2 -13
- package/dist/app/adapters/agent-event-adapter.js +63 -25
- package/dist/app/adapters/agent-event-adapter.js.map +1 -1
- package/dist/app/adapters/current-agent-adapter.d.ts +0 -5
- package/dist/app/adapters/current-agent-adapter.js +4 -7
- package/dist/app/adapters/current-agent-adapter.js.map +1 -1
- package/dist/app/adapters/current-jobs-adapter.js +1 -0
- package/dist/app/adapters/current-jobs-adapter.js.map +1 -1
- package/dist/app/adapters/current-terminal-adapter.d.ts +0 -7
- package/dist/app/adapters/current-terminal-adapter.js +0 -7
- package/dist/app/adapters/current-terminal-adapter.js.map +1 -1
- package/dist/app/adapters/current-updates-adapter.d.ts +0 -5
- package/dist/app/adapters/current-updates-adapter.js +0 -5
- package/dist/app/adapters/current-updates-adapter.js.map +1 -1
- package/dist/app/adapters/in-memory-clipboard-adapter.d.ts +0 -5
- package/dist/app/adapters/in-memory-clipboard-adapter.js +0 -5
- package/dist/app/adapters/in-memory-clipboard-adapter.js.map +1 -1
- package/dist/app/commands/command.d.ts +0 -5
- package/dist/app/commands/command.js.map +1 -1
- package/dist/app/commands/registry.d.ts +0 -14
- package/dist/app/commands/registry.js +0 -20
- package/dist/app/commands/registry.js.map +1 -1
- package/dist/app/controllers/disposable.d.ts +0 -5
- package/dist/app/controllers/disposable.js +0 -5
- package/dist/app/controllers/disposable.js.map +1 -1
- package/dist/app/controllers/job-controller.d.ts +1 -5
- package/dist/app/controllers/job-controller.js +0 -4
- package/dist/app/controllers/job-controller.js.map +1 -1
- package/dist/app/controllers/plan-controller.d.ts +5 -8
- package/dist/app/controllers/plan-controller.js +30 -12
- package/dist/app/controllers/plan-controller.js.map +1 -1
- package/dist/app/controllers/session-controller.d.ts +17 -32
- package/dist/app/controllers/session-controller.js +56 -35
- package/dist/app/controllers/session-controller.js.map +1 -1
- package/dist/app/controllers/turn-controller.d.ts +2 -6
- package/dist/app/controllers/turn-controller.js +8 -8
- package/dist/app/controllers/turn-controller.js.map +1 -1
- package/dist/app/events/app-event.d.ts +4 -7
- package/dist/app/events/app-event.js +0 -6
- package/dist/app/events/app-event.js.map +1 -1
- package/dist/app/events/event-buffer.d.ts +6 -17
- package/dist/app/events/event-buffer.js +27 -24
- package/dist/app/events/event-buffer.js.map +1 -1
- package/dist/app/events/sequencer.d.ts +0 -9
- package/dist/app/events/sequencer.js +0 -4
- package/dist/app/events/sequencer.js.map +1 -1
- package/dist/app/ports/agent-port.d.ts +13 -3
- package/dist/app/ports/clipboard-port.d.ts +0 -5
- package/dist/app/ports/confirm-port.d.ts +0 -7
- package/dist/app/ports/jobs-port.d.ts +2 -5
- package/dist/app/ports/persistence-port.d.ts +0 -4
- package/dist/app/ports/secret-port.d.ts +0 -5
- package/dist/app/ports/terminal-port.d.ts +0 -6
- package/dist/app/ports/updates-port.d.ts +0 -4
- package/dist/attachments/service.d.ts +29 -0
- package/dist/attachments/service.js +47 -0
- package/dist/attachments/service.js.map +1 -0
- package/dist/commands/providers.js +0 -3
- package/dist/commands/providers.js.map +1 -1
- package/dist/commands/search-providers.d.ts +0 -33
- package/dist/commands/search-providers.js +0 -33
- package/dist/commands/search-providers.js.map +1 -1
- package/dist/commands/update.js +1 -9
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +22 -42
- package/dist/index.js.map +1 -1
- package/dist/llm/adapters/ollama-tools.d.ts +0 -4
- package/dist/llm/adapters/ollama-tools.js +0 -4
- package/dist/llm/adapters/ollama-tools.js.map +1 -1
- package/dist/llm/capabilities.d.ts +10 -10
- package/dist/llm/capabilities.js +43 -17
- package/dist/llm/capabilities.js.map +1 -1
- package/dist/llm/groq.js +0 -6
- package/dist/llm/groq.js.map +1 -1
- package/dist/llm/http.d.ts +0 -17
- package/dist/llm/http.js +0 -45
- package/dist/llm/http.js.map +1 -1
- package/dist/llm/router.d.ts +0 -6
- package/dist/llm/router.js +0 -15
- package/dist/llm/router.js.map +1 -1
- package/dist/llm/tool-protocol.d.ts +0 -6
- package/dist/llm/tool-protocol.js +3 -7
- package/dist/llm/tool-protocol.js.map +1 -1
- package/dist/modes/agent.d.ts +2 -1
- package/dist/modes/agent.js +4 -2
- package/dist/modes/agent.js.map +1 -1
- package/dist/modes/ask.d.ts +0 -18
- package/dist/modes/ask.js +0 -49
- package/dist/modes/ask.js.map +1 -1
- package/dist/os/cwd.d.ts +0 -21
- package/dist/os/cwd.js +0 -24
- package/dist/os/cwd.js.map +1 -1
- package/dist/os/pkgmgr.js +0 -6
- package/dist/os/pkgmgr.js.map +1 -1
- package/dist/prompts/embedded.d.ts +1 -0
- package/dist/prompts/embedded.js +9 -0
- package/dist/prompts/embedded.js.map +1 -0
- package/dist/prompts/index.d.ts +6 -18
- package/dist/prompts/index.js +104 -293
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/system.agent.md +228 -0
- package/dist/prompts/system.ask.md +56 -0
- package/dist/repl/prompt-line.js +0 -36
- package/dist/repl/prompt-line.js.map +1 -1
- package/dist/repl/slash-commands.d.ts +0 -9
- package/dist/repl/slash-commands.js +2 -23
- package/dist/repl/slash-commands.js.map +1 -1
- package/dist/repl.d.ts +5 -0
- package/dist/repl.js +169 -55
- package/dist/repl.js.map +1 -1
- package/dist/safety/classifier.js +17 -9
- package/dist/safety/classifier.js.map +1 -1
- package/dist/safety/engagement-policy.d.ts +46 -0
- package/dist/safety/engagement-policy.js +198 -0
- package/dist/safety/engagement-policy.js.map +1 -0
- package/dist/store/engagement.d.ts +115 -0
- package/dist/store/engagement.js +278 -0
- package/dist/store/engagement.js.map +1 -0
- package/dist/store/logs.d.ts +5 -0
- package/dist/store/logs.js +52 -2
- package/dist/store/logs.js.map +1 -1
- package/dist/store/plan.d.ts +57 -5
- package/dist/store/plan.js +182 -8
- package/dist/store/plan.js.map +1 -1
- package/dist/store/scope.d.ts +4 -1
- package/dist/store/scope.js +2 -2
- package/dist/store/scope.js.map +1 -1
- package/dist/tools/definitions.js +70 -1
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/elevated-shell.d.ts +60 -0
- package/dist/tools/elevated-shell.js +233 -0
- package/dist/tools/elevated-shell.js.map +1 -0
- package/dist/tools/file-diff.d.ts +125 -0
- package/dist/tools/file-diff.js +495 -0
- package/dist/tools/file-diff.js.map +1 -0
- package/dist/tools/fs.d.ts +11 -13
- package/dist/tools/fs.js +269 -78
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/http.d.ts +15 -0
- package/dist/tools/http.js +202 -61
- package/dist/tools/http.js.map +1 -1
- package/dist/tools/jobs.d.ts +71 -10
- package/dist/tools/jobs.js +403 -124
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/nmap-runner.d.ts +11 -0
- package/dist/tools/nmap-runner.js +115 -74
- package/dist/tools/nmap-runner.js.map +1 -1
- package/dist/tools/pentest-workflows.d.ts +8 -0
- package/dist/tools/pentest-workflows.js +71 -0
- package/dist/tools/pentest-workflows.js.map +1 -0
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/registry.js +244 -57
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/shell.d.ts +3 -0
- package/dist/tools/shell.js +35 -13
- package/dist/tools/shell.js.map +1 -1
- package/dist/tools/tool-types.d.ts +11 -0
- package/dist/tools/web/fetch-core.d.ts +7 -0
- package/dist/tools/web/fetch-core.js +40 -1
- package/dist/tools/web/fetch-core.js.map +1 -1
- package/dist/tools/web/fetch.js +8 -1
- package/dist/tools/web/fetch.js.map +1 -1
- package/dist/tui-v2/app/App.js +34 -41
- package/dist/tui-v2/app/App.js.map +1 -1
- package/dist/tui-v2/app/command-handlers.js +20 -1
- package/dist/tui-v2/app/command-handlers.js.map +1 -1
- package/dist/tui-v2/app/commands/picker-commands.js +3 -0
- package/dist/tui-v2/app/commands/picker-commands.js.map +1 -1
- package/dist/tui-v2/app/commands/session-commands.js +5 -0
- package/dist/tui-v2/app/commands/session-commands.js.map +1 -1
- package/dist/tui-v2/app/plan-lifecycle.d.ts +25 -3
- package/dist/tui-v2/app/plan-lifecycle.js +87 -24
- package/dist/tui-v2/app/plan-lifecycle.js.map +1 -1
- package/dist/tui-v2/bootstrap/patch-opentui-text.d.ts +6 -0
- package/dist/tui-v2/bootstrap/patch-opentui-text.js +53 -0
- package/dist/tui-v2/bootstrap/patch-opentui-text.js.map +1 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js +7 -0
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
- package/dist/tui-v2/components/jobs/jobs-panel.js +23 -14
- package/dist/tui-v2/components/jobs/jobs-panel.js.map +1 -1
- package/dist/tui-v2/components/modal/confirm-modal.d.ts +1 -1
- package/dist/tui-v2/components/modal/confirm-modal.js +18 -7
- package/dist/tui-v2/components/modal/confirm-modal.js.map +1 -1
- package/dist/tui-v2/components/overlay/overlay-host.js +1 -1
- package/dist/tui-v2/components/overlay/overlay-host.js.map +1 -1
- package/dist/tui-v2/components/pager/pager.d.ts +6 -0
- package/dist/tui-v2/components/pager/pager.js +313 -67
- package/dist/tui-v2/components/pager/pager.js.map +1 -1
- package/dist/tui-v2/components/status/status-line.d.ts +9 -0
- package/dist/tui-v2/components/status/status-line.js +17 -3
- package/dist/tui-v2/components/status/status-line.js.map +1 -1
- package/dist/tui-v2/components/transcript/assistant-message.js +1 -1
- package/dist/tui-v2/components/transcript/assistant-message.js.map +1 -1
- package/dist/tui-v2/components/transcript/compacted-row.js +1 -1
- package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -1
- package/dist/tui-v2/components/transcript/tool-card.d.ts +9 -1
- package/dist/tui-v2/components/transcript/tool-card.js +114 -9
- package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
- package/dist/tui-v2/components/transcript/transcript-row.js +2 -2
- package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -1
- package/dist/tui-v2/composer/composer-editor.js +16 -0
- package/dist/tui-v2/composer/composer-editor.js.map +1 -1
- package/dist/tui-v2/controllers/overlay-controller.d.ts +16 -2
- package/dist/tui-v2/controllers/overlay-controller.js +92 -12
- package/dist/tui-v2/controllers/overlay-controller.js.map +1 -1
- package/dist/tui-v2/rendering/artifact-pager-source.d.ts +19 -0
- package/dist/tui-v2/rendering/artifact-pager-source.js +103 -0
- package/dist/tui-v2/rendering/artifact-pager-source.js.map +1 -0
- package/dist/tui-v2/rendering/file-diff-view.d.ts +63 -0
- package/dist/tui-v2/rendering/file-diff-view.js +263 -0
- package/dist/tui-v2/rendering/file-diff-view.js.map +1 -0
- package/dist/tui-v2/rendering/open-tool-output.d.ts +9 -1
- package/dist/tui-v2/rendering/open-tool-output.js +65 -12
- package/dist/tui-v2/rendering/open-tool-output.js.map +1 -1
- package/dist/tui-v2/rendering/pager-chrome.d.ts +12 -0
- package/dist/tui-v2/rendering/pager-chrome.js +56 -0
- package/dist/tui-v2/rendering/pager-chrome.js.map +1 -0
- package/dist/tui-v2/rendering/plan-view.js +1 -1
- package/dist/tui-v2/rendering/plan-view.js.map +1 -1
- package/dist/tui-v2/rendering/syntax-highlight.d.ts +37 -0
- package/dist/tui-v2/rendering/syntax-highlight.js +1303 -0
- package/dist/tui-v2/rendering/syntax-highlight.js.map +1 -0
- package/dist/tui-v2/rendering/theme.d.ts +28 -0
- package/dist/tui-v2/rendering/theme.js +28 -0
- package/dist/tui-v2/rendering/theme.js.map +1 -1
- package/dist/tui-v2/rendering/tool-presenter.d.ts +5 -0
- package/dist/tui-v2/rendering/tool-presenter.js +35 -3
- package/dist/tui-v2/rendering/tool-presenter.js.map +1 -1
- package/dist/tui-v2/state/transcript-hydrate.js +5 -0
- package/dist/tui-v2/state/transcript-hydrate.js.map +1 -1
- package/dist/tui-v2/state/transcript-reducer.js +12 -2
- package/dist/tui-v2/state/transcript-reducer.js.map +1 -1
- package/dist/tui-v2/state/transcript-store.d.ts +7 -0
- package/dist/tui-v2/state/transcript-store.js +46 -0
- package/dist/tui-v2/state/transcript-store.js.map +1 -1
- package/dist/tui-v2/state/transcript-types.d.ts +12 -0
- package/dist/tui-v2/state/transcript-types.js +9 -0
- package/dist/tui-v2/state/transcript-types.js.map +1 -1
- package/dist/types.d.ts +17 -1
- package/dist/ui/mentions.d.ts +6 -0
- package/dist/ui/mentions.js +50 -12
- package/dist/ui/mentions.js.map +1 -1
- package/dist/ui/plan-pane.js +1 -1
- package/dist/ui/plan-pane.js.map +1 -1
- package/package.json +18 -12
|
@@ -1,33 +1,273 @@
|
|
|
1
|
+
import { createPlanStep } from "./task-plan.js";
|
|
2
|
+
const PENTEST_RE = /\b(?:pentest|pen[\s-]?test|penetration|security\s*(?:test|audit|scan|assess)|vapt|csrf|xss|sqli|sql[\s-]?inject|rce|lfi|rfi|ssrf|idor|xxe|deserialization|brute[\s-]?force|enumerat|exploit|vulnerabilit|recon|bug[\s-]?bounty|ctf|capture[\s-]?the[\s-]?flag|red[\s-]?team|offensive|nmap|nikto|nuclei|ffuf|gobuster|sqlmap|hydra|metasploit)\b/i;
|
|
3
|
+
const BUILD_RE = /\b(?:build|scaffold|create|implement|refactor|migrate|bootstrap|set\s*up|setup)\b/i;
|
|
4
|
+
const APP_RE = /\b(?:app|application|project|website|api|service|cli|dashboard|todo|blog|frontend|backend)\b/i;
|
|
5
|
+
const FIX_RE = /\b(?:fix|debug|broken|error|failing|crash|bug|regression|not\s+work|doesn'?t\s+work|typeerror|exception)\b/i;
|
|
6
|
+
const RESEARCH_RE = /\b(?:what\s+is|how\s+(?:do|does|to)|explain|compare|difference|latest|current|who\s+is|when\s+did|why\s+(?:is|does))\b/i;
|
|
7
|
+
const NETWORK_RE = /\b(?:scan|nmap|ping|subnet|cidr|local\s*network|hosts?|ports?|dns|whois|http|https|url|domain|ip\s*address)\b/i;
|
|
8
|
+
const SHELL_RE = /\b(?:run|execute|install|upgrade|brew|apt|npm\s+i|docker|kubectl|chmod|chown|kill|restart|service)\b/i;
|
|
9
|
+
const FS_RE = /\b(?:read|write|edit|file|directory|folder|path|rename|delete|list\s+files?|open\s+)\b/i;
|
|
1
10
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
11
|
+
* A bounded, explicit nmap operation is not a request for a full pentest.
|
|
12
|
+
* Keep it to one net.scan call unless the user also asks for assessment,
|
|
13
|
+
* reconnaissance, enumeration, exploitation, or multiple named operations.
|
|
4
14
|
*/
|
|
5
|
-
|
|
15
|
+
export function isNarrowExplicitNmapOperation(prompt) {
|
|
16
|
+
const text = prompt.replace(/\s+/g, " ").trim();
|
|
17
|
+
if (!/\bnmap\b/i.test(text))
|
|
18
|
+
return false;
|
|
19
|
+
const explicitRun = /^(?:sudo\s+)?nmap(?:\s|$)/i.test(text) ||
|
|
20
|
+
/\b(?:run|execute|start|perform)\b[\s\S]{0,40}\bnmap\b/i.test(text) ||
|
|
21
|
+
/\bnmap\b[\s\S]{0,20}\bscan\b/i.test(text) ||
|
|
22
|
+
/\bscan\b[\s\S]{0,40}\bwith\s+nmap\b/i.test(text);
|
|
23
|
+
if (!explicitRun)
|
|
24
|
+
return false;
|
|
25
|
+
if (/\b(?:pentest|pen[\s-]?test|penetration|security\s+(?:audit|assessment|test)|vapt|recon(?:naissance)?|enumerat\w*|attack\s+surface|vulnerabilit\w*|exploit\w*|bug\s*bounty|red\s*team|threat\s+model|web\s+assessment)\b/i.test(text)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (/\b(?:and|then|also)\b[\s\S]{0,40}\b(?:whois|dns|dig|http|crawl|fuzz|nikto|nuclei|sqlmap|gobuster|ffuf)\b/i.test(text)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
function wordCount(prompt) {
|
|
34
|
+
return prompt.trim().split(/\s+/).filter(Boolean).length;
|
|
35
|
+
}
|
|
36
|
+
function classifyCategory(prompt) {
|
|
37
|
+
if (PENTEST_RE.test(prompt)) {
|
|
38
|
+
if (/\b(?:dns|whois|subdomain)\b/i.test(prompt))
|
|
39
|
+
return "dns";
|
|
40
|
+
if (/\b(?:whois|registrar|owner)\b/i.test(prompt))
|
|
41
|
+
return "whois";
|
|
42
|
+
if (/\b(?:dir|fuzz|gobuster|ffuf|content\s*discover)\b/i.test(prompt)) {
|
|
43
|
+
return "web-enum";
|
|
44
|
+
}
|
|
45
|
+
if (/\b(?:recon|enumerat|osint|fingerprint)\b/i.test(prompt)) {
|
|
46
|
+
return "pentest-recon";
|
|
47
|
+
}
|
|
48
|
+
return "pentest-recon";
|
|
49
|
+
}
|
|
50
|
+
if (/\b(?:whois)\b/i.test(prompt))
|
|
51
|
+
return "whois";
|
|
52
|
+
if (/\b(?:dns|dig|nslookup|resolve)\b/i.test(prompt))
|
|
53
|
+
return "dns";
|
|
54
|
+
if (NETWORK_RE.test(prompt) && /\b(?:discover|sweep|live\s*hosts?)\b/i.test(prompt)) {
|
|
55
|
+
return "network-discovery";
|
|
56
|
+
}
|
|
57
|
+
if (/\b(?:pkg|package|brew\s+install|apt\s+install|install\s+\w+)\b/i.test(prompt)) {
|
|
58
|
+
return "package";
|
|
59
|
+
}
|
|
60
|
+
if (BUILD_RE.test(prompt) || FIX_RE.test(prompt) || FS_RE.test(prompt)) {
|
|
61
|
+
return "filesystem";
|
|
62
|
+
}
|
|
63
|
+
if (SHELL_RE.test(prompt))
|
|
64
|
+
return "shell";
|
|
65
|
+
if (RESEARCH_RE.test(prompt) || prompt.trim().endsWith("?"))
|
|
66
|
+
return "answer";
|
|
67
|
+
return "other";
|
|
68
|
+
}
|
|
69
|
+
function estimateComplexity(prompt, category, words) {
|
|
70
|
+
if (PENTEST_RE.test(prompt))
|
|
71
|
+
return "complex";
|
|
72
|
+
if (BUILD_RE.test(prompt) && APP_RE.test(prompt))
|
|
73
|
+
return "complex";
|
|
74
|
+
if (/\b(?:multi-?file|across\s+files|refactor|migrate|end-?to-?end|full\s+stack)\b/i.test(prompt)) {
|
|
75
|
+
return "complex";
|
|
76
|
+
}
|
|
77
|
+
if (FIX_RE.test(prompt)) {
|
|
78
|
+
return words > 40 ? "complex" : "standard";
|
|
79
|
+
}
|
|
80
|
+
if (category === "answer" && words <= 20)
|
|
81
|
+
return "simple";
|
|
82
|
+
if (words <= 6 && !BUILD_RE.test(prompt) && !PENTEST_RE.test(prompt)) {
|
|
83
|
+
return "simple";
|
|
84
|
+
}
|
|
85
|
+
if (words <= 28 && !BUILD_RE.test(prompt))
|
|
86
|
+
return "standard";
|
|
87
|
+
return words > 40 || BUILD_RE.test(prompt) ? "complex" : "standard";
|
|
88
|
+
}
|
|
89
|
+
function shouldPlanFor(prompt, complexity, category) {
|
|
90
|
+
if (complexity === "simple")
|
|
91
|
+
return false;
|
|
92
|
+
if (category === "answer")
|
|
93
|
+
return false;
|
|
94
|
+
if (PENTEST_RE.test(prompt))
|
|
95
|
+
return true;
|
|
96
|
+
if (BUILD_RE.test(prompt) && APP_RE.test(prompt))
|
|
97
|
+
return true;
|
|
98
|
+
if (/\b(?:implement|refactor|migrate|multi-?step|several\s+files|end-?to-?end)\b/i.test(prompt)) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return complexity === "complex" && wordCount(prompt) > 25;
|
|
102
|
+
}
|
|
103
|
+
function inferLikelyTools(prompt, category) {
|
|
104
|
+
const tools = new Set();
|
|
105
|
+
if (category === "answer" || RESEARCH_RE.test(prompt)) {
|
|
106
|
+
tools.add("web.search");
|
|
107
|
+
tools.add("web.fetch");
|
|
108
|
+
}
|
|
109
|
+
if (category === "filesystem" || BUILD_RE.test(prompt) || FIX_RE.test(prompt)) {
|
|
110
|
+
tools.add("fs.list");
|
|
111
|
+
tools.add("fs.read");
|
|
112
|
+
tools.add("fs.write");
|
|
113
|
+
tools.add("fs.edit");
|
|
114
|
+
tools.add("shell.exec");
|
|
115
|
+
}
|
|
116
|
+
if (BUILD_RE.test(prompt) && APP_RE.test(prompt)) {
|
|
117
|
+
tools.add("plan.create");
|
|
118
|
+
tools.add("task.update");
|
|
119
|
+
tools.add("shell.start");
|
|
120
|
+
}
|
|
121
|
+
if (PENTEST_RE.test(prompt) || category.startsWith("pentest") || category === "web-enum") {
|
|
122
|
+
tools.add("dns.lookup");
|
|
123
|
+
tools.add("whois.lookup");
|
|
124
|
+
tools.add("http.fetch");
|
|
125
|
+
tools.add("net.scan");
|
|
126
|
+
tools.add("tool.check");
|
|
127
|
+
tools.add("plan.create");
|
|
128
|
+
}
|
|
129
|
+
if (category === "network-discovery") {
|
|
130
|
+
tools.add("net.context");
|
|
131
|
+
tools.add("net.pingSweep");
|
|
132
|
+
tools.add("net.scan");
|
|
133
|
+
}
|
|
134
|
+
if (category === "dns")
|
|
135
|
+
tools.add("dns.lookup");
|
|
136
|
+
if (category === "whois")
|
|
137
|
+
tools.add("whois.lookup");
|
|
138
|
+
if (category === "package")
|
|
139
|
+
tools.add("pkg.install");
|
|
140
|
+
if (SHELL_RE.test(prompt))
|
|
141
|
+
tools.add("shell.exec");
|
|
142
|
+
if (/\b(?:pdf)\b/i.test(prompt))
|
|
143
|
+
tools.add("pdf.read");
|
|
144
|
+
if (/\b(?:ocr|image|screenshot)\b/i.test(prompt))
|
|
145
|
+
tools.add("image.ocr");
|
|
146
|
+
return [...tools];
|
|
147
|
+
}
|
|
148
|
+
function softSteps(prompt, category) {
|
|
149
|
+
if (PENTEST_RE.test(prompt)) {
|
|
150
|
+
return [
|
|
151
|
+
createPlanStep("Recon and fingerprint stack", "pentest-recon", {
|
|
152
|
+
toolHint: "dns.lookup / http.fetch / net.scan",
|
|
153
|
+
successCriteria: "real findings from tool output",
|
|
154
|
+
}),
|
|
155
|
+
createPlanStep("Plan from findings", "other", {
|
|
156
|
+
toolHint: "plan.create",
|
|
157
|
+
successCriteria: "durable plan with verifiable tasks",
|
|
158
|
+
}),
|
|
159
|
+
createPlanStep("Test high-value vectors", "web-enum", {
|
|
160
|
+
successCriteria: "validated evidence or clean negatives",
|
|
161
|
+
}),
|
|
162
|
+
createPlanStep("Report with evidence", "other", {
|
|
163
|
+
successCriteria: "findings with repro + severity",
|
|
164
|
+
}),
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
if (BUILD_RE.test(prompt) && APP_RE.test(prompt)) {
|
|
168
|
+
return [
|
|
169
|
+
createPlanStep("Explore destination and stack", "filesystem", {
|
|
170
|
+
toolHint: "fs.list / fs.read",
|
|
171
|
+
}),
|
|
172
|
+
createPlanStep("Plan multi-step build", "other", {
|
|
173
|
+
toolHint: "plan.create",
|
|
174
|
+
}),
|
|
175
|
+
createPlanStep("Implement requested feature", "filesystem", {
|
|
176
|
+
toolHint: "fs.write / fs.edit",
|
|
177
|
+
}),
|
|
178
|
+
createPlanStep("Verify (build and/or live server)", "shell", {
|
|
179
|
+
toolHint: "shell.start / shell.exec",
|
|
180
|
+
}),
|
|
181
|
+
];
|
|
182
|
+
}
|
|
183
|
+
if (FIX_RE.test(prompt)) {
|
|
184
|
+
return [
|
|
185
|
+
createPlanStep("Reproduce and capture error", "shell"),
|
|
186
|
+
createPlanStep("Localize root cause", "filesystem", {
|
|
187
|
+
toolHint: "fs.read / fs.search",
|
|
188
|
+
}),
|
|
189
|
+
createPlanStep("Apply minimal fix", "filesystem", {
|
|
190
|
+
toolHint: "fs.edit",
|
|
191
|
+
}),
|
|
192
|
+
createPlanStep("Re-run failing check", "shell"),
|
|
193
|
+
];
|
|
194
|
+
}
|
|
195
|
+
if (category === "network-discovery") {
|
|
196
|
+
return [
|
|
197
|
+
createPlanStep("Local network context", "network-discovery", {
|
|
198
|
+
toolHint: "net.context",
|
|
199
|
+
}),
|
|
200
|
+
createPlanStep("Discover live hosts", "network-discovery", {
|
|
201
|
+
toolHint: "net.pingSweep",
|
|
202
|
+
}),
|
|
203
|
+
createPlanStep("Summarize findings", "other"),
|
|
204
|
+
];
|
|
205
|
+
}
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
function stopWhenFor(prompt, category) {
|
|
209
|
+
if (PENTEST_RE.test(prompt)) {
|
|
210
|
+
return "Findings report with evidence; no local dev server; scope respected.";
|
|
211
|
+
}
|
|
212
|
+
if (BUILD_RE.test(prompt) && APP_RE.test(prompt)) {
|
|
213
|
+
return "Requested feature works; verified via build and/or live localhost probe; server left running when applicable.";
|
|
214
|
+
}
|
|
215
|
+
if (FIX_RE.test(prompt)) {
|
|
216
|
+
return "Original failing check now passes; root cause addressed.";
|
|
217
|
+
}
|
|
218
|
+
if (category === "answer") {
|
|
219
|
+
return "Accurate answer grounded in tools when facts are volatile.";
|
|
220
|
+
}
|
|
221
|
+
return "User request completed with tool-backed evidence.";
|
|
222
|
+
}
|
|
6
223
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* No pre-baked steps — the AI decides everything dynamically.
|
|
224
|
+
* Lightweight task analysis for step budgets and soft guidance.
|
|
225
|
+
* Does not execute or force a plan — the agent still owns decisions.
|
|
10
226
|
*/
|
|
11
227
|
export function analyzeTask(prompt) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
228
|
+
const text = prompt.replace(/\s+/g, " ").trim();
|
|
229
|
+
if (isNarrowExplicitNmapOperation(text)) {
|
|
230
|
+
return {
|
|
231
|
+
complexity: "standard",
|
|
232
|
+
shouldPlan: false,
|
|
233
|
+
category: "pentest-recon",
|
|
234
|
+
goal: text.slice(0, 100),
|
|
235
|
+
needsNetworkContext: false,
|
|
236
|
+
needsToolPreflight: true,
|
|
237
|
+
likelyTools: ["net.scan"],
|
|
238
|
+
stopWhen: "The requested nmap operation has started or completed and its canonical job ID, status, and output are reported; do not broaden scope.",
|
|
239
|
+
suggestedSteps: [],
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
const words = wordCount(text);
|
|
243
|
+
const category = classifyCategory(text);
|
|
244
|
+
const complexity = estimateComplexity(text, category, words);
|
|
245
|
+
const shouldPlan = shouldPlanFor(text, complexity, category);
|
|
246
|
+
const likelyTools = inferLikelyTools(text, category);
|
|
247
|
+
const suggestedSteps = complexity === "simple" || category === "answer" ? [] : softSteps(text, category);
|
|
21
248
|
return {
|
|
22
249
|
complexity,
|
|
23
|
-
shouldPlan
|
|
24
|
-
category
|
|
25
|
-
goal:
|
|
26
|
-
needsNetworkContext:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
250
|
+
shouldPlan,
|
|
251
|
+
category,
|
|
252
|
+
goal: text.slice(0, 100),
|
|
253
|
+
needsNetworkContext: category === "network-discovery" ||
|
|
254
|
+
/\b(?:local\s*network|subnet|cidr|lan|my\s+network)\b/i.test(text),
|
|
255
|
+
needsToolPreflight: PENTEST_RE.test(text) ||
|
|
256
|
+
/\b(?:nmap|ffuf|gobuster|sqlmap|nuclei|hydra|nikto)\b/i.test(text),
|
|
257
|
+
likelyTools,
|
|
258
|
+
stopWhen: stopWhenFor(text, category),
|
|
259
|
+
suggestedSteps,
|
|
31
260
|
};
|
|
32
261
|
}
|
|
262
|
+
/** Compact one-liner for session/system context (optional inject). */
|
|
263
|
+
export function formatTaskAnalysisHint(analysis) {
|
|
264
|
+
const tools = analysis.likelyTools.length > 0
|
|
265
|
+
? analysis.likelyTools.slice(0, 8).join(", ")
|
|
266
|
+
: "—";
|
|
267
|
+
const tracking = analysis.shouldPlan
|
|
268
|
+
? "durable task tracking strongly recommended: create one concise plan before mutation, then keep task.update states aligned with real work"
|
|
269
|
+
: "direct execution ok";
|
|
270
|
+
return (`TASK ANALYSIS: category=${analysis.category} complexity=${analysis.complexity} (${tracking}). ` +
|
|
271
|
+
`Likely tools: ${tools}. Done when: ${analysis.stopWhen}`);
|
|
272
|
+
}
|
|
33
273
|
//# sourceMappingURL=task-analyzer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-analyzer.js","sourceRoot":"","sources":["../../src/agent/task-analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"task-analyzer.js","sourceRoot":"","sources":["../../src/agent/task-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBhD,MAAM,UAAU,GACd,mVAAmV,CAAC;AAEtV,MAAM,QAAQ,GACZ,oFAAoF,CAAC;AAEvF,MAAM,MAAM,GACV,+FAA+F,CAAC;AAElG,MAAM,MAAM,GACV,6GAA6G,CAAC;AAEhH,MAAM,WAAW,GACf,yHAAyH,CAAC;AAE5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AAU;QAClC,CAAC,CAAC,0IAA0I;QAC5I,CAAC,CAAC,qBAAqB,CAAC;IAC1B,OAAO,CACL,2BAA2B,QAAQ,CAAC,QAAQ,eAAe,QAAQ,CAAC,UAAU,KAAK,QAAQ,KAAK;QAChG,iBAAiB,KAAK,gBAAgB,QAAQ,CAAC,QAAQ,EAAE,CAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -1,26 +1,100 @@
|
|
|
1
1
|
import type { ToolCall } from "../types.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
export interface TaskWorkLedger {
|
|
2
|
+
import type { TaskEvidence } from "../store/plan.js";
|
|
3
|
+
/** Successful non-meta work under the open plan task (typed evidence for done). */
|
|
4
|
+
export type TaskClass = "explore" | "scaffold" | "install" | "implement" | "verify" | "recon" | "exploit" | "report" | "generic";
|
|
5
|
+
export interface TaskWorkLedger extends TaskEvidence {
|
|
8
6
|
taskId: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
}
|
|
8
|
+
/** Rehydrate the live task ledger from durable plan evidence after a resume. */
|
|
9
|
+
export declare function ledgerFromTaskEvidence(taskId: string, evidence?: TaskEvidence | undefined): TaskWorkLedger;
|
|
10
|
+
/** Store only serializable evidence on the plan; the task id is already its key. */
|
|
11
|
+
export declare function taskEvidenceFromLedger(ledger: TaskWorkLedger): TaskEvidence;
|
|
12
|
+
/** Optional signals recorded from a successful tool call. */
|
|
13
|
+
export interface TaskWorkSignals {
|
|
14
|
+
sourceWrite?: boolean;
|
|
15
|
+
featureWrite?: boolean;
|
|
16
|
+
installOk?: boolean;
|
|
17
|
+
scaffoldOk?: boolean;
|
|
18
|
+
devServerStart?: boolean;
|
|
19
|
+
localHttpProbeOk?: boolean;
|
|
20
|
+
serverReady?: boolean;
|
|
21
|
+
portListening?: boolean;
|
|
22
|
+
remoteReconOk?: boolean;
|
|
23
|
+
remoteActiveTestOk?: boolean;
|
|
12
24
|
}
|
|
13
25
|
export declare function isMetaPlanTool(name: string): boolean;
|
|
14
26
|
/** Tools that count as real work/verify evidence for the open task. */
|
|
15
27
|
export declare function isEvidenceWorkTool(name: string): boolean;
|
|
16
|
-
export declare function
|
|
28
|
+
export declare function isPentestPlanKind(kind: string | undefined): boolean;
|
|
29
|
+
export declare function classifyTaskTitle(title: string, opts?: {
|
|
30
|
+
planKind?: string | undefined;
|
|
31
|
+
}): TaskClass;
|
|
32
|
+
/** Successful work observed this turn without a credited open task. */
|
|
33
|
+
export interface LooseWorkReceipt {
|
|
34
|
+
readonly toolName: string;
|
|
35
|
+
readonly signals?: TaskWorkSignals | undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a successful tool can satisfy a task of the given class.
|
|
39
|
+
* Used to retroactively credit preflight work (tool.check before in_progress).
|
|
40
|
+
*/
|
|
41
|
+
export declare function toolFitsTaskClass(toolName: string, taskTitle: string, opts?: {
|
|
42
|
+
planKind?: string | undefined;
|
|
43
|
+
signals?: TaskWorkSignals | undefined;
|
|
44
|
+
}): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Fold turn-level loose successes into a task ledger so preflight work
|
|
47
|
+
* (tool.check / fs.list before in_progress) can satisfy explore/check tasks.
|
|
48
|
+
*/
|
|
49
|
+
export declare function absorbLooseWorkIntoLedger(ledger: TaskWorkLedger | null, taskId: string, taskTitle: string, loose: readonly LooseWorkReceipt[], opts?: {
|
|
50
|
+
planKind?: string | undefined;
|
|
51
|
+
}): TaskWorkLedger | null;
|
|
52
|
+
export declare function recordTaskWorkSuccess(ledger: TaskWorkLedger | null, taskId: string | undefined, toolName: string, signals?: TaskWorkSignals): TaskWorkLedger | null;
|
|
17
53
|
export declare function openTaskLedger(taskId: string): TaskWorkLedger;
|
|
18
|
-
export
|
|
54
|
+
export interface CanMarkTaskDoneOpts {
|
|
55
|
+
taskTitle?: string | undefined;
|
|
56
|
+
/** User asked for a product feature app (todo/blog/…). */
|
|
57
|
+
featureAppRequired?: boolean | undefined;
|
|
58
|
+
/** Session-level flag: feature write observed any time this turn. */
|
|
59
|
+
sessionFeatureSeen?: boolean | undefined;
|
|
60
|
+
/** A real project root was discovered, so a scaffold checkpoint is already satisfied. */
|
|
61
|
+
existingProject?: boolean | undefined;
|
|
62
|
+
/** An earlier plan task already proved the local server is ready and running. */
|
|
63
|
+
runtimeVerified?: boolean | undefined;
|
|
64
|
+
/** Plan kind: coding | pentest | general — selects domain gates. */
|
|
65
|
+
planKind?: string | undefined;
|
|
66
|
+
/** Any plan task already has successful remote recon/active test evidence. */
|
|
67
|
+
remoteWorkVerified?: boolean | undefined;
|
|
68
|
+
}
|
|
69
|
+
/** Local app runtime is proven by any strong independent signal. */
|
|
70
|
+
export declare function hasLocalRuntimeProof(evidence?: Pick<TaskEvidence, "sawDevServerStart" | "sawLocalHttpProbeOk" | "sawServerReady" | "sawPortListening"> | null): boolean;
|
|
71
|
+
export declare function hasRemoteWorkProof(evidence?: Pick<TaskEvidence, "sawRemoteReconOk" | "sawRemoteActiveTestOk"> | null): boolean;
|
|
72
|
+
/** Dev-server job log shows ready + local URL. */
|
|
73
|
+
export declare function isServerReadyOutput(output: string): boolean;
|
|
74
|
+
/** lsof/ss (or similar) shows a process LISTENing on a local port. */
|
|
75
|
+
export declare function isPortListeningOutput(command: string, output: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Leave/keep-running observational tasks may inherit already-proven runtime.
|
|
78
|
+
* "for user to test" must NOT block inheritance (prior brittle exclusion of "test").
|
|
79
|
+
*/
|
|
80
|
+
export declare function isRuntimeObservationTask(title: string): boolean;
|
|
81
|
+
/** Report / residual documentation that can inherit prior remote evidence. */
|
|
82
|
+
export declare function isRemoteObservationTask(title: string): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Typed evidence gate: base rule is ≥1 successful work tool; implement/install/verify
|
|
85
|
+
* (and pentest recon) require stronger signals when classified. Existing project and
|
|
86
|
+
* already-proven runtime/remote facts satisfy corresponding observational tasks.
|
|
87
|
+
*/
|
|
88
|
+
export declare function canMarkTaskDone(ledger: TaskWorkLedger | null, taskId: string, opts?: CanMarkTaskDoneOpts): {
|
|
19
89
|
ok: true;
|
|
20
90
|
} | {
|
|
21
91
|
ok: false;
|
|
22
92
|
reason: string;
|
|
23
93
|
};
|
|
94
|
+
/** True when a tool call is remote recon (not local app tooling). */
|
|
95
|
+
export declare function isRemoteReconToolCall(call: ToolCall): boolean;
|
|
96
|
+
/** Active/offensive test (not passive recon). */
|
|
97
|
+
export declare function isRemoteActiveTestCall(call: ToolCall): boolean;
|
|
24
98
|
/** One-shot scaffolders — must NEVER be treated as "start the dev server". Stack-agnostic. */
|
|
25
99
|
export declare function isScaffoldCreateCommand(cmd: string): boolean;
|
|
26
100
|
/**
|
|
@@ -28,12 +102,17 @@ export declare function isScaffoldCreateCommand(cmd: string): boolean;
|
|
|
28
102
|
* npm create which merely contain the word "vite".
|
|
29
103
|
*/
|
|
30
104
|
export declare function isDevServerCall(call: ToolCall): boolean;
|
|
31
|
-
/**
|
|
105
|
+
/** Inspect tools allowed without opening a plan task. */
|
|
32
106
|
export declare function isPlanPreflightTool(name: string): boolean;
|
|
107
|
+
/** Read-only recon tools that may run without an in_progress task on pentest plans. */
|
|
108
|
+
export declare function isReadOnlyReconTool(name: string): boolean;
|
|
33
109
|
/**
|
|
34
|
-
* Tools
|
|
35
|
-
*
|
|
110
|
+
* Tools whose failure must NOT cancel later siblings in the same model turn.
|
|
111
|
+
* Plan bookkeeping failures (task.update done-gate, etc.) and independent
|
|
112
|
+
* recon lookups should never wipe a whole batch of http.fetch / dns calls.
|
|
36
113
|
*/
|
|
114
|
+
export declare function isBatchSoftFailTool(name: string): boolean;
|
|
115
|
+
/** Tools allowed on a coding build turn before plan.create exists. */
|
|
37
116
|
export declare function isBuildPrePlanAllowedTool(name: string): boolean;
|
|
38
117
|
/**
|
|
39
118
|
* Commands that legitimately sit quiet for minutes (npm install, create-next-app).
|
|
@@ -45,6 +124,18 @@ export declare function toolStallBudgetMs(call: {
|
|
|
45
124
|
name: string;
|
|
46
125
|
args: Record<string, unknown>;
|
|
47
126
|
}): number;
|
|
127
|
+
/**
|
|
128
|
+
* Hard wall-clock budget for a tool call. When exceeded the runner aborts
|
|
129
|
+
* and force-settles even if the underlying promise never resolves (hung
|
|
130
|
+
* socket that ignored AbortSignal). Distinct from the stall watchdog
|
|
131
|
+
* (which fires on *silence*); this fires on total elapsed time.
|
|
132
|
+
*/
|
|
133
|
+
export declare function toolHardBudgetMs(call: {
|
|
134
|
+
name: string;
|
|
135
|
+
args: Record<string, unknown>;
|
|
136
|
+
}): number;
|
|
137
|
+
/** Grace period after abort before force-settling a hung tool promise. */
|
|
138
|
+
export declare const TOOL_ABORT_GRACE_MS = 2500;
|
|
48
139
|
/** Harmless version/which probes models use instead of tool.check before planning. */
|
|
49
140
|
export declare function isReadOnlyVersionProbeCommand(cmd: string): boolean;
|
|
50
141
|
/**
|
|
@@ -59,15 +150,6 @@ export declare function codingBuildRequiresPlan(prompt: string, opts?: {
|
|
|
59
150
|
export declare function looksLikeInstallTaskTitle(title: string): boolean;
|
|
60
151
|
export declare function looksLikeScaffoldTaskTitle(title: string): boolean;
|
|
61
152
|
export declare function isPackageInstallCommand(cmd: string): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Soft scope check: refuse run/verify tools while the open task is only
|
|
64
|
-
* scaffold / implement / install.
|
|
65
|
-
* When `planTaskTitles` is provided, install is only blocked on implement
|
|
66
|
-
* tasks if the plan actually has a dedicated install task (otherwise allow).
|
|
67
|
-
*/
|
|
68
|
-
export declare function workOutOfScopeForTask(taskTitle: string, call: ToolCall, opts?: {
|
|
69
|
-
planTaskTitles?: string[];
|
|
70
|
-
}): string | undefined;
|
|
71
153
|
/**
|
|
72
154
|
* Choose which pending plan task should own this tool call (auto-start).
|
|
73
155
|
* Prevents npm install from being attributed to "localStorage" / style tasks.
|
|
@@ -75,7 +157,7 @@ export declare function workOutOfScopeForTask(taskTitle: string, call: ToolCall,
|
|
|
75
157
|
export declare function pickPendingTaskForToolCall<T extends {
|
|
76
158
|
id: string;
|
|
77
159
|
title: string;
|
|
78
|
-
}>(pending: T[], call: ToolCall,
|
|
160
|
+
}>(pending: T[], call: ToolCall, _allTitles?: string[]): T | undefined;
|
|
79
161
|
/**
|
|
80
162
|
* User asked for a product feature app (todo, blog, …), not "just scaffold framework X".
|
|
81
163
|
* Stack-agnostic: detects intent, not a particular framework.
|
|
@@ -84,15 +166,15 @@ export declare function userAskedForFeatureApp(prompt: string): boolean;
|
|
|
84
166
|
/** Paths that look like application source (not lockfiles / build output). */
|
|
85
167
|
export declare function isAppSourcePath(path: string): boolean;
|
|
86
168
|
export declare function extractWritePathsFromCall(call: ToolCall): string[];
|
|
169
|
+
/** Default framework starter / marketing copy — not the product feature. */
|
|
170
|
+
export declare function looksLikeStarterBoilerplate(content: string): boolean;
|
|
171
|
+
/** Content that looks like real product UI/logic for common feature apps. */
|
|
172
|
+
export declare function looksLikeFeatureProductCode(content: string): boolean;
|
|
87
173
|
/**
|
|
88
174
|
* True when a successful tool call implements product feature code (not only scaffold).
|
|
175
|
+
* Starter boilerplate alone does not count.
|
|
89
176
|
*/
|
|
90
177
|
export declare function isFeatureImplementationCall(call: ToolCall): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Soft block: don't start the local server until the product feature exists.
|
|
93
|
-
* Returns a message when the open work is still scaffold-only for a feature ask.
|
|
94
|
-
*/
|
|
95
|
-
export declare function incompleteFeatureBeforeServerMessage(userPrompt: string, sawFeatureImpl: boolean, call: ToolCall): string | undefined;
|
|
96
178
|
/**
|
|
97
179
|
* User said work belongs on the Desktop (or similar). Returns absolute path.
|
|
98
180
|
*/
|