@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,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE order agent lists are shown in.
|
|
3
|
+
*
|
|
4
|
+
* WHY THERE IS A SINGLE RULE AND NOT A RULE PER SIDE. The picker's list, the settings page's grid, the
|
|
5
|
+
* sub-agent roster and the project panel's employee candidates are four views of the same catalogue, and
|
|
6
|
+
* they used to disagree about what a list of agents looks like. The server sorted what it read by
|
|
7
|
+
* "(built-in first, then id)", and the client re-sorted what the server sent by a rule of its own that
|
|
8
|
+
* added one more level - "roles before workers". A reader who saw the same agents in two orders had no
|
|
9
|
+
* way to tell which screen was wrong, because neither was: they were two answers to a question nobody
|
|
10
|
+
* had asked twice the same way.
|
|
11
|
+
*
|
|
12
|
+
* So the rule is stated once, HERE, and both sides apply it. The server imports it to order the
|
|
13
|
+
* catalogue it reads; the client imports it to order every list it draws. There is no second
|
|
14
|
+
* implementation to drift, because there is no second implementation.
|
|
15
|
+
*
|
|
16
|
+
* THE ORDER IS:
|
|
17
|
+
*
|
|
18
|
+
* 1. THE PACKAGE'S OWN agents first, then the user's. The ones that ship with Super Pi are drawn with
|
|
19
|
+
* a colour dot, and a dot scattered among the user's own reads as noise rather than as a group.
|
|
20
|
+
* 2. Inside a group, the CONVERSATION ROLES (mode: primary) before the DELEGATED ones (mode:
|
|
21
|
+
* subagent), so a list reads as "the roles, then the workers".
|
|
22
|
+
* 3. Inside a group and a role, alphabetical by id, so the order never depends on the order the
|
|
23
|
+
* filesystem happened to hand the files over in.
|
|
24
|
+
*
|
|
25
|
+
* WHY THE FLAG IS NOT GUESSED HERE. "Is this the package's own agent?" is a question about where the app
|
|
26
|
+
* is installed, and only the server knows that: it reads the definitions and marks them. A client that
|
|
27
|
+
* tried to work it out from the directory path would be guessing, and would guess wrong the moment the
|
|
28
|
+
* package is installed somewhere unusual - which is exactly the case where the answer matters.
|
|
29
|
+
*/
|
|
30
|
+
/** The minimum an agent has to carry for this ordering to be able to place it. */
|
|
31
|
+
export type OrderableAgent = {
|
|
32
|
+
id: string;
|
|
33
|
+
mode?: "primary" | "subagent";
|
|
34
|
+
/** True when the definition came from the package's own agents directory. */
|
|
35
|
+
builtin?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The built-in group first, then the user's, each group by role and then by id.
|
|
39
|
+
*
|
|
40
|
+
* An agent with no `builtin` flag at all (an older server, or a hand-built fixture) counts as the
|
|
41
|
+
* user's, which is the safe direction: it puts the unflagged one where a user's own would sit rather
|
|
42
|
+
* than promoting it into the group that means "this ships with Super Pi".
|
|
43
|
+
*/
|
|
44
|
+
export declare function orderAgentsForDisplay<T extends OrderableAgent>(agents: readonly T[]): T[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE order agent lists are shown in.
|
|
3
|
+
*
|
|
4
|
+
* WHY THERE IS A SINGLE RULE AND NOT A RULE PER SIDE. The picker's list, the settings page's grid, the
|
|
5
|
+
* sub-agent roster and the project panel's employee candidates are four views of the same catalogue, and
|
|
6
|
+
* they used to disagree about what a list of agents looks like. The server sorted what it read by
|
|
7
|
+
* "(built-in first, then id)", and the client re-sorted what the server sent by a rule of its own that
|
|
8
|
+
* added one more level - "roles before workers". A reader who saw the same agents in two orders had no
|
|
9
|
+
* way to tell which screen was wrong, because neither was: they were two answers to a question nobody
|
|
10
|
+
* had asked twice the same way.
|
|
11
|
+
*
|
|
12
|
+
* So the rule is stated once, HERE, and both sides apply it. The server imports it to order the
|
|
13
|
+
* catalogue it reads; the client imports it to order every list it draws. There is no second
|
|
14
|
+
* implementation to drift, because there is no second implementation.
|
|
15
|
+
*
|
|
16
|
+
* THE ORDER IS:
|
|
17
|
+
*
|
|
18
|
+
* 1. THE PACKAGE'S OWN agents first, then the user's. The ones that ship with Super Pi are drawn with
|
|
19
|
+
* a colour dot, and a dot scattered among the user's own reads as noise rather than as a group.
|
|
20
|
+
* 2. Inside a group, the CONVERSATION ROLES (mode: primary) before the DELEGATED ones (mode:
|
|
21
|
+
* subagent), so a list reads as "the roles, then the workers".
|
|
22
|
+
* 3. Inside a group and a role, alphabetical by id, so the order never depends on the order the
|
|
23
|
+
* filesystem happened to hand the files over in.
|
|
24
|
+
*
|
|
25
|
+
* WHY THE FLAG IS NOT GUESSED HERE. "Is this the package's own agent?" is a question about where the app
|
|
26
|
+
* is installed, and only the server knows that: it reads the definitions and marks them. A client that
|
|
27
|
+
* tried to work it out from the directory path would be guessing, and would guess wrong the moment the
|
|
28
|
+
* package is installed somewhere unusual - which is exactly the case where the answer matters.
|
|
29
|
+
*/
|
|
30
|
+
/** The conversation roles come before the delegated ones, so a screen keeps reading as "roles, then workers". */
|
|
31
|
+
const modeRank = (mode) => (mode === "subagent" ? 1 : 0);
|
|
32
|
+
/**
|
|
33
|
+
* The built-in group first, then the user's, each group by role and then by id.
|
|
34
|
+
*
|
|
35
|
+
* An agent with no `builtin` flag at all (an older server, or a hand-built fixture) counts as the
|
|
36
|
+
* user's, which is the safe direction: it puts the unflagged one where a user's own would sit rather
|
|
37
|
+
* than promoting it into the group that means "this ships with Super Pi".
|
|
38
|
+
*/
|
|
39
|
+
export function orderAgentsForDisplay(agents) {
|
|
40
|
+
return [...agents].sort((a, b) => {
|
|
41
|
+
const left = a.builtin ? 0 : 1;
|
|
42
|
+
const right = b.builtin ? 0 : 1;
|
|
43
|
+
if (left !== right)
|
|
44
|
+
return left - right;
|
|
45
|
+
const roles = modeRank(a.mode) - modeRank(b.mode);
|
|
46
|
+
if (roles !== 0)
|
|
47
|
+
return roles;
|
|
48
|
+
return a.id.localeCompare(b.id);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type OverviewProject } from "./project-overview.js";
|
|
2
|
+
/**
|
|
3
|
+
* THE WORDS THE RECORD CARRIES WHEN AN ARCHIVE THROWS THE DECISION AWAY.
|
|
4
|
+
*
|
|
5
|
+
* A dismissal is a qualification, not a deletion: the case STAYS in `p.escalations`, with the
|
|
6
|
+
* reason, the decision and the moment in it - searchable, exportable. What changes is the
|
|
7
|
+
* STATUS. So the sentence has to read like a person wrote it, and it has to say who did it: the
|
|
8
|
+
* reader archived the session, and the decision went with it.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ARCHIVED_DECISION_REASON = "\u7528\u6237\u5F52\u6863\u4E86\u8D1F\u8D23\u4EBA\u4F1A\u8BDD\uFF0C\u672A\u62CD\u677F\u7684\u51B3\u7B56\u968F\u4E4B\u4F5C\u5E9F\u3002";
|
|
11
|
+
/**
|
|
12
|
+
* HOW MANY DECISIONS EACH SESSION CARRIES - counted through the projects it leads.
|
|
13
|
+
*
|
|
14
|
+
* A project can hold several open cases, and all of them are counted on that project's OWNER
|
|
15
|
+
* SESSION: that session is the project's leader, the cases were raised against it, and they are
|
|
16
|
+
* its business. Once the session is archived, the project has nobody left.
|
|
17
|
+
*/
|
|
18
|
+
export declare function pendingUserDecisionsByOwner(projects: OverviewProject[]): Record<string, number>;
|
|
19
|
+
/**
|
|
20
|
+
* HOW MANY DECISIONS THIS ARCHIVE THROWS AWAY.
|
|
21
|
+
*
|
|
22
|
+
* Every session in the tree counts: an owner session in the tree means the projects it leads
|
|
23
|
+
* lose their pending decisions.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pendingUserDecisionsForTree(counts: Record<string, number> | undefined, conversationIds: string[]): number;
|
|
26
|
+
/**
|
|
27
|
+
* THE DISMISSAL: archiving a leader session throws away the decisions that were waiting on it.
|
|
28
|
+
*
|
|
29
|
+
* There is one predicate: **the owner session is in the tree being archived** means the project
|
|
30
|
+
* has nobody left to run it, so the decisions it owes the reader go with it. Three things are
|
|
31
|
+
* NOT done:
|
|
32
|
+
*
|
|
33
|
+
* - **Another project's cases are left alone.** Somebody else's project is not this archive's
|
|
34
|
+
* business.
|
|
35
|
+
* - **Supervisor-level cases are left alone.** That is the team's business; the reader was
|
|
36
|
+
* never asked.
|
|
37
|
+
* - **No record is deleted.** The case stays in `p.escalations`, its `status` becomes
|
|
38
|
+
* `dismissed`, `decision` says why it went, and `resolvedAt` says when. A dismissal is a
|
|
39
|
+
* qualification, not a disappearance.
|
|
40
|
+
*
|
|
41
|
+
* The result is a list of the same length and the same order: an untouched project is the SAME
|
|
42
|
+
* object, a touched one is a new object. That is how the caller knows which ones to persist.
|
|
43
|
+
*/
|
|
44
|
+
export declare function dismissArchivedOwnerDecisions<T extends OverviewProject>(projects: T[], archivedConversationIds: Iterable<string>, stamp: string, reason?: string): T[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// The archive, and the decisions nobody made - one predicate, two ends.
|
|
2
|
+
//
|
|
3
|
+
// WHY THIS FILE EXISTS.
|
|
4
|
+
//
|
|
5
|
+
// An archive touches three things, and all three count the same exceptions:
|
|
6
|
+
//
|
|
7
|
+
// 1. Before the archive, tell the reader that this archive throws N decisions away
|
|
8
|
+
// (the confirmation box in the client);
|
|
9
|
+
// 2. After the archive, dismiss those decisions (the server; the record stays, only its
|
|
10
|
+
// status changes);
|
|
11
|
+
// 3. Once the decisions are dismissed, the project belongs to history or to the current view
|
|
12
|
+
// (the server decides which; the client applies the same rule).
|
|
13
|
+
//
|
|
14
|
+
// If each of the three wrote its own predicate, each of the three would get it wrong: the
|
|
15
|
+
// warning says three, the dismissal drops two, and the view files the third somewhere else.
|
|
16
|
+
// So the predicate is written once, and both ends call it.
|
|
17
|
+
//
|
|
18
|
+
// ONE PREDICATE RUNS THROUGH THE WHOLE FILE: **a decision nobody made = the reader's own
|
|
19
|
+
// decision = an open boss-level case on a project** (a case with no audience counts too - that
|
|
20
|
+
// was the default audience back then). A supervisor-level case is the team's business, not the
|
|
21
|
+
// reader's to-do: the archive does not touch it, and the view does not make room for it.
|
|
22
|
+
import { isOpenUserDecision, userProjectDecisions } from "./project-overview.js";
|
|
23
|
+
/**
|
|
24
|
+
* THE WORDS THE RECORD CARRIES WHEN AN ARCHIVE THROWS THE DECISION AWAY.
|
|
25
|
+
*
|
|
26
|
+
* A dismissal is a qualification, not a deletion: the case STAYS in `p.escalations`, with the
|
|
27
|
+
* reason, the decision and the moment in it - searchable, exportable. What changes is the
|
|
28
|
+
* STATUS. So the sentence has to read like a person wrote it, and it has to say who did it: the
|
|
29
|
+
* reader archived the session, and the decision went with it.
|
|
30
|
+
*/
|
|
31
|
+
export const ARCHIVED_DECISION_REASON = "用户归档了负责人会话,未拍板的决策随之作废。";
|
|
32
|
+
/**
|
|
33
|
+
* HOW MANY DECISIONS EACH SESSION CARRIES - counted through the projects it leads.
|
|
34
|
+
*
|
|
35
|
+
* A project can hold several open cases, and all of them are counted on that project's OWNER
|
|
36
|
+
* SESSION: that session is the project's leader, the cases were raised against it, and they are
|
|
37
|
+
* its business. Once the session is archived, the project has nobody left.
|
|
38
|
+
*/
|
|
39
|
+
export function pendingUserDecisionsByOwner(projects) {
|
|
40
|
+
const counts = {};
|
|
41
|
+
for (const project of projects) {
|
|
42
|
+
const owner = project.ownerConversationId;
|
|
43
|
+
if (!owner)
|
|
44
|
+
continue;
|
|
45
|
+
const open = userProjectDecisions(project).length;
|
|
46
|
+
if (!open)
|
|
47
|
+
continue;
|
|
48
|
+
counts[owner] = (counts[owner] ?? 0) + open;
|
|
49
|
+
}
|
|
50
|
+
return counts;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* HOW MANY DECISIONS THIS ARCHIVE THROWS AWAY.
|
|
54
|
+
*
|
|
55
|
+
* Every session in the tree counts: an owner session in the tree means the projects it leads
|
|
56
|
+
* lose their pending decisions.
|
|
57
|
+
*/
|
|
58
|
+
export function pendingUserDecisionsForTree(counts, conversationIds) {
|
|
59
|
+
if (!counts)
|
|
60
|
+
return 0;
|
|
61
|
+
let total = 0;
|
|
62
|
+
for (const id of conversationIds)
|
|
63
|
+
total += counts[id] ?? 0;
|
|
64
|
+
return total;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* THE DISMISSAL: archiving a leader session throws away the decisions that were waiting on it.
|
|
68
|
+
*
|
|
69
|
+
* There is one predicate: **the owner session is in the tree being archived** means the project
|
|
70
|
+
* has nobody left to run it, so the decisions it owes the reader go with it. Three things are
|
|
71
|
+
* NOT done:
|
|
72
|
+
*
|
|
73
|
+
* - **Another project's cases are left alone.** Somebody else's project is not this archive's
|
|
74
|
+
* business.
|
|
75
|
+
* - **Supervisor-level cases are left alone.** That is the team's business; the reader was
|
|
76
|
+
* never asked.
|
|
77
|
+
* - **No record is deleted.** The case stays in `p.escalations`, its `status` becomes
|
|
78
|
+
* `dismissed`, `decision` says why it went, and `resolvedAt` says when. A dismissal is a
|
|
79
|
+
* qualification, not a disappearance.
|
|
80
|
+
*
|
|
81
|
+
* The result is a list of the same length and the same order: an untouched project is the SAME
|
|
82
|
+
* object, a touched one is a new object. That is how the caller knows which ones to persist.
|
|
83
|
+
*/
|
|
84
|
+
export function dismissArchivedOwnerDecisions(projects, archivedConversationIds, stamp, reason = ARCHIVED_DECISION_REASON) {
|
|
85
|
+
const archived = new Set(archivedConversationIds);
|
|
86
|
+
return projects.map(project => {
|
|
87
|
+
const owner = project.ownerConversationId;
|
|
88
|
+
if (!owner || !archived.has(owner))
|
|
89
|
+
return project;
|
|
90
|
+
const escalations = project.escalations ?? [];
|
|
91
|
+
if (!escalations.some(isOpenUserDecision))
|
|
92
|
+
return project;
|
|
93
|
+
const dismissed = escalations.map(item => isOpenUserDecision(item)
|
|
94
|
+
? { ...item, status: "dismissed", decision: reason, resolvedAt: stamp }
|
|
95
|
+
: item);
|
|
96
|
+
return { ...project, escalations: dismissed };
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type BackgroundTaskStatus = "running" | "completed" | "failed" | "cancelled" | "interrupted";
|
|
2
|
+
export type BackgroundTaskDetails = {
|
|
3
|
+
id: string;
|
|
4
|
+
status: BackgroundTaskStatus;
|
|
5
|
+
output?: string;
|
|
6
|
+
outputOffset?: number;
|
|
7
|
+
outputTruncated?: boolean;
|
|
8
|
+
exitCode?: number;
|
|
9
|
+
signal?: number;
|
|
10
|
+
reason?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const BACKGROUND_LOG_LIMIT = 128000;
|
|
13
|
+
/** Render a PTY byte stream as readable text for logs and chat. This is deliberately a text view, not a
|
|
14
|
+
* terminal UI: cursor movement edits the buffered lines, while colour, title and mode controls vanish. */
|
|
15
|
+
export declare function sanitizeBackgroundOutput(value: string): string;
|
|
16
|
+
export type BackgroundCompletion = Omit<BackgroundTaskDetails, "id" | "status"> & {
|
|
17
|
+
status: Exclude<BackgroundTaskStatus, "running">;
|
|
18
|
+
};
|
|
19
|
+
export declare function subagentProgress(run: {
|
|
20
|
+
output?: string;
|
|
21
|
+
partialOutput?: string;
|
|
22
|
+
toolCalls?: readonly {
|
|
23
|
+
output?: string;
|
|
24
|
+
}[];
|
|
25
|
+
}): string;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export const BACKGROUND_LOG_LIMIT = 128_000;
|
|
2
|
+
/** Render a PTY byte stream as readable text for logs and chat. This is deliberately a text view, not a
|
|
3
|
+
* terminal UI: cursor movement edits the buffered lines, while colour, title and mode controls vanish. */
|
|
4
|
+
export function sanitizeBackgroundOutput(value) {
|
|
5
|
+
const lines = [[]];
|
|
6
|
+
let row = 0;
|
|
7
|
+
let column = 0;
|
|
8
|
+
let savedCursor = [0, 0];
|
|
9
|
+
const ensureRow = (index) => {
|
|
10
|
+
while (lines.length <= index)
|
|
11
|
+
lines.push([]);
|
|
12
|
+
};
|
|
13
|
+
const write = (text) => {
|
|
14
|
+
const cells = lines[row];
|
|
15
|
+
while (cells.length < column)
|
|
16
|
+
cells.push(" ");
|
|
17
|
+
for (const char of text) {
|
|
18
|
+
cells[column] = char;
|
|
19
|
+
column += 1;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const paramsOf = (raw) => raw.replace(/^[?>!]/u, "").split(";").map(item => Number.parseInt(item, 10) || 0);
|
|
23
|
+
const consumeCsi = (raw, final) => {
|
|
24
|
+
const params = paramsOf(raw);
|
|
25
|
+
const amount = Math.max(1, params[0] || 1);
|
|
26
|
+
switch (final) {
|
|
27
|
+
case "A":
|
|
28
|
+
row = Math.max(0, row - amount);
|
|
29
|
+
break;
|
|
30
|
+
case "B":
|
|
31
|
+
case "e":
|
|
32
|
+
row += amount;
|
|
33
|
+
ensureRow(row);
|
|
34
|
+
break;
|
|
35
|
+
case "C":
|
|
36
|
+
case "a":
|
|
37
|
+
column += amount;
|
|
38
|
+
break;
|
|
39
|
+
case "D":
|
|
40
|
+
column = Math.max(0, column - amount);
|
|
41
|
+
break;
|
|
42
|
+
case "E":
|
|
43
|
+
row += amount;
|
|
44
|
+
ensureRow(row);
|
|
45
|
+
column = 0;
|
|
46
|
+
break;
|
|
47
|
+
case "F":
|
|
48
|
+
row = Math.max(0, row - amount);
|
|
49
|
+
column = 0;
|
|
50
|
+
break;
|
|
51
|
+
case "G":
|
|
52
|
+
case "`":
|
|
53
|
+
column = Math.max(0, amount - 1);
|
|
54
|
+
break;
|
|
55
|
+
case "d":
|
|
56
|
+
row = Math.max(0, amount - 1);
|
|
57
|
+
ensureRow(row);
|
|
58
|
+
break;
|
|
59
|
+
case "H":
|
|
60
|
+
case "f":
|
|
61
|
+
row = Math.max(0, amount - 1);
|
|
62
|
+
ensureRow(row);
|
|
63
|
+
column = Math.max(0, (params[1] || 1) - 1);
|
|
64
|
+
break;
|
|
65
|
+
case "K": {
|
|
66
|
+
const cells = lines[row];
|
|
67
|
+
if ((params[0] ?? 0) === 2)
|
|
68
|
+
lines[row] = [];
|
|
69
|
+
else if ((params[0] ?? 0) === 1)
|
|
70
|
+
lines[row] = [...Array.from({ length: Math.min(column + 1, cells.length) }, () => " "), ...cells.slice(column + 1)];
|
|
71
|
+
else
|
|
72
|
+
cells.splice(column);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "J":
|
|
76
|
+
if ((params[0] ?? 0) === 2 || (params[0] ?? 0) === 3) {
|
|
77
|
+
lines.splice(0, lines.length, []);
|
|
78
|
+
row = 0;
|
|
79
|
+
column = 0;
|
|
80
|
+
}
|
|
81
|
+
else if ((params[0] ?? 0) === 0)
|
|
82
|
+
lines.splice(row + 1);
|
|
83
|
+
else if ((params[0] ?? 0) === 1) {
|
|
84
|
+
lines.splice(0, row);
|
|
85
|
+
row = 0;
|
|
86
|
+
lines[0] = [];
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
case "s":
|
|
90
|
+
savedCursor = [row, column];
|
|
91
|
+
break;
|
|
92
|
+
case "u":
|
|
93
|
+
[row, column] = savedCursor;
|
|
94
|
+
ensureRow(row);
|
|
95
|
+
break;
|
|
96
|
+
case "P":
|
|
97
|
+
lines[row].splice(column, amount);
|
|
98
|
+
break;
|
|
99
|
+
case "X": {
|
|
100
|
+
const cells = lines[row];
|
|
101
|
+
for (let index = column; index < Math.min(cells.length, column + amount); index += 1)
|
|
102
|
+
cells[index] = " ";
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
case "@": {
|
|
106
|
+
const cells = lines[row];
|
|
107
|
+
cells.splice(column, 0, ...Array.from({ length: amount }, () => " "));
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
default: break;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const skipStringControl = (start) => {
|
|
114
|
+
for (let index = start; index < value.length; index += 1) {
|
|
115
|
+
if (value[index] === "\u0007")
|
|
116
|
+
return index + 1;
|
|
117
|
+
if (value[index] === "\u001b" && value[index + 1] === "\\")
|
|
118
|
+
return index + 2;
|
|
119
|
+
}
|
|
120
|
+
return value.length;
|
|
121
|
+
};
|
|
122
|
+
for (let index = 0; index < value.length;) {
|
|
123
|
+
const char = value[index];
|
|
124
|
+
if (char === "\u0090" || char === "\u009d" || char === "\u009e" || char === "\u009f") {
|
|
125
|
+
index = skipStringControl(index + 1);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (char === "\u001b" || char === "\u009b") {
|
|
129
|
+
const next = value[index + 1];
|
|
130
|
+
if (char === "\u001b" && (next === "]" || next === "P" || next === "^" || next === "_")) {
|
|
131
|
+
index = skipStringControl(index + 2);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if ((char === "\u001b" && next === "[") || char === "\u009b") {
|
|
135
|
+
const parameterStart = index + (char === "\u009b" ? 1 : 2);
|
|
136
|
+
let end = parameterStart;
|
|
137
|
+
while (end < value.length && !(value.charCodeAt(end) >= 0x40 && value.charCodeAt(end) <= 0x7e))
|
|
138
|
+
end += 1;
|
|
139
|
+
if (end < value.length)
|
|
140
|
+
consumeCsi(value.slice(parameterStart, end), value[end]);
|
|
141
|
+
index = Math.min(value.length, end + 1);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
index += next === undefined ? 1 : 2;
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
if (char === "\r") {
|
|
148
|
+
index += 1;
|
|
149
|
+
column = 0;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (char === "\n") {
|
|
153
|
+
index += 1;
|
|
154
|
+
row += 1;
|
|
155
|
+
ensureRow(row);
|
|
156
|
+
column = 0;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (char === "\b") {
|
|
160
|
+
index += 1;
|
|
161
|
+
column = Math.max(0, column - 1);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (char === "\t") {
|
|
165
|
+
index += 1;
|
|
166
|
+
write(" ".repeat(8 - (column % 8)));
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const code = value.codePointAt(index) ?? 0;
|
|
170
|
+
if (code < 0x20 || code === 0x7f || (code >= 0x80 && code <= 0x9f)) {
|
|
171
|
+
index += code > 0xffff ? 2 : 1;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const printable = String.fromCodePoint(code);
|
|
175
|
+
write(printable);
|
|
176
|
+
index += printable.length;
|
|
177
|
+
}
|
|
178
|
+
return lines.map(cells => cells.join("")).join("\n").replace(/\n+$/u, "");
|
|
179
|
+
}
|
|
180
|
+
export function subagentProgress(run) {
|
|
181
|
+
return [run.partialOutput ?? run.output, ...(run.toolCalls ?? []).map(call => call.output)]
|
|
182
|
+
.filter(Boolean).join("\n\n");
|
|
183
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE SENTENCE. The lock says it, and the server refuses with it.
|
|
3
|
+
*
|
|
4
|
+
* IT SAYS THE RULE, NOT 「禁止」. A refusal that only says "forbidden" leaves the reader with
|
|
5
|
+
* nothing to do; a refusal that names the rule and the way out is something the reader can act
|
|
6
|
+
* on. This is why the sentence is one sentence and why it is shared: the interface and the
|
|
7
|
+
* server must not disagree about what the rule is.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CHILD_SESSION_LOCK_REASON = "\u6C47\u62A5\u7EBF\u53EA\u5141\u8BB8\u9010\u7EA7\u4E0A\u5347\uFF0C\u5B50\u4F1A\u8BDD\u9ED8\u8BA4\u4E0D\u80FD\u76F4\u63A5\u5BF9\u8BDD\uFF1B\u786E\u6709\u7279\u6B8A\u60C5\u51B5\u53EF\u89E3\u9501\u3002";
|
|
10
|
+
/**
|
|
11
|
+
* THE QUESTION LOCK SENTENCE.
|
|
12
|
+
*
|
|
13
|
+
* Child sessions must not use the `question` tool to ask the reader directly.
|
|
14
|
+
* When they need a human decision, they must report to their direct supervisor
|
|
15
|
+
* using `session_report`, which escalates through the reporting line.
|
|
16
|
+
*/
|
|
17
|
+
export declare const CHILD_QUESTION_LOCK_REASON = "\u6C47\u62A5\u7EBF\u53EA\u5141\u8BB8\u9010\u7EA7\u4E0A\u5347\uFF0C\u5B50\u4F1A\u8BDD\u9ED8\u8BA4\u4E0D\u80FD\u76F4\u63A5\u5BF9\u8BDD\uFF1B\u786E\u6709\u7279\u6B8A\u60C5\u51B5\u53EF\u89E3\u9501\u3002\u5B50\u4F1A\u8BDD\u8981\u7528 session_report \u5411\u76F4\u63A5\u4E0A\u7EA7\uFF08\u7236\u4F1A\u8BDD\uFF09\u6C47\u62A5\uFF0C\u7531\u7236\u4F1A\u8BDD\u9010\u7EA7\u8F6C\u8FF0\u3002";
|
|
18
|
+
/** The minimum a parent row has to expose for the judgement to be made. */
|
|
19
|
+
export type ChildSessionRow = {
|
|
20
|
+
id: string;
|
|
21
|
+
archivedAt?: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Whether a conversation is a CHILD SESSION: it hangs under a parent that is still ALIVE.
|
|
25
|
+
*
|
|
26
|
+
* A conversation with no parent at all is top-level, and so is an ORPHAN - one whose parent was
|
|
27
|
+
* archived and left behind. Both of them can talk to the reader directly, because there is no
|
|
28
|
+
* reporting line above them to bypass.
|
|
29
|
+
*
|
|
30
|
+
* `parentConversationId` is the conversation's own edge, and `parent` is the parent's row (or
|
|
31
|
+
* undefined when there is no such row any more). Both sides answer the question from their own
|
|
32
|
+
* rows - the client from `state.conversations`, the server from its store - and neither of them
|
|
33
|
+
* has to hand this function a whole conversation: the server's send path asks this on EVERY
|
|
34
|
+
* message, and a long conversation must not pay for its entire transcript to answer one yes/no
|
|
35
|
+
* question.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isChildSession(parentConversationId: string | undefined, parent: ChildSessionRow | undefined): boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// 子会话的输入框默认上锁 —— 两边共用的两件东西:那句话,和「什么是子会话」这个判据。
|
|
2
|
+
//
|
|
3
|
+
// WHY THIS FILE EXISTS.
|
|
4
|
+
//
|
|
5
|
+
// 一条规矩被写了两遍,就会有两遍的规矩。锁要挡的东西有两半:一半在界面上(画一把看得见的
|
|
6
|
+
// 锁),一半在服务端(拒绝这条用户消息)。这两半必须说同一句话 —— 界面上写着「汇报线只允许
|
|
7
|
+
// 逐级上升」,服务端回一句「禁止发送」,读者看到的是两套规矩,而且不知道该信哪一套。
|
|
8
|
+
//
|
|
9
|
+
// 所以那句话写在这里,两边各自 import,谁都不许自己写一份。
|
|
10
|
+
//
|
|
11
|
+
// 而「什么是子会话」这个判据更不能写两遍:客户端画锁要判断一次,服务端拒绝消息又要判断一次。
|
|
12
|
+
// 两个判断只要有一个偏了,就会出现「界面锁着但服务端放行」或者「界面没锁但服务端拒绝」——
|
|
13
|
+
// 前者让人以为有规矩其实没有,后者让人莫名其妙发不出去。
|
|
14
|
+
//
|
|
15
|
+
// THE ORPHAN, AND WHY 「父会话还活着」 MEANS 「父会话没有归档」.
|
|
16
|
+
//
|
|
17
|
+
// 父会话被归档之后留下的孤儿会话,在树上已经没有了上级,实际上就是一个顶层会话:它没有可
|
|
18
|
+
// 汇报的上级,也就无所谓「越过汇报线」。把它锁住,等于把一个没有对象的规矩套上去。所以判据是
|
|
19
|
+
// 「父会话这一行存在 **而且没有归档**」,而不是「父会话这一行存在」。
|
|
20
|
+
//
|
|
21
|
+
// 这个区别不是咬文嚼字:归档一棵树的时候,父会话和它的子孙是一起归档的;所以一个「父会话
|
|
22
|
+
// 已归档、子会话还活着」的局面,只可能出现在归档没有覆盖到它的地方 —— 而那里恰恰是最需要
|
|
23
|
+
// 读者能说话的地方。
|
|
24
|
+
/**
|
|
25
|
+
* THE SENTENCE. The lock says it, and the server refuses with it.
|
|
26
|
+
*
|
|
27
|
+
* IT SAYS THE RULE, NOT 「禁止」. A refusal that only says "forbidden" leaves the reader with
|
|
28
|
+
* nothing to do; a refusal that names the rule and the way out is something the reader can act
|
|
29
|
+
* on. This is why the sentence is one sentence and why it is shared: the interface and the
|
|
30
|
+
* server must not disagree about what the rule is.
|
|
31
|
+
*/
|
|
32
|
+
export const CHILD_SESSION_LOCK_REASON = "汇报线只允许逐级上升,子会话默认不能直接对话;确有特殊情况可解锁。";
|
|
33
|
+
/**
|
|
34
|
+
* THE QUESTION LOCK SENTENCE.
|
|
35
|
+
*
|
|
36
|
+
* Child sessions must not use the `question` tool to ask the reader directly.
|
|
37
|
+
* When they need a human decision, they must report to their direct supervisor
|
|
38
|
+
* using `session_report`, which escalates through the reporting line.
|
|
39
|
+
*/
|
|
40
|
+
export const CHILD_QUESTION_LOCK_REASON = `${CHILD_SESSION_LOCK_REASON}子会话要用 session_report 向直接上级(父会话)汇报,由父会话逐级转述。`;
|
|
41
|
+
/**
|
|
42
|
+
* Whether a conversation is a CHILD SESSION: it hangs under a parent that is still ALIVE.
|
|
43
|
+
*
|
|
44
|
+
* A conversation with no parent at all is top-level, and so is an ORPHAN - one whose parent was
|
|
45
|
+
* archived and left behind. Both of them can talk to the reader directly, because there is no
|
|
46
|
+
* reporting line above them to bypass.
|
|
47
|
+
*
|
|
48
|
+
* `parentConversationId` is the conversation's own edge, and `parent` is the parent's row (or
|
|
49
|
+
* undefined when there is no such row any more). Both sides answer the question from their own
|
|
50
|
+
* rows - the client from `state.conversations`, the server from its store - and neither of them
|
|
51
|
+
* has to hand this function a whole conversation: the server's send path asks this on EVERY
|
|
52
|
+
* message, and a long conversation must not pay for its entire transcript to answer one yes/no
|
|
53
|
+
* question.
|
|
54
|
+
*/
|
|
55
|
+
export function isChildSession(parentConversationId, parent) {
|
|
56
|
+
if (!parentConversationId)
|
|
57
|
+
return false;
|
|
58
|
+
return Boolean(parent && parent.id === parentConversationId && !parent.archivedAt);
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ContentSearchHit = {
|
|
2
|
+
path: string;
|
|
3
|
+
name: string;
|
|
4
|
+
line: number;
|
|
5
|
+
column: number;
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
export type ContentSearchSummary = {
|
|
9
|
+
complete: boolean;
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
reasons: string[];
|
|
12
|
+
};
|
|
13
|
+
export type ContentSearchEvent = {
|
|
14
|
+
type: "matches";
|
|
15
|
+
hits: ContentSearchHit[];
|
|
16
|
+
} | {
|
|
17
|
+
type: "done";
|
|
18
|
+
summary: ContentSearchSummary;
|
|
19
|
+
} | {
|
|
20
|
+
type: "error";
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Title generation is a short background operation; both ends use the same deadline plus a transport margin. */
|
|
2
|
+
export declare const CONVERSATION_TITLE_TIMEOUT_MS = 90000;
|
|
3
|
+
export declare const CONVERSATION_TITLE_CLIENT_TIMEOUT_MS: number;
|
|
4
|
+
export declare const CONVERSATION_TITLE_CONTEXT_MAX_CHARS = 12000;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Title generation is a short background operation; both ends use the same deadline plus a transport margin. */
|
|
2
|
+
export const CONVERSATION_TITLE_TIMEOUT_MS = 90_000;
|
|
3
|
+
export const CONVERSATION_TITLE_CLIENT_TIMEOUT_MS = CONVERSATION_TITLE_TIMEOUT_MS + 5_000;
|
|
4
|
+
export const CONVERSATION_TITLE_CONTEXT_MAX_CHARS = 12_000;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface PathMentionEntry {
|
|
2
|
+
path: string;
|
|
3
|
+
kind: "file" | "directory";
|
|
4
|
+
}
|
|
5
|
+
export interface MentionToken {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
query: string;
|
|
9
|
+
}
|
|
10
|
+
/** Only a standalone @ token opens completion; email addresses and escaped @ stay literal. */
|
|
11
|
+
export declare function findMentionToken(text: string, caret: number, selectionEnd?: number): MentionToken | undefined;
|
|
12
|
+
export declare function rankPathMatches<T extends PathMentionEntry>(entries: Iterable<T>, query: string): T[];
|
|
13
|
+
export declare function matchPathMentions<T extends PathMentionEntry>(entries: Iterable<T>, query: string, limit?: number): T[];
|
|
14
|
+
export declare function insertPathMention(text: string, token: MentionToken, entry: PathMentionEntry): {
|
|
15
|
+
text: string;
|
|
16
|
+
caret: number;
|
|
17
|
+
};
|