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
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
// get consumed as a tool result answer (which lost voice/image content).
|
|
5
5
|
import { describe, test, expect, afterEach } from 'vitest';
|
|
6
6
|
import { setupQueueAdvancedSuite, TEST_USER_ID } from './queue-advanced-e2e-setup.js';
|
|
7
|
-
import { waitForBotMessageContaining, waitForFooterMessage } from './test-utils.js';
|
|
7
|
+
import { waitForBotMessageContaining, waitForBotReplyAfterUserMessage, waitForFooterMessage, } from './test-utils.js';
|
|
8
8
|
import { store } from './store.js';
|
|
9
9
|
import { getOpencodeClient } from './opencode.js';
|
|
10
10
|
import { getThreadSession } from './database.js';
|
|
11
11
|
const TEXT_CHANNEL_ID = '200000000000001007';
|
|
12
|
-
const VOICE_CHANNEL_ID = '200000000000001017';
|
|
13
12
|
function setDeterministicTranscription(config) {
|
|
14
13
|
store.setState({
|
|
15
14
|
test: { deterministicTranscription: config },
|
|
@@ -128,45 +127,55 @@ describe('queue advanced: question tool answer', () => {
|
|
|
128
127
|
// 1. Dismiss the pending question (cleanup context)
|
|
129
128
|
// 2. Abort the blocked session so OpenCode unblocks
|
|
130
129
|
// 3. Enqueue the message as a normal user prompt (not consumed as answer)
|
|
130
|
+
const answer = 'Reply with exactly: question-text-answer-done';
|
|
131
131
|
await th.user(TEST_USER_ID).sendMessage({
|
|
132
|
-
content:
|
|
132
|
+
content: answer,
|
|
133
133
|
});
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
await waitForBotReplyAfterUserMessage({
|
|
135
|
+
discord: ctx.discord,
|
|
136
|
+
threadId: thread.id,
|
|
137
|
+
userId: TEST_USER_ID,
|
|
138
|
+
userMessageIncludes: answer,
|
|
139
|
+
timeout: 8_000,
|
|
140
|
+
});
|
|
141
|
+
await waitForBotMessageContaining({
|
|
142
|
+
discord: ctx.discord,
|
|
143
|
+
threadId: thread.id,
|
|
144
|
+
userId: TEST_USER_ID,
|
|
145
|
+
text: 'ok',
|
|
146
|
+
afterUserMessageIncludes: answer,
|
|
147
|
+
timeout: 8_000,
|
|
148
|
+
});
|
|
149
|
+
await waitForFooterMessage({
|
|
150
|
+
discord: ctx.discord,
|
|
151
|
+
threadId: thread.id,
|
|
152
|
+
timeout: 8_000,
|
|
153
|
+
afterMessageIncludes: 'ok',
|
|
154
|
+
afterAuthorId: ctx.discord.botUserId,
|
|
137
155
|
});
|
|
138
156
|
const timeline = await th.text({ showInteractions: true });
|
|
139
157
|
// The user's text answer must appear in Discord
|
|
140
|
-
expect(timeline).toContain(
|
|
158
|
+
expect(timeline).toContain(answer);
|
|
159
|
+
expect(timeline).toContain('⬥ ok');
|
|
141
160
|
// The original question must have appeared
|
|
142
161
|
expect(timeline).toContain('Which option do you prefer?');
|
|
143
162
|
// The user's marker message triggered the question
|
|
144
163
|
expect(timeline).toContain('QUESTION_TEXT_ANSWER_MARKER');
|
|
145
164
|
}, 20_000);
|
|
146
|
-
});
|
|
147
|
-
describe('queue advanced: voice message during pending question', () => {
|
|
148
|
-
const ctx = setupQueueAdvancedSuite({
|
|
149
|
-
channelId: VOICE_CHANNEL_ID,
|
|
150
|
-
channelName: 'qa-question-voice-e2e',
|
|
151
|
-
dirName: 'qa-question-voice-e2e',
|
|
152
|
-
username: 'queue-question-tester',
|
|
153
|
-
});
|
|
154
|
-
afterEach(() => {
|
|
155
|
-
setDeterministicTranscription(null);
|
|
156
|
-
});
|
|
157
165
|
test('voice message during pending question dismisses question and transcribes normally', async () => {
|
|
158
166
|
// This is the exact bug scenario: user sends a voice message while a
|
|
159
167
|
// question dropdown is pending. Voice messages have empty message.content
|
|
160
168
|
// (audio is in attachments, transcription happens later). The old code
|
|
161
169
|
// passed "" as the question answer and consumed the message — the voice
|
|
162
170
|
// content was completely lost.
|
|
163
|
-
|
|
164
|
-
|
|
171
|
+
const marker = 'QUESTION_TEXT_ANSWER_MARKER voice';
|
|
172
|
+
await ctx.discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
173
|
+
content: marker,
|
|
165
174
|
});
|
|
166
|
-
const thread = await ctx.discord.channel(
|
|
175
|
+
const thread = await ctx.discord.channel(TEXT_CHANNEL_ID).waitForThread({
|
|
167
176
|
timeout: 8_000,
|
|
168
177
|
predicate: (t) => {
|
|
169
|
-
return t.name ===
|
|
178
|
+
return t.name === marker;
|
|
170
179
|
},
|
|
171
180
|
});
|
|
172
181
|
const th = ctx.discord.thread(thread.id);
|
|
@@ -188,10 +197,6 @@ describe('queue advanced: voice message during pending question', () => {
|
|
|
188
197
|
await th.user(TEST_USER_ID).sendVoiceMessage({
|
|
189
198
|
content: 'VOICE_TEXT_CONTENT_SHOULD_NOT_REACH_MODEL',
|
|
190
199
|
});
|
|
191
|
-
// Give time for question cleanup to propagate
|
|
192
|
-
await new Promise((r) => {
|
|
193
|
-
setTimeout(r, 1_000);
|
|
194
|
-
});
|
|
195
200
|
// Voice content should be transcribed and appear as the next user message,
|
|
196
201
|
// processed after the model responds to the empty question answer.
|
|
197
202
|
await waitForBotMessageContaining({
|
|
@@ -84,7 +84,7 @@ e2eTest('queue advanced: typing interrupt', () => {
|
|
|
84
84
|
--- from: assistant (TestBot)
|
|
85
85
|
*using deterministic-provider/deterministic-v2*
|
|
86
86
|
⬥ ok
|
|
87
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
87
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>
|
|
88
88
|
--- from: user (queue-advanced-tester)
|
|
89
89
|
PLUGIN_TIMEOUT_SLEEP_MARKER
|
|
90
90
|
--- from: assistant (TestBot)
|
|
@@ -93,7 +93,7 @@ e2eTest('queue advanced: typing interrupt', () => {
|
|
|
93
93
|
Reply with exactly: typing-stop-interrupt-final
|
|
94
94
|
--- from: assistant (TestBot)
|
|
95
95
|
⬥ ok
|
|
96
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
96
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
97
97
|
`);
|
|
98
98
|
const timeline = await th.text({ showTyping: true });
|
|
99
99
|
expect(finalUserIndex).toBeGreaterThanOrEqual(0);
|
|
@@ -67,7 +67,7 @@ e2eTest('queue delete message', () => {
|
|
|
67
67
|
Queued at position 1. Edit or delete your message to update the queue
|
|
68
68
|
⬦ **queue-delete-tester** removed message from queue
|
|
69
69
|
⬥ slow-busy-reply
|
|
70
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
70
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
71
71
|
`);
|
|
72
72
|
const finalText = await th.text();
|
|
73
73
|
expect(finalText).not.toContain('» **queue-delete-tester:** Reply with exactly: deleted-queue');
|
|
@@ -109,12 +109,12 @@ describe('queue drain with pending interactive UI', () => {
|
|
|
109
109
|
--- from: assistant (TestBot)
|
|
110
110
|
*using deterministic-provider/deterministic-v2*
|
|
111
111
|
⬥ ok
|
|
112
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
112
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>
|
|
113
113
|
**Action Required**
|
|
114
114
|
[user interaction]
|
|
115
115
|
» **drain-ui-tester:** Reply with exactly: post-button-drain
|
|
116
116
|
⬥ ok
|
|
117
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
117
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
118
118
|
`);
|
|
119
119
|
}, 20_000);
|
|
120
120
|
});
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
import { describe, test, expect } from 'vitest';
|
|
16
16
|
import { setupQueueAdvancedSuite, TEST_USER_ID, } from './queue-advanced-e2e-setup.js';
|
|
17
17
|
import { waitForFooterMessage, waitForBotMessageContaining, waitForMessageById, } from './test-utils.js';
|
|
18
|
+
import { getThreadSession } from './database.js';
|
|
19
|
+
import { archiveThread } from './discord-utils.js';
|
|
20
|
+
import { getOpencodeClient } from './opencode.js';
|
|
18
21
|
const TEXT_CHANNEL_ID = '200000000000001099';
|
|
19
22
|
const e2eTest = describe;
|
|
20
23
|
e2eTest('queue + interrupt drain ordering', () => {
|
|
@@ -24,6 +27,113 @@ e2eTest('queue + interrupt drain ordering', () => {
|
|
|
24
27
|
dirName: 'qa-interrupt-drain-e2e',
|
|
25
28
|
username: 'interrupt-tester',
|
|
26
29
|
});
|
|
30
|
+
test('archiving keeps the active run alive so queued messages drain', async () => {
|
|
31
|
+
await ctx.discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
32
|
+
content: 'Reply with exactly: setup-archive-drain',
|
|
33
|
+
});
|
|
34
|
+
const thread = await ctx.discord.channel(TEXT_CHANNEL_ID).waitForThread({
|
|
35
|
+
timeout: 4_000,
|
|
36
|
+
predicate: (candidate) => {
|
|
37
|
+
return candidate.name === 'Reply with exactly: setup-archive-drain';
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
const th = ctx.discord.thread(thread.id);
|
|
41
|
+
await th.waitForBotReply({ timeout: 4_000 });
|
|
42
|
+
await waitForFooterMessage({
|
|
43
|
+
discord: ctx.discord,
|
|
44
|
+
threadId: thread.id,
|
|
45
|
+
timeout: 4_000,
|
|
46
|
+
});
|
|
47
|
+
await th.user(TEST_USER_ID).sendMessage({
|
|
48
|
+
content: 'PLUGIN_TIMEOUT_SLEEP_MARKER archive queue drain',
|
|
49
|
+
});
|
|
50
|
+
await waitForBotMessageContaining({
|
|
51
|
+
discord: ctx.discord,
|
|
52
|
+
threadId: thread.id,
|
|
53
|
+
userId: TEST_USER_ID,
|
|
54
|
+
text: 'starting sleep',
|
|
55
|
+
afterUserMessageIncludes: 'PLUGIN_TIMEOUT_SLEEP_MARKER archive queue drain',
|
|
56
|
+
timeout: 4_000,
|
|
57
|
+
});
|
|
58
|
+
const { id: queueInteractionId } = await th.user(TEST_USER_ID)
|
|
59
|
+
.runSlashCommand({
|
|
60
|
+
name: 'queue',
|
|
61
|
+
options: [{
|
|
62
|
+
name: 'message',
|
|
63
|
+
type: 3,
|
|
64
|
+
value: 'Reply with exactly: archived-queue-survives',
|
|
65
|
+
}],
|
|
66
|
+
});
|
|
67
|
+
const queueAck = await th.waitForInteractionAck({
|
|
68
|
+
interactionId: queueInteractionId,
|
|
69
|
+
timeout: 4_000,
|
|
70
|
+
});
|
|
71
|
+
if (!queueAck.messageId) {
|
|
72
|
+
throw new Error('Expected /queue response message id');
|
|
73
|
+
}
|
|
74
|
+
const queueStatusMessage = await waitForMessageById({
|
|
75
|
+
discord: ctx.discord,
|
|
76
|
+
threadId: thread.id,
|
|
77
|
+
messageId: queueAck.messageId,
|
|
78
|
+
timeout: 4_000,
|
|
79
|
+
});
|
|
80
|
+
expect(queueStatusMessage.content).toContain('Queued message');
|
|
81
|
+
const sessionId = await getThreadSession(thread.id);
|
|
82
|
+
if (!sessionId)
|
|
83
|
+
throw new Error('Expected mapped OpenCode session');
|
|
84
|
+
const client = getOpencodeClient(ctx.directories.projectDirectory);
|
|
85
|
+
if (!client)
|
|
86
|
+
throw new Error('Expected initialized OpenCode client');
|
|
87
|
+
await archiveThread({
|
|
88
|
+
rest: ctx.botClient.rest,
|
|
89
|
+
threadId: thread.id,
|
|
90
|
+
parentChannelId: TEXT_CHANNEL_ID,
|
|
91
|
+
sessionId,
|
|
92
|
+
client,
|
|
93
|
+
});
|
|
94
|
+
const statusResponse = await client.session.status({
|
|
95
|
+
directory: ctx.directories.projectDirectory,
|
|
96
|
+
});
|
|
97
|
+
expect(statusResponse.data?.[sessionId]?.type).toBe('busy');
|
|
98
|
+
await th.user(TEST_USER_ID).sendMessage({
|
|
99
|
+
content: 'Reply with exactly: continue-after-archive',
|
|
100
|
+
});
|
|
101
|
+
await waitForFooterMessage({
|
|
102
|
+
discord: ctx.discord,
|
|
103
|
+
threadId: thread.id,
|
|
104
|
+
timeout: 12_000,
|
|
105
|
+
afterMessageIncludes: 'continue-after-archive',
|
|
106
|
+
afterAuthorId: TEST_USER_ID,
|
|
107
|
+
});
|
|
108
|
+
await waitForFooterMessage({
|
|
109
|
+
discord: ctx.discord,
|
|
110
|
+
threadId: thread.id,
|
|
111
|
+
timeout: 12_000,
|
|
112
|
+
afterMessageIncludes: 'archived-queue-survives',
|
|
113
|
+
afterAuthorId: ctx.discord.botUserId,
|
|
114
|
+
});
|
|
115
|
+
expect(await th.text()).toMatchInlineSnapshot(`
|
|
116
|
+
"--- from: user (interrupt-tester)
|
|
117
|
+
Reply with exactly: setup-archive-drain
|
|
118
|
+
--- from: assistant (TestBot)
|
|
119
|
+
*using deterministic-provider/deterministic-v2*
|
|
120
|
+
⬥ ok
|
|
121
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>
|
|
122
|
+
--- from: user (interrupt-tester)
|
|
123
|
+
PLUGIN_TIMEOUT_SLEEP_MARKER archive queue drain
|
|
124
|
+
--- from: assistant (TestBot)
|
|
125
|
+
⬥ starting sleep 100
|
|
126
|
+
Queued message (position 1)
|
|
127
|
+
--- from: user (interrupt-tester)
|
|
128
|
+
Reply with exactly: continue-after-archive
|
|
129
|
+
--- from: assistant (TestBot)
|
|
130
|
+
⬥ ok
|
|
131
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
132
|
+
» **interrupt-tester:** Reply with exactly: archived-queue-survives
|
|
133
|
+
⬥ ok
|
|
134
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
135
|
+
`);
|
|
136
|
+
}, 20_000);
|
|
27
137
|
test('queued message via /queue + normal interrupt: interrupt reply should appear, then queue drains', async () => {
|
|
28
138
|
// 1. Establish session with a quick first message
|
|
29
139
|
await ctx.discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
@@ -100,7 +210,7 @@ e2eTest('queue + interrupt drain ordering', () => {
|
|
|
100
210
|
--- from: assistant (TestBot)
|
|
101
211
|
*using deterministic-provider/deterministic-v2*
|
|
102
212
|
⬥ ok
|
|
103
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
213
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>
|
|
104
214
|
--- from: user (interrupt-tester)
|
|
105
215
|
PLUGIN_TIMEOUT_SLEEP_MARKER
|
|
106
216
|
--- from: assistant (TestBot)
|
|
@@ -113,7 +223,7 @@ e2eTest('queue + interrupt drain ordering', () => {
|
|
|
113
223
|
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
114
224
|
» **interrupt-tester:** Reply with exactly: queued-behind-slow
|
|
115
225
|
⬥ ok
|
|
116
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
226
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
117
227
|
`);
|
|
118
228
|
// 7. Assert the interrupt message got its own ⬥ ok reply between the
|
|
119
229
|
// user's interrupt message and the queue dispatch indicator.
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
// E2e test
|
|
2
|
-
// via the Discord dropdown select menu. Reproduces a bug where answering via
|
|
3
|
-
// select (not text) leaves queued messages stuck because the session continues
|
|
4
|
-
// processing after the answer and may enter another blocking state.
|
|
1
|
+
// E2e test for ordered queue drain after a pending question is answered via select.
|
|
5
2
|
import { describe, test, expect } from 'vitest';
|
|
6
3
|
import { setupQueueAdvancedSuite, TEST_USER_ID, } from './queue-advanced-e2e-setup.js';
|
|
7
4
|
import { waitForBotMessageContaining, waitForFooterMessage, } from './test-utils.js';
|
|
@@ -27,8 +24,7 @@ async function expectNoBotMessageContaining({ discord, threadId, text, timeout,
|
|
|
27
24
|
while (Date.now() - start < timeout) {
|
|
28
25
|
const messages = await discord.thread(threadId).getMessages();
|
|
29
26
|
const match = messages.find((message) => {
|
|
30
|
-
return
|
|
31
|
-
&& message.content.includes(text));
|
|
27
|
+
return message.author.id === discord.botUserId && message.content.includes(text);
|
|
32
28
|
});
|
|
33
29
|
if (match) {
|
|
34
30
|
throw new Error(`Unexpected bot message containing ${JSON.stringify(text)} while it should still be queued`);
|
|
@@ -45,110 +41,15 @@ describe('queue drain after question select answer', () => {
|
|
|
45
41
|
dirName: 'qa-question-select-drain',
|
|
46
42
|
username: 'question-select-tester',
|
|
47
43
|
});
|
|
48
|
-
test('queued
|
|
49
|
-
|
|
50
|
-
await ctx.discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
51
|
-
content: 'QUESTION_SELECT_QUEUE_MARKER',
|
|
52
|
-
});
|
|
53
|
-
const thread = await ctx.discord.channel(TEXT_CHANNEL_ID).waitForThread({
|
|
54
|
-
timeout: 8_000,
|
|
55
|
-
predicate: (t) => {
|
|
56
|
-
return t.name === 'QUESTION_SELECT_QUEUE_MARKER';
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
const th = ctx.discord.thread(thread.id);
|
|
60
|
-
// 2. Wait for the question dropdown message to appear in Discord.
|
|
61
|
-
// Uses visible message wait instead of internal Map polling which
|
|
62
|
-
// is too timing-sensitive on CI.
|
|
63
|
-
const questionMessages = await waitForBotMessageContaining({
|
|
64
|
-
discord: ctx.discord,
|
|
65
|
-
threadId: thread.id,
|
|
66
|
-
text: 'How to proceed?',
|
|
67
|
-
timeout: 12_000,
|
|
68
|
-
});
|
|
69
|
-
// Get the pending question context hash from the internal map.
|
|
70
|
-
// By this point the question message is visible so the context must exist.
|
|
71
|
-
const pending = await waitForPendingQuestion({
|
|
72
|
-
threadId: thread.id,
|
|
73
|
-
timeoutMs: 8_000,
|
|
74
|
-
});
|
|
75
|
-
const questionMsg = questionMessages.find((m) => {
|
|
76
|
-
return m.content.includes('How to proceed?');
|
|
77
|
-
});
|
|
78
|
-
expect(questionMsg).toBeTruthy();
|
|
79
|
-
// 3. Queue a message while question is pending
|
|
80
|
-
const { id: queueInteractionId } = await th.user(TEST_USER_ID)
|
|
81
|
-
.runSlashCommand({
|
|
82
|
-
name: 'queue',
|
|
83
|
-
options: [{ name: 'message', type: 3, value: 'Reply with exactly: post-question-drain' }],
|
|
84
|
-
});
|
|
85
|
-
const queueAck = await th.waitForInteractionAck({
|
|
86
|
-
interactionId: queueInteractionId,
|
|
87
|
-
timeout: 8_000,
|
|
88
|
-
});
|
|
89
|
-
if (!queueAck.messageId) {
|
|
90
|
-
throw new Error('Expected /queue response message id');
|
|
91
|
-
}
|
|
92
|
-
// 4. The first queued item should be handed off immediately even while
|
|
93
|
-
// the question is still pending, so the visible dispatch indicator
|
|
94
|
-
// appears before the user answers the dropdown.
|
|
95
|
-
await waitForBotMessageContaining({
|
|
96
|
-
discord: ctx.discord,
|
|
97
|
-
threadId: thread.id,
|
|
98
|
-
text: '» **question-select-tester:** Reply with exactly: post-question-drain',
|
|
99
|
-
timeout: 8_000,
|
|
100
|
-
});
|
|
101
|
-
// 5. Answer the question via dropdown select (pick first option "Alpha")
|
|
102
|
-
const interaction = await th.user(TEST_USER_ID).selectMenu({
|
|
103
|
-
messageId: questionMsg.id,
|
|
104
|
-
customId: `ask_question:${pending.contextHash}:0`,
|
|
105
|
-
values: ['0'],
|
|
106
|
-
});
|
|
107
|
-
await th.waitForInteractionAck({
|
|
108
|
-
interactionId: interaction.id,
|
|
109
|
-
timeout: 8_000,
|
|
110
|
-
});
|
|
111
|
-
// 6. Wait for footer from the drained queued message
|
|
112
|
-
await waitForFooterMessage({
|
|
113
|
-
discord: ctx.discord,
|
|
114
|
-
threadId: thread.id,
|
|
115
|
-
timeout: 8_000,
|
|
116
|
-
afterMessageIncludes: '» **question-select-tester:**',
|
|
117
|
-
afterAuthorId: ctx.discord.botUserId,
|
|
118
|
-
});
|
|
119
|
-
const timeline = await th.text({ showInteractions: true });
|
|
120
|
-
expect(timeline).toMatchInlineSnapshot(`
|
|
121
|
-
"--- from: user (question-select-tester)
|
|
122
|
-
QUESTION_SELECT_QUEUE_MARKER
|
|
123
|
-
--- from: assistant (TestBot)
|
|
124
|
-
*using deterministic-provider/deterministic-v2*
|
|
125
|
-
**Select action**
|
|
126
|
-
How to proceed?
|
|
127
|
-
✓ _Alpha_
|
|
128
|
-
[user interaction]
|
|
129
|
-
» **question-select-tester:** Reply with exactly: post-question-drain
|
|
130
|
-
Queued message (position 1)
|
|
131
|
-
[user selects dropdown: 0]
|
|
132
|
-
» **question-select-tester:** Alpha
|
|
133
|
-
⬥ ok
|
|
134
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
135
|
-
`);
|
|
136
|
-
expect(timeline).toContain('QUESTION_SELECT_QUEUE_MARKER');
|
|
137
|
-
expect(timeline).toContain('How to proceed?');
|
|
138
|
-
expect(timeline).toContain('[user selects dropdown: 0]');
|
|
139
|
-
expect(timeline).toContain('» **question-select-tester:** Reply with exactly: post-question-drain');
|
|
140
|
-
expect(timeline).toContain('⬥ ok');
|
|
141
|
-
expect(timeline).toContain('*project ⋅ main ⋅');
|
|
142
|
-
}, 20_000);
|
|
143
|
-
test('only the first queued message is handed off after dropdown answer', async () => {
|
|
144
|
-
const marker = 'QUESTION_SELECT_QUEUE_MARKER second-test';
|
|
44
|
+
test('queued messages drain in order after answering via dropdown select', async () => {
|
|
45
|
+
const marker = 'QUESTION_SELECT_QUEUE_MARKER';
|
|
145
46
|
await ctx.discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
146
47
|
content: marker,
|
|
147
48
|
});
|
|
148
49
|
const thread = await ctx.discord.channel(TEXT_CHANNEL_ID).waitForThread({
|
|
149
50
|
timeout: 8_000,
|
|
150
|
-
predicate: (
|
|
151
|
-
return
|
|
51
|
+
predicate: (candidate) => {
|
|
52
|
+
return candidate.name === marker;
|
|
152
53
|
},
|
|
153
54
|
});
|
|
154
55
|
const th = ctx.discord.thread(thread.id);
|
|
@@ -162,14 +63,13 @@ describe('queue drain after question select answer', () => {
|
|
|
162
63
|
threadId: thread.id,
|
|
163
64
|
timeoutMs: 8_000,
|
|
164
65
|
});
|
|
165
|
-
const
|
|
66
|
+
const questionMessage = questionMessages.find((message) => {
|
|
166
67
|
return message.content.includes('How to proceed?');
|
|
167
68
|
});
|
|
168
|
-
|
|
169
|
-
if (!questionMsg) {
|
|
69
|
+
if (!questionMessage) {
|
|
170
70
|
throw new Error('Expected question message');
|
|
171
71
|
}
|
|
172
|
-
const firstQueuedPrompt = '
|
|
72
|
+
const firstQueuedPrompt = 'QUESTION_SELECT_DRAIN_FIRST_MARKER';
|
|
173
73
|
const secondQueuedPrompt = 'Reply with exactly: post-question-second';
|
|
174
74
|
const { id: firstQueueInteractionId } = await th.user(TEST_USER_ID)
|
|
175
75
|
.runSlashCommand({
|
|
@@ -180,6 +80,12 @@ describe('queue drain after question select answer', () => {
|
|
|
180
80
|
interactionId: firstQueueInteractionId,
|
|
181
81
|
timeout: 8_000,
|
|
182
82
|
});
|
|
83
|
+
await waitForBotMessageContaining({
|
|
84
|
+
discord: ctx.discord,
|
|
85
|
+
threadId: thread.id,
|
|
86
|
+
text: `» **question-select-tester:** ${firstQueuedPrompt}`,
|
|
87
|
+
timeout: 8_000,
|
|
88
|
+
});
|
|
183
89
|
const { id: secondQueueInteractionId } = await th.user(TEST_USER_ID)
|
|
184
90
|
.runSlashCommand({
|
|
185
91
|
name: 'queue',
|
|
@@ -189,8 +95,14 @@ describe('queue drain after question select answer', () => {
|
|
|
189
95
|
interactionId: secondQueueInteractionId,
|
|
190
96
|
timeout: 8_000,
|
|
191
97
|
});
|
|
98
|
+
await expectNoBotMessageContaining({
|
|
99
|
+
discord: ctx.discord,
|
|
100
|
+
threadId: thread.id,
|
|
101
|
+
text: `» **question-select-tester:** ${secondQueuedPrompt}`,
|
|
102
|
+
timeout: 200,
|
|
103
|
+
});
|
|
192
104
|
const interaction = await th.user(TEST_USER_ID).selectMenu({
|
|
193
|
-
messageId:
|
|
105
|
+
messageId: questionMessage.id,
|
|
194
106
|
customId: `ask_question:${pending.contextHash}:0`,
|
|
195
107
|
values: ['0'],
|
|
196
108
|
});
|
|
@@ -198,18 +110,6 @@ describe('queue drain after question select answer', () => {
|
|
|
198
110
|
interactionId: interaction.id,
|
|
199
111
|
timeout: 8_000,
|
|
200
112
|
});
|
|
201
|
-
await waitForBotMessageContaining({
|
|
202
|
-
discord: ctx.discord,
|
|
203
|
-
threadId: thread.id,
|
|
204
|
-
text: `» **question-select-tester:** ${firstQueuedPrompt}`,
|
|
205
|
-
timeout: 8_000,
|
|
206
|
-
});
|
|
207
|
-
await expectNoBotMessageContaining({
|
|
208
|
-
discord: ctx.discord,
|
|
209
|
-
threadId: thread.id,
|
|
210
|
-
text: `» **question-select-tester:** ${secondQueuedPrompt}`,
|
|
211
|
-
timeout: 200,
|
|
212
|
-
});
|
|
213
113
|
await waitForFooterMessage({
|
|
214
114
|
discord: ctx.discord,
|
|
215
115
|
threadId: thread.id,
|
|
@@ -233,28 +133,30 @@ describe('queue drain after question select answer', () => {
|
|
|
233
133
|
const timeline = await th.text({ showInteractions: true });
|
|
234
134
|
expect(timeline).toMatchInlineSnapshot(`
|
|
235
135
|
"--- from: user (question-select-tester)
|
|
236
|
-
QUESTION_SELECT_QUEUE_MARKER
|
|
136
|
+
QUESTION_SELECT_QUEUE_MARKER
|
|
237
137
|
--- from: assistant (TestBot)
|
|
238
138
|
*using deterministic-provider/deterministic-v2*
|
|
239
139
|
**Select action**
|
|
240
140
|
How to proceed?
|
|
241
141
|
✓ _Alpha_
|
|
242
142
|
[user interaction]
|
|
243
|
-
» **question-select-tester:**
|
|
143
|
+
» **question-select-tester:** QUESTION_SELECT_DRAIN_FIRST_MARKER
|
|
244
144
|
Queued message (position 1)
|
|
245
145
|
[user interaction]
|
|
246
146
|
Queued message (position 1)
|
|
247
147
|
[user selects dropdown: 0]
|
|
248
148
|
» **question-select-tester:** Alpha
|
|
249
|
-
⬥
|
|
149
|
+
⬥ question-drain-first
|
|
250
150
|
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
251
151
|
» **question-select-tester:** Reply with exactly: post-question-second
|
|
252
152
|
⬥ ok
|
|
253
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
153
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000991>"
|
|
254
154
|
`);
|
|
155
|
+
expect(timeline).toContain('How to proceed?');
|
|
156
|
+
expect(timeline).toContain('[user selects dropdown: 0]');
|
|
255
157
|
expect(timeline).toContain(`» **question-select-tester:** ${firstQueuedPrompt}`);
|
|
256
|
-
expect(timeline).toContain('⬥
|
|
158
|
+
expect(timeline).toContain('⬥ question-drain-first');
|
|
257
159
|
expect(timeline).toContain(`» **question-select-tester:** ${secondQueuedPrompt}`);
|
|
258
160
|
expect(timeline).toContain('⬥ ok');
|
|
259
|
-
},
|
|
161
|
+
}, 15_000);
|
|
260
162
|
});
|
|
@@ -202,10 +202,10 @@ describe('runtime lifecycle', () => {
|
|
|
202
202
|
fs.rmSync(directories.dataDir, { recursive: true, force: true });
|
|
203
203
|
}
|
|
204
204
|
}, 5_000);
|
|
205
|
-
test('
|
|
206
|
-
// Sends A, waits for full completion (footer), sends B
|
|
207
|
-
//
|
|
208
|
-
//
|
|
205
|
+
test('two sequential completions reuse same runtime and listener', async () => {
|
|
206
|
+
// Sends A, waits for full completion (footer), then sends B and waits
|
|
207
|
+
// for its footer. Proves the listener stays alive across full run cycles
|
|
208
|
+
// without any interrupt/queue involvement.
|
|
209
209
|
// This is the "calm" path — no abort, no queue, just sequential use.
|
|
210
210
|
// 1. Send first message → thread created, session established
|
|
211
211
|
await discord.channel(TEXT_CHANNEL_ID).user(TEST_USER_ID).sendMessage({
|
|
@@ -251,47 +251,20 @@ describe('runtime lifecycle', () => {
|
|
|
251
251
|
});
|
|
252
252
|
// Same runtime instance — listener was not recreated
|
|
253
253
|
const runtimeAfterB = getRuntime(thread.id);
|
|
254
|
-
expect(runtimeAfterB).toBe(runtimeAfterA);
|
|
255
|
-
// 3. Send C after B fully completed
|
|
256
|
-
await th.user(TEST_USER_ID).sendMessage({
|
|
257
|
-
content: 'Reply with exactly: seq-gamma',
|
|
258
|
-
});
|
|
259
|
-
await waitForBotReplyAfterUserMessage({
|
|
260
|
-
discord,
|
|
261
|
-
threadId: thread.id,
|
|
262
|
-
userId: TEST_USER_ID,
|
|
263
|
-
userMessageIncludes: 'seq-gamma',
|
|
264
|
-
timeout: 4_000,
|
|
265
|
-
});
|
|
266
|
-
await waitForBotMessageContaining({
|
|
267
|
-
discord,
|
|
268
|
-
threadId: thread.id,
|
|
269
|
-
userId: TEST_USER_ID,
|
|
270
|
-
text: '*project',
|
|
271
|
-
afterUserMessageIncludes: 'seq-gamma',
|
|
272
|
-
timeout: 4_000,
|
|
273
|
-
});
|
|
274
|
-
// Still the same runtime — three full cycles, one runtime, one listener
|
|
275
|
-
const runtimeAfterC = getRuntime(thread.id);
|
|
276
254
|
expect(await th.text()).toMatchInlineSnapshot(`
|
|
277
255
|
"--- from: user (lifecycle-tester)
|
|
278
256
|
Reply with exactly: seq-alpha
|
|
279
257
|
--- from: assistant (TestBot)
|
|
280
258
|
*using deterministic-provider/deterministic-v2*
|
|
281
259
|
⬥ ok
|
|
282
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
260
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000888>
|
|
283
261
|
--- from: user (lifecycle-tester)
|
|
284
262
|
Reply with exactly: seq-beta
|
|
285
263
|
--- from: assistant (TestBot)
|
|
286
264
|
⬥ ok
|
|
287
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
288
|
-
--- from: user (lifecycle-tester)
|
|
289
|
-
Reply with exactly: seq-gamma
|
|
290
|
-
--- from: assistant (TestBot)
|
|
291
|
-
⬥ ok
|
|
292
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
265
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000888>"
|
|
293
266
|
`);
|
|
294
|
-
expect(
|
|
267
|
+
expect(runtimeAfterB).toBe(runtimeAfterA);
|
|
295
268
|
}, 15_000);
|
|
296
269
|
test('footer includes context percentage and model id', async () => {
|
|
297
270
|
const prompt = 'Reply with exactly: footer-check';
|
|
@@ -327,7 +300,7 @@ describe('runtime lifecycle', () => {
|
|
|
327
300
|
--- from: assistant (TestBot)
|
|
328
301
|
*using deterministic-provider/deterministic-v2*
|
|
329
302
|
⬥ ok
|
|
330
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
303
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000888>"
|
|
331
304
|
`);
|
|
332
305
|
expect(footerMessage).toBeDefined();
|
|
333
306
|
if (!footerMessage) {
|
|
@@ -385,12 +358,12 @@ describe('runtime lifecycle', () => {
|
|
|
385
358
|
--- from: assistant (TestBot)
|
|
386
359
|
*using deterministic-provider/deterministic-v2*
|
|
387
360
|
⬥ ok
|
|
388
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*
|
|
361
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000888>
|
|
389
362
|
--- from: user (lifecycle-tester)
|
|
390
363
|
Reply with exactly: reconnect-beta
|
|
391
364
|
--- from: assistant (TestBot)
|
|
392
365
|
⬥ ok
|
|
393
|
-
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2*"
|
|
366
|
+
*project ⋅ main ⋅ Ns ⋅ N% ⋅ deterministic-v2* <@200000000000000888>"
|
|
394
367
|
`);
|
|
395
368
|
const runtimeAfterRestart = getRuntime(thread.id);
|
|
396
369
|
expect(runtimeAfterRestart).toBe(runtimeBeforeRestart);
|
package/dist/schema.js
CHANGED
|
@@ -27,6 +27,10 @@ export const thread_sessions = sqliteCore.sqliteTable('thread_sessions', {
|
|
|
27
27
|
// Survives bot restarts so child multi-turn system prompts keep the parent ID.
|
|
28
28
|
parent_session_id: sqliteCore.text('parent_session_id'),
|
|
29
29
|
created_at: datetime('created_at').default(orm.sql `CURRENT_TIMESTAMP`),
|
|
30
|
+
// Bumped on every (re)binding of a session to this thread. /resume can map one
|
|
31
|
+
// session to several threads, so session_id -> thread_id needs a tiebreaker.
|
|
32
|
+
// Without it the reverse lookup is arbitrary and tools can target a dead thread.
|
|
33
|
+
updated_at: datetime('updated_at').default(orm.sql `CURRENT_TIMESTAMP`).$onUpdate(() => new Date()),
|
|
30
34
|
});
|
|
31
35
|
export const session_events = sqliteCore.sqliteTable('session_events', {
|
|
32
36
|
id: sqliteCore.integer('id', { mode: 'number' }).primaryKey({ autoIncrement: true }).notNull(),
|
|
@@ -198,6 +202,35 @@ export const forum_sync_configs = sqliteCore.sqliteTable('forum_sync_configs', {
|
|
|
198
202
|
}, (table) => [
|
|
199
203
|
sqliteCore.uniqueIndex('forum_sync_configs_app_id_forum_channel_id_key').on(table.app_id, table.forum_channel_id),
|
|
200
204
|
]);
|
|
205
|
+
// Durable "wake this session later" rows for the kimaki_sleep tool.
|
|
206
|
+
//
|
|
207
|
+
// Delivery is at-least-once, and ingress makes it at-most-once-per-turn:
|
|
208
|
+
//
|
|
209
|
+
// planned ──► consumed cancelled / failed are terminal
|
|
210
|
+
// ▲ │
|
|
211
|
+
// └───┘ retried until ingress consumes it
|
|
212
|
+
//
|
|
213
|
+
// A row stays `planned` until ingress turns the wake into a turn, so ANY loss
|
|
214
|
+
// (crash before posting, crash after posting, missed gateway event) is covered
|
|
215
|
+
// by the same retry. `delivery_id` is the Discord message nonce, so a retry
|
|
216
|
+
// returns the existing message instead of waking the session twice.
|
|
217
|
+
//
|
|
218
|
+
// There is no thread_id: the owning thread is resolved from session_id at wake
|
|
219
|
+
// time, so a session rebound by /resume wakes in its current thread.
|
|
220
|
+
export const session_sleeps = sqliteCore.sqliteTable('session_sleeps', {
|
|
221
|
+
session_id: sqliteCore.text('session_id').primaryKey().notNull(),
|
|
222
|
+
wake_at: datetime('wake_at').notNull(),
|
|
223
|
+
reason: sqliteCore.text('reason'),
|
|
224
|
+
status: sqliteCore.text('status', { enum: ['planned', 'consumed', 'cancelled', 'failed'] }).notNull().default('planned'),
|
|
225
|
+
// Regenerated per sleep occurrence. Doubles as the Discord nonce and as a
|
|
226
|
+
// generation guard so a stale in-flight wake cannot mutate a newer sleep.
|
|
227
|
+
delivery_id: sqliteCore.text('delivery_id').notNull().$defaultFn(() => crypto.randomUUID()),
|
|
228
|
+
attempts: sqliteCore.integer('attempts', { mode: 'number' }).notNull().default(0),
|
|
229
|
+
last_attempt_at: datetime('last_attempt_at'),
|
|
230
|
+
created_at: datetime('created_at').default(orm.sql `CURRENT_TIMESTAMP`),
|
|
231
|
+
}, (table) => [
|
|
232
|
+
sqliteCore.index('session_sleeps_status_wake_at_idx').on(table.status, table.wake_at),
|
|
233
|
+
]);
|
|
201
234
|
export const ipc_requests = sqliteCore.sqliteTable('ipc_requests', {
|
|
202
235
|
id: sqliteCore.text('id').primaryKey().notNull().$defaultFn(() => crypto.randomUUID()),
|
|
203
236
|
type: sqliteCore.text('type', { enum: ['file_upload', 'action_buttons'] }).notNull(),
|
|
@@ -232,6 +265,7 @@ export const relations = defineRelations({
|
|
|
232
265
|
scheduled_task_runs,
|
|
233
266
|
session_start_sources,
|
|
234
267
|
forum_sync_configs,
|
|
268
|
+
session_sleeps,
|
|
235
269
|
ipc_requests,
|
|
236
270
|
}, (r) => ({
|
|
237
271
|
thread_sessions: {
|