@alfe.ai/openclaw-chat 0.6.0 → 0.7.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,91 +1,2 @@
1
- import { _ as AlfeResolvedAccount, g as AlfePluginConfig, h as AlfeChannelConfig, m as createAlfeChannelPlugin, u as plugin } from "./plugin.cjs";
2
-
3
- //#region src/session-store.d.ts
4
-
5
- /**
6
- * Session Store — persists chat sessions to the local filesystem.
7
- *
8
- * Storage layout:
9
- * ~/.alfe/sessions/chat/{sessionId}.json
10
- *
11
- * Each session file contains metadata and the full message history.
12
- * Sessions are written on every message to ensure durability.
13
- * Old sessions are cleaned up automatically (30-day TTL, 1000 max).
14
- */
15
- interface ChatMessage {
16
- role: 'user' | 'assistant';
17
- content: string;
18
- timestamp: number;
19
- senderId?: string;
20
- senderName?: string;
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
- };
51
- interface SessionData {
52
- sessionId: string;
53
- agentId: string;
54
- channel: string;
55
- tenantId?: string;
56
- userId?: string;
57
- createdAt: string;
58
- updatedAt: string;
59
- messages: ChatMessage[];
60
- /**
61
- * Fallback activity records (see appendActivity). The PRIMARY history
62
- * source is OpenClaw's own session transcript (transcript-activity.ts) —
63
- * these records serve conversations whose transcript is missing
64
- * (deleted / rotated / compacted). Absent on pre-persistence files.
65
- */
66
- activity?: ChatActivityRecord[];
67
- /**
68
- * OpenClaw route(s) this conversation dispatched through, captured per
69
- * turn — the exact transcript lookup keys for transcript-backed history.
70
- * Multiple entries occur for group conversations (per-peer dm scope
71
- * yields one OpenClaw session per sender). Absent on old files (the
72
- * transcript index `:conv:` scan covers those retroactively).
73
- */
74
- routes?: {
75
- sessionKey: string;
76
- storePath: string;
77
- }[];
78
- }
79
- interface SessionSummary {
80
- sessionId: string;
81
- agentId: string;
82
- channel: string;
83
- tenantId?: string;
84
- userId?: string;
85
- createdAt: string;
86
- lastMessageAt?: string;
87
- preview?: string;
88
- messageCount: number;
89
- }
90
- //#endregion
1
+ import { _ as AlfeResolvedAccount, b as SessionSummary, g as AlfePluginConfig, h as AlfeChannelConfig, m as createAlfeChannelPlugin, u as plugin, v as ChatMessage, y as SessionData } from "./plugin.cjs";
91
2
  export { type AlfeChannelConfig, type AlfePluginConfig, type AlfeResolvedAccount, type ChatMessage, type SessionData, type SessionSummary, createAlfeChannelPlugin, plugin as default };
package/dist/index.d.ts CHANGED
@@ -1,91 +1,2 @@
1
- import { _ as AlfeResolvedAccount, g as AlfePluginConfig, h as AlfeChannelConfig, m as createAlfeChannelPlugin, u as plugin } from "./plugin.js";
2
-
3
- //#region src/session-store.d.ts
4
-
5
- /**
6
- * Session Store — persists chat sessions to the local filesystem.
7
- *
8
- * Storage layout:
9
- * ~/.alfe/sessions/chat/{sessionId}.json
10
- *
11
- * Each session file contains metadata and the full message history.
12
- * Sessions are written on every message to ensure durability.
13
- * Old sessions are cleaned up automatically (30-day TTL, 1000 max).
14
- */
15
- interface ChatMessage {
16
- role: 'user' | 'assistant';
17
- content: string;
18
- timestamp: number;
19
- senderId?: string;
20
- senderName?: string;
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
- };
51
- interface SessionData {
52
- sessionId: string;
53
- agentId: string;
54
- channel: string;
55
- tenantId?: string;
56
- userId?: string;
57
- createdAt: string;
58
- updatedAt: string;
59
- messages: ChatMessage[];
60
- /**
61
- * Fallback activity records (see appendActivity). The PRIMARY history
62
- * source is OpenClaw's own session transcript (transcript-activity.ts) —
63
- * these records serve conversations whose transcript is missing
64
- * (deleted / rotated / compacted). Absent on pre-persistence files.
65
- */
66
- activity?: ChatActivityRecord[];
67
- /**
68
- * OpenClaw route(s) this conversation dispatched through, captured per
69
- * turn — the exact transcript lookup keys for transcript-backed history.
70
- * Multiple entries occur for group conversations (per-peer dm scope
71
- * yields one OpenClaw session per sender). Absent on old files (the
72
- * transcript index `:conv:` scan covers those retroactively).
73
- */
74
- routes?: {
75
- sessionKey: string;
76
- storePath: string;
77
- }[];
78
- }
79
- interface SessionSummary {
80
- sessionId: string;
81
- agentId: string;
82
- channel: string;
83
- tenantId?: string;
84
- userId?: string;
85
- createdAt: string;
86
- lastMessageAt?: string;
87
- preview?: string;
88
- messageCount: number;
89
- }
90
- //#endregion
1
+ import { _ as AlfeResolvedAccount, b as SessionSummary, g as AlfePluginConfig, h as AlfeChannelConfig, m as createAlfeChannelPlugin, u as plugin, v as ChatMessage, y as SessionData } from "./plugin.js";
91
2
  export { type AlfeChannelConfig, type AlfePluginConfig, type AlfeResolvedAccount, type ChatMessage, type SessionData, type SessionSummary, createAlfeChannelPlugin, plugin as default };
package/dist/plugin.d.cts CHANGED
@@ -1,3 +1,123 @@
1
+ //#region src/session-store.d.ts
2
+ /**
3
+ * Session Store — persists chat sessions to the local filesystem.
4
+ *
5
+ * Storage layout:
6
+ * ~/.alfe/sessions/chat/{sessionId}.json
7
+ *
8
+ * Each session file contains metadata and the full message history.
9
+ * Sessions are written on every message to ensure durability.
10
+ * Old sessions are cleaned up automatically (30-day TTL, 1000 max).
11
+ *
12
+ * NOTE: the storage path and SessionData shape are a read contract —
13
+ * packages/openclaw-memory-cloud/src/session-backfill.ts reads these files
14
+ * directly (the memory plugin can't depend on this package). Keep in sync.
15
+ */
16
+ /**
17
+ * Persisted form of an interactive message component. Structural mirror of
18
+ * `MessageComponent` in `@alfe/chat-transport` — duplicated here rather than
19
+ * imported because openclaw-chat is a PUBLISHED (`@alfe.ai/*`) package and must
20
+ * not carry a runtime dependency on an internal (`@alfe/*`) package (see root
21
+ * DEVELOPING.md → "Publishing public @alfe.ai/* packages"). Keep in sync with
22
+ * the transport union.
23
+ */
24
+ type StoredMessageComponent = {
25
+ type: 'link_button';
26
+ id: string;
27
+ label: string;
28
+ url: string;
29
+ target?: 'same-tab' | 'new-tab' | 'popup';
30
+ style?: 'primary' | 'secondary' | 'danger';
31
+ } | {
32
+ type: 'quick_reply';
33
+ id: string;
34
+ label: string;
35
+ value: string;
36
+ style?: 'primary' | 'secondary' | 'danger';
37
+ };
38
+ interface ChatMessage {
39
+ role: 'user' | 'assistant';
40
+ content: string;
41
+ timestamp: number;
42
+ senderId?: string;
43
+ senderName?: string;
44
+ /**
45
+ * Interactive components attached to the message (link buttons, quick
46
+ * replies). Additive field — absent on pre-component files, and ignored by
47
+ * the memory backfill read contract (session-backfill.ts reads only role +
48
+ * content). Persisted so a refresh / reconnect replays the button.
49
+ */
50
+ components?: StoredMessageComponent[];
51
+ }
52
+ /**
53
+ * Persisted form of a turn's agent activity (tool cards + thinking), so a
54
+ * refresh can replay what the live `chat-activity` stream showed. Terminal
55
+ * by construction: no `progressText` (transient streaming window) and no
56
+ * `running` status — a tool still running at flush time is persisted as
57
+ * `interrupted`. Tool text fields arrive pre-capped (activity-serialize.ts);
58
+ * thinking text is capped at append time (MAX_ACTIVITY_THINKING_CHARS).
59
+ */
60
+ type ChatActivityRecord = {
61
+ kind: 'thinking';
62
+ text: string;
63
+ ts: number;
64
+ } | {
65
+ kind: 'tool';
66
+ toolCallId: string;
67
+ name: string;
68
+ status: 'done' | 'failed' | 'interrupted';
69
+ summary?: string;
70
+ argsText?: string;
71
+ resultText?: string;
72
+ isError?: boolean;
73
+ durationMs?: number;
74
+ truncated?: {
75
+ args?: boolean;
76
+ progress?: boolean;
77
+ result?: boolean;
78
+ };
79
+ ts: number;
80
+ };
81
+ interface SessionData {
82
+ sessionId: string;
83
+ agentId: string;
84
+ channel: string;
85
+ tenantId?: string;
86
+ userId?: string;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ messages: ChatMessage[];
90
+ /**
91
+ * Fallback activity records (see appendActivity). The PRIMARY history
92
+ * source is OpenClaw's own session transcript (transcript-activity.ts) —
93
+ * these records serve conversations whose transcript is missing
94
+ * (deleted / rotated / compacted). Absent on pre-persistence files.
95
+ */
96
+ activity?: ChatActivityRecord[];
97
+ /**
98
+ * OpenClaw route(s) this conversation dispatched through, captured per
99
+ * turn — the exact transcript lookup keys for transcript-backed history.
100
+ * Multiple entries occur for group conversations (per-peer dm scope
101
+ * yields one OpenClaw session per sender). Absent on old files (the
102
+ * transcript index `:conv:` scan covers those retroactively).
103
+ */
104
+ routes?: {
105
+ sessionKey: string;
106
+ storePath: string;
107
+ }[];
108
+ }
109
+ interface SessionSummary {
110
+ sessionId: string;
111
+ agentId: string;
112
+ channel: string;
113
+ tenantId?: string;
114
+ userId?: string;
115
+ createdAt: string;
116
+ lastMessageAt?: string;
117
+ preview?: string;
118
+ messageCount: number;
119
+ }
120
+ //#endregion
1
121
  //#region src/types.d.ts
2
122
  /**
3
123
  * Types for the Alfe chat channel plugin.
@@ -48,12 +168,19 @@ interface AlfeOutboundSession {
48
168
  }
49
169
  interface AlfeChannelOutboundDeps {
50
170
  getChatClient: () => AlfeOutboundChatClient | null;
171
+ /** Plugin logger — used by the outbound media upload path. Optional so
172
+ * CLI metadata registration (no deps at all) stays unaffected. */
173
+ log?: {
174
+ info(msg: string): void;
175
+ warn(msg: string): void;
176
+ error(msg: string): void;
177
+ };
51
178
  listSessions: (filters?: {
52
179
  userId?: string;
53
180
  }) => Promise<AlfeOutboundSessionSummary[]>;
54
181
  getSession: (sessionId: string) => Promise<AlfeOutboundSession | null>;
55
182
  createSession: (sessionId: string, agentId: string, channel: string, tenantId?: string, userId?: string) => Promise<unknown>;
56
- addMessage: (sessionId: string, role: 'user' | 'assistant', content: string, senderId?: string, senderName?: string) => Promise<void>;
183
+ addMessage: (sessionId: string, role: 'user' | 'assistant', content: string, senderId?: string, senderName?: string, components?: StoredMessageComponent[]) => Promise<void>;
57
184
  }
58
185
  //#endregion
59
186
  //#region src/alfe-channel.d.ts
@@ -71,6 +198,16 @@ interface OutboundDeliveryResult {
71
198
  conversationId: string;
72
199
  timestamp: number;
73
200
  }
201
+ /**
202
+ * Present interactive components (link buttons, quick replies) into a
203
+ * conversation — the outbound path for the `chat_present_components` tool.
204
+ * `to` is a `conv:{id}` or `user:{id}` target (same vocabulary as the channel's
205
+ * `resolveTarget`). Persists + broadcasts through the same `sendViaChat` path
206
+ * as a normal reply, so the components ride the standard `message` frame and
207
+ * are replayed on backfill. Components are sanitized (unsafe URLs dropped)
208
+ * before delivery.
209
+ */
210
+
74
211
  /**
75
212
  * Creates the Alfe ChannelPlugin object for registration with OpenClaw.
76
213
  *
@@ -440,4 +577,4 @@ declare const plugin: {
440
577
  deactivate(api: PluginApi): Promise<void>;
441
578
  };
442
579
  //#endregion
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 };
580
+ export { AlfeResolvedAccount as _, __setActiveRunForTest as a, SessionSummary as b, 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, ChatMessage as v, SessionData as y };
package/dist/plugin.d.ts CHANGED
@@ -1,3 +1,123 @@
1
+ //#region src/session-store.d.ts
2
+ /**
3
+ * Session Store — persists chat sessions to the local filesystem.
4
+ *
5
+ * Storage layout:
6
+ * ~/.alfe/sessions/chat/{sessionId}.json
7
+ *
8
+ * Each session file contains metadata and the full message history.
9
+ * Sessions are written on every message to ensure durability.
10
+ * Old sessions are cleaned up automatically (30-day TTL, 1000 max).
11
+ *
12
+ * NOTE: the storage path and SessionData shape are a read contract —
13
+ * packages/openclaw-memory-cloud/src/session-backfill.ts reads these files
14
+ * directly (the memory plugin can't depend on this package). Keep in sync.
15
+ */
16
+ /**
17
+ * Persisted form of an interactive message component. Structural mirror of
18
+ * `MessageComponent` in `@alfe/chat-transport` — duplicated here rather than
19
+ * imported because openclaw-chat is a PUBLISHED (`@alfe.ai/*`) package and must
20
+ * not carry a runtime dependency on an internal (`@alfe/*`) package (see root
21
+ * DEVELOPING.md → "Publishing public @alfe.ai/* packages"). Keep in sync with
22
+ * the transport union.
23
+ */
24
+ type StoredMessageComponent = {
25
+ type: 'link_button';
26
+ id: string;
27
+ label: string;
28
+ url: string;
29
+ target?: 'same-tab' | 'new-tab' | 'popup';
30
+ style?: 'primary' | 'secondary' | 'danger';
31
+ } | {
32
+ type: 'quick_reply';
33
+ id: string;
34
+ label: string;
35
+ value: string;
36
+ style?: 'primary' | 'secondary' | 'danger';
37
+ };
38
+ interface ChatMessage {
39
+ role: 'user' | 'assistant';
40
+ content: string;
41
+ timestamp: number;
42
+ senderId?: string;
43
+ senderName?: string;
44
+ /**
45
+ * Interactive components attached to the message (link buttons, quick
46
+ * replies). Additive field — absent on pre-component files, and ignored by
47
+ * the memory backfill read contract (session-backfill.ts reads only role +
48
+ * content). Persisted so a refresh / reconnect replays the button.
49
+ */
50
+ components?: StoredMessageComponent[];
51
+ }
52
+ /**
53
+ * Persisted form of a turn's agent activity (tool cards + thinking), so a
54
+ * refresh can replay what the live `chat-activity` stream showed. Terminal
55
+ * by construction: no `progressText` (transient streaming window) and no
56
+ * `running` status — a tool still running at flush time is persisted as
57
+ * `interrupted`. Tool text fields arrive pre-capped (activity-serialize.ts);
58
+ * thinking text is capped at append time (MAX_ACTIVITY_THINKING_CHARS).
59
+ */
60
+ type ChatActivityRecord = {
61
+ kind: 'thinking';
62
+ text: string;
63
+ ts: number;
64
+ } | {
65
+ kind: 'tool';
66
+ toolCallId: string;
67
+ name: string;
68
+ status: 'done' | 'failed' | 'interrupted';
69
+ summary?: string;
70
+ argsText?: string;
71
+ resultText?: string;
72
+ isError?: boolean;
73
+ durationMs?: number;
74
+ truncated?: {
75
+ args?: boolean;
76
+ progress?: boolean;
77
+ result?: boolean;
78
+ };
79
+ ts: number;
80
+ };
81
+ interface SessionData {
82
+ sessionId: string;
83
+ agentId: string;
84
+ channel: string;
85
+ tenantId?: string;
86
+ userId?: string;
87
+ createdAt: string;
88
+ updatedAt: string;
89
+ messages: ChatMessage[];
90
+ /**
91
+ * Fallback activity records (see appendActivity). The PRIMARY history
92
+ * source is OpenClaw's own session transcript (transcript-activity.ts) —
93
+ * these records serve conversations whose transcript is missing
94
+ * (deleted / rotated / compacted). Absent on pre-persistence files.
95
+ */
96
+ activity?: ChatActivityRecord[];
97
+ /**
98
+ * OpenClaw route(s) this conversation dispatched through, captured per
99
+ * turn — the exact transcript lookup keys for transcript-backed history.
100
+ * Multiple entries occur for group conversations (per-peer dm scope
101
+ * yields one OpenClaw session per sender). Absent on old files (the
102
+ * transcript index `:conv:` scan covers those retroactively).
103
+ */
104
+ routes?: {
105
+ sessionKey: string;
106
+ storePath: string;
107
+ }[];
108
+ }
109
+ interface SessionSummary {
110
+ sessionId: string;
111
+ agentId: string;
112
+ channel: string;
113
+ tenantId?: string;
114
+ userId?: string;
115
+ createdAt: string;
116
+ lastMessageAt?: string;
117
+ preview?: string;
118
+ messageCount: number;
119
+ }
120
+ //#endregion
1
121
  //#region src/types.d.ts
2
122
  /**
3
123
  * Types for the Alfe chat channel plugin.
@@ -48,12 +168,19 @@ interface AlfeOutboundSession {
48
168
  }
49
169
  interface AlfeChannelOutboundDeps {
50
170
  getChatClient: () => AlfeOutboundChatClient | null;
171
+ /** Plugin logger — used by the outbound media upload path. Optional so
172
+ * CLI metadata registration (no deps at all) stays unaffected. */
173
+ log?: {
174
+ info(msg: string): void;
175
+ warn(msg: string): void;
176
+ error(msg: string): void;
177
+ };
51
178
  listSessions: (filters?: {
52
179
  userId?: string;
53
180
  }) => Promise<AlfeOutboundSessionSummary[]>;
54
181
  getSession: (sessionId: string) => Promise<AlfeOutboundSession | null>;
55
182
  createSession: (sessionId: string, agentId: string, channel: string, tenantId?: string, userId?: string) => Promise<unknown>;
56
- addMessage: (sessionId: string, role: 'user' | 'assistant', content: string, senderId?: string, senderName?: string) => Promise<void>;
183
+ addMessage: (sessionId: string, role: 'user' | 'assistant', content: string, senderId?: string, senderName?: string, components?: StoredMessageComponent[]) => Promise<void>;
57
184
  }
58
185
  //#endregion
59
186
  //#region src/alfe-channel.d.ts
@@ -71,6 +198,16 @@ interface OutboundDeliveryResult {
71
198
  conversationId: string;
72
199
  timestamp: number;
73
200
  }
201
+ /**
202
+ * Present interactive components (link buttons, quick replies) into a
203
+ * conversation — the outbound path for the `chat_present_components` tool.
204
+ * `to` is a `conv:{id}` or `user:{id}` target (same vocabulary as the channel's
205
+ * `resolveTarget`). Persists + broadcasts through the same `sendViaChat` path
206
+ * as a normal reply, so the components ride the standard `message` frame and
207
+ * are replayed on backfill. Components are sanitized (unsafe URLs dropped)
208
+ * before delivery.
209
+ */
210
+
74
211
  /**
75
212
  * Creates the Alfe ChannelPlugin object for registration with OpenClaw.
76
213
  *
@@ -440,4 +577,4 @@ declare const plugin: {
440
577
  deactivate(api: PluginApi): Promise<void>;
441
578
  };
442
579
  //#endregion
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 };
580
+ export { AlfeResolvedAccount as _, __setActiveRunForTest as a, SessionSummary as b, 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, ChatMessage as v, SessionData as y };