gsd-pi 2.73.1-dev.d987996 → 2.74.0-dev.0306a2e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-web-branch.d.ts +4 -3
- package/dist/cli-web-branch.js +10 -7
- package/dist/cli.js +184 -206
- package/dist/headless-query.js +4 -1
- package/dist/help-text.js +23 -0
- package/dist/logo.d.ts +1 -1
- package/dist/logo.js +1 -1
- package/dist/onboarding.js +59 -53
- package/dist/resource-loader.js +2 -2
- package/dist/resources/extensions/claude-code-cli/stream-adapter.js +68 -4
- package/dist/resources/extensions/gsd/activity-log.js +16 -0
- package/dist/resources/extensions/gsd/auto/detect-stuck.js +11 -4
- package/dist/resources/extensions/gsd/auto/loop.js +147 -10
- package/dist/resources/extensions/gsd/auto/phases.js +173 -13
- package/dist/resources/extensions/gsd/auto/session.js +10 -0
- package/dist/resources/extensions/gsd/auto-dispatch.js +22 -4
- package/dist/resources/extensions/gsd/auto-model-selection.js +105 -16
- package/dist/resources/extensions/gsd/auto-post-unit.js +254 -15
- package/dist/resources/extensions/gsd/auto-prompts.js +12 -0
- package/dist/resources/extensions/gsd/auto-start.js +23 -6
- package/dist/resources/extensions/gsd/auto-timeout-recovery.js +13 -0
- package/dist/resources/extensions/gsd/auto-unit-closeout.js +18 -0
- package/dist/resources/extensions/gsd/auto-verification.js +186 -3
- package/dist/resources/extensions/gsd/auto.js +65 -12
- package/dist/resources/extensions/gsd/bootstrap/register-extension.js +30 -8
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +41 -2
- package/dist/resources/extensions/gsd/commands/catalog.js +26 -1
- package/dist/resources/extensions/gsd/commands/handlers/ops.js +25 -0
- package/dist/resources/extensions/gsd/commands/handlers/workflow.js +68 -9
- package/dist/resources/extensions/gsd/commands-add-tests.js +111 -0
- package/dist/resources/extensions/gsd/commands-backlog.js +140 -0
- package/dist/resources/extensions/gsd/commands-do.js +79 -0
- package/dist/resources/extensions/gsd/commands-extract-learnings.js +225 -0
- package/dist/resources/extensions/gsd/commands-handlers.js +8 -2
- package/dist/resources/extensions/gsd/commands-maintenance.js +6 -6
- package/dist/resources/extensions/gsd/commands-pr-branch.js +180 -0
- package/dist/resources/extensions/gsd/commands-prefs-wizard.js +1 -1
- package/dist/resources/extensions/gsd/commands-session-report.js +82 -0
- package/dist/resources/extensions/gsd/commands-ship.js +187 -0
- package/dist/resources/extensions/gsd/db-writer.js +3 -5
- package/dist/resources/extensions/gsd/docs/preferences-reference.md +15 -2
- package/dist/resources/extensions/gsd/ecosystem/gsd-extension-api.js +144 -0
- package/dist/resources/extensions/gsd/ecosystem/loader.js +145 -0
- package/dist/resources/extensions/gsd/git-service.js +49 -1
- package/dist/resources/extensions/gsd/graph-context.js +157 -0
- package/dist/resources/extensions/gsd/gsd-db.js +581 -2
- package/dist/resources/extensions/gsd/guided-flow.js +23 -0
- package/dist/resources/extensions/gsd/index.js +15 -2
- package/dist/resources/extensions/gsd/init-wizard.js +1 -0
- package/dist/resources/extensions/gsd/journal.js +27 -0
- package/dist/resources/extensions/gsd/md-importer.js +3 -4
- package/dist/resources/extensions/gsd/memory-store.js +19 -51
- package/dist/resources/extensions/gsd/metrics.js +19 -0
- package/dist/resources/extensions/gsd/milestone-validation-gates.js +13 -12
- package/dist/resources/extensions/gsd/native-git-bridge.js +7 -4
- package/dist/resources/extensions/gsd/notification-widget.js +2 -2
- package/dist/resources/extensions/gsd/parallel-orchestrator.js +33 -1
- package/dist/resources/extensions/gsd/preferences-models.js +63 -3
- package/dist/resources/extensions/gsd/preferences-types.js +2 -0
- package/dist/resources/extensions/gsd/preferences-validation.js +130 -2
- package/dist/resources/extensions/gsd/preferences.js +26 -0
- package/dist/resources/extensions/gsd/prompts/add-tests.md +35 -0
- package/dist/resources/extensions/gsd/slice-parallel-orchestrator.js +12 -2
- package/dist/resources/extensions/gsd/state.js +66 -15
- package/dist/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
- package/dist/resources/extensions/gsd/tools/complete-slice.js +20 -0
- package/dist/resources/extensions/gsd/tools/validate-milestone.js +39 -4
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +3 -14
- package/dist/resources/extensions/gsd/triage-resolution.js +2 -5
- package/dist/resources/extensions/gsd/unit-ownership.js +1 -1
- package/dist/resources/extensions/gsd/uok/audit-toggle.js +7 -0
- package/dist/resources/extensions/gsd/uok/audit.js +40 -0
- package/dist/resources/extensions/gsd/uok/contracts.js +1 -0
- package/dist/resources/extensions/gsd/uok/execution-graph.js +179 -0
- package/dist/resources/extensions/gsd/uok/flags.js +29 -0
- package/dist/resources/extensions/gsd/uok/gate-runner.js +109 -0
- package/dist/resources/extensions/gsd/uok/gitops.js +53 -0
- package/dist/resources/extensions/gsd/uok/kernel.js +80 -0
- package/dist/resources/extensions/gsd/uok/loop-adapter.js +133 -0
- package/dist/resources/extensions/gsd/uok/model-policy.js +66 -0
- package/dist/resources/extensions/gsd/uok/plan-v2.js +132 -0
- package/dist/resources/extensions/gsd/workflow-logger.js +22 -0
- package/dist/resources/extensions/gsd/workflow-manifest.js +8 -69
- package/dist/resources/extensions/gsd/workflow-migration.js +21 -22
- package/dist/resources/extensions/gsd/workflow-projections.js +4 -1
- package/dist/resources/extensions/gsd/workflow-reconcile.js +14 -11
- package/dist/resources/extensions/ttsr/ttsr-manager.js +3 -1
- package/dist/tsconfig.extensions.tsbuildinfo +1 -0
- package/dist/update-check.d.ts +1 -0
- package/dist/update-check.js +13 -5
- package/dist/update-cmd.js +4 -3
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +13 -13
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/api/onboarding/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/input/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/resize/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/sessions/route.js +1 -1
- package/dist/web/standalone/.next/server/app/api/terminal/stream/route.js +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +13 -13
- package/dist/web/standalone/.next/server/chunks/6897.js +3 -3
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/middleware-manifest.json +5 -5
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +3 -3
- package/packages/daemon/package.json +2 -2
- package/packages/mcp-server/dist/index.d.ts +3 -0
- package/packages/mcp-server/dist/index.d.ts.map +1 -1
- package/packages/mcp-server/dist/index.js +3 -0
- package/packages/mcp-server/dist/index.js.map +1 -1
- package/packages/mcp-server/dist/readers/graph.d.ts +87 -0
- package/packages/mcp-server/dist/readers/graph.d.ts.map +1 -0
- package/packages/mcp-server/dist/readers/graph.js +655 -0
- package/packages/mcp-server/dist/readers/graph.js.map +1 -0
- package/packages/mcp-server/dist/readers/index.d.ts +2 -0
- package/packages/mcp-server/dist/readers/index.d.ts.map +1 -1
- package/packages/mcp-server/dist/readers/index.js +1 -0
- package/packages/mcp-server/dist/readers/index.js.map +1 -1
- package/packages/mcp-server/dist/server.d.ts.map +1 -1
- package/packages/mcp-server/dist/server.js +65 -0
- package/packages/mcp-server/dist/server.js.map +1 -1
- package/packages/mcp-server/package.json +2 -2
- package/packages/mcp-server/src/index.ts +15 -0
- package/packages/mcp-server/src/readers/graph.test.ts +604 -0
- package/packages/mcp-server/src/readers/graph.ts +855 -0
- package/packages/mcp-server/src/readers/index.ts +12 -0
- package/packages/mcp-server/src/server.ts +83 -0
- package/packages/mcp-server/tsconfig.json +1 -0
- package/packages/mcp-server/tsconfig.tsbuildinfo +1 -0
- package/packages/native/package.json +2 -2
- package/packages/native/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-agent-core/package.json +1 -1
- package/packages/pi-agent-core/tsconfig.json +1 -0
- package/packages/pi-agent-core/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-ai/dist/index.d.ts +2 -9
- package/packages/pi-ai/dist/index.d.ts.map +1 -1
- package/packages/pi-ai/dist/index.js +2 -9
- package/packages/pi-ai/dist/index.js.map +1 -1
- package/packages/pi-ai/dist/models/capability-patches.d.ts +19 -0
- package/packages/pi-ai/dist/models/capability-patches.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/capability-patches.js +36 -0
- package/packages/pi-ai/dist/models/capability-patches.js.map +1 -0
- package/packages/pi-ai/dist/{models.custom.d.ts → models/custom.d.ts} +1 -1
- package/packages/pi-ai/dist/models/custom.d.ts.map +1 -0
- package/packages/pi-ai/dist/{models.custom.js → models/custom.js} +4 -4
- package/packages/pi-ai/dist/models/custom.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.d.ts +1482 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.js +1484 -0
- package/packages/pi-ai/dist/models/generated/amazon-bedrock.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/anthropic.d.ts +377 -0
- package/packages/pi-ai/dist/models/generated/anthropic.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/anthropic.js +379 -0
- package/packages/pi-ai/dist/models/generated/anthropic.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.d.ts +700 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.js +702 -0
- package/packages/pi-ai/dist/models/generated/azure-openai-responses.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/cerebras.d.ts +71 -0
- package/packages/pi-ai/dist/models/generated/cerebras.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/cerebras.js +73 -0
- package/packages/pi-ai/dist/models/generated/cerebras.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.d.ts +590 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.js +444 -0
- package/packages/pi-ai/dist/models/generated/github-copilot.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.d.ts +156 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.js +158 -0
- package/packages/pi-ai/dist/models/generated/google-antigravity.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.js +107 -0
- package/packages/pi-ai/dist/models/generated/google-gemini-cli.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.d.ts +207 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.js +209 -0
- package/packages/pi-ai/dist/models/generated/google-vertex.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/google.d.ts +462 -0
- package/packages/pi-ai/dist/models/generated/google.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/google.js +464 -0
- package/packages/pi-ai/dist/models/generated/google.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/groq.d.ts +309 -0
- package/packages/pi-ai/dist/models/generated/groq.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/groq.js +311 -0
- package/packages/pi-ai/dist/models/generated/groq.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/huggingface.d.ts +383 -0
- package/packages/pi-ai/dist/models/generated/huggingface.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/huggingface.js +347 -0
- package/packages/pi-ai/dist/models/generated/huggingface.js.map +1 -0
- package/packages/pi-ai/dist/{models.generated.d.ts → models/generated/index.d.ts} +1 -1
- package/packages/pi-ai/dist/{models.generated.d.ts.map → models/generated/index.d.ts.map} +1 -1
- package/packages/pi-ai/dist/models/generated/index.js +51 -0
- package/packages/pi-ai/dist/models/generated/index.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.d.ts +37 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.js +39 -0
- package/packages/pi-ai/dist/models/generated/kimi-coding.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.js +107 -0
- package/packages/pi-ai/dist/models/generated/minimax-cn.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax.d.ts +105 -0
- package/packages/pi-ai/dist/models/generated/minimax.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/minimax.js +107 -0
- package/packages/pi-ai/dist/models/generated/minimax.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/mistral.d.ts +445 -0
- package/packages/pi-ai/dist/models/generated/mistral.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/mistral.js +447 -0
- package/packages/pi-ai/dist/models/generated/mistral.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.d.ts +139 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.js +141 -0
- package/packages/pi-ai/dist/models/generated/openai-codex.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai.d.ts +700 -0
- package/packages/pi-ai/dist/models/generated/openai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openai.js +702 -0
- package/packages/pi-ai/dist/models/generated/openai.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.d.ts +122 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.js +124 -0
- package/packages/pi-ai/dist/models/generated/opencode-go.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode.d.ts +530 -0
- package/packages/pi-ai/dist/models/generated/opencode.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/opencode.js +532 -0
- package/packages/pi-ai/dist/models/generated/opencode.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/openrouter.d.ts +4270 -0
- package/packages/pi-ai/dist/models/generated/openrouter.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/openrouter.js +4272 -0
- package/packages/pi-ai/dist/models/generated/openrouter.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.d.ts +2604 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.js +2606 -0
- package/packages/pi-ai/dist/models/generated/vercel-ai-gateway.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/xai.d.ts +411 -0
- package/packages/pi-ai/dist/models/generated/xai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/xai.js +413 -0
- package/packages/pi-ai/dist/models/generated/xai.js.map +1 -0
- package/packages/pi-ai/dist/models/generated/zai.d.ts +276 -0
- package/packages/pi-ai/dist/models/generated/zai.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/generated/zai.js +239 -0
- package/packages/pi-ai/dist/models/generated/zai.js.map +1 -0
- package/packages/pi-ai/dist/models/index.d.ts +27 -0
- package/packages/pi-ai/dist/models/index.d.ts.map +1 -0
- package/packages/pi-ai/dist/models/index.js +80 -0
- package/packages/pi-ai/dist/models/index.js.map +1 -0
- package/packages/pi-ai/dist/models.d.ts +1 -36
- package/packages/pi-ai/dist/models.d.ts.map +1 -1
- package/packages/pi-ai/dist/models.generated.test.js +1 -2
- package/packages/pi-ai/dist/models.generated.test.js.map +1 -1
- package/packages/pi-ai/dist/models.js +3 -112
- package/packages/pi-ai/dist/models.js.map +1 -1
- package/packages/pi-ai/dist/models.test.js +6 -5
- package/packages/pi-ai/dist/models.test.js.map +1 -1
- package/packages/pi-ai/dist/utils/overflow.d.ts.map +1 -1
- package/packages/pi-ai/dist/utils/overflow.js +12 -0
- package/packages/pi-ai/dist/utils/overflow.js.map +1 -1
- package/packages/pi-ai/dist/utils/tests/overflow.test.d.ts +2 -0
- package/packages/pi-ai/dist/utils/tests/overflow.test.d.ts.map +1 -0
- package/packages/pi-ai/dist/utils/tests/overflow.test.js +50 -0
- package/packages/pi-ai/dist/utils/tests/overflow.test.js.map +1 -0
- package/packages/pi-ai/package.json +1 -1
- package/packages/pi-ai/scripts/generate-models.ts +74 -40
- package/packages/pi-ai/src/index.ts +5 -9
- package/packages/pi-ai/src/models/capability-patches.ts +40 -0
- package/packages/pi-ai/src/{models.custom.ts → models/custom.ts} +4 -4
- package/packages/pi-ai/src/models/generated/amazon-bedrock.ts +1486 -0
- package/packages/pi-ai/src/models/generated/anthropic.ts +381 -0
- package/packages/pi-ai/src/models/generated/azure-openai-responses.ts +704 -0
- package/packages/pi-ai/src/models/generated/cerebras.ts +75 -0
- package/packages/pi-ai/src/models/generated/github-copilot.ts +446 -0
- package/packages/pi-ai/src/models/generated/google-antigravity.ts +160 -0
- package/packages/pi-ai/src/models/generated/google-gemini-cli.ts +109 -0
- package/packages/pi-ai/src/models/generated/google-vertex.ts +211 -0
- package/packages/pi-ai/src/models/generated/google.ts +466 -0
- package/packages/pi-ai/src/models/generated/groq.ts +313 -0
- package/packages/pi-ai/src/models/generated/huggingface.ts +349 -0
- package/packages/pi-ai/src/models/generated/index.ts +52 -0
- package/packages/pi-ai/src/models/generated/kimi-coding.ts +41 -0
- package/packages/pi-ai/src/models/generated/minimax-cn.ts +109 -0
- package/packages/pi-ai/src/models/generated/minimax.ts +109 -0
- package/packages/pi-ai/src/models/generated/mistral.ts +449 -0
- package/packages/pi-ai/src/models/generated/openai-codex.ts +143 -0
- package/packages/pi-ai/src/models/generated/openai.ts +704 -0
- package/packages/pi-ai/src/models/generated/opencode-go.ts +126 -0
- package/packages/pi-ai/src/models/generated/opencode.ts +534 -0
- package/packages/pi-ai/src/models/generated/openrouter.ts +4274 -0
- package/packages/pi-ai/src/models/generated/vercel-ai-gateway.ts +2608 -0
- package/packages/pi-ai/src/models/generated/xai.ts +415 -0
- package/packages/pi-ai/src/models/generated/zai.ts +241 -0
- package/packages/pi-ai/src/models/index.ts +106 -0
- package/packages/pi-ai/src/models.generated.test.ts +1 -2
- package/packages/pi-ai/src/models.test.ts +6 -5
- package/packages/pi-ai/src/models.ts +3 -153
- package/packages/pi-ai/src/utils/overflow.ts +14 -1
- package/packages/pi-ai/src/utils/tests/overflow.test.ts +58 -0
- package/packages/pi-ai/tsconfig.json +1 -0
- package/packages/pi-ai/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js +721 -8
- package/packages/pi-coding-agent/dist/core/chat-controller-ordering.test.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction/utils.js +5 -5
- package/packages/pi-coding-agent/dist/core/compaction/utils.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.js +45 -0
- package/packages/pi-coding-agent/dist/core/compaction-utils.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js +52 -0
- package/packages/pi-coding-agent/dist/core/model-registry-env-fallback.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/model-registry.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/model-registry.js +2 -2
- package/packages/pi-coding-agent/dist/core/model-registry.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts +12 -2
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js +65 -28
- package/packages/pi-coding-agent/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts +2 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js +9 -3
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.js +52 -0
- package/packages/pi-coding-agent/dist/modes/interactive/components/dynamic-border.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js +305 -20
- package/packages/pi-coding-agent/dist/modes/interactive/controllers/chat-controller.js.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.d.ts +2 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js +38 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode-ordering.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +13 -0
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +59 -6
- package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/packages/pi-coding-agent/package.json +1 -1
- package/packages/pi-coding-agent/src/core/chat-controller-ordering.test.ts +884 -8
- package/packages/pi-coding-agent/src/core/compaction/utils.ts +5 -5
- package/packages/pi-coding-agent/src/core/compaction-utils.test.ts +50 -0
- package/packages/pi-coding-agent/src/core/model-registry-env-fallback.test.ts +59 -0
- package/packages/pi-coding-agent/src/core/model-registry.ts +2 -1
- package/packages/pi-coding-agent/src/modes/interactive/components/assistant-message.ts +78 -32
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.test.ts +73 -0
- package/packages/pi-coding-agent/src/modes/interactive/components/dynamic-border.ts +9 -3
- package/packages/pi-coding-agent/src/modes/interactive/controllers/chat-controller.ts +381 -39
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode-ordering.test.ts +44 -0
- package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +79 -6
- package/packages/pi-coding-agent/src/types/ambient-modules.d.ts +69 -0
- package/packages/pi-coding-agent/tsconfig.json +3 -2
- package/packages/pi-coding-agent/tsconfig.tsbuildinfo +1 -0
- package/packages/pi-tui/dist/__tests__/tui.test.js +60 -1
- package/packages/pi-tui/dist/__tests__/tui.test.js.map +1 -1
- package/packages/pi-tui/dist/tui.d.ts +8 -0
- package/packages/pi-tui/dist/tui.d.ts.map +1 -1
- package/packages/pi-tui/dist/tui.js +32 -3
- package/packages/pi-tui/dist/tui.js.map +1 -1
- package/packages/pi-tui/package.json +1 -1
- package/packages/pi-tui/src/__tests__/tui.test.ts +76 -1
- package/packages/pi-tui/src/tui.ts +31 -3
- package/packages/pi-tui/tsconfig.json +1 -0
- package/packages/pi-tui/tsconfig.tsbuildinfo +1 -0
- package/packages/rpc-client/package.json +1 -1
- package/packages/rpc-client/tsconfig.json +1 -0
- package/packages/rpc-client/tsconfig.tsbuildinfo +1 -0
- package/pkg/package.json +1 -1
- package/src/resources/extensions/claude-code-cli/stream-adapter.ts +107 -5
- package/src/resources/extensions/claude-code-cli/tests/stream-adapter.test.ts +111 -2
- package/src/resources/extensions/gsd/activity-log.ts +21 -0
- package/src/resources/extensions/gsd/auto/detect-stuck.ts +12 -4
- package/src/resources/extensions/gsd/auto/loop-deps.ts +10 -0
- package/src/resources/extensions/gsd/auto/loop.ts +159 -10
- package/src/resources/extensions/gsd/auto/phases.ts +213 -13
- package/src/resources/extensions/gsd/auto/session.ts +10 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +26 -10
- package/src/resources/extensions/gsd/auto-model-selection.ts +151 -16
- package/src/resources/extensions/gsd/auto-post-unit.ts +278 -16
- package/src/resources/extensions/gsd/auto-prompts.ts +13 -0
- package/src/resources/extensions/gsd/auto-start.ts +30 -6
- package/src/resources/extensions/gsd/auto-timeout-recovery.ts +17 -0
- package/src/resources/extensions/gsd/auto-unit-closeout.ts +25 -1
- package/src/resources/extensions/gsd/auto-verification.ts +225 -3
- package/src/resources/extensions/gsd/auto.ts +72 -16
- package/src/resources/extensions/gsd/bootstrap/register-extension.ts +38 -8
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +52 -2
- package/src/resources/extensions/gsd/commands/catalog.ts +26 -1
- package/src/resources/extensions/gsd/commands/handlers/ops.ts +25 -0
- package/src/resources/extensions/gsd/commands/handlers/workflow.ts +74 -9
- package/src/resources/extensions/gsd/commands-add-tests.ts +137 -0
- package/src/resources/extensions/gsd/commands-backlog.ts +182 -0
- package/src/resources/extensions/gsd/commands-do.ts +109 -0
- package/src/resources/extensions/gsd/commands-extract-learnings.ts +304 -0
- package/src/resources/extensions/gsd/commands-handlers.ts +8 -2
- package/src/resources/extensions/gsd/commands-maintenance.ts +6 -6
- package/src/resources/extensions/gsd/commands-pr-branch.ts +234 -0
- package/src/resources/extensions/gsd/commands-prefs-wizard.ts +1 -1
- package/src/resources/extensions/gsd/commands-session-report.ts +101 -0
- package/src/resources/extensions/gsd/commands-ship.ts +219 -0
- package/src/resources/extensions/gsd/db-writer.ts +3 -5
- package/src/resources/extensions/gsd/docs/preferences-reference.md +15 -2
- package/src/resources/extensions/gsd/ecosystem/gsd-extension-api.ts +228 -0
- package/src/resources/extensions/gsd/ecosystem/loader.ts +201 -0
- package/src/resources/extensions/gsd/git-service.ts +68 -0
- package/src/resources/extensions/gsd/graph-context.ts +212 -0
- package/src/resources/extensions/gsd/gsd-db.ts +788 -3
- package/src/resources/extensions/gsd/guided-flow.ts +32 -0
- package/src/resources/extensions/gsd/index.ts +18 -2
- package/src/resources/extensions/gsd/init-wizard.ts +3 -2
- package/src/resources/extensions/gsd/journal.ts +30 -0
- package/src/resources/extensions/gsd/md-importer.ts +3 -5
- package/src/resources/extensions/gsd/memory-store.ts +31 -62
- package/src/resources/extensions/gsd/metrics.ts +26 -0
- package/src/resources/extensions/gsd/milestone-validation-gates.ts +13 -14
- package/src/resources/extensions/gsd/native-git-bridge.ts +11 -12
- package/src/resources/extensions/gsd/notification-widget.ts +2 -2
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +40 -1
- package/src/resources/extensions/gsd/preferences-models.ts +61 -3
- package/src/resources/extensions/gsd/preferences-types.ts +44 -0
- package/src/resources/extensions/gsd/preferences-validation.ts +130 -2
- package/src/resources/extensions/gsd/preferences.ts +28 -0
- package/src/resources/extensions/gsd/prompts/add-tests.md +35 -0
- package/src/resources/extensions/gsd/session-lock.ts +14 -2
- package/src/resources/extensions/gsd/slice-parallel-orchestrator.ts +20 -1
- package/src/resources/extensions/gsd/state.ts +80 -17
- package/src/resources/extensions/gsd/templates/PREFERENCES.md +18 -0
- package/src/resources/extensions/gsd/tests/auto-loop.test.ts +9 -5
- package/src/resources/extensions/gsd/tests/auto-model-selection.test.ts +20 -0
- package/src/resources/extensions/gsd/tests/auto-post-unit-step-message.test.ts +53 -0
- package/src/resources/extensions/gsd/tests/auto-project-root-env.test.ts +7 -3
- package/src/resources/extensions/gsd/tests/auto-start-model-capture.test.ts +51 -2
- package/src/resources/extensions/gsd/tests/cold-resume-db-reopen.test.ts +6 -2
- package/src/resources/extensions/gsd/tests/commands-backlog.test.ts +158 -0
- package/src/resources/extensions/gsd/tests/commands-do.test.ts +127 -0
- package/src/resources/extensions/gsd/tests/commands-extract-learnings.test.ts +340 -0
- package/src/resources/extensions/gsd/tests/commands-pr-branch.test.ts +68 -0
- package/src/resources/extensions/gsd/tests/commands-session-report.test.ts +82 -0
- package/src/resources/extensions/gsd/tests/commands-ship.test.ts +71 -0
- package/src/resources/extensions/gsd/tests/commands-workflow-custom.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/complete-milestone-false-merge.test.ts +142 -0
- package/src/resources/extensions/gsd/tests/complete-slice.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/complete-task.test.ts +2 -2
- package/src/resources/extensions/gsd/tests/completed-at-reconcile.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/derive-state-crossval.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +3 -2
- package/src/resources/extensions/gsd/tests/derive-state-helpers.test.ts +68 -8
- package/src/resources/extensions/gsd/tests/derive-state.test.ts +3 -3
- package/src/resources/extensions/gsd/tests/extension-bootstrap-isolation.test.ts +154 -0
- package/src/resources/extensions/gsd/tests/finalize-timeout-guard.test.ts +10 -7
- package/src/resources/extensions/gsd/tests/flat-rate-routing-guard.test.ts +137 -1
- package/src/resources/extensions/gsd/tests/graph-context.test.ts +337 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/health-widget.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/integration/state-machine-edge-cases.test.ts +4 -2
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +68 -1
- package/src/resources/extensions/gsd/tests/md-importer.test.ts +1 -2
- package/src/resources/extensions/gsd/tests/memory-store.test.ts +2 -3
- package/src/resources/extensions/gsd/tests/model-isolation.test.ts +91 -2
- package/src/resources/extensions/gsd/tests/native-git-bridge-exec-fallback.test.ts +140 -0
- package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +79 -1
- package/src/resources/extensions/gsd/tests/post-unit-state-rebuild.test.ts +2 -1
- package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +40 -1
- package/src/resources/extensions/gsd/tests/preferences.test.ts +47 -0
- package/src/resources/extensions/gsd/tests/register-hooks-depth-verification.test.ts +1 -1
- package/src/resources/extensions/gsd/tests/single-writer-invariant.test.ts +180 -0
- package/src/resources/extensions/gsd/tests/state-machine-full-walkthrough.test.ts +5 -7
- package/src/resources/extensions/gsd/tests/token-profile.test.ts +9 -6
- package/src/resources/extensions/gsd/tests/uok-audit-unified.test.ts +101 -0
- package/src/resources/extensions/gsd/tests/uok-contracts.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/uok-execution-graph.test.ts +69 -0
- package/src/resources/extensions/gsd/tests/uok-flags.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/uok-gate-runner.test.ts +70 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-turn-action.test.ts +85 -0
- package/src/resources/extensions/gsd/tests/uok-gitops-wiring.test.ts +35 -0
- package/src/resources/extensions/gsd/tests/uok-model-policy.test.ts +89 -0
- package/src/resources/extensions/gsd/tests/uok-plan-v2-wiring.test.ts +167 -0
- package/src/resources/extensions/gsd/tests/uok-preferences.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/validate-milestone-stuck-guard.test.ts +179 -0
- package/src/resources/extensions/gsd/tests/validate-milestone-write-order.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/workflow-logger-wiring.test.ts +223 -0
- package/src/resources/extensions/gsd/tools/complete-slice.ts +26 -0
- package/src/resources/extensions/gsd/tools/validate-milestone.ts +48 -3
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +3 -11
- package/src/resources/extensions/gsd/triage-resolution.ts +2 -7
- package/src/resources/extensions/gsd/types.ts +14 -1
- package/src/resources/extensions/gsd/unit-ownership.ts +2 -2
- package/src/resources/extensions/gsd/uok/audit-toggle.ts +9 -0
- package/src/resources/extensions/gsd/uok/audit.ts +51 -0
- package/src/resources/extensions/gsd/uok/contracts.ts +135 -0
- package/src/resources/extensions/gsd/uok/execution-graph.ts +241 -0
- package/src/resources/extensions/gsd/uok/flags.ts +45 -0
- package/src/resources/extensions/gsd/uok/gate-runner.ts +146 -0
- package/src/resources/extensions/gsd/uok/gitops.ts +75 -0
- package/src/resources/extensions/gsd/uok/kernel.ts +105 -0
- package/src/resources/extensions/gsd/uok/loop-adapter.ts +162 -0
- package/src/resources/extensions/gsd/uok/model-policy.ts +112 -0
- package/src/resources/extensions/gsd/uok/plan-v2.ts +156 -0
- package/src/resources/extensions/gsd/workflow-logger.ts +27 -1
- package/src/resources/extensions/gsd/workflow-manifest.ts +9 -104
- package/src/resources/extensions/gsd/workflow-migration.ts +21 -29
- package/src/resources/extensions/gsd/workflow-projections.ts +8 -1
- package/src/resources/extensions/gsd/workflow-reconcile.ts +15 -15
- package/src/resources/extensions/ttsr/ttsr-manager.ts +10 -5
- package/packages/pi-ai/dist/models.custom.d.ts.map +0 -1
- package/packages/pi-ai/dist/models.custom.js.map +0 -1
- package/packages/pi-ai/dist/models.generated.js +0 -14343
- package/packages/pi-ai/dist/models.generated.js.map +0 -1
- package/packages/pi-ai/src/models.generated.ts +0 -14345
- /package/dist/web/standalone/.next/static/{cGmbVq2su4f9tMpgIkG8u → tqdo0yKKYz6fJXQnIgbdx}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{cGmbVq2su4f9tMpgIkG8u → tqdo0yKKYz6fJXQnIgbdx}/_ssgManifest.js +0 -0
|
@@ -94,7 +94,7 @@ function createHost() {
|
|
|
94
94
|
return host;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
test("chat-controller
|
|
97
|
+
test("chat-controller renders content blocks in content[] index order (tool-first stream)", async () => {
|
|
98
98
|
// ToolExecutionComponent uses the global theme singleton.
|
|
99
99
|
// Install a minimal no-op theme implementation for this unit test.
|
|
100
100
|
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
@@ -116,7 +116,6 @@ test("chat-controller keeps tool output ahead of delayed assistant text for exte
|
|
|
116
116
|
|
|
117
117
|
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
118
118
|
|
|
119
|
-
assert.equal(host.streamingComponent, undefined, "assistant component should be deferred at message_start");
|
|
120
119
|
assert.equal(host.chatContainer.children.length, 0, "nothing should render before content arrives");
|
|
121
120
|
|
|
122
121
|
await handleAgentEvent(
|
|
@@ -140,11 +139,10 @@ test("chat-controller keeps tool output ahead of delayed assistant text for exte
|
|
|
140
139
|
} as any,
|
|
141
140
|
);
|
|
142
141
|
|
|
143
|
-
|
|
142
|
+
// content[0] = toolCall → ToolExecutionComponent renders first
|
|
144
143
|
assert.equal(host.chatContainer.children.length, 1, "tool execution block should render immediately");
|
|
145
144
|
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
146
145
|
|
|
147
|
-
// Re-assert required host method before the text-bearing update path.
|
|
148
146
|
host.getMarkdownThemeWithSettings = () => ({});
|
|
149
147
|
|
|
150
148
|
await handleAgentEvent(
|
|
@@ -161,12 +159,13 @@ test("chat-controller keeps tool output ahead of delayed assistant text for exte
|
|
|
161
159
|
} as any,
|
|
162
160
|
);
|
|
163
161
|
|
|
164
|
-
|
|
162
|
+
// content[0]=toolCall, content[1]=text → order: tool, then text
|
|
163
|
+
assert.equal(host.chatContainer.children.length, 2, "text run should render after tool in content[] order");
|
|
165
164
|
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
166
165
|
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
167
166
|
});
|
|
168
167
|
|
|
169
|
-
test("chat-controller
|
|
168
|
+
test("chat-controller renders serverToolUse before trailing text matching content[] index order", async () => {
|
|
170
169
|
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
171
170
|
fg: (_key: string, text: string) => text,
|
|
172
171
|
bg: (_key: string, text: string) => text,
|
|
@@ -199,7 +198,7 @@ test("chat-controller keeps serverToolUse output ahead of assistant text when ex
|
|
|
199
198
|
} as any,
|
|
200
199
|
);
|
|
201
200
|
|
|
202
|
-
|
|
201
|
+
// content[0] = serverToolUse → ToolExecutionComponent renders first
|
|
203
202
|
assert.equal(host.chatContainer.children.length, 1, "server tool block should render immediately");
|
|
204
203
|
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
205
204
|
|
|
@@ -229,11 +228,461 @@ test("chat-controller keeps serverToolUse output ahead of assistant text when ex
|
|
|
229
228
|
} as any,
|
|
230
229
|
);
|
|
231
230
|
|
|
232
|
-
|
|
231
|
+
// content[0]=serverToolUse, content[1]=text → order: tool, then text
|
|
232
|
+
assert.equal(host.chatContainer.children.length, 2, "text run should render after server tool in content[] order");
|
|
233
233
|
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
234
234
|
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
+
test("chat-controller replays final message_end content when result adds unstreamed trailing text", async () => {
|
|
238
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
239
|
+
fg: (_key: string, text: string) => text,
|
|
240
|
+
bg: (_key: string, text: string) => text,
|
|
241
|
+
bold: (text: string) => text,
|
|
242
|
+
italic: (text: string) => text,
|
|
243
|
+
truncate: (text: string) => text,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const host = createHost();
|
|
247
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
248
|
+
|
|
249
|
+
const tool = {
|
|
250
|
+
type: "toolCall",
|
|
251
|
+
id: "mcp-end-replay-1",
|
|
252
|
+
name: "read",
|
|
253
|
+
mcpServer: "filesystem",
|
|
254
|
+
arguments: { filePath: "/tmp/demo.txt" },
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
258
|
+
|
|
259
|
+
const streamedContent = [
|
|
260
|
+
tool,
|
|
261
|
+
{ type: "thinking", thinking: "I am analyzing tool output..." },
|
|
262
|
+
];
|
|
263
|
+
await handleAgentEvent(
|
|
264
|
+
host,
|
|
265
|
+
{
|
|
266
|
+
type: "message_update",
|
|
267
|
+
message: makeAssistant(streamedContent),
|
|
268
|
+
assistantMessageEvent: {
|
|
269
|
+
type: "thinking_delta",
|
|
270
|
+
contentIndex: 1,
|
|
271
|
+
delta: "I am analyzing tool output...",
|
|
272
|
+
partial: makeAssistant(streamedContent),
|
|
273
|
+
},
|
|
274
|
+
} as any,
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
assert.equal(host.chatContainer.children.length, 2, "streaming shows tool + thinking only");
|
|
278
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
279
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
280
|
+
|
|
281
|
+
// Final payload includes trailing text that never arrived as message_update.
|
|
282
|
+
const finalContent = [
|
|
283
|
+
tool,
|
|
284
|
+
{ type: "thinking", thinking: "I am analyzing tool output..." },
|
|
285
|
+
{ type: "text", text: "Correct anything important I missed?" },
|
|
286
|
+
];
|
|
287
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant(finalContent) } as any);
|
|
288
|
+
|
|
289
|
+
assert.equal(host.chatContainer.children.length, 3, "message_end should replay and include trailing text segment");
|
|
290
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
291
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
292
|
+
assert.equal(host.chatContainer.children[2]?.constructor?.name, "AssistantMessageComponent");
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
test("chat-controller keeps pre-tool prose visible until post-tool prose arrives, then prunes it", async () => {
|
|
296
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
297
|
+
fg: (_key: string, text: string) => text,
|
|
298
|
+
bg: (_key: string, text: string) => text,
|
|
299
|
+
bold: (text: string) => text,
|
|
300
|
+
italic: (text: string) => text,
|
|
301
|
+
truncate: (text: string) => text,
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const host = createHost();
|
|
305
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
306
|
+
|
|
307
|
+
const mcpTool = {
|
|
308
|
+
type: "toolCall",
|
|
309
|
+
id: "mcp-tool-1",
|
|
310
|
+
name: "read",
|
|
311
|
+
mcpServer: "filesystem",
|
|
312
|
+
arguments: { filePath: "/tmp/demo.txt" },
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
316
|
+
|
|
317
|
+
// Provisional assistant text arrives first.
|
|
318
|
+
await handleAgentEvent(
|
|
319
|
+
host,
|
|
320
|
+
{
|
|
321
|
+
type: "message_update",
|
|
322
|
+
message: makeAssistant([{ type: "text", text: "Let me inspect the workspace first." }]),
|
|
323
|
+
assistantMessageEvent: {
|
|
324
|
+
type: "text_delta",
|
|
325
|
+
contentIndex: 0,
|
|
326
|
+
delta: "Let me inspect the workspace first.",
|
|
327
|
+
partial: makeAssistant([{ type: "text", text: "Let me inspect the workspace first." }]),
|
|
328
|
+
},
|
|
329
|
+
} as any,
|
|
330
|
+
);
|
|
331
|
+
assert.equal(host.chatContainer.children.length, 1);
|
|
332
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent");
|
|
333
|
+
|
|
334
|
+
// MCP tool appears; provisional text should remain visible until post-tool prose exists.
|
|
335
|
+
await handleAgentEvent(
|
|
336
|
+
host,
|
|
337
|
+
{
|
|
338
|
+
type: "message_update",
|
|
339
|
+
message: makeAssistant([{ type: "text", text: "Let me inspect the workspace first." }, mcpTool]),
|
|
340
|
+
assistantMessageEvent: {
|
|
341
|
+
type: "toolcall_end",
|
|
342
|
+
contentIndex: 1,
|
|
343
|
+
toolCall: {
|
|
344
|
+
...mcpTool,
|
|
345
|
+
externalResult: {
|
|
346
|
+
content: [{ type: "text", text: "file preview" }],
|
|
347
|
+
details: {},
|
|
348
|
+
isError: false,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
partial: makeAssistant([{ type: "text", text: "Let me inspect the workspace first." }, mcpTool]),
|
|
352
|
+
},
|
|
353
|
+
} as any,
|
|
354
|
+
);
|
|
355
|
+
assert.equal(host.chatContainer.children.length, 2, "pre-tool prose should remain during tool-only window");
|
|
356
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent");
|
|
357
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "ToolExecutionComponent");
|
|
358
|
+
|
|
359
|
+
// Post-tool prose arrives: pre-tool prose should now be pruned.
|
|
360
|
+
const finalContent = [
|
|
361
|
+
{ type: "text", text: "Let me inspect the workspace first." },
|
|
362
|
+
mcpTool,
|
|
363
|
+
{ type: "text", text: "Which missing feature matters most to you?" },
|
|
364
|
+
];
|
|
365
|
+
await handleAgentEvent(
|
|
366
|
+
host,
|
|
367
|
+
{
|
|
368
|
+
type: "message_update",
|
|
369
|
+
message: makeAssistant(finalContent),
|
|
370
|
+
assistantMessageEvent: {
|
|
371
|
+
type: "text_delta",
|
|
372
|
+
contentIndex: 2,
|
|
373
|
+
delta: "Which missing feature matters most to you?",
|
|
374
|
+
partial: makeAssistant(finalContent),
|
|
375
|
+
},
|
|
376
|
+
} as any,
|
|
377
|
+
);
|
|
378
|
+
assert.equal(host.chatContainer.children.length, 2);
|
|
379
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
380
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
381
|
+
|
|
382
|
+
// Finalize to tear down any pinned spinner state.
|
|
383
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant(finalContent) } as any);
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("chat-controller keeps pre-tool thinking visible for claude-code MCP turns without post-tool prose", async () => {
|
|
387
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
388
|
+
fg: (_key: string, text: string) => text,
|
|
389
|
+
bg: (_key: string, text: string) => text,
|
|
390
|
+
bold: (text: string) => text,
|
|
391
|
+
italic: (text: string) => text,
|
|
392
|
+
truncate: (text: string) => text,
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
const host = createHost();
|
|
396
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
397
|
+
|
|
398
|
+
const mcpTool = {
|
|
399
|
+
type: "toolCall",
|
|
400
|
+
id: "mcp-tool-thinking-1",
|
|
401
|
+
name: "read",
|
|
402
|
+
mcpServer: "filesystem",
|
|
403
|
+
arguments: { filePath: "/tmp/demo.txt" },
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
407
|
+
|
|
408
|
+
const thinkingOnly = [{ type: "thinking", thinking: "I should inspect the workspace." }];
|
|
409
|
+
await handleAgentEvent(
|
|
410
|
+
host,
|
|
411
|
+
{
|
|
412
|
+
type: "message_update",
|
|
413
|
+
message: makeAssistant(thinkingOnly),
|
|
414
|
+
assistantMessageEvent: {
|
|
415
|
+
type: "thinking_delta",
|
|
416
|
+
contentIndex: 0,
|
|
417
|
+
delta: "I should inspect the workspace.",
|
|
418
|
+
partial: makeAssistant(thinkingOnly),
|
|
419
|
+
},
|
|
420
|
+
} as any,
|
|
421
|
+
);
|
|
422
|
+
assert.equal(host.chatContainer.children.length, 1);
|
|
423
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent");
|
|
424
|
+
|
|
425
|
+
await handleAgentEvent(
|
|
426
|
+
host,
|
|
427
|
+
{
|
|
428
|
+
type: "message_update",
|
|
429
|
+
message: makeAssistant([thinkingOnly[0], mcpTool]),
|
|
430
|
+
assistantMessageEvent: {
|
|
431
|
+
type: "toolcall_end",
|
|
432
|
+
contentIndex: 1,
|
|
433
|
+
toolCall: {
|
|
434
|
+
...mcpTool,
|
|
435
|
+
externalResult: {
|
|
436
|
+
content: [{ type: "text", text: "file preview" }],
|
|
437
|
+
details: {},
|
|
438
|
+
isError: false,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
partial: makeAssistant([thinkingOnly[0], mcpTool]),
|
|
442
|
+
},
|
|
443
|
+
} as any,
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
assert.equal(host.chatContainer.children.length, 2, "thinking should remain visible while only tool output is present");
|
|
447
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent");
|
|
448
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "ToolExecutionComponent");
|
|
449
|
+
|
|
450
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant([thinkingOnly[0], mcpTool]) } as any);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
test("chat-controller prunes orphaned provisional text after claude-code sub-turn shrink when MCP tools appear", async () => {
|
|
454
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
455
|
+
fg: (_key: string, text: string) => text,
|
|
456
|
+
bg: (_key: string, text: string) => text,
|
|
457
|
+
bold: (text: string) => text,
|
|
458
|
+
italic: (text: string) => text,
|
|
459
|
+
truncate: (text: string) => text,
|
|
460
|
+
};
|
|
461
|
+
|
|
462
|
+
const host = createHost();
|
|
463
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
464
|
+
|
|
465
|
+
const mcpTool = {
|
|
466
|
+
type: "toolCall",
|
|
467
|
+
id: "mcp-tool-shrink-1",
|
|
468
|
+
name: "glob",
|
|
469
|
+
mcpServer: "filesystem",
|
|
470
|
+
arguments: { pattern: "**/*" },
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
474
|
+
|
|
475
|
+
// Sub-turn 1: generate longer provisional text content.
|
|
476
|
+
await handleAgentEvent(
|
|
477
|
+
host,
|
|
478
|
+
{
|
|
479
|
+
type: "message_update",
|
|
480
|
+
message: makeAssistant([{ type: "text", text: "Old provisional preface." }, { type: "text", text: "More old text." }]),
|
|
481
|
+
assistantMessageEvent: {
|
|
482
|
+
type: "text_delta",
|
|
483
|
+
contentIndex: 1,
|
|
484
|
+
delta: "More old text.",
|
|
485
|
+
partial: makeAssistant([{ type: "text", text: "Old provisional preface." }, { type: "text", text: "More old text." }]),
|
|
486
|
+
},
|
|
487
|
+
} as any,
|
|
488
|
+
);
|
|
489
|
+
assert.equal(host.chatContainer.children.length, 1, "first sub-turn text run should render");
|
|
490
|
+
|
|
491
|
+
// Sub-turn 2 starts (content shrink): old component is orphaned by design.
|
|
492
|
+
await handleAgentEvent(
|
|
493
|
+
host,
|
|
494
|
+
{
|
|
495
|
+
type: "message_update",
|
|
496
|
+
message: makeAssistant([{ type: "text", text: "New provisional text before tool." }]),
|
|
497
|
+
assistantMessageEvent: {
|
|
498
|
+
type: "text_delta",
|
|
499
|
+
contentIndex: 0,
|
|
500
|
+
delta: "New provisional text before tool.",
|
|
501
|
+
partial: makeAssistant([{ type: "text", text: "New provisional text before tool." }]),
|
|
502
|
+
},
|
|
503
|
+
} as any,
|
|
504
|
+
);
|
|
505
|
+
assert.equal(host.chatContainer.children.length, 2, "shrink keeps prior text until MCP tool context appears");
|
|
506
|
+
|
|
507
|
+
// MCP tool appears in sub-turn 2: tool-only windows keep provisional prose visible.
|
|
508
|
+
await handleAgentEvent(
|
|
509
|
+
host,
|
|
510
|
+
{
|
|
511
|
+
type: "message_update",
|
|
512
|
+
message: makeAssistant([{ type: "text", text: "New provisional text before tool." }, mcpTool]),
|
|
513
|
+
assistantMessageEvent: {
|
|
514
|
+
type: "toolcall_end",
|
|
515
|
+
contentIndex: 1,
|
|
516
|
+
toolCall: {
|
|
517
|
+
...mcpTool,
|
|
518
|
+
externalResult: {
|
|
519
|
+
content: [{ type: "text", text: "glob output" }],
|
|
520
|
+
details: {},
|
|
521
|
+
isError: false,
|
|
522
|
+
},
|
|
523
|
+
},
|
|
524
|
+
partial: makeAssistant([{ type: "text", text: "New provisional text before tool." }, mcpTool]),
|
|
525
|
+
},
|
|
526
|
+
} as any,
|
|
527
|
+
);
|
|
528
|
+
assert.equal(host.chatContainer.children.length, 3, "stale text runs are deferred until post-tool prose arrives");
|
|
529
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent");
|
|
530
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
531
|
+
assert.equal(host.chatContainer.children[2]?.constructor?.name, "ToolExecutionComponent");
|
|
532
|
+
|
|
533
|
+
const finalContent = [mcpTool, { type: "text", text: "Final visible question?" }];
|
|
534
|
+
await handleAgentEvent(
|
|
535
|
+
host,
|
|
536
|
+
{
|
|
537
|
+
type: "message_update",
|
|
538
|
+
message: makeAssistant(finalContent),
|
|
539
|
+
assistantMessageEvent: {
|
|
540
|
+
type: "text_delta",
|
|
541
|
+
contentIndex: 1,
|
|
542
|
+
delta: "Final visible question?",
|
|
543
|
+
partial: makeAssistant(finalContent),
|
|
544
|
+
},
|
|
545
|
+
} as any,
|
|
546
|
+
);
|
|
547
|
+
assert.equal(host.chatContainer.children.length, 2);
|
|
548
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
549
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
550
|
+
|
|
551
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant(finalContent) } as any);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
test("chat-controller prunes orphans from multiple sub-turn shrinks before MCP post-tool prose", async () => {
|
|
555
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
556
|
+
fg: (_key: string, text: string) => text,
|
|
557
|
+
bg: (_key: string, text: string) => text,
|
|
558
|
+
bold: (text: string) => text,
|
|
559
|
+
italic: (text: string) => text,
|
|
560
|
+
truncate: (text: string) => text,
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
const host = createHost();
|
|
564
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
565
|
+
|
|
566
|
+
const mcpTool = {
|
|
567
|
+
type: "toolCall",
|
|
568
|
+
id: "mcp-tool-multi-shrink-1",
|
|
569
|
+
name: "glob",
|
|
570
|
+
mcpServer: "filesystem",
|
|
571
|
+
arguments: { pattern: "**/*" },
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
575
|
+
|
|
576
|
+
// Sub-turn 1: 3 text blocks (merged into one text-run).
|
|
577
|
+
const subTurn1 = [
|
|
578
|
+
{ type: "text", text: "First provisional A." },
|
|
579
|
+
{ type: "text", text: "First provisional B." },
|
|
580
|
+
{ type: "text", text: "First provisional C." },
|
|
581
|
+
];
|
|
582
|
+
await handleAgentEvent(
|
|
583
|
+
host,
|
|
584
|
+
{
|
|
585
|
+
type: "message_update",
|
|
586
|
+
message: makeAssistant(subTurn1),
|
|
587
|
+
assistantMessageEvent: {
|
|
588
|
+
type: "text_delta",
|
|
589
|
+
contentIndex: 2,
|
|
590
|
+
delta: "First provisional C.",
|
|
591
|
+
partial: makeAssistant(subTurn1),
|
|
592
|
+
},
|
|
593
|
+
} as any,
|
|
594
|
+
);
|
|
595
|
+
assert.equal(host.chatContainer.children.length, 1, "first sub-turn renders 1 text-run");
|
|
596
|
+
|
|
597
|
+
// Sub-turn 2 (first shrink 3 → 2 blocks).
|
|
598
|
+
const subTurn2 = [
|
|
599
|
+
{ type: "text", text: "Second provisional A." },
|
|
600
|
+
{ type: "text", text: "Second provisional B." },
|
|
601
|
+
];
|
|
602
|
+
await handleAgentEvent(
|
|
603
|
+
host,
|
|
604
|
+
{
|
|
605
|
+
type: "message_update",
|
|
606
|
+
message: makeAssistant(subTurn2),
|
|
607
|
+
assistantMessageEvent: {
|
|
608
|
+
type: "text_delta",
|
|
609
|
+
contentIndex: 1,
|
|
610
|
+
delta: "Second provisional B.",
|
|
611
|
+
partial: makeAssistant(subTurn2),
|
|
612
|
+
},
|
|
613
|
+
} as any,
|
|
614
|
+
);
|
|
615
|
+
assert.equal(host.chatContainer.children.length, 2, "first shrink appends, keeps prior text as frozen history");
|
|
616
|
+
|
|
617
|
+
// Sub-turn 3 (second shrink 2 → 1 block). This is the critical step —
|
|
618
|
+
// without orphan accumulation, sub-turn 1's orphaned segment would be
|
|
619
|
+
// dropped from tracking here and later strand in the container.
|
|
620
|
+
const subTurn3 = [{ type: "text", text: "Third provisional." }];
|
|
621
|
+
await handleAgentEvent(
|
|
622
|
+
host,
|
|
623
|
+
{
|
|
624
|
+
type: "message_update",
|
|
625
|
+
message: makeAssistant(subTurn3),
|
|
626
|
+
assistantMessageEvent: {
|
|
627
|
+
type: "text_delta",
|
|
628
|
+
contentIndex: 0,
|
|
629
|
+
delta: "Third provisional.",
|
|
630
|
+
partial: makeAssistant(subTurn3),
|
|
631
|
+
},
|
|
632
|
+
} as any,
|
|
633
|
+
);
|
|
634
|
+
assert.equal(host.chatContainer.children.length, 3, "second shrink appends again, still no prune (no post-tool text)");
|
|
635
|
+
|
|
636
|
+
// MCP tool appears — tool-only window still keeps provisional prose visible.
|
|
637
|
+
await handleAgentEvent(
|
|
638
|
+
host,
|
|
639
|
+
{
|
|
640
|
+
type: "message_update",
|
|
641
|
+
message: makeAssistant([{ type: "text", text: "Third provisional." }, mcpTool]),
|
|
642
|
+
assistantMessageEvent: {
|
|
643
|
+
type: "toolcall_end",
|
|
644
|
+
contentIndex: 1,
|
|
645
|
+
toolCall: {
|
|
646
|
+
...mcpTool,
|
|
647
|
+
externalResult: {
|
|
648
|
+
content: [{ type: "text", text: "glob output" }],
|
|
649
|
+
details: {},
|
|
650
|
+
isError: false,
|
|
651
|
+
},
|
|
652
|
+
},
|
|
653
|
+
partial: makeAssistant([{ type: "text", text: "Third provisional." }, mcpTool]),
|
|
654
|
+
},
|
|
655
|
+
} as any,
|
|
656
|
+
);
|
|
657
|
+
assert.equal(host.chatContainer.children.length, 4, "tool-only window keeps all three provisional text-runs");
|
|
658
|
+
|
|
659
|
+
// Final post-tool text arrives — prune must drop ALL three pre-tool
|
|
660
|
+
// provisional text-runs across both shrinks, leaving only tool + final text.
|
|
661
|
+
const finalContent = [mcpTool, { type: "text", text: "Final answer." }];
|
|
662
|
+
await handleAgentEvent(
|
|
663
|
+
host,
|
|
664
|
+
{
|
|
665
|
+
type: "message_update",
|
|
666
|
+
message: makeAssistant(finalContent),
|
|
667
|
+
assistantMessageEvent: {
|
|
668
|
+
type: "text_delta",
|
|
669
|
+
contentIndex: 1,
|
|
670
|
+
delta: "Final answer.",
|
|
671
|
+
partial: makeAssistant(finalContent),
|
|
672
|
+
},
|
|
673
|
+
} as any,
|
|
674
|
+
);
|
|
675
|
+
assert.equal(
|
|
676
|
+
host.chatContainer.children.length,
|
|
677
|
+
2,
|
|
678
|
+
"all pre-tool provisional segments from every shrink must be pruned once post-tool prose arrives",
|
|
679
|
+
);
|
|
680
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "ToolExecutionComponent");
|
|
681
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "AssistantMessageComponent");
|
|
682
|
+
|
|
683
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant(finalContent) } as any);
|
|
684
|
+
});
|
|
685
|
+
|
|
237
686
|
test("chat-controller pins latest assistant text above editor when tool calls are present", async () => {
|
|
238
687
|
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
239
688
|
fg: (_key: string, text: string) => text,
|
|
@@ -466,3 +915,430 @@ test("chat-controller does not pin when there are no tool calls", async () => {
|
|
|
466
915
|
|
|
467
916
|
assert.equal(host.pinnedMessageContainer.children.length, 0, "pinned zone should stay empty without tool calls");
|
|
468
917
|
});
|
|
918
|
+
|
|
919
|
+
// Regression test for issue #4144: interleaved text/tool content must render in content[] index order.
|
|
920
|
+
// Stream: [text "A", toolCall T1, text "B", toolCall T2, text "C"]
|
|
921
|
+
// Expected chatContainer order: textRun(A), toolExec(T1), textRun(B), toolExec(T2), textRun(C)
|
|
922
|
+
// Each AssistantMessageComponent must render ONLY its own text — no duplication after message_end.
|
|
923
|
+
test("chat-controller renders interleaved text and tool blocks in content[] index order (#4144)", async () => {
|
|
924
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
925
|
+
fg: (_key: string, text: string) => text,
|
|
926
|
+
bg: (_key: string, text: string) => text,
|
|
927
|
+
bold: (text: string) => text,
|
|
928
|
+
italic: (text: string) => text,
|
|
929
|
+
truncate: (text: string) => text,
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
const host = createHost();
|
|
933
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
934
|
+
|
|
935
|
+
const t1 = { type: "toolCall", id: "t1", name: "tool_one", arguments: {} };
|
|
936
|
+
const t2 = { type: "toolCall", id: "t2", name: "tool_two", arguments: {} };
|
|
937
|
+
|
|
938
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
939
|
+
|
|
940
|
+
// Stream text "A" at index 0
|
|
941
|
+
await handleAgentEvent(host, {
|
|
942
|
+
type: "message_update",
|
|
943
|
+
message: makeAssistant([{ type: "text", text: "A" }]),
|
|
944
|
+
assistantMessageEvent: {
|
|
945
|
+
type: "text_delta",
|
|
946
|
+
contentIndex: 0,
|
|
947
|
+
delta: "A",
|
|
948
|
+
partial: makeAssistant([{ type: "text", text: "A" }]),
|
|
949
|
+
},
|
|
950
|
+
} as any);
|
|
951
|
+
|
|
952
|
+
// Stream toolCall T1 at index 1
|
|
953
|
+
await handleAgentEvent(host, {
|
|
954
|
+
type: "message_update",
|
|
955
|
+
message: makeAssistant([{ type: "text", text: "A" }, t1]),
|
|
956
|
+
assistantMessageEvent: {
|
|
957
|
+
type: "toolcall_end",
|
|
958
|
+
contentIndex: 1,
|
|
959
|
+
toolCall: {
|
|
960
|
+
...t1,
|
|
961
|
+
externalResult: { content: [{ type: "text", text: "result1" }], details: {}, isError: false },
|
|
962
|
+
},
|
|
963
|
+
partial: makeAssistant([{ type: "text", text: "A" }, t1]),
|
|
964
|
+
},
|
|
965
|
+
} as any);
|
|
966
|
+
|
|
967
|
+
// Stream text "B" at index 2
|
|
968
|
+
await handleAgentEvent(host, {
|
|
969
|
+
type: "message_update",
|
|
970
|
+
message: makeAssistant([{ type: "text", text: "A" }, t1, { type: "text", text: "B" }]),
|
|
971
|
+
assistantMessageEvent: {
|
|
972
|
+
type: "text_delta",
|
|
973
|
+
contentIndex: 2,
|
|
974
|
+
delta: "B",
|
|
975
|
+
partial: makeAssistant([{ type: "text", text: "A" }, t1, { type: "text", text: "B" }]),
|
|
976
|
+
},
|
|
977
|
+
} as any);
|
|
978
|
+
|
|
979
|
+
// Stream toolCall T2 at index 3
|
|
980
|
+
await handleAgentEvent(host, {
|
|
981
|
+
type: "message_update",
|
|
982
|
+
message: makeAssistant([{ type: "text", text: "A" }, t1, { type: "text", text: "B" }, t2]),
|
|
983
|
+
assistantMessageEvent: {
|
|
984
|
+
type: "toolcall_end",
|
|
985
|
+
contentIndex: 3,
|
|
986
|
+
toolCall: {
|
|
987
|
+
...t2,
|
|
988
|
+
externalResult: { content: [{ type: "text", text: "result2" }], details: {}, isError: false },
|
|
989
|
+
},
|
|
990
|
+
partial: makeAssistant([{ type: "text", text: "A" }, t1, { type: "text", text: "B" }, t2]),
|
|
991
|
+
},
|
|
992
|
+
} as any);
|
|
993
|
+
|
|
994
|
+
// Stream text "C" at index 4
|
|
995
|
+
const finalContent = [
|
|
996
|
+
{ type: "text", text: "A" }, t1, { type: "text", text: "B" }, t2, { type: "text", text: "C" },
|
|
997
|
+
];
|
|
998
|
+
await handleAgentEvent(host, {
|
|
999
|
+
type: "message_update",
|
|
1000
|
+
message: makeAssistant(finalContent),
|
|
1001
|
+
assistantMessageEvent: {
|
|
1002
|
+
type: "text_delta",
|
|
1003
|
+
contentIndex: 4,
|
|
1004
|
+
delta: "C",
|
|
1005
|
+
partial: makeAssistant(finalContent),
|
|
1006
|
+
},
|
|
1007
|
+
} as any);
|
|
1008
|
+
|
|
1009
|
+
// Finalize — exercises the message_end path where a buggy setRange(undefined) would cause duplication
|
|
1010
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant(finalContent) } as any);
|
|
1011
|
+
|
|
1012
|
+
// Assert interleaved order: textRun(A), toolExec(T1), textRun(B), toolExec(T2), textRun(C)
|
|
1013
|
+
assert.equal(host.chatContainer.children.length, 5, "should have 5 children in interleaved order");
|
|
1014
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent", "index 0: text run A");
|
|
1015
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "ToolExecutionComponent", "index 1: tool T1");
|
|
1016
|
+
assert.equal(host.chatContainer.children[2]?.constructor?.name, "AssistantMessageComponent", "index 2: text run B");
|
|
1017
|
+
assert.equal(host.chatContainer.children[3]?.constructor?.name, "ToolExecutionComponent", "index 3: tool T2");
|
|
1018
|
+
assert.equal(host.chatContainer.children[4]?.constructor?.name, "AssistantMessageComponent", "index 4: text run C");
|
|
1019
|
+
|
|
1020
|
+
// Helper: collect the text of all Markdown children inside an AssistantMessageComponent.
|
|
1021
|
+
// Structure: AssistantMessageComponent (Container) -> contentContainer (children[0]) -> Markdown nodes.
|
|
1022
|
+
function getRenderedTexts(comp: any): string[] {
|
|
1023
|
+
const contentContainer = comp.children?.[0];
|
|
1024
|
+
if (!contentContainer) return [];
|
|
1025
|
+
return (contentContainer.children ?? [])
|
|
1026
|
+
.filter((c: any) => c.constructor?.name === "Markdown")
|
|
1027
|
+
.map((c: any) => (c as any).text as string);
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
// Each text-run component must contain only its own text — no cross-contamination after message_end
|
|
1031
|
+
assert.deepEqual(getRenderedTexts(host.chatContainer.children[0]), ["A"], "text run A must contain only 'A'");
|
|
1032
|
+
assert.deepEqual(getRenderedTexts(host.chatContainer.children[2]), ["B"], "text run B must contain only 'B'");
|
|
1033
|
+
assert.deepEqual(getRenderedTexts(host.chatContainer.children[4]), ["C"], "text run C must contain only 'C'");
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
test("chat-controller does not duplicate text when content is [text, tool, text] (interleaved stream)", async () => {
|
|
1037
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
1038
|
+
fg: (_key: string, text: string) => text,
|
|
1039
|
+
bg: (_key: string, text: string) => text,
|
|
1040
|
+
bold: (text: string) => text,
|
|
1041
|
+
italic: (text: string) => text,
|
|
1042
|
+
truncate: (text: string) => text,
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
const host = createHost();
|
|
1046
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
1047
|
+
|
|
1048
|
+
const t1 = { type: "toolCall", id: "t1", name: "tool_one", arguments: {} };
|
|
1049
|
+
|
|
1050
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
1051
|
+
|
|
1052
|
+
// Step 1: text "A" at index 0
|
|
1053
|
+
await handleAgentEvent(host, {
|
|
1054
|
+
type: "message_update",
|
|
1055
|
+
message: makeAssistant([{ type: "text", text: "A" }]),
|
|
1056
|
+
assistantMessageEvent: {
|
|
1057
|
+
type: "text_delta",
|
|
1058
|
+
contentIndex: 0,
|
|
1059
|
+
delta: "A",
|
|
1060
|
+
partial: makeAssistant([{ type: "text", text: "A" }]),
|
|
1061
|
+
},
|
|
1062
|
+
} as any);
|
|
1063
|
+
|
|
1064
|
+
// Step 2: toolCall at index 1
|
|
1065
|
+
await handleAgentEvent(host, {
|
|
1066
|
+
type: "message_update",
|
|
1067
|
+
message: makeAssistant([{ type: "text", text: "A" }, t1]),
|
|
1068
|
+
assistantMessageEvent: {
|
|
1069
|
+
type: "toolcall_end",
|
|
1070
|
+
contentIndex: 1,
|
|
1071
|
+
toolCall: {
|
|
1072
|
+
...t1,
|
|
1073
|
+
externalResult: { content: [{ type: "text", text: "result1" }], details: {}, isError: false },
|
|
1074
|
+
},
|
|
1075
|
+
partial: makeAssistant([{ type: "text", text: "A" }, t1]),
|
|
1076
|
+
},
|
|
1077
|
+
} as any);
|
|
1078
|
+
|
|
1079
|
+
// Step 3: text "B" at index 2
|
|
1080
|
+
const finalContent = [{ type: "text", text: "A" }, t1, { type: "text", text: "B" }];
|
|
1081
|
+
await handleAgentEvent(host, {
|
|
1082
|
+
type: "message_update",
|
|
1083
|
+
message: makeAssistant(finalContent),
|
|
1084
|
+
assistantMessageEvent: {
|
|
1085
|
+
type: "text_delta",
|
|
1086
|
+
contentIndex: 2,
|
|
1087
|
+
delta: "B",
|
|
1088
|
+
partial: makeAssistant(finalContent),
|
|
1089
|
+
},
|
|
1090
|
+
} as any);
|
|
1091
|
+
|
|
1092
|
+
assert.equal(host.chatContainer.children.length, 3);
|
|
1093
|
+
assert.equal(host.chatContainer.children[0]?.constructor?.name, "AssistantMessageComponent");
|
|
1094
|
+
assert.equal(host.chatContainer.children[1]?.constructor?.name, "ToolExecutionComponent");
|
|
1095
|
+
assert.equal(host.chatContainer.children[2]?.constructor?.name, "AssistantMessageComponent");
|
|
1096
|
+
|
|
1097
|
+
const firstText = host.chatContainer.children[0];
|
|
1098
|
+
const secondText = host.chatContainer.children[2];
|
|
1099
|
+
assert.notEqual(firstText, secondText, "text-before-tool and text-after-tool must be separate component instances");
|
|
1100
|
+
assert.deepEqual((firstText as any).range, { startIndex: 0, endIndex: 0 }, "first text-run covers only content[0]");
|
|
1101
|
+
assert.deepEqual((secondText as any).range, { startIndex: 2, endIndex: 2 }, "second text-run covers only content[2]");
|
|
1102
|
+
|
|
1103
|
+
// Finalize — regression guard: range must NOT be cleared on message_end (would cause duplication)
|
|
1104
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant(finalContent) } as any);
|
|
1105
|
+
|
|
1106
|
+
assert.deepEqual((secondText as any).range, { startIndex: 2, endIndex: 2 }, "range must not be cleared on message_end (would cause duplication)");
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
// Regression for the claude-code sub-turn bug that followed #4144:
|
|
1110
|
+
// an adapter can reset content[] back to 0/1 mid-lifecycle when a new provider
|
|
1111
|
+
// sub-turn begins. The segment walker must NOT update prior-sub-turn text-run
|
|
1112
|
+
// components in place (which would destroy earlier history) and must NOT reuse
|
|
1113
|
+
// stale tool registrations for a new tool at the same contentIndex. Prior
|
|
1114
|
+
// sub-turn children must stay frozen; new sub-turn segments must append after
|
|
1115
|
+
// them, and the pinned "Latest Output" mirror must re-evaluate for the new sub-turn.
|
|
1116
|
+
test("chat-controller freezes prior sub-turn and appends new segments when content shrinks", async () => {
|
|
1117
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
1118
|
+
fg: (_key: string, text: string) => text,
|
|
1119
|
+
bg: (_key: string, text: string) => text,
|
|
1120
|
+
bold: (text: string) => text,
|
|
1121
|
+
italic: (text: string) => text,
|
|
1122
|
+
truncate: (text: string) => text,
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
const host = createHost();
|
|
1126
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
1127
|
+
|
|
1128
|
+
const t1 = { type: "toolCall", id: "t1", name: "tool_one", arguments: {} };
|
|
1129
|
+
const t2 = { type: "toolCall", id: "t2", name: "tool_two", arguments: {} };
|
|
1130
|
+
|
|
1131
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
1132
|
+
|
|
1133
|
+
// Sub-turn 1: grow to [A, T1, B]
|
|
1134
|
+
await handleAgentEvent(host, {
|
|
1135
|
+
type: "message_update",
|
|
1136
|
+
message: makeAssistant([{ type: "text", text: "A" }]),
|
|
1137
|
+
assistantMessageEvent: {
|
|
1138
|
+
type: "text_delta", contentIndex: 0, delta: "A",
|
|
1139
|
+
partial: makeAssistant([{ type: "text", text: "A" }]),
|
|
1140
|
+
},
|
|
1141
|
+
} as any);
|
|
1142
|
+
await handleAgentEvent(host, {
|
|
1143
|
+
type: "message_update",
|
|
1144
|
+
message: makeAssistant([{ type: "text", text: "A" }, t1]),
|
|
1145
|
+
assistantMessageEvent: {
|
|
1146
|
+
type: "toolcall_end", contentIndex: 1,
|
|
1147
|
+
toolCall: { ...t1, externalResult: { content: [{ type: "text", text: "r1" }], details: {}, isError: false } },
|
|
1148
|
+
partial: makeAssistant([{ type: "text", text: "A" }, t1]),
|
|
1149
|
+
},
|
|
1150
|
+
} as any);
|
|
1151
|
+
await handleAgentEvent(host, {
|
|
1152
|
+
type: "message_update",
|
|
1153
|
+
message: makeAssistant([{ type: "text", text: "A" }, t1, { type: "text", text: "B" }]),
|
|
1154
|
+
assistantMessageEvent: {
|
|
1155
|
+
type: "text_delta", contentIndex: 2, delta: "B",
|
|
1156
|
+
partial: makeAssistant([{ type: "text", text: "A" }, t1, { type: "text", text: "B" }]),
|
|
1157
|
+
},
|
|
1158
|
+
} as any);
|
|
1159
|
+
|
|
1160
|
+
assert.equal(host.chatContainer.children.length, 3, "sub-turn 1 renders 3 children");
|
|
1161
|
+
const priorA = host.chatContainer.children[0];
|
|
1162
|
+
const priorT1 = host.chatContainer.children[1];
|
|
1163
|
+
const priorB = host.chatContainer.children[2];
|
|
1164
|
+
|
|
1165
|
+
// Sub-turn boundary: adapter resets content[] to [C]
|
|
1166
|
+
await handleAgentEvent(host, {
|
|
1167
|
+
type: "message_update",
|
|
1168
|
+
message: makeAssistant([{ type: "text", text: "C" }]),
|
|
1169
|
+
assistantMessageEvent: {
|
|
1170
|
+
type: "text_delta", contentIndex: 0, delta: "C",
|
|
1171
|
+
partial: makeAssistant([{ type: "text", text: "C" }]),
|
|
1172
|
+
},
|
|
1173
|
+
} as any);
|
|
1174
|
+
|
|
1175
|
+
// Prior 3 children must still exist in DOM — and a NEW text-run for "C" appended after them.
|
|
1176
|
+
assert.equal(host.chatContainer.children.length, 4, "shrink must append new segment, not replace prior history");
|
|
1177
|
+
assert.equal(host.chatContainer.children[0], priorA, "prior A component stays at index 0");
|
|
1178
|
+
assert.equal(host.chatContainer.children[1], priorT1, "prior T1 component stays at index 1");
|
|
1179
|
+
assert.equal(host.chatContainer.children[2], priorB, "prior B component stays at index 2");
|
|
1180
|
+
assert.notEqual(host.chatContainer.children[3], priorA, "new C text-run must be a different component from prior A");
|
|
1181
|
+
assert.equal(host.chatContainer.children[3]?.constructor?.name, "AssistantMessageComponent");
|
|
1182
|
+
|
|
1183
|
+
// Prior A component must still render "A", not be overwritten with "C".
|
|
1184
|
+
function getRenderedTexts(comp: any): string[] {
|
|
1185
|
+
const contentContainer = comp.children?.[0];
|
|
1186
|
+
if (!contentContainer) return [];
|
|
1187
|
+
return (contentContainer.children ?? [])
|
|
1188
|
+
.filter((c: any) => c.constructor?.name === "Markdown")
|
|
1189
|
+
.map((c: any) => (c as any).text as string);
|
|
1190
|
+
}
|
|
1191
|
+
assert.deepEqual(getRenderedTexts(priorA), ["A"], "prior A text-run must still contain 'A' after shrink");
|
|
1192
|
+
assert.deepEqual(getRenderedTexts(priorB), ["B"], "prior B text-run must still contain 'B' after shrink");
|
|
1193
|
+
assert.deepEqual(getRenderedTexts(host.chatContainer.children[3]), ["C"], "new text-run must contain only 'C'");
|
|
1194
|
+
|
|
1195
|
+
// Sub-turn 2 grows with a new tool T2 at contentIndex=1.
|
|
1196
|
+
await handleAgentEvent(host, {
|
|
1197
|
+
type: "message_update",
|
|
1198
|
+
message: makeAssistant([{ type: "text", text: "C" }, t2]),
|
|
1199
|
+
assistantMessageEvent: {
|
|
1200
|
+
type: "toolcall_end", contentIndex: 1,
|
|
1201
|
+
toolCall: { ...t2, externalResult: { content: [{ type: "text", text: "r2" }], details: {}, isError: false } },
|
|
1202
|
+
partial: makeAssistant([{ type: "text", text: "C" }, t2]),
|
|
1203
|
+
},
|
|
1204
|
+
} as any);
|
|
1205
|
+
|
|
1206
|
+
// T2 must be appended after the new C text-run, not conflated with the stale T1 registration.
|
|
1207
|
+
assert.equal(host.chatContainer.children.length, 5, "new tool appends after new text-run");
|
|
1208
|
+
assert.equal(host.chatContainer.children[4]?.constructor?.name, "ToolExecutionComponent");
|
|
1209
|
+
assert.notEqual(host.chatContainer.children[4], priorT1, "new T2 must be a different component from prior T1");
|
|
1210
|
+
|
|
1211
|
+
// Finalize so the module-level pinned spinner (setInterval) is torn down and the test process can exit.
|
|
1212
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant([{ type: "text", text: "C" }, t2]) } as any);
|
|
1213
|
+
});
|
|
1214
|
+
|
|
1215
|
+
// Regression: after a sub-turn shrink, lastPinnedText must be cleared so the
|
|
1216
|
+
// pinned "Latest Output" mirror can display text from the new sub-turn instead
|
|
1217
|
+
// of staying frozen on a stale snapshot (the "bottom green stays" symptom).
|
|
1218
|
+
test("chat-controller updates pinned zone after sub-turn shrink", async () => {
|
|
1219
|
+
(globalThis as any)[Symbol.for("@gsd/pi-coding-agent:theme")] = {
|
|
1220
|
+
fg: (_key: string, text: string) => text,
|
|
1221
|
+
bg: (_key: string, text: string) => text,
|
|
1222
|
+
bold: (text: string) => text,
|
|
1223
|
+
italic: (text: string) => text,
|
|
1224
|
+
truncate: (text: string) => text,
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
const host = createHost();
|
|
1228
|
+
host.getMarkdownThemeWithSettings = () => ({});
|
|
1229
|
+
|
|
1230
|
+
const t1 = { type: "toolCall", id: "t1", name: "tool_one", arguments: {} };
|
|
1231
|
+
const t2 = { type: "toolCall", id: "t2", name: "tool_two", arguments: {} };
|
|
1232
|
+
|
|
1233
|
+
await handleAgentEvent(host, { type: "message_start", message: makeAssistant([]) } as any);
|
|
1234
|
+
|
|
1235
|
+
// Sub-turn 1 with pinnable text before a tool → populates pinned zone with "first".
|
|
1236
|
+
await handleAgentEvent(host, {
|
|
1237
|
+
type: "message_update",
|
|
1238
|
+
message: makeAssistant([{ type: "text", text: "first" }, t1]),
|
|
1239
|
+
assistantMessageEvent: {
|
|
1240
|
+
type: "toolcall_end", contentIndex: 1,
|
|
1241
|
+
toolCall: { ...t1, externalResult: { content: [{ type: "text", text: "r1" }], details: {}, isError: false } },
|
|
1242
|
+
partial: makeAssistant([{ type: "text", text: "first" }, t1]),
|
|
1243
|
+
},
|
|
1244
|
+
} as any);
|
|
1245
|
+
const pinnedMarkdown = host.pinnedMessageContainer.children[1];
|
|
1246
|
+
assert.equal((pinnedMarkdown as any)?.text, "first", "pinned zone seeded with sub-turn 1 text");
|
|
1247
|
+
|
|
1248
|
+
// Sub-turn boundary: content resets to [second, t2].
|
|
1249
|
+
await handleAgentEvent(host, {
|
|
1250
|
+
type: "message_update",
|
|
1251
|
+
message: makeAssistant([{ type: "text", text: "second" }, t2]),
|
|
1252
|
+
assistantMessageEvent: {
|
|
1253
|
+
type: "toolcall_end", contentIndex: 1,
|
|
1254
|
+
toolCall: { ...t2, externalResult: { content: [{ type: "text", text: "r2" }], details: {}, isError: false } },
|
|
1255
|
+
partial: makeAssistant([{ type: "text", text: "second" }, t2]),
|
|
1256
|
+
},
|
|
1257
|
+
} as any);
|
|
1258
|
+
|
|
1259
|
+
// Pinned markdown must now reflect the new sub-turn's text, not stay frozen on "first".
|
|
1260
|
+
assert.equal((pinnedMarkdown as any)?.text, "second", "pinned zone must update after sub-turn shrink (#4144 regression)");
|
|
1261
|
+
|
|
1262
|
+
// Finalize so the module-level pinned spinner (setInterval) is torn down and the test process can exit.
|
|
1263
|
+
await handleAgentEvent(host, { type: "message_end", message: makeAssistant([{ type: "text", text: "second" }, t2]) } as any);
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1266
|
+
test("chat-controller: agent_end without message_end must not remove streaming component from DOM (regression #4197)", async () => {
|
|
1267
|
+
const host = createHost();
|
|
1268
|
+
|
|
1269
|
+
await handleAgentEvent(host, {
|
|
1270
|
+
type: "message_start",
|
|
1271
|
+
message: makeAssistant([]),
|
|
1272
|
+
} as any);
|
|
1273
|
+
|
|
1274
|
+
// Simulate partial streaming that creates an AssistantMessageComponent
|
|
1275
|
+
await handleAgentEvent(host, {
|
|
1276
|
+
type: "message_update",
|
|
1277
|
+
message: makeAssistant([{ type: "text", text: "partial answer" }]),
|
|
1278
|
+
assistantMessageEvent: {
|
|
1279
|
+
type: "text_delta",
|
|
1280
|
+
contentIndex: 0,
|
|
1281
|
+
delta: "partial answer",
|
|
1282
|
+
partial: makeAssistant([{ type: "text", text: "partial answer" }]),
|
|
1283
|
+
},
|
|
1284
|
+
} as any);
|
|
1285
|
+
|
|
1286
|
+
// Precondition: component is in DOM
|
|
1287
|
+
assert.equal(
|
|
1288
|
+
host.chatContainer.children.length,
|
|
1289
|
+
1,
|
|
1290
|
+
"streaming component must be in DOM after message_update",
|
|
1291
|
+
);
|
|
1292
|
+
const comp = host.chatContainer.children[0];
|
|
1293
|
+
|
|
1294
|
+
// Simulate abort: agent_end fires WITHOUT message_end
|
|
1295
|
+
await handleAgentEvent(host, { type: "agent_end" } as any);
|
|
1296
|
+
|
|
1297
|
+
assert.equal(
|
|
1298
|
+
host.chatContainer.children.length,
|
|
1299
|
+
1,
|
|
1300
|
+
"agent_end must NOT remove the streaming component from the DOM (issue #4197)",
|
|
1301
|
+
);
|
|
1302
|
+
assert.equal(
|
|
1303
|
+
host.chatContainer.children[0],
|
|
1304
|
+
comp,
|
|
1305
|
+
"the same component instance must remain in the DOM after agent_end",
|
|
1306
|
+
);
|
|
1307
|
+
});
|
|
1308
|
+
|
|
1309
|
+
test("chat-controller: agent_end after message_end must not alter DOM", async () => {
|
|
1310
|
+
const host = createHost();
|
|
1311
|
+
const content = [{ type: "text", text: "complete answer" }];
|
|
1312
|
+
|
|
1313
|
+
await handleAgentEvent(host, {
|
|
1314
|
+
type: "message_start",
|
|
1315
|
+
message: makeAssistant([]),
|
|
1316
|
+
} as any);
|
|
1317
|
+
|
|
1318
|
+
await handleAgentEvent(host, {
|
|
1319
|
+
type: "message_update",
|
|
1320
|
+
message: makeAssistant(content),
|
|
1321
|
+
assistantMessageEvent: {
|
|
1322
|
+
type: "text_delta",
|
|
1323
|
+
contentIndex: 0,
|
|
1324
|
+
delta: "complete answer",
|
|
1325
|
+
partial: makeAssistant(content),
|
|
1326
|
+
},
|
|
1327
|
+
} as any);
|
|
1328
|
+
|
|
1329
|
+
await handleAgentEvent(host, {
|
|
1330
|
+
type: "message_end",
|
|
1331
|
+
message: makeAssistant(content),
|
|
1332
|
+
} as any);
|
|
1333
|
+
|
|
1334
|
+
const countAfterMessageEnd = host.chatContainer.children.length;
|
|
1335
|
+
assert.ok(countAfterMessageEnd > 0, "component must be present after message_end");
|
|
1336
|
+
|
|
1337
|
+
await handleAgentEvent(host, { type: "agent_end" } as any);
|
|
1338
|
+
|
|
1339
|
+
assert.equal(
|
|
1340
|
+
host.chatContainer.children.length,
|
|
1341
|
+
countAfterMessageEnd,
|
|
1342
|
+
"agent_end after message_end must not add or remove DOM nodes",
|
|
1343
|
+
);
|
|
1344
|
+
});
|