@polderlabs/bizar 6.2.4 → 6.3.0
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/.claude/CLAUDE.md +15 -0
- package/.claude/agents/_shared/AGENT_BASELINE.md +168 -0
- package/.claude/agents/_shared/CLAUDE_TOOLS.md +412 -0
- package/.claude/agents/_shared/SKILLS.md +109 -0
- package/.claude/agents/agent-browser.md +80 -0
- package/.claude/agents/baldr.md +49 -0
- package/.claude/agents/forseti.md +51 -0
- package/.claude/agents/frigg.md +42 -0
- package/.claude/agents/heimdall.md +33 -0
- package/.claude/agents/hermod.md +53 -0
- package/.claude/agents/mimir.md +49 -0
- package/.claude/agents/odin.md +287 -0
- package/.claude/agents/quick.md +34 -0
- package/.claude/agents/semble-search.md +50 -0
- package/.claude/agents/thor.md +53 -0
- package/.claude/agents/tyr.md +56 -0
- package/.claude/agents/vidarr.md +54 -0
- package/.claude/agents/vor.md +53 -0
- package/.claude/commands/audit.md +25 -0
- package/.claude/commands/bizar.md +22 -0
- package/.claude/commands/explain.md +17 -0
- package/.claude/commands/init.md +29 -0
- package/.claude/commands/learn.md +44 -0
- package/.claude/commands/plan.md +35 -0
- package/.claude/commands/plow-through.md +50 -0
- package/.claude/commands/pr-review.md +49 -0
- package/.claude/commands/setup-provider.md +96 -0
- package/.claude/commands/tailscale-serve.md +100 -0
- package/.claude/commands/team.md +132 -0
- package/.claude/commands/test.md +62 -0
- package/.claude/commands/validate.md +68 -0
- package/.claude/commands/visual-plan.md +24 -0
- package/.claude/hooks/README.md +92 -0
- package/.claude/hooks/posttooluse-editwrite.mjs +91 -0
- package/.claude/hooks/pretooluse-bash.mjs +81 -0
- package/.claude/hooks/pretooluse-editwrite.mjs +139 -0
- package/.claude/hooks/sessionend-recall.mjs +74 -0
- package/.claude/hooks/sessionstart-prime.mjs +80 -0
- package/.claude/hooks/userpromptsubmit-tag.mjs +80 -0
- package/.claude/settings.json +116 -0
- package/.claude/skills/9router/SKILL.md +80 -0
- package/.claude/skills/9router-chat/SKILL.md +73 -0
- package/.claude/skills/9router-embeddings/SKILL.md +69 -0
- package/.claude/skills/9router-image/SKILL.md +86 -0
- package/.claude/skills/9router-stt/SKILL.md +79 -0
- package/.claude/skills/9router-tts/SKILL.md +80 -0
- package/.claude/skills/9router-web-fetch/SKILL.md +99 -0
- package/.claude/skills/9router-web-search/SKILL.md +91 -0
- package/.claude/skills/bizar/README.md +9 -0
- package/.claude/skills/bizar/SKILL.md +450 -0
- package/.claude/skills/cpp-coding-standards/README.md +28 -0
- package/.claude/skills/cpp-coding-standards/SKILL.md +634 -0
- package/.claude/skills/cpp-coding-standards/references/concurrency.md +320 -0
- package/.claude/skills/cpp-coding-standards/references/error-handling.md +229 -0
- package/.claude/skills/cpp-coding-standards/references/memory-safety.md +216 -0
- package/.claude/skills/cpp-coding-standards/references/modern-idioms.md +282 -0
- package/.claude/skills/cpp-coding-standards/references/review-checklist.md +96 -0
- package/.claude/skills/cpp-testing/README.md +28 -0
- package/.claude/skills/cpp-testing/SKILL.md +304 -0
- package/.claude/skills/cpp-testing/references/coverage.md +370 -0
- package/.claude/skills/cpp-testing/references/framework-compare.md +175 -0
- package/.claude/skills/cpp-testing/references/host-test-for-embedded.md +499 -0
- package/.claude/skills/cpp-testing/references/mocking.md +364 -0
- package/.claude/skills/cpp-testing/references/tdd-workflow.md +308 -0
- package/.claude/skills/cubesandbox/SKILL.md +148 -0
- package/.claude/skills/embedded-esp-idf/README.md +41 -0
- package/.claude/skills/embedded-esp-idf/SKILL.md +439 -0
- package/.claude/skills/embedded-esp-idf/references/freertos-patterns.md +214 -0
- package/.claude/skills/embedded-esp-idf/references/host-tests.md +164 -0
- package/.claude/skills/embedded-esp-idf/references/idf-py-commands.md +157 -0
- package/.claude/skills/embedded-esp-idf/references/kconfig.md +159 -0
- package/.claude/skills/embedded-esp-idf/references/logging-discipline.md +118 -0
- package/.claude/skills/embedded-esp-idf/references/memory-and-iram.md +137 -0
- package/.claude/skills/embedded-esp-idf/references/nvs.md +121 -0
- package/.claude/skills/embedded-esp-idf/references/packed-structs.md +192 -0
- package/.claude/skills/embedded-esp-idf/scripts/idf_env.sh +47 -0
- package/.claude/skills/embedded-esp-idf/scripts/size_check.sh +77 -0
- package/.claude/skills/glyph/SKILL.md +163 -0
- package/.claude/skills/harness-engineering/SKILL.md +143 -0
- package/.claude/skills/lightrag/SKILL.md +81 -0
- package/.claude/skills/memory-protocol/SKILL.md +105 -0
- package/.claude/skills/obsidian/SKILL.md +306 -0
- package/.claude/skills/read-the-damn-docs/SKILL.md +113 -0
- package/.claude/skills/self-improvement/SKILL.md +64 -0
- package/README.md +87 -59
- package/bizar-dash/dist/assets/{EnvVarsSection-DXM8gRm_.js → EnvVarsSection-B58aiJiE.js} +1 -1
- package/bizar-dash/dist/assets/{EnvVarsSection-DXM8gRm_.js.map → EnvVarsSection-B58aiJiE.js.map} +1 -1
- package/bizar-dash/dist/assets/{MobileChat-BnKN_Ks_.js → MobileChat-BJrqwVDd.js} +1 -1
- package/bizar-dash/dist/assets/{MobileChat-BnKN_Ks_.js.map → MobileChat-BJrqwVDd.js.map} +1 -1
- package/bizar-dash/dist/assets/{MobileSettings-DjCPxC-Q.js → MobileSettings-CEQNJNLJ.js} +1 -1
- package/bizar-dash/dist/assets/{MobileSettings-DjCPxC-Q.js.map → MobileSettings-CEQNJNLJ.js.map} +1 -1
- package/bizar-dash/dist/assets/{main-DYiZqMrn.js → main-IvfQAOfy.js} +1 -1
- package/bizar-dash/dist/assets/{main-DYiZqMrn.js.map → main-IvfQAOfy.js.map} +1 -1
- package/bizar-dash/dist/assets/{markdown-C6mXtQxD.js → markdown-tOLaD6nm.js} +1 -1
- package/bizar-dash/dist/assets/{markdown-C6mXtQxD.js.map → markdown-tOLaD6nm.js.map} +1 -1
- package/bizar-dash/dist/assets/{mobile-CMHqtLV2.js → mobile-DYCHcUpq.js} +1 -1
- package/bizar-dash/dist/assets/{mobile-CMHqtLV2.js.map → mobile-DYCHcUpq.js.map} +1 -1
- package/bizar-dash/dist/assets/{mobile-layout-3jIhHX_p.js → mobile-layout-CBHjpwsb.js} +2 -2
- package/bizar-dash/dist/assets/{mobile-layout-3jIhHX_p.js.map → mobile-layout-CBHjpwsb.js.map} +1 -1
- package/bizar-dash/dist/assets/{useSlashCommands-DtITw8Xv.js → useSlashCommands-Bd7_FA6U.js} +2 -2
- package/bizar-dash/dist/assets/{useSlashCommands-DtITw8Xv.js.map → useSlashCommands-Bd7_FA6U.js.map} +1 -1
- package/bizar-dash/dist/assets/{vendor-CeHGtduv.js → vendor-C843201K.js} +12 -12
- package/bizar-dash/dist/assets/vendor-C843201K.js.map +1 -0
- package/bizar-dash/dist/index.html +6 -6
- package/bizar-dash/dist/mobile.html +2 -2
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/bizar-dash/src/server/api.mjs +4 -4
- package/bizar-dash/src/server/background-store.mjs +15 -16
- package/bizar-dash/src/server/bg-poller.mjs +25 -35
- package/bizar-dash/src/server/bg-retry.mjs +66 -194
- package/bizar-dash/src/server/claude-bg-spawner.mjs +390 -0
- package/bizar-dash/src/server/claude-info.mjs +412 -0
- package/bizar-dash/src/server/{cline-runner.mjs → claude-runner.mjs} +53 -48
- package/bizar-dash/src/server/claude-sdk.mjs +191 -0
- package/bizar-dash/src/server/providers-store.mjs +22 -49
- package/bizar-dash/src/server/routes/background.mjs +24 -20
- package/bizar-dash/src/server/routes/chat.mjs +223 -326
- package/bizar-dash/src/server/routes/claude-session-detail.mjs +329 -0
- package/bizar-dash/src/server/routes/claude-sessions.mjs +259 -0
- package/bizar-dash/src/server/routes/tasks.mjs +20 -28
- package/bizar-dash/src/server/task-delegator.mjs +76 -77
- package/bizar-dash/src/web/components/chat/useChat.ts +23 -27
- package/bizar-dash/src/web/views/Chat.tsx +8 -8
- package/cli/bin.mjs +31 -18
- package/cli/commands/claude-cmd.mjs +348 -0
- package/cli/commands/install.mjs +12 -11
- package/cli/commands/sandbox.mjs +220 -0
- package/cli/commands/validate.mjs +252 -288
- package/cli/dev-link.test.mjs +11 -11
- package/cli/doctor.mjs +131 -213
- package/cli/install.mjs +33 -37
- package/cli/install.test.mjs +9 -9
- package/cli/provision-claude.mjs +893 -0
- package/cli/provision.mjs +330 -226
- package/cli/provision.test.mjs +102 -0
- package/cli/utils.mjs +72 -58
- package/config/AGENTS.md +28 -28
- package/config/agents/_shared/AGENT_BASELINE.md +104 -684
- package/config/skills/bizar/SKILL.md +197 -0
- package/config/skills/cubesandbox/SKILL.md +148 -0
- package/config/skills/harness-engineering/SKILL.md +142 -0
- package/install.sh +66 -44
- package/package.json +19 -11
- package/packages/sdk/ARCHITECTURE.md +40 -36
- package/packages/sdk/package-lock.json +32 -0
- package/packages/sdk/package.json +15 -5
- package/{plugins/bizar → packages/sdk}/src/dangerous-patterns.ts +6 -28
- package/packages/sdk/src/fingerprint.ts +0 -0
- package/packages/sdk/src/index.ts +38 -73
- package/packages/sdk/src/mcp/bin.ts +51 -0
- package/packages/sdk/src/mcp/server.ts +498 -0
- package/{plugins/bizar/src/memory-vault.ts → packages/sdk/src/memory/index.ts} +18 -21
- package/packages/sdk/tests/sdk.test.mjs +148 -0
- package/packages/sdk/vitest.config.ts +1 -1
- package/scripts/bh-full-e2e.mjs +166 -363
- package/scripts/check-deps.mjs +28 -46
- package/scripts/mirror-claude-md.sh +78 -0
- package/scripts/test-in-container.sh +157 -0
- package/templates/clean-state-checklist.md +3 -3
- package/templates/sprint-contract.md +2 -2
- package/bizar-dash/.bizar/activity.log +0 -3
- package/bizar-dash/.omx/logs/omx-2026-07-07.jsonl +0 -1
- package/bizar-dash/.omx/state/session.json +0 -10
- package/bizar-dash/bizar-design/EXPLANATION.md +0 -307
- package/bizar-dash/bizar-design/INSTRUCTIONS.md +0 -149
- package/bizar-dash/bizar-design/canvas.html +0 -281
- package/bizar-dash/bizar-design/canvas.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/components.css +0 -1665
- package/bizar-dash/bizar-design/components.html +0 -557
- package/bizar-dash/bizar-design/components.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/agents.html +0 -74
- package/bizar-dash/bizar-design/desktop/agents.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/memory.html +0 -75
- package/bizar-dash/bizar-design/desktop/memory.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/metrics.html +0 -63
- package/bizar-dash/bizar-design/desktop/metrics.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/overview.html +0 -95
- package/bizar-dash/bizar-design/desktop/overview.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/settings.html +0 -70
- package/bizar-dash/bizar-design/desktop/settings.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/icons.svg +0 -44
- package/bizar-dash/bizar-design/index.html +0 -192
- package/bizar-dash/bizar-design/index.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/agents.html +0 -29
- package/bizar-dash/bizar-design/mobile/agents.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/memory.html +0 -28
- package/bizar-dash/bizar-design/mobile/memory.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/metrics.html +0 -29
- package/bizar-dash/bizar-design/mobile/metrics.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/overview.html +0 -33
- package/bizar-dash/bizar-design/mobile/overview.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/settings.html +0 -28
- package/bizar-dash/bizar-design/mobile/settings.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/prototype.js +0 -114
- package/bizar-dash/bizar-design/tokens.css +0 -106
- package/bizar-dash/dist/assets/vendor-CeHGtduv.js.map +0 -1
- package/bizar-dash/node_modules/.package-lock.json +0 -6
- package/bizar-dash/package-lock.json +0 -6
- package/bizar-dash/src/server/cline-sdk.mjs +0 -132
- package/bizar-dash/src/server/routes/cline-session-detail.mjs +0 -559
- package/bizar-dash/src/server/routes/cline-sessions.mjs +0 -291
- package/cli/commands/cline-cmd.mjs +0 -289
- package/cli/commands/validate.test.mjs +0 -344
- package/cli/doctor.test.mjs +0 -350
- package/config/cline.json.template +0 -342
- package/packages/sdk/src/client.ts +0 -188
- package/packages/sdk/src/cline-events.ts +0 -134
- package/packages/sdk/src/cline-types.ts +0 -66
- package/packages/sdk/src/cline.ts +0 -339
- package/packages/sdk/src/errors.ts +0 -129
- package/packages/sdk/src/events.ts +0 -153
- package/packages/sdk/src/types.ts +0 -176
- package/packages/sdk/tests/client.test.ts +0 -217
- package/packages/sdk/tests/errors.test.ts +0 -108
- package/packages/sdk/tests/events.test.ts +0 -139
- package/packages/sdk/tests/fixtures/fetch-mock.ts +0 -152
- package/packages/sdk/tests/fixtures/sse-mock.ts +0 -30
- package/plugins/bizar/ARCHITECTURE.md +0 -142
- package/plugins/bizar/CONSTRAINTS.md +0 -67
- package/plugins/bizar/LICENSE +0 -21
- package/plugins/bizar/README.md +0 -448
- package/plugins/bizar/index.ts +0 -872
- package/plugins/bizar/package.json +0 -39
- package/plugins/bizar/scripts/check-forbidden-imports.sh +0 -33
- package/plugins/bizar/src/background-state.ts +0 -641
- package/plugins/bizar/src/background.ts +0 -1806
- package/plugins/bizar/src/cline-runner.ts +0 -203
- package/plugins/bizar/src/clineruntime.ts +0 -227
- package/plugins/bizar/src/commands-impl.ts +0 -151
- package/plugins/bizar/src/commands.ts +0 -1799
- package/plugins/bizar/src/compaction.d.mts +0 -48
- package/plugins/bizar/src/compaction.mjs +0 -192
- package/plugins/bizar/src/dashboard-client.ts +0 -233
- package/plugins/bizar/src/event-stream.ts +0 -606
- package/plugins/bizar/src/fingerprint.ts +0 -120
- package/plugins/bizar/src/handoff.ts +0 -79
- package/plugins/bizar/src/hooks/memory-flush-on-compact.ts +0 -123
- package/plugins/bizar/src/hooks/memory-inject.ts +0 -247
- package/plugins/bizar/src/hooks/memory-write-on-end.ts +0 -188
- package/plugins/bizar/src/hooks/skill-curator.ts +0 -180
- package/plugins/bizar/src/http-client.ts +0 -467
- package/plugins/bizar/src/key-rotation.ts +0 -218
- package/plugins/bizar/src/logger.ts +0 -144
- package/plugins/bizar/src/loop-engineering.ts +0 -241
- package/plugins/bizar/src/loop.ts +0 -176
- package/plugins/bizar/src/mistake-recovery.ts +0 -98
- package/plugins/bizar/src/odin.ts +0 -227
- package/plugins/bizar/src/options.ts +0 -470
- package/plugins/bizar/src/plan-fs.ts +0 -323
- package/plugins/bizar/src/reasoning-clean.ts +0 -454
- package/plugins/bizar/src/report.ts +0 -178
- package/plugins/bizar/src/research-prompt.ts +0 -35
- package/plugins/bizar/src/serve-info.ts +0 -228
- package/plugins/bizar/src/serve.ts +0 -496
- package/plugins/bizar/src/settings.ts +0 -349
- package/plugins/bizar/src/state.ts +0 -298
- package/plugins/bizar/src/tool-discipline.ts +0 -105
- package/plugins/bizar/src/tools/agent-browser.ts +0 -315
- package/plugins/bizar/src/tools/bg-collect.ts +0 -131
- package/plugins/bizar/src/tools/bg-get-comments.ts +0 -266
- package/plugins/bizar/src/tools/bg-kill.ts +0 -116
- package/plugins/bizar/src/tools/bg-pause.ts +0 -99
- package/plugins/bizar/src/tools/bg-report-progress.ts +0 -115
- package/plugins/bizar/src/tools/bg-resume.ts +0 -94
- package/plugins/bizar/src/tools/bg-send-message.ts +0 -223
- package/plugins/bizar/src/tools/bg-spawn.ts +0 -502
- package/plugins/bizar/src/tools/bg-status.ts +0 -130
- package/plugins/bizar/src/tools/graph-query.ts +0 -278
- package/plugins/bizar/src/tools/loop-engineering.ts +0 -193
- package/plugins/bizar/src/tools/memory-list.ts +0 -43
- package/plugins/bizar/src/tools/memory-read.ts +0 -69
- package/plugins/bizar/src/tools/memory-search.ts +0 -47
- package/plugins/bizar/src/tools/memory-write.ts +0 -54
- package/plugins/bizar/src/tools/open-kb.ts +0 -198
- package/plugins/bizar/src/tools/plan-action.ts +0 -785
- package/plugins/bizar/src/tools/read-glyph-feedback.ts +0 -191
- package/plugins/bizar/src/tools/team-spawn.ts +0 -73
- package/plugins/bizar/src/tools/team-status.ts +0 -76
- package/plugins/bizar/src/tools/wait-for-feedback.ts +0 -415
- package/plugins/bizar/src/trajectory.ts +0 -104
- package/plugins/bizar/tests/README.md +0 -99
- package/plugins/bizar/tests/attach-handler-bug.test.ts +0 -169
- package/plugins/bizar/tests/background-state.test.ts +0 -277
- package/plugins/bizar/tests/background.test.ts +0 -402
- package/plugins/bizar/tests/block.test.ts +0 -195
- package/plugins/bizar/tests/canonical-key-order.test.ts +0 -75
- package/plugins/bizar/tests/clineruntime-config.test.ts +0 -283
- package/plugins/bizar/tests/commands-impl.test.ts +0 -316
- package/plugins/bizar/tests/commands.test.ts +0 -584
- package/plugins/bizar/tests/compaction.test.ts +0 -264
- package/plugins/bizar/tests/config.test.ts +0 -128
- package/plugins/bizar/tests/dashboard-client.test.ts +0 -159
- package/plugins/bizar/tests/dispose.test.ts +0 -336
- package/plugins/bizar/tests/event-stream.test.ts +0 -409
- package/plugins/bizar/tests/event.test.ts +0 -262
- package/plugins/bizar/tests/fingerprint.test.ts +0 -162
- package/plugins/bizar/tests/http-client.test.ts +0 -404
- package/plugins/bizar/tests/init-helpers.test.ts +0 -203
- package/plugins/bizar/tests/integration/slash-command.test.ts +0 -349
- package/plugins/bizar/tests/integration/tool-routing.test.ts +0 -98
- package/plugins/bizar/tests/key-rotation.test.ts +0 -396
- package/plugins/bizar/tests/loop-engineering.test.ts +0 -168
- package/plugins/bizar/tests/loop.test.ts +0 -397
- package/plugins/bizar/tests/memory-write-on-end.test.ts +0 -92
- package/plugins/bizar/tests/mistake-recovery.test.ts +0 -116
- package/plugins/bizar/tests/odin.test.ts +0 -125
- package/plugins/bizar/tests/options.test.ts +0 -329
- package/plugins/bizar/tests/reasoning-clean.test.ts +0 -422
- package/plugins/bizar/tests/safety.test.ts +0 -256
- package/plugins/bizar/tests/serve.test.ts +0 -339
- package/plugins/bizar/tests/settings.test.ts +0 -351
- package/plugins/bizar/tests/stall-think.test.ts +0 -750
- package/plugins/bizar/tests/state.test.ts +0 -276
- package/plugins/bizar/tests/tool-discipline.test.ts +0 -77
- package/plugins/bizar/tests/tools/agent-browser.test.ts +0 -98
- package/plugins/bizar/tests/tools/bg-collect.test.ts +0 -337
- package/plugins/bizar/tests/tools/bg-get-comments.test.ts +0 -485
- package/plugins/bizar/tests/tools/bg-kill.test.ts +0 -235
- package/plugins/bizar/tests/tools/bg-pause.test.ts +0 -61
- package/plugins/bizar/tests/tools/bg-report-progress.test.ts +0 -79
- package/plugins/bizar/tests/tools/bg-resume.test.ts +0 -40
- package/plugins/bizar/tests/tools/bg-send-message.test.ts +0 -116
- package/plugins/bizar/tests/tools/bg-spawn-delegation.test.ts +0 -147
- package/plugins/bizar/tests/tools/bg-spawn-http.test.ts +0 -233
- package/plugins/bizar/tests/tools/bg-spawn.test.ts +0 -311
- package/plugins/bizar/tests/tools/bg-status.test.ts +0 -217
- package/plugins/bizar/tests/tools/cline-runner.test.ts +0 -115
- package/plugins/bizar/tests/tools/plan-action.test.ts +0 -599
- package/plugins/bizar/tests/tools/read-glyph-feedback.test.ts +0 -253
- package/plugins/bizar/tests/tools/wait-for-feedback.test.ts +0 -390
- package/plugins/bizar/tests/update-deadlock.test.ts +0 -151
- package/plugins/bizar/tsconfig.json +0 -29
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type definitions matching .bizar/research/OPENAPI_SPEC.yaml.
|
|
3
|
-
*
|
|
4
|
-
* Hand-written in v0.7.0-alpha.1. In v0.7.1 these will be auto-generated
|
|
5
|
-
* via @hey-api/openapi-ts. Keep this file in sync with OPENAPI_SPEC.yaml
|
|
6
|
-
* until codegen is wired.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// ─── Session ────────────────────────────────────────────────────────────
|
|
10
|
-
|
|
11
|
-
export type SessionStatus =
|
|
12
|
-
| "pending"
|
|
13
|
-
| "running"
|
|
14
|
-
| "done"
|
|
15
|
-
| "failed"
|
|
16
|
-
| "killed"
|
|
17
|
-
| "timed_out";
|
|
18
|
-
|
|
19
|
-
export type Session = {
|
|
20
|
-
id: string;
|
|
21
|
-
clineSessionId?: string;
|
|
22
|
-
agent: string;
|
|
23
|
-
status: SessionStatus;
|
|
24
|
-
parentId?: string;
|
|
25
|
-
model?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
toolCallCount: number;
|
|
28
|
-
resultPreview?: string;
|
|
29
|
-
worktree: string;
|
|
30
|
-
createdAt: number;
|
|
31
|
-
updatedAt: number;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export type SessionCreate = {
|
|
35
|
-
agent: string;
|
|
36
|
-
prompt: string;
|
|
37
|
-
model?: string;
|
|
38
|
-
parentId?: string;
|
|
39
|
-
timeoutMs?: number;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type SessionListQuery = {
|
|
43
|
-
status?: SessionStatus;
|
|
44
|
-
agent?: string;
|
|
45
|
-
limit?: number;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// ─── Project ────────────────────────────────────────────────────────────
|
|
49
|
-
|
|
50
|
-
export type Project = {
|
|
51
|
-
id: string;
|
|
52
|
-
name: string;
|
|
53
|
-
path: string;
|
|
54
|
-
bankId?: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// ─── Plan ───────────────────────────────────────────────────────────────
|
|
58
|
-
|
|
59
|
-
export type PlanStatus = "draft" | "approved" | "rejected" | "in-progress" | "done";
|
|
60
|
-
|
|
61
|
-
export type Plan = {
|
|
62
|
-
slug: string;
|
|
63
|
-
title: string;
|
|
64
|
-
status: PlanStatus;
|
|
65
|
-
createdAt?: number;
|
|
66
|
-
updatedAt?: number;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// ─── Part (discriminated by `type`) ─────────────────────────────────────
|
|
70
|
-
|
|
71
|
-
export type TextPart = {
|
|
72
|
-
type: "text";
|
|
73
|
-
text: string;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export type ToolCallPart = {
|
|
77
|
-
type: "tool_call";
|
|
78
|
-
toolName: string;
|
|
79
|
-
args: Record<string, unknown>;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export type ToolResultPart = {
|
|
83
|
-
type: "tool_result";
|
|
84
|
-
toolName: string;
|
|
85
|
-
result: Record<string, unknown>;
|
|
86
|
-
isError?: boolean;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type ReasoningPart = {
|
|
90
|
-
type: "reasoning";
|
|
91
|
-
text: string;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type Part = TextPart | ToolCallPart | ToolResultPart | ReasoningPart;
|
|
95
|
-
|
|
96
|
-
// ─── Event (discriminated by `type`) ────────────────────────────────────
|
|
97
|
-
|
|
98
|
-
export type DashboardConnectedEvent = {
|
|
99
|
-
type: "dashboard.connected";
|
|
100
|
-
properties: Record<string, never>;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export type SessionCreatedEvent = {
|
|
104
|
-
type: "session.created";
|
|
105
|
-
properties: {
|
|
106
|
-
sessionId: string;
|
|
107
|
-
agent: string;
|
|
108
|
-
};
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export type SessionUpdatedEvent = {
|
|
112
|
-
type: "session.updated";
|
|
113
|
-
properties: {
|
|
114
|
-
sessionId: string;
|
|
115
|
-
status: SessionStatus;
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export type SessionIdleEvent = {
|
|
120
|
-
type: "session.idle";
|
|
121
|
-
properties: {
|
|
122
|
-
sessionId: string;
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
export type SessionErrorEvent = {
|
|
127
|
-
type: "session.error";
|
|
128
|
-
properties: {
|
|
129
|
-
sessionId: string;
|
|
130
|
-
error: string;
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
export type MessagePartUpdatedEvent = {
|
|
135
|
-
type: "message.part.updated";
|
|
136
|
-
properties: {
|
|
137
|
-
sessionId: string;
|
|
138
|
-
messageId: string;
|
|
139
|
-
part: Part;
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export type ToolExecutedEvent = {
|
|
144
|
-
type: "tool.executed";
|
|
145
|
-
properties: {
|
|
146
|
-
sessionId: string;
|
|
147
|
-
toolName: string;
|
|
148
|
-
durationMs?: number;
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export type PlanUpdatedEvent = {
|
|
153
|
-
type: "plan.updated";
|
|
154
|
-
properties: {
|
|
155
|
-
slug: string;
|
|
156
|
-
status: PlanStatus;
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export type DashboardEvent =
|
|
161
|
-
| DashboardConnectedEvent
|
|
162
|
-
| SessionCreatedEvent
|
|
163
|
-
| SessionUpdatedEvent
|
|
164
|
-
| SessionIdleEvent
|
|
165
|
-
| SessionErrorEvent
|
|
166
|
-
| MessagePartUpdatedEvent
|
|
167
|
-
| ToolExecutedEvent
|
|
168
|
-
| PlanUpdatedEvent;
|
|
169
|
-
|
|
170
|
-
// ─── Health ─────────────────────────────────────────────────────────────
|
|
171
|
-
|
|
172
|
-
export type Health = {
|
|
173
|
-
status: "ok" | "degraded";
|
|
174
|
-
uptime: number;
|
|
175
|
-
version: string;
|
|
176
|
-
};
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the createBizarClient factory and its resource methods.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
6
|
-
import { createBizarClient } from "../src/client.js";
|
|
7
|
-
import { isBizarError, type BizarError } from "../src/errors.js";
|
|
8
|
-
import type { Session } from "../src/types.js";
|
|
9
|
-
import { makeFetchMock, type FetchMock } from "./fixtures/fetch-mock.js";
|
|
10
|
-
|
|
11
|
-
describe("createBizarClient", () => {
|
|
12
|
-
let m: FetchMock;
|
|
13
|
-
|
|
14
|
-
beforeEach(() => {
|
|
15
|
-
m = makeFetchMock();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("attaches HTTP basic auth header with username 'cline'", async () => {
|
|
19
|
-
m.respondWith("GET", "/sessions", { status: 200, body: "[]" });
|
|
20
|
-
|
|
21
|
-
const client = createBizarClient({
|
|
22
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
23
|
-
password: "secret123",
|
|
24
|
-
fetch: m.fetch,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const result = await client.sessions.list();
|
|
28
|
-
expect(isBizarError(result)).toBe(false);
|
|
29
|
-
expect(m.lastRequest).not.toBeNull();
|
|
30
|
-
expect(m.lastRequest!.headers["Authorization"]).toBe(
|
|
31
|
-
`Basic ${Buffer.from("cline:secret123").toString("base64")}`,
|
|
32
|
-
);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("GET /sessions returns an array of sessions on 200", async () => {
|
|
36
|
-
const sessions: Session[] = [
|
|
37
|
-
{
|
|
38
|
-
id: "bgr_1",
|
|
39
|
-
agent: "mimir",
|
|
40
|
-
status: "running",
|
|
41
|
-
toolCallCount: 0,
|
|
42
|
-
worktree: "/tmp",
|
|
43
|
-
createdAt: 1,
|
|
44
|
-
updatedAt: 2,
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
m.respondWith("GET", "/sessions", { status: 200, body: JSON.stringify(sessions) });
|
|
48
|
-
|
|
49
|
-
const client = createBizarClient({
|
|
50
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
51
|
-
password: "x",
|
|
52
|
-
fetch: m.fetch,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const result = await client.sessions.list();
|
|
56
|
-
expect(isBizarError(result)).toBe(false);
|
|
57
|
-
expect(result).toEqual(sessions);
|
|
58
|
-
expect(m.lastRequest!.method).toBe("GET");
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("POST /sessions sends JSON body and returns 201 session", async () => {
|
|
62
|
-
const created: Session = {
|
|
63
|
-
id: "bgr_2",
|
|
64
|
-
agent: "thor",
|
|
65
|
-
status: "pending",
|
|
66
|
-
toolCallCount: 0,
|
|
67
|
-
worktree: "/tmp",
|
|
68
|
-
createdAt: 1,
|
|
69
|
-
updatedAt: 1,
|
|
70
|
-
};
|
|
71
|
-
m.respondWith("POST", "/sessions", { status: 201, body: JSON.stringify(created) });
|
|
72
|
-
|
|
73
|
-
const client = createBizarClient({
|
|
74
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
75
|
-
password: "x",
|
|
76
|
-
fetch: m.fetch,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const result = await client.sessions.create({
|
|
80
|
-
agent: "thor",
|
|
81
|
-
prompt: "hello",
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
expect(isBizarError(result)).toBe(false);
|
|
85
|
-
expect(result).toEqual(created);
|
|
86
|
-
expect(m.lastRequest!.method).toBe("POST");
|
|
87
|
-
expect(m.lastRequest!.headers["Content-Type"]).toBe("application/json");
|
|
88
|
-
const body = JSON.parse(m.lastRequest!.body!);
|
|
89
|
-
expect(body.agent).toBe("thor");
|
|
90
|
-
expect(body.prompt).toBe("hello");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("DELETE /sessions/:id returns null on 204", async () => {
|
|
94
|
-
m.respondWith("DELETE", "/sessions/bgr_2", { status: 204, body: "" });
|
|
95
|
-
|
|
96
|
-
const client = createBizarClient({
|
|
97
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
98
|
-
password: "x",
|
|
99
|
-
fetch: m.fetch,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const result = await client.sessions.abort({ sessionId: "bgr_2" });
|
|
103
|
-
expect(isBizarError(result)).toBe(false);
|
|
104
|
-
expect(result).toBeNull();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("returns a DashboardError on 4xx (not thrown by default)", async () => {
|
|
108
|
-
m.respondWith("GET", "/sessions/missing", {
|
|
109
|
-
status: 404,
|
|
110
|
-
body: JSON.stringify({ name: "DashboardError", data: { statusCode: 404, message: "Session not found" } }),
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const client = createBizarClient({
|
|
114
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
115
|
-
password: "x",
|
|
116
|
-
fetch: m.fetch,
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const result = await client.sessions.get({ sessionId: "missing" });
|
|
120
|
-
expect(isBizarError(result)).toBe(true);
|
|
121
|
-
if (isBizarError(result)) {
|
|
122
|
-
expect(result.name).toBe("DashboardError");
|
|
123
|
-
if (result.name === "DashboardError") {
|
|
124
|
-
expect(result.data.statusCode).toBe(404);
|
|
125
|
-
expect(result.data.message).toBe("Session not found");
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
it("returns an APIError on 5xx with isRetryable=true", async () => {
|
|
131
|
-
m.respondWith("GET", "/sessions", { status: 503, body: "service unavailable" });
|
|
132
|
-
|
|
133
|
-
const client = createBizarClient({
|
|
134
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
135
|
-
password: "x",
|
|
136
|
-
fetch: m.fetch,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const result = await client.sessions.list();
|
|
140
|
-
expect(isBizarError(result)).toBe(true);
|
|
141
|
-
if (isBizarError(result)) {
|
|
142
|
-
expect(result.name).toBe("APIError");
|
|
143
|
-
if (result.name === "APIError") {
|
|
144
|
-
expect(result.data.statusCode).toBe(503);
|
|
145
|
-
expect(result.data.isRetryable).toBe(true);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it("returns a ConnectionError when fetch throws", async () => {
|
|
151
|
-
m.respondWithError("GET", "/health", new TypeError("fetch failed"));
|
|
152
|
-
|
|
153
|
-
const client = createBizarClient({
|
|
154
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
155
|
-
password: "x",
|
|
156
|
-
fetch: m.fetch,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const result = await client.health.check();
|
|
160
|
-
expect(isBizarError(result)).toBe(true);
|
|
161
|
-
if (isBizarError(result)) {
|
|
162
|
-
expect(result.name).toBe("ConnectionError");
|
|
163
|
-
if (result.name === "ConnectionError") {
|
|
164
|
-
expect(result.data.message).toContain("fetch failed");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("throws when throwOnError=true", async () => {
|
|
170
|
-
m.respondWithError("GET", "/sessions", new TypeError("connection refused"));
|
|
171
|
-
|
|
172
|
-
const client = createBizarClient({
|
|
173
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
174
|
-
password: "x",
|
|
175
|
-
fetch: m.fetch,
|
|
176
|
-
throwOnError: true,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
await expect(client.sessions.list()).rejects.toMatchObject({
|
|
180
|
-
name: "ConnectionError",
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it("sends query parameters for sessions.list", async () => {
|
|
185
|
-
m.respondWith("GET", "/sessions", { status: 200, body: "[]" });
|
|
186
|
-
|
|
187
|
-
const client = createBizarClient({
|
|
188
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
189
|
-
password: "x",
|
|
190
|
-
fetch: m.fetch,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
await client.sessions.list({ status: "running", limit: 25 });
|
|
194
|
-
expect(m.lastRequest!.url).toContain("status=running");
|
|
195
|
-
expect(m.lastRequest!.url).toContain("limit=25");
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("publishes a DashboardEvent via POST /event", async () => {
|
|
199
|
-
m.respondWith("POST", "/event", { status: 204, body: "" });
|
|
200
|
-
|
|
201
|
-
const client = createBizarClient({
|
|
202
|
-
baseUrl: "http://127.0.0.1:4098",
|
|
203
|
-
password: "x",
|
|
204
|
-
fetch: m.fetch,
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
const result = await client.events.publish({
|
|
208
|
-
type: "session.created",
|
|
209
|
-
properties: { sessionId: "ses_1", agent: "mimir" },
|
|
210
|
-
});
|
|
211
|
-
expect(isBizarError(result)).toBe(false);
|
|
212
|
-
|
|
213
|
-
const body = JSON.parse(m.lastRequest!.body!);
|
|
214
|
-
expect(body.type).toBe("session.created");
|
|
215
|
-
expect(body.properties.sessionId).toBe("ses_1");
|
|
216
|
-
});
|
|
217
|
-
});
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the discriminated error model.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect } from "vitest";
|
|
6
|
-
import {
|
|
7
|
-
isBizarError,
|
|
8
|
-
connectionErrorFrom,
|
|
9
|
-
dashboardErrorFrom,
|
|
10
|
-
apiErrorFrom,
|
|
11
|
-
} from "../src/errors.js";
|
|
12
|
-
|
|
13
|
-
describe("isBizarError", () => {
|
|
14
|
-
it("returns true for PluginError", () => {
|
|
15
|
-
expect(
|
|
16
|
-
isBizarError({
|
|
17
|
-
name: "PluginError",
|
|
18
|
-
data: { code: "X", message: "y" },
|
|
19
|
-
}),
|
|
20
|
-
).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("returns true for DashboardError", () => {
|
|
24
|
-
expect(
|
|
25
|
-
isBizarError({
|
|
26
|
-
name: "DashboardError",
|
|
27
|
-
data: { statusCode: 401, message: "unauth" },
|
|
28
|
-
}),
|
|
29
|
-
).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("returns true for ConnectionError", () => {
|
|
33
|
-
expect(
|
|
34
|
-
isBizarError({
|
|
35
|
-
name: "ConnectionError",
|
|
36
|
-
data: { message: "fetch failed" },
|
|
37
|
-
}),
|
|
38
|
-
).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("returns true for APIError", () => {
|
|
42
|
-
expect(
|
|
43
|
-
isBizarError({
|
|
44
|
-
name: "APIError",
|
|
45
|
-
data: { statusCode: 500, isRetryable: true, message: "boom" },
|
|
46
|
-
}),
|
|
47
|
-
).toBe(true);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("returns false for unknown shapes", () => {
|
|
51
|
-
expect(isBizarError(null)).toBe(false);
|
|
52
|
-
expect(isBizarError(undefined)).toBe(false);
|
|
53
|
-
expect(isBizarError("string")).toBe(false);
|
|
54
|
-
expect(isBizarError({})).toBe(false);
|
|
55
|
-
expect(isBizarError({ name: "OtherError" })).toBe(false);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe("connectionErrorFrom", () => {
|
|
60
|
-
it("wraps Error instances", () => {
|
|
61
|
-
const err = connectionErrorFrom(new TypeError("ECONNREFUSED"));
|
|
62
|
-
expect(err.name).toBe("ConnectionError");
|
|
63
|
-
expect(err.data.message).toBe("ECONNREFUSED");
|
|
64
|
-
expect(err.data.cause).toBeInstanceOf(TypeError);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("wraps non-Error values", () => {
|
|
68
|
-
const err = connectionErrorFrom("weird");
|
|
69
|
-
expect(err.name).toBe("ConnectionError");
|
|
70
|
-
expect(err.data.message).toBe("weird");
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
describe("dashboardErrorFrom", () => {
|
|
75
|
-
it("extracts message from JSON body", () => {
|
|
76
|
-
const err = dashboardErrorFrom(
|
|
77
|
-
401,
|
|
78
|
-
JSON.stringify({ data: { message: "auth failed" } }),
|
|
79
|
-
);
|
|
80
|
-
expect(err.name).toBe("DashboardError");
|
|
81
|
-
expect(err.data.statusCode).toBe(401);
|
|
82
|
-
expect(err.data.message).toBe("auth failed");
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it("falls back to status-only message when body is not JSON", () => {
|
|
86
|
-
const err = dashboardErrorFrom(500, "<html>error</html>");
|
|
87
|
-
expect(err.data.statusCode).toBe(500);
|
|
88
|
-
expect(err.data.message).toBe("HTTP 500");
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe("apiErrorFrom", () => {
|
|
93
|
-
it("marks 5xx as retryable", () => {
|
|
94
|
-
const err = apiErrorFrom(502, "bad gateway");
|
|
95
|
-
expect(err.name).toBe("APIError");
|
|
96
|
-
expect(err.data.isRetryable).toBe(true);
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
it("marks 429 as retryable", () => {
|
|
100
|
-
const err = apiErrorFrom(429, "rate limit");
|
|
101
|
-
expect(err.data.isRetryable).toBe(true);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it("marks 4xx other than 429 as non-retryable", () => {
|
|
105
|
-
const err = apiErrorFrom(400, "bad request");
|
|
106
|
-
expect(err.data.isRetryable).toBe(false);
|
|
107
|
-
});
|
|
108
|
-
});
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the SSE event subscriber.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect, beforeEach } from "vitest";
|
|
6
|
-
import { subscribeEvents, parseSseStream } from "../src/events.js";
|
|
7
|
-
import type { DashboardEvent } from "../src/types.js";
|
|
8
|
-
import { sseStream, sseRawStream } from "./fixtures/sse-mock.js";
|
|
9
|
-
import { makeFetchMock, type FetchMock } from "./fixtures/fetch-mock.js";
|
|
10
|
-
|
|
11
|
-
describe("parseSseStream", () => {
|
|
12
|
-
it("parses a single event", async () => {
|
|
13
|
-
const stream = sseStream([
|
|
14
|
-
{ type: "dashboard.connected", properties: {} },
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
const controller = new AbortController();
|
|
18
|
-
const iter = parseSseStream<DashboardEvent>(stream, controller);
|
|
19
|
-
const events: DashboardEvent[] = [];
|
|
20
|
-
for await (const e of iter) events.push(e);
|
|
21
|
-
|
|
22
|
-
expect(events).toHaveLength(1);
|
|
23
|
-
expect(events[0].type).toBe("dashboard.connected");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("parses multiple events in order", async () => {
|
|
27
|
-
const stream = sseStream([
|
|
28
|
-
{ type: "dashboard.connected", properties: {} },
|
|
29
|
-
{
|
|
30
|
-
type: "session.created",
|
|
31
|
-
properties: { sessionId: "ses_1", agent: "mimir" },
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
type: "session.updated",
|
|
35
|
-
properties: { sessionId: "ses_1", status: "running" },
|
|
36
|
-
},
|
|
37
|
-
]);
|
|
38
|
-
|
|
39
|
-
const controller = new AbortController();
|
|
40
|
-
const iter = parseSseStream<DashboardEvent>(stream, controller);
|
|
41
|
-
const events: DashboardEvent[] = [];
|
|
42
|
-
for await (const e of iter) events.push(e);
|
|
43
|
-
|
|
44
|
-
expect(events).toHaveLength(3);
|
|
45
|
-
expect(events.map((e) => e.type)).toEqual([
|
|
46
|
-
"dashboard.connected",
|
|
47
|
-
"session.created",
|
|
48
|
-
"session.updated",
|
|
49
|
-
]);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("skips malformed data lines instead of throwing", async () => {
|
|
53
|
-
const stream = sseRawStream([
|
|
54
|
-
"event: dashboard.connected\ndata: {not valid json}\n\n",
|
|
55
|
-
"event: session.created\ndata: {\"type\":\"session.created\",\"properties\":{\"sessionId\":\"ses_1\",\"agent\":\"thor\"}}\n\n",
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
|
-
const controller = new AbortController();
|
|
59
|
-
const iter = parseSseStream<DashboardEvent>(stream, controller);
|
|
60
|
-
const events: DashboardEvent[] = [];
|
|
61
|
-
for await (const e of iter) events.push(e);
|
|
62
|
-
|
|
63
|
-
expect(events).toHaveLength(1);
|
|
64
|
-
expect(events[0].type).toBe("session.created");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("ignores comment lines starting with ':'", async () => {
|
|
68
|
-
const stream = sseRawStream([
|
|
69
|
-
": this is a comment\n",
|
|
70
|
-
"event: dashboard.connected\n",
|
|
71
|
-
"data: {\"type\":\"dashboard.connected\",\"properties\":{}}\n\n",
|
|
72
|
-
]);
|
|
73
|
-
|
|
74
|
-
const controller = new AbortController();
|
|
75
|
-
const iter = parseSseStream<DashboardEvent>(stream, controller);
|
|
76
|
-
const events: DashboardEvent[] = [];
|
|
77
|
-
for await (const e of iter) events.push(e);
|
|
78
|
-
|
|
79
|
-
expect(events).toHaveLength(1);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe("subscribeEvents", () => {
|
|
84
|
-
let m: FetchMock;
|
|
85
|
-
|
|
86
|
-
beforeEach(() => {
|
|
87
|
-
m = makeFetchMock();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("returns subscription that yields parsed events", async () => {
|
|
91
|
-
const events: DashboardEvent[] = [
|
|
92
|
-
{ type: "dashboard.connected", properties: {} },
|
|
93
|
-
{
|
|
94
|
-
type: "session.created",
|
|
95
|
-
properties: { sessionId: "ses_1", agent: "mimir" },
|
|
96
|
-
},
|
|
97
|
-
];
|
|
98
|
-
|
|
99
|
-
m.respondWithStream("GET", "/event", sseStream(events));
|
|
100
|
-
|
|
101
|
-
const sub = await subscribeEvents(
|
|
102
|
-
"http://127.0.0.1:4098",
|
|
103
|
-
"Basic xyz",
|
|
104
|
-
{},
|
|
105
|
-
m.fetch,
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const received: DashboardEvent[] = [];
|
|
109
|
-
for await (const e of sub.stream) received.push(e);
|
|
110
|
-
|
|
111
|
-
expect(received).toHaveLength(2);
|
|
112
|
-
expect(received[0].type).toBe("dashboard.connected");
|
|
113
|
-
expect(received[1].type).toBe("session.created");
|
|
114
|
-
|
|
115
|
-
expect(m.lastRequest!.headers["Accept"]).toBe("text/event-stream");
|
|
116
|
-
expect(m.lastRequest!.headers["Authorization"]).toBe("Basic xyz");
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("aborts the fetch when subscription.close() is called", async () => {
|
|
120
|
-
// Long-lived stream that blocks
|
|
121
|
-
const blockedStream = new ReadableStream<Uint8Array>({
|
|
122
|
-
start() {
|
|
123
|
-
/* never closes */
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
m.respondWithStream("GET", "/event", blockedStream);
|
|
128
|
-
|
|
129
|
-
const sub = await subscribeEvents(
|
|
130
|
-
"http://127.0.0.1:4098",
|
|
131
|
-
"Basic xyz",
|
|
132
|
-
{},
|
|
133
|
-
m.fetch,
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
sub.close();
|
|
137
|
-
// No assertion needed beyond "did not hang"
|
|
138
|
-
});
|
|
139
|
-
});
|