@tea-agent/loop-agent 0.52.0-next.1 → 0.52.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -21
- package/dist/build-stamp.json +3 -3
- package/dist/cli/command-definitions.js +1 -75
- package/dist/cli/help.js +1 -1
- package/dist/cli/program.js +1 -28
- package/dist/commands/init-accepted-merge.js +46 -0
- package/dist/commands/init-upgrade.js +114 -2
- package/dist/commands/init.js +79 -12
- package/dist/shared/operator/capabilities.js +0 -122
- package/dist/shared/update/npm-client.js +14 -3
- package/dist/task/config-types.js +5 -10
- package/dist/task/read-model.js +0 -4
- package/dist/task/runtime.js +0 -1
- package/dist/worker/console/chat/api-workbench-core.js +17 -6
- package/dist/worker/console/chat/api-workbench.js +2 -0
- package/dist/worker/console/chat/chat-event-projection.js +2 -0
- package/dist/worker/console/chat/chat-event-store.js +32 -2
- package/dist/worker/console/chat/chat-references.js +4 -0
- package/dist/worker/console/chat/pi-runtime/custom-tools/apiworkbench-tools.js +65 -3
- package/dist/worker/console/chat/pi-runtime/sdk-bindings.js +4 -0
- package/dist/worker/console/chat/pi-runtime.js +274 -94
- package/dist/worker/console/chat/repo-browser.js +5 -2
- package/dist/worker/console/chat/repo-preview-kind.js +16 -6
- package/dist/worker/console/chat/routes.js +295 -25
- package/dist/worker/console/chat/subagents/jobs.js +115 -4
- package/dist/worker/console/chat/terminal-sessions.js +36 -2
- package/dist/worker/console/chat/tool-exposure-catalog.js +1 -1
- package/dist/worker/console/chat/tool-preview.js +22 -0
- package/dist/worker/console/chat/turn-process.js +52 -0
- package/dist/worker/console/chat/vcp-prompt.js +14 -9
- package/dist/worker/console/chat/workspace-changes.js +137 -0
- package/dist/worker/console/console-update-runtime.js +5 -1
- package/dist/worker/console/operator-actions.js +7 -6
- package/dist/worker/console/operator-user-error.js +5 -1
- package/dist/worker/console/routes.js +1 -1
- package/dist/worker/console/server.js +89 -5
- package/dist/worker/console/static/assets/FilePreviewDocx-ybM3ZqSl.js +9 -0
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-CM5ocMUs.js +1 -0
- package/dist/worker/console/static/assets/{arc-Bkf_oc0_.js → arc-CDapwdTN.js} +1 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-Ogy4GOqS.js +36 -0
- package/dist/worker/console/static/assets/{blockDiagram-VBNYF7ZC-D62uVvbI.js → blockDiagram-VBNYF7ZC-DsiaOIgU.js} +1 -1
- package/dist/worker/console/static/assets/{c4Diagram-5PPSVZJV-Iq0Y8Afx.js → c4Diagram-5PPSVZJV-B84hhgSe.js} +1 -1
- package/dist/worker/console/static/assets/channel-BCVzSVXD.js +1 -0
- package/dist/worker/console/static/assets/{chunk-2GRJ4B5K-D1TxRE3k.js → chunk-2GRJ4B5K-SPqOhMla.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-2Q5K7J3B-BE-DHkAO.js → chunk-2Q5K7J3B-BL0Q4ZV3.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5RXB4S5H-t0iYO8Cc.js → chunk-5RXB4S5H-CJpOcFAh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-5VM5RSS4-Clo2nExi.js → chunk-5VM5RSS4-DQC6vqVW.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-6Q2QTUOP-C7bSpo-3.js → chunk-6Q2QTUOP-D4dq_L0l.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-GF5L2VYU-DorZaymh.js → chunk-GF5L2VYU-DVNZmiVo.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-JWPE2WC7-Ch_4HvyJ.js → chunk-JWPE2WC7-B1yOfAhr.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-KBJHAD2P-yaSoFe-3.js → chunk-KBJHAD2P-BEPc1N6N.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-RYQCIY6F-QpjaXecS.js → chunk-RYQCIY6F-Da_-gMwh.js} +1 -1
- package/dist/worker/console/static/assets/{chunk-XXDRQBXY-B3t6cycg.js → chunk-XXDRQBXY-C75eW9DT.js} +1 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-BRlRsJR0.js +1 -0
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-BRlRsJR0.js +1 -0
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-C4Gn7eYB.js +1 -0
- package/dist/worker/console/static/assets/{cynefin-VYW2F7L2-CP8LtrOl.js → cynefin-VYW2F7L2-BIFL8KrA.js} +1 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55--CBwVt18.js +62 -0
- package/dist/worker/console/static/assets/{dagre-VZM6K2ZE-BK0ua9V8.js → dagre-VZM6K2ZE-B8dBxboB.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-7IWD3JNH-t9-HP13j.js → diagram-7IWD3JNH-hKtlE0w-.js} +1 -1
- package/dist/worker/console/static/assets/{diagram-B4RE2ZJO-L5Sg9jMD.js → diagram-B4RE2ZJO-BKirx0F3.js} +1 -1
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-bkx-oUrD.js +24 -0
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-D7sFtSjr.js +24 -0
- package/dist/worker/console/static/assets/diagram-UB23O5K3-BPjzGBV_.js +41 -0
- package/dist/worker/console/static/assets/docx-preview-CAbT0VNs.js +23 -0
- package/dist/worker/console/static/assets/docxPreview-D_T4B7qe.js +1 -0
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-DODv-GbM.js +1 -0
- package/dist/worker/console/static/assets/{erDiagram-JOGREHBK-CNOuj3BO.js → erDiagram-JOGREHBK-DbfVp5uI.js} +1 -1
- package/dist/worker/console/static/assets/{flowDiagram-UKHOOZJN-h_Cyayai.js → flowDiagram-UKHOOZJN-BHWWThbx.js} +1 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-SWY_8oU3.js +292 -0
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-CJdhHY-i.js +106 -0
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-CLC4mTWX.js +2 -0
- package/dist/worker/console/static/assets/{ishikawaDiagram-WSZJBQD7-DAdf5lHp.js → ishikawaDiagram-WSZJBQD7-CiJDWOmX.js} +1 -1
- package/dist/worker/console/static/assets/{journeyDiagram-NVQOT4AX-BQbGtg66.js → journeyDiagram-NVQOT4AX-eIQfMD0f.js} +1 -1
- package/dist/worker/console/static/assets/{kanban-definition-27J2QSJJ-CetLubYc.js → kanban-definition-27J2QSJJ-3d6r1cG7.js} +1 -1
- package/dist/worker/console/static/assets/{linear-DLZOjaVz.js → linear-BjbmxxDk.js} +1 -1
- package/dist/worker/console/static/assets/main-B9ZnQejR.css +1 -0
- package/dist/worker/console/static/assets/main-D4knTr0R.js +644 -0
- package/dist/worker/console/static/assets/{mermaid.core-B_xZl_gM.js → mermaid.core-CD2GFYrr.js} +5 -5
- package/dist/worker/console/static/assets/{mindmap-definition-FAOFIHXS-Dzo3dzp0.js → mindmap-definition-FAOFIHXS-D0ORXhx-.js} +1 -1
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-BqNbcp7_.js +1 -0
- package/dist/worker/console/static/assets/{pieDiagram-7S7Q4E2Y-Cp3YrVzQ.js → pieDiagram-7S7Q4E2Y-CGO0Y13N.js} +1 -1
- package/dist/worker/console/static/assets/{quadrantDiagram-CIZ2JOQS-4tI5mUgW.js → quadrantDiagram-CIZ2JOQS-vH4fdvTV.js} +1 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-B_sbmiFS.js +1 -0
- package/dist/worker/console/static/assets/{requirementDiagram-LRYGKXZP-DY-0JqdT.js → requirementDiagram-LRYGKXZP-DbHtPigL.js} +1 -1
- package/dist/worker/console/static/assets/{sankeyDiagram-W5VNT64P-DuJIzRKC.js → sankeyDiagram-W5VNT64P-BcqNS0Ko.js} +1 -1
- package/dist/worker/console/static/assets/{sequenceDiagram-SI44F4Z6-BTbVJ85l.js → sequenceDiagram-SI44F4Z6-5Zf3xJfg.js} +1 -1
- package/dist/worker/console/static/assets/{sheet-workbook-BPPh1uLw.js → sheet-workbook-Bvq6WFll.js} +2 -2
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-BoO7GXeG.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-3suojNXT.js +1 -0
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-Bq6cg1c9.js +1 -0
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-B5CyFSLq.js +2 -0
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-VvJzDuB_.js +8 -0
- package/dist/worker/console/static/assets/{timeline-definition-Z64GVDOM-GR6lxokn.js → timeline-definition-Z64GVDOM-BuZ_HcXz.js} +1 -1
- package/dist/worker/console/static/assets/{vennDiagram-T6HMQDX7-DEkwyzsF.js → vennDiagram-T6HMQDX7-CJ_IDS7Q.js} +1 -1
- package/dist/worker/console/static/assets/{wardleyDiagram-T6FBY63Y-W5jnvEJ3.js → wardleyDiagram-T6FBY63Y-BpKLb-Su.js} +1 -1
- package/dist/worker/console/static/assets/{xychartDiagram-ELKLHX3M-cqsloioo.js → xychartDiagram-ELKLHX3M-Mdo6gaIk.js} +1 -1
- package/dist/worker/console/static/docx-preview.html +25 -0
- package/dist/worker/console/static/index.html +3 -2
- package/dist/worker/console/static/vcp/fonts/README.md +28 -0
- package/dist/worker/console/static/vcp/vendor/vcp-engine-v1.js +4 -4
- package/dist/worker/console/static-src/operator-chat/StateDot.js +17 -0
- package/dist/worker/console/static-src/operator-chat/chat-font-size.js +90 -0
- package/dist/worker/console/static-src/operator-chat/chat-session-order.js +96 -0
- package/dist/worker/console/static-src/operator-chat/chat-sse-events.js +8 -1
- package/dist/worker/console/static-src/operator-chat/details-rail-surfaces.js +2 -0
- package/dist/worker/console/static-src/operator-chat/file-touch.js +107 -0
- package/dist/worker/console/static-src/operator-chat/open-preview-in-browser.js +44 -0
- package/dist/worker/console/static-src/operator-chat/reference-display.js +7 -1
- package/dist/worker/console/static-src/operator-chat/tasks-auto-open.js +100 -0
- package/dist/worker/console/static-src/operator-chat/tasks-layout-tween.js +103 -0
- package/dist/worker/console/static-src/operator-chat/tasks-model.js +657 -0
- package/dist/worker/console/static-src/operator-chat/tasks-view-glide.js +96 -0
- package/dist/worker/console/static-src/operator-chat/turn-group-equality.js +1 -0
- package/dist/worker/console/static-src/operator-chat/use-auto-animate.js +61 -0
- package/dist/worker/console/static-src/operator-chat/useChatSessions.js +194 -47
- package/dist/worker/console/static-src/operator-chat/useChatStream.js +4 -0
- package/dist/worker/console/static-src/operator-chat/useChatThread.js +18 -0
- package/dist/worker/console/static-src/operator-chat/useRepoBrowser.js +111 -21
- package/dist/worker/console/static-src/operator-chat/useRuntimeControls.js +91 -47
- package/dist/worker/console/static-src/operator-chat/useVcpPreferences.js +1 -1
- package/dist/worker/console/static-src/operator-chat/vcp-fonts.js +180 -22
- package/dist/worker/console/static-src/operator-chat/vcp-frame.js +3 -3
- package/dist/worker/console/static-src/shell/console-update-progress.js +16 -0
- package/dist/worker/console/static-src/shell/console-update-reload.js +4 -1
- package/dist/worker/console/static-src/shell/workspace-route.js +0 -2
- package/dist/worker/console/vite.config.js +5 -1
- package/dist/worker/console/workspace-registry.js +62 -19
- package/dist/worker/observe/static/operator-chrome.js +0 -1
- package/dist/workflows/dag/backend-test-scenario-param.js +60 -4
- package/dist/workflows/dag/dynamic-runtime/reduction.js +7 -2
- package/dist/workflows/dag/frontend-test-framework-adapters.js +11 -2
- package/dist/workflows/script/windows/guest.js +13 -2
- package/dist/workflows/script/windows/native.js +21 -3
- package/docs/architecture/dag-execution.md +2 -13
- package/docs/architecture/facts-and-state.md +2 -3
- package/docs/architecture/runtime-boundaries.md +2 -2
- package/package.json +5 -3
- package/resource-catalog.v1.json +6 -6
- package/skills/loop-agent/references/command-reference.md +2 -41
- package/skills/loop-agent/references/harness-policy.md +3 -30
- package/skills/loop-agent/references/long-running-loop.md +6 -54
- package/dist/application/loop/run-action.js +0 -19
- package/dist/commands/dag-workflow-compile.js +0 -93
- package/dist/commands/dag-workflow-plan.js +0 -132
- package/dist/commands/dag-workflow-validate.js +0 -68
- package/dist/commands/loop-benchmark.js +0 -74
- package/dist/commands/loop.js +0 -251
- package/dist/commands/workflow.js +0 -259
- package/dist/infrastructure/harness/loop-store.js +0 -41
- package/dist/worker/console/static/assets/abnfDiagram-N423BO3Z-FQePHM07.js +0 -1
- package/dist/worker/console/static/assets/architectureDiagram-T3A2C74G-p_mwm8cd.js +0 -36
- package/dist/worker/console/static/assets/channel-CIBAg8WF.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-JCYQIIEL-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/classDiagram-v2-OCEON4UE-B4xQrSmv.js +0 -1
- package/dist/worker/console/static/assets/cose-bilkent-JH36ORCC-BPXf8ZYr.js +0 -1
- package/dist/worker/console/static/assets/cynefinDiagram-MW4NZA55-CNsL9N2-.js +0 -62
- package/dist/worker/console/static/assets/diagram-LBJQPF4R-BipWFRgs.js +0 -24
- package/dist/worker/console/static/assets/diagram-Q27KOJAE-T2p4xa38.js +0 -24
- package/dist/worker/console/static/assets/diagram-UB23O5K3-CVwz6LVu.js +0 -41
- package/dist/worker/console/static/assets/ebnfDiagram-BXEA7PRR-CybQrGSA.js +0 -1
- package/dist/worker/console/static/assets/ganttDiagram-PKOTCBZU-D411_55h.js +0 -292
- package/dist/worker/console/static/assets/gitGraphDiagram-DS77QQ5N-DpVtzs9z.js +0 -106
- package/dist/worker/console/static/assets/index-B7cwOTL9.js +0 -649
- package/dist/worker/console/static/assets/index-CATbSkPc.css +0 -1
- package/dist/worker/console/static/assets/infoDiagram-6WML65LV-D74Uvx6K.js +0 -2
- package/dist/worker/console/static/assets/pegDiagram-VL7TDLO6-CSwoBOpM.js +0 -1
- package/dist/worker/console/static/assets/railroadDiagram-AXF67PYL-n0Mt3Yia.js +0 -1
- package/dist/worker/console/static/assets/sizeCapture-X5ZJPWSS-Dmf1pC7B.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-OKZ733FA-4-jdPUHD.js +0 -1
- package/dist/worker/console/static/assets/stateDiagram-v2-UEYNNEHI-DojWfYnC.js +0 -1
- package/dist/worker/console/static/assets/swimlanes-SLNWSIFB-DNhjjaAU.js +0 -2
- package/dist/worker/console/static/assets/swimlanesDiagram-ULZ7WXOC-CJo4AKWH.js +0 -8
- package/dist/worker/console/static/vcp/fonts/Lanxi-/345/217/257/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/346/234/227/345/256/213.woff2 +0 -0
- package/dist/worker/console/static/vcp/fonts/Lanxi-/350/266/205/347/262/227/351/273/221.woff2 +0 -0
- package/dist/workflows/dynamic/compile.js +0 -371
- package/dist/workflows/dynamic/compileTypes.js +0 -1
- package/dist/workflows/dynamic/errors.js +0 -5
- package/dist/workflows/dynamic/profiles.js +0 -156
- package/dist/workflows/dynamic/spec.js +0 -115
- package/dist/workflows/dynamic/validate.js +0 -275
- package/dist/workflows/loop/actions/dag-action.js +0 -129
- package/dist/workflows/loop/actions/pi-review.js +0 -267
- package/dist/workflows/loop/actions/shared.js +0 -157
- package/dist/workflows/loop/actions/shell-verify.js +0 -82
- package/dist/workflows/loop/actions/types.js +0 -1
- package/dist/workflows/loop/actions/workflow-action.js +0 -255
- package/dist/workflows/loop/actions.js +0 -160
- package/dist/workflows/loop/benchmark.js +0 -513
- package/dist/workflows/loop/closeout.js +0 -135
- package/dist/workflows/loop/context.js +0 -47
- package/dist/workflows/loop/events.js +0 -26
- package/dist/workflows/loop/hash.js +0 -32
- package/dist/workflows/loop/index.js +0 -8
- package/dist/workflows/loop/paths.js +0 -17
- package/dist/workflows/loop/policy/auto-policy.js +0 -112
- package/dist/workflows/loop/policy/path-patterns.js +0 -13
- package/dist/workflows/loop/rounds.js +0 -81
- package/dist/workflows/loop/signals.js +0 -52
- package/dist/workflows/loop/state.js +0 -116
- package/dist/workflows/loop/templates.js +0 -54
- package/dist/workflows/loop/types.js +0 -28
- /package/dist/workflows/{dynamic/artifacts.js → dag/dynamic-runtime/reduction-artifacts.js} +0 -0
|
@@ -187,6 +187,13 @@ export function OPERATOR_CHAT_ACTIVE_TOOL_NAMES() {
|
|
|
187
187
|
export function computeOperatorChatActiveToolNames(session, sessionMode = DEFAULT_CONSOLE_CHAT_SESSION_MODE) {
|
|
188
188
|
return computeChatActiveToolNames(session, sessionMode);
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Last-resort window when neither the provider nor `models.json` declares one.
|
|
192
|
+
* Matches the default the Console model editor writes for a new model, so a
|
|
193
|
+
* gateway that reports nothing still gets proactive compaction instead of
|
|
194
|
+
* running until it rejects the request.
|
|
195
|
+
*/
|
|
196
|
+
const DEFAULT_CONTEXT_WINDOW = 128_000;
|
|
190
197
|
const OPERATOR_CHAT_SESSION_EXCLUDE_TOOLS = Object.freeze([
|
|
191
198
|
"apply_patch",
|
|
192
199
|
"apply-patch",
|
|
@@ -325,6 +332,15 @@ export function createWizardLocalHeadersExtension(options) {
|
|
|
325
332
|
}
|
|
326
333
|
export { THINKING_LEVELS, RuntimeSnapshotUnavailableError, projectRuntimeSnapshot, };
|
|
327
334
|
export { createDefaultPiSdkBindings } from "./pi-runtime/sdk-bindings.js";
|
|
335
|
+
/**
|
|
336
|
+
* Give queued macrotasks (an in-flight HTTP 201, an SSE write, a pending
|
|
337
|
+
* `/sessions` read) a turn on the loop before the next synchronous stretch of
|
|
338
|
+
* session preparation starts. Microtasks alone are not enough: they drain
|
|
339
|
+
* inside the same tick that the materialization chain continues in.
|
|
340
|
+
*/
|
|
341
|
+
function yieldEventLoop() {
|
|
342
|
+
return new Promise((resolve) => setImmediate(resolve));
|
|
343
|
+
}
|
|
328
344
|
/** Catalog listing must not load skills/extensions/context — those belong to reopen. */
|
|
329
345
|
const CATALOG_RESOURCE_LOADER_OPTIONS = Object.freeze({
|
|
330
346
|
noContextFiles: true,
|
|
@@ -796,6 +812,7 @@ export class ConsolePiRuntime {
|
|
|
796
812
|
async refreshSkillPrefsCache() {
|
|
797
813
|
const prefs = await this.loadSkillAutoInvocationPreferences();
|
|
798
814
|
this.cachedSkillPrefs = prefs;
|
|
815
|
+
this.invalidateWorkspaceInspection();
|
|
799
816
|
return prefs;
|
|
800
817
|
}
|
|
801
818
|
getCompactionController(sessionId) {
|
|
@@ -864,6 +881,31 @@ export class ConsolePiRuntime {
|
|
|
864
881
|
});
|
|
865
882
|
void sessionId;
|
|
866
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Pick the context window to gate proactive compaction on.
|
|
886
|
+
*
|
|
887
|
+
* `getSessionStats().contextUsage.contextWindow` is what the provider
|
|
888
|
+
* reported for the live request, and a private/self-hosted gateway
|
|
889
|
+
* routinely reports `0`, `-1` or nothing at all — it has no obligation to
|
|
890
|
+
* tell us its limit. Gating only on that value silently disabled
|
|
891
|
+
* proactive compaction on such gateways: every session ran until the
|
|
892
|
+
* provider rejected the request, then fell back to the local checkpoint.
|
|
893
|
+
*
|
|
894
|
+
* The model definition in `models.json` (`session.model.contextWindow`)
|
|
895
|
+
* is the configured window and is authoritative when present. The
|
|
896
|
+
* reported value wins only when it is a usable positive number, because
|
|
897
|
+
* a gateway may enforce a tighter limit than the declared window.
|
|
898
|
+
*/
|
|
899
|
+
resolveContextWindow(session, reportedWindow) {
|
|
900
|
+
if (typeof reportedWindow === "number" && reportedWindow > 0) {
|
|
901
|
+
return reportedWindow;
|
|
902
|
+
}
|
|
903
|
+
const configured = session.model?.contextWindow;
|
|
904
|
+
if (typeof configured === "number" && configured > 0) {
|
|
905
|
+
return configured;
|
|
906
|
+
}
|
|
907
|
+
return DEFAULT_CONTEXT_WINDOW;
|
|
908
|
+
}
|
|
867
909
|
async runPrePromptCompaction(sessionId, session, promptText, imageCount, onEvent, signal) {
|
|
868
910
|
const policy = parseCompactionPolicy();
|
|
869
911
|
if (signal?.aborted)
|
|
@@ -872,8 +914,9 @@ export class ConsolePiRuntime {
|
|
|
872
914
|
return;
|
|
873
915
|
const controller = this.getCompactionController(sessionId);
|
|
874
916
|
const stats = session.getSessionStats?.();
|
|
875
|
-
const
|
|
917
|
+
const reportedWindow = stats?.contextUsage?.contextWindow;
|
|
876
918
|
const tokens = stats?.contextUsage?.tokens;
|
|
919
|
+
const window = this.resolveContextWindow(session, reportedWindow);
|
|
877
920
|
if (typeof window === "number" && window > 0) {
|
|
878
921
|
this.applySessionRecoveryOverrides(sessionId, this.serviceScopes.get(sessionId) ?? {}, session);
|
|
879
922
|
}
|
|
@@ -886,10 +929,8 @@ export class ConsolePiRuntime {
|
|
|
886
929
|
incrementPressureCounter(controller.counters, "usage-unavailable");
|
|
887
930
|
return;
|
|
888
931
|
}
|
|
889
|
-
const effective =
|
|
890
|
-
|
|
891
|
-
: undefined;
|
|
892
|
-
if (!effective || projection.projected < effective.triggerTokens) {
|
|
932
|
+
const effective = deriveEffectiveWindow(window, policy);
|
|
933
|
+
if (projection.projected < effective.triggerTokens) {
|
|
893
934
|
controller.pruneArmed = false;
|
|
894
935
|
return;
|
|
895
936
|
}
|
|
@@ -1136,6 +1177,10 @@ export class ConsolePiRuntime {
|
|
|
1136
1177
|
if (existing?.status === "failed")
|
|
1137
1178
|
return Promise.reject(existing.error);
|
|
1138
1179
|
const promise = Promise.resolve(init.initializationBarrier)
|
|
1180
|
+
// The durable 201 response is still being written when this detached
|
|
1181
|
+
// chain starts. Yield one macrotask so it flushes before the first
|
|
1182
|
+
// synchronous preparation stretch takes the loop.
|
|
1183
|
+
.then(() => yieldEventLoop())
|
|
1139
1184
|
.then(() => this.materializeSession(sessionId, init))
|
|
1140
1185
|
.then(() => {
|
|
1141
1186
|
if (this.disposedSessions.has(sessionId)) {
|
|
@@ -1184,19 +1229,21 @@ export class ConsolePiRuntime {
|
|
|
1184
1229
|
abandon();
|
|
1185
1230
|
return undefined;
|
|
1186
1231
|
}
|
|
1187
|
-
// Capture before services parse models.json. A concurrent edit can therefore
|
|
1188
|
-
// cause at most one harmless extra refresh, never a missed next-turn refresh.
|
|
1189
|
-
const modelConfigFile = await captureModelConfigFile(agentDir);
|
|
1190
|
-
if (aborted()) {
|
|
1191
|
-
abandon();
|
|
1192
|
-
return undefined;
|
|
1193
|
-
}
|
|
1194
1232
|
const appendSystemPrompt = composeChatSystemPromptParts({
|
|
1195
1233
|
sessionMode: init.sessionMode,
|
|
1196
1234
|
workflowPrompt: OPERATOR_CHAT_SYSTEM_PROMPT_BASE,
|
|
1197
1235
|
systemPromptSuffix: init.systemPromptSuffix,
|
|
1198
1236
|
});
|
|
1199
|
-
|
|
1237
|
+
// One parallel pass: models.json change capture and the skill
|
|
1238
|
+
// auto-invocation preferences are independent, so a new session never
|
|
1239
|
+
// pays their disk reads one after another.
|
|
1240
|
+
const [modelConfigFile] = await Promise.all([
|
|
1241
|
+
// Capture before services parse models.json. A concurrent edit can
|
|
1242
|
+
// therefore cause at most one harmless extra refresh, never a missed
|
|
1243
|
+
// next-turn refresh.
|
|
1244
|
+
captureModelConfigFile(agentDir),
|
|
1245
|
+
this.refreshSkillPrefsCache().catch(() => undefined),
|
|
1246
|
+
]);
|
|
1200
1247
|
if (aborted()) {
|
|
1201
1248
|
abandon();
|
|
1202
1249
|
return undefined;
|
|
@@ -1212,6 +1259,10 @@ export class ConsolePiRuntime {
|
|
|
1212
1259
|
agentDir,
|
|
1213
1260
|
resourceLoaderOptions,
|
|
1214
1261
|
});
|
|
1262
|
+
// ResourceLoader construction is the heaviest synchronous stretch of
|
|
1263
|
+
// preparation (skills/AGENTS.md/packages scan). Let queued HTTP/SSE work
|
|
1264
|
+
// run before tool assembly starts.
|
|
1265
|
+
await yieldEventLoop();
|
|
1215
1266
|
if (init.sessionMode !== "pi") {
|
|
1216
1267
|
const expected = this.workflowIntakeCapabilities.get(init.sessionId);
|
|
1217
1268
|
const loader = services.resourceLoader;
|
|
@@ -1248,6 +1299,10 @@ export class ConsolePiRuntime {
|
|
|
1248
1299
|
}) ?? undefined)
|
|
1249
1300
|
: undefined;
|
|
1250
1301
|
assertNoWriteToolInList(OPERATOR_CHAT_ALLOWED_TOOLS);
|
|
1302
|
+
// Tool assembly builds every custom tool factory synchronously; yield
|
|
1303
|
+
// first so an already-queued create response or list read is not delayed
|
|
1304
|
+
// by the whole assembly.
|
|
1305
|
+
await yieldEventLoop();
|
|
1251
1306
|
const customTools = await this.loadCustomTools(init.sessionId);
|
|
1252
1307
|
if (aborted()) {
|
|
1253
1308
|
abandon();
|
|
@@ -1275,8 +1330,16 @@ export class ConsolePiRuntime {
|
|
|
1275
1330
|
await disposeSessionExtensions(session).catch(() => undefined);
|
|
1276
1331
|
return undefined;
|
|
1277
1332
|
}
|
|
1333
|
+
// Session creation registers the full tool catalog synchronously; the
|
|
1334
|
+
// extension handshake below is the next long await, so give the loop one
|
|
1335
|
+
// turn in between.
|
|
1336
|
+
await yieldEventLoop();
|
|
1278
1337
|
try {
|
|
1279
1338
|
await bindSessionExtensions(session);
|
|
1339
|
+
// Seven console extensions emit `session_start` here. Yield after the
|
|
1340
|
+
// handshake so their synchronous registrations do not stack onto the
|
|
1341
|
+
// readiness write that follows.
|
|
1342
|
+
await yieldEventLoop();
|
|
1280
1343
|
assertConsoleResourcePolicy(session, services.resourceLoader);
|
|
1281
1344
|
if (aborted()) {
|
|
1282
1345
|
abandon();
|
|
@@ -1893,7 +1956,28 @@ export class ConsolePiRuntime {
|
|
|
1893
1956
|
* conversation JSONL so the picker is not blocked on cold reopen.
|
|
1894
1957
|
*/
|
|
1895
1958
|
workspaceModelRuntime;
|
|
1896
|
-
|
|
1959
|
+
static WORKSPACE_INSPECTION_TTL_MS = 45_000;
|
|
1960
|
+
workspaceInspectionServices;
|
|
1961
|
+
workspaceInspectionCachedAt = 0;
|
|
1962
|
+
workspaceInspectionInFlight = null;
|
|
1963
|
+
workspaceInspectionGeneration = 0;
|
|
1964
|
+
workspaceInspectionModelsVersion;
|
|
1965
|
+
workspaceInspectionPrefsMtime;
|
|
1966
|
+
workspaceSnapshotTemplates = new Map();
|
|
1967
|
+
workspaceSnapshotInFlight = new Map();
|
|
1968
|
+
/**
|
|
1969
|
+
* Actively invalidate cached workspace inspection services and snapshot
|
|
1970
|
+
* templates (P1-A generation invalidation). Next inspection rebuilds cleanly.
|
|
1971
|
+
*/
|
|
1972
|
+
invalidateWorkspaceInspection() {
|
|
1973
|
+
this.workspaceInspectionServices = undefined;
|
|
1974
|
+
this.workspaceInspectionCachedAt = 0;
|
|
1975
|
+
this.workspaceInspectionInFlight = null;
|
|
1976
|
+
this.workspaceInspectionGeneration += 1;
|
|
1977
|
+
this.workspaceSnapshotTemplates.clear();
|
|
1978
|
+
this.workspaceSnapshotInFlight.clear();
|
|
1979
|
+
this.workspaceModelRuntime = undefined;
|
|
1980
|
+
}
|
|
1897
1981
|
async getWorkspaceModelRuntime() {
|
|
1898
1982
|
if (!this.workspaceModelRuntime) {
|
|
1899
1983
|
this.workspaceModelRuntime = (async () => {
|
|
@@ -1914,34 +1998,84 @@ export class ConsolePiRuntime {
|
|
|
1914
1998
|
/**
|
|
1915
1999
|
* Full OPEN-surface services for inspect UIs. No SessionManager / JSONL.
|
|
1916
2000
|
* Cached without sessionId so todo/goal extensions stay off the shared scope.
|
|
2001
|
+
* P1-A: short TTL + generation invalidation + single-flight concurrency.
|
|
1917
2002
|
*/
|
|
1918
2003
|
async getWorkspaceInspectionServices() {
|
|
1919
|
-
|
|
1920
|
-
|
|
2004
|
+
const now = Date.now();
|
|
2005
|
+
if (this.workspaceInspectionServices &&
|
|
2006
|
+
now - this.workspaceInspectionCachedAt < ConsolePiRuntime.WORKSPACE_INSPECTION_TTL_MS) {
|
|
2007
|
+
try {
|
|
1921
2008
|
const agentDir = await safeGetAgentDir(this.bindings);
|
|
1922
|
-
const
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
}
|
|
1932
|
-
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2009
|
+
const modelsPath = path.join(agentDir, "models.json");
|
|
2010
|
+
const currentModelsVersion = await readModelConfigFileVersion(modelsPath);
|
|
2011
|
+
let prefsMtime;
|
|
2012
|
+
if (this.options.resourcePreferencesPath) {
|
|
2013
|
+
try {
|
|
2014
|
+
prefsMtime = (await stat(this.options.resourcePreferencesPath)).mtimeMs;
|
|
2015
|
+
}
|
|
2016
|
+
catch {
|
|
2017
|
+
prefsMtime = undefined;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
if (this.workspaceInspectionModelsVersion &&
|
|
2021
|
+
sameModelConfigFileVersion(this.workspaceInspectionModelsVersion, currentModelsVersion) &&
|
|
2022
|
+
this.workspaceInspectionPrefsMtime === prefsMtime) {
|
|
2023
|
+
return this.workspaceInspectionServices;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
catch {
|
|
2027
|
+
// Failed probe: invalidate and recreate.
|
|
2028
|
+
}
|
|
2029
|
+
this.invalidateWorkspaceInspection();
|
|
2030
|
+
}
|
|
2031
|
+
if (this.workspaceInspectionInFlight) {
|
|
2032
|
+
return this.workspaceInspectionInFlight;
|
|
1943
2033
|
}
|
|
1944
|
-
|
|
2034
|
+
const promise = (async () => {
|
|
2035
|
+
const agentDir = await safeGetAgentDir(this.bindings);
|
|
2036
|
+
const modelsPath = path.join(agentDir, "models.json");
|
|
2037
|
+
const currentModelsVersion = await readModelConfigFileVersion(modelsPath);
|
|
2038
|
+
let prefsMtime;
|
|
2039
|
+
if (this.options.resourcePreferencesPath) {
|
|
2040
|
+
try {
|
|
2041
|
+
prefsMtime = (await stat(this.options.resourcePreferencesPath)).mtimeMs;
|
|
2042
|
+
}
|
|
2043
|
+
catch {
|
|
2044
|
+
prefsMtime = undefined;
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
const appendSystemPrompt = composeChatSystemPromptParts({
|
|
2048
|
+
sessionMode: DEFAULT_CONSOLE_CHAT_SESSION_MODE,
|
|
2049
|
+
workflowPrompt: OPERATOR_CHAT_SYSTEM_PROMPT_BASE,
|
|
2050
|
+
});
|
|
2051
|
+
const { services } = await this.bindings.createServices({
|
|
2052
|
+
cwd: this.options.cwd,
|
|
2053
|
+
agentDir,
|
|
2054
|
+
resourceLoaderOptions: await this.buildResourceLoaderOptions({
|
|
2055
|
+
appendSystemPrompt,
|
|
2056
|
+
}),
|
|
2057
|
+
});
|
|
2058
|
+
const inspectionServices = {
|
|
2059
|
+
modelRuntime: services.modelRuntime,
|
|
2060
|
+
resourceLoader: services
|
|
2061
|
+
.resourceLoader,
|
|
2062
|
+
settingsManager: services.settingsManager,
|
|
2063
|
+
};
|
|
2064
|
+
this.workspaceInspectionServices = inspectionServices;
|
|
2065
|
+
this.workspaceInspectionCachedAt = Date.now();
|
|
2066
|
+
this.workspaceInspectionModelsVersion = currentModelsVersion;
|
|
2067
|
+
this.workspaceInspectionPrefsMtime = prefsMtime;
|
|
2068
|
+
return inspectionServices;
|
|
2069
|
+
})()
|
|
2070
|
+
.catch((error) => {
|
|
2071
|
+
this.invalidateWorkspaceInspection();
|
|
2072
|
+
throw error;
|
|
2073
|
+
})
|
|
2074
|
+
.finally(() => {
|
|
2075
|
+
this.workspaceInspectionInFlight = null;
|
|
2076
|
+
});
|
|
2077
|
+
this.workspaceInspectionInFlight = promise;
|
|
2078
|
+
return promise;
|
|
1945
2079
|
}
|
|
1946
2080
|
async listModels(sessionId) {
|
|
1947
2081
|
const live = this.modelRuntimes.get(sessionId);
|
|
@@ -2274,6 +2408,15 @@ export class ConsolePiRuntime {
|
|
|
2274
2408
|
}
|
|
2275
2409
|
async getRuntimeSnapshot(sessionId, options) {
|
|
2276
2410
|
const initializing = this.sessionInit.get(sessionId)?.status === "initializing";
|
|
2411
|
+
// Inspect GETs that supplied a durable `workspaceProjection` must not wait
|
|
2412
|
+
// for extension `session_start`: the model selector and context overview
|
|
2413
|
+
// render from the cached workspace ResourceLoader/ModelRuntime instead.
|
|
2414
|
+
// Direct `getRuntimeSnapshot(sessionId)` (no projection) keeps the
|
|
2415
|
+
// blocking `ensureSessionReady` contract, including
|
|
2416
|
+
// PiSessionInitFailedError, for callers that need the live Agent.
|
|
2417
|
+
if (initializing && options?.workspaceProjection) {
|
|
2418
|
+
return this.projectWorkspaceRuntimeSnapshot(sessionId, options);
|
|
2419
|
+
}
|
|
2277
2420
|
if (this.sessions.has(sessionId) || initializing) {
|
|
2278
2421
|
try {
|
|
2279
2422
|
await this.ensureSessionReady(sessionId);
|
|
@@ -2434,52 +2577,89 @@ export class ConsolePiRuntime {
|
|
|
2434
2577
|
const thinkingSelection = this.resolveWorkspaceThinkingSelection(sessionId, hint.thinkingLevel);
|
|
2435
2578
|
const effectiveThinkingLevel = settingsManager?.getDefaultThinkingLevel?.() ??
|
|
2436
2579
|
(thinkingSelection === "auto" ? undefined : thinkingSelection);
|
|
2437
|
-
const
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
let models = [];
|
|
2446
|
-
try {
|
|
2447
|
-
models = this.bindings
|
|
2448
|
-
.listAvailableModels({ modelRuntime: inspection.modelRuntime })
|
|
2449
|
-
.map((entry) => ({
|
|
2450
|
-
provider: entry.provider,
|
|
2451
|
-
id: entry.id,
|
|
2452
|
-
...(entry.name ? { name: entry.name } : {}),
|
|
2453
|
-
hasCredentials: entry.hasCredentials,
|
|
2454
|
-
}));
|
|
2455
|
-
}
|
|
2456
|
-
catch (error) {
|
|
2457
|
-
throw new RuntimeSnapshotUnavailableError(`model enumeration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
2458
|
-
}
|
|
2459
|
-
const thinkingLevels = [
|
|
2460
|
-
{ value: "auto" },
|
|
2461
|
-
...THINKING_LEVELS.map((value) => ({ value })),
|
|
2462
|
-
];
|
|
2463
|
-
let skillPrefs = { schemaVersion: 1, skills: {} };
|
|
2464
|
-
let skillPrefsError;
|
|
2465
|
-
if (resourceLoader) {
|
|
2466
|
-
try {
|
|
2467
|
-
skillPrefs = await this.loadSkillAutoInvocationPreferences();
|
|
2580
|
+
const now = Date.now();
|
|
2581
|
+
let template = this.workspaceSnapshotTemplates.get(sessionMode);
|
|
2582
|
+
if (!template ||
|
|
2583
|
+
template.generation !== this.workspaceInspectionGeneration ||
|
|
2584
|
+
now - template.cachedAt >= ConsolePiRuntime.WORKSPACE_INSPECTION_TTL_MS) {
|
|
2585
|
+
const existingInFlight = this.workspaceSnapshotInFlight.get(sessionMode);
|
|
2586
|
+
if (existingInFlight) {
|
|
2587
|
+
template = await existingInFlight;
|
|
2468
2588
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2589
|
+
else {
|
|
2590
|
+
const promise = (async () => {
|
|
2591
|
+
const rawSystemPrompt = resourceLoader?.getSystemPrompt?.() ||
|
|
2592
|
+
composeChatSystemPrompt({
|
|
2593
|
+
sessionMode,
|
|
2594
|
+
workflowPrompt: OPERATOR_CHAT_SYSTEM_PROMPT_BASE,
|
|
2595
|
+
});
|
|
2596
|
+
if (!rawSystemPrompt) {
|
|
2597
|
+
throw new RuntimeSnapshotUnavailableError("system prompt projection failed: workspace prompt was empty");
|
|
2598
|
+
}
|
|
2599
|
+
let models = [];
|
|
2600
|
+
try {
|
|
2601
|
+
models = this.bindings
|
|
2602
|
+
.listAvailableModels({ modelRuntime: inspection.modelRuntime })
|
|
2603
|
+
.map((entry) => ({
|
|
2604
|
+
provider: entry.provider,
|
|
2605
|
+
id: entry.id,
|
|
2606
|
+
...(entry.name ? { name: entry.name } : {}),
|
|
2607
|
+
hasCredentials: entry.hasCredentials,
|
|
2608
|
+
}));
|
|
2609
|
+
}
|
|
2610
|
+
catch (error) {
|
|
2611
|
+
throw new RuntimeSnapshotUnavailableError(`model enumeration failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
2612
|
+
}
|
|
2613
|
+
const thinkingLevels = [
|
|
2614
|
+
{ value: "auto" },
|
|
2615
|
+
...THINKING_LEVELS.map((value) => ({ value })),
|
|
2616
|
+
];
|
|
2617
|
+
let skillPrefs = { schemaVersion: 1, skills: {} };
|
|
2618
|
+
let skillPrefsError;
|
|
2619
|
+
if (resourceLoader) {
|
|
2620
|
+
try {
|
|
2621
|
+
skillPrefs = await this.loadSkillAutoInvocationPreferences();
|
|
2622
|
+
}
|
|
2623
|
+
catch (error) {
|
|
2624
|
+
skillPrefsError = error;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
const activeTools = chatActiveToolBaseline(sessionMode);
|
|
2628
|
+
const inventories = await collectRuntimeInventories({
|
|
2629
|
+
resourceLoader,
|
|
2630
|
+
skillPrefs,
|
|
2631
|
+
skillPrefsError,
|
|
2632
|
+
agentDir: await safeGetAgentDir(this.bindings),
|
|
2633
|
+
cwd: this.options.cwd,
|
|
2634
|
+
tools: [],
|
|
2635
|
+
activeToolNames: activeTools,
|
|
2636
|
+
});
|
|
2637
|
+
const createdTemplate = {
|
|
2638
|
+
models,
|
|
2639
|
+
thinkingLevels,
|
|
2640
|
+
rawSystemPrompt,
|
|
2641
|
+
activeTools,
|
|
2642
|
+
contextFiles: inventories.contextFiles,
|
|
2643
|
+
skills: inventories.skills,
|
|
2644
|
+
extensions: inventories.extensions,
|
|
2645
|
+
packages: inventories.packages,
|
|
2646
|
+
mcp: inventories.mcp,
|
|
2647
|
+
diagnostics: inventories.diagnostics,
|
|
2648
|
+
cachedAt: Date.now(),
|
|
2649
|
+
generation: this.workspaceInspectionGeneration,
|
|
2650
|
+
};
|
|
2651
|
+
this.workspaceSnapshotTemplates.set(sessionMode, createdTemplate);
|
|
2652
|
+
return createdTemplate;
|
|
2653
|
+
})().finally(() => {
|
|
2654
|
+
this.workspaceSnapshotInFlight.delete(sessionMode);
|
|
2655
|
+
});
|
|
2656
|
+
this.workspaceSnapshotInFlight.set(sessionMode, promise);
|
|
2657
|
+
template = await promise;
|
|
2471
2658
|
}
|
|
2472
2659
|
}
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
skillPrefs,
|
|
2477
|
-
skillPrefsError,
|
|
2478
|
-
agentDir: await safeGetAgentDir(this.bindings),
|
|
2479
|
-
cwd: this.options.cwd,
|
|
2480
|
-
tools: [],
|
|
2481
|
-
activeToolNames: activeTools,
|
|
2482
|
-
});
|
|
2660
|
+
if (!template) {
|
|
2661
|
+
throw new RuntimeSnapshotUnavailableError("workspace snapshot template missing");
|
|
2662
|
+
}
|
|
2483
2663
|
const storedModel = this.sessionModels.get(sessionId);
|
|
2484
2664
|
const provider = storedModel?.provider ?? hint.modelProvider;
|
|
2485
2665
|
const modelId = storedModel?.modelId ?? hint.modelId;
|
|
@@ -2496,21 +2676,21 @@ export class ConsolePiRuntime {
|
|
|
2496
2676
|
? { effectiveThinkingLevel: effectiveThinkingLevel }
|
|
2497
2677
|
: {}),
|
|
2498
2678
|
},
|
|
2499
|
-
models,
|
|
2500
|
-
thinkingLevels,
|
|
2679
|
+
models: template.models,
|
|
2680
|
+
thinkingLevels: template.thinkingLevels,
|
|
2501
2681
|
systemPrompt: {
|
|
2502
|
-
...(options.includeRaw ? { raw: rawSystemPrompt } : {}),
|
|
2503
|
-
text: rawSystemPrompt,
|
|
2504
|
-
sha256: createHash("sha256").update(rawSystemPrompt).digest("hex"),
|
|
2505
|
-
characters: rawSystemPrompt.length,
|
|
2682
|
+
...(options.includeRaw ? { raw: template.rawSystemPrompt } : {}),
|
|
2683
|
+
text: template.rawSystemPrompt,
|
|
2684
|
+
sha256: createHash("sha256").update(template.rawSystemPrompt).digest("hex"),
|
|
2685
|
+
characters: template.rawSystemPrompt.length,
|
|
2506
2686
|
},
|
|
2507
|
-
activeTools,
|
|
2508
|
-
contextFiles:
|
|
2509
|
-
skills:
|
|
2510
|
-
extensions:
|
|
2511
|
-
packages:
|
|
2512
|
-
mcp:
|
|
2513
|
-
diagnostics:
|
|
2687
|
+
activeTools: template.activeTools,
|
|
2688
|
+
contextFiles: template.contextFiles,
|
|
2689
|
+
skills: template.skills,
|
|
2690
|
+
extensions: template.extensions,
|
|
2691
|
+
packages: template.packages,
|
|
2692
|
+
mcp: template.mcp,
|
|
2693
|
+
diagnostics: template.diagnostics,
|
|
2514
2694
|
hasBash: true,
|
|
2515
2695
|
});
|
|
2516
2696
|
}
|
|
@@ -125,6 +125,7 @@ export function repoHtmlAssetContentType(rawPath) {
|
|
|
125
125
|
".mp4": "video/mp4",
|
|
126
126
|
".webm": "video/webm",
|
|
127
127
|
".pdf": "application/pdf",
|
|
128
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
128
129
|
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
129
130
|
".xls": "application/vnd.ms-excel",
|
|
130
131
|
".csv": "text/csv; charset=utf-8",
|
|
@@ -263,10 +264,12 @@ async function readRepoNonTextPreview(repoRoot, rawPath, classified) {
|
|
|
263
264
|
// Same ceiling as the byte route that serves the preview bytes.
|
|
264
265
|
if (size > HTML_PREVIEW_ASSET_LIMIT)
|
|
265
266
|
throw new RepoBrowserError(413, "TOO_LARGE", `file exceeds ${HTML_PREVIEW_ASSET_LIMIT} byte preview limit`);
|
|
266
|
-
if (classified.kind === "sheet") {
|
|
267
|
+
if (classified.kind === "sheet" || classified.kind === "docx") {
|
|
268
|
+
// Sheets and Word documents are cited by visible region, so the snapshot
|
|
269
|
+
// carries a content hash as the reference version.
|
|
267
270
|
return {
|
|
268
271
|
path: repoRelative,
|
|
269
|
-
kind:
|
|
272
|
+
kind: classified.kind,
|
|
270
273
|
content: "",
|
|
271
274
|
language,
|
|
272
275
|
mediaType: classified.mediaType,
|
|
@@ -71,9 +71,9 @@ export const UNVIEWABLE_BINARY_EXTENSIONS = [
|
|
|
71
71
|
"tar",
|
|
72
72
|
"jar",
|
|
73
73
|
// office documents without a renderer — `key` stays out: it collides with
|
|
74
|
-
// readable key/credential text files. xls/xlsx are spreadsheets
|
|
74
|
+
// readable key/credential text files. xls/xlsx are spreadsheets and docx is
|
|
75
|
+
// the Word renderer, so neither belongs here.
|
|
75
76
|
"doc",
|
|
76
|
-
"docx",
|
|
77
77
|
"ppt",
|
|
78
78
|
"pptx",
|
|
79
79
|
"odt",
|
|
@@ -115,6 +115,9 @@ export const UNVIEWABLE_BINARY_EXTENSIONS = [
|
|
|
115
115
|
];
|
|
116
116
|
/** Spreadsheet suffixes rendered as a table (DSH excel renderer). */
|
|
117
117
|
export const SHEET_EXTENSIONS = ["xlsx", "xls", "csv", "tsv"];
|
|
118
|
+
/** Word suffixes rendered by the in-browser docx renderer. `.doc` stays out:
|
|
119
|
+
* the legacy binary format has no renderer and remains unsupported. */
|
|
120
|
+
export const DOCX_EXTENSIONS = ["docx"];
|
|
118
121
|
/** Workbook suffixes whose bytes are not readable text. CSV and TSV stay text. */
|
|
119
122
|
export const BINARY_SHEET_EXTENSIONS = ["xlsx", "xls"];
|
|
120
123
|
const SHEET_MEDIA_TYPES = {
|
|
@@ -135,6 +138,7 @@ const IMAGE_MEDIA_TYPES = {
|
|
|
135
138
|
};
|
|
136
139
|
const IMAGE_SUFFIX_SET = new Set(IMAGE_EXTENSIONS);
|
|
137
140
|
const SHEET_SUFFIX_SET = new Set(SHEET_EXTENSIONS);
|
|
141
|
+
const DOCX_SUFFIX_SET = new Set(DOCX_EXTENSIONS);
|
|
138
142
|
const UNVIEWABLE_SUFFIX_SET = new Set(UNVIEWABLE_BINARY_EXTENSIONS);
|
|
139
143
|
const UNVIEWABLE_FILENAME_SET = new Set(UNVIEWABLE_BINARY_FILENAMES);
|
|
140
144
|
/** The lowercased final path segment (DSH documentFileName). */
|
|
@@ -152,10 +156,10 @@ export function fileSuffixOf(path) {
|
|
|
152
156
|
return "";
|
|
153
157
|
return name.slice(dot + 1);
|
|
154
158
|
}
|
|
155
|
-
/** Classify a repo-relative path by its final extension: image, PDF,
|
|
156
|
-
* spreadsheet renderers first, then unviewable binary containers
|
|
157
|
-
* or, for extensionless dotfiles like `.DS_Store`, by full name),
|
|
158
|
-
* else text. */
|
|
159
|
+
/** Classify a repo-relative path by its final extension: image, PDF,
|
|
160
|
+
* spreadsheet, and Word renderers first, then unviewable binary containers
|
|
161
|
+
* (by suffix or, for extensionless dotfiles like `.DS_Store`, by full name),
|
|
162
|
+
* everything else text. */
|
|
159
163
|
export function classifyRepoPreview(path) {
|
|
160
164
|
const name = documentFileName(path);
|
|
161
165
|
if (UNVIEWABLE_FILENAME_SET.has(name))
|
|
@@ -166,6 +170,12 @@ export function classifyRepoPreview(path) {
|
|
|
166
170
|
}
|
|
167
171
|
if (suffix === "pdf")
|
|
168
172
|
return { kind: "pdf", mediaType: "application/pdf" };
|
|
173
|
+
if (DOCX_SUFFIX_SET.has(suffix)) {
|
|
174
|
+
return {
|
|
175
|
+
kind: "docx",
|
|
176
|
+
mediaType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
177
|
+
};
|
|
178
|
+
}
|
|
169
179
|
if (SHEET_SUFFIX_SET.has(suffix)) {
|
|
170
180
|
return {
|
|
171
181
|
kind: "sheet",
|