@cortex-agent/server 2026.5.19-3 → 2026.5.22

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.
Files changed (132) hide show
  1. package/README.md +5 -1
  2. package/defaults/config/thread-templates.json +65 -39
  3. package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +4 -4
  4. package/defaults/prompts/directives/coder-reviewer.md +9 -4
  5. package/defaults/prompts/directives/coder.md +10 -2
  6. package/dist/core/log.js +61 -12
  7. package/dist/core/status-format.js +1 -1
  8. package/dist/core/task-parser.d.ts +1 -1
  9. package/dist/core/task-parser.js +13 -6
  10. package/dist/core/types/thread-types.d.ts +4 -2
  11. package/dist/domain/costs/codex-usage-monitor.d.ts +1 -2
  12. package/dist/domain/costs/codex-usage-monitor.js +2 -2
  13. package/dist/domain/costs/cost-tracker.d.ts +2 -0
  14. package/dist/domain/costs/cost-tracker.js +4 -20
  15. package/dist/domain/costs/rate-limit-throttle.js +1 -4
  16. package/dist/domain/mcp/tools/context.d.ts +4 -2
  17. package/dist/domain/mcp/tools/context.js +7 -5
  18. package/dist/domain/mcp/tools/schedule.d.ts +1 -1
  19. package/dist/domain/mcp/tools/schedule.js +24 -20
  20. package/dist/domain/memory/index-regen.js +8 -5
  21. package/dist/domain/monitor/disk-monitor.js +1 -6
  22. package/dist/domain/projects/index.d.ts +2 -0
  23. package/dist/domain/projects/index.js +3 -0
  24. package/dist/domain/projects/project-store.d.ts +54 -0
  25. package/dist/domain/projects/project-store.js +194 -0
  26. package/dist/domain/projects/project-types.d.ts +11 -0
  27. package/dist/domain/projects/project-types.js +5 -0
  28. package/dist/domain/remote/client-hot-reload.d.ts +1 -0
  29. package/dist/domain/remote/client-hot-reload.js +284 -53
  30. package/dist/domain/scheduling/jobs/_shared.d.ts +1 -1
  31. package/dist/domain/scheduling/jobs/_shared.js +6 -5
  32. package/dist/domain/scheduling/jobs/memory-index-regen.js +2 -2
  33. package/dist/domain/scheduling/jobs/scheduled-task.d.ts +2 -2
  34. package/dist/domain/scheduling/jobs/scheduled-task.js +38 -36
  35. package/dist/domain/scheduling/jobs/sync-public.d.ts +1 -0
  36. package/dist/domain/scheduling/jobs/sync-public.js +34 -0
  37. package/dist/domain/scheduling/jobs/target-dispatch.d.ts +3 -7
  38. package/dist/domain/scheduling/jobs/target-dispatch.js +7 -9
  39. package/dist/domain/scheduling/jobs/task-archive.js +2 -2
  40. package/dist/domain/scheduling/jobs/task-dispatch.js +18 -16
  41. package/dist/domain/scheduling/runner.d.ts +1 -0
  42. package/dist/domain/scheduling/runner.js +2 -0
  43. package/dist/domain/scheduling/schedule-cli.d.ts +1 -0
  44. package/dist/domain/scheduling/schedule-cli.js +14 -14
  45. package/dist/domain/scheduling/schedule-command.js +45 -36
  46. package/dist/domain/scheduling/scheduler.d.ts +1 -1
  47. package/dist/domain/scheduling/scheduler.js +12 -11
  48. package/dist/domain/sessions/session-hooks.d.ts +10 -11
  49. package/dist/domain/sessions/session-hooks.js +26 -27
  50. package/dist/domain/sessions/session-registry.d.ts +10 -5
  51. package/dist/domain/sessions/session-registry.js +24 -9
  52. package/dist/domain/tasks/pending-tracker.js +8 -9
  53. package/dist/domain/tasks/system/task-cli.d.ts +2 -0
  54. package/dist/domain/tasks/system/task-cli.js +189 -29
  55. package/dist/domain/tasks/system/task-lifecycle-edit.js +3 -3
  56. package/dist/domain/threads/hook-runner.js +12 -7
  57. package/dist/domain/threads/runner.d.ts +3 -3
  58. package/dist/domain/threads/runner.js +30 -28
  59. package/dist/domain/threads/state-machine.d.ts +3 -0
  60. package/dist/domain/threads/state-machine.js +4 -0
  61. package/dist/entry/app.js +30 -9
  62. package/dist/entry/cli.js +19 -4
  63. package/dist/entry/daemon.js +28 -2
  64. package/dist/entry/startup-notify.js +8 -6
  65. package/dist/orchestration/agent-runner.js +19 -13
  66. package/dist/orchestration/durable-helpers.js +3 -2
  67. package/dist/orchestration/interactions/ask-user-question.d.ts +2 -3
  68. package/dist/orchestration/interactions/ask-user-question.js +5 -4
  69. package/dist/orchestration/interactions/interaction-handlers.js +8 -5
  70. package/dist/orchestration/interactions/plan-handler.js +3 -3
  71. package/dist/orchestration/lifecycle.js +43 -38
  72. package/dist/orchestration/routing/commands/cancel.js +9 -8
  73. package/dist/orchestration/routing/commands/channel.js +32 -26
  74. package/dist/orchestration/routing/commands/cost.js +5 -3
  75. package/dist/orchestration/routing/commands/device.js +2 -1
  76. package/dist/orchestration/routing/commands/dispatch.js +8 -7
  77. package/dist/orchestration/routing/commands/index.js +7 -4
  78. package/dist/orchestration/routing/commands/mode.js +24 -18
  79. package/dist/orchestration/routing/commands/nvtop.js +14 -12
  80. package/dist/orchestration/routing/commands/orient.js +2 -1
  81. package/dist/orchestration/routing/commands/schedule.js +2 -1
  82. package/dist/orchestration/routing/commands/sendfile.js +12 -9
  83. package/dist/orchestration/routing/commands/session.js +12 -10
  84. package/dist/orchestration/routing/commands/status.js +2 -2
  85. package/dist/orchestration/routing/commands/tail.js +10 -6
  86. package/dist/orchestration/routing/commands/task.js +5 -4
  87. package/dist/orchestration/routing/commands/thread-handlers.js +19 -12
  88. package/dist/orchestration/routing/hook-bridge-subscribers.js +15 -13
  89. package/dist/orchestration/status-helpers.d.ts +4 -5
  90. package/dist/orchestration/status-helpers.js +7 -8
  91. package/dist/orchestration/thread-executor.js +21 -12
  92. package/dist/platform/adapter.d.ts +13 -9
  93. package/dist/platform/adapter.js +1 -1
  94. package/dist/platform/adapters/feishu-output-stream.d.ts +27 -0
  95. package/dist/platform/adapters/feishu-output-stream.js +114 -0
  96. package/dist/platform/adapters/feishu.d.ts +16 -7
  97. package/dist/platform/adapters/feishu.js +64 -18
  98. package/dist/platform/adapters/index.d.ts +4 -1
  99. package/dist/platform/adapters/index.js +1 -1
  100. package/dist/platform/adapters/slack-output-stream.d.ts +55 -0
  101. package/dist/platform/{virtual-message.js → adapters/slack-output-stream.js} +98 -165
  102. package/dist/platform/adapters/slack-project-conduits.d.ts +9 -0
  103. package/dist/platform/adapters/slack-project-conduits.js +40 -0
  104. package/dist/platform/adapters/slack.d.ts +18 -8
  105. package/dist/platform/adapters/slack.js +82 -24
  106. package/dist/platform/index.d.ts +3 -2
  107. package/dist/platform/index.js +1 -1
  108. package/dist/platform/output-stream-chunk.d.ts +6 -0
  109. package/dist/platform/output-stream-chunk.js +45 -0
  110. package/dist/platform/output-stream-helpers.d.ts +6 -0
  111. package/dist/platform/output-stream-helpers.js +11 -0
  112. package/dist/platform/output-stream.d.ts +28 -0
  113. package/dist/platform/output-stream.js +4 -0
  114. package/dist/platform/testing.d.ts +41 -8
  115. package/dist/platform/testing.js +93 -11
  116. package/dist/platform/tool-trace.d.ts +9 -8
  117. package/dist/platform/tool-trace.js +19 -17
  118. package/dist/platform/types.d.ts +21 -1
  119. package/dist/platform/types.js +17 -1
  120. package/dist/store/channel-repo.d.ts +6 -0
  121. package/dist/store/channel-repo.js +9 -0
  122. package/dist/store/json-repository.js +12 -1
  123. package/dist/store/outbound-queue.d.ts +5 -4
  124. package/dist/store/outbound-queue.js +9 -6
  125. package/dist/store/schedule-repo.d.ts +9 -5
  126. package/dist/store/schedule-repo.js +59 -14
  127. package/dist/store/session-registry-repo.d.ts +36 -7
  128. package/dist/store/session-registry-repo.js +186 -25
  129. package/dist/store/thread-repo.d.ts +1 -0
  130. package/dist/store/thread-repo.js +8 -0
  131. package/package.json +1 -1
  132. package/dist/platform/virtual-message.d.ts +0 -68
@@ -1,28 +1,108 @@
1
1
  // input: session-registry.json + JsonRepository
2
- // output: SessionRegistryRepo (async generateSessionName / registerSession / updateSession / lookupSession / lookupBySessionId / listRecentSessions / getActiveSessionName)
2
+ // output: SessionRegistryRepo (async generateSessionName / registerSession / updateSession / lookupSession / lookupBySessionId / getById / listRecentSessions / listByProject / listResumable / markUsed / pruneStale / getActiveSessionName)
3
3
  // pos: cortex-XXXX short name ↔ session UUID registry persistence layer (Pattern A, JsonRepository)
4
4
  // >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
5
+ import * as fs from 'fs';
5
6
  import * as path from 'path';
6
7
  import * as crypto from 'crypto';
7
8
  import { JsonRepository } from './json-repository.js';
8
9
  import { STORE_DIR } from '../core/paths.js';
10
+ import { CHANNEL_REGISTRY_FILE } from './channel-repo.js';
9
11
  import { sessionRepo } from './session-repo.js';
12
+ import { executionRepo } from './execution-repo.js';
13
+ import { threadStore } from './thread-repo.js';
10
14
  export const REGISTRY_FILE = path.join(STORE_DIR, 'session-registry.json');
11
15
  export class SessionRegistryRepo {
12
16
  _repo;
17
+ /** name → sessionId index keeping lookupSession O(1). */
18
+ _nameIndex = new Map();
19
+ /** Optional callback invoked when a session is pruned. Receives the sessionId. */
20
+ _onPruneSession = null;
13
21
  constructor(filePath = REGISTRY_FILE) {
14
22
  this._repo = new JsonRepository({
15
23
  filePath,
16
24
  defaultValue: () => ({}),
17
- migrate: (raw) => (typeof raw === 'object' && raw !== null ? raw : ({})),
25
+ migrate: (raw) => {
26
+ if (typeof raw !== 'object' || raw === null)
27
+ return {};
28
+ const data = raw;
29
+ const entries = Object.entries(data);
30
+ if (entries.length === 0)
31
+ return {};
32
+ // Detect new format: first entry's value has 'name' field
33
+ const firstVal = entries[0][1];
34
+ if (firstVal && typeof firstVal === 'object' && 'name' in firstVal) {
35
+ return data;
36
+ }
37
+ // Old format: name-keyed (cortex-XXXX → SessionRecord), values lack 'name' field.
38
+ // Build channel → project reverse map from channel-registry.json.
39
+ const channelToProject = {};
40
+ try {
41
+ const channelRegistryRaw = fs.readFileSync(CHANNEL_REGISTRY_FILE, 'utf8');
42
+ const channelRegistry = JSON.parse(channelRegistryRaw);
43
+ // channelRegistry is projectName → channelId; reverse to channelId → projectName.
44
+ for (const [project, channel] of Object.entries(channelRegistry)) {
45
+ channelToProject[channel] = project;
46
+ }
47
+ }
48
+ catch {
49
+ // channel-registry.json may not exist yet — all projectIds default to 'general'.
50
+ }
51
+ // Re-key from name → sessionId, deduplicate by lastUsedAt.
52
+ const sessionMap = new Map();
53
+ for (const [name, record] of entries) {
54
+ if (!record || typeof record !== 'object')
55
+ continue;
56
+ const sid = typeof record.sessionId === 'string' ? record.sessionId : '';
57
+ if (!sid)
58
+ continue;
59
+ const existing = sessionMap.get(sid);
60
+ if (existing && existing.record.lastUsedAt > record.lastUsedAt)
61
+ continue;
62
+ sessionMap.set(sid, { name, record });
63
+ }
64
+ // Build new format: sessionId-keyed, with name and projectId fields added.
65
+ const result = {};
66
+ for (const [sid, { name, record }] of sessionMap) {
67
+ const channel = typeof record.channel === 'string' ? record.channel : '';
68
+ result[sid] = {
69
+ ...record,
70
+ name,
71
+ projectId: channelToProject[channel] || 'general',
72
+ };
73
+ }
74
+ return result;
75
+ },
18
76
  });
19
77
  }
78
+ // ── name→sessionId index ──────────────────────────────────────
79
+ _rebuildNameIndex(data) {
80
+ this._nameIndex.clear();
81
+ for (const [sid, record] of Object.entries(data)) {
82
+ this._nameIndex.set(record.name, sid);
83
+ }
84
+ }
85
+ /** Read registry data, rebuilding the name index from cache when empty. */
86
+ async _readWithIndex() {
87
+ const data = await this._repo.read();
88
+ if (this._nameIndex.size === 0) {
89
+ this._rebuildNameIndex(data);
90
+ }
91
+ return data;
92
+ }
93
+ /** Rebuild the name index from the current cached data (zero I/O on cache hit). */
94
+ async _syncIndex() {
95
+ const data = await this._repo.read();
96
+ this._rebuildNameIndex(data);
97
+ }
98
+ // ── Public API ────────────────────────────────────────────────
20
99
  async generateSessionName() {
21
100
  const registry = await this._repo.read();
101
+ const knownNames = new Set(Object.values(registry).map((s) => s.name));
22
102
  for (let i = 0; i < 100; i++) {
23
103
  const hex = crypto.randomBytes(3).toString('hex');
24
104
  const name = `cortex-${hex}`;
25
- if (!registry[name])
105
+ if (!knownNames.has(name))
26
106
  return name;
27
107
  }
28
108
  return `cortex-${crypto.randomBytes(4).toString('hex')}`;
@@ -30,8 +110,10 @@ export class SessionRegistryRepo {
30
110
  async registerSession(name, opts) {
31
111
  const now = new Date().toISOString();
32
112
  await this._repo.mutate((registry) => {
33
- registry[name] = {
113
+ registry[opts.sessionId] = {
114
+ name,
34
115
  sessionId: opts.sessionId,
116
+ projectId: opts.projectId ?? 'general',
35
117
  channel: opts.channel,
36
118
  backend: opts.backend,
37
119
  kind: opts.kind,
@@ -40,44 +122,120 @@ export class SessionRegistryRepo {
40
122
  label: opts.label?.substring(0, 60) || null,
41
123
  profileName: opts.profileName ?? null,
42
124
  };
125
+ this._nameIndex.set(name, opts.sessionId);
43
126
  return { next: registry, result: undefined };
44
127
  });
45
128
  }
46
129
  async updateSession(name, updates) {
47
130
  await this._repo.mutate((registry) => {
48
- const record = registry[name];
49
- if (!record)
50
- return { next: registry, result: undefined };
51
- if (updates.sessionId !== undefined)
52
- record.sessionId = updates.sessionId;
53
- if (updates.lastUsedAt !== undefined)
54
- record.lastUsedAt = updates.lastUsedAt;
55
- if (updates.label !== undefined)
56
- record.label = updates.label?.substring(0, 60) || null;
57
- if (updates.profileName !== undefined)
58
- record.profileName = updates.profileName;
131
+ // Records are keyed by sessionId; find the target by name.
132
+ for (const record of Object.values(registry)) {
133
+ if (record.name === name) {
134
+ if (updates.sessionId !== undefined)
135
+ record.sessionId = updates.sessionId;
136
+ if (updates.lastUsedAt !== undefined)
137
+ record.lastUsedAt = updates.lastUsedAt;
138
+ if (updates.label !== undefined)
139
+ record.label = updates.label?.substring(0, 60) || null;
140
+ if (updates.profileName !== undefined)
141
+ record.profileName = updates.profileName;
142
+ break;
143
+ }
144
+ }
59
145
  return { next: registry, result: undefined };
60
146
  });
61
147
  }
62
148
  async lookupSession(name) {
63
- const registry = await this._repo.read();
64
- return registry[name] || null;
149
+ const registry = await this._readWithIndex();
150
+ const sid = this._nameIndex.get(name);
151
+ if (!sid)
152
+ return null;
153
+ return registry[sid] ?? null;
65
154
  }
66
155
  async lookupBySessionId(sessionId) {
67
156
  const registry = await this._repo.read();
68
- for (const [name, record] of Object.entries(registry)) {
69
- if (record.sessionId === sessionId)
70
- return name;
71
- }
72
- return null;
157
+ const record = registry[sessionId];
158
+ return record?.name ?? null;
73
159
  }
74
160
  async listRecentSessions(limit = 10) {
75
161
  const registry = await this._repo.read();
76
- return Object.entries(registry)
77
- .map(([name, record]) => ({ name, ...record }))
162
+ return Object.values(registry)
78
163
  .sort((a, b) => b.lastUsedAt.localeCompare(a.lastUsedAt))
79
164
  .slice(0, limit);
80
165
  }
166
+ /** Return a session by sessionId, or null if not found. O(1) key lookup. */
167
+ async getById(sessionId) {
168
+ const registry = await this._repo.read();
169
+ return registry[sessionId] ?? null;
170
+ }
171
+ /** List sessions belonging to a project, most recently used first. */
172
+ async listByProject(projectId) {
173
+ const registry = await this._repo.read();
174
+ return Object.values(registry)
175
+ .filter((s) => s.projectId === projectId)
176
+ .sort((a, b) => b.lastUsedAt.localeCompare(a.lastUsedAt));
177
+ }
178
+ /** List resumable (non-scheduled) sessions, optionally filtered by projectId. */
179
+ async listResumable(projectId) {
180
+ const registry = await this._repo.read();
181
+ return Object.values(registry)
182
+ .filter((s) => s.kind !== 'scheduled')
183
+ .filter((s) => projectId === undefined || s.projectId === projectId)
184
+ .sort((a, b) => b.lastUsedAt.localeCompare(a.lastUsedAt));
185
+ }
186
+ /** Touch the lastUsedAt timestamp of a session to now. No-op if sessionId not found. */
187
+ async markUsed(sessionId) {
188
+ const now = new Date().toISOString();
189
+ await this._repo.mutate((registry) => {
190
+ const record = registry[sessionId];
191
+ if (record)
192
+ record.lastUsedAt = now;
193
+ return { next: registry, result: undefined };
194
+ });
195
+ }
196
+ /**
197
+ * Remove sessions whose lastUsedAt is older than maxAgeMs from now,
198
+ * and are not referenced by any executionRepo or threadStore record.
199
+ * Invokes the onPruneSession callback (if set) for each removed session.
200
+ * Returns the number of removed sessions.
201
+ */
202
+ async pruneStale(maxAgeMs) {
203
+ const cutoff = Date.now() - maxAgeMs;
204
+ // Build set of sessionIds still referenced by active records.
205
+ const referencedSessionIds = new Set();
206
+ for (const exec of executionRepo.getAll()) {
207
+ if (exec.session.sessionId)
208
+ referencedSessionIds.add(exec.session.sessionId);
209
+ }
210
+ for (const thread of threadStore.getAll()) {
211
+ for (const agent of Object.values(thread.agents)) {
212
+ if (agent.sessionId)
213
+ referencedSessionIds.add(agent.sessionId);
214
+ }
215
+ for (const step of thread.steps) {
216
+ if (step.sessionId)
217
+ referencedSessionIds.add(step.sessionId);
218
+ }
219
+ }
220
+ const count = await this._repo.mutate((registry) => {
221
+ let removed = 0;
222
+ for (const [sid, record] of Object.entries(registry)) {
223
+ const usedAt = new Date(record.lastUsedAt).getTime();
224
+ if (usedAt < cutoff && !referencedSessionIds.has(sid)) {
225
+ this._onPruneSession?.(sid);
226
+ this._nameIndex.delete(record.name);
227
+ delete registry[sid];
228
+ removed++;
229
+ }
230
+ }
231
+ return { next: registry, result: removed };
232
+ });
233
+ return count;
234
+ }
235
+ /** Set a callback to invoke when a session is pruned (e.g. cleanup backup files). */
236
+ setOnPruneSession(fn) {
237
+ this._onPruneSession = fn;
238
+ }
81
239
  async getActiveSessionName(channel, backend) {
82
240
  const sessionId = await sessionRepo.getSessionAsync(channel, backend);
83
241
  if (!sessionId)
@@ -87,10 +245,13 @@ export class SessionRegistryRepo {
87
245
  /** Drop the in-memory cache so the next read() fetches from disk. Test hook. */
88
246
  invalidate() {
89
247
  this._repo.invalidate();
248
+ this._nameIndex.clear();
90
249
  }
91
250
  /** Wait for any in-flight mutate() to complete. For graceful SIGTERM drain. */
92
251
  flush() {
93
252
  return this._repo.flush();
94
253
  }
95
254
  }
96
- export const sessionRegistryRepo = new SessionRegistryRepo();
255
+ export const sessionStore = new SessionRegistryRepo();
256
+ /** @deprecated Use `sessionStore` instead. Alias for backward compatibility. */
257
+ export const sessionRegistryRepo = sessionStore;
@@ -31,6 +31,7 @@ declare class ThreadRepo {
31
31
  * markRunningAsFailedOnStartup acquire this.mutex directly after awaiting the chain. */
32
32
  flush(): Promise<void>;
33
33
  findByChannel(channel: string): ThreadRecord[];
34
+ findByProject(projectId: string): ThreadRecord[];
34
35
  findByPlatformThread(channel: string, platformThreadId: string): ThreadRecord | null;
35
36
  findActive(channel: string): ThreadRecord | null;
36
37
  getAll(): ThreadRecord[];
@@ -95,6 +95,14 @@ class ThreadRepo {
95
95
  }
96
96
  return results.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
97
97
  }
98
+ findByProject(projectId) {
99
+ const results = [];
100
+ for (const record of this.map.values()) {
101
+ if (record.projectId === projectId)
102
+ results.push(record);
103
+ }
104
+ return results.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
105
+ }
98
106
  findByPlatformThread(channel, platformThreadId) {
99
107
  for (const record of this.map.values()) {
100
108
  if (record.channel === channel && record.platformThreadId === platformThreadId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortex-agent/server",
3
- "version": "2026.5.19-3",
3
+ "version": "2026.5.22",
4
4
  "type": "module",
5
5
  "description": "Autonomous agent system for long-running projects — mission-driven, multi-agent pipelines, self-evolving skills.",
6
6
  "engines": {
@@ -1,68 +0,0 @@
1
- import type { PlatformAdapter } from './adapter.js';
2
- import type { MessageRef, RichBlock, ActionElement, DurableHooks } from './types.js';
3
- /**
4
- * Test-only: override retry delays to skip real wall-clock waits.
5
- * Pass [] for no retries, [0,0,0,0] to keep 4-attempt retry semantics with no wait.
6
- * Production code must never call this.
7
- */
8
- export declare function _testSetRetryDelays(delays: readonly number[]): void;
9
- /** Test-only: restore production retry delays. */
10
- export declare function _testResetRetryDelays(): void;
11
- export declare class VirtualMessage {
12
- private adapter;
13
- private channel;
14
- private threadId;
15
- private onMessagePosted;
16
- private maxChunk;
17
- private durable;
18
- private parentRef;
19
- private currentRef;
20
- private currentContent;
21
- private mutableTail;
22
- private allRefs;
23
- private queue;
24
- private lastError;
25
- constructor(adapter: PlatformAdapter, channel: string, opts?: {
26
- threadId?: string | null;
27
- onMessagePosted?: ((ref: MessageRef) => void) | null;
28
- durable?: DurableHooks | null;
29
- });
30
- append(text: string): void;
31
- /** Append `text` as a new mutable tail on the current Slack message.
32
- * Seals any existing mutable tail into `currentContent` first, then writes
33
- * the new tail via updateMessage (or postMessage if no message yet).
34
- * Use this for "start a new tool group" or any ephemeral trailing line. */
35
- appendMutableTail(text: string): void;
36
- /** Replace the current mutable tail with `text`. No-op if no tail is open
37
- * (use appendMutableTail to open one). Use this for "update same tool group". */
38
- editMutableTail(text: string): void;
39
- postStandalone(text: string, opts?: {
40
- richBlocks?: RichBlock[];
41
- actions?: ActionElement[];
42
- }): Promise<MessageRef | null>;
43
- flush(): Promise<void>;
44
- static postOnce(adapter: PlatformAdapter, channel: string, text: string, opts?: {
45
- threadId?: string | null;
46
- onMessagePosted?: ((ref: MessageRef) => void) | null;
47
- }): Promise<MessageRef | null>;
48
- getRefs(): MessageRef[];
49
- getParentRef(): MessageRef | null;
50
- /** Compatibility: return parentRef's messageId (maps to Slack's ts). */
51
- getParentTs(): string | null;
52
- private _processAppend;
53
- /** Combined display = currentContent [+ SEP + mutableTail]. */
54
- private _renderWithTail;
55
- /** Synchronously move mutableTail into currentContent. Slack state is
56
- * already up-to-date with the tail displayed; this is pure bookkeeping. */
57
- private _sealMutableTailNow;
58
- private _processAppendMutableTail;
59
- private _processEditMutableTail;
60
- private _postNew;
61
- /**
62
- * Post a single chunk with rich-text + plain-text fallback wrapped in
63
- * exponential-backoff retries. Throws on permanent failure (after retries).
64
- * When durable hooks are configured, persists intent to WAL before sending.
65
- */
66
- private _postOne;
67
- private _updateCurrent;
68
- }