@evandu/super-pi-server 0.0.0-stage → 0.1.260
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 +250 -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 +396 -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 +450 -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,269 @@
|
|
|
1
|
+
import type { BigIntStats } from "node:fs";
|
|
2
|
+
/**
|
|
3
|
+
* Above this a read is refused rather than served. 5MB is roughly a large source file or a long document,
|
|
4
|
+
* and it is deliberately far below the point where an editor tab stops being useful: this panel is for
|
|
5
|
+
* reading and editing code and markdown, and a file too big for that has not become more editable by
|
|
6
|
+
* being loaded whole. The size is checked from `stat` BEFORE the read, so an oversized file costs one
|
|
7
|
+
* `stat` rather than a full buffer.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MAX_FILE_BYTES: number;
|
|
10
|
+
/** Cap on one directory listing, so a `node_modules` or a generated assets folder cannot produce a
|
|
11
|
+
* multi-megabyte response. The count is reported as `truncated` rather than applied silently. */
|
|
12
|
+
export declare const MAX_DIR_ENTRIES = 2000;
|
|
13
|
+
/** Cap on a recursive filename search, for the same reason: a scan of a large repository has to end
|
|
14
|
+
* somewhere. The UI says the list was cut rather than pretending it is complete. */
|
|
15
|
+
export declare const MAX_SEARCH_RESULTS = 500;
|
|
16
|
+
/** How deep the recursive search walks. Twelve levels is past any real source tree; the cap is what
|
|
17
|
+
* turns a pathologically deep dependency tree from a hang into a result. */
|
|
18
|
+
export declare const MAX_SEARCH_DEPTH = 12;
|
|
19
|
+
/** Directories the recursive search skips. The TREE does not skip them - a directory the user cannot
|
|
20
|
+
* browse is a directory they cannot inspect a file in, and the binary handling below is only reachable
|
|
21
|
+
* if `node_modules` is reachable. A recursive filename search, by contrast, returns thousands of matches
|
|
22
|
+
* from these and nothing a person searched for, so they are excluded from the scan and the exclusion is
|
|
23
|
+
* reported in the response rather than being invisible. */
|
|
24
|
+
/** Shared exclusion list for recursive search and the quick-open index. The directory tree intentionally
|
|
25
|
+
* does not use it: users may still browse dependencies on demand. */
|
|
26
|
+
export declare const SEARCH_SKIP_DIRS: Set<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Extensions this panel OPENS without needing a sniff. It is a hint used only to label a file in the tree
|
|
29
|
+
* before it is read, and never as a permission: a `.png` is refused by name even if a sniffing pass would
|
|
30
|
+
* have liked it, and a `.txt` holding PNG bytes is still refused by the sniff.
|
|
31
|
+
*/
|
|
32
|
+
export declare const TEXT_EXTENSIONS: Set<string>;
|
|
33
|
+
/** The HTTP failure, carried as a status so the route can render it without a second switch. `details` is
|
|
34
|
+
* for the cases where the CLIENT can act on more than the sentence - today that is a conflict, where the
|
|
35
|
+
* current etag is what lets the UI offer a deliberate "overwrite anyway" instead of a blind one. */
|
|
36
|
+
export declare class FilesError extends Error {
|
|
37
|
+
readonly status: number;
|
|
38
|
+
readonly code?: string | undefined;
|
|
39
|
+
readonly details?: unknown;
|
|
40
|
+
constructor(status: number, message: string, code?: string | undefined, details?: unknown);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether `candidate` is `root` itself or something under it.
|
|
44
|
+
*
|
|
45
|
+
* THE COMPARISON IS NOT `startsWith(root)`, because that is the traversal bug this whole file exists to
|
|
46
|
+
* avoid: with root `/home/u/proj`, the string `/home/u/proj-secrets` also starts with `/home/u/proj`.
|
|
47
|
+
* `relative()` asks the question in the form that can be answered exactly - it returns a path RELATIVE to
|
|
48
|
+
* the root, so "escaped" becomes "the relative path begins by going up", which is true for
|
|
49
|
+
* `/home/u/proj/../etc` and false for `/home/u/proj/etc`. `isAbsolute(relative)` catches the case
|
|
50
|
+
* `relative` cannot express: two different Windows drives, where there is no relative path between them
|
|
51
|
+
* and it hands back an absolute one.
|
|
52
|
+
*/
|
|
53
|
+
export declare function contains(root: string, candidate: string): boolean;
|
|
54
|
+
/** A guard bound to one workspace root. `resolveInsideRoot` is the one-shot form and is what callers are
|
|
55
|
+
* meant to use; the factory exists for the two places that check many paths against the SAME root in one
|
|
56
|
+
* request, so the canonical form of the root is resolved once instead of once per entry. */
|
|
57
|
+
export declare function createRootGuard(root: string): (requested: string | null | undefined) => Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* THE CONTAINMENT CHECK. Every read, write, listing and search in this file goes through it, and the
|
|
60
|
+
* route layer is not allowed to do its own path arithmetic.
|
|
61
|
+
*
|
|
62
|
+
* `requested` arrives already percent-decoded, because `URLSearchParams` decodes once when the query is
|
|
63
|
+
* parsed. That is the right number of decodes: `%2e%2e%2f` is `../` by the time it gets here and is
|
|
64
|
+
* refused by the lexical test, while decoding a SECOND time would turn the harmless literal `%2e%2e%2f`
|
|
65
|
+
* into a live traversal - inventing an attack the URL parser does not actually have. The route decodes
|
|
66
|
+
* nothing further and never passes the raw query string down.
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveInsideRoot(root: string, requested: string | null | undefined): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* The identity of a file's CURRENT bytes, as far as a filesystem can cheaply say.
|
|
71
|
+
*
|
|
72
|
+
* Built from size and the nanosecond modification time rather than a content hash: hashing every file on
|
|
73
|
+
* every read would make opening a tab cost a full pass over the file, and the two fields together already
|
|
74
|
+
* change on any edit a human would call an edit. `bigint: true` is what makes this exact - the
|
|
75
|
+
* millisecond float `stat` reports by default rounds two edits inside the same millisecond into one
|
|
76
|
+
* value, and an external-change check that misses a change is worse than no check at all, because the
|
|
77
|
+
* user has been told it is safe to save.
|
|
78
|
+
*/
|
|
79
|
+
export declare function fileEtag(path: string): Promise<string>;
|
|
80
|
+
export type FileMeta = {
|
|
81
|
+
etag: string;
|
|
82
|
+
size: number;
|
|
83
|
+
modifiedAt: string;
|
|
84
|
+
};
|
|
85
|
+
export declare function fileMeta(path: string): Promise<FileMeta>;
|
|
86
|
+
export declare function fileMetaFromStat(info: BigIntStats): FileMeta;
|
|
87
|
+
export declare function looksBinary(sample: Uint8Array): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Whether the NAME alone says this is binary.
|
|
90
|
+
*
|
|
91
|
+
* `endsWith` is the whole test, and the dot is what makes it a suffix test rather than a substring one:
|
|
92
|
+
* `"tool.bin".endsWith(".bin")` is true and `"foobin".endsWith(".bin")` is false, because the dot has to be
|
|
93
|
+
* one of the characters being matched. An earlier version added a "the character before the suffix must be
|
|
94
|
+
* a dot" guard on top of this, which was wrong - it compared the index of the dot AGAINST ITSELF minus
|
|
95
|
+
* one, so `"photo.png"` was checked at the `o` and came back false. Every binary file was therefore
|
|
96
|
+
* reaching the byte sniff instead of being refused by name, and the tests only ever passed because the
|
|
97
|
+
* fixture binaries also contained NUL bytes. A check that is dead code while a second check quietly does
|
|
98
|
+
* its job is exactly the kind of thing that survives review, which is why `files-api.test.mjs` asserts
|
|
99
|
+
* the extension path with a fixture whose CONTENT is text.
|
|
100
|
+
*/
|
|
101
|
+
export declare function hasBinaryExtension(name: string): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The extensions of the documents the parsing layer can read.
|
|
104
|
+
*
|
|
105
|
+
* WHY THE LIST LIVES HERE AND NOT IN `documents.ts`. This module has no relative imports, and that is
|
|
106
|
+
* load-bearing: `scripts/files-api.test.mjs` copies this file ALONE into a temp directory and
|
|
107
|
+
* compiles it there, to prove that a broken containment check really does leak. An import of a
|
|
108
|
+
* sibling module would not resolve in that scratch directory, so the mutation would fail to compile
|
|
109
|
+
* - which the test would read as "the guard still refuses the escape", the exact opposite of what it
|
|
110
|
+
* is checking.
|
|
111
|
+
*
|
|
112
|
+
* The parsing layer holds the same list, and the two are checked against each other by
|
|
113
|
+
* `scripts/documents.test.mjs`, so the tree cannot offer a file the parser cannot read.
|
|
114
|
+
*/
|
|
115
|
+
export declare const DOCUMENT_EXTENSIONS: Set<string>;
|
|
116
|
+
/** Whether a file is worth putting in an editor tab at all, decided from its NAME alone, for the tree's
|
|
117
|
+
* own labelling. The authoritative answer comes from `readWorkspaceFile`, which reads bytes. */
|
|
118
|
+
export declare function isTextName(name: string): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Whether a file is a DOCUMENT the parsing layer can read, decided from its name.
|
|
121
|
+
*
|
|
122
|
+
* The same list the knowledge base and the document tools use, so a picker that offers a file and a
|
|
123
|
+
* server that accepts it cannot disagree about which files those are.
|
|
124
|
+
*/
|
|
125
|
+
export declare function isDocumentName(name: string): boolean;
|
|
126
|
+
/** What a caller is told about one entry in a directory. */
|
|
127
|
+
export type DirEntry = {
|
|
128
|
+
/** The path RELATIVE to the workspace root, always `/`-separated, never with a leading slash. This is
|
|
129
|
+
* the form every client sends back, so there is exactly one spelling of "a file" on the wire and no
|
|
130
|
+
* round trip can invent a second one. */
|
|
131
|
+
path: string;
|
|
132
|
+
name: string;
|
|
133
|
+
kind: "directory" | "file" | "symlink";
|
|
134
|
+
/** Whether a file is worth opening, decided from its name. `null` for a directory. */
|
|
135
|
+
text: boolean | null;
|
|
136
|
+
/**
|
|
137
|
+
* Whether this file is a DOCUMENT the parsing layer can read - a PDF, a Word document, a
|
|
138
|
+
* spreadsheet. `null` for a directory.
|
|
139
|
+
*
|
|
140
|
+
* WHY IT IS A SEPARATE FLAG AND NOT PART OF `text`. A document is not text - it cannot be opened in
|
|
141
|
+
* the editor, and opening it as text would show a zip file's bytes - but it IS worth offering to
|
|
142
|
+
* the person, because the knowledge base can import it and the agent can read it. One flag for
|
|
143
|
+
* "worth showing" would force the two cases into one, and a picker that offers a file the server
|
|
144
|
+
* then refuses is worse than one that offers nothing.
|
|
145
|
+
*/
|
|
146
|
+
document?: boolean;
|
|
147
|
+
/** Set when this entry is a link, and `kind` becomes `symlink` when it points OUT of the workspace. The
|
|
148
|
+
* tree can then say "cannot be opened" before the request comes back 403 rather than after. */
|
|
149
|
+
symlink?: boolean;
|
|
150
|
+
/** Set when a link points outside: the containment check's own verdict, surfaced rather than swallowed. */
|
|
151
|
+
outside?: boolean;
|
|
152
|
+
/** A file link can be opened individually from the workbench. */
|
|
153
|
+
openLink?: true;
|
|
154
|
+
};
|
|
155
|
+
export type DirListing = {
|
|
156
|
+
/** The directory that was listed, relative to the root. `""` is the root itself. */
|
|
157
|
+
path: string;
|
|
158
|
+
/** Its parent, or `null` at the root - the tree uses this to decide whether to draw an "up" affordance. */
|
|
159
|
+
parent: string | null;
|
|
160
|
+
entries: DirEntry[];
|
|
161
|
+
truncated: boolean;
|
|
162
|
+
};
|
|
163
|
+
/** The `/`-separated relative form used on the wire and in every comparison. */
|
|
164
|
+
export declare function toRelative(root: string, absolute: string): string;
|
|
165
|
+
/**
|
|
166
|
+
* A PATH A MODEL WROTE, AS THE WORKSPACE SPELLS IT.
|
|
167
|
+
*
|
|
168
|
+
* WHO SPELLS PATHS THIS WAY. Pi's `write`/`edit` tools carry whatever path the MODEL produced, and a
|
|
169
|
+
* model that has been told where the workspace is writes an absolute path: `/home/me/project/src/a.ts`
|
|
170
|
+
* is the same file as `src/a.ts`. The model is not trying to escape anything - it is repeating the
|
|
171
|
+
* workspace root it was given.
|
|
172
|
+
*
|
|
173
|
+
* WHY THIS IS HERE AND NOT IN THE CALLER. Two layers need the same translation and neither may own
|
|
174
|
+
* it: the file-change tracker (which records what the agent wrote) and the file index (which refreshes
|
|
175
|
+
* what the agent wrote). Before this function existed, the index refused an absolute path outright -
|
|
176
|
+
* and because the refusal was thrown out of a promise nobody was awaiting, one absolute-path write
|
|
177
|
+
* produced one `[fatal] unhandledRejection` in the server log and left the Files panel showing a file
|
|
178
|
+
* the agent had just written as if it had never been touched.
|
|
179
|
+
*
|
|
180
|
+
* AN ABSOLUTE PATH OUTSIDE THE WORKSPACE IS REFUSED, EXACTLY AS `../` IS REFUSED. The containment rule
|
|
181
|
+
* belongs to this module and has exactly one owner; this function does not get a second, weaker copy of
|
|
182
|
+
* it. It translates a spelling and then hands the result to the guard, which is what actually decides
|
|
183
|
+
* containment - including the symlink case, which a string comparison can never see.
|
|
184
|
+
*/
|
|
185
|
+
export declare function toWorkspaceRelative(root: string, requested: string): string;
|
|
186
|
+
/** One directory's contents. Directories sort before files, then case-insensitively by name with numeric
|
|
187
|
+
* ordering, so `src2` lands between `src` and `src10` rather than after every `srcN`. */
|
|
188
|
+
export declare function listDirectory(root: string, requested: string | null | undefined): Promise<DirListing>;
|
|
189
|
+
export type SearchHit = {
|
|
190
|
+
path: string;
|
|
191
|
+
name: string;
|
|
192
|
+
directory: string;
|
|
193
|
+
};
|
|
194
|
+
export type SearchResult = {
|
|
195
|
+
hits: SearchHit[];
|
|
196
|
+
truncated: boolean;
|
|
197
|
+
skipped: string[];
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* A recursive FILENAME search. Filename only, on purpose: content search is a different feature with
|
|
201
|
+
* different costs - it reads every candidate file, honours the size cap on each one, and it is the thing
|
|
202
|
+
* that turns a panel into a hang - and the requirement is explicit that this round does not need it.
|
|
203
|
+
*
|
|
204
|
+
* Every directory it descends into goes through the SAME guard as every other path here, so the search
|
|
205
|
+
* cannot be walked out of the workspace by a link, and it stops at `MAX_SEARCH_DEPTH` and
|
|
206
|
+
* `MAX_SEARCH_RESULTS` so a repository with a vendored dependency tree returns a truncated answer rather
|
|
207
|
+
* than never returning.
|
|
208
|
+
*/
|
|
209
|
+
export declare function searchByName(root: string, query: string): Promise<SearchResult>;
|
|
210
|
+
export type FileContents = {
|
|
211
|
+
path: string;
|
|
212
|
+
content: string;
|
|
213
|
+
meta: FileMeta;
|
|
214
|
+
/** Newline convention read off the bytes, so a CRLF file is saved back as CRLF instead of silently
|
|
215
|
+
* rewritten to LF - which on Windows is a whole-file diff the user did not ask for. */
|
|
216
|
+
eol: "\n" | "\r\n";
|
|
217
|
+
bom: boolean;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Read one file, or refuse it with a reason a person can act on.
|
|
221
|
+
*
|
|
222
|
+
* ORDER MATTERS and is the whole reason the refusals are trustworthy: extension, then SIZE from `stat`,
|
|
223
|
+
* then a sniff, then a fatal decode. The size check precedes the read so an oversized file costs a `stat`
|
|
224
|
+
* rather than a buffer, and the sniff precedes the decode so binary bytes are never handed to
|
|
225
|
+
* `TextDecoder` as if they were text - a decode that "succeeds" on binary produces U+FFFD throughout,
|
|
226
|
+
* which is mojibake, and mojibake that then gets SAVED is how a text editor destroys a binary file.
|
|
227
|
+
*/
|
|
228
|
+
export declare function readWorkspaceFile(root: string, requested: string): Promise<FileContents>;
|
|
229
|
+
export declare function decodeWorkspaceText(raw: Uint8Array, requested: string): Pick<FileContents, "content" | "bom" | "eol">;
|
|
230
|
+
export type WriteOutcome = {
|
|
231
|
+
path: string;
|
|
232
|
+
meta: FileMeta;
|
|
233
|
+
created: false;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* Write one EXISTING text file. No creation, no deletion, no rename, no directories.
|
|
237
|
+
*
|
|
238
|
+
* THE SCOPE CALL, with its reasoning, because it is a decision and not an omission:
|
|
239
|
+
*
|
|
240
|
+
* This panel's stated job is to BROWSE and EDIT what is in the workspace. Creation is refused even though
|
|
241
|
+
* the brief leaves it open, because creation is the operation where a mistake has no undo: a bad `path`
|
|
242
|
+
* parameter or a bug that loses one character writes a file the user never asked for and never has to
|
|
243
|
+
* clean up, whereas a refused write leaves nothing behind. Deletion is deferred by the brief and is
|
|
244
|
+
* deferred here for the same reason plus the one that matters more - it is irreversible.
|
|
245
|
+
*
|
|
246
|
+
* The symmetry is deliberate: create and delete are the two ends of the same axis, and shipping one
|
|
247
|
+
* without the other is how a "conservative, no surprises" surface becomes a half-built file manager.
|
|
248
|
+
*
|
|
249
|
+
* What IS refused regardless: a write to a file that does not exist (428), a write with no `baseEtag` at
|
|
250
|
+
* all (428 - without one the server cannot tell a save from a blind overwrite, and "may I overwrite" is
|
|
251
|
+
* not a question this endpoint is allowed to skip), a write whose `baseEtag` no longer matches the file
|
|
252
|
+
* on disk (409 `stale`), and a write that would push the file past the size cap.
|
|
253
|
+
*
|
|
254
|
+
* The write itself is a whole-file replace through a temporary file in the SAME directory and a rename,
|
|
255
|
+
* so an interrupted save cannot leave a half-written file where a whole one used to be. The temporary name
|
|
256
|
+
* is derived from the target's OWN name rather than living in the system temp directory, because a rename
|
|
257
|
+
* across filesystems is not atomic and would silently become a copy.
|
|
258
|
+
*/
|
|
259
|
+
export declare function writeWorkspaceFile(root: string, requested: string, content: string, baseEtag: string | null | undefined): Promise<WriteOutcome>;
|
|
260
|
+
/** Every `FilesError` carries the status it should be rendered with; anything else is a real fault and
|
|
261
|
+
* becomes a 500 rather than being dressed up as a refusal the user is asked to understand. */
|
|
262
|
+
export declare function describe(error: unknown): {
|
|
263
|
+
status: number;
|
|
264
|
+
body: {
|
|
265
|
+
error: string;
|
|
266
|
+
code?: string;
|
|
267
|
+
[key: string]: unknown;
|
|
268
|
+
};
|
|
269
|
+
};
|