@alfe.ai/openclaw-chat 0.3.3 → 0.5.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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as plugin, c as AlfeChannelConfig, l as AlfePluginConfig, s as createAlfeChannelPlugin, u as AlfeResolvedAccount } from "./plugin.cjs";
1
+ import { _ as AlfeResolvedAccount, g as AlfePluginConfig, h as AlfeChannelConfig, m as createAlfeChannelPlugin, u as plugin } from "./plugin.cjs";
2
2
 
3
3
  //#region src/session-store.d.ts
4
4
 
@@ -19,6 +19,35 @@ interface ChatMessage {
19
19
  senderId?: string;
20
20
  senderName?: string;
21
21
  }
22
+ /**
23
+ * Persisted form of a turn's agent activity (tool cards + thinking), so a
24
+ * refresh can replay what the live `chat-activity` stream showed. Terminal
25
+ * by construction: no `progressText` (transient streaming window) and no
26
+ * `running` status — a tool still running at flush time is persisted as
27
+ * `interrupted`. Tool text fields arrive pre-capped (activity-serialize.ts);
28
+ * thinking text is capped at append time (MAX_ACTIVITY_THINKING_CHARS).
29
+ */
30
+ type ChatActivityRecord = {
31
+ kind: 'thinking';
32
+ text: string;
33
+ ts: number;
34
+ } | {
35
+ kind: 'tool';
36
+ toolCallId: string;
37
+ name: string;
38
+ status: 'done' | 'failed' | 'interrupted';
39
+ summary?: string;
40
+ argsText?: string;
41
+ resultText?: string;
42
+ isError?: boolean;
43
+ durationMs?: number;
44
+ truncated?: {
45
+ args?: boolean;
46
+ progress?: boolean;
47
+ result?: boolean;
48
+ };
49
+ ts: number;
50
+ };
22
51
  interface SessionData {
23
52
  sessionId: string;
24
53
  agentId: string;
@@ -28,6 +57,8 @@ interface SessionData {
28
57
  createdAt: string;
29
58
  updatedAt: string;
30
59
  messages: ChatMessage[];
60
+ /** Absent on session files written before activity persistence shipped. */
61
+ activity?: ChatActivityRecord[];
31
62
  }
32
63
  interface SessionSummary {
33
64
  sessionId: string;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as plugin, c as AlfeChannelConfig, l as AlfePluginConfig, s as createAlfeChannelPlugin, u as AlfeResolvedAccount } from "./plugin.js";
1
+ import { _ as AlfeResolvedAccount, g as AlfePluginConfig, h as AlfeChannelConfig, m as createAlfeChannelPlugin, u as plugin } from "./plugin.js";
2
2
 
3
3
  //#region src/session-store.d.ts
4
4
 
@@ -19,6 +19,35 @@ interface ChatMessage {
19
19
  senderId?: string;
20
20
  senderName?: string;
21
21
  }
22
+ /**
23
+ * Persisted form of a turn's agent activity (tool cards + thinking), so a
24
+ * refresh can replay what the live `chat-activity` stream showed. Terminal
25
+ * by construction: no `progressText` (transient streaming window) and no
26
+ * `running` status — a tool still running at flush time is persisted as
27
+ * `interrupted`. Tool text fields arrive pre-capped (activity-serialize.ts);
28
+ * thinking text is capped at append time (MAX_ACTIVITY_THINKING_CHARS).
29
+ */
30
+ type ChatActivityRecord = {
31
+ kind: 'thinking';
32
+ text: string;
33
+ ts: number;
34
+ } | {
35
+ kind: 'tool';
36
+ toolCallId: string;
37
+ name: string;
38
+ status: 'done' | 'failed' | 'interrupted';
39
+ summary?: string;
40
+ argsText?: string;
41
+ resultText?: string;
42
+ isError?: boolean;
43
+ durationMs?: number;
44
+ truncated?: {
45
+ args?: boolean;
46
+ progress?: boolean;
47
+ result?: boolean;
48
+ };
49
+ ts: number;
50
+ };
22
51
  interface SessionData {
23
52
  sessionId: string;
24
53
  agentId: string;
@@ -28,6 +57,8 @@ interface SessionData {
28
57
  createdAt: string;
29
58
  updatedAt: string;
30
59
  messages: ChatMessage[];
60
+ /** Absent on session files written before activity persistence shipped. */
61
+ activity?: ChatActivityRecord[];
31
62
  }
32
63
  interface SessionSummary {
33
64
  sessionId: string;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { i as plugin, o as createAlfeChannelPlugin } from "./plugin2.js";
1
+ import { c as plugin, f as createAlfeChannelPlugin } from "./plugin2.js";
2
2
  export { createAlfeChannelPlugin, plugin as default };
package/dist/plugin.cjs CHANGED
@@ -3,8 +3,14 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_plugin = require("./plugin2.cjs");
6
+ exports.__agentTurnQueueForTest = require_plugin.__agentTurnQueueForTest;
7
+ exports.__resetAgentTurnQueueForTest = require_plugin.__resetAgentTurnQueueForTest;
8
+ exports.__setActiveRunForTest = require_plugin.__setActiveRunForTest;
6
9
  exports.admitAgentEvent = require_plugin.admitAgentEvent;
7
10
  exports.buildA2ACompletePayload = require_plugin.buildA2ACompletePayload;
8
11
  exports.buildToolActivity = require_plugin.buildToolActivity;
9
12
  exports.default = require_plugin.plugin;
13
+ exports.joinAssistantText = require_plugin.joinAssistantText;
14
+ exports.resolveAbortTargetKeys = require_plugin.resolveAbortTargetKeys;
15
+ exports.rewriteAssistantText = require_plugin.rewriteAssistantText;
10
16
  exports.stripLeakedToolSummary = require_plugin.stripLeakedToolSummary;
package/dist/plugin.d.cts CHANGED
@@ -334,6 +334,21 @@ type ChatActivity = {
334
334
  ts?: number;
335
335
  seq?: number;
336
336
  };
337
+ /**
338
+ * Join the text parts of an assistant-stream event's content array.
339
+ * Assistant `evt.data` is a message object whose `content` is an array of
340
+ * typed parts; deltas are CUMULATIVE snapshots (the relay length-compares
341
+ * them — see adapter.ts's lastSentLength slicing). Non-array/absent content
342
+ * yields '' (nothing to divert).
343
+ */
344
+ declare function joinAssistantText(data: Record<string, unknown>): string;
345
+ /**
346
+ * Rebuild an assistant event's message with its text parts replaced by one
347
+ * `{type:'text', text: visible}` part. Non-text parts are preserved — the
348
+ * relay's consumers (adapter/inject/voice-bridge) only join text parts, so
349
+ * relative ordering against non-text items is not load-bearing.
350
+ */
351
+ declare function rewriteAssistantText(data: Record<string, unknown>, visible: string): Record<string, unknown>;
337
352
  /**
338
353
  * Extract structured tool status from an OpenClaw `tool`-stream event.
339
354
  * We send the emoji-free raw `name` plus a lifecycle `status` and let the
@@ -387,6 +402,35 @@ interface PluginApi {
387
402
  priority?: number;
388
403
  }): void;
389
404
  }
405
+ declare function enqueueAgentTurn(task: () => Promise<void>, opts?: {
406
+ coalesceKey?: string;
407
+ onSuperseded?: () => void;
408
+ }): Promise<void>;
409
+ /**
410
+ * Test-only: reset the agent-turn backlog between unit tests. Not used at
411
+ * runtime (the backlog lives for the process lifetime of one daemon).
412
+ */
413
+ declare function __resetAgentTurnQueueForTest(): void;
414
+ /** Test-only accessor for the coalescing queue (see __tests__/queue.test.ts). */
415
+ declare const __agentTurnQueueForTest: {
416
+ enqueue: typeof enqueueAgentTurn;
417
+ backlogLength: () => number;
418
+ };
419
+ interface ActiveRunRef {
420
+ requestSessionKey: string;
421
+ routeSessionKey: string | null;
422
+ }
423
+ /** Test-only: set/clear the active-run ref for handleChatAbort unit tests. */
424
+ declare function __setActiveRunForTest(ref: ActiveRunRef | null): void;
425
+ /**
426
+ * Ordered session keys to try when aborting for `abortSessionKey`. Pure, so it
427
+ * unit-tests without the OpenClaw SDK. The resolved route key (what the run
428
+ * registered under) is preferred; the raw request key is a best-effort
429
+ * fallback. An abort with NO sessionKey targets the single active run. A
430
+ * sessionKey that does NOT match the running turn yields no candidates — we
431
+ * never abort another session's run on a shared daemon.
432
+ */
433
+ declare function resolveAbortTargetKeys(active: ActiveRunRef | null, abortSessionKey: string | undefined): string[];
390
434
  declare const plugin: {
391
435
  id: string;
392
436
  name: string;
@@ -396,4 +440,4 @@ declare const plugin: {
396
440
  deactivate(api: PluginApi): Promise<void>;
397
441
  };
398
442
  //#endregion
399
- export { plugin as a, AlfeChannelConfig as c, buildToolActivity as i, AlfePluginConfig as l, admitAgentEvent as n, stripLeakedToolSummary as o, buildA2ACompletePayload as r, createAlfeChannelPlugin as s, RunEventGate as t, AlfeResolvedAccount as u };
443
+ export { AlfeResolvedAccount as _, __setActiveRunForTest as a, buildToolActivity as c, resolveAbortTargetKeys as d, rewriteAssistantText as f, AlfePluginConfig as g, AlfeChannelConfig as h, __resetAgentTurnQueueForTest as i, joinAssistantText as l, createAlfeChannelPlugin as m, RunEventGate as n, admitAgentEvent as o, stripLeakedToolSummary as p, __agentTurnQueueForTest as r, buildA2ACompletePayload as s, ActiveRunRef as t, plugin as u };
package/dist/plugin.d.ts CHANGED
@@ -334,6 +334,21 @@ type ChatActivity = {
334
334
  ts?: number;
335
335
  seq?: number;
336
336
  };
337
+ /**
338
+ * Join the text parts of an assistant-stream event's content array.
339
+ * Assistant `evt.data` is a message object whose `content` is an array of
340
+ * typed parts; deltas are CUMULATIVE snapshots (the relay length-compares
341
+ * them — see adapter.ts's lastSentLength slicing). Non-array/absent content
342
+ * yields '' (nothing to divert).
343
+ */
344
+ declare function joinAssistantText(data: Record<string, unknown>): string;
345
+ /**
346
+ * Rebuild an assistant event's message with its text parts replaced by one
347
+ * `{type:'text', text: visible}` part. Non-text parts are preserved — the
348
+ * relay's consumers (adapter/inject/voice-bridge) only join text parts, so
349
+ * relative ordering against non-text items is not load-bearing.
350
+ */
351
+ declare function rewriteAssistantText(data: Record<string, unknown>, visible: string): Record<string, unknown>;
337
352
  /**
338
353
  * Extract structured tool status from an OpenClaw `tool`-stream event.
339
354
  * We send the emoji-free raw `name` plus a lifecycle `status` and let the
@@ -387,6 +402,35 @@ interface PluginApi {
387
402
  priority?: number;
388
403
  }): void;
389
404
  }
405
+ declare function enqueueAgentTurn(task: () => Promise<void>, opts?: {
406
+ coalesceKey?: string;
407
+ onSuperseded?: () => void;
408
+ }): Promise<void>;
409
+ /**
410
+ * Test-only: reset the agent-turn backlog between unit tests. Not used at
411
+ * runtime (the backlog lives for the process lifetime of one daemon).
412
+ */
413
+ declare function __resetAgentTurnQueueForTest(): void;
414
+ /** Test-only accessor for the coalescing queue (see __tests__/queue.test.ts). */
415
+ declare const __agentTurnQueueForTest: {
416
+ enqueue: typeof enqueueAgentTurn;
417
+ backlogLength: () => number;
418
+ };
419
+ interface ActiveRunRef {
420
+ requestSessionKey: string;
421
+ routeSessionKey: string | null;
422
+ }
423
+ /** Test-only: set/clear the active-run ref for handleChatAbort unit tests. */
424
+ declare function __setActiveRunForTest(ref: ActiveRunRef | null): void;
425
+ /**
426
+ * Ordered session keys to try when aborting for `abortSessionKey`. Pure, so it
427
+ * unit-tests without the OpenClaw SDK. The resolved route key (what the run
428
+ * registered under) is preferred; the raw request key is a best-effort
429
+ * fallback. An abort with NO sessionKey targets the single active run. A
430
+ * sessionKey that does NOT match the running turn yields no candidates — we
431
+ * never abort another session's run on a shared daemon.
432
+ */
433
+ declare function resolveAbortTargetKeys(active: ActiveRunRef | null, abortSessionKey: string | undefined): string[];
390
434
  declare const plugin: {
391
435
  id: string;
392
436
  name: string;
@@ -396,4 +440,4 @@ declare const plugin: {
396
440
  deactivate(api: PluginApi): Promise<void>;
397
441
  };
398
442
  //#endregion
399
- export { plugin as a, AlfeChannelConfig as c, buildToolActivity as i, AlfePluginConfig as l, admitAgentEvent as n, stripLeakedToolSummary as o, buildA2ACompletePayload as r, createAlfeChannelPlugin as s, RunEventGate as t, AlfeResolvedAccount as u };
443
+ export { AlfeResolvedAccount as _, __setActiveRunForTest as a, buildToolActivity as c, resolveAbortTargetKeys as d, rewriteAssistantText as f, AlfePluginConfig as g, AlfeChannelConfig as h, __resetAgentTurnQueueForTest as i, joinAssistantText as l, createAlfeChannelPlugin as m, RunEventGate as n, admitAgentEvent as o, stripLeakedToolSummary as p, __agentTurnQueueForTest as r, buildA2ACompletePayload as s, ActiveRunRef as t, plugin as u };
package/dist/plugin.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as stripLeakedToolSummary, i as plugin, n as buildA2ACompletePayload, r as buildToolActivity, t as admitAgentEvent } from "./plugin2.js";
2
- export { admitAgentEvent, buildA2ACompletePayload, buildToolActivity, plugin as default, stripLeakedToolSummary };
1
+ import { a as buildA2ACompletePayload, c as plugin, d as stripLeakedToolSummary, i as admitAgentEvent, l as resolveAbortTargetKeys, n as __resetAgentTurnQueueForTest, o as buildToolActivity, r as __setActiveRunForTest, s as joinAssistantText, t as __agentTurnQueueForTest, u as rewriteAssistantText } from "./plugin2.js";
2
+ export { __agentTurnQueueForTest, __resetAgentTurnQueueForTest, __setActiveRunForTest, admitAgentEvent, buildA2ACompletePayload, buildToolActivity, plugin as default, joinAssistantText, resolveAbortTargetKeys, rewriteAssistantText, stripLeakedToolSummary };