@cortex-agent/server 2026.5.19-3 → 2026.5.22-2
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/README.md +5 -1
- package/defaults/config/thread-templates.json +65 -39
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +4 -4
- package/defaults/prompts/directives/coder-reviewer.md +9 -4
- package/defaults/prompts/directives/coder.md +10 -2
- package/dist/core/gateway-generator.js +26 -4
- package/dist/core/log.js +61 -12
- package/dist/core/profile-generator.js +4 -3
- package/dist/core/status-format.js +1 -1
- package/dist/core/task-parser.d.ts +1 -1
- package/dist/core/task-parser.js +13 -6
- package/dist/core/types/thread-types.d.ts +4 -2
- package/dist/domain/costs/codex-usage-monitor.d.ts +1 -2
- package/dist/domain/costs/codex-usage-monitor.js +2 -2
- package/dist/domain/costs/cost-tracker.d.ts +2 -0
- package/dist/domain/costs/cost-tracker.js +4 -20
- package/dist/domain/costs/rate-limit-throttle.js +1 -4
- package/dist/domain/mcp/tools/context.d.ts +4 -2
- package/dist/domain/mcp/tools/context.js +7 -5
- package/dist/domain/mcp/tools/schedule.d.ts +1 -1
- package/dist/domain/mcp/tools/schedule.js +24 -20
- package/dist/domain/memory/index-regen.js +8 -5
- package/dist/domain/monitor/disk-monitor.js +1 -6
- package/dist/domain/projects/index.d.ts +2 -0
- package/dist/domain/projects/index.js +3 -0
- package/dist/domain/projects/project-store.d.ts +54 -0
- package/dist/domain/projects/project-store.js +194 -0
- package/dist/domain/projects/project-types.d.ts +11 -0
- package/dist/domain/projects/project-types.js +5 -0
- package/dist/domain/remote/client-hot-reload.d.ts +1 -0
- package/dist/domain/remote/client-hot-reload.js +284 -53
- package/dist/domain/scheduling/jobs/_shared.d.ts +1 -1
- package/dist/domain/scheduling/jobs/_shared.js +6 -5
- package/dist/domain/scheduling/jobs/memory-index-regen.js +2 -2
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +2 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +38 -36
- package/dist/domain/scheduling/jobs/sync-public.d.ts +1 -0
- package/dist/domain/scheduling/jobs/sync-public.js +34 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +3 -7
- package/dist/domain/scheduling/jobs/target-dispatch.js +7 -9
- package/dist/domain/scheduling/jobs/task-archive.js +2 -2
- package/dist/domain/scheduling/jobs/task-dispatch.js +18 -16
- package/dist/domain/scheduling/runner.d.ts +1 -0
- package/dist/domain/scheduling/runner.js +2 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +1 -0
- package/dist/domain/scheduling/schedule-cli.js +14 -14
- package/dist/domain/scheduling/schedule-command.js +45 -36
- package/dist/domain/scheduling/scheduler.d.ts +1 -1
- package/dist/domain/scheduling/scheduler.js +12 -11
- package/dist/domain/sessions/session-hooks.d.ts +10 -11
- package/dist/domain/sessions/session-hooks.js +26 -27
- package/dist/domain/sessions/session-registry.d.ts +10 -5
- package/dist/domain/sessions/session-registry.js +24 -9
- package/dist/domain/tasks/pending-tracker.js +8 -9
- package/dist/domain/tasks/system/task-cli.d.ts +2 -0
- package/dist/domain/tasks/system/task-cli.js +189 -29
- package/dist/domain/tasks/system/task-lifecycle-edit.js +3 -3
- package/dist/domain/threads/hook-runner.js +12 -7
- package/dist/domain/threads/runner.d.ts +3 -3
- package/dist/domain/threads/runner.js +30 -28
- package/dist/domain/threads/state-machine.d.ts +3 -0
- package/dist/domain/threads/state-machine.js +4 -0
- package/dist/entry/app.js +30 -9
- package/dist/entry/cli.js +19 -4
- package/dist/entry/daemon.js +28 -2
- package/dist/entry/startup-notify.js +8 -6
- package/dist/orchestration/agent-runner.js +19 -13
- package/dist/orchestration/durable-helpers.js +3 -2
- package/dist/orchestration/interactions/ask-user-question.d.ts +2 -3
- package/dist/orchestration/interactions/ask-user-question.js +5 -4
- package/dist/orchestration/interactions/interaction-handlers.js +8 -5
- package/dist/orchestration/interactions/plan-handler.js +3 -3
- package/dist/orchestration/lifecycle.js +43 -38
- package/dist/orchestration/routing/commands/cancel.js +9 -8
- package/dist/orchestration/routing/commands/channel.js +32 -26
- package/dist/orchestration/routing/commands/cost.js +5 -3
- package/dist/orchestration/routing/commands/device.js +2 -1
- package/dist/orchestration/routing/commands/dispatch.js +8 -7
- package/dist/orchestration/routing/commands/index.js +7 -4
- package/dist/orchestration/routing/commands/mode.js +24 -18
- package/dist/orchestration/routing/commands/nvtop.js +14 -12
- package/dist/orchestration/routing/commands/orient.js +2 -1
- package/dist/orchestration/routing/commands/schedule.js +2 -1
- package/dist/orchestration/routing/commands/sendfile.js +12 -9
- package/dist/orchestration/routing/commands/session.js +12 -10
- package/dist/orchestration/routing/commands/status.js +2 -2
- package/dist/orchestration/routing/commands/tail.js +10 -6
- package/dist/orchestration/routing/commands/task.js +5 -4
- package/dist/orchestration/routing/commands/thread-handlers.js +19 -12
- package/dist/orchestration/routing/hook-bridge-subscribers.js +15 -13
- package/dist/orchestration/status-helpers.d.ts +4 -5
- package/dist/orchestration/status-helpers.js +7 -8
- package/dist/orchestration/thread-executor.js +21 -12
- package/dist/platform/adapter.d.ts +13 -9
- package/dist/platform/adapter.js +1 -1
- package/dist/platform/adapters/feishu-output-stream.d.ts +27 -0
- package/dist/platform/adapters/feishu-output-stream.js +114 -0
- package/dist/platform/adapters/feishu.d.ts +16 -7
- package/dist/platform/adapters/feishu.js +64 -18
- package/dist/platform/adapters/index.d.ts +4 -1
- package/dist/platform/adapters/index.js +1 -1
- package/dist/platform/adapters/slack-output-stream.d.ts +55 -0
- package/dist/platform/{virtual-message.js → adapters/slack-output-stream.js} +98 -165
- package/dist/platform/adapters/slack-project-conduits.d.ts +9 -0
- package/dist/platform/adapters/slack-project-conduits.js +40 -0
- package/dist/platform/adapters/slack.d.ts +18 -8
- package/dist/platform/adapters/slack.js +82 -24
- package/dist/platform/index.d.ts +3 -2
- package/dist/platform/index.js +1 -1
- package/dist/platform/output-stream-chunk.d.ts +6 -0
- package/dist/platform/output-stream-chunk.js +45 -0
- package/dist/platform/output-stream-helpers.d.ts +6 -0
- package/dist/platform/output-stream-helpers.js +11 -0
- package/dist/platform/output-stream.d.ts +28 -0
- package/dist/platform/output-stream.js +4 -0
- package/dist/platform/testing.d.ts +41 -8
- package/dist/platform/testing.js +93 -11
- package/dist/platform/tool-trace.d.ts +9 -8
- package/dist/platform/tool-trace.js +19 -17
- package/dist/platform/types.d.ts +21 -1
- package/dist/platform/types.js +17 -1
- package/dist/store/channel-repo.d.ts +6 -0
- package/dist/store/channel-repo.js +9 -0
- package/dist/store/json-repository.js +12 -1
- package/dist/store/outbound-queue.d.ts +5 -4
- package/dist/store/outbound-queue.js +9 -6
- package/dist/store/schedule-repo.d.ts +9 -5
- package/dist/store/schedule-repo.js +59 -14
- package/dist/store/session-registry-repo.d.ts +36 -7
- package/dist/store/session-registry-repo.js +186 -25
- package/dist/store/thread-repo.d.ts +1 -0
- package/dist/store/thread-repo.js +8 -0
- package/package.json +1 -1
- package/dist/platform/virtual-message.d.ts +0 -68
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
// pos: !schedule subcommand routing and profile pinning
|
|
4
4
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
5
|
import { formatDuration, formatTimeUntil, parseDuration } from './scheduler.js';
|
|
6
|
+
import { channelToProjectId } from '../../store/schedule-repo.js';
|
|
6
7
|
import { listProfiles, resolveProfile, getDefaultProfileName } from '../agents/profile-manager.js';
|
|
8
|
+
/** Convert a raw channel string to a Destination for postMessage calls. */
|
|
9
|
+
function toDest(channel) {
|
|
10
|
+
return { type: 'interactive-reply', conduit: channel };
|
|
11
|
+
}
|
|
7
12
|
function scheduleHelp() {
|
|
8
13
|
const profileNames = listProfiles().map(p => `\`${p.name}\``).join(', ');
|
|
9
14
|
return [
|
|
@@ -25,12 +30,12 @@ const fmtTime = (ts) => new Date(ts).toLocaleString('en-US', FMT_OPTS);
|
|
|
25
30
|
async function handleList(parts, channel, adapter, scheduler) {
|
|
26
31
|
const tasks = await scheduler.list();
|
|
27
32
|
if (tasks.length === 0) {
|
|
28
|
-
await adapter.postMessage(channel, { text: 'No scheduled tasks.' });
|
|
33
|
+
await adapter.postMessage(toDest(channel), { text: 'No scheduled tasks.' });
|
|
29
34
|
return;
|
|
30
35
|
}
|
|
31
36
|
const now = Date.now();
|
|
32
37
|
const lines = tasks.map((t) => formatTaskLine(t, now));
|
|
33
|
-
await adapter.postMessage(channel, { text: `*Scheduled tasks (${tasks.length}):*\n${lines.join('\n')}` });
|
|
38
|
+
await adapter.postMessage(toDest(channel), { text: `*Scheduled tasks (${tasks.length}):*\n${lines.join('\n')}` });
|
|
34
39
|
}
|
|
35
40
|
function formatTaskLine(t, now) {
|
|
36
41
|
const id = `\`${t.id}\``;
|
|
@@ -69,11 +74,11 @@ async function handleRemove(parts, channel, adapter, scheduler) {
|
|
|
69
74
|
const rawId = parts[2];
|
|
70
75
|
const id = normalizeTaskId(rawId);
|
|
71
76
|
if (!id) {
|
|
72
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule remove <id>`' });
|
|
77
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule remove <id>`' });
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
const removed = await scheduler.remove(id);
|
|
76
|
-
await adapter.postMessage(channel, {
|
|
81
|
+
await adapter.postMessage(toDest(channel), {
|
|
77
82
|
text: removed ? `:white_check_mark: Removed task \`${id}\`.` : `:x: Task not found: \`${id}\``,
|
|
78
83
|
});
|
|
79
84
|
}
|
|
@@ -81,39 +86,39 @@ async function handlePause(parts, channel, adapter, scheduler) {
|
|
|
81
86
|
const rawId = parts[2];
|
|
82
87
|
const id = normalizeTaskId(rawId);
|
|
83
88
|
if (!id) {
|
|
84
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule pause <id>`' });
|
|
89
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule pause <id>`' });
|
|
85
90
|
return;
|
|
86
91
|
}
|
|
87
92
|
try {
|
|
88
93
|
const task = await scheduler.pause(id);
|
|
89
94
|
if (!task) {
|
|
90
|
-
await adapter.postMessage(channel, { text: `:x: Task not found: \`${id}\`` });
|
|
95
|
+
await adapter.postMessage(toDest(channel), { text: `:x: Task not found: \`${id}\`` });
|
|
91
96
|
return;
|
|
92
97
|
}
|
|
93
|
-
await adapter.postMessage(channel, { text: `:double_vertical_bar: Paused task \`${id}\`.` });
|
|
98
|
+
await adapter.postMessage(toDest(channel), { text: `:double_vertical_bar: Paused task \`${id}\`.` });
|
|
94
99
|
}
|
|
95
100
|
catch (error) {
|
|
96
|
-
await adapter.postMessage(channel, { text: `:x: ${error.message}` });
|
|
101
|
+
await adapter.postMessage(toDest(channel), { text: `:x: ${error.message}` });
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
async function handleResume(parts, channel, adapter, scheduler) {
|
|
100
105
|
const rawId = parts[2];
|
|
101
106
|
const id = normalizeTaskId(rawId);
|
|
102
107
|
if (!id) {
|
|
103
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule resume <id>`' });
|
|
108
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule resume <id>`' });
|
|
104
109
|
return;
|
|
105
110
|
}
|
|
106
111
|
try {
|
|
107
112
|
const task = await scheduler.resume(id);
|
|
108
113
|
if (!task) {
|
|
109
|
-
await adapter.postMessage(channel, { text: `:x: Task not found: \`${id}\`` });
|
|
114
|
+
await adapter.postMessage(toDest(channel), { text: `:x: Task not found: \`${id}\`` });
|
|
110
115
|
return;
|
|
111
116
|
}
|
|
112
117
|
const nextAt = task.nextRun ? ` Next run: ${fmtTime(task.nextRun)}.` : '';
|
|
113
|
-
await adapter.postMessage(channel, { text: `:arrow_forward: Resumed task \`${id}\`.${nextAt}` });
|
|
118
|
+
await adapter.postMessage(toDest(channel), { text: `:arrow_forward: Resumed task \`${id}\`.${nextAt}` });
|
|
114
119
|
}
|
|
115
120
|
catch (error) {
|
|
116
|
-
await adapter.postMessage(channel, { text: `:x: ${error.message}` });
|
|
121
|
+
await adapter.postMessage(toDest(channel), { text: `:x: ${error.message}` });
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
function parseProfileArgs(args, usage) {
|
|
@@ -145,22 +150,23 @@ async function handleAddInterval(parts, channel, adapter, scheduler) {
|
|
|
145
150
|
parsed = parseProfileArgs(parts.slice(4), '`!schedule add interval <duration> [--profile <name>] <message>`');
|
|
146
151
|
}
|
|
147
152
|
catch (error) {
|
|
148
|
-
await adapter.postMessage(channel, { text: `:x: ${error.message}` });
|
|
153
|
+
await adapter.postMessage(toDest(channel), { text: `:x: ${error.message}` });
|
|
149
154
|
return;
|
|
150
155
|
}
|
|
151
156
|
const msg = parsed.rest.join(' ');
|
|
152
157
|
const ms = parseDuration(durationStr);
|
|
153
158
|
if (!ms) {
|
|
154
|
-
await adapter.postMessage(channel, { text: `Invalid duration: \`${durationStr}\`. Use e.g. \`30s\`, \`5m\`, \`2h\`, \`1d\`` });
|
|
159
|
+
await adapter.postMessage(toDest(channel), { text: `Invalid duration: \`${durationStr}\`. Use e.g. \`30s\`, \`5m\`, \`2h\`, \`1d\`` });
|
|
155
160
|
return;
|
|
156
161
|
}
|
|
157
162
|
if (!msg) {
|
|
158
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule add interval <duration> [--profile <name>] <message>`' });
|
|
163
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule add interval <duration> [--profile <name>] <message>`' });
|
|
159
164
|
return;
|
|
160
165
|
}
|
|
161
|
-
const
|
|
166
|
+
const resolvedProjectId = channelToProjectId(channel) ?? 'general';
|
|
167
|
+
const task = await scheduler.add('interval', { intervalMs: ms, message: msg, projectId: resolvedProjectId, profile: parsed.profileName });
|
|
162
168
|
const nextAt = task.nextRun ? ` | first run: ${fmtTime(task.nextRun)}` : '';
|
|
163
|
-
await adapter.postMessage(channel, { text: buildScheduledConfirmation(`:white_check_mark: Scheduled every *${formatDuration(ms)}*: "${msg}"`, task, nextAt) });
|
|
169
|
+
await adapter.postMessage(toDest(channel), { text: buildScheduledConfirmation(`:white_check_mark: Scheduled every *${formatDuration(ms)}*: "${msg}"`, task, nextAt) });
|
|
164
170
|
}
|
|
165
171
|
async function handleAddDaily(parts, channel, adapter, scheduler) {
|
|
166
172
|
const time = parts[3];
|
|
@@ -169,21 +175,22 @@ async function handleAddDaily(parts, channel, adapter, scheduler) {
|
|
|
169
175
|
parsed = parseProfileArgs(parts.slice(4), '`!schedule add daily <HH:MM> [--profile <name>] <message>`');
|
|
170
176
|
}
|
|
171
177
|
catch (error) {
|
|
172
|
-
await adapter.postMessage(channel, { text: `:x: ${error.message}` });
|
|
178
|
+
await adapter.postMessage(toDest(channel), { text: `:x: ${error.message}` });
|
|
173
179
|
return;
|
|
174
180
|
}
|
|
175
181
|
const msg = parsed.rest.join(' ');
|
|
176
182
|
if (!/^\d{2}:\d{2}$/.test(time)) {
|
|
177
|
-
await adapter.postMessage(channel, { text: `Invalid time: \`${time}\`. Use 24-hour HH:MM, e.g. \`09:00\`` });
|
|
183
|
+
await adapter.postMessage(toDest(channel), { text: `Invalid time: \`${time}\`. Use 24-hour HH:MM, e.g. \`09:00\`` });
|
|
178
184
|
return;
|
|
179
185
|
}
|
|
180
186
|
if (!msg) {
|
|
181
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule add daily <HH:MM> [--profile <name>] <message>`' });
|
|
187
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule add daily <HH:MM> [--profile <name>] <message>`' });
|
|
182
188
|
return;
|
|
183
189
|
}
|
|
184
|
-
const
|
|
190
|
+
const resolvedProjectId = channelToProjectId(channel) ?? 'general';
|
|
191
|
+
const task = await scheduler.add('daily', { time, message: msg, projectId: resolvedProjectId, profile: parsed.profileName });
|
|
185
192
|
const nextAt = task.nextRun ? ` | first run: ${fmtTime(task.nextRun)}` : '';
|
|
186
|
-
await adapter.postMessage(channel, { text: buildScheduledConfirmation(`:white_check_mark: Scheduled daily at *${time}*: "${msg}"`, task, nextAt) });
|
|
193
|
+
await adapter.postMessage(toDest(channel), { text: buildScheduledConfirmation(`:white_check_mark: Scheduled daily at *${time}*: "${msg}"`, task, nextAt) });
|
|
187
194
|
}
|
|
188
195
|
async function handleAddWeekly(parts, channel, adapter, scheduler) {
|
|
189
196
|
const dayStr = (parts[3] || '').toLowerCase();
|
|
@@ -193,27 +200,28 @@ async function handleAddWeekly(parts, channel, adapter, scheduler) {
|
|
|
193
200
|
parsed = parseProfileArgs(parts.slice(5), '`!schedule add weekly <day> <HH:MM> [--profile <name>] <message>`');
|
|
194
201
|
}
|
|
195
202
|
catch (error) {
|
|
196
|
-
await adapter.postMessage(channel, { text: `:x: ${error.message}` });
|
|
203
|
+
await adapter.postMessage(toDest(channel), { text: `:x: ${error.message}` });
|
|
197
204
|
return;
|
|
198
205
|
}
|
|
199
206
|
const msg = parsed.rest.join(' ');
|
|
200
207
|
const dayOfWeek = DAY_MAP[dayStr];
|
|
201
208
|
if (dayOfWeek == null) {
|
|
202
|
-
await adapter.postMessage(channel, { text: `Invalid day: \`${parts[3]}\`. Use: mon, tue, wed, thu, fri, sat, sun` });
|
|
209
|
+
await adapter.postMessage(toDest(channel), { text: `Invalid day: \`${parts[3]}\`. Use: mon, tue, wed, thu, fri, sat, sun` });
|
|
203
210
|
return;
|
|
204
211
|
}
|
|
205
212
|
if (!/^\d{2}:\d{2}$/.test(time)) {
|
|
206
|
-
await adapter.postMessage(channel, { text: `Invalid time: \`${time}\`. Use 24-hour HH:MM, e.g. \`21:00\`` });
|
|
213
|
+
await adapter.postMessage(toDest(channel), { text: `Invalid time: \`${time}\`. Use 24-hour HH:MM, e.g. \`21:00\`` });
|
|
207
214
|
return;
|
|
208
215
|
}
|
|
209
216
|
if (!msg) {
|
|
210
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule add weekly <day> <HH:MM> [--profile <name>] <message>`' });
|
|
217
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule add weekly <day> <HH:MM> [--profile <name>] <message>`' });
|
|
211
218
|
return;
|
|
212
219
|
}
|
|
213
220
|
const dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
214
|
-
const
|
|
221
|
+
const resolvedProjectId = channelToProjectId(channel) ?? 'general';
|
|
222
|
+
const task = await scheduler.add('weekly', { dayOfWeek, time, message: msg, projectId: resolvedProjectId, profile: parsed.profileName });
|
|
215
223
|
const nextAt = task.nextRun ? ` | first run: ${fmtTime(task.nextRun)}` : '';
|
|
216
|
-
await adapter.postMessage(channel, { text: buildScheduledConfirmation(`:white_check_mark: Scheduled weekly *${dayNames[dayOfWeek]} ${time}*: "${msg}"`, task, nextAt) });
|
|
224
|
+
await adapter.postMessage(toDest(channel), { text: buildScheduledConfirmation(`:white_check_mark: Scheduled weekly *${dayNames[dayOfWeek]} ${time}*: "${msg}"`, task, nextAt) });
|
|
217
225
|
}
|
|
218
226
|
async function handleAddOnce(parts, channel, adapter, scheduler) {
|
|
219
227
|
const durationStr = parts[3];
|
|
@@ -222,22 +230,23 @@ async function handleAddOnce(parts, channel, adapter, scheduler) {
|
|
|
222
230
|
parsed = parseProfileArgs(parts.slice(4), '`!schedule add once <duration> [--profile <name>] <message>`');
|
|
223
231
|
}
|
|
224
232
|
catch (error) {
|
|
225
|
-
await adapter.postMessage(channel, { text: `:x: ${error.message}` });
|
|
233
|
+
await adapter.postMessage(toDest(channel), { text: `:x: ${error.message}` });
|
|
226
234
|
return;
|
|
227
235
|
}
|
|
228
236
|
const msg = parsed.rest.join(' ');
|
|
229
237
|
const ms = parseDuration(durationStr);
|
|
230
238
|
if (!ms) {
|
|
231
|
-
await adapter.postMessage(channel, { text: `Invalid duration: \`${durationStr}\`. Use e.g. \`30s\`, \`5m\`, \`2h\`, \`1d\`` });
|
|
239
|
+
await adapter.postMessage(toDest(channel), { text: `Invalid duration: \`${durationStr}\`. Use e.g. \`30s\`, \`5m\`, \`2h\`, \`1d\`` });
|
|
232
240
|
return;
|
|
233
241
|
}
|
|
234
242
|
if (!msg) {
|
|
235
|
-
await adapter.postMessage(channel, { text: 'Usage: `!schedule add once <duration> [--profile <name>] <message>`' });
|
|
243
|
+
await adapter.postMessage(toDest(channel), { text: 'Usage: `!schedule add once <duration> [--profile <name>] <message>`' });
|
|
236
244
|
return;
|
|
237
245
|
}
|
|
238
|
-
const
|
|
246
|
+
const resolvedProjectId = channelToProjectId(channel) ?? 'general';
|
|
247
|
+
const task = await scheduler.add('once', { delay: ms, message: msg, projectId: resolvedProjectId, profile: parsed.profileName });
|
|
239
248
|
const runAt = task.runAt ? ` | runs at: ${fmtTime(task.runAt)}` : '';
|
|
240
|
-
await adapter.postMessage(channel, { text: buildScheduledConfirmation(`:white_check_mark: Scheduled once in *${formatDuration(ms)}*: "${msg}"`, task, runAt) });
|
|
249
|
+
await adapter.postMessage(toDest(channel), { text: buildScheduledConfirmation(`:white_check_mark: Scheduled once in *${formatDuration(ms)}*: "${msg}"`, task, runAt) });
|
|
241
250
|
}
|
|
242
251
|
const ADD_TYPE_HANDLERS = {
|
|
243
252
|
interval: handleAddInterval,
|
|
@@ -251,10 +260,10 @@ async function handleAdd(parts, channel, adapter, scheduler) {
|
|
|
251
260
|
if (handler)
|
|
252
261
|
return handler(parts, channel, adapter, scheduler);
|
|
253
262
|
if (type) {
|
|
254
|
-
await adapter.postMessage(channel, { text: `Unknown type: \`${type}\`. Use \`interval\`, \`daily\`, \`weekly\`, or \`once\`` });
|
|
263
|
+
await adapter.postMessage(toDest(channel), { text: `Unknown type: \`${type}\`. Use \`interval\`, \`daily\`, \`weekly\`, or \`once\`` });
|
|
255
264
|
return;
|
|
256
265
|
}
|
|
257
|
-
await adapter.postMessage(channel, { text: scheduleHelp() });
|
|
266
|
+
await adapter.postMessage(toDest(channel), { text: scheduleHelp() });
|
|
258
267
|
}
|
|
259
268
|
const SUB_HANDLERS = {
|
|
260
269
|
list: handleList,
|
|
@@ -269,6 +278,6 @@ async function handleScheduleCommand(text, channel, adapter, scheduler) {
|
|
|
269
278
|
const handler = SUB_HANDLERS[sub];
|
|
270
279
|
if (handler)
|
|
271
280
|
return handler(parts, channel, adapter, scheduler);
|
|
272
|
-
await adapter.postMessage(channel, { text: scheduleHelp() });
|
|
281
|
+
await adapter.postMessage(toDest(channel), { text: scheduleHelp() });
|
|
273
282
|
}
|
|
274
283
|
export { handleScheduleCommand };
|
|
@@ -6,7 +6,7 @@ declare function formatDuration(ms: number): string;
|
|
|
6
6
|
declare function formatTimeUntil(ms: number): string;
|
|
7
7
|
interface RunnerParams {
|
|
8
8
|
message: string;
|
|
9
|
-
|
|
9
|
+
projectId: string;
|
|
10
10
|
scheduleTaskId: string;
|
|
11
11
|
profileName: string;
|
|
12
12
|
/** Where the fired task should land — passed through so scheduled-task.ts can pick its dispatch branch. */
|
|
@@ -73,7 +73,7 @@ function taskConfigHash(task) {
|
|
|
73
73
|
const keys = { interval: 'intervalMs', daily: 'time', once: 'runAt', weekly: 'dayOfWeek' };
|
|
74
74
|
const key = keys[task.type];
|
|
75
75
|
const extra = task.type === 'weekly' ? `${task.dayOfWeek}:${task.time}` : (String(task[key] || ''));
|
|
76
|
-
return `${task.type}:${extra}:${task.message}:${task.
|
|
76
|
+
return `${task.type}:${extra}:${task.message}:${task.projectId}:${task.profile || ''}:${task.dispatchType || ''}:${task.preCheck || ''}`;
|
|
77
77
|
}
|
|
78
78
|
function validateTime(time) {
|
|
79
79
|
if (!/^\d{2}:\d{2}$/.test(time))
|
|
@@ -102,7 +102,7 @@ function computeTaskTiming(type, task) {
|
|
|
102
102
|
return {};
|
|
103
103
|
}
|
|
104
104
|
function validateTaskPatch(task, patch) {
|
|
105
|
-
const commonFields = new Set(['message', '
|
|
105
|
+
const commonFields = new Set(['message', 'projectId', 'profile', 'dispatchType', 'preCheck']);
|
|
106
106
|
const typeFields = {
|
|
107
107
|
interval: new Set(['intervalMs']),
|
|
108
108
|
daily: new Set(['time']),
|
|
@@ -129,20 +129,20 @@ function resolveTaskProfile(profile) {
|
|
|
129
129
|
return profile || getDefaultProfileName();
|
|
130
130
|
}
|
|
131
131
|
function buildTask(type, id, now, options) {
|
|
132
|
-
const { message,
|
|
132
|
+
const { message, projectId, profile = null, preCheck = null } = options;
|
|
133
133
|
const resolvedProfile = resolveTaskProfile(profile);
|
|
134
134
|
const base = { preCheck: preCheck || undefined };
|
|
135
135
|
if (type === 'interval') {
|
|
136
136
|
const { intervalMs } = options;
|
|
137
137
|
if (!intervalMs)
|
|
138
138
|
throw new Error('intervalMs required');
|
|
139
|
-
return { id, type: 'interval', intervalMs, message,
|
|
139
|
+
return { id, type: 'interval', intervalMs, message, projectId, profile: resolvedProfile, ...base, lastRun: null, nextRun: now + intervalMs, createdAt: now };
|
|
140
140
|
}
|
|
141
141
|
if (type === 'daily') {
|
|
142
142
|
const { time } = options;
|
|
143
143
|
if (!time)
|
|
144
144
|
throw new Error('time required (HH:MM)');
|
|
145
|
-
return { id, type: 'daily', time, message,
|
|
145
|
+
return { id, type: 'daily', time, message, projectId, profile: resolvedProfile, ...base, lastRun: null, nextRun: now + nextDailyMs(time), createdAt: now };
|
|
146
146
|
}
|
|
147
147
|
if (type === 'weekly') {
|
|
148
148
|
const { dayOfWeek, time } = options;
|
|
@@ -150,13 +150,13 @@ function buildTask(type, id, now, options) {
|
|
|
150
150
|
throw new Error('dayOfWeek required (0=Sun..6=Sat)');
|
|
151
151
|
if (!time)
|
|
152
152
|
throw new Error('time required (HH:MM)');
|
|
153
|
-
return { id, type: 'weekly', dayOfWeek, time, message,
|
|
153
|
+
return { id, type: 'weekly', dayOfWeek, time, message, projectId, profile: resolvedProfile, ...base, lastRun: null, nextRun: now + nextWeeklyMs(dayOfWeek, time), createdAt: now };
|
|
154
154
|
}
|
|
155
155
|
if (type === 'once') {
|
|
156
156
|
const { delay } = options;
|
|
157
157
|
if (!delay)
|
|
158
158
|
throw new Error('delay required');
|
|
159
|
-
return { id, type: 'once', runAt: now + delay, message,
|
|
159
|
+
return { id, type: 'once', runAt: now + delay, message, projectId, profile: resolvedProfile, ...base, createdAt: now };
|
|
160
160
|
}
|
|
161
161
|
throw new Error(`Unknown type: ${type}. Use: interval, daily, weekly, once`);
|
|
162
162
|
}
|
|
@@ -510,25 +510,26 @@ class Scheduler {
|
|
|
510
510
|
// Internal: invoke the runner for a task
|
|
511
511
|
async _runTask(task) {
|
|
512
512
|
const profileName = resolveTaskProfile(task.profile);
|
|
513
|
-
|
|
513
|
+
const resolvedChannel = task.projectId;
|
|
514
|
+
log.info(`Firing task ${task.id} (${task.type}, dispatch=${task.dispatchType || 'llm'}, profile=${profileName}, channel=${resolvedChannel}): "${task.message}"`);
|
|
514
515
|
try {
|
|
515
516
|
if (task.dispatchType === 'task-dispatch' && this.taskDispatchRunner) {
|
|
516
517
|
await this.taskDispatchRunner({
|
|
517
|
-
channel:
|
|
518
|
+
channel: resolvedChannel,
|
|
518
519
|
scheduleTaskId: task.id,
|
|
519
520
|
profileName,
|
|
520
521
|
});
|
|
521
522
|
}
|
|
522
523
|
else if (task.dispatchType && this.programmaticHandlers[task.dispatchType]) {
|
|
523
524
|
await this.programmaticHandlers[task.dispatchType]({
|
|
524
|
-
channel:
|
|
525
|
+
channel: resolvedChannel,
|
|
525
526
|
scheduleTaskId: task.id,
|
|
526
527
|
});
|
|
527
528
|
}
|
|
528
529
|
else {
|
|
529
530
|
await this.runner({
|
|
530
531
|
message: `[Scheduled Task] ${task.message}`,
|
|
531
|
-
|
|
532
|
+
projectId: task.projectId,
|
|
532
533
|
scheduleTaskId: task.id,
|
|
533
534
|
profileName,
|
|
534
535
|
target: task.target,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { PlatformAdapter } from '../../platform/index.js';
|
|
2
|
-
import { VirtualMessage } from '../../platform/virtual-message.js';
|
|
1
|
+
import type { PlatformAdapter, OutputStream } from '../../platform/index.js';
|
|
3
2
|
export interface SessionHookConfig {
|
|
4
3
|
command: string;
|
|
5
4
|
args?: string[];
|
|
@@ -21,7 +20,7 @@ export interface SessionHookContext {
|
|
|
21
20
|
profile?: string | null;
|
|
22
21
|
}
|
|
23
22
|
/** Caller-supplied formatters — keep wording per-hook so existing UX text doesn't change.
|
|
24
|
-
* All formatters return short single-line strings; runSessionHook appends them via
|
|
23
|
+
* All formatters return short single-line strings; runSessionHook appends them via OutputStream,
|
|
25
24
|
* so they share the same Slack thread/group as surrounding agent output. */
|
|
26
25
|
export interface SessionHookFormat {
|
|
27
26
|
/** Status line shown immediately when the hook starts. */
|
|
@@ -34,7 +33,7 @@ export interface SessionHookFormat {
|
|
|
34
33
|
emptyLine?: () => string | null;
|
|
35
34
|
}
|
|
36
35
|
/** When set, the hook stdout is injected as a fresh agent turn against `targetSessionId`.
|
|
37
|
-
* All assistant output is appended into the same
|
|
36
|
+
* All assistant output is appended into the same OutputStream so it visually
|
|
38
37
|
* continues the hook's status/preview lines. */
|
|
39
38
|
export interface SessionHookInject {
|
|
40
39
|
targetSessionId: string;
|
|
@@ -50,14 +49,14 @@ export interface SessionHookSpec {
|
|
|
50
49
|
}
|
|
51
50
|
/** Unified pipeline: post status line → spawn subprocess → post preview/error line →
|
|
52
51
|
* optionally inject stdout as a fresh agent turn. Every Slack write goes through
|
|
53
|
-
* `
|
|
52
|
+
* `stream` so hook output and the follow-up agent turn share one continuous thread.
|
|
54
53
|
*
|
|
55
|
-
* Caller controls the `
|
|
56
|
-
* - onMessageEnd: pass the assistant turn's
|
|
54
|
+
* Caller controls the `stream`:
|
|
55
|
+
* - onMessageEnd: pass the assistant turn's stream so hook lines extend the same
|
|
57
56
|
* reply chain (no top-level leak).
|
|
58
|
-
* - onNew: pass a fresh
|
|
57
|
+
* - onNew: pass a fresh stream anchored at the last assistant message's thread parent
|
|
59
58
|
* (resolved via resolveSessionThreadTs). */
|
|
60
|
-
export declare function runSessionHook(spec: SessionHookSpec,
|
|
59
|
+
export declare function runSessionHook(spec: SessionHookSpec, stream: OutputStream): Promise<void>;
|
|
61
60
|
/** Resolve the profile name to use when injecting the onNew hook's stdout as a fresh
|
|
62
61
|
* agent turn. Priority order:
|
|
63
62
|
* 1. session-registry (per-session truth — correct for thread-spawned sessions whose
|
|
@@ -93,9 +92,9 @@ export interface OnMessageEndArgs {
|
|
|
93
92
|
sessionName: string;
|
|
94
93
|
executionId: string;
|
|
95
94
|
profile?: string | null;
|
|
96
|
-
/**
|
|
95
|
+
/** OutputStream to extend — pass the assistant turn's stream so the hook lines
|
|
97
96
|
* thread under the just-finished reply rather than leaking to top-level. */
|
|
98
|
-
|
|
97
|
+
stream: OutputStream;
|
|
99
98
|
}
|
|
100
99
|
/** Run the onMessageEnd hook against the just-finished assistant turn's vm.
|
|
101
100
|
* No-op when not configured. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// input: agent-server/session-hooks.json (lazy-read), spawn() subprocess,
|
|
1
|
+
// input: agent-server/session-hooks.json (lazy-read), spawn() subprocess, OutputStream
|
|
2
2
|
// output: runSessionHook() unified pipeline + fireAndForgetPreCloseHook (onNew) + onMessageEnd helpers
|
|
3
3
|
// pos: session-level hook subsystem — config loading, subprocess spawn, unified Slack-display pipeline
|
|
4
4
|
// (parallel to thread-hook system, scoped to channel/session rather than thread)
|
|
@@ -10,9 +10,8 @@ import { DATA_DIR, CONFIG_DIR } from '../../core/paths.js';
|
|
|
10
10
|
import { createLogger } from '../../core/log.js';
|
|
11
11
|
import { runAgent, resolveBackendForChannel } from '../agents/index.js';
|
|
12
12
|
import { getSessionAsync } from '../sessions/session.js';
|
|
13
|
-
import {
|
|
13
|
+
import { sessionStore } from '../../store/session-registry-repo.js';
|
|
14
14
|
import { conversationLedger } from '../../store/conversation-ledger-repo.js';
|
|
15
|
-
import { VirtualMessage } from '../../platform/virtual-message.js';
|
|
16
15
|
const log = createLogger('session-hook');
|
|
17
16
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'session-hooks.json');
|
|
18
17
|
const DEFAULT_TIMEOUT_MS = 60_000;
|
|
@@ -124,19 +123,19 @@ function buildHookStdin(name, ctx) {
|
|
|
124
123
|
}
|
|
125
124
|
/** Unified pipeline: post status line → spawn subprocess → post preview/error line →
|
|
126
125
|
* optionally inject stdout as a fresh agent turn. Every Slack write goes through
|
|
127
|
-
* `
|
|
126
|
+
* `stream` so hook output and the follow-up agent turn share one continuous thread.
|
|
128
127
|
*
|
|
129
|
-
* Caller controls the `
|
|
130
|
-
* - onMessageEnd: pass the assistant turn's
|
|
128
|
+
* Caller controls the `stream`:
|
|
129
|
+
* - onMessageEnd: pass the assistant turn's stream so hook lines extend the same
|
|
131
130
|
* reply chain (no top-level leak).
|
|
132
|
-
* - onNew: pass a fresh
|
|
131
|
+
* - onNew: pass a fresh stream anchored at the last assistant message's thread parent
|
|
133
132
|
* (resolved via resolveSessionThreadTs). */
|
|
134
|
-
export async function runSessionHook(spec,
|
|
133
|
+
export async function runSessionHook(spec, stream) {
|
|
135
134
|
const cfg = loadHookConfig(spec.name);
|
|
136
135
|
if (!cfg)
|
|
137
136
|
return;
|
|
138
137
|
const label = (cfg.args && cfg.args.length) ? `${cfg.command} ${cfg.args.join(' ')}` : cfg.command;
|
|
139
|
-
|
|
138
|
+
stream.emitText(spec.format.statusLine());
|
|
140
139
|
const result = await spawnHookProcess({
|
|
141
140
|
cfg,
|
|
142
141
|
stdinPayload: buildHookStdin(spec.name, spec.ctx),
|
|
@@ -144,20 +143,20 @@ export async function runSessionHook(spec, vm) {
|
|
|
144
143
|
label,
|
|
145
144
|
});
|
|
146
145
|
if (result.error) {
|
|
147
|
-
|
|
148
|
-
await
|
|
146
|
+
stream.emitText(spec.format.errorLine(result.error));
|
|
147
|
+
await stream.flush().catch((e) => log.warn(`stream.flush after error failed (${label}): ${e?.message || e}`));
|
|
149
148
|
return;
|
|
150
149
|
}
|
|
151
150
|
if (!result.stdout) {
|
|
152
151
|
const empty = spec.format.emptyLine?.();
|
|
153
152
|
if (empty)
|
|
154
|
-
|
|
155
|
-
await
|
|
153
|
+
stream.emitText(empty);
|
|
154
|
+
await stream.flush().catch((e) => log.warn(`stream.flush on empty failed (${label}): ${e?.message || e}`));
|
|
156
155
|
return;
|
|
157
156
|
}
|
|
158
|
-
|
|
157
|
+
stream.emitText(spec.format.previewLine(result.stdout));
|
|
159
158
|
if (!spec.inject) {
|
|
160
|
-
await
|
|
159
|
+
await stream.flush().catch((e) => log.warn(`stream.flush no-inject failed (${label}): ${e?.message || e}`));
|
|
161
160
|
return;
|
|
162
161
|
}
|
|
163
162
|
try {
|
|
@@ -168,17 +167,17 @@ export async function runSessionHook(spec, vm) {
|
|
|
168
167
|
isUserInitiated: false,
|
|
169
168
|
profileName: spec.inject.profileName,
|
|
170
169
|
trigger: spec.inject.trigger ?? `hook:${spec.name}`,
|
|
171
|
-
onAssistantMessage: (text) =>
|
|
170
|
+
onAssistantMessage: (text) => stream.emitText(text),
|
|
172
171
|
});
|
|
173
172
|
await handle.promise;
|
|
174
173
|
}
|
|
175
174
|
catch (err) {
|
|
176
175
|
const msg = err?.message || String(err);
|
|
177
176
|
log.error(`hook ${spec.name} injected agent failed: ${msg}`);
|
|
178
|
-
|
|
177
|
+
stream.emitText(`:warning: ${spec.name} hook follow-up failed: ${msg}`);
|
|
179
178
|
}
|
|
180
179
|
finally {
|
|
181
|
-
await
|
|
180
|
+
await stream.flush().catch((e) => log.warn(`stream.flush after inject failed (${label}): ${e?.message || e}`));
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
183
|
// ── onNew (pre-close) entry points ────────────────────────────────────────────
|
|
@@ -227,17 +226,17 @@ export async function resolveOnNewProfileName(channel, sessionId, deps) {
|
|
|
227
226
|
/** Default binding of the registry lookup — composes lookupBySessionId + lookupSession.
|
|
228
227
|
* Extracted so prepareOnNewRun's call site stays one line and tests can swap in fakes. */
|
|
229
228
|
async function defaultLookupRegistryProfile(sessionId) {
|
|
230
|
-
const name = await
|
|
229
|
+
const name = await sessionStore.lookupBySessionId(sessionId);
|
|
231
230
|
if (!name)
|
|
232
231
|
return null;
|
|
233
|
-
const record = await
|
|
232
|
+
const record = await sessionStore.lookupSession(name);
|
|
234
233
|
return record?.profileName ?? null;
|
|
235
234
|
}
|
|
236
235
|
async function defaultLookupLedgerProfile(channel) {
|
|
237
236
|
const conv = await conversationLedger.getConversation(channel);
|
|
238
237
|
return conv?.profileName ?? null;
|
|
239
238
|
}
|
|
240
|
-
/** Build the onNew SessionHookSpec + a fresh
|
|
239
|
+
/** Build the onNew SessionHookSpec + a fresh stream. Returns null when the hook isn't
|
|
241
240
|
* configured or there's no live session to capture context from. */
|
|
242
241
|
async function prepareOnNewRun(channel, adapter, threadTs) {
|
|
243
242
|
if (!isOnNewHookConfigured())
|
|
@@ -248,7 +247,7 @@ async function prepareOnNewRun(channel, adapter, threadTs) {
|
|
|
248
247
|
log.info('onNew hook skipped: no active session for channel', channel);
|
|
249
248
|
return null;
|
|
250
249
|
}
|
|
251
|
-
const sessionName = (await
|
|
250
|
+
const sessionName = (await sessionStore.lookupBySessionId(sessionId)) || sessionId.slice(0, 8);
|
|
252
251
|
// Resolve profile BEFORE handleNewCmd clears the ledger (sync, runs after this fn returns).
|
|
253
252
|
// Registry is the per-session truth; ledger is the channel-level fallback.
|
|
254
253
|
const profileName = await resolveOnNewProfileName(channel, sessionId, {
|
|
@@ -256,14 +255,14 @@ async function prepareOnNewRun(channel, adapter, threadTs) {
|
|
|
256
255
|
lookupLedgerProfile: defaultLookupLedgerProfile,
|
|
257
256
|
});
|
|
258
257
|
const anchor = await resolveOnNewThreadAnchor(channel, threadTs);
|
|
259
|
-
const
|
|
258
|
+
const stream = adapter.openOutputStream({ type: 'interactive-reply', conduit: channel, sessionId: '' }, { threadId: anchor });
|
|
260
259
|
const spec = {
|
|
261
260
|
name: 'onNew',
|
|
262
261
|
ctx: { channel, sessionId, sessionName, profile: profileName },
|
|
263
262
|
format: ONNEW_FORMAT,
|
|
264
263
|
inject: { targetSessionId: sessionId, profileName, trigger: 'hook:onNew' },
|
|
265
264
|
};
|
|
266
|
-
return { spec,
|
|
265
|
+
return { spec, stream };
|
|
267
266
|
}
|
|
268
267
|
/** Fire-and-forget onNew hook used by the !new command and the "New" status button.
|
|
269
268
|
* Returns immediately; the hook subprocess and any injected agent turn run async
|
|
@@ -273,7 +272,7 @@ export async function fireAndForgetPreCloseHook(channel, adapter, threadTs) {
|
|
|
273
272
|
const prepared = await prepareOnNewRun(channel, adapter, threadTs);
|
|
274
273
|
if (!prepared)
|
|
275
274
|
return;
|
|
276
|
-
void runSessionHook(prepared.spec, prepared.
|
|
275
|
+
void runSessionHook(prepared.spec, prepared.stream).catch((err) => {
|
|
277
276
|
log.error('onNew hook async completion failed:', err?.message || err);
|
|
278
277
|
});
|
|
279
278
|
}
|
|
@@ -284,7 +283,7 @@ export async function runPreCloseHook(channel, adapter, threadTs) {
|
|
|
284
283
|
const prepared = await prepareOnNewRun(channel, adapter, threadTs);
|
|
285
284
|
if (!prepared)
|
|
286
285
|
return;
|
|
287
|
-
await runSessionHook(prepared.spec, prepared.
|
|
286
|
+
await runSessionHook(prepared.spec, prepared.stream);
|
|
288
287
|
}
|
|
289
288
|
/** Run the onMessageEnd hook against the just-finished assistant turn's vm.
|
|
290
289
|
* No-op when not configured. */
|
|
@@ -307,5 +306,5 @@ export async function runMessageEndSessionHook(args) {
|
|
|
307
306
|
trigger: 'hook:onMessageEnd',
|
|
308
307
|
},
|
|
309
308
|
};
|
|
310
|
-
await runSessionHook(spec, args.
|
|
309
|
+
await runSessionHook(spec, args.stream);
|
|
311
310
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { sessionRegistryRepo, type
|
|
1
|
+
export { sessionStore, sessionRegistryRepo, type Session, type SessionRegistryData } from '../../store/session-registry-repo.js';
|
|
2
2
|
export declare function generateSessionName(): Promise<string>;
|
|
3
3
|
export declare function registerSession(name: string, opts: {
|
|
4
4
|
sessionId: string;
|
|
5
5
|
channel: string;
|
|
6
6
|
backend: string;
|
|
7
7
|
kind: 'local' | 'scheduled';
|
|
8
|
+
projectId?: string;
|
|
8
9
|
label?: string | null;
|
|
9
10
|
profileName?: string | null;
|
|
10
11
|
}): Promise<void>;
|
|
@@ -12,10 +13,14 @@ export declare function updateSession(name: string, updates: {
|
|
|
12
13
|
sessionId?: string;
|
|
13
14
|
lastUsedAt?: string;
|
|
14
15
|
label?: string | null;
|
|
16
|
+
profileName?: string | null;
|
|
15
17
|
}): Promise<void>;
|
|
16
|
-
export declare function lookupSession(name: string): Promise<import("../../store/session-registry-repo.js").
|
|
18
|
+
export declare function lookupSession(name: string): Promise<import("../../store/session-registry-repo.js").Session>;
|
|
17
19
|
export declare function lookupBySessionId(sessionId: string): Promise<string>;
|
|
18
|
-
export declare function listRecentSessions(limit?: number): Promise<(
|
|
19
|
-
name: string;
|
|
20
|
-
} & import("../../store/session-registry-repo.js").SessionRecord)[]>;
|
|
20
|
+
export declare function listRecentSessions(limit?: number): Promise<import("../../store/session-registry-repo.js").Session[]>;
|
|
21
21
|
export declare function getActiveSessionName(channel: string, backend: string): Promise<string>;
|
|
22
|
+
export declare function getById(sessionId: string): Promise<import("../../store/session-registry-repo.js").Session>;
|
|
23
|
+
export declare function listByProject(projectId: string): Promise<import("../../store/session-registry-repo.js").Session[]>;
|
|
24
|
+
export declare function listResumable(projectId?: string): Promise<import("../../store/session-registry-repo.js").Session[]>;
|
|
25
|
+
export declare function markUsed(sessionId: string): Promise<void>;
|
|
26
|
+
export declare function pruneStale(maxAgeMs: number): Promise<number>;
|
|
@@ -6,26 +6,41 @@
|
|
|
6
6
|
// This file is kept only so any external tooling that still imports this path
|
|
7
7
|
// continues to compile until the S12 git-mv sweep.
|
|
8
8
|
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
9
|
-
import {
|
|
10
|
-
export { sessionRegistryRepo } from '../../store/session-registry-repo.js';
|
|
9
|
+
import { sessionStore } from '../../store/session-registry-repo.js';
|
|
10
|
+
export { sessionStore, sessionRegistryRepo } from '../../store/session-registry-repo.js';
|
|
11
11
|
export function generateSessionName() {
|
|
12
|
-
return
|
|
12
|
+
return sessionStore.generateSessionName();
|
|
13
13
|
}
|
|
14
14
|
export function registerSession(name, opts) {
|
|
15
|
-
return
|
|
15
|
+
return sessionStore.registerSession(name, opts);
|
|
16
16
|
}
|
|
17
17
|
export function updateSession(name, updates) {
|
|
18
|
-
return
|
|
18
|
+
return sessionStore.updateSession(name, updates);
|
|
19
19
|
}
|
|
20
20
|
export function lookupSession(name) {
|
|
21
|
-
return
|
|
21
|
+
return sessionStore.lookupSession(name);
|
|
22
22
|
}
|
|
23
23
|
export function lookupBySessionId(sessionId) {
|
|
24
|
-
return
|
|
24
|
+
return sessionStore.lookupBySessionId(sessionId);
|
|
25
25
|
}
|
|
26
26
|
export function listRecentSessions(limit = 10) {
|
|
27
|
-
return
|
|
27
|
+
return sessionStore.listRecentSessions(limit);
|
|
28
28
|
}
|
|
29
29
|
export function getActiveSessionName(channel, backend) {
|
|
30
|
-
return
|
|
30
|
+
return sessionStore.getActiveSessionName(channel, backend);
|
|
31
|
+
}
|
|
32
|
+
export function getById(sessionId) {
|
|
33
|
+
return sessionStore.getById(sessionId);
|
|
34
|
+
}
|
|
35
|
+
export function listByProject(projectId) {
|
|
36
|
+
return sessionStore.listByProject(projectId);
|
|
37
|
+
}
|
|
38
|
+
export function listResumable(projectId) {
|
|
39
|
+
return sessionStore.listResumable(projectId);
|
|
40
|
+
}
|
|
41
|
+
export function markUsed(sessionId) {
|
|
42
|
+
return sessionStore.markUsed(sessionId);
|
|
43
|
+
}
|
|
44
|
+
export function pruneStale(maxAgeMs) {
|
|
45
|
+
return sessionStore.pruneStale(maxAgeMs);
|
|
31
46
|
}
|