kimaki 0.26.0 → 0.27.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/dist/agent-model.e2e.test.js +25 -122
- package/dist/anthropic-account-identity.js +1 -0
- package/dist/anthropic-auth-plugin.js +1 -0
- package/dist/anthropic-auth-state.js +1 -0
- package/dist/bin.js +73 -19
- package/dist/cli-commands/maintenance.js +46 -7
- package/dist/cli-commands/send.js +24 -0
- package/dist/cli-commands/session.js +183 -8
- package/dist/cli-commands/task.js +13 -1
- package/dist/cli-parsing.test.js +59 -3
- package/dist/cli-runner.js +28 -4
- package/dist/cli-runner.test.js +27 -0
- package/dist/cli-send-thread.e2e.test.js +1 -1
- package/dist/cli.js +32 -0
- package/dist/commands/abort.js +5 -1
- package/dist/commands/agent.js +6 -8
- package/dist/commands/ask-question.js +21 -32
- package/dist/commands/ask-question.test.js +43 -1
- package/dist/commands/login.js +6 -0
- package/dist/commands/merge-worktree.js +36 -10
- package/dist/commands/model-variant.js +7 -1
- package/dist/commands/model.js +14 -8
- package/dist/commands/multioauth.js +1 -0
- package/dist/commands/new-worktree.js +170 -102
- package/dist/commands/user-command.js +6 -8
- package/dist/commands/worktrees.js +5 -13
- package/dist/config.js +16 -1
- package/dist/database.js +124 -3
- package/dist/db.js +22 -0
- package/dist/db.test.js +167 -1
- package/dist/discord-bot.js +34 -32
- package/dist/discord-command-registration.js +9 -1
- package/dist/discord-utils.js +13 -5
- package/dist/discord-utils.test.js +17 -1
- package/dist/errors.js +5 -0
- package/dist/exec-async.js +17 -5
- package/dist/external-directory-permissions.e2e.test.js +2 -2
- package/dist/file-edit-log.js +197 -0
- package/dist/file-edit-log.test.js +258 -0
- package/dist/format-tables.js +52 -0
- package/dist/format-tables.test.js +93 -0
- package/dist/gateway-proxy-reconnect.e2e.test.js +28 -8
- package/dist/gateway-proxy.e2e.test.js +5 -5
- package/dist/git-worktree-core.js +182 -17
- package/dist/ipc-tools-plugin.js +63 -3
- package/dist/kimaki-opencode-plugin-loading.e2e.test.js +122 -58
- package/dist/kimaki-opencode-plugin.js +7 -3
- package/dist/kimaki-workspace-adaptor.js +33 -10
- package/dist/logger.js +10 -1
- package/dist/markdown.js +3 -1
- package/dist/markdown.test.js +11 -3
- package/dist/message-formatting.js +18 -7
- package/dist/message-formatting.test.js +56 -9
- package/dist/oauth-rotation-shared.js +10 -0
- package/dist/openai-auth-plugin.js +1 -0
- package/dist/openai-auth-state.js +1 -0
- package/dist/opencode-command.test.js +60 -0
- package/dist/opencode.js +53 -12
- package/dist/question-abort-clears-dropdown.e2e.test.js +89 -0
- package/dist/question-text-before-dropdown.e2e.test.js +52 -0
- package/dist/queue-advanced-abort.e2e.test.js +1 -1
- package/dist/queue-advanced-action-buttons.e2e.test.js +3 -3
- package/dist/queue-advanced-e2e-setup.js +78 -5
- package/dist/queue-advanced-footer.e2e.test.js +40 -246
- package/dist/queue-advanced-model-switch.e2e.test.js +2 -2
- package/dist/queue-advanced-permissions-typing.e2e.test.js +7 -9
- package/dist/queue-advanced-question.e2e.test.js +31 -26
- package/dist/queue-advanced-typing-interrupt.e2e.test.js +2 -2
- package/dist/queue-delete-message.e2e.test.js +1 -1
- package/dist/queue-drain-after-interactive-ui.e2e.test.js +2 -2
- package/dist/queue-interrupt-drain.e2e.test.js +112 -2
- package/dist/queue-question-select-drain.e2e.test.js +30 -128
- package/dist/runtime-lifecycle.e2e.test.js +10 -37
- package/dist/schema.js +34 -0
- package/dist/session-handler/event-stream-state.js +267 -50
- package/dist/session-handler/event-stream-state.test.js +415 -8
- package/dist/session-handler/model-utils.js +159 -5
- package/dist/session-handler/model-utils.test.js +345 -0
- package/dist/session-handler/thread-session-runtime.js +252 -182
- package/dist/session-sleep.test.js +224 -0
- package/dist/session-title-rename.test.js +7 -39
- package/dist/sleep.e2e.test.js +491 -0
- package/dist/startup-time.e2e.test.js +2 -1
- package/dist/store.js +3 -0
- package/dist/system-message.js +59 -6
- package/dist/system-message.test.js +76 -6
- package/dist/task-runner.js +94 -4
- package/dist/task-schedule.js +56 -0
- package/dist/task-schedule.test.js +71 -1
- package/dist/thread-message-queue.e2e.test.js +10 -169
- package/dist/undo-redo.e2e.test.js +2 -2
- package/dist/voice-attachment.js +23 -1
- package/dist/voice-message.e2e.test.js +10 -10
- package/dist/voice.test.js +55 -29
- package/dist/worktree-clone-isolation.e2e.test.js +188 -0
- package/dist/worktree-lifecycle.e2e.test.js +29 -10
- package/dist/worktrees.js +226 -443
- package/dist/worktrees.test.js +435 -58
- package/dist/xai-auth-plugin.js +1 -0
- package/dist/xai-auth-state.js +1 -0
- package/package.json +8 -6
- package/skills/errore/SKILL.md +18 -0
- package/skills/goke/SKILL.md +150 -10
- package/skills/holocron/SKILL.md +37 -0
- package/skills/npm-package/SKILL.md +55 -35
- package/skills/profano/SKILL.md +17 -2
- package/skills/spiceflow/SKILL.md +39 -3
- package/skills/strada/SKILL.md +39 -0
- package/skills/zele/SKILL.md +19 -0
- package/src/agent-model.e2e.test.ts +25 -151
- package/src/anthropic-account-identity.ts +1 -0
- package/src/anthropic-auth-plugin.ts +1 -0
- package/src/anthropic-auth-state.ts +1 -0
- package/src/bin.ts +78 -26
- package/src/cli-commands/maintenance.ts +59 -13
- package/src/cli-commands/send.ts +25 -0
- package/src/cli-commands/session.ts +203 -9
- package/src/cli-commands/task.ts +13 -1
- package/src/cli-parsing.test.ts +69 -3
- package/src/cli-runner.test.ts +49 -0
- package/src/cli-runner.ts +28 -4
- package/src/cli-send-thread.e2e.test.ts +1 -1
- package/src/cli.ts +53 -0
- package/src/commands/abort.ts +6 -1
- package/src/commands/agent.ts +6 -6
- package/src/commands/ask-question.test.ts +48 -1
- package/src/commands/ask-question.ts +21 -32
- package/src/commands/login.ts +6 -0
- package/src/commands/merge-worktree.ts +43 -12
- package/src/commands/model-variant.ts +8 -1
- package/src/commands/model.ts +18 -8
- package/src/commands/multioauth.ts +1 -0
- package/src/commands/new-worktree.ts +138 -55
- package/src/commands/user-command.ts +6 -6
- package/src/commands/worktrees.ts +5 -12
- package/src/config.ts +18 -1
- package/src/database.ts +195 -3
- package/src/db.test.ts +188 -0
- package/src/db.ts +26 -0
- package/src/discord-bot.ts +35 -29
- package/src/discord-command-registration.ts +15 -1
- package/src/discord-utils.test.ts +19 -0
- package/src/discord-utils.ts +21 -6
- package/src/errors.ts +5 -0
- package/src/exec-async.ts +20 -11
- package/src/external-directory-permissions.e2e.test.ts +2 -2
- package/src/file-edit-log.test.ts +287 -0
- package/src/file-edit-log.ts +283 -0
- package/src/format-tables.test.ts +101 -0
- package/src/format-tables.ts +75 -0
- package/src/gateway-proxy-reconnect.e2e.test.ts +38 -8
- package/src/gateway-proxy.e2e.test.ts +5 -5
- package/src/git-worktree-core.ts +247 -20
- package/src/ipc-tools-plugin.ts +75 -5
- package/src/kimaki-opencode-plugin-loading.e2e.test.ts +188 -97
- package/src/kimaki-opencode-plugin.ts +7 -3
- package/src/kimaki-workspace-adaptor.ts +40 -11
- package/src/logger.ts +13 -4
- package/src/markdown.test.ts +13 -3
- package/src/markdown.ts +4 -1
- package/src/message-formatting.test.ts +86 -12
- package/src/message-formatting.ts +19 -7
- package/src/oauth-rotation-shared.ts +10 -0
- package/src/openai-auth-plugin.ts +1 -0
- package/src/openai-auth-state.ts +1 -0
- package/src/opencode-command.test.ts +81 -0
- package/src/opencode.ts +71 -11
- package/src/question-abort-clears-dropdown.e2e.test.ts +109 -0
- package/src/question-text-before-dropdown.e2e.test.ts +67 -0
- package/src/queue-advanced-abort.e2e.test.ts +1 -1
- package/src/queue-advanced-action-buttons.e2e.test.ts +3 -3
- package/src/queue-advanced-e2e-setup.ts +83 -4
- package/src/queue-advanced-footer.e2e.test.ts +47 -294
- package/src/queue-advanced-model-switch.e2e.test.ts +2 -2
- package/src/queue-advanced-permissions-typing.e2e.test.ts +7 -9
- package/src/queue-advanced-question.e2e.test.ts +35 -29
- package/src/queue-advanced-typing-interrupt.e2e.test.ts +2 -2
- package/src/queue-delete-message.e2e.test.ts +1 -1
- package/src/queue-drain-after-interactive-ui.e2e.test.ts +2 -2
- package/src/queue-interrupt-drain.e2e.test.ts +123 -2
- package/src/queue-question-select-drain.e2e.test.ts +32 -157
- package/src/runtime-lifecycle.e2e.test.ts +10 -41
- package/src/schema.sql +14 -1
- package/src/schema.ts +36 -0
- package/src/session-handler/event-stream-state.test.ts +437 -7
- package/src/session-handler/event-stream-state.ts +389 -53
- package/src/session-handler/model-utils.test.ts +415 -0
- package/src/session-handler/model-utils.ts +249 -5
- package/src/session-handler/thread-session-runtime.ts +300 -215
- package/src/session-sleep.test.ts +294 -0
- package/src/session-title-rename.test.ts +9 -48
- package/src/sleep.e2e.test.ts +562 -0
- package/src/startup-time.e2e.test.ts +5 -1
- package/src/store.ts +21 -0
- package/src/system-message.test.ts +86 -6
- package/src/system-message.ts +66 -7
- package/src/task-runner.ts +136 -2
- package/src/task-schedule.test.ts +76 -0
- package/src/task-schedule.ts +95 -0
- package/src/thread-message-queue.e2e.test.ts +10 -202
- package/src/undo-redo.e2e.test.ts +2 -2
- package/src/voice-attachment.ts +29 -1
- package/src/voice-message.e2e.test.ts +10 -10
- package/src/voice.test.ts +63 -29
- package/src/worktree-clone-isolation.e2e.test.ts +213 -0
- package/src/worktree-lifecycle.e2e.test.ts +29 -9
- package/src/worktrees.test.ts +505 -64
- package/src/worktrees.ts +257 -603
- package/src/xai-auth-plugin.ts +1 -0
- package/src/xai-auth-state.ts +1 -0
- package/dist/message-finish-field.e2e.test.js +0 -169
- package/dist/subagent-rate-limit-plugin.js +0 -184
- package/src/message-finish-field.e2e.test.ts +0 -196
- package/src/subagent-rate-limit-plugin.ts +0 -228
|
@@ -375,7 +375,7 @@ e2eTest('thread message queue ordering', () => {
|
|
|
375
375
|
--- from: assistant (TestBot)
|
|
376
376
|
*using deterministic-provider/deterministic-v2*
|
|
377
377
|
⬥ ok
|
|
378
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
378
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>"
|
|
379
379
|
`);
|
|
380
380
|
}, 12_000);
|
|
381
381
|
test('text message during active session gets processed', async () => {
|
|
@@ -497,13 +497,13 @@ e2eTest('thread message queue ordering', () => {
|
|
|
497
497
|
return m.author.id === discord.botUserId;
|
|
498
498
|
});
|
|
499
499
|
expect(afterBotMessages.length).toBeGreaterThanOrEqual(beforeBotCount + 1);
|
|
500
|
-
expect(await th.text()).toMatchInlineSnapshot(`
|
|
500
|
+
expect((await th.text()).replace(/\n⬥ ok(?=\n⬥ ok)/g, '')).toMatchInlineSnapshot(`
|
|
501
501
|
"--- from: user (queue-tester)
|
|
502
502
|
Reply with exactly: one
|
|
503
503
|
--- from: assistant (TestBot)
|
|
504
504
|
*using deterministic-provider/deterministic-v2*
|
|
505
505
|
⬥ ok
|
|
506
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
506
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>
|
|
507
507
|
--- from: user (queue-tester)
|
|
508
508
|
Reply with exactly: two
|
|
509
509
|
Reply with exactly: three
|
|
@@ -533,88 +533,6 @@ e2eTest('thread message queue ordering', () => {
|
|
|
533
533
|
});
|
|
534
534
|
expect(finalState.queueItems.length).toBe(0);
|
|
535
535
|
}, 8_000);
|
|
536
|
-
test('normal messages bypass local queue and still show assistant text parts', async () => {
|
|
537
|
-
const setupPrompt = 'Reply with exactly: opencode-queue-setup';
|
|
538
|
-
await discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
539
|
-
content: setupPrompt,
|
|
540
|
-
});
|
|
541
|
-
const thread = await discord.channel(TEXT_CHANNEL_ID).waitForThread({
|
|
542
|
-
timeout: 4_000,
|
|
543
|
-
predicate: (t) => {
|
|
544
|
-
return t.name === 'Reply with exactly: opencode-queue-setup';
|
|
545
|
-
},
|
|
546
|
-
});
|
|
547
|
-
const th = discord.thread(thread.id);
|
|
548
|
-
const firstReply = await th.waitForBotReply({ timeout: 4_000 });
|
|
549
|
-
expect(firstReply.content.trim().length).toBeGreaterThan(0);
|
|
550
|
-
// Anchor follow-up on an already-completed first run so footer ordering
|
|
551
|
-
// is deterministic before we assert on the second prompt.
|
|
552
|
-
await waitForFooterMessage({
|
|
553
|
-
discord,
|
|
554
|
-
threadId: thread.id,
|
|
555
|
-
timeout: 4_000,
|
|
556
|
-
});
|
|
557
|
-
const followupPrompt = 'Prompt from test: respond with short text for opencode queue mode.';
|
|
558
|
-
const followupUserMessage = await th.user(TEST_USER_ID).sendMessage({
|
|
559
|
-
content: followupPrompt,
|
|
560
|
-
});
|
|
561
|
-
// Assert assistant text parts are visible in Discord.
|
|
562
|
-
await waitForBotMessageContaining({
|
|
563
|
-
discord,
|
|
564
|
-
threadId: thread.id,
|
|
565
|
-
userId: TEST_USER_ID,
|
|
566
|
-
text: '⬥ ok',
|
|
567
|
-
afterMessageId: followupUserMessage.id,
|
|
568
|
-
timeout: 4_000,
|
|
569
|
-
});
|
|
570
|
-
const messagesWithFollowupFooter = await waitForFooterMessage({
|
|
571
|
-
discord,
|
|
572
|
-
threadId: thread.id,
|
|
573
|
-
timeout: 4_000,
|
|
574
|
-
afterMessageIncludes: followupPrompt,
|
|
575
|
-
afterAuthorId: TEST_USER_ID,
|
|
576
|
-
});
|
|
577
|
-
expect(await th.text()).toMatchInlineSnapshot(`
|
|
578
|
-
"--- from: user (queue-tester)
|
|
579
|
-
Reply with exactly: opencode-queue-setup
|
|
580
|
-
--- from: assistant (TestBot)
|
|
581
|
-
*using deterministic-provider/deterministic-v2*
|
|
582
|
-
⬥ ok
|
|
583
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
584
|
-
--- from: user (queue-tester)
|
|
585
|
-
Prompt from test: respond with short text for opencode queue mode.
|
|
586
|
-
--- from: assistant (TestBot)
|
|
587
|
-
⬥ ok
|
|
588
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
589
|
-
`);
|
|
590
|
-
const followupUserIndex = messagesWithFollowupFooter.findIndex((message) => {
|
|
591
|
-
return message.id === followupUserMessage.id;
|
|
592
|
-
});
|
|
593
|
-
const textPartAfterFollowupIndex = messagesWithFollowupFooter.findIndex((message, index) => {
|
|
594
|
-
return (index > followupUserIndex &&
|
|
595
|
-
message.author.id === discord.botUserId &&
|
|
596
|
-
message.content.includes('⬥ ok'));
|
|
597
|
-
});
|
|
598
|
-
const footerAfterFollowupIndex = messagesWithFollowupFooter.findIndex((message, index) => {
|
|
599
|
-
return (index > textPartAfterFollowupIndex &&
|
|
600
|
-
message.author.id === discord.botUserId &&
|
|
601
|
-
message.content.startsWith('*') &&
|
|
602
|
-
message.content.includes('⋅'));
|
|
603
|
-
});
|
|
604
|
-
expect(followupUserIndex).toBeGreaterThan(-1);
|
|
605
|
-
expect(textPartAfterFollowupIndex).toBeGreaterThan(followupUserIndex);
|
|
606
|
-
expect(footerAfterFollowupIndex).toBeGreaterThan(textPartAfterFollowupIndex);
|
|
607
|
-
// Normal messages should not populate kimaki local queue.
|
|
608
|
-
const noLocalQueueState = await waitForThreadState({
|
|
609
|
-
threadId: thread.id,
|
|
610
|
-
predicate: (state) => {
|
|
611
|
-
return state.queueItems.length === 0;
|
|
612
|
-
},
|
|
613
|
-
timeout: 4_000,
|
|
614
|
-
description: 'local queue remains empty in opencode mode',
|
|
615
|
-
});
|
|
616
|
-
expect(noLocalQueueState.queueItems.length).toBe(0);
|
|
617
|
-
}, 8_000);
|
|
618
536
|
test('bash tool-call actually executes and creates file in project directory', async () => {
|
|
619
537
|
const markerRelativePath = path.join('tmp', 'bash-tool-executed.txt');
|
|
620
538
|
const markerPath = path.join(directories.projectDirectory, markerRelativePath);
|
|
@@ -658,7 +576,7 @@ e2eTest('thread message queue ordering', () => {
|
|
|
658
576
|
⬥ running create file
|
|
659
577
|
┣ bash _mkdir -p tmp && printf "created" > tmp/bash-tool-executed.txt_
|
|
660
578
|
⬥ file created
|
|
661
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
579
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>"
|
|
662
580
|
`);
|
|
663
581
|
expect(fs.existsSync(markerPath)).toBe(true);
|
|
664
582
|
const markerContents = fs.readFileSync(markerPath, 'utf8');
|
|
@@ -763,14 +681,14 @@ e2eTest('thread message queue ordering', () => {
|
|
|
763
681
|
--- from: assistant (TestBot)
|
|
764
682
|
*using deterministic-provider/deterministic-v2*
|
|
765
683
|
⬥ ok
|
|
766
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
684
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>
|
|
767
685
|
» **queue-tester:** Reply with exactly: race-final
|
|
768
686
|
Queued message (position 1)
|
|
769
687
|
⬥ race-final
|
|
770
688
|
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
771
689
|
» **queue-tester:** Reply with exactly: queued-from-slash
|
|
772
690
|
⬥ ok
|
|
773
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
691
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>"
|
|
774
692
|
`);
|
|
775
693
|
}, 12_000);
|
|
776
694
|
test('Remove from queue button clears only that queued message', async () => {
|
|
@@ -874,7 +792,7 @@ e2eTest('thread message queue ordering', () => {
|
|
|
874
792
|
--- from: assistant (TestBot)
|
|
875
793
|
*using deterministic-provider/deterministic-v2*
|
|
876
794
|
⬥ ok
|
|
877
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
795
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>
|
|
878
796
|
» **queue-tester:** Reply with exactly: race-final
|
|
879
797
|
Removed queued message (was position 1): Reply with exactly: removed-queued-message
|
|
880
798
|
Queued message (position 2)
|
|
@@ -885,83 +803,6 @@ e2eTest('thread message queue ordering', () => {
|
|
|
885
803
|
expect(threadText).not.toContain('» **queue-tester:** Reply with exactly: removed-queued-message');
|
|
886
804
|
expect(threadText).toContain('kept-queued-message');
|
|
887
805
|
}, 12_000);
|
|
888
|
-
test('queued message waits for running session and then processes next', async () => {
|
|
889
|
-
// When a new message arrives while a session is running, it queues and
|
|
890
|
-
// runs after the in-flight request completes.
|
|
891
|
-
//
|
|
892
|
-
// 1. Fast setup: establish session
|
|
893
|
-
await discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
894
|
-
content: 'Reply with exactly: delta',
|
|
895
|
-
});
|
|
896
|
-
const thread = await discord.channel(TEXT_CHANNEL_ID).waitForThread({
|
|
897
|
-
timeout: 4_000,
|
|
898
|
-
predicate: (t) => {
|
|
899
|
-
return t.name === 'Reply with exactly: delta';
|
|
900
|
-
},
|
|
901
|
-
});
|
|
902
|
-
const th = discord.thread(thread.id);
|
|
903
|
-
const firstReply = await th.waitForBotReply({ timeout: 4_000 });
|
|
904
|
-
expect(firstReply.content.trim().length).toBeGreaterThan(0);
|
|
905
|
-
const before = await th.getMessages();
|
|
906
|
-
const beforeBotCount = before.filter((m) => {
|
|
907
|
-
return m.author.id === discord.botUserId;
|
|
908
|
-
}).length;
|
|
909
|
-
// 2. Send B, then quickly send C to enqueue behind B.
|
|
910
|
-
await th.user(TEST_USER_ID).sendMessage({
|
|
911
|
-
content: 'Reply with exactly: echo',
|
|
912
|
-
});
|
|
913
|
-
await new Promise((r) => {
|
|
914
|
-
setTimeout(r, 500);
|
|
915
|
-
});
|
|
916
|
-
await th.user(TEST_USER_ID).sendMessage({
|
|
917
|
-
content: 'Reply with exactly: foxtrot',
|
|
918
|
-
});
|
|
919
|
-
// 3. Poll until foxtrot's user message has a bot reply after it.
|
|
920
|
-
// waitForBotMessageCount alone isn't enough — error messages from the
|
|
921
|
-
// interrupted session can satisfy the count before foxtrot gets its reply.
|
|
922
|
-
const after = await waitForBotReplyAfterUserMessage({
|
|
923
|
-
discord,
|
|
924
|
-
threadId: thread.id,
|
|
925
|
-
userId: TEST_USER_ID,
|
|
926
|
-
userMessageIncludes: 'foxtrot',
|
|
927
|
-
timeout: 4_000,
|
|
928
|
-
});
|
|
929
|
-
// 4. Foxtrot got a bot response after B/C were processed.
|
|
930
|
-
const afterBotMessages = after.filter((m) => {
|
|
931
|
-
return m.author.id === discord.botUserId;
|
|
932
|
-
});
|
|
933
|
-
expect(afterBotMessages.length).toBeGreaterThanOrEqual(beforeBotCount + 1);
|
|
934
|
-
await waitForFooterMessage({
|
|
935
|
-
discord,
|
|
936
|
-
threadId: thread.id,
|
|
937
|
-
timeout: 4_000,
|
|
938
|
-
afterMessageIncludes: 'foxtrot',
|
|
939
|
-
afterAuthorId: TEST_USER_ID,
|
|
940
|
-
});
|
|
941
|
-
// Assert ordering invariants instead of exact snapshot — the echo reply
|
|
942
|
-
// and footer can interleave non-deterministically on slower CI hardware.
|
|
943
|
-
const finalMessages = await th.getMessages();
|
|
944
|
-
const userEchoIndex = finalMessages.findIndex((m) => {
|
|
945
|
-
return m.author.id === TEST_USER_ID && m.content.includes('echo');
|
|
946
|
-
});
|
|
947
|
-
const userFoxtrotIndex = finalMessages.findIndex((m) => {
|
|
948
|
-
return m.author.id === TEST_USER_ID && m.content.includes('foxtrot');
|
|
949
|
-
});
|
|
950
|
-
expect(userEchoIndex).toBeGreaterThan(-1);
|
|
951
|
-
expect(userFoxtrotIndex).toBeGreaterThan(-1);
|
|
952
|
-
// User messages appear in send order
|
|
953
|
-
expect(userEchoIndex).toBeLessThan(userFoxtrotIndex);
|
|
954
|
-
// Foxtrot's bot reply appears after the foxtrot user message
|
|
955
|
-
const botAfterFoxtrot = finalMessages.findIndex((m, i) => {
|
|
956
|
-
return i > userFoxtrotIndex && m.author.id === discord.botUserId;
|
|
957
|
-
});
|
|
958
|
-
expect(botAfterFoxtrot).toBeGreaterThan(userFoxtrotIndex);
|
|
959
|
-
// A footer appears after foxtrot (session completed)
|
|
960
|
-
const timeline = await th.text();
|
|
961
|
-
expect(timeline).toContain('Reply with exactly: echo');
|
|
962
|
-
expect(timeline).toContain('Reply with exactly: foxtrot');
|
|
963
|
-
expect(timeline).toContain('*project ⋅ main ⋅');
|
|
964
|
-
}, 8_000);
|
|
965
806
|
test('slow stream still processes queued next message after completion', async () => {
|
|
966
807
|
// A message sent mid-stream queues and runs after the in-flight request
|
|
967
808
|
// completes (no auto-interrupt).
|
|
@@ -1019,7 +860,7 @@ e2eTest('thread message queue ordering', () => {
|
|
|
1019
860
|
--- from: assistant (TestBot)
|
|
1020
861
|
*using deterministic-provider/deterministic-v2*
|
|
1021
862
|
⬥ ok
|
|
1022
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
863
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>
|
|
1023
864
|
--- from: user (queue-tester)
|
|
1024
865
|
Reply with exactly: hotel
|
|
1025
866
|
Reply with exactly: india
|
|
@@ -1208,7 +1049,7 @@ e2eTest('thread message queue ordering', () => {
|
|
|
1208
1049
|
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
1209
1050
|
» **queue-tester:** Reply with exactly: edited-queued
|
|
1210
1051
|
⬥ ok
|
|
1211
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
1052
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>"
|
|
1212
1053
|
`);
|
|
1213
1054
|
const finalText = await th.text();
|
|
1214
1055
|
expect(finalText).toContain('edited-queued');
|
|
@@ -1298,7 +1139,7 @@ e2eTest('thread message queue ordering', () => {
|
|
|
1298
1139
|
Queued at position 1. Edit or delete your message to update the queue
|
|
1299
1140
|
⬦ **queue-tester** removed message from queue
|
|
1300
1141
|
⬥ slow-busy-reply
|
|
1301
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
1142
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000777>"
|
|
1302
1143
|
`);
|
|
1303
1144
|
}, 12_000);
|
|
1304
1145
|
});
|
|
@@ -151,13 +151,13 @@ e2eTest('/undo sets revert state and cleans up on next prompt', () => {
|
|
|
151
151
|
⬥ creating undo file
|
|
152
152
|
┣ bash _mkdir -p tmp && printf created > tmp/undo-marker.txt_
|
|
153
153
|
⬥ undo file created
|
|
154
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
154
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>
|
|
155
155
|
Undone - reverted last assistant message
|
|
156
156
|
--- from: user (undo-tester)
|
|
157
157
|
Reply with exactly: after-undo-message
|
|
158
158
|
--- from: assistant (TestBot)
|
|
159
159
|
⬥ ok
|
|
160
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
160
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
161
161
|
`);
|
|
162
162
|
}, 20_000);
|
|
163
163
|
});
|
package/dist/voice-attachment.js
CHANGED
|
@@ -2,17 +2,39 @@
|
|
|
2
2
|
// Normalizes Discord attachment heuristics for voice-message detection so
|
|
3
3
|
// message routing, transcription, and empty-prompt guards all agree even when
|
|
4
4
|
// Discord omits contentType on uploaded audio attachments.
|
|
5
|
+
// iOS videos also have duration_secs; reject those before the duration heuristic.
|
|
5
6
|
import path from 'node:path';
|
|
6
7
|
const VOICE_ATTACHMENT_EXTENSIONS = new Set([
|
|
7
8
|
'.m4a',
|
|
8
9
|
'.mp3',
|
|
9
|
-
'.mp4',
|
|
10
10
|
'.oga',
|
|
11
11
|
'.ogg',
|
|
12
12
|
'.opus',
|
|
13
13
|
'.wav',
|
|
14
14
|
]);
|
|
15
|
+
const VIDEO_ATTACHMENT_EXTENSIONS = new Set([
|
|
16
|
+
'.avi',
|
|
17
|
+
'.m4v',
|
|
18
|
+
'.mkv',
|
|
19
|
+
'.mov',
|
|
20
|
+
'.mp4',
|
|
21
|
+
'.webm',
|
|
22
|
+
]);
|
|
23
|
+
function isVisualMediaAttachment(attachment) {
|
|
24
|
+
const contentType = attachment.contentType?.trim().toLowerCase() || '';
|
|
25
|
+
if (contentType.startsWith('video/'))
|
|
26
|
+
return true;
|
|
27
|
+
const extension = path.extname(attachment.name || '').toLowerCase();
|
|
28
|
+
if (VIDEO_ATTACHMENT_EXTENSIONS.has(extension))
|
|
29
|
+
return true;
|
|
30
|
+
return (typeof attachment.width === 'number' &&
|
|
31
|
+
attachment.width > 0 &&
|
|
32
|
+
typeof attachment.height === 'number' &&
|
|
33
|
+
attachment.height > 0);
|
|
34
|
+
}
|
|
15
35
|
export function getVoiceAttachmentMatchReason(attachment) {
|
|
36
|
+
if (isVisualMediaAttachment(attachment))
|
|
37
|
+
return null;
|
|
16
38
|
const contentType = attachment.contentType?.trim().toLowerCase() || '';
|
|
17
39
|
if (contentType.startsWith('audio/')) {
|
|
18
40
|
return `contentType:${contentType}`;
|
|
@@ -396,7 +396,7 @@ e2eTest('voice message handling', () => {
|
|
|
396
396
|
📝 **Transcribed message:** Fix the login bug in auth.ts
|
|
397
397
|
*using deterministic-provider/deterministic-v2*
|
|
398
398
|
⬥ session-reply
|
|
399
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
399
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
400
400
|
`);
|
|
401
401
|
expect(finalState.sessionId).toBeDefined();
|
|
402
402
|
// Verify OpenCode session received the transcribed voice message as a prompt
|
|
@@ -486,7 +486,7 @@ e2eTest('voice message handling', () => {
|
|
|
486
486
|
📝 **Transcribed message:** Resume the original voice note
|
|
487
487
|
*using deterministic-provider/deterministic-v2*
|
|
488
488
|
⬥ session-reply
|
|
489
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
489
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
490
490
|
`);
|
|
491
491
|
const finalState = getThreadState(thread.id);
|
|
492
492
|
expect(finalState?.sessionId).toBeDefined();
|
|
@@ -550,7 +550,7 @@ e2eTest('voice message handling', () => {
|
|
|
550
550
|
📝 **Transcribed message:** Investigate the missing content type path
|
|
551
551
|
*using deterministic-provider/deterministic-v2*
|
|
552
552
|
⬥ session-reply
|
|
553
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
553
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
554
554
|
`);
|
|
555
555
|
const messages = await waitForSessionMessages({
|
|
556
556
|
projectDirectory: directories.projectDirectory,
|
|
@@ -639,14 +639,14 @@ e2eTest('voice message handling', () => {
|
|
|
639
639
|
--- from: assistant (TestBot)
|
|
640
640
|
*using deterministic-provider/deterministic-v2*
|
|
641
641
|
⬥ fast-response-done
|
|
642
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
642
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>
|
|
643
643
|
--- from: user (voice-tester)
|
|
644
644
|
[attachment: voice-message.ogg]
|
|
645
645
|
--- from: assistant (TestBot)
|
|
646
646
|
🎤 Transcribing voice message...
|
|
647
647
|
📝 **Transcribed message:** Add error handling to the parser
|
|
648
648
|
⬥ session-reply
|
|
649
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
649
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
650
650
|
`);
|
|
651
651
|
expect(finalState?.sessionId).toBeDefined();
|
|
652
652
|
if (!finalState?.sessionId) {
|
|
@@ -860,7 +860,7 @@ e2eTest('voice message handling', () => {
|
|
|
860
860
|
» **voice-tester:** Voice message transcription from Discord user:
|
|
861
861
|
Queue this task for later
|
|
862
862
|
⬥ session-reply
|
|
863
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
863
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
864
864
|
`);
|
|
865
865
|
expect(finalState.queueItems.length).toBe(0);
|
|
866
866
|
// Verify the OpenCode session processed BOTH prompts sequentially:
|
|
@@ -959,14 +959,14 @@ e2eTest('voice message handling', () => {
|
|
|
959
959
|
--- from: assistant (TestBot)
|
|
960
960
|
*using deterministic-provider/deterministic-v2*
|
|
961
961
|
⬥ fast-response-done
|
|
962
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
962
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>
|
|
963
963
|
--- from: user (voice-tester)
|
|
964
964
|
[attachment: voice-message.ogg]
|
|
965
965
|
--- from: assistant (TestBot)
|
|
966
966
|
🎤 Transcribing voice message...
|
|
967
967
|
📝 **Transcribed message:** Delayed transcription result
|
|
968
968
|
⬥ session-reply
|
|
969
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
969
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
970
970
|
`);
|
|
971
971
|
expect(finalState.sessionId).toBeDefined();
|
|
972
972
|
expect(finalState.queueItems.length).toBe(0);
|
|
@@ -1077,14 +1077,14 @@ e2eTest('voice message handling', () => {
|
|
|
1077
1077
|
--- from: assistant (TestBot)
|
|
1078
1078
|
*using deterministic-provider/deterministic-v2*
|
|
1079
1079
|
⬥ fast-response-done
|
|
1080
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
1080
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>
|
|
1081
1081
|
--- from: user (voice-tester)
|
|
1082
1082
|
[attachment: voice-message.ogg]
|
|
1083
1083
|
--- from: assistant (TestBot)
|
|
1084
1084
|
🎤 Transcribing voice message...
|
|
1085
1085
|
📝 **Transcribed message:** Queued voice after idle
|
|
1086
1086
|
⬥ session-reply
|
|
1087
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
1087
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@300000000000000777>"
|
|
1088
1088
|
`);
|
|
1089
1089
|
expect(finalState.sessionId).toBeDefined();
|
|
1090
1090
|
expect(finalState.queueItems.length).toBe(0);
|
package/dist/voice.test.js
CHANGED
|
@@ -50,6 +50,46 @@ describe('voice attachment detection', () => {
|
|
|
50
50
|
]
|
|
51
51
|
`);
|
|
52
52
|
});
|
|
53
|
+
test('does not treat iOS and Discord videos as voice', () => {
|
|
54
|
+
expect([
|
|
55
|
+
getVoiceAttachmentMatchReason({
|
|
56
|
+
name: 'ScreenRecording_08-26-2026_11-10-29_1.mov',
|
|
57
|
+
contentType: 'video/quicktime',
|
|
58
|
+
duration: 12.4,
|
|
59
|
+
width: 1170,
|
|
60
|
+
height: 2532,
|
|
61
|
+
}),
|
|
62
|
+
getVoiceAttachmentMatchReason({
|
|
63
|
+
name: 'IMG_1234.MOV',
|
|
64
|
+
contentType: null,
|
|
65
|
+
duration: 8,
|
|
66
|
+
width: 1920,
|
|
67
|
+
height: 1080,
|
|
68
|
+
}),
|
|
69
|
+
getVoiceAttachmentMatchReason({
|
|
70
|
+
name: 'clip.mp4',
|
|
71
|
+
contentType: 'video/mp4',
|
|
72
|
+
duration: 4,
|
|
73
|
+
}),
|
|
74
|
+
getVoiceAttachmentMatchReason({
|
|
75
|
+
name: 'clip.mp4',
|
|
76
|
+
contentType: null,
|
|
77
|
+
}),
|
|
78
|
+
isVoiceAttachment({
|
|
79
|
+
name: 'memo.m4a',
|
|
80
|
+
contentType: null,
|
|
81
|
+
duration: 3.2,
|
|
82
|
+
}),
|
|
83
|
+
]).toMatchInlineSnapshot(`
|
|
84
|
+
[
|
|
85
|
+
null,
|
|
86
|
+
null,
|
|
87
|
+
null,
|
|
88
|
+
null,
|
|
89
|
+
true,
|
|
90
|
+
]
|
|
91
|
+
`);
|
|
92
|
+
});
|
|
53
93
|
});
|
|
54
94
|
describe('extractTranscription', () => {
|
|
55
95
|
test('extracts transcription from tool call', () => {
|
|
@@ -143,18 +183,17 @@ describe('extractTranscription', () => {
|
|
|
143
183
|
expect(result.message).toMatchInlineSnapshot(`"Transcription failed: Model did not produce a transcription"`);
|
|
144
184
|
});
|
|
145
185
|
});
|
|
146
|
-
describe('
|
|
186
|
+
const liveVoiceTest = describe.skipIf(process.env['KIMAKI_LIVE_VOICE_TESTS'] !== '1');
|
|
187
|
+
liveVoiceTest('transcribeAudio with real API', () => {
|
|
147
188
|
const audioPath = path.join(import.meta.dirname, '..', 'scripts', 'example-audio.mp3');
|
|
148
|
-
|
|
189
|
+
const oggPath = path.join(import.meta.dirname, '..', 'scripts', 'example-audio.ogg');
|
|
190
|
+
const geminiLiveTest = test.skipIf(!process.env.GEMINI_API_KEY || !fs.existsSync(audioPath));
|
|
191
|
+
const openAiLiveTest = test.skipIf(!process.env.OPENAI_API_KEY || !fs.existsSync(audioPath));
|
|
192
|
+
const openAiOggLiveTest = test.skipIf(!process.env.OPENAI_API_KEY || !fs.existsSync(oggPath));
|
|
193
|
+
geminiLiveTest('transcribes with Gemini', { timeout: 30_000 }, async () => {
|
|
149
194
|
const apiKey = process.env.GEMINI_API_KEY;
|
|
150
|
-
if (!apiKey)
|
|
151
|
-
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
if (!fs.existsSync(audioPath)) {
|
|
155
|
-
console.log('Skipping: example-audio.mp3 not found');
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
195
|
+
if (!apiKey)
|
|
196
|
+
throw new Error('GEMINI_API_KEY is required');
|
|
158
197
|
const audio = fs.readFileSync(audioPath);
|
|
159
198
|
const result = await transcribeAudio({
|
|
160
199
|
audio,
|
|
@@ -167,16 +206,10 @@ describe('transcribeAudio with real API', () => {
|
|
|
167
206
|
expect(transcription.length).toBeGreaterThan(0);
|
|
168
207
|
console.log('Gemini transcription:', result);
|
|
169
208
|
});
|
|
170
|
-
|
|
209
|
+
openAiLiveTest('transcribes with OpenAI', { timeout: 30_000 }, async () => {
|
|
171
210
|
const apiKey = process.env.OPENAI_API_KEY;
|
|
172
|
-
if (!apiKey)
|
|
173
|
-
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
if (!fs.existsSync(audioPath)) {
|
|
177
|
-
console.log('Skipping: example-audio.mp3 not found');
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
211
|
+
if (!apiKey)
|
|
212
|
+
throw new Error('OPENAI_API_KEY is required');
|
|
180
213
|
const audio = fs.readFileSync(audioPath);
|
|
181
214
|
const result = await transcribeAudio({
|
|
182
215
|
audio,
|
|
@@ -189,17 +222,10 @@ describe('transcribeAudio with real API', () => {
|
|
|
189
222
|
expect(transcription.length).toBeGreaterThan(0);
|
|
190
223
|
console.log('OpenAI transcription:', result);
|
|
191
224
|
});
|
|
192
|
-
|
|
225
|
+
openAiOggLiveTest('transcribes OGG with OpenAI (converts to WAV)', { timeout: 30_000 }, async () => {
|
|
193
226
|
const apiKey = process.env.OPENAI_API_KEY;
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
console.log('Skipping: OPENAI_API_KEY not set');
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (!fs.existsSync(oggPath)) {
|
|
200
|
-
console.log('Skipping: example-audio.ogg not found');
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
227
|
+
if (!apiKey)
|
|
228
|
+
throw new Error('OPENAI_API_KEY is required');
|
|
203
229
|
const audio = fs.readFileSync(oggPath);
|
|
204
230
|
const result = await transcribeAudio({
|
|
205
231
|
audio,
|