@agentmemory/agentmemory 0.9.28 → 0.9.30

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 (158) hide show
  1. package/.env.example +98 -28
  2. package/AGENTS.md +19 -26
  3. package/README.md +619 -274
  4. package/dist/.env.example +98 -28
  5. package/dist/cli.d.mts.map +1 -1
  6. package/dist/cli.mjs +1328 -244
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/{connect-JnsJXc68.mjs → connect-B4_ca6BD.mjs} +619 -70
  9. package/dist/connect-B4_ca6BD.mjs.map +1 -0
  10. package/dist/docker-compose.yml +42 -16
  11. package/dist/hooks/_capture.d.mts +22 -0
  12. package/dist/hooks/_capture.d.mts.map +1 -0
  13. package/dist/hooks/_capture.mjs +908 -0
  14. package/dist/hooks/_capture.mjs.map +1 -0
  15. package/dist/hooks/antigravity-bridge.d.mts +8 -0
  16. package/dist/hooks/antigravity-bridge.d.mts.map +1 -0
  17. package/dist/hooks/antigravity-bridge.mjs +123 -0
  18. package/dist/hooks/antigravity-bridge.mjs.map +1 -0
  19. package/dist/hooks/notification.mjs +34 -27
  20. package/dist/hooks/notification.mjs.map +1 -1
  21. package/dist/hooks/post-commit.mjs +84 -2
  22. package/dist/hooks/post-commit.mjs.map +1 -1
  23. package/dist/hooks/post-tool-failure.mjs +71 -26
  24. package/dist/hooks/post-tool-failure.mjs.map +1 -1
  25. package/dist/hooks/post-tool-use.mjs +99 -36
  26. package/dist/hooks/post-tool-use.mjs.map +1 -1
  27. package/dist/hooks/pre-compact.mjs +95 -5
  28. package/dist/hooks/pre-compact.mjs.map +1 -1
  29. package/dist/hooks/pre-tool-use.mjs +72 -2
  30. package/dist/hooks/pre-tool-use.mjs.map +1 -1
  31. package/dist/hooks/prompt-submit.mjs +25 -22
  32. package/dist/hooks/prompt-submit.mjs.map +1 -1
  33. package/dist/hooks/session-end.mjs +93 -24
  34. package/dist/hooks/session-end.mjs.map +1 -1
  35. package/dist/hooks/session-start.mjs +101 -6
  36. package/dist/hooks/session-start.mjs.map +1 -1
  37. package/dist/hooks/stop.mjs +72 -8
  38. package/dist/hooks/stop.mjs.map +1 -1
  39. package/dist/hooks/subagent-start.mjs +28 -26
  40. package/dist/hooks/subagent-start.mjs.map +1 -1
  41. package/dist/hooks/subagent-stop.mjs +29 -26
  42. package/dist/hooks/subagent-stop.mjs.map +1 -1
  43. package/dist/hooks/task-completed.mjs +31 -28
  44. package/dist/hooks/task-completed.mjs.map +1 -1
  45. package/dist/iii-config.docker.yaml +10 -10
  46. package/dist/iii-config.yaml +3 -1
  47. package/dist/{image-refs-BKLmp_sD.mjs → image-refs-BaT-9oMU.mjs} +2 -2
  48. package/dist/image-refs-BaT-9oMU.mjs.map +1 -0
  49. package/dist/{image-refs-C2YU7BIm.mjs → image-refs-T_urbwHM.mjs} +3 -3
  50. package/dist/image-refs-T_urbwHM.mjs.map +1 -0
  51. package/dist/{keyed-mutex-DTHtcZrt.mjs → image-store-BsN4vyjr.mjs} +2 -14
  52. package/dist/image-store-BsN4vyjr.mjs.map +1 -0
  53. package/dist/index.mjs +14021 -6494
  54. package/dist/index.mjs.map +1 -1
  55. package/dist/keyed-mutex-DchXsyfP.mjs +221 -0
  56. package/dist/keyed-mutex-DchXsyfP.mjs.map +1 -0
  57. package/dist/secret-store-BnY3A50C.mjs +2348 -0
  58. package/dist/secret-store-BnY3A50C.mjs.map +1 -0
  59. package/dist/{src-CzgoepGU.mjs → src-Jsq9LCeH.mjs} +7349 -2940
  60. package/dist/src-Jsq9LCeH.mjs.map +1 -0
  61. package/dist/{standalone-YsZFFQBM.mjs → standalone-DKCdrf1d.mjs} +62 -24
  62. package/dist/standalone-DKCdrf1d.mjs.map +1 -0
  63. package/dist/standalone.d.mts.map +1 -1
  64. package/dist/standalone.mjs +298 -27
  65. package/dist/standalone.mjs.map +1 -1
  66. package/dist/status-IRz7ta8-.mjs +2344 -0
  67. package/dist/status-IRz7ta8-.mjs.map +1 -0
  68. package/dist/viewer/favicon.svg +35 -1
  69. package/dist/viewer/index.html +7428 -2608
  70. package/docker-compose.yml +42 -16
  71. package/iii-config.docker.yaml +10 -10
  72. package/iii-config.yaml +3 -1
  73. package/integrations/pi/README.md +77 -0
  74. package/integrations/pi/index.ts +402 -0
  75. package/integrations/pi/package.json +32 -0
  76. package/integrations/pi/security.ts +87 -0
  77. package/package.json +15 -7
  78. package/plugin/.claude-plugin/plugin.json +2 -2
  79. package/plugin/.codex-plugin/plugin.json +26 -4
  80. package/plugin/.devin-plugin/plugin.json +32 -0
  81. package/plugin/.mcp.codex.json +12 -0
  82. package/plugin/.mcp.copilot.json +2 -7
  83. package/plugin/.mcp.json +2 -7
  84. package/plugin/assets/icon.svg +35 -0
  85. package/plugin/cursor/hooks.json +41 -0
  86. package/plugin/cursor/mcp.json +12 -0
  87. package/plugin/hooks/hooks.antigravity.json +43 -0
  88. package/plugin/hooks/hooks.copilot.json +11 -11
  89. package/plugin/hooks/hooks.devin.json +67 -0
  90. package/plugin/hooks/hooks.droid.json +55 -0
  91. package/plugin/opencode/README.md +267 -31
  92. package/plugin/opencode/agentmemory-capture.ts +644 -15
  93. package/plugin/opencode/plugin.json +1 -1
  94. package/plugin/plugin.json +2 -2
  95. package/plugin/scripts/_capture.d.mts +22 -0
  96. package/plugin/scripts/_capture.d.mts.map +1 -0
  97. package/plugin/scripts/_capture.mjs +908 -0
  98. package/plugin/scripts/_capture.mjs.map +1 -0
  99. package/plugin/scripts/antigravity-bridge.d.mts +8 -0
  100. package/plugin/scripts/antigravity-bridge.d.mts.map +1 -0
  101. package/plugin/scripts/antigravity-bridge.mjs +123 -0
  102. package/plugin/scripts/antigravity-bridge.mjs.map +1 -0
  103. package/plugin/scripts/notification.mjs +34 -27
  104. package/plugin/scripts/notification.mjs.map +1 -1
  105. package/plugin/scripts/plugin-bridge.mjs +378 -0
  106. package/plugin/scripts/post-commit.mjs +84 -2
  107. package/plugin/scripts/post-commit.mjs.map +1 -1
  108. package/plugin/scripts/post-tool-failure.mjs +71 -26
  109. package/plugin/scripts/post-tool-failure.mjs.map +1 -1
  110. package/plugin/scripts/post-tool-use.mjs +99 -36
  111. package/plugin/scripts/post-tool-use.mjs.map +1 -1
  112. package/plugin/scripts/pre-compact.mjs +95 -5
  113. package/plugin/scripts/pre-compact.mjs.map +1 -1
  114. package/plugin/scripts/pre-tool-use.mjs +72 -2
  115. package/plugin/scripts/pre-tool-use.mjs.map +1 -1
  116. package/plugin/scripts/prompt-submit.mjs +25 -22
  117. package/plugin/scripts/prompt-submit.mjs.map +1 -1
  118. package/plugin/scripts/session-end.mjs +93 -24
  119. package/plugin/scripts/session-end.mjs.map +1 -1
  120. package/plugin/scripts/session-start.mjs +101 -6
  121. package/plugin/scripts/session-start.mjs.map +1 -1
  122. package/plugin/scripts/stop.mjs +72 -8
  123. package/plugin/scripts/stop.mjs.map +1 -1
  124. package/plugin/scripts/subagent-start.mjs +28 -26
  125. package/plugin/scripts/subagent-start.mjs.map +1 -1
  126. package/plugin/scripts/subagent-stop.mjs +29 -26
  127. package/plugin/scripts/subagent-stop.mjs.map +1 -1
  128. package/plugin/scripts/task-completed.mjs +31 -28
  129. package/plugin/scripts/task-completed.mjs.map +1 -1
  130. package/plugin/skills/_shared/TROUBLESHOOTING.md +22 -6
  131. package/plugin/skills/agentmemory-agents/REFERENCE.md +8 -5
  132. package/plugin/skills/agentmemory-config/REFERENCE.md +52 -1
  133. package/plugin/skills/agentmemory-config/SKILL.md +44 -7
  134. package/plugin/skills/agentmemory-mcp-tools/REFERENCE.md +4 -3
  135. package/plugin/skills/agentmemory-rest-api/REFERENCE.md +23 -2
  136. package/plugin/skills/forget/SKILL.md +4 -1
  137. package/plugin/skills/handoff/SKILL.md +4 -2
  138. package/plugin/skills/lesson/SKILL.md +64 -0
  139. package/plugin/skills/memory-discipline/SKILL.md +65 -0
  140. package/plugin/skills/recall/SKILL.md +4 -1
  141. package/plugin/skills/remember/SKILL.md +6 -1
  142. package/dist/config-ChC9EtgV.mjs +0 -259
  143. package/dist/config-ChC9EtgV.mjs.map +0 -1
  144. package/dist/connect-JnsJXc68.mjs.map +0 -1
  145. package/dist/image-refs-BKLmp_sD.mjs.map +0 -1
  146. package/dist/image-refs-C2YU7BIm.mjs.map +0 -1
  147. package/dist/keyed-mutex-DTHtcZrt.mjs.map +0 -1
  148. package/dist/logger-BEB7pCI9.mjs +0 -43
  149. package/dist/logger-BEB7pCI9.mjs.map +0 -1
  150. package/dist/schema-CNiCWzV9.mjs +0 -78
  151. package/dist/schema-CNiCWzV9.mjs.map +0 -1
  152. package/dist/src-CzgoepGU.mjs.map +0 -1
  153. package/dist/standalone-YsZFFQBM.mjs.map +0 -1
  154. package/dist/tools-registry-D3NEoe5m.mjs +0 -1115
  155. package/dist/tools-registry-D3NEoe5m.mjs.map +0 -1
  156. package/plugin/scripts/diagnostics.d.mts +0 -17
  157. package/plugin/scripts/diagnostics.d.mts.map +0 -1
  158. package/plugin/scripts/diagnostics.mjs.map +0 -1
@@ -0,0 +1,908 @@
1
+ import { spawn } from "node:child_process";
2
+ import { chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, statSync, unlinkSync, utimesSync, writeFileSync, writeSync } from "node:fs";
3
+ import { createHash } from "node:crypto";
4
+ import { homedir, platform } from "node:os";
5
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
+ //#region src/secret-store.ts
7
+ const SECRET_KEY = "AGENTMEMORY_SECRET";
8
+ function agentmemoryHomeDir() {
9
+ return join(homedir(), ".agentmemory");
10
+ }
11
+ function secretFilePath() {
12
+ return join(agentmemoryHomeDir(), "secret");
13
+ }
14
+ function usable(value) {
15
+ if (typeof value !== "string") return "";
16
+ const trimmed = value.trim();
17
+ if (!trimmed) return "";
18
+ if (trimmed.startsWith("${") && trimmed.endsWith("}")) return "";
19
+ return trimmed;
20
+ }
21
+ function unquote(value) {
22
+ const quote = value[0];
23
+ if ((quote === "\"" || quote === "'") && value.length > 1) {
24
+ const close = value.indexOf(quote, 1);
25
+ if (close !== -1) return value.slice(1, close);
26
+ }
27
+ const hash = value.indexOf(" #");
28
+ return hash === -1 ? value : value.slice(0, hash).trim();
29
+ }
30
+ function readEnvFileSecret() {
31
+ let content;
32
+ try {
33
+ content = readFileSync(join(agentmemoryHomeDir(), ".env"), "utf-8");
34
+ } catch {
35
+ return "";
36
+ }
37
+ if (typeof content !== "string") return "";
38
+ let found = "";
39
+ for (const line of content.split("\n")) {
40
+ const trimmed = line.trim();
41
+ if (trimmed.startsWith("#")) continue;
42
+ const eq = trimmed.indexOf("=");
43
+ if (eq === -1) continue;
44
+ if (trimmed.slice(0, eq).replace(/^export\s+/, "").trim() !== SECRET_KEY) continue;
45
+ found = usable(unquote(trimmed.slice(eq + 1).trim()));
46
+ }
47
+ return found;
48
+ }
49
+ function readStoredSecret() {
50
+ try {
51
+ return usable(readFileSync(secretFilePath(), "utf-8"));
52
+ } catch {
53
+ return "";
54
+ }
55
+ }
56
+ function isLoopbackUrl(url) {
57
+ let hostname;
58
+ try {
59
+ hostname = new URL(url).hostname.toLowerCase();
60
+ } catch {
61
+ return false;
62
+ }
63
+ const bare = hostname.replace(/^\[|\]$/g, "");
64
+ return bare === "localhost" || bare === "::1" || /^127(?:\.\d{1,3}){3}$/.test(bare);
65
+ }
66
+ function resolveClientSecret(baseUrl, env = process.env) {
67
+ const fromEnv = usable(env[SECRET_KEY]);
68
+ if (fromEnv) return fromEnv;
69
+ if (!isLoopbackUrl(baseUrl)) return "";
70
+ return readEnvFileSecret() || readStoredSecret();
71
+ }
72
+ //#endregion
73
+ //#region src/capture/event-id.ts
74
+ const HOST_ID_FIELDS = [
75
+ "event_id",
76
+ "eventId",
77
+ "tool_use_id",
78
+ "toolUseId",
79
+ "tool_call_id",
80
+ "toolCallId",
81
+ "call_id",
82
+ "callId",
83
+ "prompt_id",
84
+ "promptId",
85
+ "message_id",
86
+ "messageId"
87
+ ];
88
+ const HOST_TIME_FIELDS = [
89
+ "timestamp",
90
+ "ts",
91
+ "created_at",
92
+ "createdAt",
93
+ "event_time"
94
+ ];
95
+ function stableStringify(value) {
96
+ if (value === void 0) return "null";
97
+ if (value === null || typeof value !== "object") {
98
+ const encoded = JSON.stringify(value);
99
+ return encoded === void 0 ? "null" : encoded;
100
+ }
101
+ if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
102
+ const obj = value;
103
+ return `{${Object.keys(obj).filter((k) => obj[k] !== void 0).sort().map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`).join(",")}}`;
104
+ }
105
+ function hostScalar(host, fields) {
106
+ for (const field of fields) {
107
+ const v = host[field];
108
+ if (typeof v === "string" && v.trim()) return v.trim();
109
+ if (typeof v === "number" && Number.isFinite(v)) return String(v);
110
+ }
111
+ }
112
+ function digest(parts) {
113
+ return createHash("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
114
+ }
115
+ function hasHostIdentity(host) {
116
+ const source = host && typeof host === "object" ? host : {};
117
+ return hostScalar(source, HOST_ID_FIELDS) !== void 0 || hostScalar(source, HOST_TIME_FIELDS) !== void 0;
118
+ }
119
+ function deriveEventId(hookType, sessionId, host, content) {
120
+ const source = host && typeof host === "object" ? host : {};
121
+ const hostId = hostScalar(source, HOST_ID_FIELDS);
122
+ if (hostId) return `evh_${digest([
123
+ "host",
124
+ sessionId,
125
+ hookType,
126
+ hostId
127
+ ])}`;
128
+ return `evc_${digest([
129
+ "content",
130
+ sessionId,
131
+ hookType,
132
+ hostScalar(source, HOST_TIME_FIELDS) ?? "",
133
+ stableStringify(content)
134
+ ])}`;
135
+ }
136
+ //#endregion
137
+ //#region src/cli-data-dir.ts
138
+ function argValue(args, name) {
139
+ const equals = `${name}=`;
140
+ const inline = args.find((arg) => arg.startsWith(equals));
141
+ if (inline) return inline.slice(equals.length);
142
+ const idx = args.indexOf(name);
143
+ if (idx !== -1) return args[idx + 1];
144
+ }
145
+ function expandHome(pathValue, home) {
146
+ if (pathValue === "~") return home;
147
+ if (pathValue.startsWith("~/") || pathValue.startsWith("~\\")) return join(home, pathValue.slice(2));
148
+ return pathValue;
149
+ }
150
+ function absoluteDataDir(pathValue, cwd, home) {
151
+ const expanded = expandHome(pathValue, home);
152
+ return isAbsolute(expanded) ? expanded : resolve(cwd, expanded);
153
+ }
154
+ function platformDefaultDataDir(env, home, nodePlatform, useXdg = true) {
155
+ if (nodePlatform === "darwin") return join(home, "Library", "Application Support", "agentmemory");
156
+ if (nodePlatform === "win32") {
157
+ const appData = env["APPDATA"];
158
+ return appData ? join(appData, "agentmemory") : join(home, ".agentmemory");
159
+ }
160
+ const xdgDataHome = env["XDG_DATA_HOME"];
161
+ if (useXdg && xdgDataHome && isAbsolute(xdgDataHome)) return join(xdgDataHome, "agentmemory");
162
+ return join(home, ".local", "share", "agentmemory");
163
+ }
164
+ function nearestGitParent(pathValue) {
165
+ let current = pathValue;
166
+ while (true) {
167
+ if (existsSync(join(current, ".git"))) return current;
168
+ const parent = dirname(current);
169
+ if (parent === current) return void 0;
170
+ current = parent;
171
+ }
172
+ }
173
+ function isWithin(parent, child) {
174
+ const pathFromParent = relative(parent, child);
175
+ return pathFromParent === "" || pathFromParent !== ".." && !pathFromParent.startsWith(`..${sep}`) && !isAbsolute(pathFromParent);
176
+ }
177
+ function resolveDataDir(options = {}) {
178
+ const args = options.args ?? process.argv.slice(2);
179
+ const env = options.env ?? process.env;
180
+ const cwd = options.cwd ?? process.cwd();
181
+ const home = options.home ?? homedir();
182
+ const nodePlatform = options.platform ?? platform();
183
+ const parsedInstance = parseInt(argValue(args, "--instance") ?? "0", 10);
184
+ const instance = parsedInstance > 0 && parsedInstance <= 50 ? parsedInstance : 0;
185
+ const forInstance = (dataDir) => instance ? join(dataDir, `instance-${instance}`) : dataDir;
186
+ const flagValue = argValue(args, "--data-dir");
187
+ if (flagValue) return {
188
+ dataDir: forInstance(absoluteDataDir(flagValue, cwd, home)),
189
+ source: "flag"
190
+ };
191
+ const envValue = env["AGENTMEMORY_DATA_DIR"];
192
+ if (envValue) return {
193
+ dataDir: forInstance(absoluteDataDir(envValue, cwd, home)),
194
+ source: "env"
195
+ };
196
+ const legacyDir = resolve(cwd, "data");
197
+ const hasLegacyStore = existsSync(join(legacyDir, "state_store.db")) || existsSync(join(legacyDir, "iii-config.yaml"));
198
+ if (instance === 0 && hasLegacyStore) return {
199
+ dataDir: legacyDir,
200
+ source: "default"
201
+ };
202
+ const defaultDir = platformDefaultDataDir(env, home, nodePlatform);
203
+ const gitParent = nearestGitParent(cwd);
204
+ if (gitParent && isWithin(gitParent, defaultDir)) {
205
+ const relocated = platformDefaultDataDir(env, home, nodePlatform, false);
206
+ if (relocated !== defaultDir) return {
207
+ dataDir: forInstance(relocated),
208
+ source: "default",
209
+ relocatedFrom: defaultDir
210
+ };
211
+ }
212
+ return {
213
+ dataDir: forInstance(defaultDir),
214
+ source: "default"
215
+ };
216
+ }
217
+ //#endregion
218
+ //#region src/functions/privacy.ts
219
+ const PRIVATE_TAG_RE = /<private>[\s\S]*?<\/private>/gi;
220
+ const SECRET_PATTERN_SOURCES = [
221
+ /(?:api[_-]?key|secret|token|password|credential|auth)[\s]*[=:]\s*["']?[A-Za-z0-9_\-/.+]{20,}["']?/gi,
222
+ /Bearer\s+[A-Za-z0-9._\-+/=]{20,}/gi,
223
+ /sk-proj-[A-Za-z0-9\-_]{20,}/g,
224
+ /(?:sk|pk|rk|ak)-[A-Za-z0-9][A-Za-z0-9\-_]{19,}/g,
225
+ /sk-ant-[A-Za-z0-9\-_]{20,}/g,
226
+ /gh[pus]_[A-Za-z0-9]{36,}/g,
227
+ /github_pat_[A-Za-z0-9_]{22,}/g,
228
+ /xoxb-[A-Za-z0-9\-]+/g,
229
+ /AKIA[0-9A-Z]{16}/g,
230
+ /AIza[A-Za-z0-9\-_]{35}/g,
231
+ /eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
232
+ /npm_[A-Za-z0-9]{36}/g,
233
+ /glpat-[A-Za-z0-9\-_]{20,}/g,
234
+ /dop_v1_[A-Za-z0-9]{64}/g
235
+ ];
236
+ const PRIVATE_KEY_BLOCK_RE = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----|$)/g;
237
+ const URL_CREDENTIALS_RE = /\b([a-z][a-z0-9+.-]*:\/\/)[^\s/?#@:"'<>]*:[^\s/?#@"'<>]+@/gi;
238
+ function stripPrivateData(input) {
239
+ let result = input.replace(PRIVATE_TAG_RE, "[REDACTED]");
240
+ result = result.replace(new RegExp(PRIVATE_KEY_BLOCK_RE.source, PRIVATE_KEY_BLOCK_RE.flags), "[REDACTED_SECRET]");
241
+ result = result.replace(new RegExp(URL_CREDENTIALS_RE.source, URL_CREDENTIALS_RE.flags), "$1[REDACTED_SECRET]@");
242
+ for (const source of SECRET_PATTERN_SOURCES) {
243
+ const pattern = new RegExp(source.source, source.flags);
244
+ result = result.replace(pattern, "[REDACTED_SECRET]");
245
+ }
246
+ return result;
247
+ }
248
+ //#endregion
249
+ //#region src/capture/spool.ts
250
+ const DEFAULT_MAX_BYTES = 5 * 1024 * 1024;
251
+ const MIN_MAX_BYTES = 64 * 1024;
252
+ const DEFAULT_MAX_AGE_HOURS = 168;
253
+ const LOCK_STALE_MS = 1e4;
254
+ const DRAIN_LOCK_STALE_MS = 12e4;
255
+ const ORPHAN_CLAIM_MS = 12e4;
256
+ const LOCK_WAIT_MS = 500;
257
+ const IMAGE_PLACEHOLDER = "[image dropped from capture spool]";
258
+ const BOOT_ID_RE = /^[A-Za-z0-9]{8,64}$/;
259
+ const SENT_FILE_RE = /^([A-Za-z0-9]{8,64})-(\d+)\.jsonl$/;
260
+ const SENT_BUCKET_MS = 1e3;
261
+ const MAX_DURABLE_AFTER_MS = 10 * 6e4;
262
+ function emptyStats() {
263
+ return {
264
+ spooled: 0,
265
+ dropped: 0,
266
+ droppedBytes: 0,
267
+ expired: 0,
268
+ delivered: 0,
269
+ duplicates: 0,
270
+ rejected: 0
271
+ };
272
+ }
273
+ function positiveInt(raw, fallback) {
274
+ if (!raw || !/^\d+$/.test(raw.trim())) return fallback;
275
+ const n = parseInt(raw.trim(), 10);
276
+ return n > 0 ? n : fallback;
277
+ }
278
+ function spoolPolicy(env = process.env) {
279
+ const maxBytes = Math.max(MIN_MAX_BYTES, positiveInt(env["AGENTMEMORY_CAPTURE_SPOOL_MAX_BYTES"], DEFAULT_MAX_BYTES));
280
+ const maxAgeHours = positiveInt(env["AGENTMEMORY_CAPTURE_SPOOL_MAX_AGE_HOURS"], DEFAULT_MAX_AGE_HOURS);
281
+ return {
282
+ enabled: env["AGENTMEMORY_CAPTURE_SPOOL"] !== "false",
283
+ maxBytes,
284
+ maxAgeMs: maxAgeHours * 36e5,
285
+ maxRecordBytes: Math.min(256 * 1024, Math.floor(maxBytes / 4))
286
+ };
287
+ }
288
+ function spoolDir(env = process.env) {
289
+ const explicit = env["AGENTMEMORY_CAPTURE_SPOOL_DIR"];
290
+ if (explicit && explicit.trim()) return resolve(explicit.trim());
291
+ return join(resolveDataDir({
292
+ args: [],
293
+ env
294
+ }).dataDir, "capture-spool");
295
+ }
296
+ const LOOPBACK = new Set([
297
+ "localhost",
298
+ "127.0.0.1",
299
+ "::1",
300
+ "[::1]",
301
+ "0.0.0.0"
302
+ ]);
303
+ function spoolTargetName(url) {
304
+ try {
305
+ const u = new URL(url);
306
+ return `${LOOPBACK.has(u.hostname) ? "local" : u.hostname.toLowerCase().replace(/[^a-z0-9.-]/g, "_")}-${u.port || (u.protocol === "https:" ? "443" : "80")}`;
307
+ } catch {
308
+ return "local-3111";
309
+ }
310
+ }
311
+ function spoolPaths(url, dir = spoolDir()) {
312
+ const name = spoolTargetName(url);
313
+ return {
314
+ dir,
315
+ name,
316
+ file: join(dir, `${name}.jsonl`),
317
+ lock: join(dir, `${name}.lock`),
318
+ drainLock: join(dir, `${name}.drain.lock`),
319
+ stats: join(dir, `${name}.stats.json`)
320
+ };
321
+ }
322
+ function ensureDir(dir) {
323
+ mkdirSync(dir, {
324
+ recursive: true,
325
+ mode: 448
326
+ });
327
+ try {
328
+ chmodSync(dir, 448);
329
+ } catch {}
330
+ }
331
+ function sleepSync(ms) {
332
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
333
+ }
334
+ function tryLock(path, staleMs) {
335
+ try {
336
+ const fd = openSync(path, "wx", 384);
337
+ writeSync(fd, `${process.pid}\n`);
338
+ closeSync(fd);
339
+ return true;
340
+ } catch (err) {
341
+ if (err.code !== "EEXIST") return false;
342
+ try {
343
+ if (Date.now() - statSync(path).mtimeMs > staleMs) unlinkSync(path);
344
+ } catch {}
345
+ return false;
346
+ }
347
+ }
348
+ function releaseLock(path) {
349
+ try {
350
+ unlinkSync(path);
351
+ } catch {}
352
+ }
353
+ function withLock(path, fn, waitMs = LOCK_WAIT_MS) {
354
+ const deadline = Date.now() + waitMs;
355
+ let locked = tryLock(path, LOCK_STALE_MS);
356
+ while (!locked && Date.now() < deadline) {
357
+ sleepSync(5);
358
+ locked = tryLock(path, LOCK_STALE_MS);
359
+ }
360
+ try {
361
+ return fn(locked);
362
+ } finally {
363
+ if (locked) releaseLock(path);
364
+ }
365
+ }
366
+ function readSpoolStats(paths) {
367
+ try {
368
+ const parsed = JSON.parse(readFileSync(paths.stats, "utf-8"));
369
+ return {
370
+ ...emptyStats(),
371
+ ...parsed
372
+ };
373
+ } catch {
374
+ return emptyStats();
375
+ }
376
+ }
377
+ function writeStats(paths, patch) {
378
+ try {
379
+ const stats = readSpoolStats(paths);
380
+ patch(stats);
381
+ const tmp = `${paths.stats}.${process.pid}.tmp`;
382
+ writeFileSync(tmp, JSON.stringify(stats), { mode: 384 });
383
+ renameSync(tmp, paths.stats);
384
+ } catch {}
385
+ }
386
+ function fileSize(path) {
387
+ try {
388
+ return statSync(path).size;
389
+ } catch {
390
+ return 0;
391
+ }
392
+ }
393
+ function sanitizeBody(body) {
394
+ try {
395
+ return JSON.parse(stripPrivateData(JSON.stringify(body)));
396
+ } catch {
397
+ return body;
398
+ }
399
+ }
400
+ function withoutImage(body) {
401
+ const data = body["data"];
402
+ if (!data || typeof data !== "object" || Array.isArray(data)) return body;
403
+ const d = data;
404
+ if (d["image_data"] === void 0) return body;
405
+ return {
406
+ ...body,
407
+ data: {
408
+ ...d,
409
+ image_data: IMAGE_PLACEHOLDER
410
+ }
411
+ };
412
+ }
413
+ function parseLines(text) {
414
+ const records = [];
415
+ let corrupt = 0;
416
+ for (const line of text.split("\n")) {
417
+ if (!line.trim()) continue;
418
+ try {
419
+ const rec = JSON.parse(line);
420
+ if (rec && typeof rec.eventId === "string" && rec.body && typeof rec.body === "object") records.push(rec);
421
+ else corrupt++;
422
+ } catch {
423
+ corrupt++;
424
+ }
425
+ }
426
+ return {
427
+ records,
428
+ corrupt
429
+ };
430
+ }
431
+ function isExpired(rec, policy, now) {
432
+ const at = Date.parse(rec.spooledAt);
433
+ return Number.isFinite(at) && now - at > policy.maxAgeMs;
434
+ }
435
+ function serialize(records) {
436
+ return records.map((r) => JSON.stringify(r)).join("\n") + (records.length ? "\n" : "");
437
+ }
438
+ function rewriteLocked(paths, records) {
439
+ const tmp = `${paths.file}.${process.pid}.tmp`;
440
+ const fd = openSync(tmp, "w", 384);
441
+ try {
442
+ writeSync(fd, serialize(records));
443
+ fsyncSync(fd);
444
+ } finally {
445
+ closeSync(fd);
446
+ }
447
+ renameSync(tmp, paths.file);
448
+ }
449
+ function pruneExpiredLocked(paths, policy) {
450
+ if (!existsSync(paths.file)) return 0;
451
+ const { records } = parseLines(readFileSync(paths.file, "utf-8"));
452
+ const now = Date.now();
453
+ const kept = records.filter((r) => !isExpired(r, policy, now));
454
+ const expired = records.length - kept.length;
455
+ if (expired > 0) rewriteLocked(paths, kept);
456
+ return expired;
457
+ }
458
+ function appendSpool(url, eventId, body, reason, options = {}) {
459
+ const policy = options.policy ?? spoolPolicy();
460
+ if (!policy.enabled) return {
461
+ spooled: false,
462
+ dropped: "disabled"
463
+ };
464
+ const paths = spoolPaths(url, options.dir);
465
+ const note = (dropReason, bytes) => {
466
+ writeStats(paths, (s) => {
467
+ s.dropped++;
468
+ s.droppedBytes += bytes;
469
+ s.lastDropAt = (/* @__PURE__ */ new Date()).toISOString();
470
+ s.lastDropReason = dropReason;
471
+ });
472
+ return {
473
+ spooled: false,
474
+ dropped: dropReason
475
+ };
476
+ };
477
+ try {
478
+ ensureDir(paths.dir);
479
+ const record = {
480
+ v: 1,
481
+ eventId,
482
+ spooledAt: (/* @__PURE__ */ new Date()).toISOString(),
483
+ reason,
484
+ attempts: options.attempts ?? 0,
485
+ body: sanitizeBody(body)
486
+ };
487
+ let line = JSON.stringify(record) + "\n";
488
+ if (Buffer.byteLength(line) > policy.maxRecordBytes) {
489
+ record.body = withoutImage(record.body);
490
+ line = JSON.stringify(record) + "\n";
491
+ }
492
+ const bytes = Buffer.byteLength(line);
493
+ if (bytes > policy.maxRecordBytes) return note("too-large", bytes);
494
+ return withLock(paths.lock, (locked) => {
495
+ let expired = 0;
496
+ if (locked && fileSize(paths.file) + bytes > policy.maxBytes) expired = pruneExpiredLocked(paths, policy);
497
+ const over = fileSize(paths.file) + sentBytes(paths) + bytes - policy.maxBytes;
498
+ if (locked && over > 0) evictSent(paths, over);
499
+ if (fileSize(paths.file) + sentBytes(paths) + bytes > policy.maxBytes) {
500
+ if (expired) writeStats(paths, (s) => void (s.expired += expired));
501
+ return note("full", bytes);
502
+ }
503
+ const fd = openSync(paths.file, "a", 384);
504
+ try {
505
+ writeSync(fd, line);
506
+ fsyncSync(fd);
507
+ } finally {
508
+ closeSync(fd);
509
+ }
510
+ writeStats(paths, (s) => {
511
+ s.spooled++;
512
+ s.expired += expired;
513
+ s.lastSpooledAt = record.spooledAt;
514
+ s.lastSpoolReason = reason;
515
+ });
516
+ return { spooled: true };
517
+ });
518
+ } catch {
519
+ return {
520
+ spooled: false,
521
+ dropped: "error"
522
+ };
523
+ }
524
+ }
525
+ function listSent(paths) {
526
+ const segments = [];
527
+ let entries;
528
+ try {
529
+ entries = readdirSync(paths.dir);
530
+ } catch {
531
+ return segments;
532
+ }
533
+ const prefix = `${paths.name}.sent-`;
534
+ for (const entry of entries) {
535
+ if (!entry.startsWith(prefix)) continue;
536
+ const match = entry.slice(prefix.length).match(SENT_FILE_RE);
537
+ if (!match) continue;
538
+ const file = join(paths.dir, entry);
539
+ segments.push({
540
+ file,
541
+ bootId: match[1],
542
+ dueAt: Number(match[2]),
543
+ bytes: fileSize(file)
544
+ });
545
+ }
546
+ return segments;
547
+ }
548
+ function sentBytes(paths) {
549
+ return listSent(paths).reduce((n, s) => n + s.bytes, 0);
550
+ }
551
+ function evictSent(paths, need) {
552
+ let freed = 0;
553
+ for (const seg of listSent(paths).sort((a, b) => a.dueAt - b.dueAt)) {
554
+ if (freed >= need) return;
555
+ try {
556
+ unlinkSync(seg.file);
557
+ freed += seg.bytes;
558
+ } catch {}
559
+ }
560
+ }
561
+ function parseSentMark(body) {
562
+ if (!body || typeof body !== "object" || Array.isArray(body)) return null;
563
+ const bootId = body["bootId"];
564
+ const after = body["durableAfterMs"];
565
+ if (typeof bootId !== "string" || !BOOT_ID_RE.test(bootId)) return null;
566
+ if (typeof after !== "number" || !Number.isFinite(after) || after < 0) return null;
567
+ return {
568
+ bootId,
569
+ durableAfterMs: Math.min(Math.ceil(after), MAX_DURABLE_AFTER_MS)
570
+ };
571
+ }
572
+ function retainSent(url, eventId, body, mark, options = {}) {
573
+ const policy = options.policy ?? spoolPolicy();
574
+ if (!policy.enabled || !BOOT_ID_RE.test(mark.bootId)) return false;
575
+ const paths = spoolPaths(url, options.dir);
576
+ const now = options.now ?? Date.now();
577
+ try {
578
+ ensureDir(paths.dir);
579
+ const record = {
580
+ v: 1,
581
+ eventId,
582
+ spooledAt: new Date(now).toISOString(),
583
+ reason: "sent",
584
+ attempts: 0,
585
+ body: sanitizeBody(body),
586
+ bootId: mark.bootId
587
+ };
588
+ let line = JSON.stringify(record) + "\n";
589
+ if (Buffer.byteLength(line) > policy.maxRecordBytes) {
590
+ record.body = withoutImage(record.body);
591
+ line = JSON.stringify(record) + "\n";
592
+ }
593
+ const bytes = Buffer.byteLength(line);
594
+ if (bytes > policy.maxRecordBytes) return false;
595
+ const dueAt = Math.ceil((now + mark.durableAfterMs) / SENT_BUCKET_MS) * SENT_BUCKET_MS;
596
+ const file = join(paths.dir, `${paths.name}.sent-${mark.bootId}-${dueAt}.jsonl`);
597
+ return withLock(paths.lock, () => {
598
+ if (fileSize(paths.file) + sentBytes(paths) + bytes > policy.maxBytes) return false;
599
+ const fd = openSync(file, "a", 384);
600
+ try {
601
+ writeSync(fd, line);
602
+ } finally {
603
+ closeSync(fd);
604
+ }
605
+ return true;
606
+ });
607
+ } catch {
608
+ return false;
609
+ }
610
+ }
611
+ function reconcileSent(url, bootId, options = {}) {
612
+ const result = {
613
+ released: 0,
614
+ requeued: 0
615
+ };
616
+ if (!(options.policy ?? spoolPolicy()).enabled) return result;
617
+ const paths = spoolPaths(url, options.dir);
618
+ const now = options.now ?? Date.now();
619
+ for (const seg of listSent(paths)) {
620
+ if (seg.bootId === bootId) {
621
+ if (seg.dueAt > now) continue;
622
+ try {
623
+ unlinkSync(seg.file);
624
+ result.released++;
625
+ } catch {}
626
+ continue;
627
+ }
628
+ const target = join(paths.dir, `${paths.name}.draining-${process.pid}-${now}-${result.requeued}.jsonl`);
629
+ try {
630
+ renameSync(seg.file, target);
631
+ } catch {
632
+ continue;
633
+ }
634
+ try {
635
+ utimesSync(target, 0, 0);
636
+ } catch {}
637
+ result.requeued++;
638
+ }
639
+ return result;
640
+ }
641
+ function claimFiles(paths) {
642
+ const claimed = [];
643
+ try {
644
+ const prefix = `${paths.name}.draining-`;
645
+ for (const entry of readdirSync(paths.dir)) {
646
+ if (!entry.startsWith(prefix) || !entry.endsWith(".jsonl")) continue;
647
+ const full = join(paths.dir, entry);
648
+ try {
649
+ if (Date.now() - statSync(full).mtimeMs > ORPHAN_CLAIM_MS) claimed.push(full);
650
+ } catch {}
651
+ }
652
+ } catch {}
653
+ if (fileSize(paths.file) > 0) {
654
+ const target = join(paths.dir, `${paths.name}.draining-${process.pid}-${Date.now()}.jsonl`);
655
+ withLock(paths.lock, (locked) => {
656
+ if (!locked) return;
657
+ try {
658
+ renameSync(paths.file, target);
659
+ claimed.push(target);
660
+ } catch {}
661
+ });
662
+ }
663
+ return claimed;
664
+ }
665
+ function requeueLocked(paths, leftover) {
666
+ if (leftover.length === 0) return;
667
+ const existing = existsSync(paths.file) ? parseLines(readFileSync(paths.file, "utf-8")).records : [];
668
+ rewriteLocked(paths, [...leftover, ...existing]);
669
+ }
670
+ function requeueUnlocked(paths, leftover) {
671
+ if (leftover.length === 0) return;
672
+ const target = join(paths.dir, `${paths.name}.draining-${process.pid}-${Date.now()}-requeue.jsonl`);
673
+ const fd = openSync(target, "wx", 384);
674
+ try {
675
+ writeSync(fd, serialize(leftover));
676
+ fsyncSync(fd);
677
+ } finally {
678
+ closeSync(fd);
679
+ }
680
+ try {
681
+ utimesSync(target, 0, 0);
682
+ } catch {}
683
+ }
684
+ function spoolHasRecords(url, dir) {
685
+ return fileSize(spoolPaths(url, dir).file) > 0;
686
+ }
687
+ function drainInProgress(url, dir) {
688
+ const paths = spoolPaths(url, dir);
689
+ try {
690
+ return Date.now() - statSync(paths.drainLock).mtimeMs < DRAIN_LOCK_STALE_MS;
691
+ } catch {
692
+ return false;
693
+ }
694
+ }
695
+ async function drainSpool(url, send, options = {}) {
696
+ const policy = options.policy ?? spoolPolicy();
697
+ const result = {
698
+ claimed: 0,
699
+ delivered: 0,
700
+ duplicates: 0,
701
+ rejected: 0,
702
+ expired: 0,
703
+ corrupt: 0,
704
+ remaining: 0
705
+ };
706
+ const paths = spoolPaths(url, options.dir);
707
+ if (!existsSync(paths.dir)) return {
708
+ ...result,
709
+ skipped: "empty"
710
+ };
711
+ try {
712
+ ensureDir(paths.dir);
713
+ } catch {}
714
+ if (!tryLock(paths.drainLock, DRAIN_LOCK_STALE_MS)) return {
715
+ ...result,
716
+ skipped: "locked"
717
+ };
718
+ try {
719
+ const files = claimFiles(paths);
720
+ if (files.length === 0) return {
721
+ ...result,
722
+ skipped: "empty"
723
+ };
724
+ const records = [];
725
+ for (const file of files) try {
726
+ const parsed = parseLines(readFileSync(file, "utf-8"));
727
+ records.push(...parsed.records);
728
+ result.corrupt += parsed.corrupt;
729
+ } catch {}
730
+ result.claimed = records.length;
731
+ const seen = /* @__PURE__ */ new Set();
732
+ const now = Date.now();
733
+ const deadline = options.deadlineMs ? now + options.deadlineMs : Number.POSITIVE_INFINITY;
734
+ const maxRecords = options.maxRecords ?? Number.POSITIVE_INFINITY;
735
+ const leftover = [];
736
+ let stopped = false;
737
+ let processed = 0;
738
+ for (const rec of records) {
739
+ if (seen.has(rec.eventId)) {
740
+ result.duplicates++;
741
+ continue;
742
+ }
743
+ seen.add(rec.eventId);
744
+ if (isExpired(rec, policy, now)) {
745
+ result.expired++;
746
+ continue;
747
+ }
748
+ if (stopped || processed >= maxRecords || Date.now() > deadline) {
749
+ leftover.push(rec);
750
+ continue;
751
+ }
752
+ processed++;
753
+ let outcome;
754
+ try {
755
+ outcome = await send(rec);
756
+ } catch (err) {
757
+ outcome = "retry";
758
+ result.error = err instanceof Error ? err.message : String(err);
759
+ }
760
+ if (outcome === "delivered") result.delivered++;
761
+ else if (outcome === "duplicate") result.duplicates++;
762
+ else if (outcome === "rejected") result.rejected++;
763
+ else {
764
+ stopped = true;
765
+ leftover.push({
766
+ ...rec,
767
+ attempts: (rec.attempts ?? 0) + 1
768
+ });
769
+ }
770
+ }
771
+ result.remaining = leftover.length;
772
+ withLock(paths.lock, (locked) => locked ? requeueLocked(paths, leftover) : requeueUnlocked(paths, leftover), 2e3);
773
+ for (const file of files) try {
774
+ unlinkSync(file);
775
+ } catch {}
776
+ writeStats(paths, (s) => {
777
+ s.delivered += result.delivered;
778
+ s.duplicates += result.duplicates;
779
+ s.rejected += result.rejected;
780
+ s.expired += result.expired;
781
+ s.lastDrainAt = (/* @__PURE__ */ new Date()).toISOString();
782
+ s.lastDrainDelivered = result.delivered;
783
+ s.lastDrainDuplicates = result.duplicates;
784
+ s.lastDrainRejected = result.rejected;
785
+ s.lastDrainRemaining = result.remaining;
786
+ if (result.error) s.lastDrainError = result.error;
787
+ else delete s.lastDrainError;
788
+ });
789
+ return result;
790
+ } finally {
791
+ releaseLock(paths.drainLock);
792
+ }
793
+ }
794
+ //#endregion
795
+ //#region src/hooks/_capture.ts
796
+ const REST_URL = process.env["AGENTMEMORY_URL"] || "http://localhost:3111";
797
+ const SECRET = resolveClientSecret(REST_URL);
798
+ const DRAIN_CHILD_ENV = "AGENTMEMORY_CAPTURE_DRAIN_CHILD";
799
+ const DRAIN_MAX_RECORDS = 500;
800
+ const DRAIN_DEADLINE_MS = 2e4;
801
+ const DRAIN_REQUEST_TIMEOUT_MS = 5e3;
802
+ function authHeaders() {
803
+ const h = { "Content-Type": "application/json" };
804
+ if (SECRET) h["Authorization"] = `Bearer ${SECRET}`;
805
+ return h;
806
+ }
807
+ function withEventId(body, host, content, options = {}) {
808
+ const source = options.stable || hasHostIdentity(host) ? host : {
809
+ ...host,
810
+ timestamp: body.timestamp
811
+ };
812
+ return {
813
+ ...body,
814
+ eventId: deriveEventId(body.hookType, body.sessionId, source, content ?? body.data)
815
+ };
816
+ }
817
+ function classify(status) {
818
+ if (status >= 200 && status < 300) return status === 200 ? "duplicate" : "delivered";
819
+ if (status === 408 || status === 429 || status >= 500) return "retry";
820
+ return "rejected";
821
+ }
822
+ async function post(body, timeoutMs) {
823
+ const res = await fetch(`${REST_URL}/agentmemory/observe`, {
824
+ method: "POST",
825
+ headers: authHeaders(),
826
+ body: JSON.stringify(body),
827
+ signal: AbortSignal.timeout(timeoutMs)
828
+ });
829
+ const text = await res.text().catch(() => "");
830
+ const outcome = classify(res.status);
831
+ if (outcome !== "delivered" && outcome !== "duplicate") return {
832
+ outcome,
833
+ mark: null
834
+ };
835
+ try {
836
+ return {
837
+ outcome,
838
+ mark: parseSentMark(JSON.parse(text))
839
+ };
840
+ } catch {
841
+ return {
842
+ outcome,
843
+ mark: null
844
+ };
845
+ }
846
+ }
847
+ function keepUntilDurable(eventId, body, mark) {
848
+ const { requeued } = reconcileSent(REST_URL, mark.bootId);
849
+ retainSent(REST_URL, eventId, body, mark);
850
+ return requeued;
851
+ }
852
+ function startDrainChild() {
853
+ if (process.env[DRAIN_CHILD_ENV] === "1") return;
854
+ if (!process.argv[1] || drainInProgress(REST_URL)) return;
855
+ try {
856
+ const child = spawn(process.execPath, [process.argv[1]], {
857
+ detached: true,
858
+ stdio: "ignore",
859
+ windowsHide: true,
860
+ env: {
861
+ ...process.env,
862
+ [DRAIN_CHILD_ENV]: "1"
863
+ }
864
+ });
865
+ child.on("error", () => {});
866
+ child.unref();
867
+ } catch {}
868
+ }
869
+ async function captureObservation(body, timeoutMs) {
870
+ const eventId = body.eventId ?? deriveEventId(body.hookType, body.sessionId, null, body.data);
871
+ const payload = {
872
+ ...body,
873
+ eventId
874
+ };
875
+ let reason;
876
+ try {
877
+ const { outcome, mark } = await post(payload, timeoutMs);
878
+ if (outcome !== "retry") {
879
+ if ((mark ? keepUntilDurable(eventId, payload, mark) : 0) > 0 || spoolHasRecords(REST_URL)) startDrainChild();
880
+ return outcome;
881
+ }
882
+ reason = "server-error";
883
+ } catch (err) {
884
+ const name = err instanceof Error ? err.name : "";
885
+ reason = name === "TimeoutError" || name === "AbortError" ? "timeout" : "unreachable";
886
+ }
887
+ return appendSpool(REST_URL, eventId, payload, reason).spooled ? "spooled" : "dropped";
888
+ }
889
+ function isDrainChild() {
890
+ return process.env[DRAIN_CHILD_ENV] === "1";
891
+ }
892
+ async function runDrainChild() {
893
+ await drainSpool(REST_URL, async (record) => {
894
+ const { outcome, mark } = await post({
895
+ ...record.body,
896
+ eventId: record.eventId
897
+ }, DRAIN_REQUEST_TIMEOUT_MS);
898
+ if (mark) retainSent(REST_URL, record.eventId, record.body, mark);
899
+ return outcome;
900
+ }, {
901
+ maxRecords: DRAIN_MAX_RECORDS,
902
+ deadlineMs: DRAIN_DEADLINE_MS
903
+ }).catch(() => void 0);
904
+ }
905
+ //#endregion
906
+ export { REST_URL, authHeaders, captureObservation, isDrainChild, runDrainChild, withEventId };
907
+
908
+ //# sourceMappingURL=_capture.mjs.map