@agent-native/core 0.94.2 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +14 -0
- package/corpus/core/docs/content/pr-visual-recap.mdx +20 -12
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/artifact-response.ts +154 -1
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +3 -0
- package/corpus/core/src/agent/engine/registry.ts +6 -1
- package/corpus/core/src/agent/engine/types.ts +2 -0
- package/corpus/core/src/cli/code-agent-executor.ts +61 -1
- package/corpus/core/src/cli/pr-visual-recap-workflow.ts +1 -1
- package/corpus/core/src/cli/recap.ts +262 -25
- package/corpus/core/src/client/settings/UsageSection.tsx +26 -5
- package/corpus/core/src/index.ts +2 -0
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +118 -31
- package/corpus/core/src/integrations/a2a-continuations-store.ts +165 -7
- package/corpus/core/src/integrations/adapters/slack.ts +77 -7
- package/corpus/core/src/integrations/types.ts +30 -0
- package/corpus/core/src/integrations/webhook-handler.ts +54 -18
- package/corpus/core/src/scripts/call-agent.ts +1 -0
- package/corpus/core/src/server/request-context.ts +2 -0
- package/corpus/core/src/usage/store.ts +82 -20
- package/corpus/templates/plan/actions/record-recap-usage-cost.ts +49 -0
- package/corpus/templates/plan/actions/record-recap-usage.ts +15 -22
- package/dist/a2a/artifact-response.d.ts.map +1 -1
- package/dist/a2a/artifact-response.js +127 -1
- package/dist/a2a/artifact-response.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +3 -0
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +2 -0
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/engine/types.d.ts +2 -0
- package/dist/agent/engine/types.d.ts.map +1 -1
- package/dist/agent/engine/types.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts +2 -0
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +52 -3
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts +22 -2
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +199 -22
- package/dist/cli/recap.js.map +1 -1
- package/dist/client/settings/UsageSection.d.ts.map +1 -1
- package/dist/client/settings/UsageSection.js +12 -3
- package/dist/client/settings/UsageSection.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +76 -21
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/a2a-continuations-store.d.ts +4 -1
- package/dist/integrations/a2a-continuations-store.d.ts.map +1 -1
- package/dist/integrations/a2a-continuations-store.js +130 -6
- package/dist/integrations/a2a-continuations-store.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +56 -7
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/types.d.ts +25 -0
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/webhook-handler.js +54 -16
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +1 -0
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/request-context.d.ts +2 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/usage/store.d.ts +21 -0
- package/dist/usage/store.d.ts.map +1 -1
- package/dist/usage/store.js +54 -19
- package/dist/usage/store.js.map +1 -1
- package/docs/content/pr-visual-recap.mdx +20 -12
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsageSection.d.ts","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UsageSection.d.ts","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":"AAkNA,wBAAgB,YAAY,gCA8L3B"}
|
|
@@ -44,6 +44,13 @@ function formatSpend(cents, billing) {
|
|
|
44
44
|
return `${cents.toFixed(2)}¢`;
|
|
45
45
|
return `$${(cents / 100).toFixed(2)}`;
|
|
46
46
|
}
|
|
47
|
+
function formatAggregateCost(cost, billing) {
|
|
48
|
+
if (cost.status === "known")
|
|
49
|
+
return formatSpend(cost.knownCents, billing);
|
|
50
|
+
if (cost.status === "unavailable")
|
|
51
|
+
return "Unknown";
|
|
52
|
+
return `${formatSpend(cost.knownCents, billing)} + ${cost.unavailableCalls} unpriced`;
|
|
53
|
+
}
|
|
47
54
|
function formatTokens(n) {
|
|
48
55
|
if (n >= 1_000_000)
|
|
49
56
|
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
@@ -56,7 +63,7 @@ function BucketBars({ buckets, emptyMessage, billing, }) {
|
|
|
56
63
|
return (_jsx("p", { className: "text-[10px] text-muted-foreground py-1.5", children: emptyMessage }));
|
|
57
64
|
}
|
|
58
65
|
const max = Math.max(...buckets.map((b) => displayAmountFromCostCents(b.cents, billing)), 0.0001);
|
|
59
|
-
return (_jsx("div", { className: "space-y-1", children: buckets.map((b) => (_jsxs("div", { className: "text-[10px]", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 mb-0.5", children: [_jsx("span", { className: "truncate text-foreground", title: b.key || "(none)", children: b.key || "(none)" }), _jsxs("span", { className: "shrink-0 text-muted-foreground tabular-nums", children: [
|
|
66
|
+
return (_jsx("div", { className: "space-y-1", children: buckets.map((b) => (_jsxs("div", { className: "text-[10px]", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 mb-0.5", children: [_jsx("span", { className: "truncate text-foreground", title: b.key || "(none)", children: b.key || "(none)" }), _jsxs("span", { className: "shrink-0 text-muted-foreground tabular-nums", children: [formatAggregateCost(b.cost, billing), _jsxs("span", { className: "ms-1 opacity-60", children: ["\u00B7 ", formatTokens(b.inputTokens + b.outputTokens), " tok"] })] })] }), _jsx("div", { className: "h-1 rounded-full bg-accent/40 overflow-hidden", children: _jsx("div", { className: "h-full bg-foreground/70", style: {
|
|
60
67
|
width: `${(displayAmountFromCostCents(b.cents, billing) / max) * 100}%`,
|
|
61
68
|
} }) })] }, b.key))) }));
|
|
62
69
|
}
|
|
@@ -66,7 +73,7 @@ function DailySparkline({ days, billing, }) {
|
|
|
66
73
|
const max = Math.max(...days.map((d) => displayAmountFromCostCents(d.cents, billing)), 0.0001);
|
|
67
74
|
return (_jsx("div", { className: "flex items-end gap-[2px] h-8 pt-2", children: days.map((d) => (_jsx("div", { className: "flex-1 bg-foreground/60 rounded-sm min-h-[1px]", style: {
|
|
68
75
|
height: `${Math.max(2, (displayAmountFromCostCents(d.cents, billing) / max) * 100)}%`,
|
|
69
|
-
}, title: `${d.date}: ${
|
|
76
|
+
}, title: `${d.date}: ${formatAggregateCost(d.cost, billing)} (${d.calls} calls)` }, d.date))) }));
|
|
70
77
|
}
|
|
71
78
|
export function UsageSection() {
|
|
72
79
|
const [days, setDays] = useState(30);
|
|
@@ -99,6 +106,8 @@ export function UsageSection() {
|
|
|
99
106
|
? "bg-accent text-foreground"
|
|
100
107
|
: "text-muted-foreground hover:text-foreground"}`, children: r.label }, r.value))) }), _jsx("button", { onClick: () => load(days), className: "flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground", disabled: loading, children: loading ? (_jsx(IconLoader2, { size: 11, className: "animate-spin" })) : (_jsx(IconRefresh, { size: 11 })) })] }), error && _jsx("p", { className: "text-[10px] text-red-500", children: error }), data && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "rounded-md border border-border px-2.5 py-2", children: [_jsxs("div", { className: "flex items-baseline justify-between", children: [_jsxs("div", { children: [_jsx("div", { className: "text-[10px] text-muted-foreground", children: billing.unit === "builder-credits"
|
|
101
108
|
? "Builder.io credit spend"
|
|
102
|
-
: "Total spend" }), _jsx("div", { className: "text-[18px] font-semibold tabular-nums", children:
|
|
109
|
+
: "Total spend" }), _jsx("div", { className: "text-[18px] font-semibold tabular-nums", children: formatAggregateCost(data.totalCost, billing) })] }), _jsxs("div", { className: "text-end", children: [_jsxs("div", { className: "text-[10px] text-muted-foreground", children: [data.totalCalls, " calls"] }), _jsxs("div", { className: "text-[10px] text-muted-foreground", children: [formatTokens(data.totalInputTokens), " in \u00B7", " ", formatTokens(data.totalOutputTokens), " out"] }), data.totalCacheReadTokens > 0 && (_jsxs("div", { className: "text-[10px] text-green-500/80", children: [formatTokens(data.totalCacheReadTokens), " cached"] }))] })] }), _jsx(DailySparkline, { days: data.byDay, billing: billing })] }), _jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-medium text-foreground mb-1", children: "By label" }), _jsx(BucketBars, { buckets: data.byLabel, emptyMessage: "No labeled calls yet.", billing: billing })] }), _jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-medium text-foreground mb-1", children: "By model" }), _jsx(BucketBars, { buckets: data.byModel, emptyMessage: "No calls recorded.", billing: billing })] }), data.byApp.filter((b) => b.key).length > 1 && (_jsxs("div", { children: [_jsx("div", { className: "text-[10px] font-medium text-foreground mb-1", children: "By app" }), _jsx(BucketBars, { buckets: data.byApp, emptyMessage: "", billing: billing })] })), data.recent.length > 0 && (_jsxs("details", { children: [_jsxs("summary", { className: "text-[10px] font-medium text-foreground cursor-pointer select-none hover:text-foreground/80", children: ["Recent calls (", data.recent.length, ")"] }), _jsx("div", { className: "mt-1.5 max-h-48 overflow-y-auto space-y-0.5 rounded border border-border", children: data.recent.map((r) => (_jsxs("div", { className: "flex items-center justify-between gap-2 px-2 py-1 text-[10px] border-b border-border last:border-b-0", children: [_jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "truncate text-foreground", title: r.label, children: [r.label, r.app ? (_jsxs("span", { className: "text-muted-foreground", children: [" ", "\u00B7 ", r.app] })) : null] }), _jsxs("div", { className: "truncate text-muted-foreground", children: [new Date(r.createdAt).toLocaleString(), " \u00B7 ", r.model] })] }), _jsx("div", { className: "shrink-0 text-end tabular-nums text-muted-foreground", children: r.costSource === "unavailable"
|
|
110
|
+
? "Unknown"
|
|
111
|
+
: formatSpend(r.cents, billing) })] }, r.id))) })] })), billing.unit === "builder-credits" ? (_jsxs("p", { className: "text-[10px] text-muted-foreground", children: ["Builder.io credits are estimated from hard token cost, a", " ", billing.hardCostMarginMultiplier ?? 1.25, "x margin, and", " ", billing.creditsPerUsd ?? 20, " credits per dollar."] })) : (_jsx("p", { className: "text-[10px] text-muted-foreground", children: "Spend is estimated from published Anthropic pricing and your own recorded token counts. Cached input is priced at ~10% of regular input. Calls without provider pricing are marked unknown and excluded from known-cost subtotals." }))] }))] }));
|
|
103
112
|
}
|
|
104
113
|
//# sourceMappingURL=UsageSection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UsageSection.js","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;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C1D,OAAO,CAAC,aAAa,IAAI,EAAE,4BAC1B,CACL,CAAC,CAAC,CAAC,CACF,YAAG,SAAS,EAAC,mCAAmC,yJAI5C,CACL,IACA,CACJ,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { IconLoader2, IconRefresh } from \"@tabler/icons-react\";\nimport { useEffect, useState } from \"react\";\n\nimport { agentNativePath } from \"../api-path.js\";\n\ninterface UsageBucket {\n key: string;\n cents: number;\n calls: number;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n}\n\ninterface DailyBucket {\n date: string;\n cents: number;\n calls: number;\n}\n\ninterface UsageRecentEntry {\n id: number;\n createdAt: number;\n label: string;\n app: string;\n model: string;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n cents: number;\n}\n\ninterface UsageBillingMode {\n unit: \"usd\" | \"builder-credits\";\n label: string;\n shortLabel: string;\n source: \"estimated-provider-cost\" | \"builder-agent-credits\";\n hardCostMarginMultiplier?: number;\n creditsPerUsd?: number;\n}\n\ninterface UsageSummary {\n billing?: UsageBillingMode;\n totalCents: number;\n totalCalls: number;\n totalInputTokens: number;\n totalOutputTokens: number;\n totalCacheReadTokens: number;\n totalCacheWriteTokens: number;\n sinceMs: number;\n byLabel: UsageBucket[];\n byModel: UsageBucket[];\n byApp: UsageBucket[];\n byDay: DailyBucket[];\n recent: UsageRecentEntry[];\n}\n\nconst RANGES = [\n { value: 1, label: \"24h\" },\n { value: 7, label: \"7d\" },\n { value: 30, label: \"30d\" },\n { value: 90, label: \"90d\" },\n];\n\nconst USD_BILLING: UsageBillingMode = {\n unit: \"usd\",\n label: \"Estimated spend\",\n shortLabel: \"Cost\",\n source: \"estimated-provider-cost\",\n};\n\nfunction displayAmountFromCostCents(\n cents: number,\n billing: UsageBillingMode,\n): number {\n if (billing.unit !== \"builder-credits\") return cents;\n const margin = billing.hardCostMarginMultiplier ?? 1.25;\n const creditsPerUsd = billing.creditsPerUsd ?? 20;\n const credits = (cents / 100) * margin * creditsPerUsd;\n return credits <= 0 ? 0 : Math.ceil(credits * 1000) / 1000;\n}\n\nfunction formatCredits(credits: number): string {\n if (!Number.isFinite(credits) || credits === 0) return \"0 credits\";\n const maximumFractionDigits = credits < 1 ? 3 : credits < 10 ? 2 : 1;\n const value = credits.toLocaleString(undefined, {\n maximumFractionDigits,\n });\n return `${value} ${credits === 1 ? \"credit\" : \"credits\"}`;\n}\n\nfunction formatSpend(cents: number, billing: UsageBillingMode): string {\n if (billing.unit === \"builder-credits\") {\n return formatCredits(displayAmountFromCostCents(cents, billing));\n }\n // Sub-cent values (e.g. a single LLM call at $0.0045 = 0.45¢) — keep\n // three decimals so tiny calls don't round to 0.00¢. The prior impl\n // multiplied by 100 in this branch, overstating small costs 100×.\n if (cents < 1) return `${cents.toFixed(3)}¢`;\n if (cents < 100) return `${cents.toFixed(2)}¢`;\n return `$${(cents / 100).toFixed(2)}`;\n}\n\nfunction formatTokens(n: number): string {\n if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;\n if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;\n return String(n);\n}\n\nfunction BucketBars({\n buckets,\n emptyMessage,\n billing,\n}: {\n buckets: UsageBucket[];\n emptyMessage: string;\n billing: UsageBillingMode;\n}) {\n if (buckets.length === 0) {\n return (\n <p className=\"text-[10px] text-muted-foreground py-1.5\">{emptyMessage}</p>\n );\n }\n const max = Math.max(\n ...buckets.map((b) => displayAmountFromCostCents(b.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"space-y-1\">\n {buckets.map((b) => (\n <div key={b.key} className=\"text-[10px]\">\n <div className=\"flex items-center justify-between gap-2 mb-0.5\">\n <span\n className=\"truncate text-foreground\"\n title={b.key || \"(none)\"}\n >\n {b.key || \"(none)\"}\n </span>\n <span className=\"shrink-0 text-muted-foreground tabular-nums\">\n {formatSpend(b.cents, billing)}\n <span className=\"ms-1 opacity-60\">\n · {formatTokens(b.inputTokens + b.outputTokens)} tok\n </span>\n </span>\n </div>\n <div className=\"h-1 rounded-full bg-accent/40 overflow-hidden\">\n <div\n className=\"h-full bg-foreground/70\"\n style={{\n width: `${(displayAmountFromCostCents(b.cents, billing) / max) * 100}%`,\n }}\n />\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction DailySparkline({\n days,\n billing,\n}: {\n days: DailyBucket[];\n billing: UsageBillingMode;\n}) {\n if (days.length === 0) return null;\n const max = Math.max(\n ...days.map((d) => displayAmountFromCostCents(d.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"flex items-end gap-[2px] h-8 pt-2\">\n {days.map((d) => (\n <div\n key={d.date}\n className=\"flex-1 bg-foreground/60 rounded-sm min-h-[1px]\"\n style={{\n height: `${Math.max(\n 2,\n (displayAmountFromCostCents(d.cents, billing) / max) * 100,\n )}%`,\n }}\n title={`${d.date}: ${formatSpend(d.cents, billing)} (${d.calls} calls)`}\n />\n ))}\n </div>\n );\n}\n\nexport function UsageSection() {\n const [days, setDays] = useState(30);\n const [data, setData] = useState<UsageSummary | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const billing = data?.billing ?? USD_BILLING;\n\n const load = async (rangeDays: number) => {\n setLoading(true);\n setError(null);\n try {\n const res = await fetch(\n agentNativePath(`/_agent-native/usage?sinceDays=${rangeDays}`),\n );\n if (!res.ok) {\n throw new Error(`Failed (${res.status})`);\n }\n const json = (await res.json()) as UsageSummary;\n setData(json);\n } catch (err: any) {\n setError(err?.message || \"Failed to load usage\");\n } finally {\n setLoading(false);\n }\n };\n\n useEffect(() => {\n load(days);\n }, [days]);\n\n return (\n <div className=\"space-y-3\">\n {/* Range selector + refresh */}\n <div className=\"flex items-center justify-between\">\n <div className=\"flex gap-1 rounded-md border border-border p-0.5\">\n {RANGES.map((r) => (\n <button\n key={r.value}\n onClick={() => setDays(r.value)}\n className={`px-2 py-0.5 text-[10px] rounded ${\n days === r.value\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\"\n }`}\n >\n {r.label}\n </button>\n ))}\n </div>\n <button\n onClick={() => load(days)}\n className=\"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground\"\n disabled={loading}\n >\n {loading ? (\n <IconLoader2 size={11} className=\"animate-spin\" />\n ) : (\n <IconRefresh size={11} />\n )}\n </button>\n </div>\n\n {error && <p className=\"text-[10px] text-red-500\">{error}</p>}\n\n {data && (\n <>\n {/* Totals */}\n <div className=\"rounded-md border border-border px-2.5 py-2\">\n <div className=\"flex items-baseline justify-between\">\n <div>\n <div className=\"text-[10px] text-muted-foreground\">\n {billing.unit === \"builder-credits\"\n ? \"Builder.io credit spend\"\n : \"Total spend\"}\n </div>\n <div className=\"text-[18px] font-semibold tabular-nums\">\n {formatSpend(data.totalCents, billing)}\n </div>\n </div>\n <div className=\"text-end\">\n <div className=\"text-[10px] text-muted-foreground\">\n {data.totalCalls} calls\n </div>\n <div className=\"text-[10px] text-muted-foreground\">\n {formatTokens(data.totalInputTokens)} in ·{\" \"}\n {formatTokens(data.totalOutputTokens)} out\n </div>\n {data.totalCacheReadTokens > 0 && (\n <div className=\"text-[10px] text-green-500/80\">\n {formatTokens(data.totalCacheReadTokens)} cached\n </div>\n )}\n </div>\n </div>\n <DailySparkline days={data.byDay} billing={billing} />\n </div>\n\n {/* By label */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By label\n </div>\n <BucketBars\n buckets={data.byLabel}\n emptyMessage=\"No labeled calls yet.\"\n billing={billing}\n />\n </div>\n\n {/* By model */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By model\n </div>\n <BucketBars\n buckets={data.byModel}\n emptyMessage=\"No calls recorded.\"\n billing={billing}\n />\n </div>\n\n {/* By app — only show when multiple apps contribute */}\n {data.byApp.filter((b) => b.key).length > 1 && (\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By app\n </div>\n <BucketBars\n buckets={data.byApp}\n emptyMessage=\"\"\n billing={billing}\n />\n </div>\n )}\n\n {/* Recent calls */}\n {data.recent.length > 0 && (\n <details>\n <summary className=\"text-[10px] font-medium text-foreground cursor-pointer select-none hover:text-foreground/80\">\n Recent calls ({data.recent.length})\n </summary>\n <div className=\"mt-1.5 max-h-48 overflow-y-auto space-y-0.5 rounded border border-border\">\n {data.recent.map((r) => (\n <div\n key={r.id}\n className=\"flex items-center justify-between gap-2 px-2 py-1 text-[10px] border-b border-border last:border-b-0\"\n >\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-foreground\" title={r.label}>\n {r.label}\n {r.app ? (\n <span className=\"text-muted-foreground\">\n {\" \"}\n · {r.app}\n </span>\n ) : null}\n </div>\n <div className=\"truncate text-muted-foreground\">\n {new Date(r.createdAt).toLocaleString()} · {r.model}\n </div>\n </div>\n <div className=\"shrink-0 text-end tabular-nums text-muted-foreground\">\n {formatSpend(r.cents, billing)}\n </div>\n </div>\n ))}\n </div>\n </details>\n )}\n\n {billing.unit === \"builder-credits\" ? (\n <p className=\"text-[10px] text-muted-foreground\">\n Builder.io credits are estimated from hard token cost, a{\" \"}\n {billing.hardCostMarginMultiplier ?? 1.25}x margin, and{\" \"}\n {billing.creditsPerUsd ?? 20} credits per dollar.\n </p>\n ) : (\n <p className=\"text-[10px] text-muted-foreground\">\n Spend is estimated from published Anthropic pricing and your own\n recorded token counts. Cached input is priced at ~10% of regular\n input.\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UsageSection.js","sourceRoot":"","sources":["../../../src/client/settings/UsageSection.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAiEjD,MAAM,MAAM,GAAG;IACb,EAAE,KAAK,EAAE,C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SAAS,EAAC,sDAAsD,YAClE,CAAC,CAAC,UAAU,KAAK,aAAa;gDAC7B,CAAC,CAAC,SAAS;gDACX,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,GAC7B,KArBD,CAAC,CAAC,EAAE,CAsBL,CACP,CAAC,GACE,IACE,CACX,EAEA,OAAO,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,CACpC,aAAG,SAAS,EAAC,mCAAmC,yEACW,GAAG,EAC3D,OAAO,CAAC,wBAAwB,IAAI,IAAI,mBAAe,GAAG,EAC1D,OAAO,CAAC,aAAa,IAAI,EAAE,4BAC1B,CACL,CAAC,CAAC,CAAC,CACF,YAAG,SAAS,EAAC,mCAAmC,mPAK5C,CACL,IACA,CACJ,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { IconLoader2, IconRefresh } from \"@tabler/icons-react\";\nimport { useEffect, useState } from \"react\";\n\nimport { agentNativePath } from \"../api-path.js\";\n\ninterface UsageBucket {\n key: string;\n cents: number;\n cost: UsageCostAggregate;\n calls: number;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n}\n\ninterface DailyBucket {\n date: string;\n cents: number;\n cost: UsageCostAggregate;\n calls: number;\n}\n\ninterface UsageRecentEntry {\n id: number;\n createdAt: number;\n label: string;\n app: string;\n model: string;\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n cents: number;\n costSource: \"reported\" | \"estimated\" | \"unavailable\";\n}\n\ntype UsageCostAggregate =\n | { status: \"known\"; knownCents: number; unavailableCalls: 0 }\n | { status: \"partial\"; knownCents: number; unavailableCalls: number }\n | { status: \"unavailable\"; knownCents: 0; unavailableCalls: number };\n\ninterface UsageBillingMode {\n unit: \"usd\" | \"builder-credits\";\n label: string;\n shortLabel: string;\n source: \"estimated-provider-cost\" | \"builder-agent-credits\";\n hardCostMarginMultiplier?: number;\n creditsPerUsd?: number;\n}\n\ninterface UsageSummary {\n billing?: UsageBillingMode;\n totalCents: number;\n totalCost: UsageCostAggregate;\n totalCalls: number;\n totalInputTokens: number;\n totalOutputTokens: number;\n totalCacheReadTokens: number;\n totalCacheWriteTokens: number;\n sinceMs: number;\n byLabel: UsageBucket[];\n byModel: UsageBucket[];\n byApp: UsageBucket[];\n byDay: DailyBucket[];\n recent: UsageRecentEntry[];\n}\n\nconst RANGES = [\n { value: 1, label: \"24h\" },\n { value: 7, label: \"7d\" },\n { value: 30, label: \"30d\" },\n { value: 90, label: \"90d\" },\n];\n\nconst USD_BILLING: UsageBillingMode = {\n unit: \"usd\",\n label: \"Estimated spend\",\n shortLabel: \"Cost\",\n source: \"estimated-provider-cost\",\n};\n\nfunction displayAmountFromCostCents(\n cents: number,\n billing: UsageBillingMode,\n): number {\n if (billing.unit !== \"builder-credits\") return cents;\n const margin = billing.hardCostMarginMultiplier ?? 1.25;\n const creditsPerUsd = billing.creditsPerUsd ?? 20;\n const credits = (cents / 100) * margin * creditsPerUsd;\n return credits <= 0 ? 0 : Math.ceil(credits * 1000) / 1000;\n}\n\nfunction formatCredits(credits: number): string {\n if (!Number.isFinite(credits) || credits === 0) return \"0 credits\";\n const maximumFractionDigits = credits < 1 ? 3 : credits < 10 ? 2 : 1;\n const value = credits.toLocaleString(undefined, {\n maximumFractionDigits,\n });\n return `${value} ${credits === 1 ? \"credit\" : \"credits\"}`;\n}\n\nfunction formatSpend(cents: number, billing: UsageBillingMode): string {\n if (billing.unit === \"builder-credits\") {\n return formatCredits(displayAmountFromCostCents(cents, billing));\n }\n // Sub-cent values (e.g. a single LLM call at $0.0045 = 0.45¢) — keep\n // three decimals so tiny calls don't round to 0.00¢. The prior impl\n // multiplied by 100 in this branch, overstating small costs 100×.\n if (cents < 1) return `${cents.toFixed(3)}¢`;\n if (cents < 100) return `${cents.toFixed(2)}¢`;\n return `$${(cents / 100).toFixed(2)}`;\n}\n\nfunction formatAggregateCost(\n cost: UsageCostAggregate,\n billing: UsageBillingMode,\n): string {\n if (cost.status === \"known\") return formatSpend(cost.knownCents, billing);\n if (cost.status === \"unavailable\") return \"Unknown\";\n return `${formatSpend(cost.knownCents, billing)} + ${cost.unavailableCalls} unpriced`;\n}\n\nfunction formatTokens(n: number): string {\n if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;\n if (n >= 1_000) return `${(n / 1_000).toFixed(1)}K`;\n return String(n);\n}\n\nfunction BucketBars({\n buckets,\n emptyMessage,\n billing,\n}: {\n buckets: UsageBucket[];\n emptyMessage: string;\n billing: UsageBillingMode;\n}) {\n if (buckets.length === 0) {\n return (\n <p className=\"text-[10px] text-muted-foreground py-1.5\">{emptyMessage}</p>\n );\n }\n const max = Math.max(\n ...buckets.map((b) => displayAmountFromCostCents(b.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"space-y-1\">\n {buckets.map((b) => (\n <div key={b.key} className=\"text-[10px]\">\n <div className=\"flex items-center justify-between gap-2 mb-0.5\">\n <span\n className=\"truncate text-foreground\"\n title={b.key || \"(none)\"}\n >\n {b.key || \"(none)\"}\n </span>\n <span className=\"shrink-0 text-muted-foreground tabular-nums\">\n {formatAggregateCost(b.cost, billing)}\n <span className=\"ms-1 opacity-60\">\n · {formatTokens(b.inputTokens + b.outputTokens)} tok\n </span>\n </span>\n </div>\n <div className=\"h-1 rounded-full bg-accent/40 overflow-hidden\">\n <div\n className=\"h-full bg-foreground/70\"\n style={{\n width: `${(displayAmountFromCostCents(b.cents, billing) / max) * 100}%`,\n }}\n />\n </div>\n </div>\n ))}\n </div>\n );\n}\n\nfunction DailySparkline({\n days,\n billing,\n}: {\n days: DailyBucket[];\n billing: UsageBillingMode;\n}) {\n if (days.length === 0) return null;\n const max = Math.max(\n ...days.map((d) => displayAmountFromCostCents(d.cents, billing)),\n 0.0001,\n );\n return (\n <div className=\"flex items-end gap-[2px] h-8 pt-2\">\n {days.map((d) => (\n <div\n key={d.date}\n className=\"flex-1 bg-foreground/60 rounded-sm min-h-[1px]\"\n style={{\n height: `${Math.max(\n 2,\n (displayAmountFromCostCents(d.cents, billing) / max) * 100,\n )}%`,\n }}\n title={`${d.date}: ${formatAggregateCost(d.cost, billing)} (${d.calls} calls)`}\n />\n ))}\n </div>\n );\n}\n\nexport function UsageSection() {\n const [days, setDays] = useState(30);\n const [data, setData] = useState<UsageSummary | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const billing = data?.billing ?? USD_BILLING;\n\n const load = async (rangeDays: number) => {\n setLoading(true);\n setError(null);\n try {\n const res = await fetch(\n agentNativePath(`/_agent-native/usage?sinceDays=${rangeDays}`),\n );\n if (!res.ok) {\n throw new Error(`Failed (${res.status})`);\n }\n const json = (await res.json()) as UsageSummary;\n setData(json);\n } catch (err: any) {\n setError(err?.message || \"Failed to load usage\");\n } finally {\n setLoading(false);\n }\n };\n\n useEffect(() => {\n load(days);\n }, [days]);\n\n return (\n <div className=\"space-y-3\">\n {/* Range selector + refresh */}\n <div className=\"flex items-center justify-between\">\n <div className=\"flex gap-1 rounded-md border border-border p-0.5\">\n {RANGES.map((r) => (\n <button\n key={r.value}\n onClick={() => setDays(r.value)}\n className={`px-2 py-0.5 text-[10px] rounded ${\n days === r.value\n ? \"bg-accent text-foreground\"\n : \"text-muted-foreground hover:text-foreground\"\n }`}\n >\n {r.label}\n </button>\n ))}\n </div>\n <button\n onClick={() => load(days)}\n className=\"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground\"\n disabled={loading}\n >\n {loading ? (\n <IconLoader2 size={11} className=\"animate-spin\" />\n ) : (\n <IconRefresh size={11} />\n )}\n </button>\n </div>\n\n {error && <p className=\"text-[10px] text-red-500\">{error}</p>}\n\n {data && (\n <>\n {/* Totals */}\n <div className=\"rounded-md border border-border px-2.5 py-2\">\n <div className=\"flex items-baseline justify-between\">\n <div>\n <div className=\"text-[10px] text-muted-foreground\">\n {billing.unit === \"builder-credits\"\n ? \"Builder.io credit spend\"\n : \"Total spend\"}\n </div>\n <div className=\"text-[18px] font-semibold tabular-nums\">\n {formatAggregateCost(data.totalCost, billing)}\n </div>\n </div>\n <div className=\"text-end\">\n <div className=\"text-[10px] text-muted-foreground\">\n {data.totalCalls} calls\n </div>\n <div className=\"text-[10px] text-muted-foreground\">\n {formatTokens(data.totalInputTokens)} in ·{\" \"}\n {formatTokens(data.totalOutputTokens)} out\n </div>\n {data.totalCacheReadTokens > 0 && (\n <div className=\"text-[10px] text-green-500/80\">\n {formatTokens(data.totalCacheReadTokens)} cached\n </div>\n )}\n </div>\n </div>\n <DailySparkline days={data.byDay} billing={billing} />\n </div>\n\n {/* By label */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By label\n </div>\n <BucketBars\n buckets={data.byLabel}\n emptyMessage=\"No labeled calls yet.\"\n billing={billing}\n />\n </div>\n\n {/* By model */}\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By model\n </div>\n <BucketBars\n buckets={data.byModel}\n emptyMessage=\"No calls recorded.\"\n billing={billing}\n />\n </div>\n\n {/* By app — only show when multiple apps contribute */}\n {data.byApp.filter((b) => b.key).length > 1 && (\n <div>\n <div className=\"text-[10px] font-medium text-foreground mb-1\">\n By app\n </div>\n <BucketBars\n buckets={data.byApp}\n emptyMessage=\"\"\n billing={billing}\n />\n </div>\n )}\n\n {/* Recent calls */}\n {data.recent.length > 0 && (\n <details>\n <summary className=\"text-[10px] font-medium text-foreground cursor-pointer select-none hover:text-foreground/80\">\n Recent calls ({data.recent.length})\n </summary>\n <div className=\"mt-1.5 max-h-48 overflow-y-auto space-y-0.5 rounded border border-border\">\n {data.recent.map((r) => (\n <div\n key={r.id}\n className=\"flex items-center justify-between gap-2 px-2 py-1 text-[10px] border-b border-border last:border-b-0\"\n >\n <div className=\"min-w-0 flex-1\">\n <div className=\"truncate text-foreground\" title={r.label}>\n {r.label}\n {r.app ? (\n <span className=\"text-muted-foreground\">\n {\" \"}\n · {r.app}\n </span>\n ) : null}\n </div>\n <div className=\"truncate text-muted-foreground\">\n {new Date(r.createdAt).toLocaleString()} · {r.model}\n </div>\n </div>\n <div className=\"shrink-0 text-end tabular-nums text-muted-foreground\">\n {r.costSource === \"unavailable\"\n ? \"Unknown\"\n : formatSpend(r.cents, billing)}\n </div>\n </div>\n ))}\n </div>\n </details>\n )}\n\n {billing.unit === \"builder-credits\" ? (\n <p className=\"text-[10px] text-muted-foreground\">\n Builder.io credits are estimated from hard token cost, a{\" \"}\n {billing.hardCostMarginMultiplier ?? 1.25}x margin, and{\" \"}\n {billing.creditsPerUsd ?? 20} credits per dollar.\n </p>\n ) : (\n <p className=\"text-[10px] text-muted-foreground\">\n Spend is estimated from published Anthropic pricing and your own\n recorded token counts. Cached input is priced at ~10% of regular\n input. Calls without provider pricing are marked unknown and\n excluded from known-cost subtotals.\n </p>\n )}\n </>\n )}\n </div>\n );\n}\n"]}
|
|
@@ -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
|
-
error: string;
|
|
17
16
|
ok?: undefined;
|
|
17
|
+
error: string;
|
|
18
18
|
} | {
|
|
19
19
|
error?: undefined;
|
|
20
20
|
ok: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { createServer, createSSEHandler, defineNitroPlugin, autoMountAuth, getSe
|
|
|
13
13
|
export { agentChat, type AgentChatCallOptions, type AgentChatResponse, } from "./shared/index.js";
|
|
14
14
|
export { EMBED_MODE_QUERY_PARAM, EMBED_SESSION_COOKIE, EMBED_START_PATH, EMBED_TOKEN_QUERY_PARAM, } from "./shared/embed-auth.js";
|
|
15
15
|
export { AGENT_WEB_CRAWLER_CATEGORIES, AGENT_WEB_CRAWLER_USER_AGENTS, DEFAULT_AGENT_WEB_CRAWLER_POLICY, absoluteUrl, agentWebConfigFromPackageJson, buildAgentWebStaticFiles, buildBaseJsonLd, buildLlmsFullTxt, buildLlmsTxt, buildMarkdownResponseHeaders, buildPageJsonLd, buildRobotsTxt, buildSitemapXml, deriveAgentWebPublicRoutes, estimateMarkdownTokens, markdownFilePathForPage, markdownUrlForPage, normalizeAgentWebConfig, pathPatternMatches, resolveAgentWebCrawlerPolicy, type AgentWebConfig, type AgentWebCrawlerCategory, type AgentWebCrawlerDecision, type AgentWebCrawlerOverrides, type AgentWebCrawlerPolicy, type AgentWebInputConfig, type AgentWebPage, type AgentWebStaticFile, type BuildAgentWebStaticFilesOptions, type DeriveAgentWebPublicRoutesOptions, type MarkdownResponseHeadersOptions, } from "./agent-web/index.js";
|
|
16
|
-
export { recordUsage, getUsageSummary, getUserUsageCents, calculateCost, usageBillingForEngine, builderCreditsFromCostCents, BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER, BUILDER_AGENT_CREDITS_PER_USD, BUILDER_CREDIT_USAGE_BILLING, USD_USAGE_BILLING, type UsageRecord, type UsageSummary, type UsageBillingMode, type UsageBillingUnit, type UsageBucket, type DailyBucket, type UsageRecentEntry, } from "./usage/store.js";
|
|
16
|
+
export { recordUsage, getUsageSummary, getUserUsageCents, calculateCost, usageBillingForEngine, builderCreditsFromCostCents, BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER, BUILDER_AGENT_CREDITS_PER_USD, BUILDER_CREDIT_USAGE_BILLING, USD_USAGE_BILLING, type UsageRecord, type UsageCostSource, type UsageCostAggregate, type UsageSummary, type UsageBillingMode, type UsageBillingUnit, type UsageBucket, type DailyBucket, type UsageRecentEntry, } from "./usage/store.js";
|
|
17
17
|
export { deleteWorkspaceConnection, getWorkspaceConnectionAppAccess, getWorkspaceConnection, getWorkspaceConnectionGrant, listWorkspaceConnectionProviderCatalogForApp, listWorkspaceConnectionGrants, listWorkspaceConnections, resolveWorkspaceConnectionCredentialForApp, resolveWorkspaceConnectionCredentialsForApp, revokeWorkspaceConnectionGrant, serializeWorkspaceConnectionGrant, serializeWorkspaceConnection, summarizeWorkspaceConnectionProviderForApp, summarizeWorkspaceConnectionProviderReadiness, upsertWorkspaceConnectionGrant, upsertWorkspaceConnection, type ListWorkspaceConnectionProviderCatalogForAppOptions, type ListWorkspaceConnectionGrantsOptions, type ListWorkspaceConnectionsOptions, type ResolveWorkspaceConnectionCredentialForAppOptions, type ResolveWorkspaceConnectionCredentialsForAppOptions, type SerializedWorkspaceConnectionGrant, type SerializedWorkspaceConnection, type SummarizeWorkspaceConnectionProviderForAppOptions, type SummarizeWorkspaceConnectionProviderReadinessOptions, type UpsertWorkspaceConnectionGrantInput, type UpsertWorkspaceConnectionInput, type WorkspaceConnectionAppAccess, type WorkspaceConnectionAppAccessMode, type WorkspaceConnection, type WorkspaceConnectionCredentialBackend, type WorkspaceConnectionCredentialProvenance, type WorkspaceConnectionCredentialRef, type WorkspaceConnectionCredentialResolution, type WorkspaceConnectionCredentialResolutionCheck, type WorkspaceConnectionCredentialResolutionStatus, type WorkspaceConnectionCredentialsResolution, type WorkspaceConnectionExplicitGrantSummary, type WorkspaceConnectionForAppSummary, type WorkspaceConnectionGrant, type WorkspaceConnectionGrantAvailability, type WorkspaceConnectionGrantState, type WorkspaceConnectionProviderAppSummary, type WorkspaceConnectionProviderLike, type WorkspaceConnectionProviderCatalogForApp, type WorkspaceConnectionProviderCatalogForAppItem, type WorkspaceConnectionProviderReadiness, type WorkspaceConnectionProviderReadinessStatus, type WorkspaceConnectionPublicCredentialRef, type WorkspaceConnectionStatus, workspaceConnectionIsAvailableToApp, } from "./workspace-connections/index.js";
|
|
18
18
|
export { PROVIDER_READERS, ProviderReaderRuntimeError, WORKSPACE_CONNECTION_PROVIDERS, createProviderReaderRuntime, defineProviderReader, defineProviderReaderImplementation, defineWorkspaceConnectionProvider, getProviderReader, getWorkspaceConnectionProvider, isWorkspaceConnectionProviderId, listProviderReaders, listWorkspaceConnectionProviders, listWorkspaceConnectionProvidersForCapability, listWorkspaceConnectionProvidersForTemplate, providerReaderSupports, workspaceConnectionProviderSupports, type ListWorkspaceConnectionProvidersOptions, type ListProviderReadersOptions, type ProviderReaderCapability, type ProviderReaderCredentialRequirement, type ProviderReaderDefinition, type ProviderReaderImplementationStatus, type ProviderReaderOperation, type ProviderReaderOperationDescriptor, type ProviderReaderOperationParameter, type ProviderReaderRequest, type ProviderReaderRuntime, type ProviderReaderRuntimeConnection, type ProviderReaderRuntimeConnectionResolverOptions, type ProviderReaderRuntimeContext, type ProviderReaderRuntimeCredentialsResolverOptions, type ProviderReaderRuntimeErrorCode, type ProviderReaderRuntimeHandler, type ProviderReaderRuntimeImplementation, type ProviderReaderRuntimeItem, type ProviderReaderRuntimeOptions, type ProviderReaderRuntimeResponse, type WorkspaceConnectionCapability, type WorkspaceConnectionCredentialKey, type WorkspaceConnectionProvider, type WorkspaceConnectionProviderId, type WorkspaceConnectionTemplateUse, } from "./connections/index.js";
|
|
19
19
|
export { runScript, loadEnv, parseArgs, camelCaseArgs, isValidPath, isValidProjectPath, ensureDir, fail, } from "./scripts/index.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,4BAA4B,EAC5B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,aAAa,EAEb,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,i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,EACxC,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,oBAAoB,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,EACzC,KAAK,gDAAgD,GACtD,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,4BAA4B,EAC5B,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,aAAa,EAEb,QAAQ,EACR,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK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EACjC,KAAK,+CAA+C,EACpD,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EACjC,KAAK,mCAAmC,EACxC,KAAK,yBAAyB,EAC9B,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EAClC,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,GACpC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,oBAAoB,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,EACzC,KAAK,gDAAgD,GACtD,MAAM,8BAA8B,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,+CAA+C;AAE/C,0BAA0B;AAC1B,OAAO,EACL,4BAA4B,EAU5B,aAAa;AACb,6DAA6D;AAC7D,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAOtB,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,GAQ9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,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C7C,2CAA2C,EAC3C,sBAAsB,EACtB,mCAAmC,GA2BpC,MAAM,wBAAwB,CAAC;AAEhC,UAAU;AACV,OAAO,EACL,SAAS,EACT,OAAO,EACP,SAAS,EACT,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,IAAI,GACL,MAAM,oBAAoB,CAAC;AAE5B,4EAA4E;AAC5E,wEAAwE;AACxE,mCAAmC;AACnC,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,GAMhB,MAAM,oBAAoB,CAAC;AAE5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,OAAO,EACL,yCAAyC,GAE1C,MAAM,8BAA8B,CAAC","sourcesContent":["// Framework for agent-native apps.\n// Import everything from \"@agent-native/core\".\n\n// Agent (production mode)\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n DEFAULT_MODEL,\n // In-loop processors (observers/guardrails for runAgentLoop)\n TripWire,\n type Processor,\n type ProcessorState,\n type ProcessorAbort,\n} from \"./agent/index.js\";\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionDefinition,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n type PublicAgentActionConfig,\n type ActionDeepLink,\n type ActionLinkBuilder,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport { createDevScriptRegistry } from \"./scripts/dev/index.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./server/agent-chat-plugin.js\";\nexport {\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./server/embedded.js\";\nexport {\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type AutomationCapabilities,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"./integrations/catalog.js\";\nexport {\n AutomationConnectorError,\n createAutomationCallbackHandler,\n createAutomationRuntime,\n createInvokeAutomationWorkflowAction,\n type AutomationCallbackAuthentication,\n type AutomationCallbackInput,\n type AutomationCallbackResult,\n type AutomationInboundDefinition,\n type AutomationInvocation,\n type AutomationInvocationResult,\n type AutomationInvocationStatus,\n type AutomationOutboundDefinition,\n type AutomationResponseMode,\n type AutomationRetryPolicy,\n type AutomationRuntime,\n type AutomationRuntimeOptions,\n type AutomationWorkflowCapabilities,\n type AutomationWorkflowDefinition,\n type JsonSchema,\n} from \"./automation/index.js\";\n\n// Server\nexport {\n createServer,\n createSSEHandler,\n defineNitroPlugin,\n autoMountAuth,\n getSession,\n type CreateServerOptions,\n type SSEHandlerOptions,\n type AuthSession,\n type AuthOptions,\n} from \"./server/index.js\";\n\n// Client\n//\n// IMPORTANT: this top-level entry (the package `default`/Node condition) must\n// stay server-safe. It is what `import { defineAction } from \"@agent-native/core\"`\n// resolves to in a headless / Node / SSR context, where React, react-router, and\n// @tanstack/react-query are NOT installed. The React client surface therefore\n// lives behind the `@agent-native/core/client` subpath instead of being\n// re-exported here — re-exporting \"./client/index.js\" from this module would\n// eagerly pull route-state.ts → \"@tanstack/react-query\" into the load graph and\n// crash any headless app at module load.\n//\n// Browser bundlers resolve \"@agent-native/core\" to the `browser` condition\n// (./index.browser.ts), which re-exports the client surface, so UI code that\n// imports client helpers from the bare specifier keeps working in the browser.\n// Code that runs through the Node entry (SSR, scripts, headless) must import\n// client helpers explicitly:\n//\n// import { useDbSync, cn } from \"@agent-native/core/client\";\n\n// Shared (isomorphic)\nexport {\n agentChat,\n type AgentChatCallOptions,\n type AgentChatResponse,\n} from \"./shared/index.js\";\nexport {\n EMBED_MODE_QUERY_PARAM,\n EMBED_SESSION_COOKIE,\n EMBED_START_PATH,\n EMBED_TOKEN_QUERY_PARAM,\n} from \"./shared/embed-auth.js\";\n\n// Agent Web surfaces\nexport {\n AGENT_WEB_CRAWLER_CATEGORIES,\n AGENT_WEB_CRAWLER_USER_AGENTS,\n DEFAULT_AGENT_WEB_CRAWLER_POLICY,\n absoluteUrl,\n agentWebConfigFromPackageJson,\n buildAgentWebStaticFiles,\n buildBaseJsonLd,\n buildLlmsFullTxt,\n buildLlmsTxt,\n buildMarkdownResponseHeaders,\n buildPageJsonLd,\n buildRobotsTxt,\n buildSitemapXml,\n deriveAgentWebPublicRoutes,\n estimateMarkdownTokens,\n markdownFilePathForPage,\n markdownUrlForPage,\n normalizeAgentWebConfig,\n pathPatternMatches,\n resolveAgentWebCrawlerPolicy,\n type AgentWebConfig,\n type AgentWebCrawlerCategory,\n type AgentWebCrawlerDecision,\n type AgentWebCrawlerOverrides,\n type AgentWebCrawlerPolicy,\n type AgentWebInputConfig,\n type AgentWebPage,\n type AgentWebStaticFile,\n type BuildAgentWebStaticFilesOptions,\n type DeriveAgentWebPublicRoutesOptions,\n type MarkdownResponseHeadersOptions,\n} from \"./agent-web/index.js\";\n\n// Token usage tracking\nexport {\n recordUsage,\n getUsageSummary,\n getUserUsageCents,\n calculateCost,\n usageBillingForEngine,\n builderCreditsFromCostCents,\n BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,\n BUILDER_AGENT_CREDITS_PER_USD,\n BUILDER_CREDIT_USAGE_BILLING,\n USD_USAGE_BILLING,\n type UsageRecord,\n type UsageSummary,\n type UsageBillingMode,\n type UsageBillingUnit,\n type UsageBucket,\n type DailyBucket,\n type UsageRecentEntry,\n} from \"./usage/store.js\";\n\n// Workspace-scoped third-party connection metadata\nexport {\n deleteWorkspaceConnection,\n getWorkspaceConnectionAppAccess,\n getWorkspaceConnection,\n getWorkspaceConnectionGrant,\n listWorkspaceConnectionProviderCatalogForApp,\n listWorkspaceConnectionGrants,\n listWorkspaceConnections,\n resolveWorkspaceConnectionCredentialForApp,\n resolveWorkspaceConnectionCredentialsForApp,\n revokeWorkspaceConnectionGrant,\n serializeWorkspaceConnectionGrant,\n serializeWorkspaceConnection,\n summarizeWorkspaceConnectionProviderForApp,\n summarizeWorkspaceConnectionProviderReadiness,\n upsertWorkspaceConnectionGrant,\n upsertWorkspaceConnection,\n type ListWorkspaceConnectionProviderCatalogForAppOptions,\n type ListWorkspaceConnectionGrantsOptions,\n type ListWorkspaceConnectionsOptions,\n type ResolveWorkspaceConnectionCredentialForAppOptions,\n type ResolveWorkspaceConnectionCredentialsForAppOptions,\n type SerializedWorkspaceConnectionGrant,\n type SerializedWorkspaceConnection,\n type SummarizeWorkspaceConnectionProviderForAppOptions,\n type SummarizeWorkspaceConnectionProviderReadinessOptions,\n type UpsertWorkspaceConnectionGrantInput,\n type UpsertWorkspaceConnectionInput,\n type WorkspaceConnectionAppAccess,\n type WorkspaceConnectionAppAccessMode,\n type WorkspaceConnection,\n type WorkspaceConnectionCredentialBackend,\n type WorkspaceConnectionCredentialProvenance,\n type WorkspaceConnectionCredentialRef,\n type WorkspaceConnectionCredentialResolution,\n type WorkspaceConnectionCredentialResolutionCheck,\n type WorkspaceConnectionCredentialResolutionStatus,\n type WorkspaceConnectionCredentialsResolution,\n type WorkspaceConnectionExplicitGrantSummary,\n type WorkspaceConnectionForAppSummary,\n type WorkspaceConnectionGrant,\n type WorkspaceConnectionGrantAvailability,\n type WorkspaceConnectionGrantState,\n type WorkspaceConnectionProviderAppSummary,\n type WorkspaceConnectionProviderLike,\n type WorkspaceConnectionProviderCatalogForApp,\n type WorkspaceConnectionProviderCatalogForAppItem,\n type WorkspaceConnectionProviderReadiness,\n type WorkspaceConnectionProviderReadinessStatus,\n type WorkspaceConnectionPublicCredentialRef,\n type WorkspaceConnectionStatus,\n workspaceConnectionIsAvailableToApp,\n} from \"./workspace-connections/index.js\";\n\n// Reusable workspace connection provider catalog\nexport {\n PROVIDER_READERS,\n ProviderReaderRuntimeError,\n WORKSPACE_CONNECTION_PROVIDERS,\n createProviderReaderRuntime,\n defineProviderReader,\n defineProviderReaderImplementation,\n defineWorkspaceConnectionProvider,\n getProviderReader,\n getWorkspaceConnectionProvider,\n isWorkspaceConnectionProviderId,\n listProviderReaders,\n listWorkspaceConnectionProviders,\n listWorkspaceConnectionProvidersForCapability,\n listWorkspaceConnectionProvidersForTemplate,\n providerReaderSupports,\n workspaceConnectionProviderSupports,\n type ListWorkspaceConnectionProvidersOptions,\n type ListProviderReadersOptions,\n type ProviderReaderCapability,\n type ProviderReaderCredentialRequirement,\n type ProviderReaderDefinition,\n type ProviderReaderImplementationStatus,\n type ProviderReaderOperation,\n type ProviderReaderOperationDescriptor,\n type ProviderReaderOperationParameter,\n type ProviderReaderRequest,\n type ProviderReaderRuntime,\n type ProviderReaderRuntimeConnection,\n type ProviderReaderRuntimeConnectionResolverOptions,\n type ProviderReaderRuntimeContext,\n type ProviderReaderRuntimeCredentialsResolverOptions,\n type ProviderReaderRuntimeErrorCode,\n type ProviderReaderRuntimeHandler,\n type ProviderReaderRuntimeImplementation,\n type ProviderReaderRuntimeItem,\n type ProviderReaderRuntimeOptions,\n type ProviderReaderRuntimeResponse,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionCredentialKey,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionProviderId,\n type WorkspaceConnectionTemplateUse,\n} from \"./connections/index.js\";\n\n// Scripts\nexport {\n runScript,\n loadEnv,\n parseArgs,\n camelCaseArgs,\n isValidPath,\n isValidProjectPath,\n ensureDir,\n fail,\n} from \"./scripts/index.js\";\n\n// Secrets registry — import from \"@agent-native/core/secrets\" when possible\n// (the subpath keeps the top-level entry point lean), but re-export the\n// public API here for convenience.\nexport {\n registerRequiredSecret,\n listRequiredSecrets,\n getRequiredSecret,\n readAppSecret,\n writeAppSecret,\n deleteAppSecret,\n type RegisteredSecret,\n type SecretScope,\n type SecretKind,\n type SecretValidator,\n type SecretRef,\n} from \"./secrets/index.js\";\n\nexport * from \"./history/index.js\";\nexport * from \"./review/index.js\";\nexport * from \"./org-team/index.js\";\nexport * from \"./navigation/index.js\";\nexport * from \"./command-navigation/index.js\";\nexport {\n registerWorkspaceConnectionOnboardingStep,\n type RegisterWorkspaceConnectionOnboardingStepOptions,\n} from \"./setup-connections/index.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,+CAA+C;AAE/C,0BAA0B;AAC1B,OAAO,EACL,4BAA4B,EAU5B,aAAa;AACb,6DAA6D;AAC7D,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,sBAAsB,EAOtB,oBAAoB,EACpB,iBAAiB,EACjB,6BAA6B,GAQ9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,QAAQ,EACR,iCAAiC,GAElC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,UAAU,GAKX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAClC,mCAAmC,EACnC,wCAAwC,GAEzC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,2BAA2B,EAC3B,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAe1B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAA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yCAAyC,GAE1C,MAAM,8BAA8B,CAAC","sourcesContent":["// Framework for agent-native apps.\n// Import everything from \"@agent-native/core\".\n\n// Agent (production mode)\nexport {\n createProductionAgentHandler,\n type ActionEntry,\n type ScriptEntry,\n type ProductionAgentOptions,\n type ActionTool,\n type ScriptTool,\n type AgentMessage,\n type AgentChatRequest,\n type AgentChatEvent,\n type AgentChatAttachment,\n DEFAULT_MODEL,\n // In-loop processors (observers/guardrails for runAgentLoop)\n TripWire,\n type Processor,\n type ProcessorState,\n type ProcessorAbort,\n} from \"./agent/index.js\";\nexport {\n defineAction,\n AgentActionStopError,\n isAgentActionStopError,\n type ActionDefinition,\n type ActionHttpConfig,\n type AgentActionStopOptions,\n type PublicAgentActionConfig,\n type ActionDeepLink,\n type ActionLinkBuilder,\n MCP_APP_EXTENSION_ID,\n MCP_APP_MIME_TYPE,\n MCP_APP_RESOURCE_URI_META_KEY,\n type ActionMcpAppConfig,\n type ActionMcpAppCsp,\n type ActionMcpAppCspBuilder,\n type ActionMcpAppHtmlBuilder,\n type ActionMcpAppPermissions,\n type ActionMcpAppResourceConfig,\n type ActionMcpAppResourceMeta,\n} from \"./action.js\";\nexport {\n embedApp,\n MCP_APP_REQUEST_ORIGIN_CSP_SOURCE,\n type EmbedAppOptions,\n} from \"./mcp/embed-app.js\";\nexport {\n embedRoute,\n type EmbedRouteContext,\n type EmbedRouteOptions,\n type EmbedRoutePathBuilder,\n type EmbedRouteResult,\n} from \"./mcp/embed-route.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n ACTION_CHAT_UI_INLINE_EXTENSION_RENDERER,\n type ActionChatUIConfig,\n} from \"./action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./data-widgets/index.js\";\nexport { createDevScriptRegistry } from \"./scripts/dev/index.js\";\nexport {\n createAgentChatPlugin,\n defaultAgentChatPlugin,\n type AgentChatPluginOptions,\n} from \"./server/agent-chat-plugin.js\";\nexport {\n createAgentNativeEmbeddedPlugin,\n mountAgentNativeEmbedded,\n type AgentNativeEmbeddedPluginOptions,\n} from \"./server/embedded.js\";\nexport {\n BUILT_IN_INTEGRATION_CATALOG,\n INTEGRATION_CATEGORIES,\n getIntegrationCatalogEntry,\n listBuiltInChannelIntegrations,\n listIntegrationCatalog,\n type AutomationCapabilities,\n type BuiltInChannelId,\n type ChannelCapabilities,\n type IntegrationAvailability,\n type IntegrationCatalogEntry,\n type IntegrationCategory,\n type IntegrationCredentialRequirement,\n type IntegrationIconKey,\n type IntegrationSupportMaturity,\n} from \"./integrations/catalog.js\";\nexport {\n AutomationConnectorError,\n createAutomationCallbackHandler,\n createAutomationRuntime,\n createInvokeAutomationWorkflowAction,\n type AutomationCallbackAuthentication,\n type AutomationCallbackInput,\n type AutomationCallbackResult,\n type AutomationInboundDefinition,\n type AutomationInvocation,\n type AutomationInvocationResult,\n type AutomationInvocationStatus,\n type AutomationOutboundDefinition,\n type AutomationResponseMode,\n type AutomationRetryPolicy,\n type AutomationRuntime,\n type AutomationRuntimeOptions,\n type AutomationWorkflowCapabilities,\n type AutomationWorkflowDefinition,\n type JsonSchema,\n} from \"./automation/index.js\";\n\n// Server\nexport {\n createServer,\n createSSEHandler,\n defineNitroPlugin,\n autoMountAuth,\n getSession,\n type CreateServerOptions,\n type SSEHandlerOptions,\n type AuthSession,\n type AuthOptions,\n} from \"./server/index.js\";\n\n// Client\n//\n// IMPORTANT: this top-level entry (the package `default`/Node condition) must\n// stay server-safe. It is what `import { defineAction } from \"@agent-native/core\"`\n// resolves to in a headless / Node / SSR context, where React, react-router, and\n// @tanstack/react-query are NOT installed. The React client surface therefore\n// lives behind the `@agent-native/core/client` subpath instead of being\n// re-exported here — re-exporting \"./client/index.js\" from this module would\n// eagerly pull route-state.ts → \"@tanstack/react-query\" into the load graph and\n// crash any headless app at module load.\n//\n// Browser bundlers resolve \"@agent-native/core\" to the `browser` condition\n// (./index.browser.ts), which re-exports the client surface, so UI code that\n// imports client helpers from the bare specifier keeps working in the browser.\n// Code that runs through the Node entry (SSR, scripts, headless) must import\n// client helpers explicitly:\n//\n// import { useDbSync, cn } from \"@agent-native/core/client\";\n\n// Shared (isomorphic)\nexport {\n agentChat,\n type AgentChatCallOptions,\n type AgentChatResponse,\n} from \"./shared/index.js\";\nexport {\n EMBED_MODE_QUERY_PARAM,\n EMBED_SESSION_COOKIE,\n EMBED_START_PATH,\n EMBED_TOKEN_QUERY_PARAM,\n} from \"./shared/embed-auth.js\";\n\n// Agent Web surfaces\nexport {\n AGENT_WEB_CRAWLER_CATEGORIES,\n AGENT_WEB_CRAWLER_USER_AGENTS,\n DEFAULT_AGENT_WEB_CRAWLER_POLICY,\n absoluteUrl,\n agentWebConfigFromPackageJson,\n buildAgentWebStaticFiles,\n buildBaseJsonLd,\n buildLlmsFullTxt,\n buildLlmsTxt,\n buildMarkdownResponseHeaders,\n buildPageJsonLd,\n buildRobotsTxt,\n buildSitemapXml,\n deriveAgentWebPublicRoutes,\n estimateMarkdownTokens,\n markdownFilePathForPage,\n markdownUrlForPage,\n normalizeAgentWebConfig,\n pathPatternMatches,\n resolveAgentWebCrawlerPolicy,\n type AgentWebConfig,\n type AgentWebCrawlerCategory,\n type AgentWebCrawlerDecision,\n type AgentWebCrawlerOverrides,\n type AgentWebCrawlerPolicy,\n type AgentWebInputConfig,\n type AgentWebPage,\n type AgentWebStaticFile,\n type BuildAgentWebStaticFilesOptions,\n type DeriveAgentWebPublicRoutesOptions,\n type MarkdownResponseHeadersOptions,\n} from \"./agent-web/index.js\";\n\n// Token usage tracking\nexport {\n recordUsage,\n getUsageSummary,\n getUserUsageCents,\n calculateCost,\n usageBillingForEngine,\n builderCreditsFromCostCents,\n BUILDER_AGENT_CREDIT_MARGIN_MULTIPLIER,\n BUILDER_AGENT_CREDITS_PER_USD,\n BUILDER_CREDIT_USAGE_BILLING,\n USD_USAGE_BILLING,\n type UsageRecord,\n type UsageCostSource,\n type UsageCostAggregate,\n type UsageSummary,\n type UsageBillingMode,\n type UsageBillingUnit,\n type UsageBucket,\n type DailyBucket,\n type UsageRecentEntry,\n} from \"./usage/store.js\";\n\n// Workspace-scoped third-party connection metadata\nexport {\n deleteWorkspaceConnection,\n getWorkspaceConnectionAppAccess,\n getWorkspaceConnection,\n getWorkspaceConnectionGrant,\n listWorkspaceConnectionProviderCatalogForApp,\n listWorkspaceConnectionGrants,\n listWorkspaceConnections,\n resolveWorkspaceConnectionCredentialForApp,\n resolveWorkspaceConnectionCredentialsForApp,\n revokeWorkspaceConnectionGrant,\n serializeWorkspaceConnectionGrant,\n serializeWorkspaceConnection,\n summarizeWorkspaceConnectionProviderForApp,\n summarizeWorkspaceConnectionProviderReadiness,\n upsertWorkspaceConnectionGrant,\n upsertWorkspaceConnection,\n type ListWorkspaceConnectionProviderCatalogForAppOptions,\n type ListWorkspaceConnectionGrantsOptions,\n type ListWorkspaceConnectionsOptions,\n type ResolveWorkspaceConnectionCredentialForAppOptions,\n type ResolveWorkspaceConnectionCredentialsForAppOptions,\n type SerializedWorkspaceConnectionGrant,\n type SerializedWorkspaceConnection,\n type SummarizeWorkspaceConnectionProviderForAppOptions,\n type SummarizeWorkspaceConnectionProviderReadinessOptions,\n type UpsertWorkspaceConnectionGrantInput,\n type UpsertWorkspaceConnectionInput,\n type WorkspaceConnectionAppAccess,\n type WorkspaceConnectionAppAccessMode,\n type WorkspaceConnection,\n type WorkspaceConnectionCredentialBackend,\n type WorkspaceConnectionCredentialProvenance,\n type WorkspaceConnectionCredentialRef,\n type WorkspaceConnectionCredentialResolution,\n type WorkspaceConnectionCredentialResolutionCheck,\n type WorkspaceConnectionCredentialResolutionStatus,\n type WorkspaceConnectionCredentialsResolution,\n type WorkspaceConnectionExplicitGrantSummary,\n type WorkspaceConnectionForAppSummary,\n type WorkspaceConnectionGrant,\n type WorkspaceConnectionGrantAvailability,\n type WorkspaceConnectionGrantState,\n type WorkspaceConnectionProviderAppSummary,\n type WorkspaceConnectionProviderLike,\n type WorkspaceConnectionProviderCatalogForApp,\n type WorkspaceConnectionProviderCatalogForAppItem,\n type WorkspaceConnectionProviderReadiness,\n type WorkspaceConnectionProviderReadinessStatus,\n type WorkspaceConnectionPublicCredentialRef,\n type WorkspaceConnectionStatus,\n workspaceConnectionIsAvailableToApp,\n} from \"./workspace-connections/index.js\";\n\n// Reusable workspace connection provider catalog\nexport {\n PROVIDER_READERS,\n ProviderReaderRuntimeError,\n WORKSPACE_CONNECTION_PROVIDERS,\n createProviderReaderRuntime,\n defineProviderReader,\n defineProviderReaderImplementation,\n defineWorkspaceConnectionProvider,\n getProviderReader,\n getWorkspaceConnectionProvider,\n isWorkspaceConnectionProviderId,\n listProviderReaders,\n listWorkspaceConnectionProviders,\n listWorkspaceConnectionProvidersForCapability,\n listWorkspaceConnectionProvidersForTemplate,\n providerReaderSupports,\n workspaceConnectionProviderSupports,\n type ListWorkspaceConnectionProvidersOptions,\n type ListProviderReadersOptions,\n type ProviderReaderCapability,\n type ProviderReaderCredentialRequirement,\n type ProviderReaderDefinition,\n type ProviderReaderImplementationStatus,\n type ProviderReaderOperation,\n type ProviderReaderOperationDescriptor,\n type ProviderReaderOperationParameter,\n type ProviderReaderRequest,\n type ProviderReaderRuntime,\n type ProviderReaderRuntimeConnection,\n type ProviderReaderRuntimeConnectionResolverOptions,\n type ProviderReaderRuntimeContext,\n type ProviderReaderRuntimeCredentialsResolverOptions,\n type ProviderReaderRuntimeErrorCode,\n type ProviderReaderRuntimeHandler,\n type ProviderReaderRuntimeImplementation,\n type ProviderReaderRuntimeItem,\n type ProviderReaderRuntimeOptions,\n type ProviderReaderRuntimeResponse,\n type WorkspaceConnectionCapability,\n type WorkspaceConnectionCredentialKey,\n type WorkspaceConnectionProvider,\n type WorkspaceConnectionProviderId,\n type WorkspaceConnectionTemplateUse,\n} from \"./connections/index.js\";\n\n// Scripts\nexport {\n runScript,\n loadEnv,\n parseArgs,\n camelCaseArgs,\n isValidPath,\n isValidProjectPath,\n ensureDir,\n fail,\n} from \"./scripts/index.js\";\n\n// Secrets registry — import from \"@agent-native/core/secrets\" when possible\n// (the subpath keeps the top-level entry point lean), but re-export the\n// public API here for convenience.\nexport {\n registerRequiredSecret,\n listRequiredSecrets,\n getRequiredSecret,\n readAppSecret,\n writeAppSecret,\n deleteAppSecret,\n type RegisteredSecret,\n type SecretScope,\n type SecretKind,\n type SecretValidator,\n type SecretRef,\n} from \"./secrets/index.js\";\n\nexport * from \"./history/index.js\";\nexport * from \"./review/index.js\";\nexport * from \"./org-team/index.js\";\nexport * from \"./navigation/index.js\";\nexport * from \"./command-navigation/index.js\";\nexport {\n registerWorkspaceConnectionOnboardingStep,\n type RegisterWorkspaceConnectionOnboardingStepOptions,\n} from \"./setup-connections/index.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-continuation-processor.d.ts","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"a2a-continuation-processor.d.ts","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAEV,eAAe,EAEhB,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"}
|
|
@@ -93,6 +93,7 @@ async function processClaimedContinuation(continuation, options) {
|
|
|
93
93
|
await failA2AContinuation(continuation.id, `Unknown platform: ${continuation.platform}`);
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
+
const progress = await resumeA2AContinuationProgress(continuation, adapter);
|
|
96
97
|
const auth = await signContinuationToken(continuation);
|
|
97
98
|
const client = new A2AClient(continuation.agentUrl, auth.apiKey, {
|
|
98
99
|
requestTimeoutMs: POLL_REQUEST_TIMEOUT_MS,
|
|
@@ -105,33 +106,29 @@ async function processClaimedContinuation(continuation, options) {
|
|
|
105
106
|
task = await client.getTask(continuation.a2aTaskId);
|
|
106
107
|
if (TERMINAL_STATES.has(task.status.state))
|
|
107
108
|
break;
|
|
109
|
+
await reportA2AContinuationProgress(continuation, progress, task);
|
|
108
110
|
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
catch (err) {
|
|
112
114
|
if (isTransientA2APollError(err)) {
|
|
113
115
|
if (shouldStopPollingRemoteTask(continuation)) {
|
|
114
|
-
await notifyAndFailA2AContinuation(continuation, adapter, remotePollFailureReason(continuation));
|
|
116
|
+
await notifyAndFailA2AContinuation(continuation, adapter, remotePollFailureReason(continuation), progress);
|
|
115
117
|
return;
|
|
116
118
|
}
|
|
117
119
|
await rescheduleAndRedispatchA2AContinuation(continuation.id);
|
|
118
120
|
return;
|
|
119
121
|
}
|
|
120
122
|
if (continuation.attempts >= MAX_ATTEMPTS) {
|
|
121
|
-
await notifyAndFailA2AContinuation(continuation, adapter, err instanceof Error ? err.message : String(err));
|
|
123
|
+
await notifyAndFailA2AContinuation(continuation, adapter, err instanceof Error ? err.message : String(err), progress);
|
|
122
124
|
return;
|
|
123
125
|
}
|
|
124
126
|
await rescheduleAndRedispatchA2AContinuation(continuation.id);
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
129
|
if (!task || !TERMINAL_STATES.has(task.status.state)) {
|
|
128
|
-
const recoverableArtifactText = extractRecoverableArtifactText(task);
|
|
129
|
-
if (recoverableArtifactText) {
|
|
130
|
-
await deliverAndCompleteA2AContinuation(continuation, adapter, formatContinuationArtifactText(recoverableArtifactText, continuation.agentUrl));
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
130
|
if (shouldStopPollingRemoteTask(continuation)) {
|
|
134
|
-
await notifyAndFailA2AContinuation(continuation, adapter, remotePollFailureReason(continuation));
|
|
131
|
+
await notifyAndFailA2AContinuation(continuation, adapter, remotePollFailureReason(continuation), progress);
|
|
135
132
|
return;
|
|
136
133
|
}
|
|
137
134
|
await rescheduleAndRedispatchA2AContinuation(continuation.id);
|
|
@@ -140,15 +137,48 @@ async function processClaimedContinuation(continuation, options) {
|
|
|
140
137
|
if (task.status.state !== "completed") {
|
|
141
138
|
const reason = extractTaskText(task) ||
|
|
142
139
|
`Remote A2A task ${continuation.a2aTaskId} ended with state ${task.status.state}`;
|
|
143
|
-
await notifyAndFailA2AContinuation(continuation, adapter, reason);
|
|
140
|
+
await notifyAndFailA2AContinuation(continuation, adapter, reason, progress);
|
|
144
141
|
return;
|
|
145
142
|
}
|
|
146
143
|
const text = formatContinuationArtifactText(extractTaskText(task), continuation.agentUrl);
|
|
147
144
|
if (!text.trim()) {
|
|
148
|
-
await notifyAndFailA2AContinuation(continuation, adapter, `Remote A2A task ${continuation.a2aTaskId} completed without text
|
|
145
|
+
await notifyAndFailA2AContinuation(continuation, adapter, `Remote A2A task ${continuation.a2aTaskId} completed without text`, progress);
|
|
149
146
|
return;
|
|
150
147
|
}
|
|
151
|
-
await deliverAndCompleteA2AContinuation(continuation, adapter, text);
|
|
148
|
+
await deliverAndCompleteA2AContinuation(continuation, adapter, text, progress);
|
|
149
|
+
}
|
|
150
|
+
async function resumeA2AContinuationProgress(continuation, adapter) {
|
|
151
|
+
if (!continuation.progressRef || !adapter.resumeRunProgress)
|
|
152
|
+
return null;
|
|
153
|
+
try {
|
|
154
|
+
const progress = await adapter.resumeRunProgress(continuation.incoming, continuation.progressRef);
|
|
155
|
+
if (!progress)
|
|
156
|
+
return null;
|
|
157
|
+
await progress.onEvent({
|
|
158
|
+
type: "agent_call_progress",
|
|
159
|
+
agent: continuation.agentName,
|
|
160
|
+
state: "working",
|
|
161
|
+
elapsedSeconds: Math.max(0, Math.round((Date.now() - continuation.createdAt) / 1_000)),
|
|
162
|
+
detail: "Continuing in the background",
|
|
163
|
+
});
|
|
164
|
+
return progress;
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
// A continuation still has a normal reply fallback. Do not log the
|
|
168
|
+
// opaque provider reference or the inbound message payload.
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function reportA2AContinuationProgress(continuation, progress, task) {
|
|
173
|
+
if (!progress)
|
|
174
|
+
return;
|
|
175
|
+
await progress.onEvent({
|
|
176
|
+
type: "agent_call_progress",
|
|
177
|
+
agent: continuation.agentName,
|
|
178
|
+
state: task.status.state,
|
|
179
|
+
elapsedSeconds: Math.max(0, Math.round((Date.now() - continuation.createdAt) / 1_000)),
|
|
180
|
+
detail: "Still working on the delegated request",
|
|
181
|
+
});
|
|
152
182
|
}
|
|
153
183
|
async function waitForContinuationDue(continuationId) {
|
|
154
184
|
const continuation = await getA2AContinuation(continuationId);
|
|
@@ -167,25 +197,27 @@ async function waitForContinuationDue(continuationId) {
|
|
|
167
197
|
await sleep(waitMs);
|
|
168
198
|
return true;
|
|
169
199
|
}
|
|
170
|
-
async function notifyAndFailA2AContinuation(continuation, adapter, reason) {
|
|
200
|
+
async function notifyAndFailA2AContinuation(continuation, adapter, reason, progress = null) {
|
|
171
201
|
const deliveryContinuation = await claimA2AContinuationDelivery(continuation.id);
|
|
172
202
|
if (!deliveryContinuation)
|
|
173
203
|
return;
|
|
174
204
|
const message = formatContinuationFailureMessage(deliveryContinuation, reason);
|
|
175
205
|
try {
|
|
176
|
-
|
|
206
|
+
const outgoing = adapter.formatAgentResponse(message);
|
|
207
|
+
await withTimeout(deliverA2AContinuationResponse(adapter, deliveryContinuation, outgoing, progress, "error"), PLATFORM_SEND_TIMEOUT_MS, `${deliveryContinuation.platform} failure notification timed out`);
|
|
177
208
|
}
|
|
178
209
|
catch (err) {
|
|
179
210
|
console.error(`[integrations] Failed to notify ${deliveryContinuation.platform} about failed A2A continuation ${deliveryContinuation.id}:`, err);
|
|
180
211
|
}
|
|
181
212
|
await failA2AContinuation(deliveryContinuation.id, reason);
|
|
182
213
|
}
|
|
183
|
-
async function deliverAndCompleteA2AContinuation(continuation, adapter, text) {
|
|
214
|
+
async function deliverAndCompleteA2AContinuation(continuation, adapter, text, progress = null) {
|
|
184
215
|
const deliveryContinuation = await claimA2AContinuationDelivery(continuation.id);
|
|
185
216
|
if (!deliveryContinuation)
|
|
186
217
|
return;
|
|
187
218
|
try {
|
|
188
|
-
|
|
219
|
+
const outgoing = adapter.formatAgentResponse(text);
|
|
220
|
+
await withTimeout(deliverA2AContinuationResponse(adapter, deliveryContinuation, outgoing, progress, "done"), PLATFORM_SEND_TIMEOUT_MS, `${deliveryContinuation.platform} response delivery timed out`);
|
|
189
221
|
}
|
|
190
222
|
catch (err) {
|
|
191
223
|
if (deliveryContinuation.attempts >= MAX_ATTEMPTS) {
|
|
@@ -197,6 +229,35 @@ async function deliverAndCompleteA2AContinuation(continuation, adapter, text) {
|
|
|
197
229
|
}
|
|
198
230
|
await completeAfterSuccessfulDelivery(deliveryContinuation);
|
|
199
231
|
}
|
|
232
|
+
async function deliverA2AContinuationResponse(adapter, continuation, message, progress, status) {
|
|
233
|
+
if (progress) {
|
|
234
|
+
try {
|
|
235
|
+
await progress.onEvent({
|
|
236
|
+
type: "agent_call",
|
|
237
|
+
agent: continuation.agentName,
|
|
238
|
+
status,
|
|
239
|
+
});
|
|
240
|
+
await progress.complete(message);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// A resumed Slack stream can no longer be finalized (for example when
|
|
245
|
+
// chat.stopStream rejects). Preserve the final answer with the same
|
|
246
|
+
// thread reply fallback used by the initial webhook run. Also ask the
|
|
247
|
+
// adapter to terminate the native stream: otherwise Slack can keep the
|
|
248
|
+
// task card in its working state after the thread fallback succeeds.
|
|
249
|
+
try {
|
|
250
|
+
await progress.fail?.("I couldn't update the live response, but I posted the final result in this thread.");
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
// The thread reply below is still the authoritative final answer.
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
await adapter.sendResponse(message, continuation.incoming, {
|
|
258
|
+
placeholderRef: continuation.placeholderRef ?? undefined,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
200
261
|
async function rescheduleAndRedispatchA2AContinuation(continuationId) {
|
|
201
262
|
await rescheduleA2AContinuation(continuationId, RESCHEDULE_DELAY_MS);
|
|
202
263
|
await dispatchA2AContinuation(continuationId).catch((err) => {
|
|
@@ -344,12 +405,6 @@ function extractTaskText(task) {
|
|
|
344
405
|
.map((part) => part.text)
|
|
345
406
|
.join("\n");
|
|
346
407
|
}
|
|
347
|
-
function extractRecoverableArtifactText(task) {
|
|
348
|
-
if (!task?.status.message?.metadata?.agentNativeRecoverableArtifacts) {
|
|
349
|
-
return "";
|
|
350
|
-
}
|
|
351
|
-
return extractTaskText(task);
|
|
352
|
-
}
|
|
353
408
|
function formatContinuationArtifactText(text, agentUrl) {
|
|
354
409
|
const expandedText = expandRelativeUrls(text, agentUrl);
|
|
355
410
|
return appendA2AArtifactLinks(expandedText, [{ tool: "call-agent", result: expandedText }], { baseUrl: resolveArtifactBaseUrl() });
|