@evandu/super-pi-server 0.0.0-stage → 0.1.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -3
- package/agents/code-auditor.md +64 -0
- package/agents/code-designer.md +64 -0
- package/agents/coder.md +24 -0
- package/agents/critic.md +24 -0
- package/agents/document-organizer.md +48 -0
- package/agents/patcher.md +27 -0
- package/agents/planner.md +30 -0
- package/agents/project-leader.md +28 -0
- package/agents/reviewer.md +27 -0
- package/agents/scout.md +27 -0
- package/agents/solution-designer.md +62 -0
- package/agents/super-pi-documents/index.ts +92 -0
- package/agents/super-pi-feishu/index.ts +88 -0
- package/agents/super-pi-knowledge/index.ts +70 -0
- package/agents/super-pi-managed-model/index.ts +9 -0
- package/agents/super-pi-memory/index.ts +75 -0
- package/agents/super-pi-native-tools/index.ts +1 -0
- package/agents/super-pi-task/core.ts +2262 -0
- package/agents/super-pi-task/index.ts +814 -0
- package/agents/super-pi-task/workflow-schema.ts +34 -0
- package/agents/super-pi-web/index.ts +32 -0
- package/agents/verifier.md +25 -0
- package/assets/fonts/LICENSE +92 -0
- package/assets/fonts/NotoSansSC-Bold.otf +0 -0
- package/assets/fonts/NotoSansSC-Regular.otf +0 -0
- package/assets/knowledge-model/README.md +37 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/config.json +31 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/onnx/model_quantized.onnx +0 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/special_tokens_map.json +7 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer.json +21278 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/tokenizer_config.json +15 -0
- package/assets/knowledge-model/Xenova/bge-small-zh-v1.5/vocab.txt +21128 -0
- package/bin/npm-prefix.d.ts +1 -0
- package/bin/npm-prefix.js +10 -0
- package/bin/super-pi.js +349 -0
- package/dist/client/.super-pi-client-sources.json +82 -0
- package/dist/client/assets/CodeMirrorEditor-mi9rGUce.js +2 -0
- package/dist/client/assets/GitDiffEditor-CpoDDQrA.css +1 -0
- package/dist/client/assets/GitDiffEditor-FQBfGxOY.js +29 -0
- package/dist/client/assets/diff-ChtP43wD.js +1 -0
- package/dist/client/assets/dist-AW5lyI3I.js +1 -0
- package/dist/client/assets/dist-B3-a6uF0.js +7 -0
- package/dist/client/assets/dist-BGxkyh6e.js +1 -0
- package/dist/client/assets/dist-BJxfd7yb.js +11 -0
- package/dist/client/assets/dist-BRVQKlcp.js +1 -0
- package/dist/client/assets/dist-BV64A9Ji.js +1 -0
- package/dist/client/assets/dist-BXAOrsjq.js +1 -0
- package/dist/client/assets/dist-CKF2Jksy.js +1 -0
- package/dist/client/assets/dist-CX_Hm4GS.js +1 -0
- package/dist/client/assets/dist-Cus6_oaF.js +2 -0
- package/dist/client/assets/dist-Cx00EZKR.js +23 -0
- package/dist/client/assets/dist-D71y2EI1.js +1 -0
- package/dist/client/assets/dist-D978o95T.js +5 -0
- package/dist/client/assets/dist-Dc1MBGAG.js +1 -0
- package/dist/client/assets/dist-Dds-qLxY.js +9 -0
- package/dist/client/assets/dist-DeD9copn.js +1 -0
- package/dist/client/assets/dist-DuvGReu-.js +6 -0
- package/dist/client/assets/dist-Dvb0SqcK.js +2 -0
- package/dist/client/assets/dist-J6XWqRpB.js +3 -0
- package/dist/client/assets/dist-QzbOCAU6.js +1 -0
- package/dist/client/assets/dist-moiMRpw_.js +1 -0
- package/dist/client/assets/dist-scBkrwv-.js +2 -0
- package/dist/client/assets/dockerfile-BDePf5PZ.js +1 -0
- package/dist/client/assets/index-Cn7hdrDw.js +350 -0
- package/dist/client/assets/index-UfzqdECL.css +1 -0
- package/dist/client/assets/powershell-D8WpQPaX.js +1 -0
- package/dist/client/assets/properties-C357ku5U.js +1 -0
- package/dist/client/assets/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/client/assets/ruby-ChfNwlCY.js +1 -0
- package/dist/client/assets/shell-DwuoZtxw.js +1 -0
- package/dist/client/assets/swift-DKB6_1j6.js +1 -0
- package/dist/client/assets/toml-BPTmHmyx.js +1 -0
- package/dist/client/favicon.ico +0 -0
- package/dist/client/favicon.png +0 -0
- package/dist/client/favicon.svg +10 -0
- package/dist/client/index.html +18 -0
- package/dist/extension.d.ts +15 -0
- package/dist/extension.js +126 -0
- package/dist/server/active-memory.d.ts +247 -0
- package/dist/server/active-memory.js +669 -0
- package/dist/server/agents.d.ts +245 -0
- package/dist/server/agents.js +701 -0
- package/dist/server/application/catalog-service.d.ts +98 -0
- package/dist/server/application/catalog-service.js +245 -0
- package/dist/server/application/conversation-service.d.ts +245 -0
- package/dist/server/application/conversation-service.js +654 -0
- package/dist/server/application/document-service.d.ts +68 -0
- package/dist/server/application/document-service.js +120 -0
- package/dist/server/application/extension-ui-service.d.ts +44 -0
- package/dist/server/application/extension-ui-service.js +135 -0
- package/dist/server/application/feishu-service.d.ts +179 -0
- package/dist/server/application/feishu-service.js +358 -0
- package/dist/server/application/group-chat-service.d.ts +75 -0
- package/dist/server/application/group-chat-service.js +953 -0
- package/dist/server/application/group-execution.d.ts +15 -0
- package/dist/server/application/group-execution.js +77 -0
- package/dist/server/application/project-service.d.ts +464 -0
- package/dist/server/application/project-service.js +2523 -0
- package/dist/server/application/provider-service.d.ts +174 -0
- package/dist/server/application/provider-service.js +510 -0
- package/dist/server/application/run-service.d.ts +547 -0
- package/dist/server/application/run-service.js +2683 -0
- package/dist/server/application/scheduled-task-service.d.ts +184 -0
- package/dist/server/application/scheduled-task-service.js +391 -0
- package/dist/server/application/session-orchestrator-service.d.ts +388 -0
- package/dist/server/application/session-orchestrator-service.js +1146 -0
- package/dist/server/application/session-reminder-service.d.ts +59 -0
- package/dist/server/application/session-reminder-service.js +141 -0
- package/dist/server/application/session-watchdog.d.ts +171 -0
- package/dist/server/application/session-watchdog.js +284 -0
- package/dist/server/application/workspace-service.d.ts +52 -0
- package/dist/server/application/workspace-service.js +186 -0
- package/dist/server/application/worktree-service.d.ts +13 -0
- package/dist/server/application/worktree-service.js +76 -0
- package/dist/server/browser-access.d.ts +34 -0
- package/dist/server/browser-access.js +89 -0
- package/dist/server/capability.d.ts +105 -0
- package/dist/server/capability.js +170 -0
- package/dist/server/command-handler.d.ts +93 -0
- package/dist/server/command-handler.js +540 -0
- package/dist/server/content-search.d.ts +16 -0
- package/dist/server/content-search.js +235 -0
- package/dist/server/conversation-usage.d.ts +22 -0
- package/dist/server/conversation-usage.js +43 -0
- package/dist/server/documents.d.ts +152 -0
- package/dist/server/documents.js +998 -0
- package/dist/server/engineering-learning.d.ts +30 -0
- package/dist/server/engineering-learning.js +106 -0
- package/dist/server/exec-service.d.ts +45 -0
- package/dist/server/exec-service.js +167 -0
- package/dist/server/explicit-file-open.d.ts +34 -0
- package/dist/server/explicit-file-open.js +105 -0
- package/dist/server/failure-text.d.ts +18 -0
- package/dist/server/failure-text.js +44 -0
- package/dist/server/feishu-cli.d.ts +223 -0
- package/dist/server/feishu-cli.js +464 -0
- package/dist/server/file-changes.d.ts +119 -0
- package/dist/server/file-changes.js +280 -0
- package/dist/server/file-diff.d.ts +41 -0
- package/dist/server/file-diff.js +97 -0
- package/dist/server/file-index.d.ts +100 -0
- package/dist/server/file-index.js +296 -0
- package/dist/server/file-name-index.d.ts +160 -0
- package/dist/server/file-name-index.js +411 -0
- package/dist/server/files.d.ts +269 -0
- package/dist/server/files.js +748 -0
- package/dist/server/git.d.ts +245 -0
- package/dist/server/git.js +903 -0
- package/dist/server/http-server.d.ts +45 -0
- package/dist/server/http-server.js +3830 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +485 -0
- package/dist/server/inline-thinking.d.ts +90 -0
- package/dist/server/inline-thinking.js +181 -0
- package/dist/server/json-comments.d.ts +14 -0
- package/dist/server/json-comments.js +71 -0
- package/dist/server/knowledge-embedding-worker.d.ts +1 -0
- package/dist/server/knowledge-embedding-worker.js +27 -0
- package/dist/server/knowledge-vectors.d.ts +150 -0
- package/dist/server/knowledge-vectors.js +385 -0
- package/dist/server/knowledge.d.ts +273 -0
- package/dist/server/knowledge.js +848 -0
- package/dist/server/length-continuation.d.ts +83 -0
- package/dist/server/length-continuation.js +118 -0
- package/dist/server/logging.d.ts +32 -0
- package/dist/server/logging.js +185 -0
- package/dist/server/managed-http-tunnel.d.ts +6 -0
- package/dist/server/managed-http-tunnel.js +85 -0
- package/dist/server/managed-http.d.ts +4 -0
- package/dist/server/managed-http.js +85 -0
- package/dist/server/managed-model-adapter.d.ts +17 -0
- package/dist/server/managed-model-adapter.js +75 -0
- package/dist/server/managed-model-gateway.d.ts +49 -0
- package/dist/server/managed-model-gateway.js +73 -0
- package/dist/server/managed-servers.d.ts +55 -0
- package/dist/server/managed-servers.js +392 -0
- package/dist/server/managed-ssh.d.ts +26 -0
- package/dist/server/managed-ssh.js +73 -0
- package/dist/server/manager-vault.d.ts +11 -0
- package/dist/server/manager-vault.js +67 -0
- package/dist/server/memory-recall.d.ts +25 -0
- package/dist/server/memory-recall.js +45 -0
- package/dist/server/memory.d.ts +67 -0
- package/dist/server/memory.js +216 -0
- package/dist/server/message-media.d.ts +7 -0
- package/dist/server/message-media.js +54 -0
- package/dist/server/model-context-window.d.ts +186 -0
- package/dist/server/model-context-window.js +444 -0
- package/dist/server/model-filter.d.ts +23 -0
- package/dist/server/model-filter.js +48 -0
- package/dist/server/models-store.d.ts +36 -0
- package/dist/server/models-store.js +132 -0
- package/dist/server/native-tool-settings.d.ts +25 -0
- package/dist/server/native-tool-settings.js +41 -0
- package/dist/server/native-tools-extension.d.ts +2 -0
- package/dist/server/native-tools-extension.js +39 -0
- package/dist/server/native-tools-service.d.ts +39 -0
- package/dist/server/native-tools-service.js +240 -0
- package/dist/server/persistence/app-state-repository.d.ts +65 -0
- package/dist/server/persistence/app-state-repository.js +1 -0
- package/dist/server/persistence/json-state-repository.d.ts +14 -0
- package/dist/server/persistence/json-state-repository.js +43 -0
- package/dist/server/persistence/open-state-store.d.ts +3 -0
- package/dist/server/persistence/open-state-store.js +35 -0
- package/dist/server/persistence/rename.d.ts +22 -0
- package/dist/server/persistence/rename.js +44 -0
- package/dist/server/persistence/sqlite-state-repository.d.ts +12 -0
- package/dist/server/persistence/sqlite-state-repository.js +264 -0
- package/dist/server/pi-command.d.ts +94 -0
- package/dist/server/pi-command.js +265 -0
- package/dist/server/pi-native.d.ts +12 -0
- package/dist/server/pi-native.js +16 -0
- package/dist/server/pi-session-events.d.ts +158 -0
- package/dist/server/pi-session-events.js +373 -0
- package/dist/server/pi-session-pool.d.ts +233 -0
- package/dist/server/pi-session-pool.js +382 -0
- package/dist/server/pi-session.d.ts +642 -0
- package/dist/server/pi-session.js +655 -0
- package/dist/server/presentations/schema.d.ts +120 -0
- package/dist/server/presentations/schema.js +128 -0
- package/dist/server/provider-network.d.ts +16 -0
- package/dist/server/provider-network.js +106 -0
- package/dist/server/provider-proxy.d.ts +18 -0
- package/dist/server/provider-proxy.js +200 -0
- package/dist/server/providers.d.ts +333 -0
- package/dist/server/providers.js +989 -0
- package/dist/server/remote-bootstrap.d.ts +17 -0
- package/dist/server/remote-bootstrap.js +119 -0
- package/dist/server/rpc-channel.d.ts +131 -0
- package/dist/server/rpc-channel.js +135 -0
- package/dist/server/runtime.d.ts +1393 -0
- package/dist/server/runtime.js +3286 -0
- package/dist/server/scheduled-tasks.d.ts +101 -0
- package/dist/server/scheduled-tasks.js +138 -0
- package/dist/server/server-context.d.ts +119 -0
- package/dist/server/server-context.js +1 -0
- package/dist/server/session-cwd.d.ts +19 -0
- package/dist/server/session-cwd.js +58 -0
- package/dist/server/session-ledger.d.ts +67 -0
- package/dist/server/session-ledger.js +76 -0
- package/dist/server/session-memory-scope.d.ts +4 -0
- package/dist/server/session-memory-scope.js +30 -0
- package/dist/server/session-repository.d.ts +100 -0
- package/dist/server/session-repository.js +246 -0
- package/dist/server/session-tree-scope.d.ts +125 -0
- package/dist/server/session-tree-scope.js +337 -0
- package/dist/server/skills.d.ts +23 -0
- package/dist/server/skills.js +190 -0
- package/dist/server/store.d.ts +1062 -0
- package/dist/server/store.js +3305 -0
- package/dist/server/subagent-runs.d.ts +185 -0
- package/dist/server/subagent-runs.js +383 -0
- package/dist/server/subagents.d.ts +200 -0
- package/dist/server/subagents.js +619 -0
- package/dist/server/task-tool.d.ts +282 -0
- package/dist/server/task-tool.js +507 -0
- package/dist/server/tavily.d.ts +32 -0
- package/dist/server/tavily.js +136 -0
- package/dist/server/team-context.d.ts +12 -0
- package/dist/server/team-context.js +180 -0
- package/dist/server/terminal.d.ts +163 -0
- package/dist/server/terminal.js +557 -0
- package/dist/server/thinking-level-discovery.d.ts +38 -0
- package/dist/server/thinking-level-discovery.js +183 -0
- package/dist/server/time-zone.d.ts +20 -0
- package/dist/server/time-zone.js +32 -0
- package/dist/server/tool-calls.d.ts +130 -0
- package/dist/server/tool-calls.js +341 -0
- package/dist/server/tool-llm.d.ts +72 -0
- package/dist/server/tool-llm.js +146 -0
- package/dist/server/tool-registry.d.ts +129 -0
- package/dist/server/tool-registry.js +249 -0
- package/dist/server/tool-runner.d.ts +112 -0
- package/dist/server/tool-runner.js +306 -0
- package/dist/server/turn-failure.d.ts +48 -0
- package/dist/server/turn-failure.js +148 -0
- package/dist/server/types.d.ts +2315 -0
- package/dist/server/types.js +11 -0
- package/dist/server/update-status.d.ts +14 -0
- package/dist/server/update-status.js +69 -0
- package/dist/server/update.d.ts +46 -0
- package/dist/server/update.js +104 -0
- package/dist/server/upload.d.ts +35 -0
- package/dist/server/upload.js +177 -0
- package/dist/server/version.d.ts +33 -0
- package/dist/server/version.js +111 -0
- package/dist/server/web.d.ts +27 -0
- package/dist/server/web.js +183 -0
- package/dist/server/workflow-engine.d.ts +47 -0
- package/dist/server/workflow-engine.js +255 -0
- package/dist/server/workflow.d.ts +329 -0
- package/dist/server/workflow.js +469 -0
- package/dist/server/workspace-file-indexes.d.ts +2 -0
- package/dist/server/workspace-file-indexes.js +61 -0
- package/dist/server/workspace-file-operations.d.ts +36 -0
- package/dist/server/workspace-file-operations.js +281 -0
- package/dist/server/workspace-file-response.d.ts +7 -0
- package/dist/server/workspace-file-response.js +79 -0
- package/dist/server/ws-server.d.ts +149 -0
- package/dist/server/ws-server.js +640 -0
- package/dist/shared/agent-order.d.ts +44 -0
- package/dist/shared/agent-order.js +50 -0
- package/dist/shared/archive-decisions.d.ts +44 -0
- package/dist/shared/archive-decisions.js +98 -0
- package/dist/shared/background-task.d.ts +25 -0
- package/dist/shared/background-task.js +183 -0
- package/dist/shared/child-session-lock.d.ts +37 -0
- package/dist/shared/child-session-lock.js +59 -0
- package/dist/shared/content-search.d.ts +22 -0
- package/dist/shared/content-search.js +1 -0
- package/dist/shared/conversation-title.d.ts +4 -0
- package/dist/shared/conversation-title.js +4 -0
- package/dist/shared/file-mentions.d.ts +17 -0
- package/dist/shared/file-mentions.js +91 -0
- package/dist/shared/git-commit.d.ts +11 -0
- package/dist/shared/git-commit.js +1 -0
- package/dist/shared/git-graph.d.ts +42 -0
- package/dist/shared/git-graph.js +30 -0
- package/dist/shared/group-chat.d.ts +132 -0
- package/dist/shared/group-chat.js +6 -0
- package/dist/shared/managed-servers.d.ts +36 -0
- package/dist/shared/managed-servers.js +1 -0
- package/dist/shared/message-media.d.ts +12 -0
- package/dist/shared/message-media.js +27 -0
- package/dist/shared/model-window-label.d.ts +39 -0
- package/dist/shared/model-window-label.js +55 -0
- package/dist/shared/native-tools.d.ts +43 -0
- package/dist/shared/native-tools.js +1 -0
- package/dist/shared/pi-cache-warming.d.ts +9 -0
- package/dist/shared/pi-cache-warming.js +4 -0
- package/dist/shared/project-overview.d.ts +107 -0
- package/dist/shared/project-overview.js +92 -0
- package/dist/shared/project-presentation.d.ts +55 -0
- package/dist/shared/project-presentation.js +111 -0
- package/dist/shared/provider-network.d.ts +30 -0
- package/dist/shared/provider-network.js +1 -0
- package/dist/shared/session-reporting.d.ts +40 -0
- package/dist/shared/session-reporting.js +97 -0
- package/dist/shared/session-search.d.ts +14 -0
- package/dist/shared/session-search.js +1 -0
- package/dist/shared/team-context-view.d.ts +33 -0
- package/dist/shared/team-context-view.js +49 -0
- package/dist/shared/team-context.d.ts +59 -0
- package/dist/shared/team-context.js +3 -0
- package/dist/shared/terminal-protocol.d.ts +71 -0
- package/dist/shared/terminal-protocol.js +1 -0
- package/dist/shared/thinking-levels.d.ts +53 -0
- package/dist/shared/thinking-levels.js +85 -0
- package/dist/shared/tool-glyph.d.ts +7 -0
- package/dist/shared/tool-glyph.js +19 -0
- package/dist/shared/transcript-order.d.ts +7 -0
- package/dist/shared/transcript-order.js +12 -0
- package/dist/shared/update-status.d.ts +28 -0
- package/dist/shared/update-status.js +1 -0
- package/dist/shared/workspace-file-preview.d.ts +4 -0
- package/dist/shared/workspace-file-preview.js +28 -0
- package/package.json +448 -4
- package/scripts/diagnose.mjs +603 -0
- package/scripts/patch-brace-expansion.mjs +260 -0
- package/scripts/restart-server.mjs +104 -0
- package/skills/presentation/SKILL.md +30 -0
- package/skills/presentation/references/data.md +10 -0
- package/skills/presentation/references/quality.md +12 -0
- package/skills/presentation/references/story.md +12 -0
- package/skills/presentation/references/templates-and-editing.md +11 -0
- package/skills/presentation/references/visual-system.md +10 -0
- package/skills/super-pi-agent-development/SKILL.md +25 -0
- package/skills/super-pi-development/SKILL.md +31 -0
- package/skills/super-pi-tool-development/SKILL.md +39 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import type { SubagentRosterEntry } from "./task-tool.js";
|
|
2
|
+
import type { SubagentRun } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The workflow PLAN: a tree of steps, bounded loops and primary-supplied foreach iterations. The server
|
|
5
|
+
* executes the tree; it never asks a sub-agent to choose the control flow. Step outputs are still carried
|
|
6
|
+
* into later prompts, and every rule in this file remains pure so validation and conclusion matching can
|
|
7
|
+
* be tested without spawning a process.
|
|
8
|
+
*
|
|
9
|
+
* The dispatch and persistence seams are the existing ones: `task-tool.ts` supplies the roster,
|
|
10
|
+
* `SubagentRunRecorder.dispatch` settles every child, and `WorkflowAttempt` is the append-only artefact.
|
|
11
|
+
* There is deliberately no graph, expression language, server-side item discovery, or second artefact store.
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* The id an orchestrated plan answers to.
|
|
15
|
+
*
|
|
16
|
+
* Prefixed and uuid-shaped for the same reason run ids are: the string is a lookup key in `state.json`
|
|
17
|
+
* and appears in `data-*` attributes in the browser, and a shape a person can recognise in a log is worth
|
|
18
|
+
* more than a bare uuid. `engine.ts` validates caller-supplied ids against this prefix the way
|
|
19
|
+
* `subagents.ts:358` validates run ids, because the same string becomes a reconciliation key at startup.
|
|
20
|
+
*/
|
|
21
|
+
export declare const newWorkflowRunId: () => string;
|
|
22
|
+
/** Matches the shape `newWorkflowRunId` produces, for validating a caller-supplied id. */
|
|
23
|
+
export declare const WORKFLOW_ID_PATTERN: RegExp;
|
|
24
|
+
/**
|
|
25
|
+
* How many steps one plan may hold.
|
|
26
|
+
*
|
|
27
|
+
* A bound, because every step is a real Pi process that runs for minutes and every step's output is
|
|
28
|
+
* carried forward: the cost of a plan grows with both its length and the size of what it accumulates.
|
|
29
|
+
* Eight steps is more than the pipelines this install's four sub-agents are built for (`scout` to
|
|
30
|
+
* `patcher` to `verifier`, maybe twice), so the bound is one a real request would not reach rather than
|
|
31
|
+
* one it would hit by accident.
|
|
32
|
+
*/
|
|
33
|
+
export declare const WORKFLOW_MAX_STEPS = 8;
|
|
34
|
+
/** A loop always has a finite bound. The primary may lower it or explicitly raise it to this hard cap. */
|
|
35
|
+
export declare const WORKFLOW_DEFAULT_LOOP_MAX = 8;
|
|
36
|
+
export declare const WORKFLOW_MAX_LOOP_ROUNDS = 100;
|
|
37
|
+
/**
|
|
38
|
+
* What happens to a step that failed.
|
|
39
|
+
*
|
|
40
|
+
* `stop` is the DEFAULT and it is the honest one. `docs/AGENT_LOOP_DESIGN.md` named the failure this
|
|
41
|
+
* guards against in a sentence worth keeping: "A failed step never silently advances with missing input."
|
|
42
|
+
* Continuing past a failed step means the next sub-agent is handed a hole it cannot see, and the plan
|
|
43
|
+
* reports success. So a caller that says nothing about failure gets the behaviour that cannot lie.
|
|
44
|
+
*/
|
|
45
|
+
export type WorkflowFailurePolicy = "stop" | "skip" | "retry:1" | "retry:2" | "retry:3";
|
|
46
|
+
/** Every accepted policy, in the order the refusal message lists them for a model that guesses wrong. */
|
|
47
|
+
export declare const WORKFLOW_FAILURE_POLICIES: readonly WorkflowFailurePolicy[];
|
|
48
|
+
/**
|
|
49
|
+
* Reads a failure policy, or `undefined` for anything that is not one.
|
|
50
|
+
*
|
|
51
|
+
* `retry` alone normalizes to `retry:1`: a model that reaches for retry almost always means "try it
|
|
52
|
+
* again once", and refusing over a missing count would cost a retry of the plan itself. Everything else
|
|
53
|
+
* is refused rather than coerced, because guessing `stop` for a model that asked for `parallel` would
|
|
54
|
+
* silently run a different plan than the one it wrote.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseFailurePolicy(raw: unknown): WorkflowFailurePolicy | undefined;
|
|
57
|
+
/** How many times a policy re-runs a failing step. `stop` and `skip` both run it zero further times. */
|
|
58
|
+
export declare function retriesFor(policy: WorkflowFailurePolicy): number;
|
|
59
|
+
/** Where a whole plan ended. `running` is the only state from which it advances on its own. */
|
|
60
|
+
export type WorkflowStatus = "running" | "completed" | "failed" | "stopped";
|
|
61
|
+
/** Where one step ended. `skipped` means the policy chose to walk past it after a failure. */
|
|
62
|
+
export type WorkflowStepStatus = "pending" | "running" | "completed" | "failed" | "skipped" | "stopped";
|
|
63
|
+
/**
|
|
64
|
+
* One try at one step.
|
|
65
|
+
*
|
|
66
|
+
* THE ARTEFACT, AND THE REASON THERE IS NO ARTIFACT STORE. A failed `verifier` that is retried has two
|
|
67
|
+
* different answers - the first one found two failing assertions, the second found none - and the first
|
|
68
|
+
* is exactly what makes the second legible. So an attempt is written once and never edited, and a retry
|
|
69
|
+
* appends beside the attempt it replaced instead of overwriting it. `n` is the attempt number within its
|
|
70
|
+
* step, not a global counter, so one step's history reads 1, 2, 3 without knowing anything about its neighbours.
|
|
71
|
+
*/
|
|
72
|
+
export type WorkflowAttempt = {
|
|
73
|
+
/** 1-based within the step. Attempt 1 is the first try, not a zero-th. */
|
|
74
|
+
n: number;
|
|
75
|
+
/** The `SubagentRun` this attempt produced. Absent only when the dispatch was refused before a run row existed. */
|
|
76
|
+
runId?: string;
|
|
77
|
+
/** How the run settled. Never `running`: `dispatch` resolves only once the child is terminal. */
|
|
78
|
+
status: "completed" | "failed" | "stopped";
|
|
79
|
+
/** The child's final message. Carried forward to later steps, and read by the primary agent afterwards. */
|
|
80
|
+
output?: string;
|
|
81
|
+
outputTruncated?: boolean;
|
|
82
|
+
startedAt: string;
|
|
83
|
+
finishedAt?: string;
|
|
84
|
+
/** Why this attempt did not complete. Present only beside a `failed` or `stopped` status. */
|
|
85
|
+
error?: string;
|
|
86
|
+
};
|
|
87
|
+
/** One step of a plan. Its `attempts` array is append-only; `status` is the derived summary of it. */
|
|
88
|
+
export type WorkflowStep = {
|
|
89
|
+
index: number;
|
|
90
|
+
agentId: string;
|
|
91
|
+
/** An opaque label for a person to read. The engine never branches on it. */
|
|
92
|
+
label?: string;
|
|
93
|
+
/** The prompt as the model wrote it, before any prior output is composed into it. */
|
|
94
|
+
prompt: string;
|
|
95
|
+
attempts: WorkflowAttempt[];
|
|
96
|
+
status: WorkflowStepStatus;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* A whole orchestrated plan, as persisted.
|
|
100
|
+
*
|
|
101
|
+
* The plan is written in full BEFORE step one runs, and that is the point of the record: progression is
|
|
102
|
+
* controlled by the server walking this structure, not by conventions inside successive prompts, so a
|
|
103
|
+
* browser that reloads mid-plan reads an accurate account of what was intended and not merely what
|
|
104
|
+
* happened to be written in a transcript so far.
|
|
105
|
+
*/
|
|
106
|
+
export type WorkflowRun = {
|
|
107
|
+
id: string;
|
|
108
|
+
conversationId: string;
|
|
109
|
+
/** One line describing what the whole plan is for, shown to a person above the timeline. */
|
|
110
|
+
summary: string;
|
|
111
|
+
onFailure: WorkflowFailurePolicy;
|
|
112
|
+
status: WorkflowStatus;
|
|
113
|
+
/** Execution rows. The tree below references these by index rather than duplicating attempts and output. */
|
|
114
|
+
steps: WorkflowStep[];
|
|
115
|
+
/** Optional only for records written before recursive plans existed. */
|
|
116
|
+
nodes?: WorkflowRunNode[];
|
|
117
|
+
/** Number of settled execution rows; while running, the row currently executing or next. */
|
|
118
|
+
currentIndex: number;
|
|
119
|
+
startedAt: string;
|
|
120
|
+
finishedAt?: string;
|
|
121
|
+
};
|
|
122
|
+
export type WorkflowStepRef = {
|
|
123
|
+
kind: "step";
|
|
124
|
+
stepIndex: number;
|
|
125
|
+
};
|
|
126
|
+
export type WorkflowLoopRound = {
|
|
127
|
+
n: number;
|
|
128
|
+
nodes: WorkflowRunNode[];
|
|
129
|
+
/** The round's last node output. Missing output can never satisfy `until`. */
|
|
130
|
+
output?: string;
|
|
131
|
+
untilMet: boolean;
|
|
132
|
+
};
|
|
133
|
+
export type WorkflowLoopRun = {
|
|
134
|
+
kind: "loop";
|
|
135
|
+
until: string;
|
|
136
|
+
max: number;
|
|
137
|
+
/** The primary's body definition, retained so future rounds survive a reload with the whole plan. */
|
|
138
|
+
do: WorkflowPlanNode[];
|
|
139
|
+
rounds: WorkflowLoopRound[];
|
|
140
|
+
};
|
|
141
|
+
export type WorkflowForeachIteration = {
|
|
142
|
+
item: string;
|
|
143
|
+
nodes: WorkflowRunNode[];
|
|
144
|
+
};
|
|
145
|
+
export type WorkflowForeachRun = {
|
|
146
|
+
kind: "foreach";
|
|
147
|
+
items: string[];
|
|
148
|
+
iterations: WorkflowForeachIteration[];
|
|
149
|
+
};
|
|
150
|
+
export type WorkflowRunNode = WorkflowStepRef | WorkflowLoopRun | WorkflowForeachRun;
|
|
151
|
+
/** One step as the primary agent is told about it: the last attempt, not the whole history. */
|
|
152
|
+
export type WorkflowStepSummary = {
|
|
153
|
+
n: number;
|
|
154
|
+
agentId: string;
|
|
155
|
+
label?: string;
|
|
156
|
+
status: WorkflowStepStatus;
|
|
157
|
+
/** How many tries this step took. Above one, the step failed before it passed, and that is visible. */
|
|
158
|
+
attempts: number;
|
|
159
|
+
output?: string;
|
|
160
|
+
outputTruncated?: boolean;
|
|
161
|
+
error?: string;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* What the endpoint hands back so the extension can render one envelope.
|
|
165
|
+
*
|
|
166
|
+
* The last attempt's output rather than all of them, for the same reason the conversation transcript is
|
|
167
|
+
* not re-sent into every turn: the primary agent needs to know what the pipeline concluded, and the
|
|
168
|
+
* earlier attempts are already in the run records and the timeline. Rendering happens on the extension
|
|
169
|
+
* side because the envelope is the tool's return value, not the server's - the same split
|
|
170
|
+
* `task-tool.ts:17-19` states for `<task>`.
|
|
171
|
+
*/
|
|
172
|
+
export type WorkflowSummary = {
|
|
173
|
+
id: string;
|
|
174
|
+
summary: string;
|
|
175
|
+
status: WorkflowStatus;
|
|
176
|
+
onFailure: WorkflowFailurePolicy;
|
|
177
|
+
steps: WorkflowStepSummary[];
|
|
178
|
+
finishedAt?: string;
|
|
179
|
+
};
|
|
180
|
+
export type WorkflowStepPlan = {
|
|
181
|
+
kind: "step";
|
|
182
|
+
agentId: string;
|
|
183
|
+
label?: string;
|
|
184
|
+
prompt: string;
|
|
185
|
+
};
|
|
186
|
+
export type WorkflowLoopPlan = {
|
|
187
|
+
kind: "loop";
|
|
188
|
+
until: string;
|
|
189
|
+
max?: number;
|
|
190
|
+
do: WorkflowPlanNode[];
|
|
191
|
+
};
|
|
192
|
+
export type WorkflowForeachPlan = {
|
|
193
|
+
kind: "foreach";
|
|
194
|
+
items: string[];
|
|
195
|
+
do: WorkflowPlanNode[];
|
|
196
|
+
};
|
|
197
|
+
export type WorkflowPlanNode = WorkflowStepPlan | WorkflowLoopPlan | WorkflowForeachPlan;
|
|
198
|
+
/** The plan shape the engine executes, after validation. What `validateWorkflowPlan` returns on success. */
|
|
199
|
+
export type WorkflowPlan = {
|
|
200
|
+
summary: string;
|
|
201
|
+
onFailure: WorkflowFailurePolicy;
|
|
202
|
+
/** Legacy input, and a flat declaration index for recursive input. Runtime executions live on WorkflowRun. */
|
|
203
|
+
steps: {
|
|
204
|
+
agentId: string;
|
|
205
|
+
label?: string;
|
|
206
|
+
prompt: string;
|
|
207
|
+
}[];
|
|
208
|
+
/** Present when the primary used the recursive spelling. Legacy steps are normalized by the engine. */
|
|
209
|
+
nodes?: WorkflowPlanNode[];
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Text that had to lose its front, plus what it lost and why.
|
|
213
|
+
*
|
|
214
|
+
* `truncated` is carried rather than inferred from length so a CALLER can announce the loss. The house
|
|
215
|
+
* rule here is the one `task-tool.ts:102-116` already follows for an over-long roster: a payload that
|
|
216
|
+
* quietly omits part of itself makes a reader act on a belief that is not true, with no way to notice.
|
|
217
|
+
*/
|
|
218
|
+
export type CappedText = {
|
|
219
|
+
text: string;
|
|
220
|
+
truncated: boolean;
|
|
221
|
+
droppedChars: number;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Caps a block of text from the FRONT, and says in the surviving text that something was dropped.
|
|
225
|
+
*
|
|
226
|
+
* THE TAIL IS WHAT SURVIVES, and that is not an arbitrary choice. Every sub-agent in `agents/` is written
|
|
227
|
+
* to put its conclusion last - `verifier.md` says its last line is `通过`/`失败`/`无法验证` and nothing
|
|
228
|
+
* else - so keeping the end of a report keeps the part the next step and the human both need. Cutting
|
|
229
|
+
* from the end would keep the preamble and discard the verdict, which is the one line that matters.
|
|
230
|
+
*/
|
|
231
|
+
export declare function capText(text: string, budget: number, what: string): CappedText;
|
|
232
|
+
export declare const stepStatusWord: (status: WorkflowStepStatus) => string;
|
|
233
|
+
export declare const workflowStatusWord: (status: WorkflowStatus) => string;
|
|
234
|
+
/**
|
|
235
|
+
* Per-step cap on how much of one prior output is carried into the next step's prompt.
|
|
236
|
+
*
|
|
237
|
+
* Eight KB is roughly two thousand tokens of Chinese prose or a little more of code, which is enough for
|
|
238
|
+
* the conclusion-plus-evidence shape every sub-agent in `agents/` is instructed to produce, and small
|
|
239
|
+
* enough that eight of them plus the plan itself stay inside a normal model's working context.
|
|
240
|
+
*/
|
|
241
|
+
export declare const STEP_OUTPUT_BUDGET = 8000;
|
|
242
|
+
/**
|
|
243
|
+
* Total cap across all carried-forward output in one step's prompt.
|
|
244
|
+
*
|
|
245
|
+
* Separate from the per-step cap because the per-step one alone does not bound anything: eight steps
|
|
246
|
+
* carrying 8 KB each is 64 KB, which is larger than the whole context most sub-agents run with. The
|
|
247
|
+
* budget is spent newest-first, so the immediately preceding step - the one whose conclusion the current
|
|
248
|
+
* step is most likely acting on - is never the one that loses characters.
|
|
249
|
+
*/
|
|
250
|
+
export declare const WORKFLOW_CONTEXT_BUDGET = 32000;
|
|
251
|
+
/** The token that hands a step exactly the previous step's output, with nothing prepended. */
|
|
252
|
+
export declare const PREVIOUS_TOKEN = "{{previous}}";
|
|
253
|
+
/** The token that hands a step every prior step's output, with nothing prepended. */
|
|
254
|
+
export declare const HISTORY_TOKEN = "{{history}}";
|
|
255
|
+
export declare const ITEM_TOKEN = "{{item}}";
|
|
256
|
+
export declare const LAST_TOKEN = "{{last}}";
|
|
257
|
+
/** Single-pass replacement: token-looking text inside an item or prior output is data, not another expression. */
|
|
258
|
+
export declare function substituteWorkflowVariables(prompt: string, variables: {
|
|
259
|
+
item?: string;
|
|
260
|
+
last?: string;
|
|
261
|
+
}): string;
|
|
262
|
+
/** Exact whole-line matching against the final line. Empty or missing output is false, never an error. */
|
|
263
|
+
export declare function workflowUntilMet(output: string | undefined, until: string): boolean;
|
|
264
|
+
/** What a composed prompt ended up carrying, so a caller can report it without re-parsing the string. */
|
|
265
|
+
export type ComposedPrompt = {
|
|
266
|
+
prompt: string;
|
|
267
|
+
/** How many prior steps actually contributed output. */
|
|
268
|
+
handedOff: number;
|
|
269
|
+
/** Whether anything was dropped for space. */
|
|
270
|
+
truncated: boolean;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Composes the prompt one step actually runs with, carrying earlier results into it.
|
|
274
|
+
*
|
|
275
|
+
* THE DEFAULT IS THE HANDOFF BLOCK, and the two tokens are the opt-outs. A model that does nothing
|
|
276
|
+
* special gets every prior step's output prepended, because "did the model remember to copy the last
|
|
277
|
+
* result forward" is not a property worth trusting a multi-step plan to. A model that WANTS control -
|
|
278
|
+
* wants the last output and nothing else, or wants the whole history verbatim - says so with a token,
|
|
279
|
+
* and in exchange the automatic block is suppressed entirely rather than being added alongside. Both
|
|
280
|
+
* spellings keep one rule intact: whatever this returns is the complete prompt, never a prefix that
|
|
281
|
+
* hides some of the instruction.
|
|
282
|
+
*
|
|
283
|
+
* AN EMPTY FIRST STEP IS THE PROMPT, VERBATIM. Composing a handoff header onto step one would tell a
|
|
284
|
+
* sub-agent about previous steps that do not exist, and would spend its attention on the header.
|
|
285
|
+
*/
|
|
286
|
+
export declare function composeStepPrompt(prompt: string, prior: readonly WorkflowStep[]): ComposedPrompt;
|
|
287
|
+
/**
|
|
288
|
+
* A plan that survived validation, or a sentence telling a MODEL what to fix.
|
|
289
|
+
*
|
|
290
|
+
* The refusal half exists because this value's first reader is a model about to retry: every message
|
|
291
|
+
* names what was wrong AND what an acceptable value looks like, following the rule `task-tool.ts:142`
|
|
292
|
+
* states for the depth refusal. `agents` is supplied in full even when the mistake is one member of it,
|
|
293
|
+
* because a model that guessed `scouter` has one correct answer and should not have to infer it.
|
|
294
|
+
*/
|
|
295
|
+
export type ValidatedPlan = {
|
|
296
|
+
plan: WorkflowPlan;
|
|
297
|
+
refusal?: undefined;
|
|
298
|
+
} | {
|
|
299
|
+
plan?: undefined;
|
|
300
|
+
refusal: string;
|
|
301
|
+
};
|
|
302
|
+
/**
|
|
303
|
+
* Checks an untrusted plan body against the roster that may actually be dispatched.
|
|
304
|
+
*
|
|
305
|
+
* VALIDATES, NEVER REWRITES, THE AGENT LIST. `agentId` is matched against the roster rather than
|
|
306
|
+
* defaulted, because defaulting would run a different sub-agent than the model asked for - a plan that
|
|
307
|
+
* silently substituted `patcher` for a misspelled `patchre` would edit files on a read-only request.
|
|
308
|
+
* The roster arrives already filtered to `mode: subagent` and non-hidden (`task-tool.ts:88`), so a
|
|
309
|
+
* primary agent's id is refused here by the same rule that refuses it at dispatch time
|
|
310
|
+
* (`subagents.ts:368`) - one lock, consulted twice, rather than a second list that could drift.
|
|
311
|
+
*/
|
|
312
|
+
export declare function validateWorkflowPlan(raw: unknown, roster: readonly SubagentRosterEntry[]): ValidatedPlan;
|
|
313
|
+
/**
|
|
314
|
+
* Reduces a persisted plan to what the primary agent is told when the workflow returns.
|
|
315
|
+
*
|
|
316
|
+
* ONE ATTEMPT PER STEP, THE LAST ONE. The earlier attempts stay in the run records and on the timeline,
|
|
317
|
+
* which is where a person debugging a retried plan looks; putting all of them in the envelope would make
|
|
318
|
+
* the model re-read a failure it has already acted on.
|
|
319
|
+
*/
|
|
320
|
+
export declare function workflowSummary(plan: WorkflowRun): WorkflowSummary;
|
|
321
|
+
/**
|
|
322
|
+
* The step a settled run became, as an attempt record.
|
|
323
|
+
*
|
|
324
|
+
* The narrow seam between the run recorder and this engine: everything about spawning, streaming and
|
|
325
|
+
* process teardown is the recorder's, and the only thing that crosses here is the settled record it
|
|
326
|
+
* always resolves with (`subagent-runs.ts:159`). `output` is copied rather than referenced because the
|
|
327
|
+
* store hands out clones, and a plan that kept a live reference would read whatever the run wrote next.
|
|
328
|
+
*/
|
|
329
|
+
export declare function attemptFromRun(run: SubagentRun, n: number): WorkflowAttempt;
|