stitchkit 0.116.0 → 0.117.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/agent-runtime/run-acquisition.d.ts +9 -2
  3. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  4. package/dist/agent-runtime/run-execution.d.ts +3 -0
  5. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  6. package/dist/agent-runtime/run-failure.d.ts +4 -1
  7. package/dist/agent-runtime/run-failure.d.ts.map +1 -1
  8. package/dist/agent-runtime/run-store-retry.d.ts +8 -0
  9. package/dist/agent-runtime/run-store-retry.d.ts.map +1 -0
  10. package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
  11. package/dist/agent-runtime/run-unacquired.d.ts +19 -0
  12. package/dist/agent-runtime/run-unacquired.d.ts.map +1 -0
  13. package/dist/agent-runtime/store-conformance.d.ts +8 -0
  14. package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
  15. package/dist/agent-runtime/store-driver-contract.d.ts +5 -0
  16. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  17. package/dist/agent-runtime/terminal-commit.d.ts +34 -4
  18. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  19. package/dist/entrypoints/agent-runtime/harness.js +2 -2
  20. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  21. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  22. package/dist/entrypoints/agent-runtime/testing.js +22 -4
  23. package/dist/entrypoints/agent-runtime.d.ts +1 -1
  24. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  25. package/dist/entrypoints/agent-runtime.js +13 -11
  26. package/dist/entrypoints/application/diagnostic-journal.js +1 -1
  27. package/dist/entrypoints/application/directory-inbox.js +3 -3
  28. package/dist/entrypoints/cli/publish.js +2 -2
  29. package/dist/entrypoints/files.js +2 -2
  30. package/dist/entrypoints/primitives.js +51 -154
  31. package/dist/entrypoints/server.js +6 -6
  32. package/dist/entrypoints/telegram.d.ts +1 -1
  33. package/dist/entrypoints/telegram.d.ts.map +1 -1
  34. package/dist/entrypoints/telegram.js +196 -76
  35. package/dist/entrypoints/tracking/contract.d.ts +11 -0
  36. package/dist/entrypoints/tracking/contract.d.ts.map +1 -0
  37. package/dist/entrypoints/tracking/contract.js +162 -0
  38. package/dist/entrypoints/tracking/performance.d.ts +8 -0
  39. package/dist/entrypoints/tracking/performance.d.ts.map +1 -0
  40. package/dist/entrypoints/tracking/performance.js +181 -0
  41. package/dist/entrypoints/tracking/server.d.ts +1 -0
  42. package/dist/entrypoints/tracking/server.d.ts.map +1 -1
  43. package/dist/entrypoints/tracking/server.js +40 -12
  44. package/dist/entrypoints/tracking.d.ts +4 -3
  45. package/dist/entrypoints/tracking.d.ts.map +1 -1
  46. package/dist/entrypoints/tracking.js +43 -143
  47. package/dist/entrypoints/xlsx.d.ts +4 -0
  48. package/dist/entrypoints/xlsx.d.ts.map +1 -0
  49. package/dist/entrypoints/xlsx.js +406 -0
  50. package/dist/{index-fa435yq2.js → index-073nw9qr.js} +8 -8
  51. package/dist/index-1f40z584.js +7 -0
  52. package/dist/{index-fdk4r4r6.js → index-75ns2ybj.js} +1 -1
  53. package/dist/{index-jq2ky8fw.js → index-cycp3r3e.js} +124 -181
  54. package/dist/{index-4g6qmgdx.js → index-ghtpfz4z.js} +9 -9
  55. package/dist/{index-n3v695sb.js → index-hdjmdwsj.js} +277 -96
  56. package/dist/{index-zqkz4af9.js → index-nqxrm176.js} +1 -1
  57. package/dist/index-qezhmp51.js +242 -0
  58. package/dist/index-vv1sch8a.js +94 -0
  59. package/dist/{index-fggxgbrk.js → index-xx1j310k.js} +165 -102
  60. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  61. package/dist/primitives/decimal.d.ts +10 -0
  62. package/dist/primitives/decimal.d.ts.map +1 -1
  63. package/dist/primitives/index.d.ts +3 -1
  64. package/dist/primitives/index.d.ts.map +1 -1
  65. package/dist/primitives/money.d.ts +20 -0
  66. package/dist/primitives/money.d.ts.map +1 -1
  67. package/dist/primitives/quantity.d.ts.map +1 -1
  68. package/dist/primitives/rounding.d.ts +40 -0
  69. package/dist/primitives/rounding.d.ts.map +1 -0
  70. package/dist/telegram/budget-transformer.d.ts +2 -2
  71. package/dist/telegram/not-dispatched.d.ts +2 -2
  72. package/dist/telegram/not-dispatched.d.ts.map +1 -1
  73. package/dist/telegram/outbound-budget.d.ts +53 -16
  74. package/dist/telegram/outbound-budget.d.ts.map +1 -1
  75. package/dist/telegram/outbound-cost.d.ts +5 -0
  76. package/dist/telegram/outbound-cost.d.ts.map +1 -0
  77. package/dist/telegram/outbound-pauses.d.ts +17 -0
  78. package/dist/telegram/outbound-pauses.d.ts.map +1 -0
  79. package/dist/telegram/outbound-queue.d.ts +17 -0
  80. package/dist/telegram/outbound-queue.d.ts.map +1 -0
  81. package/dist/tracking/attribution.d.ts +1 -1
  82. package/dist/tracking/attribution.d.ts.map +1 -1
  83. package/dist/tracking/client-visit.d.ts +3 -1
  84. package/dist/tracking/client-visit.d.ts.map +1 -1
  85. package/dist/tracking/client.d.ts.map +1 -1
  86. package/dist/tracking/performance/collector.d.ts +61 -0
  87. package/dist/tracking/performance/collector.d.ts.map +1 -0
  88. package/dist/tracking/performance/schema.d.ts +45 -0
  89. package/dist/tracking/performance/schema.d.ts.map +1 -0
  90. package/dist/tracking/performance/summary.d.ts +12 -0
  91. package/dist/tracking/performance/summary.d.ts.map +1 -0
  92. package/dist/tracking/privacy.d.ts +5 -0
  93. package/dist/tracking/privacy.d.ts.map +1 -0
  94. package/dist/tracking/server/telemetry-health.d.ts +31 -0
  95. package/dist/tracking/server/telemetry-health.d.ts.map +1 -0
  96. package/dist/xlsx/cells.d.ts +17 -0
  97. package/dist/xlsx/cells.d.ts.map +1 -0
  98. package/dist/xlsx/render.d.ts +11 -0
  99. package/dist/xlsx/render.d.ts.map +1 -0
  100. package/dist/xlsx/schema.d.ts +119 -0
  101. package/dist/xlsx/schema.d.ts.map +1 -0
  102. package/dist/xlsx/zip.d.ts +13 -0
  103. package/dist/xlsx/zip.d.ts.map +1 -0
  104. package/llms/agent-runtime.2.txt +40 -16
  105. package/llms/agent-runtime.3.txt +17 -0
  106. package/llms/agent-runtime.txt +4 -1
  107. package/llms/primitives.txt +21 -0
  108. package/llms/stitchkit.txt +9 -6
  109. package/llms/telegram.txt +32 -12
  110. package/llms/tracking-contract.txt +32 -0
  111. package/llms/tracking-performance.txt +21 -0
  112. package/llms/tracking-server.txt +1 -0
  113. package/llms/tracking.txt +75 -12
  114. package/llms/{upgrading-0.105.0-0.116.0.txt → upgrading-0.105.0-0.117.0.txt} +50 -3
  115. package/llms/upgrading.txt +1 -1
  116. package/llms/xlsx.txt +107 -0
  117. package/llms-full.txt +355 -31
  118. package/llms.txt +11 -7
  119. package/package.json +27 -9
  120. package/dist/{index-z3d6smer.js → index-tdpmfks8.js} +5 -5
@@ -0,0 +1,242 @@
1
+ import {
2
+ assertPositiveSafeInteger
3
+ } from "./index-0s4xebbg.js";
4
+
5
+ // src/primitives/decimal.ts
6
+ import { z } from "zod";
7
+ var DECIMAL_PATTERN = /^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;
8
+ function parseDecimal(value) {
9
+ if (!DECIMAL_PATTERN.test(value))
10
+ throw new TypeError(`invalid decimal value "${value}"`);
11
+ const negative = value.startsWith("-");
12
+ const unsigned = negative ? value.slice(1) : value;
13
+ const [whole = "0", fraction = ""] = unsigned.split(".");
14
+ const coefficient = BigInt(`${negative ? "-" : ""}${whole}${fraction}`);
15
+ return normalizeDecimal({ coefficient, scale: fraction.length });
16
+ }
17
+ function normalizeDecimal(parts) {
18
+ let coefficient = parts.coefficient;
19
+ let scale = parts.scale;
20
+ while (scale > 0 && coefficient % 10n === 0n) {
21
+ coefficient /= 10n;
22
+ scale -= 1;
23
+ }
24
+ return { coefficient, scale };
25
+ }
26
+ function formatDecimal(parts) {
27
+ const normalized = normalizeDecimal(parts);
28
+ const negative = normalized.coefficient < 0n;
29
+ const digits = (negative ? -normalized.coefficient : normalized.coefficient).toString();
30
+ if (normalized.scale === 0)
31
+ return `${negative ? "-" : ""}${digits}`;
32
+ const padded = digits.padStart(normalized.scale + 1, "0");
33
+ const point = padded.length - normalized.scale;
34
+ return `${negative ? "-" : ""}${padded.slice(0, point)}.${padded.slice(point)}`;
35
+ }
36
+ function addDecimal(left, right) {
37
+ const scale = Math.max(left.scale, right.scale);
38
+ const leftCoefficient = left.coefficient * 10n ** BigInt(scale - left.scale);
39
+ const rightCoefficient = right.coefficient * 10n ** BigInt(scale - right.scale);
40
+ return normalizeDecimal({ coefficient: leftCoefficient + rightCoefficient, scale });
41
+ }
42
+ function multiplyDecimalRatio(value, numerator, denominator) {
43
+ if (denominator <= 0n)
44
+ throw new RangeError("conversion denominator must be positive");
45
+ let coefficient = value.coefficient * numerator;
46
+ let scale = value.scale;
47
+ for (let extraScale = 0;extraScale <= 18; extraScale += 1) {
48
+ if (coefficient % denominator === 0n) {
49
+ return normalizeDecimal({ coefficient: coefficient / denominator, scale });
50
+ }
51
+ coefficient *= 10n;
52
+ scale += 1;
53
+ }
54
+ throw new RangeError("conversion does not have a finite decimal representation");
55
+ }
56
+ var DecimalStringSchema2 = z.string().refine((value) => {
57
+ try {
58
+ return formatDecimal(parseDecimal(value)) === value;
59
+ } catch {
60
+ return false;
61
+ }
62
+ }, "expected a canonical decimal string");
63
+ var DecimalInputSchema2 = z.string().regex(DECIMAL_PATTERN, "expected a decimal string").transform((value) => formatDecimal(parseDecimal(value)));
64
+
65
+ // src/primitives/rounding.ts
66
+ import { z as z2 } from "zod";
67
+ var RoundingModeSchema2 = z2.enum(["half-up", "half-even", "up", "down"]);
68
+ function isPositive(value) {
69
+ return DecimalStringSchema2.safeParse(value).success && parseDecimal(value).coefficient > 0n;
70
+ }
71
+ function compareParts(left, right) {
72
+ const scale = BigInt(Math.max(left.scale, right.scale));
73
+ const a = left.coefficient * 10n ** (scale - BigInt(left.scale));
74
+ const b = right.coefficient * 10n ** (scale - BigInt(right.scale));
75
+ return a < b ? -1 : a > b ? 1 : 0;
76
+ }
77
+ var RoundingTierSchema = z2.object({
78
+ below: z2.string().refine(isPositive, "expected a positive decimal").optional(),
79
+ step: z2.string().refine(isPositive, "expected a positive decimal")
80
+ });
81
+ var RoundingPolicySchema2 = z2.object({ mode: RoundingModeSchema2, tiers: z2.array(RoundingTierSchema).min(1) }).superRefine(({ tiers }, context) => {
82
+ const bounds = tiers.map((tier) => tier.below);
83
+ if (bounds.at(-1) !== undefined || bounds.slice(0, -1).includes(undefined)) {
84
+ context.addIssue({ code: "custom", message: 'only the last tier omits "below"' });
85
+ }
86
+ const ordered = bounds.flatMap((bound) => bound !== undefined && isPositive(bound) ? [parseDecimal(bound)] : []);
87
+ for (const [index, bound] of ordered.entries()) {
88
+ const next = ordered[index + 1];
89
+ if (next !== undefined && compareParts(bound, next) >= 0) {
90
+ context.addIssue({ code: "custom", message: '"below" must ascend' });
91
+ }
92
+ }
93
+ });
94
+ function defineRoundingPolicy2(policy) {
95
+ const { mode, tiers } = RoundingPolicySchema2.parse(policy);
96
+ return Object.freeze({ mode, tiers: tiers.map((tier) => Object.freeze(tier)) });
97
+ }
98
+ function absolute(value) {
99
+ return value < 0n ? -value : value;
100
+ }
101
+ function roundRatio(numerator, denominator, mode) {
102
+ const magnitude = absolute(numerator);
103
+ const quotient = magnitude / denominator;
104
+ const remainder = magnitude % denominator;
105
+ const twice = remainder * 2n;
106
+ const away = remainder !== 0n && (mode === "up" || mode === "half-up" && twice >= denominator || mode === "half-even" && (twice > denominator || twice === denominator && quotient % 2n === 1n));
107
+ const rounded = away ? quotient + 1n : quotient;
108
+ return numerator < 0n ? -rounded : rounded;
109
+ }
110
+ function stepFor(value, policy) {
111
+ const magnitude = { ...value, coefficient: absolute(value.coefficient) };
112
+ const tier = policy.tiers.find(({ below }) => below === undefined || compareParts(magnitude, parseDecimal(below)) < 0);
113
+ if (tier === undefined)
114
+ throw new TypeError("a rounding policy needs a last tier");
115
+ return parseDecimal(tier.step);
116
+ }
117
+ function hasWholeSteps(policy) {
118
+ return policy.tiers.every(({ step }) => parseDecimal(step).scale === 0);
119
+ }
120
+ function roundParts(value, policy) {
121
+ const step = stepFor(value, policy);
122
+ const steps = roundRatio(value.coefficient * 10n ** BigInt(step.scale), step.coefficient * 10n ** BigInt(value.scale), policy.mode);
123
+ return { coefficient: steps * step.coefficient, scale: step.scale };
124
+ }
125
+ function multiplyAndRound(left, right, policy) {
126
+ return roundParts({ coefficient: left.coefficient * right.coefficient, scale: left.scale + right.scale }, policy);
127
+ }
128
+ function roundDecimal2(value, policy) {
129
+ return formatDecimal(roundParts(parseDecimal(DecimalInputSchema2.parse(value)), policy));
130
+ }
131
+
132
+ // src/primitives/money.ts
133
+ import { z as z3 } from "zod";
134
+ var IntegerStringSchema = z3.string().regex(/^-?(?:0|[1-9]\d*)$/);
135
+ function createMoneySchema2(currency) {
136
+ return z3.object({
137
+ minor: IntegerStringSchema,
138
+ currency: z3.literal(currency)
139
+ });
140
+ }
141
+ function parseMinor(value) {
142
+ return BigInt(IntegerStringSchema.parse(value.minor));
143
+ }
144
+ function assertSameCurrency(left, right) {
145
+ if (left.currency !== right.currency) {
146
+ throw new TypeError(`cannot combine "${left.currency}" and "${right.currency}"`);
147
+ }
148
+ }
149
+ function money(minor, currency) {
150
+ return Object.freeze({ minor: minor.toString(), currency });
151
+ }
152
+ function addMoney2(left, right) {
153
+ assertSameCurrency(left, right);
154
+ return money(parseMinor(left) + parseMinor(right), left.currency);
155
+ }
156
+ function subtractMoney2(left, right) {
157
+ assertSameCurrency(left, right);
158
+ return money(parseMinor(left) - parseMinor(right), left.currency);
159
+ }
160
+ function multiplyMoney2(value, quantity) {
161
+ if (typeof quantity === "number" && !Number.isSafeInteger(quantity)) {
162
+ throw new RangeError("quantity must be a safe integer");
163
+ }
164
+ const multiplier = typeof quantity === "bigint" ? quantity : BigInt(quantity);
165
+ return money(parseMinor(value) * multiplier, value.currency);
166
+ }
167
+ var ScaleSchema = z3.number().int().min(0).max(18);
168
+ function moneyFromDecimal2(currency, value, scale) {
169
+ const places = ScaleSchema.parse(scale);
170
+ const parts = parseDecimal(DecimalInputSchema2.parse(value));
171
+ if (parts.scale > places) {
172
+ throw new RangeError(`"${value}" is finer than ${places} decimal places`);
173
+ }
174
+ return money(parts.coefficient * 10n ** BigInt(places - parts.scale), currency);
175
+ }
176
+ function moneyToDecimal2(value, scale) {
177
+ const places = ScaleSchema.parse(scale);
178
+ const minor = parseMinor(value);
179
+ const whole = formatDecimal({ coefficient: minor, scale: places });
180
+ if (places === 0)
181
+ return whole;
182
+ const [integer = "0", fraction = ""] = whole.split(".");
183
+ return `${integer}.${fraction.padEnd(places, "0")}`;
184
+ }
185
+ function assertMinorSteps(policy) {
186
+ if (!hasWholeSteps(policy)) {
187
+ throw new RangeError("a money rounding step must be a whole number of minor units");
188
+ }
189
+ }
190
+ function roundMoney2(value, policy) {
191
+ assertMinorSteps(policy);
192
+ const rounded = roundParts({ coefficient: parseMinor(value), scale: 0 }, policy);
193
+ return money(rounded.coefficient, value.currency);
194
+ }
195
+ function multiplyMoneyByDecimal2(value, factor, policy) {
196
+ assertMinorSteps(policy);
197
+ const rounded = multiplyAndRound({ coefficient: parseMinor(value), scale: 0 }, parseDecimal(DecimalInputSchema2.parse(factor)), policy);
198
+ return money(rounded.coefficient, value.currency);
199
+ }
200
+ function shareMoney2(value, numerator, denominator) {
201
+ if (denominator <= 0n)
202
+ throw new RangeError("denominator must be positive");
203
+ if (numerator < 0n)
204
+ throw new RangeError("numerator must be non-negative");
205
+ const scaled = parseMinor(value) * numerator;
206
+ return Object.freeze({
207
+ amount: money(scaled / denominator, value.currency),
208
+ remainder: Object.freeze({
209
+ numerator: (scaled % denominator).toString(),
210
+ denominator: denominator.toString(),
211
+ currency: value.currency
212
+ })
213
+ });
214
+ }
215
+ function splitMoney2(value, count) {
216
+ assertPositiveSafeInteger("count", count, RangeError);
217
+ const divisor = BigInt(count);
218
+ const total = parseMinor(value);
219
+ return Object.freeze({
220
+ part: money(total / divisor, value.currency),
221
+ count,
222
+ remainder: money(total % divisor, value.currency)
223
+ });
224
+ }
225
+ function defineMoney2(currency) {
226
+ const schema = createMoneySchema2(currency);
227
+ return Object.freeze({
228
+ currency,
229
+ schema,
230
+ create(minor) {
231
+ const parsed = schema.parse({ minor: minor.toString(), currency });
232
+ return Object.freeze(parsed);
233
+ },
234
+ add: addMoney2,
235
+ subtract: subtractMoney2,
236
+ multiply: multiplyMoney2,
237
+ share: shareMoney2,
238
+ split: splitMoney2
239
+ });
240
+ }
241
+
242
+ export { parseDecimal, formatDecimal, addDecimal, multiplyDecimalRatio, DecimalStringSchema2, DecimalInputSchema2, RoundingModeSchema2, RoundingPolicySchema2, defineRoundingPolicy2, roundDecimal2, createMoneySchema2, addMoney2, subtractMoney2, multiplyMoney2, moneyFromDecimal2, moneyToDecimal2, roundMoney2, multiplyMoneyByDecimal2, shareMoney2, splitMoney2, defineMoney2 };
@@ -0,0 +1,94 @@
1
+ // src/tracking/beacon.ts
2
+ function sendUnloadBeacon2(url, body, sender = typeof navigator === "undefined" ? undefined : navigator) {
3
+ if (!sender || typeof sender.sendBeacon !== "function")
4
+ return false;
5
+ return sender.sendBeacon(url, body);
6
+ }
7
+
8
+ // src/tracking/privacy.ts
9
+ var MASK = "[masked]";
10
+ var MAX_REDACTED_CHARS = 16384;
11
+ var TELEGRAM_SIGNED_FIELD = "tgwebappdata";
12
+ var PASSWORD_FIELD = /^(?:current|new|old|confirm|repeat|repeated)?(?:password|passwd|pwd)(?:confirmation)?$/;
13
+ var CREDENTIAL_FIELDS = new Set([
14
+ "token",
15
+ "accesstoken",
16
+ "idtoken",
17
+ "refreshtoken",
18
+ "authtoken",
19
+ "sessiontoken",
20
+ "csrftoken",
21
+ "resettoken",
22
+ "magictoken",
23
+ "secret",
24
+ "clientsecret",
25
+ "apikey",
26
+ "privatekey",
27
+ "authorization",
28
+ "signature",
29
+ "xamzsignature"
30
+ ]);
31
+ var OAUTH_FIELDS = new Set(["code", "state", "sessionstate"]);
32
+ var SIGNED_LOGIN_FIELDS = new Set(["hash"]);
33
+ var PARAMETER = /([?&#])([^=&#?\s]+)=([^&#\s]*)/g;
34
+ var URL_PASSWORD = /(https?:\/\/[^\s/:@]+:)[^\s/@]+(@)/gi;
35
+ var BEARER = /\b(bearer\s+)[^\s,;]+/gi;
36
+ var ASSIGNMENT = /(^|[^\w?&#/-])("[^"\n]+"|'[^'\n]+'|[\w.$[\]-]+)(\s*[:=]\s*)("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^\s,;}]+)/g;
37
+ function fieldName(key) {
38
+ const field = key.replace(/^amp;/, "").split(/[.[\]]/).filter((part) => part !== "" && !/^\d+$/.test(part)).at(-1) ?? "";
39
+ return field.replace(/[-_\s]/g, "").toLowerCase();
40
+ }
41
+ function isSecretField(key, context) {
42
+ const field = fieldName(key);
43
+ if (PASSWORD_FIELD.test(field) || CREDENTIAL_FIELDS.has(field))
44
+ return true;
45
+ if (field === TELEGRAM_SIGNED_FIELD)
46
+ return true;
47
+ if (context?.oauth && OAUTH_FIELDS.has(field))
48
+ return true;
49
+ return Boolean(context?.signedLogin && SIGNED_LOGIN_FIELDS.has(field));
50
+ }
51
+ function decodeKey(key) {
52
+ try {
53
+ return decodeURIComponent(key.replace(/\+/g, " "));
54
+ } catch {
55
+ return key;
56
+ }
57
+ }
58
+ function secretContextOf(input) {
59
+ const names = new Set(Array.from(input.matchAll(PARAMETER), (match) => fieldName(decodeKey(match[2] ?? ""))));
60
+ return {
61
+ oauth: names.has("state") && names.has("code"),
62
+ signedLogin: names.has("authdate")
63
+ };
64
+ }
65
+ function redactTrackingText2(input) {
66
+ const text = input.slice(0, MAX_REDACTED_CHARS);
67
+ const context = secretContextOf(text);
68
+ return text.replace(URL_PASSWORD, `$1${MASK}$2`).replace(BEARER, `$1${MASK}`).replace(PARAMETER, (whole, separator, key, value) => {
69
+ try {
70
+ if (isSecretField(decodeKey(key), context))
71
+ return `${separator}${key}=${MASK}`;
72
+ const decoded = decodeURIComponent(value.replace(/\+/g, " "));
73
+ const redacted = redactTrackingText2(decoded);
74
+ return redacted === decoded ? whole : `${separator}${key}=${encodeURIComponent(redacted)}`;
75
+ } catch {
76
+ return whole;
77
+ }
78
+ }).replace(ASSIGNMENT, (whole, prefix, key, assignment) => isSecretField(key.replace(/^["']|["']$/g, "")) ? `${prefix}${key}${assignment}${MASK}` : whole);
79
+ }
80
+ function redactTrackingValue2(value) {
81
+ if (typeof value === "string")
82
+ return redactTrackingText2(value);
83
+ if (Array.isArray(value))
84
+ return value.map(redactTrackingValue2);
85
+ if (value !== null && typeof value === "object") {
86
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [
87
+ key,
88
+ isSecretField(key) ? MASK : redactTrackingValue2(item)
89
+ ]));
90
+ }
91
+ return value;
92
+ }
93
+
94
+ export { sendUnloadBeacon2, redactTrackingText2, redactTrackingValue2 };
@@ -374,158 +374,221 @@ function assistantStatus(reason) {
374
374
  return "failed";
375
375
  }
376
376
 
377
+ // src/agent-runtime/store-driver-contract.ts
378
+ import { z as z4 } from "zod";
379
+ var AgentRuntimeHeadSchema2 = z4.object({
380
+ schemaVersion: z4.literal(1),
381
+ conversationId: AgentRecordIdSchema2,
382
+ version: AgentRecordVersionSchema2
383
+ });
384
+ var AgentStoredRunSchema2 = z4.object({
385
+ schemaVersion: z4.literal(1),
386
+ run: AgentRunSchema2,
387
+ terminalAssistant: AgentMessageSchema2.optional()
388
+ });
389
+ var AgentAdmissionReceiptSchema2 = z4.object({
390
+ schemaVersion: z4.literal(1),
391
+ conversationId: AgentRecordIdSchema2,
392
+ idempotencyKey: z4.string().min(1),
393
+ input: AgentMessageSchema2,
394
+ runId: AgentRecordIdSchema2,
395
+ assistantMessageId: AgentRecordIdSchema2
396
+ });
397
+ var AgentSeedReceiptSchema2 = z4.object({
398
+ schemaVersion: z4.literal(1),
399
+ conversationId: AgentRecordIdSchema2,
400
+ seedKey: z4.string().min(1),
401
+ messageIds: z4.array(AgentRecordIdSchema2).min(1)
402
+ });
403
+ var AgentHistoryMutationSchema2 = z4.discriminatedUnion("type", [
404
+ z4.object({ type: z4.literal("admit"), input: AgentMessageSchema2 }),
405
+ z4.object({
406
+ type: z4.literal("upsert-assistant"),
407
+ message: AgentMessageSchema2
408
+ }),
409
+ z4.object({
410
+ type: z4.literal("replace-compacted-range"),
411
+ replacedMessageIds: z4.array(AgentRecordIdSchema2).min(1),
412
+ summary: AgentMessageSchema2
413
+ }),
414
+ z4.object({
415
+ type: z4.literal("seed"),
416
+ message: AgentMessageSchema2
417
+ }),
418
+ z4.object({
419
+ type: z4.literal("insert"),
420
+ message: AgentMessageSchema2,
421
+ beforeMessageId: AgentRecordIdSchema2.optional()
422
+ })
423
+ ]);
424
+ var ACTIVE_AGENT_RUN_STATES2 = [
425
+ "queued",
426
+ "running",
427
+ "interrupt_requested"
428
+ ];
429
+ function isActiveRunState(state) {
430
+ return ACTIVE_AGENT_RUN_STATES2.includes(state);
431
+ }
432
+ function emptyHead(conversationId) {
433
+ return AgentRuntimeHeadSchema2.parse({
434
+ schemaVersion: 1,
435
+ conversationId,
436
+ version: 0
437
+ });
438
+ }
439
+
377
440
  // src/agent-runtime/provider-journal.ts
378
- import { z as z5 } from "zod";
441
+ import { z as z6 } from "zod";
379
442
 
380
443
  // src/agent-runtime/provider-content.ts
381
- import { z as z4 } from "zod";
444
+ import { z as z5 } from "zod";
382
445
  var ProviderJournalOptions = {
383
- providerOptions: z4.record(z4.string(), z4.record(z4.string(), z4.json())).optional()
446
+ providerOptions: z5.record(z5.string(), z5.record(z5.string(), z5.json())).optional()
384
447
  };
385
448
  var Options = ProviderJournalOptions;
386
- var Reference = z4.record(z4.string(), z4.string()).refine((value) => !("type" in value), "Provider reference cannot contain a file discriminator");
387
- var Binary = z4.object({
388
- binary: z4.literal(true),
389
- sha256: z4.string().regex(/^[a-f0-9]{64}$/),
390
- bytes: z4.int().nonnegative()
449
+ var Reference = z5.record(z5.string(), z5.string()).refine((value) => !("type" in value), "Provider reference cannot contain a file discriminator");
450
+ var Binary = z5.object({
451
+ binary: z5.literal(true),
452
+ sha256: z5.string().regex(/^[a-f0-9]{64}$/),
453
+ bytes: z5.int().nonnegative()
391
454
  }).strict();
392
- var Inline = z4.union([z4.string(), Binary]);
393
- var TaggedBinary = z4.object({ type: z4.literal("data"), data: Inline }).strict();
394
- var TaggedUrl = z4.object({ type: z4.literal("url"), url: z4.string() }).strict();
395
- var FileData = z4.union([
455
+ var Inline = z5.union([z5.string(), Binary]);
456
+ var TaggedBinary = z5.object({ type: z5.literal("data"), data: Inline }).strict();
457
+ var TaggedUrl = z5.object({ type: z5.literal("url"), url: z5.string() }).strict();
458
+ var FileData = z5.union([
396
459
  TaggedBinary,
397
460
  TaggedUrl,
398
- z4.object({ type: z4.literal("reference"), reference: Reference }).strict(),
399
- z4.object({ type: z4.literal("text"), text: z4.string() }).strict()
461
+ z5.object({ type: z5.literal("reference"), reference: Reference }).strict(),
462
+ z5.object({ type: z5.literal("text"), text: z5.string() }).strict()
400
463
  ]);
401
- var File = z4.object({
402
- type: z4.literal("file"),
403
- data: z4.union([FileData, Inline, Reference]),
404
- mediaType: z4.string(),
405
- filename: z4.string().optional(),
464
+ var File = z5.object({
465
+ type: z5.literal("file"),
466
+ data: z5.union([FileData, Inline, Reference]),
467
+ mediaType: z5.string(),
468
+ filename: z5.string().optional(),
406
469
  ...Options
407
470
  }).strict();
408
- var Text = z4.object({ type: z4.literal("text"), text: z4.string(), ...Options }).strict();
409
- var Output = z4.discriminatedUnion("type", [
410
- z4.object({ type: z4.enum(["text", "error-text"]), value: z4.string(), ...Options }).strict(),
411
- z4.object({ type: z4.enum(["json", "error-json"]), value: z4.json(), ...Options }).strict(),
412
- z4.object({ type: z4.literal("execution-denied"), reason: z4.string().optional(), ...Options }).strict(),
413
- z4.object({
414
- type: z4.literal("content"),
415
- value: z4.array(z4.union([
471
+ var Text = z5.object({ type: z5.literal("text"), text: z5.string(), ...Options }).strict();
472
+ var Output = z5.discriminatedUnion("type", [
473
+ z5.object({ type: z5.enum(["text", "error-text"]), value: z5.string(), ...Options }).strict(),
474
+ z5.object({ type: z5.enum(["json", "error-json"]), value: z5.json(), ...Options }).strict(),
475
+ z5.object({ type: z5.literal("execution-denied"), reason: z5.string().optional(), ...Options }).strict(),
476
+ z5.object({
477
+ type: z5.literal("content"),
478
+ value: z5.array(z5.union([
416
479
  Text,
417
- z4.object({
418
- type: z4.literal("file"),
480
+ z5.object({
481
+ type: z5.literal("file"),
419
482
  data: FileData,
420
- mediaType: z4.string(),
421
- filename: z4.string().optional(),
483
+ mediaType: z5.string(),
484
+ filename: z5.string().optional(),
422
485
  ...Options
423
486
  }).strict(),
424
- z4.object({
425
- type: z4.literal("file-data"),
426
- data: z4.string(),
427
- mediaType: z4.string(),
428
- filename: z4.string().optional(),
487
+ z5.object({
488
+ type: z5.literal("file-data"),
489
+ data: z5.string(),
490
+ mediaType: z5.string(),
491
+ filename: z5.string().optional(),
429
492
  ...Options
430
493
  }).strict(),
431
- z4.object({
432
- type: z4.literal("image-data"),
433
- data: z4.string(),
434
- mediaType: z4.string(),
494
+ z5.object({
495
+ type: z5.literal("image-data"),
496
+ data: z5.string(),
497
+ mediaType: z5.string(),
435
498
  ...Options
436
499
  }).strict(),
437
- z4.object({
438
- type: z4.literal("file-url"),
439
- url: z4.string(),
440
- mediaType: z4.string().optional(),
500
+ z5.object({
501
+ type: z5.literal("file-url"),
502
+ url: z5.string(),
503
+ mediaType: z5.string().optional(),
441
504
  ...Options
442
505
  }).strict(),
443
- z4.object({ type: z4.literal("image-url"), url: z4.string(), ...Options }).strict(),
444
- z4.object({
445
- type: z4.enum(["file-id", "image-file-id"]),
446
- fileId: z4.union([z4.string(), Reference]),
506
+ z5.object({ type: z5.literal("image-url"), url: z5.string(), ...Options }).strict(),
507
+ z5.object({
508
+ type: z5.enum(["file-id", "image-file-id"]),
509
+ fileId: z5.union([z5.string(), Reference]),
447
510
  ...Options
448
511
  }).strict(),
449
- z4.object({
450
- type: z4.enum(["file-reference", "image-file-reference"]),
512
+ z5.object({
513
+ type: z5.enum(["file-reference", "image-file-reference"]),
451
514
  providerReference: Reference,
452
515
  ...Options
453
516
  }).strict(),
454
- z4.object({ type: z4.literal("custom"), ...Options }).strict()
517
+ z5.object({ type: z5.literal("custom"), ...Options }).strict()
455
518
  ]))
456
519
  }).strict()
457
520
  ]);
458
- var ProviderJournalContentSchema = z4.union([
521
+ var ProviderJournalContentSchema = z5.union([
459
522
  Text,
460
523
  File,
461
- z4.object({ type: z4.literal("reasoning"), text: z4.string(), ...Options }).strict(),
462
- z4.object({ type: z4.literal("custom"), kind: z4.string(), ...Options }).strict(),
463
- z4.object({
464
- type: z4.literal("reasoning-file"),
465
- data: z4.union([TaggedBinary, TaggedUrl, Inline]),
466
- mediaType: z4.string(),
524
+ z5.object({ type: z5.literal("reasoning"), text: z5.string(), ...Options }).strict(),
525
+ z5.object({ type: z5.literal("custom"), kind: z5.string(), ...Options }).strict(),
526
+ z5.object({
527
+ type: z5.literal("reasoning-file"),
528
+ data: z5.union([TaggedBinary, TaggedUrl, Inline]),
529
+ mediaType: z5.string(),
467
530
  ...Options
468
531
  }).strict(),
469
- z4.object({
470
- type: z4.literal("image"),
471
- image: z4.union([Inline, Reference]),
472
- mediaType: z4.string().optional(),
532
+ z5.object({
533
+ type: z5.literal("image"),
534
+ image: z5.union([Inline, Reference]),
535
+ mediaType: z5.string().optional(),
473
536
  ...Options
474
537
  }).strict(),
475
- z4.object({
476
- type: z4.literal("tool-call"),
477
- toolCallId: z4.string(),
478
- toolName: z4.string(),
479
- input: z4.json(),
480
- providerExecuted: z4.boolean().optional(),
538
+ z5.object({
539
+ type: z5.literal("tool-call"),
540
+ toolCallId: z5.string(),
541
+ toolName: z5.string(),
542
+ input: z5.json(),
543
+ providerExecuted: z5.boolean().optional(),
481
544
  ...Options
482
545
  }).strict(),
483
- z4.object({
484
- type: z4.literal("tool-result"),
485
- toolCallId: z4.string(),
486
- toolName: z4.string(),
546
+ z5.object({
547
+ type: z5.literal("tool-result"),
548
+ toolCallId: z5.string(),
549
+ toolName: z5.string(),
487
550
  output: Output,
488
551
  ...Options
489
552
  }).strict(),
490
- z4.object({
491
- type: z4.literal("tool-approval-request"),
492
- approvalId: z4.string(),
493
- toolCallId: z4.string(),
494
- signature: z4.string().optional(),
495
- isAutomatic: z4.boolean().optional(),
496
- reason: z4.string().optional()
553
+ z5.object({
554
+ type: z5.literal("tool-approval-request"),
555
+ approvalId: z5.string(),
556
+ toolCallId: z5.string(),
557
+ signature: z5.string().optional(),
558
+ isAutomatic: z5.boolean().optional(),
559
+ reason: z5.string().optional()
497
560
  }).strict(),
498
- z4.object({
499
- type: z4.literal("tool-approval-response"),
500
- approvalId: z4.string(),
501
- approved: z4.boolean(),
502
- reason: z4.string().optional(),
503
- providerExecuted: z4.boolean().optional()
561
+ z5.object({
562
+ type: z5.literal("tool-approval-response"),
563
+ approvalId: z5.string(),
564
+ approved: z5.boolean(),
565
+ reason: z5.string().optional(),
566
+ providerExecuted: z5.boolean().optional()
504
567
  }).strict()
505
568
  ]);
506
569
 
507
570
  // src/agent-runtime/provider-journal.ts
508
- var Hash = z5.string().regex(/^[a-f0-9]{64}$/);
509
- var Message = z5.object({
571
+ var Hash = z6.string().regex(/^[a-f0-9]{64}$/);
572
+ var Message = z6.object({
510
573
  ...ProviderJournalOptions,
511
- role: z5.enum(["system", "user", "assistant", "tool"]),
512
- content: z5.union([z5.string(), z5.array(ProviderJournalContentSchema)])
574
+ role: z6.enum(["system", "user", "assistant", "tool"]),
575
+ content: z6.union([z6.string(), z6.array(ProviderJournalContentSchema)])
513
576
  }).strict();
514
- var ProviderJournalMessageSchema = z5.object({ sha256: Hash, message: Message }).strict();
515
- var ProviderJournalRequestSchema = z5.object({
516
- runId: z5.string(),
517
- attempt: z5.int().nonnegative(),
518
- stepNumber: z5.int().nonnegative(),
519
- modelId: z5.string(),
577
+ var ProviderJournalMessageSchema = z6.object({ sha256: Hash, message: Message }).strict();
578
+ var ProviderJournalRequestSchema = z6.object({
579
+ runId: z6.string(),
580
+ attempt: z6.int().nonnegative(),
581
+ stepNumber: z6.int().nonnegative(),
582
+ modelId: z6.string(),
520
583
  instructionsSha256: Hash,
521
- messageShas: z5.array(Hash),
584
+ messageShas: z6.array(Hash),
522
585
  bodySha256: Hash
523
586
  }).strict();
524
- var ProviderJournalResponseSchema = z5.object({
525
- runId: z5.string(),
526
- attempt: z5.int().nonnegative(),
527
- stepNumber: z5.int().nonnegative(),
528
- response: z5.object({ id: z5.string(), provider: z5.string().optional() }).strict()
587
+ var ProviderJournalResponseSchema = z6.object({
588
+ runId: z6.string(),
589
+ attempt: z6.int().nonnegative(),
590
+ stepNumber: z6.int().nonnegative(),
591
+ response: z6.object({ id: z6.string(), provider: z6.string().optional() }).strict()
529
592
  }).strict();
530
593
 
531
- export { AgentStoreEventKindSchema2, AgentStoreEventEnvelopeSchema2, AppendAgentStoreEventSchema2, ReadAgentStoreEventsSchema2, AgentStoreEventPageSchema2, AgentStoreConflictSchema2, AgentStoreNotFoundSchema2, AgentStoreAppliedSchema2, AgentStoreDuplicateSchema2, AgentStoreMutationResultSchema2, AgentRunViewSchema2, AcceptInputAndAssignRunSchema2, AcquireAgentRunSchema2, CheckpointRunAssistantSchema2, RecordRunOperationSchema2, CommitRunTerminalSchema2, RequestRunInterruptSchema2, RecoverAgentRunSchema2, ReplaceCompactedRangeSchema2, SeedConversationInputSchema2, AgentRecoverableDescriptorSchema2, AgentRecoverablePageSchema2, AgentStoreTransitionSchema2, AgentStoreCheckpointRecordSchema, AgentStoreTransitionRecordSchema2, decodeAgentStoreEvent2, agentStoreEventDraft, canonicalAgentJson2, AgentConversationArchiveSchema2, encodeAgentConversationArchive2, decodeAgentConversationArchive2, createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence2, isCompleteAgentHistoryTurn, assistantStatus, ProviderJournalMessageSchema, ProviderJournalRequestSchema, ProviderJournalResponseSchema };
594
+ export { AgentStoreEventKindSchema2, AgentStoreEventEnvelopeSchema2, AppendAgentStoreEventSchema2, ReadAgentStoreEventsSchema2, AgentStoreEventPageSchema2, AgentStoreConflictSchema2, AgentStoreNotFoundSchema2, AgentStoreAppliedSchema2, AgentStoreDuplicateSchema2, AgentStoreMutationResultSchema2, AgentRunViewSchema2, AcceptInputAndAssignRunSchema2, AcquireAgentRunSchema2, CheckpointRunAssistantSchema2, RecordRunOperationSchema2, CommitRunTerminalSchema2, RequestRunInterruptSchema2, RecoverAgentRunSchema2, ReplaceCompactedRangeSchema2, SeedConversationInputSchema2, AgentRecoverableDescriptorSchema2, AgentRecoverablePageSchema2, AgentStoreTransitionSchema2, AgentStoreCheckpointRecordSchema, AgentStoreTransitionRecordSchema2, decodeAgentStoreEvent2, agentStoreEventDraft, canonicalAgentJson2, AgentConversationArchiveSchema2, encodeAgentConversationArchive2, decodeAgentConversationArchive2, createToolChronology, advanceToolChronology, canProjectToolChronology, isAssistantHistoryEvidence2, isCompleteAgentHistoryTurn, assistantStatus, ProviderJournalMessageSchema, ProviderJournalRequestSchema, ProviderJournalResponseSchema, AgentRuntimeHeadSchema2, AgentStoredRunSchema2, AgentAdmissionReceiptSchema2, AgentSeedReceiptSchema2, AgentHistoryMutationSchema2, ACTIVE_AGENT_RUN_STATES2, isActiveRunState, emptyHead };
@@ -1 +1 @@
1
- {"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"AA6BA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAGxB,MAAM,wBAAwB,CAAC;AAMhC,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,uFAAuF;IACvF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IACE,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AAwSN;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,EACpC,KAAK,SAAI,GACR,OAAO,CAAC,oBAAoB,CAAC,CAgC/B;AAED,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpC"}
1
+ {"version":3,"file":"exclusive-lock.d.ts","sourceRoot":"","sources":["../../src/internal/exclusive-lock.ts"],"names":[],"mappings":"AA6BA,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAGxB,MAAM,wBAAwB,CAAC;AAMhC,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,yEAAyE;IACzE,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,uFAAuF;IACvF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;CAAE,GACpC;IACE,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,SAAS,CAAC,EAAE,sBAAsB,CAAC;CAC7C,CAAC;AA4SN;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,2BAA2B,EACpC,KAAK,SAAI,GACR,OAAO,CAAC,oBAAoB,CAAC,CAgC/B;AAED,gFAAgF;AAChF,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAEpC"}