@agent-native/core 0.122.2 → 0.122.4
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/agent/run-loop-with-resume.ts +12 -0
- package/corpus/core/src/cli/index.ts +2 -1
- package/corpus/core/src/cli/mcp.ts +13 -3
- package/corpus/core/src/cli/skills-content/rewind-skill.ts +36 -4
- package/corpus/core/src/cli/skills.ts +250 -37
- package/corpus/core/src/cli/telemetry-routing.ts +57 -0
- package/corpus/core/src/cli/telemetry.ts +3 -3
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +182 -0
- package/corpus/core/src/integrations/a2a-continuations-store.ts +122 -12
- package/corpus/core/src/integrations/integration-campaign-recovery.ts +127 -0
- package/corpus/core/src/integrations/integration-campaigns-store.ts +1039 -0
- package/corpus/core/src/integrations/integration-durable-dispatch.ts +28 -3
- package/corpus/core/src/integrations/pending-tasks-retry-job.ts +8 -0
- package/corpus/core/src/integrations/plugin.ts +453 -35
- package/corpus/core/src/integrations/webhook-handler.ts +469 -11
- package/corpus/core/src/mcp/screen-memory-stdio.ts +21 -2
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +7 -3
- package/corpus/templates/content/app/components/editor/body-hydration.ts +10 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +1 -0
- package/corpus/templates/content/app/root.tsx +12 -1
- package/corpus/templates/content/changelog/2026-07-23-new-pages-open-immediately-while-slow-network-work-continues.md +6 -0
- package/corpus/templates/content/changelog/2026-07-25-database-preview-actions-open-reliably.md +6 -0
- package/corpus/templates/content/e2e/playwright.config.ts +1 -1
- package/dist/agent/run-loop-with-resume.d.ts +7 -1
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +7 -0
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/mcp.d.ts.map +1 -1
- package/dist/cli/mcp.js +12 -3
- package/dist/cli/mcp.js.map +1 -1
- package/dist/cli/skills-content/rewind-skill.d.ts +1 -1
- package/dist/cli/skills-content/rewind-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/rewind-skill.js +36 -4
- package/dist/cli/skills-content/rewind-skill.js.map +1 -1
- package/dist/cli/skills.d.ts +2 -0
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +191 -40
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/telemetry-routing.d.ts +2 -0
- package/dist/cli/telemetry-routing.d.ts.map +1 -0
- package/dist/cli/telemetry-routing.js +54 -0
- package/dist/cli/telemetry-routing.js.map +1 -0
- package/dist/cli/telemetry.js +3 -3
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +3 -3
- package/dist/integrations/a2a-continuation-processor.d.ts +14 -0
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +134 -1
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/a2a-continuations-store.d.ts +23 -0
- package/dist/integrations/a2a-continuations-store.d.ts.map +1 -1
- package/dist/integrations/a2a-continuations-store.js +99 -13
- package/dist/integrations/a2a-continuations-store.js.map +1 -1
- package/dist/integrations/integration-campaign-recovery.d.ts +16 -0
- package/dist/integrations/integration-campaign-recovery.d.ts.map +1 -0
- package/dist/integrations/integration-campaign-recovery.js +94 -0
- package/dist/integrations/integration-campaign-recovery.js.map +1 -0
- package/dist/integrations/integration-campaigns-store.d.ts +121 -0
- package/dist/integrations/integration-campaigns-store.d.ts.map +1 -0
- package/dist/integrations/integration-campaigns-store.js +784 -0
- package/dist/integrations/integration-campaigns-store.js.map +1 -0
- package/dist/integrations/integration-durable-dispatch.d.ts +3 -0
- package/dist/integrations/integration-durable-dispatch.d.ts.map +1 -1
- package/dist/integrations/integration-durable-dispatch.js +22 -3
- package/dist/integrations/integration-durable-dispatch.js.map +1 -1
- package/dist/integrations/pending-tasks-retry-job.d.ts.map +1 -1
- package/dist/integrations/pending-tasks-retry-job.js +6 -0
- package/dist/integrations/pending-tasks-retry-job.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +325 -18
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts +16 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +368 -13
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +2 -0
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -1
- package/dist/mcp/screen-memory-stdio.js +12 -2
- package/dist/mcp/screen-memory-stdio.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
- package/dist/provider-api/actions/provider-api.d.ts +8 -8
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/package.json +1 -1
- package/src/agent/run-loop-with-resume.ts +12 -0
- package/src/cli/index.ts +2 -1
- package/src/cli/mcp.ts +13 -3
- package/src/cli/skills-content/rewind-skill.ts +36 -4
- package/src/cli/skills.ts +250 -37
- package/src/cli/telemetry-routing.ts +57 -0
- package/src/cli/telemetry.ts +3 -3
- package/src/integrations/a2a-continuation-processor.ts +182 -0
- package/src/integrations/a2a-continuations-store.ts +122 -12
- package/src/integrations/integration-campaign-recovery.ts +127 -0
- package/src/integrations/integration-campaigns-store.ts +1039 -0
- package/src/integrations/integration-durable-dispatch.ts +28 -3
- package/src/integrations/pending-tasks-retry-job.ts +8 -0
- package/src/integrations/plugin.ts +453 -35
- package/src/integrations/webhook-handler.ts +469 -11
- package/src/mcp/screen-memory-stdio.ts +21 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-routing.d.ts","sourceRoot":"","sources":["../../src/cli/telemetry-routing.ts"],"names":[],"mappings":"AA4CA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,WAY5E"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const REWIND_SKILL_TARGETS = new Set([
|
|
2
|
+
"rewind",
|
|
3
|
+
"screen-memory",
|
|
4
|
+
"clips-rewind",
|
|
5
|
+
"agent-native-rewind",
|
|
6
|
+
]);
|
|
7
|
+
function isRewindSkillTarget(value) {
|
|
8
|
+
return REWIND_SKILL_TARGETS.has(value?.trim().toLowerCase() ?? "");
|
|
9
|
+
}
|
|
10
|
+
const SKILLS_VALUE_FLAGS = new Set([
|
|
11
|
+
"--client",
|
|
12
|
+
"--agent",
|
|
13
|
+
"-a",
|
|
14
|
+
"--scope",
|
|
15
|
+
"--cwd",
|
|
16
|
+
"--mcp-url",
|
|
17
|
+
"--mode",
|
|
18
|
+
]);
|
|
19
|
+
function explicitSkillTargets(args) {
|
|
20
|
+
const targets = [];
|
|
21
|
+
const start = args[0] === "add" ? 1 : 0;
|
|
22
|
+
for (let index = start; index < args.length; index++) {
|
|
23
|
+
const arg = args[index];
|
|
24
|
+
if (arg === "--skill" || arg === "-s") {
|
|
25
|
+
if (args[index + 1])
|
|
26
|
+
targets.push(args[++index]);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (arg.startsWith("--skill=")) {
|
|
30
|
+
targets.push(arg.slice("--skill=".length));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (SKILLS_VALUE_FLAGS.has(arg)) {
|
|
34
|
+
index++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (arg.startsWith("-"))
|
|
38
|
+
continue;
|
|
39
|
+
targets.push(arg);
|
|
40
|
+
}
|
|
41
|
+
return targets;
|
|
42
|
+
}
|
|
43
|
+
export function shouldTrackCliRun(command, args) {
|
|
44
|
+
if (command !== "skills")
|
|
45
|
+
return true;
|
|
46
|
+
if (["list", "status", "update", "help", "--help", "-h"].includes(args[0] ?? ""))
|
|
47
|
+
return true;
|
|
48
|
+
const targets = explicitSkillTargets(args);
|
|
49
|
+
if (targets.length === 0)
|
|
50
|
+
return false;
|
|
51
|
+
const explicitlyTargetsRewind = targets.some(isRewindSkillTarget);
|
|
52
|
+
return !explicitlyTargetsRewind;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=telemetry-routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-routing.js","sourceRoot":"","sources":["../../src/cli/telemetry-routing.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,QAAQ;IACR,eAAe;IACf,cAAc;IACd,qBAAqB;CACtB,CAAC,CAAC;AAEH,SAAS,mBAAmB,CAAC,KAAyB;IACpD,OAAO,oBAAoB,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,UAAU;IACV,SAAS;IACT,IAAI;IACJ,SAAS;IACT,OAAO;IACP,WAAW;IACX,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,oBAAoB,CAAC,IAAc;IAC1C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,KAAK,IAAI,KAAK,GAAG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AC,mBAAmB,CAAC,CAAC;IAClE,OAAO,CAAC,uBAAuB,CAAC;AAClC,CAAC","sourcesContent":["const REWIND_SKILL_TARGETS = new Set([\n \"rewind\",\n \"screen-memory\",\n \"clips-rewind\",\n \"agent-native-rewind\",\n]);\n\nfunction isRewindSkillTarget(value: string | undefined): boolean {\n return REWIND_SKILL_TARGETS.has(value?.trim().toLowerCase() ?? \"\");\n}\n\nconst SKILLS_VALUE_FLAGS = new Set([\n \"--client\",\n \"--agent\",\n \"-a\",\n \"--scope\",\n \"--cwd\",\n \"--mcp-url\",\n \"--mode\",\n]);\n\nfunction explicitSkillTargets(args: string[]): string[] {\n const targets: string[] = [];\n const start = args[0] === \"add\" ? 1 : 0;\n for (let index = start; index < args.length; index++) {\n const arg = args[index];\n if (arg === \"--skill\" || arg === \"-s\") {\n if (args[index + 1]) targets.push(args[++index]);\n continue;\n }\n if (arg.startsWith(\"--skill=\")) {\n targets.push(arg.slice(\"--skill=\".length));\n continue;\n }\n if (SKILLS_VALUE_FLAGS.has(arg)) {\n index++;\n continue;\n }\n if (arg.startsWith(\"-\")) continue;\n targets.push(arg);\n }\n return targets;\n}\n\nexport function shouldTrackCliRun(command: string | undefined, args: string[]) {\n if (command !== \"skills\") return true;\n if (\n [\"list\", \"status\", \"update\", \"help\", \"--help\", \"-h\"].includes(args[0] ?? \"\")\n )\n return true;\n\n const targets = explicitSkillTargets(args);\n if (targets.length === 0) return false;\n\n const explicitlyTargetsRewind = targets.some(isRewindSkillTarget);\n return !explicitlyTargetsRewind;\n}\n"]}
|
package/dist/cli/telemetry.js
CHANGED
|
@@ -152,7 +152,7 @@ export function createCliTelemetry(options) {
|
|
|
152
152
|
const publicKey = resolvePublicKey();
|
|
153
153
|
const disabled = telemetryDisabled() || !publicKey;
|
|
154
154
|
const endpoint = resolveEndpoint();
|
|
155
|
-
|
|
155
|
+
let installId = disabled ? "" : undefined;
|
|
156
156
|
const runId = crypto.randomUUID();
|
|
157
157
|
const inFlight = new Set();
|
|
158
158
|
const base = {
|
|
@@ -164,18 +164,18 @@ export function createCliTelemetry(options) {
|
|
|
164
164
|
ci: process.env.CI === "true",
|
|
165
165
|
interactive: options.interactive,
|
|
166
166
|
runId,
|
|
167
|
-
installId,
|
|
168
167
|
};
|
|
169
168
|
function track(event, properties) {
|
|
170
169
|
if (disabled)
|
|
171
170
|
return;
|
|
171
|
+
installId ??= resolveInstallId();
|
|
172
172
|
const body = JSON.stringify({
|
|
173
173
|
publicKey,
|
|
174
174
|
event,
|
|
175
175
|
anonymousId: installId,
|
|
176
176
|
sessionId: runId,
|
|
177
177
|
timestamp: new Date().toISOString(),
|
|
178
|
-
properties: { ...base, ...properties },
|
|
178
|
+
properties: { ...base, installId, ...properties },
|
|
179
179
|
});
|
|
180
180
|
const promise = fetch(endpoint, {
|
|
181
181
|
method: "POST",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/cli/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,gFAAgF;AAChF,+EAA+E;AAC/E,oEAAoE;AACpE,iFAAiF;AACjF,MAAM,mBAAmB,GACvB,uDAAuD,CAAC;AAC1D,MAAM,gBAAgB,GAAG,0CAA0C,CAAC;AACpE,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAuB9B,SAAS,gBAAgB;IACvB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,IAAI,EAAE,CAAC;IACtE,OAAO,OAAO,IAAI,mBAAmB,CAAC;AACxC,CAAC;AAED,SAAS,eAAe;IACtB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,IAAI,EAAE,CAAC;IACpE,O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AS;YACtB,SAAS,EAAE,KAAK;YAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,UAAU,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,EAAE;SACvC,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE;YAC9B,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;YAC/C,IAAI;YACJ,SAAS,EAAE,IAAI;SAChB,CAAC;aACC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;aACrB,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC1B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,KAAK,UAAU,KAAK;QAClB,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO;QAC5C,MAAM,OAAO,CAAC,IAAI,CAAC;YACjB,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;YACjC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAChE,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK;QACL,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CACxC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC;QACzC,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Best-effort install-funnel telemetry for the core CLI.\n *\n * Events are POSTed to the first-party Agent Native Analytics endpoint\n * (analytics.agent-native.com/track) using a PUBLIC, write-only key — the same\n * mechanism every agent-native app uses to report client-side events. Nothing\n * here ever blocks or throws into the install flow: sends are fire-and-forget\n * and `flush()` awaits any in-flight requests with a short cap before exit.\n *\n * Privacy: we report skill NAMES, client ids, scope, counts, platform, and the\n * CLI version — never file paths, repo names, cwd, skill sources, or anything\n * user-identifying. A random per-machine install id (unique installs) and a\n * per-invocation run id (step-by-step dropoff) are the only identifiers.\n *\n * Opt out with DO_NOT_TRACK=1 or AGENT_NATIVE_TELEMETRY_DISABLED=1.\n */\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\n// Public, write-only analytics key. Safe to embed (revocable from the Analytics\n// settings UI). Override with AGENT_NATIVE_ANALYTICS_PUBLIC_KEY for testing or\n// to point telemetry at a different first-party analytics instance.\n// guard:allow-public-key -- first-party analytics write key is public by design.\nconst EMBEDDED_PUBLIC_KEY =\n \"anpk_dc523e34b99bc34d76e82d94c46593544e4a8509a4bfc93c\";\nconst DEFAULT_ENDPOINT = \"https://analytics.agent-native.com/track\";\nconst FLUSH_TIMEOUT_MS = 1500;\n\nexport interface CliTelemetryOptions {\n /** Stable identifier for the emitting CLI, e.g. \"skills-installer\". */\n cli: string;\n cliVersion: string;\n command: string;\n interactive: boolean;\n}\n\nexport interface CliTelemetry {\n track(event: string, properties?: Record<string, unknown>): void;\n captureException(error: unknown, context?: CliExceptionContext): void;\n flush(): Promise<void>;\n}\n\nexport interface CliExceptionContext {\n handled?: boolean;\n level?: \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n tags?: Record<string, string | number | boolean | null | undefined>;\n extra?: Record<string, unknown>;\n}\n\nfunction resolvePublicKey(): string {\n const fromEnv = process.env.AGENT_NATIVE_ANALYTICS_PUBLIC_KEY?.trim();\n return fromEnv || EMBEDDED_PUBLIC_KEY;\n}\n\nfunction resolveEndpoint(): string {\n const fromEnv = process.env.AGENT_NATIVE_ANALYTICS_ENDPOINT?.trim();\n return (fromEnv || DEFAULT_ENDPOINT).replace(/\\/+$/, \"\");\n}\n\nfunction telemetryDisabled(): boolean {\n return (\n process.env.DO_NOT_TRACK === \"1\" ||\n process.env.AGENT_NATIVE_TELEMETRY_DISABLED === \"1\" ||\n process.env.NODE_ENV === \"test\" ||\n typeof fetch !== \"function\"\n );\n}\n\nconst MAX_EXCEPTION_MESSAGE_LENGTH = 1000;\nconst MAX_EXCEPTION_STACK_LENGTH = 8000;\nconst MAX_EXCEPTION_TAGS = 30;\nconst MAX_EXCEPTION_EXTRA_KEYS = 30;\nconst MAX_EXCEPTION_VALUE_LENGTH = 1000;\nconst SECRET_RE = /\\b(?:bearer|basic)\\s+[^\\s]+/gi;\nconst SECRET_KEY_RE =\n /(?:authorization|cookie|set[-_]?cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|credential)/i;\n\nfunction redactExceptionText(value: string): string {\n return value\n .replace(SECRET_RE, (match) => `${match.split(/\\s+/, 1)[0]} <redacted>`)\n .replace(\n /([A-Za-z0-9_$.-]*(?:authorization|cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|credential)[A-Za-z0-9_$.-]*\\s*[:=]\\s*)([^\\s,;}]+)/gi,\n \"$1<redacted>\",\n );\n}\n\nfunction boundedExceptionText(value: unknown, max: number): string {\n const text =\n typeof value === \"string\" ? value : String(value ?? \"Unknown error\");\n const safe = redactExceptionText(text);\n return safe.length > max ? safe.slice(0, max) : safe;\n}\n\nfunction safeExceptionValue(value: unknown, depth = 2): unknown {\n if (\n value == null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\"\n ) {\n return value;\n }\n if (typeof value === \"string\") {\n return boundedExceptionText(value, MAX_EXCEPTION_VALUE_LENGTH);\n }\n if (depth <= 0)\n return boundedExceptionText(value, MAX_EXCEPTION_VALUE_LENGTH);\n if (Array.isArray(value)) {\n return value\n .slice(0, 20)\n .map((item) => safeExceptionValue(item, depth - 1));\n }\n if (typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(value)) {\n if (Object.keys(out).length >= MAX_EXCEPTION_EXTRA_KEYS) break;\n const safeKey = boundedExceptionText(key, 100);\n out[safeKey] = SECRET_KEY_RE.test(safeKey)\n ? \"<redacted>\"\n : safeExceptionValue(child, depth - 1);\n }\n return out;\n }\n return boundedExceptionText(value, MAX_EXCEPTION_VALUE_LENGTH);\n}\n\nfunction captureException(\n error: unknown,\n context: CliExceptionContext,\n trackEvent: (event: string, properties?: Record<string, unknown>) => void,\n): void {\n const exception =\n error instanceof Error\n ? {\n type: boundedExceptionText(error.name || \"Error\", 200),\n message: boundedExceptionText(\n error.message || error.name || \"Error\",\n MAX_EXCEPTION_MESSAGE_LENGTH,\n ),\n stack: error.stack\n ? boundedExceptionText(error.stack, MAX_EXCEPTION_STACK_LENGTH)\n : undefined,\n }\n : {\n type: \"Error\",\n message: boundedExceptionText(error, MAX_EXCEPTION_MESSAGE_LENGTH),\n stack: undefined,\n };\n const tags: Record<string, string> = {};\n for (const [key, value] of Object.entries(context.tags ?? {})) {\n if (Object.keys(tags).length >= MAX_EXCEPTION_TAGS || value == null) break;\n const safeKey = boundedExceptionText(key, 100);\n tags[safeKey] = SECRET_KEY_RE.test(safeKey)\n ? \"<redacted>\"\n : boundedExceptionText(value, 200);\n }\n const extra = safeExceptionValue(context.extra);\n trackEvent(\"$exception\", {\n app: \"agent-native-cli\",\n template: \"cli\",\n runtime: \"cli\",\n source: \"cli\",\n exceptionType: exception.type,\n exceptionMessage: exception.message,\n ...(exception.stack ? { exceptionStack: exception.stack } : {}),\n handled: context.handled ?? false,\n level: context.level ?? \"error\",\n occurredAt: new Date().toISOString(),\n ...(Object.keys(tags).length ? { exceptionTags: tags } : {}),\n ...(extra && typeof extra === \"object\" ? { exceptionExtra: extra } : {}),\n });\n}\n\n/**\n * Read (or lazily create) a stable per-machine install id, shared across both\n * skills CLIs so one developer counts once. Best-effort: an unwritable home\n * directory just yields an ephemeral id for this run.\n */\nfunction resolveInstallId(): string {\n try {\n const dir = path.join(os.homedir(), \".agent-native\");\n const file = path.join(dir, \"installation-id\");\n const existing = fs.existsSync(file)\n ? fs.readFileSync(file, \"utf8\").trim()\n : \"\";\n if (existing) return existing;\n const id = crypto.randomUUID();\n fs.mkdirSync(dir, { recursive: true });\n fs.writeFileSync(file, `${id}\\n`, \"utf8\");\n return id;\n } catch {\n return crypto.randomUUID();\n }\n}\n\nexport function createCliTelemetry(options: CliTelemetryOptions): CliTelemetry {\n const publicKey = resolvePublicKey();\n const disabled = telemetryDisabled() || !publicKey;\n const endpoint = resolveEndpoint();\n const installId = disabled ? \"\" : resolveInstallId();\n const runId = crypto.randomUUID();\n const inFlight = new Set<Promise<void>>();\n\n const base = {\n cli: options.cli,\n cliVersion: options.cliVersion,\n command: options.command,\n node: process.version,\n platform: process.platform,\n ci: process.env.CI === \"true\",\n interactive: options.interactive,\n runId,\n installId,\n };\n\n function track(event: string, properties?: Record<string, unknown>): void {\n if (disabled) return;\n const body = JSON.stringify({\n publicKey,\n event,\n anonymousId: installId,\n sessionId: runId,\n timestamp: new Date().toISOString(),\n properties: { ...base, ...properties },\n });\n const promise = fetch(endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body,\n keepalive: true,\n })\n .then(() => undefined)\n .catch(() => undefined);\n inFlight.add(promise);\n void promise.finally(() => inFlight.delete(promise));\n }\n\n async function flush(): Promise<void> {\n if (disabled || inFlight.size === 0) return;\n await Promise.race([\n Promise.allSettled([...inFlight]),\n new Promise((resolve) => setTimeout(resolve, FLUSH_TIMEOUT_MS)),\n ]);\n }\n\n return {\n track,\n captureException: (error, context = {}) =>\n captureException(error, context, track),\n flush,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../src/cli/telemetry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,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OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;YACjC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAChE,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK;QACL,gBAAgB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,EAAE,CACxC,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC;QACzC,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Best-effort install-funnel telemetry for the core CLI.\n *\n * Events are POSTed to the first-party Agent Native Analytics endpoint\n * (analytics.agent-native.com/track) using a PUBLIC, write-only key — the same\n * mechanism every agent-native app uses to report client-side events. Nothing\n * here ever blocks or throws into the install flow: sends are fire-and-forget\n * and `flush()` awaits any in-flight requests with a short cap before exit.\n *\n * Privacy: we report skill NAMES, client ids, scope, counts, platform, and the\n * CLI version — never file paths, repo names, cwd, skill sources, or anything\n * user-identifying. A random per-machine install id (unique installs) and a\n * per-invocation run id (step-by-step dropoff) are the only identifiers.\n *\n * Opt out with DO_NOT_TRACK=1 or AGENT_NATIVE_TELEMETRY_DISABLED=1.\n */\nimport crypto from \"node:crypto\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\n// Public, write-only analytics key. Safe to embed (revocable from the Analytics\n// settings UI). Override with AGENT_NATIVE_ANALYTICS_PUBLIC_KEY for testing or\n// to point telemetry at a different first-party analytics instance.\n// guard:allow-public-key -- first-party analytics write key is public by design.\nconst EMBEDDED_PUBLIC_KEY =\n \"anpk_dc523e34b99bc34d76e82d94c46593544e4a8509a4bfc93c\";\nconst DEFAULT_ENDPOINT = \"https://analytics.agent-native.com/track\";\nconst FLUSH_TIMEOUT_MS = 1500;\n\nexport interface CliTelemetryOptions {\n /** Stable identifier for the emitting CLI, e.g. \"skills-installer\". */\n cli: string;\n cliVersion: string;\n command: string;\n interactive: boolean;\n}\n\nexport interface CliTelemetry {\n track(event: string, properties?: Record<string, unknown>): void;\n captureException(error: unknown, context?: CliExceptionContext): void;\n flush(): Promise<void>;\n}\n\nexport interface CliExceptionContext {\n handled?: boolean;\n level?: \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n tags?: Record<string, string | number | boolean | null | undefined>;\n extra?: Record<string, unknown>;\n}\n\nfunction resolvePublicKey(): string {\n const fromEnv = process.env.AGENT_NATIVE_ANALYTICS_PUBLIC_KEY?.trim();\n return fromEnv || EMBEDDED_PUBLIC_KEY;\n}\n\nfunction resolveEndpoint(): string {\n const fromEnv = process.env.AGENT_NATIVE_ANALYTICS_ENDPOINT?.trim();\n return (fromEnv || DEFAULT_ENDPOINT).replace(/\\/+$/, \"\");\n}\n\nfunction telemetryDisabled(): boolean {\n return (\n process.env.DO_NOT_TRACK === \"1\" ||\n process.env.AGENT_NATIVE_TELEMETRY_DISABLED === \"1\" ||\n process.env.NODE_ENV === \"test\" ||\n typeof fetch !== \"function\"\n );\n}\n\nconst MAX_EXCEPTION_MESSAGE_LENGTH = 1000;\nconst MAX_EXCEPTION_STACK_LENGTH = 8000;\nconst MAX_EXCEPTION_TAGS = 30;\nconst MAX_EXCEPTION_EXTRA_KEYS = 30;\nconst MAX_EXCEPTION_VALUE_LENGTH = 1000;\nconst SECRET_RE = /\\b(?:bearer|basic)\\s+[^\\s]+/gi;\nconst SECRET_KEY_RE =\n /(?:authorization|cookie|set[-_]?cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|credential)/i;\n\nfunction redactExceptionText(value: string): string {\n return value\n .replace(SECRET_RE, (match) => `${match.split(/\\s+/, 1)[0]} <redacted>`)\n .replace(\n /([A-Za-z0-9_$.-]*(?:authorization|cookie|token|secret|password|passwd|pwd|api[-_]?key|apikey|credential)[A-Za-z0-9_$.-]*\\s*[:=]\\s*)([^\\s,;}]+)/gi,\n \"$1<redacted>\",\n );\n}\n\nfunction boundedExceptionText(value: unknown, max: number): string {\n const text =\n typeof value === \"string\" ? value : String(value ?? \"Unknown error\");\n const safe = redactExceptionText(text);\n return safe.length > max ? safe.slice(0, max) : safe;\n}\n\nfunction safeExceptionValue(value: unknown, depth = 2): unknown {\n if (\n value == null ||\n typeof value === \"boolean\" ||\n typeof value === \"number\"\n ) {\n return value;\n }\n if (typeof value === \"string\") {\n return boundedExceptionText(value, MAX_EXCEPTION_VALUE_LENGTH);\n }\n if (depth <= 0)\n return boundedExceptionText(value, MAX_EXCEPTION_VALUE_LENGTH);\n if (Array.isArray(value)) {\n return value\n .slice(0, 20)\n .map((item) => safeExceptionValue(item, depth - 1));\n }\n if (typeof value === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [key, child] of Object.entries(value)) {\n if (Object.keys(out).length >= MAX_EXCEPTION_EXTRA_KEYS) break;\n const safeKey = boundedExceptionText(key, 100);\n out[safeKey] = SECRET_KEY_RE.test(safeKey)\n ? \"<redacted>\"\n : safeExceptionValue(child, depth - 1);\n }\n return out;\n }\n return boundedExceptionText(value, MAX_EXCEPTION_VALUE_LENGTH);\n}\n\nfunction captureException(\n error: unknown,\n context: CliExceptionContext,\n trackEvent: (event: string, properties?: Record<string, unknown>) => void,\n): void {\n const exception =\n error instanceof Error\n ? {\n type: boundedExceptionText(error.name || \"Error\", 200),\n message: boundedExceptionText(\n error.message || error.name || \"Error\",\n MAX_EXCEPTION_MESSAGE_LENGTH,\n ),\n stack: error.stack\n ? boundedExceptionText(error.stack, MAX_EXCEPTION_STACK_LENGTH)\n : undefined,\n }\n : {\n type: \"Error\",\n message: boundedExceptionText(error, MAX_EXCEPTION_MESSAGE_LENGTH),\n stack: undefined,\n };\n const tags: Record<string, string> = {};\n for (const [key, value] of Object.entries(context.tags ?? {})) {\n if (Object.keys(tags).length >= MAX_EXCEPTION_TAGS || value == null) break;\n const safeKey = boundedExceptionText(key, 100);\n tags[safeKey] = SECRET_KEY_RE.test(safeKey)\n ? \"<redacted>\"\n : boundedExceptionText(value, 200);\n }\n const extra = safeExceptionValue(context.extra);\n trackEvent(\"$exception\", {\n app: \"agent-native-cli\",\n template: \"cli\",\n runtime: \"cli\",\n source: \"cli\",\n exceptionType: exception.type,\n exceptionMessage: exception.message,\n ...(exception.stack ? { exceptionStack: exception.stack } : {}),\n handled: context.handled ?? false,\n level: context.level ?? \"error\",\n occurredAt: new Date().toISOString(),\n ...(Object.keys(tags).length ? { exceptionTags: tags } : {}),\n ...(extra && typeof extra === \"object\" ? { exceptionExtra: extra } : {}),\n });\n}\n\n/**\n * Read (or lazily create) a stable per-machine install id, shared across both\n * skills CLIs so one developer counts once. Best-effort: an unwritable home\n * directory just yields an ephemeral id for this run.\n */\nfunction resolveInstallId(): string {\n try {\n const dir = path.join(os.homedir(), \".agent-native\");\n const file = path.join(dir, \"installation-id\");\n const existing = fs.existsSync(file)\n ? fs.readFileSync(file, \"utf8\").trim()\n : \"\";\n if (existing) return existing;\n const id = crypto.randomUUID();\n fs.mkdirSync(dir, { recursive: true });\n fs.writeFileSync(file, `${id}\\n`, \"utf8\");\n return id;\n } catch {\n return crypto.randomUUID();\n }\n}\n\nexport function createCliTelemetry(options: CliTelemetryOptions): CliTelemetry {\n const publicKey = resolvePublicKey();\n const disabled = telemetryDisabled() || !publicKey;\n const endpoint = resolveEndpoint();\n let installId: string | undefined = disabled ? \"\" : undefined;\n const runId = crypto.randomUUID();\n const inFlight = new Set<Promise<void>>();\n\n const base = {\n cli: options.cli,\n cliVersion: options.cliVersion,\n command: options.command,\n node: process.version,\n platform: process.platform,\n ci: process.env.CI === \"true\",\n interactive: options.interactive,\n runId,\n };\n\n function track(event: string, properties?: Record<string, unknown>): void {\n if (disabled) return;\n installId ??= resolveInstallId();\n const body = JSON.stringify({\n publicKey,\n event,\n anonymousId: installId,\n sessionId: runId,\n timestamp: new Date().toISOString(),\n properties: { ...base, installId, ...properties },\n });\n const promise = fetch(endpoint, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body,\n keepalive: true,\n })\n .then(() => undefined)\n .catch(() => undefined);\n inFlight.add(promise);\n void promise.finally(() => inFlight.delete(promise));\n }\n\n async function flush(): Promise<void> {\n if (disabled || inFlight.size === 0) return;\n await Promise.race([\n Promise.allSettled([...inFlight]),\n new Promise((resolve) => setTimeout(resolve, FLUSH_TIMEOUT_MS)),\n ]);\n }\n\n return {\n track,\n captureException: (error, context = {}) =>\n captureException(error, context, track),\n flush,\n };\n}\n"]}
|
|
@@ -62,11 +62,11 @@ export declare const postAwareness: import("h3").EventHandlerWithFetch<import("h
|
|
|
62
62
|
error: string;
|
|
63
63
|
states?: undefined;
|
|
64
64
|
} | {
|
|
65
|
-
error?: undefined;
|
|
66
65
|
states: {
|
|
67
66
|
clientId: number;
|
|
68
67
|
state: string;
|
|
69
68
|
}[];
|
|
69
|
+
error?: undefined;
|
|
70
70
|
}>>;
|
|
71
71
|
/**
|
|
72
72
|
* GET /_agent-native/collab/:docId/users
|
|
@@ -77,10 +77,10 @@ export declare const getActiveUsers: import("h3").EventHandlerWithFetch<import("
|
|
|
77
77
|
error: string;
|
|
78
78
|
users?: undefined;
|
|
79
79
|
} | {
|
|
80
|
-
error?: undefined;
|
|
81
80
|
users: {
|
|
82
81
|
clientId: number;
|
|
83
82
|
lastSeen: number;
|
|
84
83
|
}[];
|
|
84
|
+
error?: undefined;
|
|
85
85
|
}>>;
|
|
86
86
|
//# sourceMappingURL=awareness.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"awareness.d.ts","sourceRoot":"","sources":["../../src/collab/awareness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAgB3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAOD,eAAO,MAAM,sBAAsB,EAAG,kBAA2B,C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AS,GAChC,IAAI,CAON;AAED,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,KAAK,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAClD,KAAK,CAAC,EAAE,cAAc,GACrB,IAAI,CAgBN;AAoBD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,SAAS,GAAE,MAAmB,GAC7B,IAAI,CAON;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE1E;AAiBD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAO1E;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,IAAI,CAOnE;AAkCD;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa;;;;;kBAwDa,MAAM;eAAS,MAAM;;;GAoB1D,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;kBAYM,MAAM;kBAAY,MAAM;;;GAMvD,CAAC"}
|
package/dist/collab/routes.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
|
|
|
26
26
|
* Body: { update: string (base64), requestSource?: string }
|
|
27
27
|
*/
|
|
28
28
|
export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
29
|
-
ok?: undefined;
|
|
30
29
|
error: string;
|
|
30
|
+
ok?: undefined;
|
|
31
31
|
} | {
|
|
32
32
|
error?: undefined;
|
|
33
33
|
ok: boolean;
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* Body: { json: any, fieldName?: string, type?: "map"|"array", requestSource?: string }
|
|
14
14
|
*/
|
|
15
15
|
export declare const postCollabJson: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
|
|
16
|
-
ok?: undefined;
|
|
17
16
|
error: string;
|
|
17
|
+
ok?: undefined;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
|
@@ -3,26 +3,26 @@ declare const _default: import("../../action.js").ActionDefinition<{
|
|
|
3
3
|
url?: string;
|
|
4
4
|
filename?: string;
|
|
5
5
|
}, {
|
|
6
|
+
id?: undefined;
|
|
6
7
|
error: string;
|
|
7
8
|
configured?: undefined;
|
|
8
9
|
connectPath?: undefined;
|
|
9
10
|
url?: undefined;
|
|
10
|
-
id?: undefined;
|
|
11
11
|
provider?: undefined;
|
|
12
12
|
} | {
|
|
13
|
+
id?: undefined;
|
|
13
14
|
error: string;
|
|
14
15
|
configured: boolean;
|
|
15
16
|
connectPath: string;
|
|
16
17
|
url?: undefined;
|
|
17
|
-
id?: undefined;
|
|
18
18
|
provider?: undefined;
|
|
19
19
|
} | {
|
|
20
|
-
error?: undefined;
|
|
21
20
|
configured?: undefined;
|
|
22
21
|
connectPath?: undefined;
|
|
23
22
|
url: string;
|
|
24
23
|
id: string;
|
|
25
24
|
provider: string;
|
|
25
|
+
error?: undefined;
|
|
26
26
|
}>;
|
|
27
27
|
export default _default;
|
|
28
28
|
//# sourceMappingURL=upload-image.d.ts.map
|
|
@@ -7,4 +7,18 @@ export declare function processDueA2AContinuations(options: {
|
|
|
7
7
|
adapters: Map<string, PlatformAdapter>;
|
|
8
8
|
limit?: number;
|
|
9
9
|
}): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Durable scheduler wake-up only: make a bounded set of due/stale rows
|
|
12
|
+
* eligible, then invoke their normal processors. It never polls remote A2A
|
|
13
|
+
* tasks or runs a mutation itself, keeping the scheduled route within its
|
|
14
|
+
* short execution budget. Duplicate wake-ups are safe because each processor
|
|
15
|
+
* still takes the store's atomic claim before it can progress or deliver.
|
|
16
|
+
*/
|
|
17
|
+
export declare function recoverDueA2AContinuations(options?: {
|
|
18
|
+
limit?: number;
|
|
19
|
+
webhookBaseUrl?: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
dispatched: number;
|
|
22
|
+
failed: number;
|
|
23
|
+
}>;
|
|
10
24
|
//# sourceMappingURL=a2a-continuation-processor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-continuation-processor.d.ts","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"a2a-continuation-processor.d.ts","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"AA8CA,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,YAAY,CAAC;AAkBpB,wBAAsB,uBAAuB,CAC3C,cAAc,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAqDf;AAmBD,wBAAsB,0BAA0B,CAC9C,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,GAClD,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE;IACxD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB;AAED;;;;;;GAMG;AACH,wBAAsB,0BAA0B,CAAC,OAAO,CAAC,EAAE;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAuClD"}
|
|
@@ -5,8 +5,11 @@ import { extractThreadMeta } from "../agent/thread-data-builder.js";
|
|
|
5
5
|
import { getThread, updateThreadData } from "../chat-threads/store.js";
|
|
6
6
|
import { withConfiguredAppBasePath } from "../server/app-base-path.js";
|
|
7
7
|
import { FRAMEWORK_ROUTE_PREFIX } from "../server/core-routes-plugin.js";
|
|
8
|
-
import { claimA2AContinuation, claimA2AContinuationDelivery, claimDueA2AContinuations, completeA2AContinuation, failA2AContinuation, getA2AContinuation, rescheduleA2AContinuation, } from "./a2a-continuations-store.js";
|
|
8
|
+
import { claimA2AContinuation, claimA2AContinuationDelivery, claimDueA2AContinuations, completeA2AContinuation, failA2AContinuationsForIntegrationTask, failA2AContinuation, getA2AContinuation, hasActiveA2AContinuationsForIntegrationTask, listRecoverableA2AIntegrationTasks, recoverDueA2AContinuationIds, rescheduleA2AContinuation, } from "./a2a-continuations-store.js";
|
|
9
|
+
import { completeIntegrationCampaignTaskAfterA2A, failDisabledIntegrationCampaignTask, getIntegrationCampaignForTask, } from "./integration-campaigns-store.js";
|
|
10
|
+
import { dispatchPendingIntegrationTask, isIntegrationDurableDispatchEnabledForTask, } from "./integration-durable-dispatch.js";
|
|
9
11
|
import { signInternalToken } from "./internal-token.js";
|
|
12
|
+
import { getNextPendingTaskForThread, getPendingTask, } from "./pending-tasks-store.js";
|
|
10
13
|
import { getThreadMapping } from "./thread-mapping-store.js";
|
|
11
14
|
const PROCESSOR_PATH = `${FRAMEWORK_ROUTE_PREFIX}/integrations/process-a2a-continuation`;
|
|
12
15
|
const TERMINAL_STATES = new Set(["completed", "failed", "canceled"]);
|
|
@@ -90,7 +93,52 @@ export async function processDueA2AContinuations(options) {
|
|
|
90
93
|
await processClaimedContinuation(continuation, options).catch((err) => console.error(`[integrations] A2A continuation ${continuation.id} failed:`, err));
|
|
91
94
|
}
|
|
92
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Durable scheduler wake-up only: make a bounded set of due/stale rows
|
|
98
|
+
* eligible, then invoke their normal processors. It never polls remote A2A
|
|
99
|
+
* tasks or runs a mutation itself, keeping the scheduled route within its
|
|
100
|
+
* short execution budget. Duplicate wake-ups are safe because each processor
|
|
101
|
+
* still takes the store's atomic claim before it can progress or deliver.
|
|
102
|
+
*/
|
|
103
|
+
export async function recoverDueA2AContinuations(options) {
|
|
104
|
+
const limit = options?.limit ?? 5;
|
|
105
|
+
const candidateTasks = await listRecoverableA2AIntegrationTasks(200);
|
|
106
|
+
const eligibleTaskIds = [];
|
|
107
|
+
for (const task of candidateTasks) {
|
|
108
|
+
const enabled = isIntegrationDurableDispatchEnabledForTask({
|
|
109
|
+
platform: task.platform,
|
|
110
|
+
externalThreadId: task.externalThreadId,
|
|
111
|
+
platformContext: task.dispatchScope
|
|
112
|
+
? { channelId: task.dispatchScope }
|
|
113
|
+
: undefined,
|
|
114
|
+
});
|
|
115
|
+
if (enabled) {
|
|
116
|
+
eligibleTaskIds.push(task.id);
|
|
117
|
+
if (eligibleTaskIds.length >= limit)
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
await failDisabledDurableA2ATask(task);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const ids = await recoverDueA2AContinuationIds(limit, eligibleTaskIds);
|
|
125
|
+
let dispatched = 0;
|
|
126
|
+
let failed = 0;
|
|
127
|
+
await Promise.all(ids.map(async (id) => {
|
|
128
|
+
try {
|
|
129
|
+
await dispatchA2AContinuation(id, options?.webhookBaseUrl);
|
|
130
|
+
dispatched += 1;
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
failed += 1;
|
|
134
|
+
console.error(`[integrations] Failed to recover A2A continuation ${id}:`, err);
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
return { dispatched, failed };
|
|
138
|
+
}
|
|
93
139
|
async function processClaimedContinuation(continuation, options) {
|
|
140
|
+
if (!(await durableContinuationScopeStillEnabled(continuation)))
|
|
141
|
+
return;
|
|
94
142
|
const adapter = options.adapters.get(continuation.platform);
|
|
95
143
|
if (!adapter) {
|
|
96
144
|
await failA2AContinuation(continuation.id, `Unknown platform: ${continuation.platform}`);
|
|
@@ -172,6 +220,52 @@ async function processClaimedContinuation(continuation, options) {
|
|
|
172
220
|
}
|
|
173
221
|
await deliverAndCompleteA2AContinuation(continuation, adapter, text, progress);
|
|
174
222
|
}
|
|
223
|
+
async function durableContinuationScopeStillEnabled(continuation) {
|
|
224
|
+
const campaign = await getIntegrationCampaignForTask(continuation.integrationTaskId);
|
|
225
|
+
if (!campaign)
|
|
226
|
+
return true;
|
|
227
|
+
if (campaign.status === "completed" || campaign.status === "failed") {
|
|
228
|
+
await failA2AContinuation(continuation.id, "Owning integration campaign is already terminal");
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
const task = await getPendingTask(continuation.integrationTaskId);
|
|
232
|
+
const enabled = task?.status === "processing" &&
|
|
233
|
+
isIntegrationDurableDispatchEnabledForTask({
|
|
234
|
+
platform: task.platform,
|
|
235
|
+
externalThreadId: task.externalThreadId,
|
|
236
|
+
platformContext: task.dispatchScope
|
|
237
|
+
? { channelId: task.dispatchScope }
|
|
238
|
+
: undefined,
|
|
239
|
+
});
|
|
240
|
+
if (enabled)
|
|
241
|
+
return true;
|
|
242
|
+
await failDisabledDurableA2ATask({
|
|
243
|
+
id: continuation.integrationTaskId,
|
|
244
|
+
platform: task?.platform ?? continuation.platform,
|
|
245
|
+
externalThreadId: task?.externalThreadId ?? continuation.externalThreadId,
|
|
246
|
+
dispatchScope: task?.dispatchScope ?? null,
|
|
247
|
+
status: task?.status ?? "missing",
|
|
248
|
+
});
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
async function failDisabledDurableA2ATask(task) {
|
|
252
|
+
const message = "Durable integration campaign was disabled for this scope";
|
|
253
|
+
await failA2AContinuationsForIntegrationTask(task.id, message);
|
|
254
|
+
await failDisabledIntegrationCampaignTask(task.id, message);
|
|
255
|
+
const nextTask = await getNextPendingTaskForThread(task.platform, task.externalThreadId);
|
|
256
|
+
if (nextTask) {
|
|
257
|
+
await dispatchPendingIntegrationTask({
|
|
258
|
+
taskId: nextTask.id,
|
|
259
|
+
task: {
|
|
260
|
+
platform: task.platform,
|
|
261
|
+
externalThreadId: task.externalThreadId,
|
|
262
|
+
platformContext: nextTask.dispatchScope
|
|
263
|
+
? { channelId: nextTask.dispatchScope }
|
|
264
|
+
: undefined,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
175
269
|
async function resumeA2AContinuationProgress(continuation, adapter) {
|
|
176
270
|
if (!continuation.progressRef || !adapter.resumeRunProgress)
|
|
177
271
|
return null;
|
|
@@ -223,6 +317,8 @@ async function waitForContinuationDue(continuationId) {
|
|
|
223
317
|
return true;
|
|
224
318
|
}
|
|
225
319
|
async function notifyAndFailA2AContinuation(continuation, adapter, reason, progress = null) {
|
|
320
|
+
if (!(await durableContinuationScopeStillEnabled(continuation)))
|
|
321
|
+
return;
|
|
226
322
|
const deliveryContinuation = await claimA2AContinuationDelivery(continuation.id);
|
|
227
323
|
if (!deliveryContinuation)
|
|
228
324
|
return;
|
|
@@ -233,10 +329,20 @@ async function notifyAndFailA2AContinuation(continuation, adapter, reason, progr
|
|
|
233
329
|
}
|
|
234
330
|
catch (err) {
|
|
235
331
|
console.error(`[integrations] Failed to notify ${deliveryContinuation.platform} about failed A2A continuation ${deliveryContinuation.id}:`, err);
|
|
332
|
+
if (deliveryContinuation.attempts >= MAX_ATTEMPTS) {
|
|
333
|
+
await failA2AContinuation(deliveryContinuation.id, reason);
|
|
334
|
+
await completeParentCampaignAfterTerminalA2A(deliveryContinuation);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
await rescheduleAndRedispatchA2AContinuation(deliveryContinuation.id);
|
|
338
|
+
return;
|
|
236
339
|
}
|
|
237
340
|
await failA2AContinuation(deliveryContinuation.id, reason);
|
|
341
|
+
await completeParentCampaignAfterTerminalA2A(deliveryContinuation);
|
|
238
342
|
}
|
|
239
343
|
async function deliverAndCompleteA2AContinuation(continuation, adapter, text, progress = null) {
|
|
344
|
+
if (!(await durableContinuationScopeStillEnabled(continuation)))
|
|
345
|
+
return;
|
|
240
346
|
const deliveryContinuation = await claimA2AContinuationDelivery(continuation.id);
|
|
241
347
|
if (!deliveryContinuation)
|
|
242
348
|
return;
|
|
@@ -358,6 +464,7 @@ async function completeAfterSuccessfulDelivery(continuation) {
|
|
|
358
464
|
for (let attempt = 0; attempt < COMPLETE_AFTER_DELIVERY_ATTEMPTS; attempt++) {
|
|
359
465
|
try {
|
|
360
466
|
await completeA2AContinuation(continuation.id);
|
|
467
|
+
await completeParentCampaignAfterTerminalA2A(continuation);
|
|
361
468
|
return;
|
|
362
469
|
}
|
|
363
470
|
catch (err) {
|
|
@@ -367,6 +474,32 @@ async function completeAfterSuccessfulDelivery(continuation) {
|
|
|
367
474
|
console.error(`[integrations] ${continuation.platform} accepted A2A continuation ${continuation.id}, ` +
|
|
368
475
|
"but marking it completed failed. Leaving it in delivering for stale-delivery recovery.", lastError);
|
|
369
476
|
}
|
|
477
|
+
async function completeParentCampaignAfterTerminalA2A(continuation) {
|
|
478
|
+
const campaign = await getIntegrationCampaignForTask(continuation.integrationTaskId);
|
|
479
|
+
if (!campaign)
|
|
480
|
+
return;
|
|
481
|
+
if (await hasActiveA2AContinuationsForIntegrationTask(continuation.integrationTaskId)) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const completed = await completeIntegrationCampaignTaskAfterA2A(continuation.integrationTaskId);
|
|
485
|
+
if (!completed)
|
|
486
|
+
return;
|
|
487
|
+
const nextTask = await getNextPendingTaskForThread(continuation.platform, continuation.externalThreadId);
|
|
488
|
+
if (!nextTask)
|
|
489
|
+
return;
|
|
490
|
+
await dispatchPendingIntegrationTask({
|
|
491
|
+
taskId: nextTask.id,
|
|
492
|
+
task: {
|
|
493
|
+
platform: continuation.platform,
|
|
494
|
+
externalThreadId: continuation.externalThreadId,
|
|
495
|
+
platformContext: nextTask.dispatchScope
|
|
496
|
+
? { channelId: nextTask.dispatchScope }
|
|
497
|
+
: undefined,
|
|
498
|
+
},
|
|
499
|
+
}).catch((err) => {
|
|
500
|
+
console.error(`[integrations] Failed to wake successor ${nextTask.id} after A2A parent completion:`, err);
|
|
501
|
+
});
|
|
502
|
+
}
|
|
370
503
|
function formatContinuationFailureMessage(continuation, reason) {
|
|
371
504
|
const explicitCode = extractFailureCode(reason);
|
|
372
505
|
const diagnostics = formatContinuationFailureDiagnostics(continuation, reason);
|