@tangle-network/agent-app 0.60.224 → 0.60.226
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/README.md +20 -0
- package/dist/DesignCanvas-SNE3H3TH.js +13 -0
- package/dist/DesignCanvasEditor-G5O75CUT.js +16 -0
- package/dist/agent-enrollment/drizzle.js +3 -3
- package/dist/agent-enrollment/index.js +3 -3
- package/dist/app-auth/index.js +3 -3
- package/dist/chat-routes/index.js +9 -8
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/{chunk-LGMJMCSE.js → chunk-2TJWEFFM.js} +3 -2
- package/dist/chunk-2TJWEFFM.js.map +1 -0
- package/dist/{chunk-DKHM4B4A.js → chunk-3KXYYAY4.js} +3 -3
- package/dist/{chunk-YWLZOPDS.js → chunk-6QJ3GB3A.js} +2 -2
- package/dist/{chunk-XWJDF34U.js → chunk-6XF3T6YD.js} +3 -2
- package/dist/chunk-6XF3T6YD.js.map +1 -0
- package/dist/{chunk-3NCPXNBZ.js → chunk-7HZCFG2A.js} +5 -3
- package/dist/chunk-7HZCFG2A.js.map +1 -0
- package/dist/{chunk-OMB4HQ2W.js → chunk-EGIVLTLQ.js} +11 -7
- package/dist/chunk-EGIVLTLQ.js.map +1 -0
- package/dist/{chunk-HA5USG2Z.js → chunk-EKV6T4YU.js} +10 -5
- package/dist/chunk-EKV6T4YU.js.map +1 -0
- package/dist/{chunk-UTAIRVOK.js → chunk-FENBDSIW.js} +2 -2
- package/dist/{chunk-EOPFHXEA.js → chunk-I57SNMX4.js} +3 -3
- package/dist/{chunk-2JY3SQD2.js → chunk-ILAQQYVL.js} +2 -2
- package/dist/{chunk-OHWQUKBP.js → chunk-JK7R7BZQ.js} +2 -2
- package/dist/chunk-MM6RLOXF.js +20 -0
- package/dist/chunk-MM6RLOXF.js.map +1 -0
- package/dist/{chunk-6RWQ4VW5.js → chunk-MY3EJJ6Y.js} +2 -2
- package/dist/{chunk-OGLTKK72.js → chunk-NMSAZFRL.js} +2 -2
- package/dist/{chunk-LZBEAWHY.js → chunk-P2NJIDLE.js} +5 -5
- package/dist/{chunk-QM7RTTDY.js → chunk-S27DKRI6.js} +6 -1
- package/dist/chunk-S27DKRI6.js.map +1 -0
- package/dist/{chunk-Q7WEEN7P.js → chunk-TCGZFSN5.js} +2 -2
- package/dist/{chunk-6NYVAURR.js → chunk-VBKP2NLI.js} +2 -2
- package/dist/{chunk-CFGA7PXM.js → chunk-X556WVBG.js} +2 -2
- package/dist/{chunk-HDY72UBR.js → chunk-XAD4VTP4.js} +3 -3
- package/dist/{chunk-HDY72UBR.js.map → chunk-XAD4VTP4.js.map} +1 -1
- package/dist/{chunk-C3JSO2CB.js → chunk-Y4W6GK5X.js} +2 -2
- package/dist/design-canvas/index.js +3 -3
- package/dist/design-canvas-react/engine.js +5 -5
- package/dist/design-canvas-react/index.js +8 -8
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/hosted-agent/application.js +2 -2
- package/dist/interactions/index.js +2 -2
- package/dist/launch-invariants/cli.js +3 -2
- package/dist/launch-invariants/cli.js.map +1 -1
- package/dist/launch-invariants/d1-query-count.d.ts +9 -0
- package/dist/launch-invariants/index.d.ts +1 -0
- package/dist/launch-invariants/index.js +8 -2
- package/dist/launch-invariants/index.js.map +1 -1
- package/dist/launch-invariants/limit-alarms.d.ts +2 -1
- package/dist/launch-invariants/testing.js +3 -2
- package/dist/openui/index.js +1 -1
- package/dist/platform/index.js +3 -3
- package/dist/public-consultation/index.js +7 -6
- package/dist/public-consultation/index.js.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/router-turn.d.ts +2 -2
- package/dist/runtime/router-turn.js +2 -2
- package/dist/sequences/index.js +2 -2
- package/dist/signoff/cli.js +1 -1
- package/dist/signoff/index.js +1 -1
- package/dist/turn-trace/index.js +2 -2
- package/dist/turn-trace/recorder.d.ts +6 -0
- package/dist/web/index.js +2 -2
- package/dist/web/rate-limit.d.ts +6 -1
- package/package.json +1 -1
- package/dist/DesignCanvas-TW45DTK7.js +0 -13
- package/dist/DesignCanvasEditor-EZ7LNKNQ.js +0 -16
- package/dist/chunk-3NCPXNBZ.js.map +0 -1
- package/dist/chunk-HA5USG2Z.js.map +0 -1
- package/dist/chunk-LGMJMCSE.js.map +0 -1
- package/dist/chunk-OMB4HQ2W.js.map +0 -1
- package/dist/chunk-QM7RTTDY.js.map +0 -1
- package/dist/chunk-XWJDF34U.js.map +0 -1
- /package/dist/{DesignCanvas-TW45DTK7.js.map → DesignCanvas-SNE3H3TH.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-EZ7LNKNQ.js.map → DesignCanvasEditor-G5O75CUT.js.map} +0 -0
- /package/dist/{chunk-DKHM4B4A.js.map → chunk-3KXYYAY4.js.map} +0 -0
- /package/dist/{chunk-YWLZOPDS.js.map → chunk-6QJ3GB3A.js.map} +0 -0
- /package/dist/{chunk-UTAIRVOK.js.map → chunk-FENBDSIW.js.map} +0 -0
- /package/dist/{chunk-EOPFHXEA.js.map → chunk-I57SNMX4.js.map} +0 -0
- /package/dist/{chunk-2JY3SQD2.js.map → chunk-ILAQQYVL.js.map} +0 -0
- /package/dist/{chunk-OHWQUKBP.js.map → chunk-JK7R7BZQ.js.map} +0 -0
- /package/dist/{chunk-6RWQ4VW5.js.map → chunk-MY3EJJ6Y.js.map} +0 -0
- /package/dist/{chunk-OGLTKK72.js.map → chunk-NMSAZFRL.js.map} +0 -0
- /package/dist/{chunk-LZBEAWHY.js.map → chunk-P2NJIDLE.js.map} +0 -0
- /package/dist/{chunk-Q7WEEN7P.js.map → chunk-TCGZFSN5.js.map} +0 -0
- /package/dist/{chunk-6NYVAURR.js.map → chunk-VBKP2NLI.js.map} +0 -0
- /package/dist/{chunk-CFGA7PXM.js.map → chunk-X556WVBG.js.map} +0 -0
- /package/dist/{chunk-C3JSO2CB.js.map → chunk-Y4W6GK5X.js.map} +0 -0
|
@@ -162,7 +162,11 @@ function createTurnTrace(options = {}) {
|
|
|
162
162
|
child: (name, kind, attrs) => trace.start(name, kind, attrs),
|
|
163
163
|
record: (name, kind, start, end, attrs) => trace.record(name, kind, start, end, attrs)
|
|
164
164
|
};
|
|
165
|
-
const
|
|
165
|
+
const withMeasurements = (summary) => ({
|
|
166
|
+
...summary,
|
|
167
|
+
...firstTextAt === void 0 ? {} : { firstTextMs: round1(firstTextAt - startedAt) },
|
|
168
|
+
...options.d1QueryCounter === void 0 ? {} : { d1Queries: options.d1QueryCounter.queries }
|
|
169
|
+
});
|
|
166
170
|
const trace = {
|
|
167
171
|
get traceId() {
|
|
168
172
|
return traceId;
|
|
@@ -194,8 +198,9 @@ function createTurnTrace(options = {}) {
|
|
|
194
198
|
firstTextAt = Math.max(startedAt, at ?? now());
|
|
195
199
|
},
|
|
196
200
|
summary(at) {
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
if (finished) return finished.summary;
|
|
202
|
+
const end = at ?? now();
|
|
203
|
+
return withMeasurements(summarizeTurnSpans(trace.spans(end), rootId, startedAt, end, traceId, dropped));
|
|
199
204
|
},
|
|
200
205
|
spans(at) {
|
|
201
206
|
const end = at ?? finished?.endedAt ?? now();
|
|
@@ -218,7 +223,7 @@ function createTurnTrace(options = {}) {
|
|
|
218
223
|
startedAt,
|
|
219
224
|
endedAt,
|
|
220
225
|
spans,
|
|
221
|
-
summary:
|
|
226
|
+
summary: withMeasurements(summarizeTurnSpans(spans, rootId, startedAt, endedAt, traceId, dropped)),
|
|
222
227
|
status: outcome?.error === void 0 ? "ok" : "error",
|
|
223
228
|
...outcome?.error === void 0 ? {} : { error: errorText(outcome.error) }
|
|
224
229
|
};
|
|
@@ -235,4 +240,4 @@ export {
|
|
|
235
240
|
summarizeTurnSpans,
|
|
236
241
|
createTurnTrace
|
|
237
242
|
};
|
|
238
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-EKV6T4YU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/turn-trace/recorder.ts"],"sourcesContent":["/**\n * One trace per agent turn: a root span for the turn's wall time and named\n * child spans for where that time went (admission, each model call, each tool\n * call, the box claim and prompt, persistence).\n *\n * This module only records. It has no imports, so the Router engine, the\n * sandbox helpers and the chat route share it from any runtime, a Worker\n * included. `./otel` turns a finished trace into OTLP spans for Tangle\n * Intelligence.\n *\n * The turn's trace id is its execution id in the charset every hop accepts\n * ({@link turnTraceId}), sent as `x-tangle-trace-id` on every Router and\n * Sandbox call, so a Router dispatch row and a sandbox record join the turn's\n * spans by one id.\n */\n\n/** What a span's time is spent on. Each instant of the turn is credited to the deepest open span's kind. */\nexport type TurnSpanKind =\n | 'admission'\n | 'router'\n | 'model'\n | 'network'\n | 'tool'\n | 'sandbox'\n | 'persist'\n | 'other'\n\nexport const TURN_SPAN_KINDS: readonly TurnSpanKind[] = ['admission', 'router', 'model', 'network', 'tool', 'sandbox', 'persist', 'other']\n\n/** Bounded primitive metadata. Never prompts, answers, tool arguments or credentials. */\nexport type TurnSpanAttrs = Record<string, string | number | boolean>\n\nexport interface TurnSpanRecord {\n spanId: string\n /** The root span's id for a top-level child. */\n parentSpanId: string\n name: string\n kind: TurnSpanKind\n startMs: number\n endMs: number\n attrs: TurnSpanAttrs\n /** Set when the span ended in failure; a short code or message, never content. */\n error?: string\n /** True when the turn finished while the span was still open. */\n unfinished?: boolean\n}\n\nexport interface TurnSpan {\n readonly id: string\n /** Merge attributes. A later value replaces an earlier one. */\n set(attrs: TurnSpanAttrs): TurnSpan\n /** End now. A second call changes nothing. `error` marks the span failed. */\n end(attrs?: TurnSpanAttrs, error?: unknown): void\n /** A child that starts now. */\n child(name: string, kind: TurnSpanKind, attrs?: TurnSpanAttrs): TurnSpan\n /** A child whose times are already known. */\n record(name: string, kind: TurnSpanKind, startMs: number, endMs: number, attrs?: TurnSpanAttrs): TurnSpan\n}\n\n/** How much of the turn's wall time is inside named spans, and what the time was spent on. */\nexport interface TurnTraceSummary {\n traceId: string\n wallMs: number\n /** Wall time inside at least one child span. */\n coveredMs: number\n /** `coveredMs / wallMs` as a percentage, one decimal. */\n coveragePct: number\n uncoveredMs: number\n /** The longest stretch with no span open: where an unnamed wait hides. */\n largestGapMs: number\n /** Wall time credited to the deepest open span's kind. Sums to `coveredMs`. */\n byKind: Record<TurnSpanKind, number>\n spans: number\n modelCalls: number\n toolCalls: number\n /** Spans refused after the per-turn cap. */\n dropped: number\n /** From the request to the first visible text the member could read (see {@link TurnTrace.markFirstText}); absent when none streamed. */\n firstTextMs?: number\n /** D1 round trips in the turn scope, when its binding is instrumented. */\n d1Queries?: number\n}\n\nexport interface TurnTraceSnapshot {\n traceId: string\n /** The id the root span is exported under. */\n rootSpanId: string\n executionId: string\n startedAt: number\n endedAt: number\n spans: TurnSpanRecord[]\n summary: TurnTraceSummary\n /** `ok`, or the failure the turn ended with. */\n status: 'ok' | 'error'\n error?: string\n}\n\n/** Where a finished turn's trace goes. `labels` are the host's metadata for the root span (session, user, workspace). */\nexport type TurnTraceSink = (snapshot: TurnTraceSnapshot, labels: TurnSpanAttrs) => void | Promise<void>\n\nexport interface TurnTrace {\n /** The turn's execution id in the charset the Router and Sandbox accept. Send it as `x-tangle-trace-id`. */\n readonly traceId: string\n readonly executionId: string\n readonly startedAt: number\n /** The span a top-level child hangs from. */\n readonly root: TurnSpan\n /** Name the turn's execution id once it is known. Spans recorded earlier keep their times. */\n bind(executionId: string): void\n start(name: string, kind: TurnSpanKind, attrs?: TurnSpanAttrs, parent?: TurnSpan): TurnSpan\n record(name: string, kind: TurnSpanKind, startMs: number, endMs: number, attrs?: TurnSpanAttrs, parent?: TurnSpan): TurnSpan\n /** Run `work` inside a span; the span ends when it settles, failed if it throws. */\n measure<T>(name: string, kind: TurnSpanKind, work: (span: TurnSpan) => Promise<T> | T, attrs?: TurnSpanAttrs, parent?: TurnSpan): Promise<T>\n /**\n * Note that the turn's first visible text reached the member. The chat route calls it on the first text event of\n * either lane; a product that owns its turn calls it itself. Only the first call counts. The summary's\n * `firstTextMs` then reads from the request, so it holds admission, the box or the Router, and the model.\n */\n markFirstText(at?: number): void\n /** Read the current numbers without ending the trace. */\n summary(now?: number): TurnTraceSummary\n /** Read the spans recorded so far without ending the trace; an open span reads as ending at `now`. */\n spans(now?: number): TurnSpanRecord[]\n /** End the trace: open spans close at `endedAt`, and later spans are refused. A second call returns the first result. */\n finish(outcome?: { error?: unknown; endedAt?: number }): TurnTraceSnapshot\n}\n\nexport interface CreateTurnTraceOptions {\n /** Epoch ms the turn began (default now). A route passes its request time so admission is inside the trace. */\n startedAt?: number\n executionId?: string\n now?: () => number\n /** Most spans one turn keeps (default 1000); the rest are counted as dropped. */\n maxSpans?: number\n /** Live counter captured by the server turn owner; no Node dependency in the recorder. */\n d1QueryCounter?: { readonly queries: number }\n}\n\nconst TRACE_ID_PATTERN = /^[\\w-]{8,200}$/\nconst MAX_ATTRS = 48\nconst MAX_ATTR_STRING = 200\n\n/** True when the Router and the Sandbox API keep this id as a `x-tangle-trace-id`. */\nexport function isTraceId(value: string): boolean {\n return TRACE_ID_PATTERN.test(value)\n}\n\n/**\n * The turn's execution id as a trace id. Execution ids carry `:` (`app:session:turn`),\n * which the Router drops from `x-tangle-trace-id`, so every character outside\n * `[A-Za-z0-9_-]` becomes `_`. An id already in the charset is returned as it is.\n */\nexport function turnTraceId(executionId: string): string {\n // An id in the charset is the caller's own, whatever its length (the Router drops one under 8 characters; it is not rewritten here).\n if (/^[\\w-]{1,200}$/.test(executionId)) return executionId\n const id = executionId.replace(/[^\\w-]/g, '_').slice(0, 200)\n return id.length >= 8 ? id : id.padEnd(8, '_')\n}\n\nfunction randomHex(bytes: number): string {\n const out = new Uint8Array(bytes)\n if (typeof globalThis.crypto?.getRandomValues === 'function') globalThis.crypto.getRandomValues(out)\n else for (let i = 0; i < bytes; i++) out[i] = Math.floor(Math.random() * 256)\n return Array.from(out, (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\nfunction boundedAttrs(attrs: TurnSpanAttrs): TurnSpanAttrs {\n const out: TurnSpanAttrs = {}\n let count = 0\n for (const [key, value] of Object.entries(attrs)) {\n if (count >= MAX_ATTRS) break\n if (typeof value === 'number' && !Number.isFinite(value)) continue\n out[key.slice(0, 80)] = typeof value === 'string' ? value.slice(0, MAX_ATTR_STRING) : value\n count++\n }\n return out\n}\n\nfunction errorText(error: unknown): string {\n if (error instanceof Error) return (error.name === 'Error' ? error.message : `${error.name}: ${error.message}`).slice(0, MAX_ATTR_STRING)\n return String(error).slice(0, MAX_ATTR_STRING)\n}\n\nconst zeroKinds = (): Record<TurnSpanKind, number> => ({\n admission: 0, router: 0, model: 0, network: 0, tool: 0, sandbox: 0, persist: 0, other: 0,\n})\n\nconst round1 = (value: number) => Math.round(value * 10) / 10\n\n/**\n * Coverage and the per-kind split for a set of spans over `[startMs, endMs]`.\n * Exported for a reader that holds the spans of a finished trace.\n */\nexport function summarizeTurnSpans(\n spans: readonly Pick<TurnSpanRecord, 'spanId' | 'parentSpanId' | 'kind' | 'name' | 'startMs' | 'endMs'>[],\n rootSpanId: string,\n startMs: number,\n endMs: number,\n traceId: string,\n dropped = 0,\n): TurnTraceSummary {\n const wallMs = Math.max(0, endMs - startMs)\n const parent = new Map(spans.map((span) => [span.spanId, span.parentSpanId]))\n const depthOf = (id: string): number => {\n let depth = 0\n for (let at = parent.get(id); at !== undefined && at !== rootSpanId; at = parent.get(at)) {\n depth++\n if (depth > 64) break\n }\n return depth\n }\n const clipped = spans\n .map((span) => ({ span, start: Math.max(startMs, span.startMs), end: Math.min(endMs, span.endMs), depth: depthOf(span.spanId) }))\n .filter((entry) => entry.end > entry.start)\n const points = [...new Set([startMs, endMs, ...clipped.flatMap((entry) => [entry.start, entry.end])])].sort((a, b) => a - b)\n const byKind = zeroKinds()\n let coveredMs = 0\n let largestGapMs = 0\n let gap = 0\n for (let i = 0; i + 1 < points.length; i++) {\n const from = points[i]!\n const to = points[i + 1]!\n let deepest: (typeof clipped)[number] | undefined\n for (const entry of clipped) {\n if (entry.start <= from && entry.end >= to && (!deepest || entry.depth > deepest.depth || (entry.depth === deepest.depth && entry.start > deepest.start))) deepest = entry\n }\n if (deepest) {\n byKind[deepest.span.kind] += to - from\n coveredMs += to - from\n gap = 0\n } else {\n gap += to - from\n largestGapMs = Math.max(largestGapMs, gap)\n }\n }\n for (const kind of TURN_SPAN_KINDS) byKind[kind] = round1(byKind[kind])\n return {\n traceId,\n wallMs: round1(wallMs),\n coveredMs: round1(coveredMs),\n coveragePct: wallMs > 0 ? round1((coveredMs / wallMs) * 100) : 0,\n uncoveredMs: round1(wallMs - coveredMs),\n largestGapMs: round1(largestGapMs),\n byKind,\n spans: spans.length,\n modelCalls: spans.filter((span) => span.name === 'model.call').length,\n toolCalls: spans.filter((span) => span.name === 'tool.call').length,\n dropped,\n }\n}\n\nexport function createTurnTrace(options: CreateTurnTraceOptions = {}): TurnTrace {\n const now = options.now ?? Date.now\n const startedAt = options.startedAt ?? now()\n const maxSpans = options.maxSpans ?? 1000\n const rootId = randomHex(8)\n let executionId = options.executionId ?? `pending_${randomHex(6)}`\n let traceId = turnTraceId(executionId)\n const records = new Map<string, TurnSpanRecord>()\n const open = new Set<string>()\n let dropped = 0\n let finished: TurnTraceSnapshot | undefined\n let firstTextAt: number | undefined\n\n // A refused or late span still returns a handle, so instrumentation never branches on the trace's state.\n const inert = (id: string): TurnSpan => {\n const handle: TurnSpan = {\n id,\n set: () => handle,\n end: () => {},\n child: () => inert(rootId),\n record: () => inert(rootId),\n }\n return handle\n }\n\n const handleFor = (id: string): TurnSpan => {\n const handle: TurnSpan = {\n id,\n set(attrs) {\n const record = records.get(id)\n if (record && !finished) record.attrs = boundedAttrs({ ...record.attrs, ...attrs })\n return handle\n },\n end(attrs, error) {\n const record = records.get(id)\n if (!record || !open.has(id) || finished) return\n open.delete(id)\n record.endMs = Math.max(record.startMs, now())\n if (attrs) record.attrs = boundedAttrs({ ...record.attrs, ...attrs })\n if (error !== undefined) record.error = errorText(error)\n },\n child: (name, kind, attrs) => trace.start(name, kind, attrs, handle),\n record: (name, kind, start, end, attrs) => trace.record(name, kind, start, end, attrs, handle),\n }\n return handle\n }\n\n const add = (name: string, kind: TurnSpanKind, startMs: number, endMs: number | undefined, attrs: TurnSpanAttrs | undefined, parent: TurnSpan | undefined): TurnSpan => {\n if (finished) return inert(rootId)\n if (records.size >= maxSpans) {\n dropped++\n return inert(rootId)\n }\n const spanId = randomHex(8)\n records.set(spanId, {\n spanId,\n parentSpanId: parent && parent.id !== spanId ? parent.id : rootId,\n name: name.slice(0, 80),\n kind,\n startMs,\n endMs: endMs ?? startMs,\n attrs: attrs ? boundedAttrs(attrs) : {},\n })\n if (endMs === undefined) open.add(spanId)\n return handleFor(spanId)\n }\n\n const rootHandle: TurnSpan = {\n id: rootId,\n set: () => rootHandle,\n end: () => {},\n child: (name, kind, attrs) => trace.start(name, kind, attrs),\n record: (name, kind, start, end, attrs) => trace.record(name, kind, start, end, attrs),\n }\n\n const withMeasurements = (summary: TurnTraceSummary): TurnTraceSummary => ({\n ...summary,\n ...(firstTextAt === undefined ? {} : { firstTextMs: round1(firstTextAt - startedAt) }),\n ...(options.d1QueryCounter === undefined ? {} : { d1Queries: options.d1QueryCounter.queries }),\n })\n\n const trace: TurnTrace = {\n get traceId() { return traceId },\n get executionId() { return executionId },\n startedAt,\n root: rootHandle,\n bind(id) {\n executionId = id\n traceId = turnTraceId(id)\n },\n start: (name, kind, attrs, parent) => add(name, kind, now(), undefined, attrs, parent),\n record: (name, kind, startMs, endMs, attrs, parent) => add(name, kind, startMs, Math.max(startMs, endMs), attrs, parent),\n async measure(name, kind, work, attrs, parent) {\n const span = trace.start(name, kind, attrs, parent)\n try {\n const result = await work(span)\n span.end()\n return result\n } catch (error) {\n span.end(undefined, error)\n throw error\n }\n },\n markFirstText(at) {\n if (finished || firstTextAt !== undefined) return\n firstTextAt = Math.max(startedAt, at ?? now())\n },\n summary(at) {\n if (finished) return finished.summary\n const end = at ?? now()\n return withMeasurements(summarizeTurnSpans(trace.spans(end), rootId, startedAt, end, traceId, dropped))\n },\n spans(at) {\n const end = at ?? finished?.endedAt ?? now()\n return [...records.values()].map((record) => open.has(record.spanId) ? { ...record, endMs: end } : { ...record })\n },\n finish(outcome) {\n if (finished) return finished\n const endedAt = Math.max(startedAt, outcome?.endedAt ?? now())\n for (const id of open) {\n const record = records.get(id)!\n record.endMs = Math.max(record.startMs, endedAt)\n record.unfinished = true\n }\n open.clear()\n const spans = [...records.values()].sort((a, b) => a.startMs - b.startMs)\n finished = {\n traceId,\n rootSpanId: rootId,\n executionId,\n startedAt,\n endedAt,\n spans,\n summary: withMeasurements(summarizeTurnSpans(spans, rootId, startedAt, endedAt, traceId, dropped)),\n status: outcome?.error === undefined ? 'ok' : 'error',\n ...(outcome?.error === undefined ? {} : { error: errorText(outcome.error) }),\n }\n return finished\n },\n }\n return trace\n}\n"],"mappings":";AA2BO,IAAM,kBAA2C,CAAC,aAAa,UAAU,SAAS,WAAW,QAAQ,WAAW,WAAW,OAAO;AA+GzI,IAAM,mBAAmB;AACzB,IAAM,YAAY;AAClB,IAAM,kBAAkB;AAGjB,SAAS,UAAU,OAAwB;AAChD,SAAO,iBAAiB,KAAK,KAAK;AACpC;AAOO,SAAS,YAAY,aAA6B;AAEvD,MAAI,iBAAiB,KAAK,WAAW,EAAG,QAAO;AAC/C,QAAM,KAAK,YAAY,QAAQ,WAAW,GAAG,EAAE,MAAM,GAAG,GAAG;AAC3D,SAAO,GAAG,UAAU,IAAI,KAAK,GAAG,OAAO,GAAG,GAAG;AAC/C;AAEA,SAAS,UAAU,OAAuB;AACxC,QAAM,MAAM,IAAI,WAAW,KAAK;AAChC,MAAI,OAAO,WAAW,QAAQ,oBAAoB,WAAY,YAAW,OAAO,gBAAgB,GAAG;AAAA,MAC9F,UAAS,IAAI,GAAG,IAAI,OAAO,IAAK,KAAI,CAAC,IAAI,KAAK,MAAM,KAAK,OAAO,IAAI,GAAG;AAC5E,SAAO,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,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W,KAAK,SAAS,OAAO,CAAC;AAAA,IACxG;AAAA,IACA,MAAM,IAAI;AACR,YAAM,MAAM,MAAM,UAAU,WAAW,IAAI;AAC3C,aAAO,CAAC,GAAG,QAAQ,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,KAAK,IAAI,OAAO,MAAM,IAAI,EAAE,GAAG,QAAQ,OAAO,IAAI,IAAI,EAAE,GAAG,OAAO,CAAC;AAAA,IAClH;AAAA,IACA,OAAO,SAAS;AACd,UAAI,SAAU,QAAO;AACrB,YAAM,UAAU,KAAK,IAAI,WAAW,SAAS,WAAW,IAAI,CAAC;AAC7D,iBAAW,MAAM,MAAM;AACrB,cAAM,SAAS,QAAQ,IAAI,EAAE;AAC7B,eAAO,QAAQ,KAAK,IAAI,OAAO,SAAS,OAAO;AAC/C,eAAO,aAAa;AAAA,MACtB;AACA,WAAK,MAAM;AACX,YAAM,QAAQ,CAAC,GAAG,QAAQ,OAAO,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,OAAO;AACxE,iBAAW;AAAA,QACT;AAAA,QACA,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,iBAAiB,mBAAmB,OAAO,QAAQ,WAAW,SAAS,SAAS,OAAO,CAAC;AAAA,QACjG,QAAQ,SAAS,UAAU,SAAY,OAAO;AAAA,QAC9C,GAAI,SAAS,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,UAAU,QAAQ,KAAK,EAAE;AAAA,MAC5E;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readCookieValue,
|
|
3
3
|
serializeCookie
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7HZCFG2A.js";
|
|
5
5
|
|
|
6
6
|
// src/web/message-groups.ts
|
|
7
7
|
function groupConversationMessages(items = []) {
|
|
@@ -111,4 +111,4 @@ export {
|
|
|
111
111
|
readFirstTouchAcquisition,
|
|
112
112
|
firstTouchAcquisitionCookie
|
|
113
113
|
};
|
|
114
|
-
//# sourceMappingURL=chunk-
|
|
114
|
+
//# sourceMappingURL=chunk-FENBDSIW.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/design-canvas-react/lazy.tsx
|
|
2
2
|
import { lazy } from "react";
|
|
3
3
|
var DesignCanvasLazy = lazy(
|
|
4
|
-
() => import("./DesignCanvasEditor-
|
|
4
|
+
() => import("./DesignCanvasEditor-G5O75CUT.js").then((m) => ({ default: m.DesignCanvasEditor }))
|
|
5
5
|
);
|
|
6
6
|
var DesignCanvasChromeLazy = lazy(
|
|
7
|
-
() => import("./DesignCanvas-
|
|
7
|
+
() => import("./DesignCanvas-SNE3H3TH.js").then((m) => ({ default: m.DesignCanvas }))
|
|
8
8
|
);
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
DesignCanvasLazy,
|
|
12
12
|
DesignCanvasChromeLazy
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=chunk-
|
|
14
|
+
//# sourceMappingURL=chunk-I57SNMX4.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runRouterTurn
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XAD4VTP4.js";
|
|
4
4
|
|
|
5
5
|
// src/runtime/protected-model.ts
|
|
6
6
|
import {
|
|
@@ -219,4 +219,4 @@ export {
|
|
|
219
219
|
createRouterProtectedModelPort,
|
|
220
220
|
runProtectedRouterTurn
|
|
221
221
|
};
|
|
222
|
-
//# sourceMappingURL=chunk-
|
|
222
|
+
//# sourceMappingURL=chunk-ILAQQYVL.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
assertMediaUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HZCFG2A.js";
|
|
4
4
|
|
|
5
5
|
// src/design-canvas/model.ts
|
|
6
6
|
var SCENE_SCHEMA_VERSION = 1;
|
|
@@ -997,4 +997,4 @@ export {
|
|
|
997
997
|
scalePageForChannelPreset,
|
|
998
998
|
bleedAwareExportRect
|
|
999
999
|
};
|
|
1000
|
-
//# sourceMappingURL=chunk-
|
|
1000
|
+
//# sourceMappingURL=chunk-JK7R7BZQ.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// src/launch-invariants/d1-query-count.ts
|
|
2
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
+
var scope = new AsyncLocalStorage();
|
|
4
|
+
function withD1QueryCount(work) {
|
|
5
|
+
return scope.run({ queries: 0 }, work);
|
|
6
|
+
}
|
|
7
|
+
function currentD1QueryCounter() {
|
|
8
|
+
return scope.getStore();
|
|
9
|
+
}
|
|
10
|
+
function tallyD1Query() {
|
|
11
|
+
const counter = scope.getStore();
|
|
12
|
+
if (counter) counter.queries += 1;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
withD1QueryCount,
|
|
17
|
+
currentD1QueryCounter,
|
|
18
|
+
tallyD1Query
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=chunk-MM6RLOXF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/launch-invariants/d1-query-count.ts"],"sourcesContent":["/**\n * AsyncLocalStorage counter ported from tangle-network/creative-agent,\n * commit 8e0d55449f6662dda3cfd5bbe75388d792a5cea3,\n * src/lib/.server/db/query-count.ts.\n * Source license: no license declared in that private repository. This port is\n * distributed under agent-app's MIT license (LICENSE).\n * The binding proxy remains owned by withD1LimitAlarms.\n */\nimport { AsyncLocalStorage } from 'node:async_hooks'\n\n/** Round trips: batch = 1; first/all/raw/run = 1 each, including failed calls. */\nexport interface D1QueryCounter { queries: number }\nconst scope = new AsyncLocalStorage<D1QueryCounter>()\n\n/** Run work in a fresh counter scope. Async descendants retain it after work returns. */\nexport function withD1QueryCount<T>(work: () => T): T {\n return scope.run({ queries: 0 }, work)\n}\n\n/** The current scope's counter, shared with the turn trace and product phase logs. */\nexport function currentD1QueryCounter(): D1QueryCounter | undefined {\n return scope.getStore()\n}\n\nexport function tallyD1Query(): void {\n const counter = scope.getStore()\n if (counter) counter.queries += 1\n}\n"],"mappings":";AAQA,SAAS,yBAAyB;AAIlC,IAAM,QAAQ,IAAI,kBAAkC;AAG7C,SAAS,iBAAoB,MAAkB;AACpD,SAAO,MAAM,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI;AACvC;AAGO,SAAS,wBAAoD;AAClE,SAAO,MAAM,SAAS;AACxB;AAEO,SAAS,eAAqB;AACnC,QAAM,UAAU,MAAM,SAAS;AAC/B,MAAI,QAAS,SAAQ,WAAW;AAClC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseJsonObjectBody
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HZCFG2A.js";
|
|
4
4
|
|
|
5
5
|
// src/hosted-agent/application.ts
|
|
6
6
|
import {
|
|
@@ -121,4 +121,4 @@ export {
|
|
|
121
121
|
publicApplicationSenderVerification,
|
|
122
122
|
createApplicationLineHandler
|
|
123
123
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-MY3EJJ6Y.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
clearCookieHeader,
|
|
6
6
|
readCookieValue,
|
|
7
7
|
serializeCookie
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-7HZCFG2A.js";
|
|
9
9
|
|
|
10
10
|
// src/platform/sso.ts
|
|
11
11
|
var DEFAULT_STATE_TTL_SECONDS = 600;
|
|
@@ -502,4 +502,4 @@ export {
|
|
|
502
502
|
createAdminGuard,
|
|
503
503
|
assertBillableBalance
|
|
504
504
|
};
|
|
505
|
-
//# sourceMappingURL=chunk-
|
|
505
|
+
//# sourceMappingURL=chunk-NMSAZFRL.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
DesignCanvas,
|
|
5
5
|
PlusGlyph,
|
|
6
6
|
ShapesGlyph
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3KXYYAY4.js";
|
|
8
8
|
import {
|
|
9
9
|
lightTheme
|
|
10
10
|
} from "./chunk-UTF7H6BK.js";
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
marqueeSelect,
|
|
21
21
|
resolveExportParams,
|
|
22
22
|
resolveNodeCachePixelRatio
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-X556WVBG.js";
|
|
24
24
|
import {
|
|
25
25
|
addElementCommand,
|
|
26
26
|
createSceneCommandStack,
|
|
@@ -29,13 +29,13 @@ import {
|
|
|
29
29
|
multiSetAttrsCommand,
|
|
30
30
|
setAttrsCommand,
|
|
31
31
|
ungroupElementCommand
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-VBKP2NLI.js";
|
|
33
33
|
import {
|
|
34
34
|
SCENE_SCHEMA_VERSION,
|
|
35
35
|
boundsIntersect,
|
|
36
36
|
elementAabb,
|
|
37
37
|
findElement
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-JK7R7BZQ.js";
|
|
39
39
|
|
|
40
40
|
// src/design-canvas-react/components/Workspace.tsx
|
|
41
41
|
import {
|
|
@@ -1937,4 +1937,4 @@ export {
|
|
|
1937
1937
|
Workspace,
|
|
1938
1938
|
DesignCanvasEditor
|
|
1939
1939
|
};
|
|
1940
|
-
//# sourceMappingURL=chunk-
|
|
1940
|
+
//# sourceMappingURL=chunk-P2NJIDLE.js.map
|
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
createThrottledAlertSink,
|
|
9
9
|
createWebhookAlertSink
|
|
10
10
|
} from "./chunk-CD2LQXY6.js";
|
|
11
|
+
import {
|
|
12
|
+
tallyD1Query
|
|
13
|
+
} from "./chunk-MM6RLOXF.js";
|
|
11
14
|
|
|
12
15
|
// src/launch-invariants/schedule.ts
|
|
13
16
|
function createScheduledDispatch(options) {
|
|
@@ -361,6 +364,7 @@ function withD1LimitAlarms(d1, alarms, options = {}) {
|
|
|
361
364
|
if (key === "bind") return (...params) => statement(value.apply(stmt, params), sql);
|
|
362
365
|
if (key === "all" || key === "raw" || key === "run" || key === "first") {
|
|
363
366
|
return async (...args) => {
|
|
367
|
+
tallyD1Query();
|
|
364
368
|
const result = await value.apply(stmt, args);
|
|
365
369
|
if (key !== "first") await observe(sql, result);
|
|
366
370
|
return result;
|
|
@@ -380,6 +384,7 @@ function withD1LimitAlarms(d1, alarms, options = {}) {
|
|
|
380
384
|
}
|
|
381
385
|
if (key === "batch" && typeof value === "function") {
|
|
382
386
|
return async (statements) => {
|
|
387
|
+
tallyD1Query();
|
|
383
388
|
const results = await value.call(binding, statements.map((stmt) => unwrapped.get(stmt) ?? stmt));
|
|
384
389
|
for (const result of results ?? []) await observe("batch", result);
|
|
385
390
|
return results;
|
|
@@ -435,4 +440,4 @@ export {
|
|
|
435
440
|
PASTED_CODE_SAMPLES,
|
|
436
441
|
isEdgeBlock
|
|
437
442
|
};
|
|
438
|
-
//# sourceMappingURL=chunk-
|
|
443
|
+
//# sourceMappingURL=chunk-S27DKRI6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/launch-invariants/schedule.ts","../src/launch-invariants/limit-alarms.ts","../src/launch-invariants/pasted-code.ts"],"sourcesContent":["/**\n * Scheduled jobs that cannot take each other down.\n *\n * On 2026-10-10 at 21:00Z GTM's turn health ran out of memory while the hourly\n * sweeps shared one scheduled run, and none of the eight queued after it ran.\n * Here each scheduled invocation runs exactly one job. A cron can carry a\n * minute list (`0,1,2 * * * *`) with one job per minute, so a Worker keeps a\n * few trigger expressions while every job gets its own invocation, its own\n * memory and its own failure.\n *\n * Cloudflare hands the handler the configured string verbatim as `event.cron`,\n * so dispatch is exact-string; a tick no entry handles is reported as\n * unhandled instead of silently running nothing. {@link checkIsolatedJobs}\n * holds the table against the deployment's configured crons.\n */\nimport { LAUNCH_BUDGETS, type InvariantVerdict } from './catalog.js'\n\n/** One cron expression and the job it runs, or one job per listed minute. */\nexport type ScheduleEntry =\n | { cron: string; job: string }\n | { cron: string; minutes: Readonly<Record<number, string>> }\n\n/** One scheduled invocation: the cron, the minute for a minute-list entry, and the job it runs. */\nexport interface ScheduleSlot {\n cron: string\n minute?: number\n job: string\n}\n\nexport interface ScheduledJobInput<Ctx> {\n cron: string\n scheduledTime: Date\n context: Ctx\n /** 1 for the first try. */\n attempt: number\n}\n\nexport type ScheduledJob<Ctx> = (input: ScheduledJobInput<Ctx>) => Promise<unknown>\n\nexport interface ScheduledDispatchOptions<Ctx> {\n entries: readonly ScheduleEntry[]\n jobs: Readonly<Record<string, ScheduledJob<Ctx>>>\n /** Waits before each retry of a failed job; empty (the default) runs a job once. Jobs that retry must be idempotent. */\n retryDelaysMs?: readonly number[]\n log?: {\n info(message: string, detail?: Record<string, unknown>): void\n error(message: string, detail?: Record<string, unknown>): void\n }\n /** Tests pass a no-op. */\n sleep?: (ms: number) => Promise<void>\n}\n\nexport interface ScheduledJobOutcome {\n job: string\n ok: boolean\n attempts: number\n durationMs: number\n error?: string\n}\n\nexport interface ScheduledDispatchResult {\n handled: boolean\n job: string | null\n /** Settles when the job's last attempt ends; never rejects. */\n done: Promise<ScheduledJobOutcome | null>\n}\n\nexport interface ScheduledDispatch<Ctx> {\n readonly entries: readonly ScheduleEntry[]\n /** Every invocation the table can make. */\n slots(): ScheduleSlot[]\n /** The job a tick runs, or null when no entry handles it. */\n jobFor(cron: string, scheduledTime: number | Date): string | null\n /**\n * Run the tick's one job. With `waitUntil` the job runs in the background and\n * this returns at once; without it, this waits for the job.\n */\n dispatch(\n event: { cron: string; scheduledTime: number | Date },\n context: Ctx,\n waitUntil?: (promise: Promise<unknown>) => void,\n ): Promise<ScheduledDispatchResult>\n}\n\nexport function createScheduledDispatch<Ctx>(options: ScheduledDispatchOptions<Ctx>): ScheduledDispatch<Ctx> {\n const problems = validateEntries(options.entries, Object.keys(options.jobs))\n if (problems.length) throw new Error(`scheduled dispatch: ${problems.join('; ')}`)\n const byCron = new Map(options.entries.map((entry) => [entry.cron, entry]))\n const retryDelaysMs = options.retryDelaysMs ?? []\n const log = options.log ?? {\n info: (message: string, detail?: Record<string, unknown>) => console.log(message, detail ?? ''),\n error: (message: string, detail?: Record<string, unknown>) => console.error(message, detail ?? ''),\n }\n const sleep = options.sleep ?? ((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)))\n\n function jobFor(cron: string, scheduledTime: number | Date): string | null {\n const entry = byCron.get(cron)\n if (!entry) return null\n if ('job' in entry) return entry.job\n const minute = new Date(scheduledTime).getUTCMinutes()\n return entry.minutes[minute] ?? null\n }\n\n async function runJob(job: string, cron: string, scheduledTime: Date, context: Ctx): Promise<ScheduledJobOutcome> {\n const run = options.jobs[job]!\n const started = Date.now()\n let lastError = ''\n for (let attempt = 1; attempt <= retryDelaysMs.length + 1; attempt += 1) {\n try {\n await run({ cron, scheduledTime, context, attempt })\n return { job, ok: true, attempts: attempt, durationMs: Date.now() - started }\n } catch (error) {\n lastError = error instanceof Error ? error.message : String(error)\n const delay = retryDelaysMs[attempt - 1]\n if (delay === undefined) break\n log.error(`[scheduled] ${job} failed; retrying`, { attempt, error: lastError })\n await sleep(delay)\n }\n }\n log.error(`[scheduled] ${job} failed`, { attempts: retryDelaysMs.length + 1, error: lastError })\n return { job, ok: false, attempts: retryDelaysMs.length + 1, durationMs: Date.now() - started, error: lastError }\n }\n\n return {\n entries: options.entries,\n slots: () => slotsOf(options.entries),\n jobFor,\n async dispatch(event, context, waitUntil) {\n const scheduledTime = new Date(event.scheduledTime)\n const job = jobFor(event.cron, scheduledTime)\n if (!job) {\n log.error(`[scheduled] no job handles cron \"${event.cron}\" at minute ${scheduledTime.getUTCMinutes()}; the configured crons and the schedule disagree`)\n return { handled: false, job: null, done: Promise.resolve(null) }\n }\n const done = runJob(job, event.cron, scheduledTime, context)\n if (waitUntil) waitUntil(done)\n else await done\n return { handled: true, job, done }\n },\n }\n}\n\n/** Every invocation a schedule table can make. */\nexport function slotsOf(entries: readonly ScheduleEntry[]): ScheduleSlot[] {\n return entries.flatMap((entry) => 'job' in entry\n ? [{ cron: entry.cron, job: entry.job }]\n : Object.entries(entry.minutes).map(([minute, job]) => ({ cron: entry.cron, minute: Number(minute), job })))\n}\n\nfunction validateEntries(entries: readonly ScheduleEntry[], jobNames: readonly string[]): string[] {\n const problems: string[] = []\n const known = new Set(jobNames)\n const seen = new Set<string>()\n for (const entry of entries) {\n if (seen.has(entry.cron)) problems.push(`cron \"${entry.cron}\" is listed twice`)\n seen.add(entry.cron)\n const fields = entry.cron.trim().split(/\\s+/)\n if (fields.length !== 5) problems.push(`cron \"${entry.cron}\" does not have five fields`)\n for (const slot of slotsOf([entry])) {\n if (!known.has(slot.job)) problems.push(`cron \"${entry.cron}\" names job \"${slot.job}\", which is not defined`)\n }\n if ('minutes' in entry) {\n const listed = minuteList(fields[0] ?? '')\n const mapped = Object.keys(entry.minutes).map(Number).sort((a, b) => a - b)\n if (!listed) problems.push(`cron \"${entry.cron}\" maps jobs by minute, so its minute field must be a list of minutes`)\n else if (listed.join(',') !== mapped.join(',')) {\n problems.push(`cron \"${entry.cron}\" lists minutes ${listed.join(',')} but maps jobs to ${mapped.join(',')}`)\n }\n }\n }\n return problems\n}\n\n/** The minutes of a plain minute list (`5` or `0,15,30`), or null for any other form. */\nfunction minuteList(field: string): number[] | null {\n if (!/^\\d{1,2}(,\\d{1,2})*$/.test(field)) return null\n const minutes = field.split(',').map(Number)\n if (minutes.some((minute) => minute > 59)) return null\n return [...new Set(minutes)].sort((a, b) => a - b)\n}\n\n// ── cron analysis ────────────────────────────────────────────────────────────\n\nfunction expandField(field: string, min: number, max: number): Set<number> | null {\n const values = new Set<number>()\n for (const part of field.split(',')) {\n const match = /^(\\*|\\d+(?:-\\d+)?)(?:\\/(\\d+))?$/.exec(part)\n if (!match) return null\n const [, range, stepText] = match\n const step = stepText ? Number(stepText) : 1\n if (!(step >= 1)) return null\n let lo = min\n let hi = max\n if (range !== '*') {\n const [a, b] = range!.split('-').map(Number)\n lo = a!\n hi = b ?? (stepText ? max : a!)\n }\n if (lo < min || hi > max || lo > hi) return null\n for (let value = lo; value <= hi; value += step) values.add(value)\n }\n return values\n}\n\n/**\n * The minutes of the day (0–1439, UTC) a cron fires, or null when it does not\n * fire every day (a day-of-month, month or weekday restriction) or cannot be read.\n */\nexport function cronDailyFirings(cron: string): Set<number> | null {\n const fields = cron.trim().split(/\\s+/)\n if (fields.length !== 5) return null\n const [minuteField, hourField, dayField, monthField, weekdayField] = fields as [string, string, string, string, string]\n if (dayField !== '*' || monthField !== '*' || (weekdayField !== '*' && weekdayField !== '?')) return null\n const minutes = expandField(minuteField, 0, 59)\n const hours = expandField(hourField, 0, 23)\n if (!minutes || !hours) return null\n const firings = new Set<number>()\n for (const hour of hours) for (const minute of minutes) firings.add(hour * 60 + minute)\n return firings\n}\n\n/** The longest wait, in minutes, between consecutive firings over a day, or null when they do not fire daily. */\nexport function longestGapMinutes(firings: Iterable<number>): number | null {\n const sorted = [...new Set(firings)].sort((a, b) => a - b)\n if (sorted.length === 0) return null\n let gap = sorted[0]! + 1440 - sorted[sorted.length - 1]!\n for (let index = 1; index < sorted.length; index += 1) gap = Math.max(gap, sorted[index]! - sorted[index - 1]!)\n return gap\n}\n\n/** The cron expressions a wrangler config declares, top level and per environment. */\nexport interface WranglerCrons {\n top: string[]\n envs: Record<string, string[]>\n}\n\n/** Read `[triggers] crons` (and `[env.<name>.triggers]`) from wrangler.toml, or `triggers.crons` from wrangler.json(c). */\nexport function parseWranglerCrons(source: string, format: 'toml' | 'json'): WranglerCrons {\n return format === 'json' ? parseJsonCrons(source) : parseTomlCrons(source)\n}\n\nfunction parseTomlCrons(source: string): WranglerCrons {\n const result: WranglerCrons = { top: [], envs: {} }\n let table = ''\n let collecting: string[] | null = null\n let buffer = ''\n for (const raw of source.split('\\n')) {\n const line = stripTomlComment(raw)\n if (collecting) {\n buffer += ` ${line}`\n if (line.includes(']')) {\n collecting.push(...quoted(buffer))\n collecting = null\n buffer = ''\n }\n continue\n }\n const header = /^\\s*\\[([^\\[\\]]+)\\]\\s*$/.exec(line)\n if (header) {\n table = header[1]!.trim()\n continue\n }\n const assignment = /^\\s*crons\\s*=\\s*(.*)$/.exec(line)\n if (!assignment) continue\n const envName = /^env\\.([^.]+)\\.triggers$/.exec(table)?.[1]\n const target = table === 'triggers' ? result.top : envName ? (result.envs[envName] ??= []) : null\n if (!target) continue\n const rest = assignment[1]!\n if (rest.includes(']')) target.push(...quoted(rest))\n else {\n collecting = target\n buffer = rest\n }\n }\n return result\n}\n\nfunction stripTomlComment(line: string): string {\n let quote: string | null = null\n for (let index = 0; index < line.length; index += 1) {\n const char = line[index]!\n if (quote) {\n if (char === quote) quote = null\n } else if (char === '\"' || char === \"'\") quote = char\n else if (char === '#') return line.slice(0, index)\n }\n return line\n}\n\nfunction quoted(text: string): string[] {\n return [...text.matchAll(/\"([^\"]*)\"|'([^']*)'/g)].map((match) => match[1] ?? match[2] ?? '')\n}\n\nfunction parseJsonCrons(source: string): WranglerCrons {\n const config = JSON.parse(stripJsonComments(source)) as {\n triggers?: { crons?: string[] }\n env?: Record<string, { triggers?: { crons?: string[] } }>\n }\n return {\n top: [...(config.triggers?.crons ?? [])],\n envs: Object.fromEntries(Object.entries(config.env ?? {})\n .filter(([, env]) => Array.isArray(env.triggers?.crons))\n .map(([name, env]) => [name, [...env.triggers!.crons!]])),\n }\n}\n\nfunction stripJsonComments(source: string): string {\n let out = ''\n let inString = false\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]!\n const next = source[index + 1]\n if (inString) {\n out += char\n if (char === '\\\\') out += source[++index] ?? ''\n else if (char === '\"') inString = false\n continue\n }\n if (char === '\"') {\n inString = true\n out += char\n } else if (char === '/' && next === '/') {\n while (index < source.length && source[index] !== '\\n') index += 1\n out += '\\n'\n } else if (char === '/' && next === '*') {\n index += 2\n while (index < source.length && !(source[index] === '*' && source[index + 1] === '/')) index += 1\n index += 1\n } else out += char\n }\n return out.replace(/,(\\s*[}\\]])/g, '$1')\n}\n\n// ── the invariant ────────────────────────────────────────────────────────────\n\n/** What one scheduled invocation was observed to run. */\nexport interface ObservedSlot {\n cron: string\n minute?: number\n /** The jobs the invocation ran; exactly one passes. */\n jobs: readonly string[]\n}\n\nexport interface IsolatedJobsInput {\n /** Every cron the deployment configures, from each wrangler environment. */\n configuredCrons: readonly string[]\n /** What each invocation runs: from {@link slotsOf} for a {@link createScheduledDispatch} table, or observed by driving the app's own handler. */\n slots: readonly ObservedSlot[]\n /** Jobs that recover and settle turns; each must run at least every 15 minutes. */\n recoveryJobs: readonly string[]\n /** Default {@link LAUNCH_BUDGETS.recoveryEveryMs}. */\n everyMs?: number\n}\n\n/** One job per invocation, the table and the deployment agree, and recovery runs at least every 15 minutes. */\nexport function checkIsolatedJobs(input: IsolatedJobsInput): InvariantVerdict {\n const everyMinutes = (input.everyMs ?? LAUNCH_BUDGETS.recoveryEveryMs) / 60_000\n const findings: string[] = []\n const configured = new Set(input.configuredCrons)\n const dispatched = new Set(input.slots.map((slot) => slot.cron))\n for (const cron of configured) if (!dispatched.has(cron)) findings.push(`configured cron \"${cron}\" runs no job: no schedule entry matches it`)\n for (const cron of dispatched) if (!configured.has(cron)) findings.push(`schedule cron \"${cron}\" is not configured, so it never runs`)\n for (const slot of input.slots) {\n const where = `cron \"${slot.cron}\"${slot.minute !== undefined ? ` at minute ${slot.minute}` : ''}`\n if (slot.jobs.length !== 1) findings.push(`${where} runs ${slot.jobs.length} jobs in one invocation (${slot.jobs.join(', ') || 'none'}); one failure ends the rest`)\n }\n const byCron = new Map<string, ObservedSlot[]>()\n for (const slot of input.slots) byCron.set(slot.cron, [...(byCron.get(slot.cron) ?? []), slot])\n for (const [cron, slots] of byCron) {\n const minuteSlots = slots.filter((slot) => slot.minute !== undefined)\n if (minuteSlots.length === 0) continue\n const listed = minuteList(cron.trim().split(/\\s+/)[0] ?? '')\n const mapped = [...new Set(minuteSlots.map((slot) => slot.minute!))].sort((a, b) => a - b)\n if (!listed || listed.join(',') !== mapped.join(',')) {\n findings.push(`cron \"${cron}\" fires at minutes ${listed?.join(',') ?? '(not a minute list)'} but jobs are mapped to ${mapped.join(',')}`)\n }\n }\n if (input.recoveryJobs.length === 0) findings.push('no turn recovery or orphan settlement job is declared')\n const gaps: Record<string, number | null> = {}\n for (const job of input.recoveryJobs) {\n const firings = new Set<number>()\n let daily = false\n for (const slot of input.slots) {\n if (slot.jobs.length !== 1 || slot.jobs[0] !== job) continue\n const fires = cronDailyFirings(slot.cron)\n if (!fires) continue\n daily = true\n for (const minuteOfDay of fires) if (slot.minute === undefined || minuteOfDay % 60 === slot.minute) firings.add(minuteOfDay)\n }\n const gap = daily ? longestGapMinutes(firings) : null\n gaps[job] = gap\n if (gap === null) findings.push(`recovery job \"${job}\" is not scheduled to run every day on its own`)\n else if (gap > everyMinutes) findings.push(`recovery job \"${job}\" can wait ${gap} minutes between runs; the most is ${everyMinutes}`)\n }\n return {\n invariant: 'isolated-jobs',\n subject: 'schedule',\n pass: findings.length === 0,\n details: findings.length ? findings : [\n `${input.slots.length} scheduled invocations, one job each, across ${configured.size} configured crons`,\n ...input.recoveryJobs.map((job) => `${job} runs at least every ${gaps[job]} minutes`),\n ],\n data: { configuredCrons: [...configured], slots: input.slots.length, recoveryGapsMinutes: gaps },\n }\n}\n","/**\n * Alarms that fire at 80% of a platform limit, before the limit fails a customer.\n *\n * On 2026-10-10 GTM recorded 19 platform-limit events (Worker memory, D1,\n * sandbox disk, snapshot count, key rate) and learned of each one after it had\n * failed someone. Each resource here has a declared limit; an observation at\n * or above 80% of it delivers a warning, and at or above the limit a critical\n * alert, through the same {@link AlertSink} the turn-health sweep uses (wrap it\n * in `createThrottledAlertSink` so a hot loop pages once).\n *\n * Where each observation comes from:\n * - `d1-rows-per-query`: {@link withD1LimitAlarms} reads `meta.rows_read` on every query.\n * - `worker-memory`: workerd exposes no heap reading, so the D1 wrapper observes\n * the bytes each response returns (the reads that overran memory today), and a\n * tail consumer reports an `exceededMemory` outcome at the full limit.\n * - `sandbox-disk` and `snapshot-count`: the Sandbox SDK's box usage and snapshot list, read on a schedule.\n * - `key-rate`: the per-key request counter the operator API keeps.\n */\nimport {\n createConsoleAlertSink,\n createMemoryThrottleStore,\n createMultiAlertSink,\n createThrottledAlertSink,\n createWebhookAlertSink,\n type AlertSink,\n type TurnHealthAlert,\n} from '../turn-health/sink.js'\nimport { tallyD1Query } from './d1-query-count.js'\nimport { LAUNCH_BUDGETS } from './catalog.js'\n\nexport type LimitResource = 'worker-memory' | 'd1-rows-per-query' | 'sandbox-disk' | 'snapshot-count' | 'key-rate'\n\nexport const LIMIT_RESOURCES: readonly LimitResource[] = [\n 'worker-memory',\n 'd1-rows-per-query',\n 'sandbox-disk',\n 'snapshot-count',\n 'key-rate',\n]\n\n/** The limit of each resource, in its own unit: bytes, rows, bytes, snapshots, requests per minute. */\nexport type LimitBudgets = Readonly<Record<LimitResource, number>>\n\nconst UNITS: Readonly<Record<LimitResource, string>> = {\n 'worker-memory': 'bytes',\n 'd1-rows-per-query': 'rows',\n 'sandbox-disk': 'bytes',\n 'snapshot-count': 'snapshots',\n 'key-rate': 'requests/min',\n}\n\nexport type LimitLevel = 'ok' | 'warning' | 'critical'\n\nexport interface LimitObservation {\n resource: LimitResource\n used: number\n limit: number\n /** used / limit. */\n share: number\n level: LimitLevel\n}\n\nexport interface LimitAlarms {\n readonly budgets: LimitBudgets\n /** Record one reading; a warning or critical reading is delivered before this resolves. */\n observe(resource: LimitResource, used: number, context?: { subject?: string; detail?: string }): Promise<LimitObservation>\n}\n\nexport interface LimitAlarmOptions {\n product: string\n budgets: LimitBudgets\n sink: AlertSink\n /** Default {@link LAUNCH_BUDGETS.alarmRatio}; a product cannot raise it past the limit itself. */\n ratio?: number\n now?: () => number\n}\n\nexport function createLimitAlarms(options: LimitAlarmOptions): LimitAlarms {\n const ratio = Math.min(options.ratio ?? LAUNCH_BUDGETS.alarmRatio, 1)\n const now = options.now ?? (() => Date.now())\n for (const resource of LIMIT_RESOURCES) {\n const limit = options.budgets[resource]\n if (!(typeof limit === 'number' && limit > 0 && Number.isFinite(limit))) {\n throw new Error(`limit alarms: ${resource} needs a positive limit`)\n }\n }\n return {\n budgets: options.budgets,\n async observe(resource, used, context) {\n const limit = options.budgets[resource]\n const share = used / limit\n const level: LimitLevel = share >= 1 ? 'critical' : share >= ratio ? 'warning' : 'ok'\n const observation = { resource, used, limit, share, level }\n if (level === 'ok') return observation\n const alert: TurnHealthAlert = {\n product: options.product,\n severity: level,\n // Keyed by product and resource only, so a throttled sink pages once per resource.\n key: `limit:${options.product}:${resource}`,\n title: `${options.product}: ${resource} at ${Math.round(share * 100)}% of its limit`,\n details: [\n `${formatAmount(used, resource)} of ${formatAmount(limit, resource)} ${UNITS[resource]}`,\n ...(context?.subject ? [`in ${context.subject}`] : []),\n ...(context?.detail ? [context.detail] : []),\n ],\n data: { resource, used, limit, share, ...(context?.subject ? { subject: context.subject } : {}) },\n at: now(),\n }\n await options.sink.deliver(alert)\n return observation\n },\n }\n}\n\nfunction formatAmount(value: number, resource: LimitResource): string {\n if (UNITS[resource] === 'bytes') return `${(value / (1024 * 1024)).toFixed(1)} MB`\n return Math.round(value).toLocaleString('en-US')\n}\n\n/** The budgets every product starts from: {@link LAUNCH_BUDGETS}' platform limits. */\nexport const DEFAULT_LIMIT_BUDGETS: LimitBudgets = {\n 'worker-memory': LAUNCH_BUDGETS.workerMemoryBytes,\n 'd1-rows-per-query': LAUNCH_BUDGETS.d1RowsPerQuery,\n 'sandbox-disk': LAUNCH_BUDGETS.sandboxDiskBytes,\n 'snapshot-count': LAUNCH_BUDGETS.snapshotCount,\n 'key-rate': LAUNCH_BUDGETS.keyRatePerMinute,\n}\n\nexport interface ProductLimitAlarmOptions {\n /** The product's name in alerts, e.g. `legal`. */\n product: string\n /** The ops webhook; without one alarms go to the console only. */\n webhookUrl?: string\n /** The few budgets this product measured differently, e.g. a larger sandbox disk. */\n overrides?: Partial<LimitBudgets>\n /** Replace the default console-and-webhook sink (tests, or an app with its own alert transport). */\n sink?: AlertSink\n}\n\n/**\n * A product's limit alarms with every default in place: {@link DEFAULT_LIMIT_BUDGETS}, the console and optional webhook\n * sink, and one page per resource every {@link LAUNCH_BUDGETS.alarmRepeatHours} hours. A product passes only what it\n * measured differently; Legal, Creative, Tax and GTM each kept a 40-line copy of this before.\n */\nexport function createProductLimitAlarms(options: ProductLimitAlarmOptions): LimitAlarms {\n const sink = options.sink ?? createThrottledAlertSink(createMultiAlertSink([\n createConsoleAlertSink((message) => console.error(message)),\n ...(options.webhookUrl ? [createWebhookAlertSink({ webhookUrl: options.webhookUrl })] : []),\n ]), { store: createMemoryThrottleStore(), windowMs: LAUNCH_BUDGETS.alarmRepeatHours * 60 * 60 * 1000 })\n return createLimitAlarms({ product: options.product, budgets: { ...DEFAULT_LIMIT_BUDGETS, ...options.overrides }, sink })\n}\n\n/** The D1 surface the wrapper measures; Cloudflare `D1Database` satisfies it. */\ninterface D1Measurable {\n prepare(sql: string): unknown\n}\n\n/**\n * The D1 binding with each query's rows read and response size observed,\n * and each round trip counted inside withD1QueryCount (chat routes scope it automatically).\n * Rows read come from `meta.rows_read` (the rows D1 scanned, not only those\n * returned). The response size is estimated from three sampled rows, so the\n * wrapper never serializes a whole response: that copy would double the memory\n * of the very read it watches.\n */\nexport function withD1LimitAlarms<D extends D1Measurable>(d1: D, alarms: LimitAlarms, options: { subject?: string } = {}): D {\n const observe = (sql: string, result: unknown) => {\n const meta = (result as { meta?: { rows_read?: unknown } } | null)?.meta\n const rowsRead = typeof meta?.rows_read === 'number' ? meta.rows_read : rowsOf(result)\n const pending: Promise<unknown>[] = []\n if (rowsRead !== null) pending.push(alarms.observe('d1-rows-per-query', rowsRead, { subject: options.subject, detail: sql }))\n const results = (result as { results?: unknown[] } | null)?.results ?? (Array.isArray(result) ? result : null)\n if (results && results.length > 0) {\n pending.push(alarms.observe('worker-memory', estimatedBytes(results), { subject: options.subject, detail: `one response: ${sql}` }))\n }\n // An alarm delivery failure must not fail the query that triggered it.\n return Promise.all(pending).catch(() => undefined)\n }\n // D1's batch() takes only its own statements, so a batch is given the unwrapped ones.\n const unwrapped = new WeakMap<object, object>()\n const statement = (target: object, sql: string): object => {\n const wrapped = new Proxy(target, {\n get(stmt, key) {\n const value = Reflect.get(stmt, key) as unknown\n if (typeof value !== 'function') return value\n if (key === 'bind') return (...params: unknown[]) => statement(value.apply(stmt, params) as object, sql)\n if (key === 'all' || key === 'raw' || key === 'run' || key === 'first') {\n return async (...args: unknown[]) => {\n tallyD1Query()\n const result: unknown = await value.apply(stmt, args)\n if (key !== 'first') await observe(sql, result)\n return result\n }\n }\n return value.bind(stmt)\n },\n })\n unwrapped.set(wrapped, target)\n return wrapped\n }\n return new Proxy(d1, {\n get(binding, key) {\n const value = Reflect.get(binding, key) as unknown\n if (key === 'prepare') {\n return (sql: string) => statement((value as (sql: string) => object).call(binding, sql), sql.replace(/\\s+/g, ' ').slice(0, 160))\n }\n if (key === 'batch' && typeof value === 'function') {\n return async (statements: object[]) => {\n tallyD1Query()\n const results = await (value as (s: object[]) => Promise<unknown[]>).call(binding, statements.map((stmt) => unwrapped.get(stmt) ?? stmt))\n for (const result of results ?? []) await observe('batch', result)\n return results\n }\n }\n return typeof value === 'function' ? value.bind(binding) : value\n },\n })\n}\n\n/** The serialized size of a result set, from its first, middle and last rows. */\nexport function estimatedBytes(results: readonly unknown[]): number {\n const picks = [...new Set([0, Math.floor(results.length / 2), results.length - 1])]\n const sampled = picks.reduce((sum, index) => sum + (JSON.stringify(results[index]) ?? '').length, 0)\n return Math.round((sampled / picks.length) * results.length)\n}\n\nfunction rowsOf(result: unknown): number | null {\n if (Array.isArray(result)) return result.length\n const results = (result as { results?: unknown } | null)?.results\n return Array.isArray(results) ? results.length : null\n}\n","/**\n * Pasted code reaches the chat.\n *\n * People paste commands, SQL and markup into a chat with an agent that runs\n * code; that is the product. On 2026-10-11 a chat message containing\n * `cat /etc/passwd` sent to gtm.tangle.tools got Cloudflare's 403 \"Attention\n * Required\" page instead of the app's own answer: a managed WAF rule matched\n * the text before the request reached the Worker. These samples are what a\n * person pastes; {@link isEdgeBlock} tells an edge block from the app's own\n * response, so an in-process check (`checkChatAcceptsCode`) and a live probe\n * against the deployed route judge the same thing.\n */\n\n/** Text people paste into a chat with an agent, each of which a WAF rule may match. */\nexport const PASTED_CODE_SAMPLES: readonly { name: string; text: string }[] = [\n { name: 'file read', text: 'cat /etc/passwd' },\n { name: 'install script', text: 'curl -fsSL https://example.com/i.sh | bash' },\n { name: 'command substitution', text: 'echo $(whoami) && rm -rf /tmp/x' },\n { name: 'SQL', text: 'SELECT * FROM users WHERE id=1 OR 1=1; --' },\n { name: 'markup', text: '<script>alert(1)</script>' },\n { name: 'fenced bash block', text: 'Why does this fail?\\n\\n```bash\\nset -euo pipefail\\nsudo cat /etc/shadow | grep root\\nwget -qO- http://127.0.0.1:8080/admin\\n```' },\n { name: 'path traversal', text: 'open ../../../../etc/hosts and tell me what it maps' },\n]\n\n/**\n * Whether a response is an edge block rather than the app's own answer: a\n * `cf-mitigated` header, or Cloudflare's HTML block page (\"Attention Required\",\n * \"Sorry, you have been blocked\"). Reads a clone, so the caller keeps the body.\n */\nexport async function isEdgeBlock(response: Response): Promise<boolean> {\n if (response.headers.has('cf-mitigated')) return true\n const type = response.headers.get('content-type') ?? ''\n const server = response.headers.get('server') ?? ''\n if (!/text\\/html/i.test(type) || !/cloudflare/i.test(server)) return false\n const body = await response.clone().text().catch(() => '')\n return /Attention Required|Sorry, you have been blocked/i.test(body)\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoFO,SAAS,wBAA6B,SAAgE;AAC3G,QAAM,WAAW,gBAAgB,QAAQ,SAAS,OAAO,KAAK,QAAQ,IAAI,C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,MAAM,SAAU,QAAQ,MAAM;AAC7D;AAEA,SAAS,OAAO,QAAgC;AAC9C,MAAI,MAAM,QAAQ,MAAM,EAAG,QAAO,OAAO;AACzC,QAAM,UAAW,QAAyC;AAC1D,SAAO,MAAM,QAAQ,OAAO,IAAI,QAAQ,SAAS;AACnD;;;ACxNO,IAAM,sBAAiE;AAAA,EAC5E,EAAE,MAAM,aAAa,MAAM,kBAAkB;AAAA,EAC7C,EAAE,MAAM,kBAAkB,MAAM,6CAA6C;AAAA,EAC7E,EAAE,MAAM,wBAAwB,MAAM,kCAAkC;AAAA,EACxE,EAAE,MAAM,OAAO,MAAM,4CAA4C;AAAA,EACjE,EAAE,MAAM,UAAU,MAAM,4BAA4B;AAAA,EACpD,EAAE,MAAM,qBAAqB,MAAM,kIAAkI;AAAA,EACrK,EAAE,MAAM,kBAAkB,MAAM,sDAAsD;AACxF;AAOA,eAAsB,YAAY,UAAsC;AACtE,MAAI,SAAS,QAAQ,IAAI,cAAc,EAAG,QAAO;AACjD,QAAM,OAAO,SAAS,QAAQ,IAAI,cAAc,KAAK;AACrD,QAAM,SAAS,SAAS,QAAQ,IAAI,QAAQ,KAAK;AACjD,MAAI,CAAC,cAAc,KAAK,IAAI,KAAK,CAAC,cAAc,KAAK,MAAM,EAAG,QAAO;AACrE,QAAM,OAAO,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,MAAM,EAAE;AACzD,SAAO,mDAAmD,KAAK,IAAI;AACrE;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseJsonObjectBody
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7HZCFG2A.js";
|
|
4
4
|
import {
|
|
5
5
|
interactionFromWireRequest,
|
|
6
6
|
isSafeInteractionFieldKey,
|
|
@@ -378,4 +378,4 @@ export {
|
|
|
378
378
|
mapInteractionRespondFailure,
|
|
379
379
|
createInteractionAnswerRoute
|
|
380
380
|
};
|
|
381
|
-
//# sourceMappingURL=chunk-
|
|
381
|
+
//# sourceMappingURL=chunk-TCGZFSN5.js.map
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
applySceneOperations,
|
|
4
4
|
requireElement,
|
|
5
5
|
requirePage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-JK7R7BZQ.js";
|
|
7
7
|
|
|
8
8
|
// src/design-canvas-react/engine/command-stack.ts
|
|
9
9
|
var SCENE_COMMAND_HISTORY_LIMIT = 200;
|
|
@@ -601,4 +601,4 @@ export {
|
|
|
601
601
|
bindSlotCommand,
|
|
602
602
|
setDocumentTitleCommand
|
|
603
603
|
};
|
|
604
|
-
//# sourceMappingURL=chunk-
|
|
604
|
+
//# sourceMappingURL=chunk-VBKP2NLI.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
boundsIntersect,
|
|
5
5
|
elementAabb,
|
|
6
6
|
scaleForPreset
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-JK7R7BZQ.js";
|
|
8
8
|
|
|
9
9
|
// src/design-canvas-react/engine/snap.ts
|
|
10
10
|
var KIND_PRIORITY = {
|
|
@@ -447,4 +447,4 @@ export {
|
|
|
447
447
|
buildInsertImageOp,
|
|
448
448
|
DEFAULT_INSERT_TEMPLATES
|
|
449
449
|
};
|
|
450
|
-
//# sourceMappingURL=chunk-
|
|
450
|
+
//# sourceMappingURL=chunk-X556WVBG.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from "./chunk-AMUXRAUO.js";
|
|
11
11
|
import {
|
|
12
12
|
turnTraceId
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-EKV6T4YU.js";
|
|
14
14
|
|
|
15
15
|
// src/runtime/loop.ts
|
|
16
16
|
import {
|
|
@@ -638,7 +638,7 @@ async function runRouterTurn(options) {
|
|
|
638
638
|
const { trace } = options;
|
|
639
639
|
let currentModel = options.model;
|
|
640
640
|
let lastModelSpan;
|
|
641
|
-
const gzipAbove = options.gzipRequestAboveBytes;
|
|
641
|
+
const gzipAbove = options.gzipRequestAboveBytes ?? (URL.canParse(options.baseUrl ?? DEFAULT_TANGLE_ROUTER_BASE_URL) && new URL(options.baseUrl ?? DEFAULT_TANGLE_ROUTER_BASE_URL).origin === new URL(DEFAULT_TANGLE_ROUTER_BASE_URL).origin ? 32 * 1024 : void 0);
|
|
642
642
|
const baseFetch = gzipAbove !== void 0 && gzipAbove >= 0 ? gzipRequestBodies(options.fetchImpl ?? fetch, gzipAbove) : options.fetchImpl;
|
|
643
643
|
const sendOnce = trace ? tracedModelFetch(trace, baseFetch ?? fetch, {
|
|
644
644
|
onSpan: (span) => {
|
|
@@ -934,4 +934,4 @@ export {
|
|
|
934
934
|
composeRouterTurnPrompt,
|
|
935
935
|
runRouterTurn
|
|
936
936
|
};
|
|
937
|
-
//# sourceMappingURL=chunk-
|
|
937
|
+
//# sourceMappingURL=chunk-XAD4VTP4.js.map
|