clawconnect-agent 0.2.6 → 0.2.8

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 (121) hide show
  1. package/README.md +7 -3
  2. package/README.zh-CN.md +7 -3
  3. package/dist/commands/hermes-file-transfer-outcome.d.ts +18 -0
  4. package/dist/commands/hermes-file-transfer-outcome.js +40 -0
  5. package/dist/commands/hermes-file-transfer-outcome.js.map +1 -0
  6. package/dist/commands/send-file.js +39 -33
  7. package/dist/commands/send-file.js.map +1 -1
  8. package/dist/core/command-types.d.ts +5 -0
  9. package/dist/core/relay/chat-payload.js +32 -22
  10. package/dist/core/relay/chat-payload.js.map +1 -1
  11. package/dist/core/relay/file-upload.d.ts +1 -0
  12. package/dist/core/relay/file-upload.js +3 -0
  13. package/dist/core/relay/file-upload.js.map +1 -1
  14. package/dist/core/relay/mobile-chat-run-bridge.d.ts +53 -8
  15. package/dist/core/relay/mobile-chat-run-bridge.js +45 -0
  16. package/dist/core/relay/mobile-chat-run-bridge.js.map +1 -1
  17. package/dist/core/relay/office-payload.js +54 -22
  18. package/dist/core/relay/office-payload.js.map +1 -1
  19. package/dist/core/relay/relay-server-connection.d.ts +1 -0
  20. package/dist/core/relay/relay-server-connection.js +17 -0
  21. package/dist/core/relay/relay-server-connection.js.map +1 -1
  22. package/dist/core/relay/source-commit.d.ts +42 -0
  23. package/dist/core/relay/source-commit.js +127 -0
  24. package/dist/core/relay/source-commit.js.map +1 -0
  25. package/dist/core/relay/timeline-event-builder.d.ts +6 -0
  26. package/dist/core/relay/timeline-event-builder.js +3 -0
  27. package/dist/core/relay/timeline-event-builder.js.map +1 -1
  28. package/dist/core/relay/timeline-event-log.d.ts +29 -0
  29. package/dist/core/relay/timeline-event-log.js +37 -0
  30. package/dist/core/relay/timeline-event-log.js.map +1 -1
  31. package/dist/core/relay/timeline-projection-v3.d.ts +63 -0
  32. package/dist/core/relay/timeline-projection-v3.js +87 -0
  33. package/dist/core/relay/timeline-projection-v3.js.map +1 -0
  34. package/dist/hermes/hermes-relay-manager.js +3 -0
  35. package/dist/hermes/hermes-relay-manager.js.map +1 -1
  36. package/dist/hermes/hermes-runtime-test-support.d.ts +3 -3
  37. package/dist/hermes/hermes-runtime-test-support.js +12 -6
  38. package/dist/hermes/hermes-runtime-test-support.js.map +1 -1
  39. package/dist/hermes/runtime/hermes-file-transfer-state.d.ts +33 -0
  40. package/dist/hermes/runtime/hermes-file-transfer-state.js +139 -0
  41. package/dist/hermes/runtime/hermes-file-transfer-state.js.map +1 -0
  42. package/dist/hermes/runtime/hermes-mobile-file-route-store.d.ts +17 -0
  43. package/dist/hermes/runtime/hermes-mobile-file-route-store.js +103 -0
  44. package/dist/hermes/runtime/hermes-mobile-file-route-store.js.map +1 -0
  45. package/dist/hermes/runtime/hermes-runtime-api-client.d.ts +1 -0
  46. package/dist/hermes/runtime/hermes-runtime-api-client.js +16 -0
  47. package/dist/hermes/runtime/hermes-runtime-api-client.js.map +1 -1
  48. package/dist/hermes/runtime/hermes-runtime-chat.d.ts +35 -4
  49. package/dist/hermes/runtime/hermes-runtime-chat.js +426 -51
  50. package/dist/hermes/runtime/hermes-runtime-chat.js.map +1 -1
  51. package/dist/hermes/runtime/hermes-runtime-command-router.js +9 -1
  52. package/dist/hermes/runtime/hermes-runtime-command-router.js.map +1 -1
  53. package/dist/hermes/runtime/hermes-runtime-cron.d.ts +1 -0
  54. package/dist/hermes/runtime/hermes-runtime-cron.js +34 -66
  55. package/dist/hermes/runtime/hermes-runtime-cron.js.map +1 -1
  56. package/dist/hermes/runtime/hermes-runtime-history-completion.d.ts +8 -1
  57. package/dist/hermes/runtime/hermes-runtime-history-completion.js +112 -41
  58. package/dist/hermes/runtime/hermes-runtime-history-completion.js.map +1 -1
  59. package/dist/hermes/runtime/hermes-runtime-history.js +92 -17
  60. package/dist/hermes/runtime/hermes-runtime-history.js.map +1 -1
  61. package/dist/hermes/runtime/hermes-runtime-models.js +4 -1
  62. package/dist/hermes/runtime/hermes-runtime-models.js.map +1 -1
  63. package/dist/hermes/runtime/hermes-runtime-process.js +4 -3
  64. package/dist/hermes/runtime/hermes-runtime-process.js.map +1 -1
  65. package/dist/hermes/runtime/hermes-runtime-state-db.d.ts +6 -0
  66. package/dist/hermes/runtime/hermes-runtime-state-db.js +20 -1
  67. package/dist/hermes/runtime/hermes-runtime-state-db.js.map +1 -1
  68. package/dist/hermes/runtime/hermes-runtime-tool-log-watcher.js +12 -20
  69. package/dist/hermes/runtime/hermes-runtime-tool-log-watcher.js.map +1 -1
  70. package/dist/index.js +16 -2
  71. package/dist/index.js.map +1 -1
  72. package/dist/openclaw/config/provider-config.js +4 -1
  73. package/dist/openclaw/config/provider-config.js.map +1 -1
  74. package/dist/openclaw/relay/agent-identity-helpers.d.ts +9 -0
  75. package/dist/openclaw/relay/agent-identity-helpers.js +118 -0
  76. package/dist/openclaw/relay/agent-identity-helpers.js.map +1 -0
  77. package/dist/openclaw/relay/assistant-media-sidecar.d.ts +19 -2
  78. package/dist/openclaw/relay/assistant-media-sidecar.js +131 -15
  79. package/dist/openclaw/relay/assistant-media-sidecar.js.map +1 -1
  80. package/dist/openclaw/relay/chat-history.d.ts +37 -2
  81. package/dist/openclaw/relay/chat-history.js +565 -51
  82. package/dist/openclaw/relay/chat-history.js.map +1 -1
  83. package/dist/openclaw/relay/chat-run-identity.js +3 -1
  84. package/dist/openclaw/relay/chat-run-identity.js.map +1 -1
  85. package/dist/openclaw/relay/gateway-history-projection.d.ts +4 -0
  86. package/dist/openclaw/relay/gateway-history-projection.js +67 -0
  87. package/dist/openclaw/relay/gateway-history-projection.js.map +1 -0
  88. package/dist/openclaw/relay/openclaw-active-run-state.d.ts +67 -0
  89. package/dist/openclaw/relay/openclaw-active-run-state.js +283 -0
  90. package/dist/openclaw/relay/openclaw-active-run-state.js.map +1 -0
  91. package/dist/openclaw/relay/openclaw-message-tool-real-shape.fixture.d.ts +12 -0
  92. package/dist/openclaw/relay/openclaw-message-tool-real-shape.fixture.js +48 -0
  93. package/dist/openclaw/relay/openclaw-message-tool-real-shape.fixture.js.map +1 -0
  94. package/dist/openclaw/relay/openclaw-source-commit-watcher.d.ts +23 -0
  95. package/dist/openclaw/relay/openclaw-source-commit-watcher.js +65 -0
  96. package/dist/openclaw/relay/openclaw-source-commit-watcher.js.map +1 -0
  97. package/dist/openclaw/relay/outgoing-media-relay.d.ts +30 -3
  98. package/dist/openclaw/relay/outgoing-media-relay.js +407 -118
  99. package/dist/openclaw/relay/outgoing-media-relay.js.map +1 -1
  100. package/dist/openclaw/relay/relay-manager-history-timing.d.ts +1 -4
  101. package/dist/openclaw/relay/relay-manager-history-timing.js +4 -4
  102. package/dist/openclaw/relay/relay-manager-history-timing.js.map +1 -1
  103. package/dist/openclaw/relay/relay-manager-payload-helpers.d.ts +28 -1
  104. package/dist/openclaw/relay/relay-manager-payload-helpers.js +219 -11
  105. package/dist/openclaw/relay/relay-manager-payload-helpers.js.map +1 -1
  106. package/dist/openclaw/relay/session-context.d.ts +15 -0
  107. package/dist/openclaw/relay/session-context.js +48 -4
  108. package/dist/openclaw/relay/session-context.js.map +1 -1
  109. package/dist/openclaw/relay/source-commit-projection.d.ts +25 -0
  110. package/dist/openclaw/relay/source-commit-projection.js +140 -0
  111. package/dist/openclaw/relay/source-commit-projection.js.map +1 -0
  112. package/dist/openclaw/relay/transcript-dedupe.js +11 -42
  113. package/dist/openclaw/relay/transcript-dedupe.js.map +1 -1
  114. package/dist/openclaw/relay-manager.js +328 -136
  115. package/dist/openclaw/relay-manager.js.map +1 -1
  116. package/dist/openclaw/runtime/local-runtime.js +4 -2
  117. package/dist/openclaw/runtime/local-runtime.js.map +1 -1
  118. package/package.json +1 -1
  119. package/dist/openclaw/session-store.d.ts +0 -6
  120. package/dist/openclaw/session-store.js +0 -231
  121. package/dist/openclaw/session-store.js.map +0 -1
@@ -0,0 +1,283 @@
1
+ import { createHash } from "node:crypto";
2
+ import { copyFile, mkdir, open, readFile, readdir, rename, stat, unlink, writeFile } from "node:fs/promises";
3
+ import { homedir } from "node:os";
4
+ import { dirname, join } from "node:path";
5
+ import { getActiveProfile, profileDisplayName } from "../../config/profile.js";
6
+ export const OPENCLAW_ACTIVE_RUN_TTL_MS = 10 * 60_000;
7
+ export const OPENCLAW_TERMINAL_RUN_GRACE_MS = 60_000;
8
+ // Serializes only this process. The per-record lock below is the cross-process
9
+ // guard; a single aggregate JSON file would let manager/CLI read-modify-write
10
+ // operations overwrite each other's unrelated runs.
11
+ let mutationChain = Promise.resolve();
12
+ /** Exact Host ownership key. Relay display canonicalization is separate. */
13
+ export function normalizeOpenClawHostSessionKey(sessionKey) {
14
+ return sessionKey.trim() || "main";
15
+ }
16
+ export function openClawRunScopeKey(params) {
17
+ return JSON.stringify([
18
+ profileDisplayName(params.profile ?? getActiveProfile()),
19
+ params.gatewayId.trim(),
20
+ normalizeOpenClawHostSessionKey(params.sessionKey),
21
+ ]);
22
+ }
23
+ /** Map a Host key to the mobile/Relay display alias only at the upload boundary. */
24
+ export function canonicalOpenClawRelaySessionKey(sessionKey) {
25
+ const normalized = normalizeOpenClawHostSessionKey(sessionKey);
26
+ const match = /^agent:[^:]+:(.+)$/i.exec(normalized);
27
+ return (match?.[1] ?? normalized) || "main";
28
+ }
29
+ export async function recordOpenClawActiveRun(params) {
30
+ const gatewayId = params.gatewayId.trim();
31
+ const sourceRunId = params.sourceRunId.trim();
32
+ const sessionKey = normalizeOpenClawHostSessionKey(params.sessionKey);
33
+ if (!gatewayId || !sourceRunId)
34
+ return undefined;
35
+ const nowMs = params.nowMs ?? Date.now();
36
+ const now = new Date(nowMs).toISOString();
37
+ const run = {
38
+ profile: profileDisplayName(params.profile ?? getActiveProfile()),
39
+ gatewayId,
40
+ sessionKey,
41
+ sourceRunId,
42
+ ...(params.providerRunId?.trim() ? { providerRunId: params.providerRunId.trim() } : {}),
43
+ state: "active",
44
+ createdAt: now,
45
+ updatedAt: now,
46
+ expiresAt: new Date(nowMs + OPENCLAW_ACTIVE_RUN_TTL_MS).toISOString(),
47
+ };
48
+ await mutateStore(async () => {
49
+ const path = recordPath(run);
50
+ await withRecordLock(path, async () => {
51
+ await writeRecordAtomic(path, run);
52
+ });
53
+ });
54
+ return run;
55
+ }
56
+ export async function updateOpenClawActiveRunProviderId(params) {
57
+ const sourceRunId = params.sourceRunId.trim();
58
+ const providerRunId = params.providerRunId.trim();
59
+ if (!sourceRunId || !providerRunId)
60
+ return;
61
+ const candidate = {
62
+ profile: profileDisplayName(params.profile ?? getActiveProfile()),
63
+ gatewayId: params.gatewayId.trim(),
64
+ sessionKey: normalizeOpenClawHostSessionKey(params.sessionKey),
65
+ sourceRunId,
66
+ };
67
+ const nowMs = params.nowMs ?? Date.now();
68
+ await mutateStore(async () => {
69
+ const path = recordPath(candidate);
70
+ await withRecordLock(path, async () => {
71
+ const existing = await readRecord(path);
72
+ if (!existing || isExpired(existing, nowMs)) {
73
+ if (existing)
74
+ await unlink(path).catch(() => undefined);
75
+ return;
76
+ }
77
+ existing.providerRunId = providerRunId;
78
+ existing.updatedAt = new Date(nowMs).toISOString();
79
+ await writeRecordAtomic(path, existing);
80
+ });
81
+ });
82
+ }
83
+ /** Return only the explicitly named run; never select a latest/unique candidate. */
84
+ export async function resolveOpenClawActiveRun(params) {
85
+ const gatewayId = params.gatewayId.trim();
86
+ const sessionKey = normalizeOpenClawHostSessionKey(params.sessionKey);
87
+ if (!gatewayId)
88
+ return undefined;
89
+ const nowMs = params.nowMs ?? Date.now();
90
+ const profile = profileDisplayName(params.profile ?? getActiveProfile());
91
+ const requestedSourceRunId = params.sourceRunId.trim();
92
+ if (!gatewayId || !requestedSourceRunId)
93
+ return undefined;
94
+ const runs = await readRuns();
95
+ for (const { path, run } of runs) {
96
+ if (isExpired(run, nowMs)) {
97
+ await removeExpiredRecord(path, run, nowMs);
98
+ continue;
99
+ }
100
+ if (run.profile === profile
101
+ && run.gatewayId === gatewayId
102
+ && run.sessionKey === sessionKey
103
+ && run.sourceRunId === requestedSourceRunId) {
104
+ return run;
105
+ }
106
+ }
107
+ return undefined;
108
+ }
109
+ export async function markOpenClawActiveRunTerminal(params) {
110
+ const sourceRunId = params.sourceRunId.trim();
111
+ if (!sourceRunId)
112
+ return;
113
+ const nowMs = params.nowMs ?? Date.now();
114
+ const candidate = {
115
+ profile: profileDisplayName(params.profile ?? getActiveProfile()),
116
+ gatewayId: params.gatewayId.trim(),
117
+ sessionKey: normalizeOpenClawHostSessionKey(params.sessionKey),
118
+ sourceRunId,
119
+ };
120
+ await mutateStore(async () => {
121
+ const path = recordPath(candidate);
122
+ await withRecordLock(path, async () => {
123
+ const existing = await readRecord(path);
124
+ if (!existing || isExpired(existing, nowMs)) {
125
+ if (existing)
126
+ await unlink(path).catch(() => undefined);
127
+ return;
128
+ }
129
+ existing.state = "terminal";
130
+ existing.updatedAt = new Date(nowMs).toISOString();
131
+ existing.expiresAt = new Date(nowMs + OPENCLAW_TERMINAL_RUN_GRACE_MS).toISOString();
132
+ await writeRecordAtomic(path, existing);
133
+ });
134
+ });
135
+ }
136
+ export async function clearOpenClawActiveRun(params) {
137
+ const profile = profileDisplayName(params.profile ?? getActiveProfile());
138
+ const gatewayId = params.gatewayId.trim();
139
+ const sessionKey = normalizeOpenClawHostSessionKey(params.sessionKey);
140
+ const requestedSourceRunId = params.sourceRunId?.trim();
141
+ await mutateStore(async () => {
142
+ for (const { path, run } of await readRuns()) {
143
+ if (run.profile !== profile
144
+ || run.gatewayId !== gatewayId
145
+ || run.sessionKey !== sessionKey
146
+ || (requestedSourceRunId && run.sourceRunId !== requestedSourceRunId))
147
+ continue;
148
+ await withRecordLock(path, async () => {
149
+ const current = await readRecord(path);
150
+ if (current && current.sourceRunId === run.sourceRunId)
151
+ await unlink(path).catch(() => undefined);
152
+ });
153
+ }
154
+ });
155
+ }
156
+ function recordKey(run) {
157
+ return createHash("sha256")
158
+ .update(JSON.stringify([run.profile, run.gatewayId, run.sessionKey, run.sourceRunId]))
159
+ .digest("hex");
160
+ }
161
+ function recordPath(run) {
162
+ return join(storeDirectory(), `${recordKey(run)}.json`);
163
+ }
164
+ function storeDirectory() {
165
+ const configured = process.env.CLAWCONNECT_OPENCLAW_ACTIVE_RUN_STORE?.trim();
166
+ return configured
167
+ ? `${configured}.records`
168
+ : join(homedir(), ".clawconnect", "openclaw", "active-runs");
169
+ }
170
+ function isExpired(run, nowMs) {
171
+ const expiresAt = Date.parse(run.expiresAt);
172
+ return !Number.isFinite(expiresAt) || nowMs >= expiresAt;
173
+ }
174
+ async function readRuns() {
175
+ const directory = storeDirectory();
176
+ let names;
177
+ try {
178
+ names = await readdir(directory);
179
+ }
180
+ catch (error) {
181
+ if (isMissing(error))
182
+ return [];
183
+ return [];
184
+ }
185
+ const runs = [];
186
+ for (const name of names) {
187
+ if (!name.endsWith(".json"))
188
+ continue;
189
+ const path = join(directory, name);
190
+ const run = await readRecord(path);
191
+ if (run)
192
+ runs.push({ path, run });
193
+ }
194
+ return runs;
195
+ }
196
+ async function readRecord(path) {
197
+ try {
198
+ const parsed = JSON.parse(await readFile(path, "utf8"));
199
+ if (typeof parsed.profile !== "string"
200
+ || typeof parsed.gatewayId !== "string"
201
+ || typeof parsed.sessionKey !== "string"
202
+ || typeof parsed.sourceRunId !== "string"
203
+ || (parsed.state !== "active" && parsed.state !== "terminal")
204
+ || typeof parsed.createdAt !== "string"
205
+ || typeof parsed.updatedAt !== "string"
206
+ || typeof parsed.expiresAt !== "string")
207
+ return undefined;
208
+ return parsed;
209
+ }
210
+ catch {
211
+ await quarantineCorruptStore(path);
212
+ return undefined;
213
+ }
214
+ }
215
+ async function writeRecordAtomic(path, run) {
216
+ await mkdir(dirname(path), { recursive: true });
217
+ const tempPath = `${path}.${process.pid}.${Date.now()}.tmp`;
218
+ await writeFile(tempPath, JSON.stringify(run, null, 2), "utf8");
219
+ await rename(tempPath, path);
220
+ }
221
+ async function removeExpiredRecord(path, run, nowMs) {
222
+ await withRecordLock(path, async () => {
223
+ const current = await readRecord(path);
224
+ if (current && current.sourceRunId === run.sourceRunId && isExpired(current, nowMs)) {
225
+ await unlink(path).catch(() => undefined);
226
+ }
227
+ });
228
+ }
229
+ async function mutateStore(mutator) {
230
+ const run = mutationChain.then(mutator);
231
+ mutationChain = run.catch(() => undefined);
232
+ await run;
233
+ }
234
+ async function withRecordLock(path, fn) {
235
+ const lockPath = `${path}.lock`;
236
+ await mkdir(dirname(path), { recursive: true });
237
+ let handle;
238
+ for (let attempt = 0; attempt < 200; attempt += 1) {
239
+ try {
240
+ handle = await open(lockPath, "wx");
241
+ break;
242
+ }
243
+ catch (error) {
244
+ if (!isAlreadyExists(error))
245
+ throw error;
246
+ try {
247
+ const lockAgeMs = Date.now() - (await stat(lockPath)).mtimeMs;
248
+ if (lockAgeMs > 30_000) {
249
+ await unlink(lockPath).catch(() => undefined);
250
+ continue;
251
+ }
252
+ }
253
+ catch {
254
+ // A concurrent owner may have released the lock between stat/unlink.
255
+ }
256
+ await new Promise((resolve) => setTimeout(resolve, 5));
257
+ }
258
+ }
259
+ if (!handle)
260
+ throw new Error("openclaw_active_run_lock_timeout");
261
+ try {
262
+ return await fn();
263
+ }
264
+ finally {
265
+ await handle.close().catch(() => undefined);
266
+ await unlink(lockPath).catch(() => undefined);
267
+ }
268
+ }
269
+ function isMissing(error) {
270
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
271
+ }
272
+ function isAlreadyExists(error) {
273
+ return typeof error === "object" && error !== null && "code" in error && error.code === "EEXIST";
274
+ }
275
+ async function quarantineCorruptStore(path) {
276
+ try {
277
+ await copyFile(path, `${path}.corrupt-${Date.now()}`);
278
+ }
279
+ catch {
280
+ // Best effort only; fail closed when the state cannot be read.
281
+ }
282
+ }
283
+ //# sourceMappingURL=openclaw-active-run-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-active-run-state.js","sourceRoot":"","sources":["../../../src/openclaw/relay/openclaw-active-run-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,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0,0 +1,12 @@
1
+ /**
2
+ * Sanitized fixture captured from the installed OpenClaw transcript_events
3
+ * shape (toolResult.details.sourceReply), with local paths and run IDs replaced
4
+ * by test values. The installed AssistantMessage.openclawDelivery type does
5
+ * not contain the identity fields; those live on this structured tool result.
6
+ */
7
+ export declare function realOpenClawMessageToolResultFixture(params: {
8
+ runId: string;
9
+ toolCallId: string;
10
+ idempotencyKey: string;
11
+ mediaUrls: string[];
12
+ }): Record<string, unknown>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Sanitized fixture captured from the installed OpenClaw transcript_events
3
+ * shape (toolResult.details.sourceReply), with local paths and run IDs replaced
4
+ * by test values. The installed AssistantMessage.openclawDelivery type does
5
+ * not contain the identity fields; those live on this structured tool result.
6
+ */
7
+ export function realOpenClawMessageToolResultFixture(params) {
8
+ const firstUrl = params.mediaUrls[0] ?? "";
9
+ return {
10
+ role: "toolResult",
11
+ toolCallId: params.toolCallId,
12
+ toolName: "message",
13
+ content: [{ type: "text", text: "Sent visible reply to the current source conversation via internal-ui." }],
14
+ details: {
15
+ status: "ok",
16
+ deliveryStatus: "sent",
17
+ channel: "webchat",
18
+ target: "current-run",
19
+ sourceReplyDeliveryMode: "message_tool_only",
20
+ idempotencyKey: params.idempotencyKey,
21
+ sourceReplyTranscriptOwner: true,
22
+ sourceReplySink: "internal-ui",
23
+ sourceReply: {
24
+ text: "",
25
+ mediaUrl: firstUrl,
26
+ mediaUrls: params.mediaUrls,
27
+ attachments: params.mediaUrls.map((url, index) => ({
28
+ name: `image-${index + 1}.png`,
29
+ mimeType: "image/png",
30
+ trustedLocalMedia: true,
31
+ url,
32
+ })),
33
+ trustedLocalMedia: true,
34
+ },
35
+ mediaUrl: firstUrl,
36
+ mediaUrls: params.mediaUrls,
37
+ dryRun: false,
38
+ messageDelivery: {
39
+ status: "settled",
40
+ partialDelivery: false,
41
+ createdThreadIds: [],
42
+ },
43
+ },
44
+ isError: false,
45
+ __openclaw: { runId: params.runId },
46
+ };
47
+ }
48
+ //# sourceMappingURL=openclaw-message-tool-real-shape.fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-message-tool-real-shape.fixture.js","sourceRoot":"","sources":["../../../src/openclaw/relay/openclaw-message-tool-real-shape.fixture.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,oCAAoC,CAAC,MAKpD;IACC,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3C,OAAO;QACL,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,QAAQ,EAAE,SAAS;QACnB,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,wEAAwE,EAAE,CAAC;QAC3G,OAAO,EAAE;YACP,MAAM,EAAE,IAAI;YACZ,cAAc,EAAE,MAAM;YACtB,OAAO,EAAE,SAAS;YAClB,MAAM,EAAE,aAAa;YACrB,uBAAuB,EAAE,mBAAmB;YAC5C,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,0BAA0B,EAAE,IAAI;YAChC,eAAe,EAAE,aAAa;YAC9B,WAAW,EAAE;gBACX,IAAI,EAAE,EAAE;gBACR,QAAQ,EAAE,QAAQ;gBAClB,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,WAAW,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;oBACjD,IAAI,EAAE,SAAS,KAAK,GAAG,CAAC,MAAM;oBAC9B,QAAQ,EAAE,WAAW;oBACrB,iBAAiB,EAAE,IAAI;oBACvB,GAAG;iBACJ,CAAC,CAAC;gBACH,iBAAiB,EAAE,IAAI;aACxB;YACD,QAAQ,EAAE,QAAQ;YAClB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,KAAK;YACb,eAAe,EAAE;gBACf,MAAM,EAAE,SAAS;gBACjB,eAAe,EAAE,KAAK;gBACtB,gBAAgB,EAAE,EAAE;aACrB;SACF;QACD,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;KACpC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { type SourceCommit } from "../../core/relay/source-commit.js";
2
+ export type OpenClawSourceCommitWatcher = {
3
+ notify(): void;
4
+ rescan(): void;
5
+ close(): void;
6
+ };
7
+ /**
8
+ * SQLite/WAL notifications are only wake-up signals. The caller supplies an
9
+ * authoritative cursor reader, which is read synchronously in a serialized
10
+ * observer. Watching both the database directory and the database file keeps
11
+ * the observer alive across SQLite WAL rotation and atomic replacement. The
12
+ * low-frequency anti-entropy rescan is deliberately only a liveness aid: the
13
+ * cursor reader still owns identity/order and the observer only advances after
14
+ * the downstream append path succeeds.
15
+ */
16
+ export declare function watchOpenClawSourceCommit(options: {
17
+ databasePath: string;
18
+ readCursor: () => SourceCommit | null | Promise<SourceCommit | null>;
19
+ onCommit: (commit: SourceCommit, previousCommittedThroughSeq: number | undefined) => void | Promise<void>;
20
+ onError?: (error: unknown) => void;
21
+ rescanIntervalMs?: number;
22
+ initialWatermarkMode?: "latest" | "from_zero";
23
+ }): OpenClawSourceCommitWatcher;
@@ -0,0 +1,65 @@
1
+ import { watch } from "node:fs";
2
+ import { dirname, basename } from "node:path";
3
+ import { createSourceCommitObserver } from "../../core/relay/source-commit.js";
4
+ /**
5
+ * SQLite/WAL notifications are only wake-up signals. The caller supplies an
6
+ * authoritative cursor reader, which is read synchronously in a serialized
7
+ * observer. Watching both the database directory and the database file keeps
8
+ * the observer alive across SQLite WAL rotation and atomic replacement. The
9
+ * low-frequency anti-entropy rescan is deliberately only a liveness aid: the
10
+ * cursor reader still owns identity/order and the observer only advances after
11
+ * the downstream append path succeeds.
12
+ */
13
+ export function watchOpenClawSourceCommit(options) {
14
+ const observer = createSourceCommitObserver({
15
+ readCursor: options.readCursor,
16
+ onCommit: options.onCommit,
17
+ onError: options.onError,
18
+ initialWatermarkMode: options.initialWatermarkMode,
19
+ });
20
+ const watchers = [];
21
+ const watchedDirectory = dirname(options.databasePath);
22
+ const databaseName = basename(options.databasePath);
23
+ const notify = () => observer.notify();
24
+ const rescanIntervalMs = options.rescanIntervalMs ?? 5_000;
25
+ let rescanTimer;
26
+ // Directory events cover create/rename/reopen and -wal/-shm churn. The
27
+ // direct file watch reduces latency for ordinary commits. Neither watcher
28
+ // performs correctness work; the cursor reader remains authoritative.
29
+ try {
30
+ watchers.push(watch(watchedDirectory, (_eventType, changedName) => {
31
+ if (!changedName || String(changedName) === databaseName || String(changedName).startsWith(`${databaseName}-`)) {
32
+ notify();
33
+ }
34
+ }));
35
+ }
36
+ catch {
37
+ // The caller still gets an immediate rescan and can continue using live
38
+ // gateway events if the source is not present yet.
39
+ }
40
+ try {
41
+ watchers.push(watch(options.databasePath, notify));
42
+ }
43
+ catch {
44
+ // The directory watch can be re-established when the file appears.
45
+ }
46
+ if (Number.isFinite(rescanIntervalMs) && rescanIntervalMs > 0) {
47
+ // Node's fs.watch can coalesce/drop SQLite WAL notifications. This timer
48
+ // is intentionally low frequency and does not participate in ordering.
49
+ rescanTimer = setInterval(notify, Math.floor(rescanIntervalMs));
50
+ rescanTimer.unref?.();
51
+ }
52
+ observer.rescan();
53
+ return {
54
+ notify,
55
+ rescan: observer.rescan,
56
+ close() {
57
+ for (const fileWatcher of watchers)
58
+ fileWatcher.close();
59
+ if (rescanTimer)
60
+ clearInterval(rescanTimer);
61
+ observer.close();
62
+ },
63
+ };
64
+ }
65
+ //# sourceMappingURL=openclaw-source-commit-watcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openclaw-source-commit-watcher.js","sourceRoot":"","sources":["../../../src/openclaw/relay/openclaw-source-commit-watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAkB,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,OAAO,EA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CAAC,CAAC,CAAC;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,mEAAmE;IACrE,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,gBAAgB,GAAG,CAAC,EAAE,CAAC;QAC9D,yEAAyE;QACzE,uEAAuE;QACvE,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAChE,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC;IACxB,CAAC;IACD,QAAQ,CAAC,MAAM,EAAE,CAAC;IAClB,OAAO;QACL,MAAM;QACN,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,KAAK;YACH,KAAK,MAAM,WAAW,IAAI,QAAQ;gBAAE,WAAW,CAAC,KAAK,EAAE,CAAC;YACxD,IAAI,WAAW;gBAAE,aAAa,CAAC,WAAW,CAAC,CAAC;YAC5C,QAAQ,CAAC,KAAK,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { type FileUploadResult } from "../../core/relay/file-upload.js";
2
+ import { type GatewaySessionDefaults } from "./session-context.js";
3
+ declare const OPENCLAW_DELIVERY_CONTRACT = "openclaw.message-tool-delivery.v1";
2
4
  export type OutgoingMediaRelayOptions = {
3
5
  relayServerUrl: string;
4
6
  relaySecret: string;
@@ -7,14 +9,39 @@ export type OutgoingMediaRelayOptions = {
7
9
  recordsDir?: string;
8
10
  stateDir?: string;
9
11
  cache?: Map<string, FileUploadResult>;
12
+ /**
13
+ * Legacy caller context. Deliberately ignored: attachment publication must
14
+ * come from typed content blocks or structured OpenClaw delivery metadata,
15
+ * never from natural-language intent in this field.
16
+ */
10
17
  userMessage?: string;
11
18
  /**
12
19
  * A live gateway event can arrive a few milliseconds before OpenClaw commits
13
- * its managed outgoing-media record. Only that path should briefly wait for
14
- * the record instead of publishing an unavailable image placeholder.
20
+ * its managed outgoing-media record. Only that file-availability path may
21
+ * briefly wait for the record; this never delays timeline identity, ordering,
22
+ * or message projection correctness.
15
23
  */
16
24
  waitForOutgoingMediaRecord?: boolean;
25
+ /** Session defaults used to canonicalize OpenClaw relation scopes. */
26
+ sessionDefaults?: GatewaySessionDefaults;
27
+ };
28
+ type OpenClawDeliveryReceipt = {
29
+ contract: typeof OPENCLAW_DELIVERY_CONTRACT;
30
+ toolName: "message";
31
+ toolCallId: string;
32
+ idempotencyKey: string;
33
+ sourceRunId: string;
34
+ mediaUrls: string[];
17
35
  };
18
36
  export declare function relayOutgoingMediaInPayload(payload: unknown, opts: OutgoingMediaRelayOptions): Promise<unknown>;
37
+ /**
38
+ * Adapt the shape emitted by the currently deployed OpenClaw message tool.
39
+ * The installed OpenClaw type declares `openclawDelivery.mediaUrls` only as a
40
+ * display projection. The authoritative toolResult carries the delivery
41
+ * status, tool call, idempotency key, run metadata, and trusted local media
42
+ * list in `details.sourceReply`; only that explicit relation becomes the
43
+ * internal typed v1 receipt. Generic mediaUrls stay inert.
44
+ */
45
+ export declare function adaptOpenClawMessageToolDelivery(value: unknown, expectedSourceRunId?: string): OpenClawDeliveryReceipt | undefined;
19
46
  export declare function relayOutgoingMediaInHistoryResponse(response: unknown, opts: OutgoingMediaRelayOptions): Promise<unknown>;
20
- export declare function extractDeliverablePathCandidates(text: string): string[];
47
+ export {};