stitchkit 0.115.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 (140) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  3. package/dist/agent-runtime/run-acquisition.d.ts +9 -2
  4. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  5. package/dist/agent-runtime/run-execution.d.ts +3 -0
  6. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  7. package/dist/agent-runtime/run-failure.d.ts +4 -1
  8. package/dist/agent-runtime/run-failure.d.ts.map +1 -1
  9. package/dist/agent-runtime/run-store-retry.d.ts +8 -0
  10. package/dist/agent-runtime/run-store-retry.d.ts.map +1 -0
  11. package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
  12. package/dist/agent-runtime/run-unacquired.d.ts +19 -0
  13. package/dist/agent-runtime/run-unacquired.d.ts.map +1 -0
  14. package/dist/agent-runtime/store-conformance.d.ts +8 -0
  15. package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
  16. package/dist/agent-runtime/store-driver-contract.d.ts +5 -0
  17. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  18. package/dist/agent-runtime/terminal-commit.d.ts +34 -4
  19. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  20. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
  21. package/dist/entrypoints/agent-runtime/harness.js +4 -4
  22. package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
  23. package/dist/entrypoints/agent-runtime/sqlite/bun.js +7 -7
  24. package/dist/entrypoints/agent-runtime/sqlite/node.js +7 -7
  25. package/dist/entrypoints/agent-runtime/testing.js +26 -8
  26. package/dist/entrypoints/agent-runtime.d.ts +1 -1
  27. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  28. package/dist/entrypoints/agent-runtime.js +17 -15
  29. package/dist/entrypoints/application/diagnostic-journal.js +1 -1
  30. package/dist/entrypoints/application/directory-inbox.js +3 -3
  31. package/dist/entrypoints/cli/publish.js +2 -2
  32. package/dist/entrypoints/cli.js +3 -3
  33. package/dist/entrypoints/files.js +2 -2
  34. package/dist/entrypoints/primitives.js +51 -154
  35. package/dist/entrypoints/server.js +6 -6
  36. package/dist/entrypoints/telegram/grammy.js +2 -2
  37. package/dist/entrypoints/telegram.d.ts +1 -1
  38. package/dist/entrypoints/telegram.d.ts.map +1 -1
  39. package/dist/entrypoints/telegram.js +203 -70
  40. package/dist/entrypoints/tools.js +3 -3
  41. package/dist/entrypoints/tracking/contract.d.ts +11 -0
  42. package/dist/entrypoints/tracking/contract.d.ts.map +1 -0
  43. package/dist/entrypoints/tracking/contract.js +162 -0
  44. package/dist/entrypoints/tracking/performance.d.ts +8 -0
  45. package/dist/entrypoints/tracking/performance.d.ts.map +1 -0
  46. package/dist/entrypoints/tracking/performance.js +181 -0
  47. package/dist/entrypoints/tracking/server.d.ts +1 -0
  48. package/dist/entrypoints/tracking/server.d.ts.map +1 -1
  49. package/dist/entrypoints/tracking/server.js +40 -12
  50. package/dist/entrypoints/tracking.d.ts +4 -3
  51. package/dist/entrypoints/tracking.d.ts.map +1 -1
  52. package/dist/entrypoints/tracking.js +43 -143
  53. package/dist/entrypoints/xlsx.d.ts +4 -0
  54. package/dist/entrypoints/xlsx.d.ts.map +1 -0
  55. package/dist/entrypoints/xlsx.js +406 -0
  56. package/dist/{index-crmswbrt.js → index-073nw9qr.js} +8 -8
  57. package/dist/index-1f40z584.js +7 -0
  58. package/dist/{index-nregbbsc.js → index-6f49krb5.js} +1 -1
  59. package/dist/{index-fdk4r4r6.js → index-75ns2ybj.js} +1 -1
  60. package/dist/{index-x0ddbj85.js → index-arjmb6de.js} +36 -1
  61. package/dist/{index-944x38nv.js → index-cycp3r3e.js} +125 -182
  62. package/dist/{index-dx5cm9pc.js → index-ghtpfz4z.js} +9 -9
  63. package/dist/{index-n3v695sb.js → index-hdjmdwsj.js} +277 -96
  64. package/dist/{index-7yx8j6ay.js → index-n5sv4z0w.js} +12 -3
  65. package/dist/{index-zqkz4af9.js → index-nqxrm176.js} +1 -1
  66. package/dist/{index-j8kf56wx.js → index-q968hy6y.js} +1 -1
  67. package/dist/index-qezhmp51.js +242 -0
  68. package/dist/index-vv1sch8a.js +94 -0
  69. package/dist/{index-3qqdqwxe.js → index-w7jq3fz9.js} +25 -5
  70. package/dist/{index-fggxgbrk.js → index-xx1j310k.js} +165 -102
  71. package/dist/internal/contained-files.d.ts +10 -0
  72. package/dist/internal/contained-files.d.ts.map +1 -1
  73. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  74. package/dist/primitives/decimal.d.ts +10 -0
  75. package/dist/primitives/decimal.d.ts.map +1 -1
  76. package/dist/primitives/index.d.ts +3 -1
  77. package/dist/primitives/index.d.ts.map +1 -1
  78. package/dist/primitives/money.d.ts +20 -0
  79. package/dist/primitives/money.d.ts.map +1 -1
  80. package/dist/primitives/quantity.d.ts.map +1 -1
  81. package/dist/primitives/rounding.d.ts +40 -0
  82. package/dist/primitives/rounding.d.ts.map +1 -0
  83. package/dist/telegram/budget-transformer.d.ts +6 -3
  84. package/dist/telegram/budget-transformer.d.ts.map +1 -1
  85. package/dist/telegram/not-dispatched.d.ts +2 -2
  86. package/dist/telegram/not-dispatched.d.ts.map +1 -1
  87. package/dist/telegram/outbound-budget.d.ts +72 -20
  88. package/dist/telegram/outbound-budget.d.ts.map +1 -1
  89. package/dist/telegram/outbound-cost.d.ts +5 -0
  90. package/dist/telegram/outbound-cost.d.ts.map +1 -0
  91. package/dist/telegram/outbound-pauses.d.ts +17 -0
  92. package/dist/telegram/outbound-pauses.d.ts.map +1 -0
  93. package/dist/telegram/outbound-queue.d.ts +17 -0
  94. package/dist/telegram/outbound-queue.d.ts.map +1 -0
  95. package/dist/tools/cli/view.d.ts +7 -1
  96. package/dist/tools/cli/view.d.ts.map +1 -1
  97. package/dist/tracking/attribution.d.ts +1 -1
  98. package/dist/tracking/attribution.d.ts.map +1 -1
  99. package/dist/tracking/client-visit.d.ts +3 -1
  100. package/dist/tracking/client-visit.d.ts.map +1 -1
  101. package/dist/tracking/client.d.ts.map +1 -1
  102. package/dist/tracking/performance/collector.d.ts +61 -0
  103. package/dist/tracking/performance/collector.d.ts.map +1 -0
  104. package/dist/tracking/performance/schema.d.ts +45 -0
  105. package/dist/tracking/performance/schema.d.ts.map +1 -0
  106. package/dist/tracking/performance/summary.d.ts +12 -0
  107. package/dist/tracking/performance/summary.d.ts.map +1 -0
  108. package/dist/tracking/privacy.d.ts +5 -0
  109. package/dist/tracking/privacy.d.ts.map +1 -0
  110. package/dist/tracking/server/telemetry-health.d.ts +31 -0
  111. package/dist/tracking/server/telemetry-health.d.ts.map +1 -0
  112. package/dist/xlsx/cells.d.ts +17 -0
  113. package/dist/xlsx/cells.d.ts.map +1 -0
  114. package/dist/xlsx/render.d.ts +11 -0
  115. package/dist/xlsx/render.d.ts.map +1 -0
  116. package/dist/xlsx/schema.d.ts +119 -0
  117. package/dist/xlsx/schema.d.ts.map +1 -0
  118. package/dist/xlsx/zip.d.ts +13 -0
  119. package/dist/xlsx/zip.d.ts.map +1 -0
  120. package/llms/agent-runtime.2.txt +40 -16
  121. package/llms/agent-runtime.3.txt +17 -0
  122. package/llms/agent-runtime.txt +6 -3
  123. package/llms/cli.txt +3 -1
  124. package/llms/primitives.txt +21 -0
  125. package/llms/stitchkit.txt +9 -6
  126. package/llms/telegram.txt +39 -12
  127. package/llms/tracking-contract.txt +32 -0
  128. package/llms/tracking-performance.txt +21 -0
  129. package/llms/tracking-server.txt +1 -0
  130. package/llms/tracking.txt +75 -12
  131. package/llms/{upgrading-0.104.0-0.115.0.txt → upgrading-0.105.0-0.117.0.txt} +73 -124
  132. package/llms/{upgrading-0.44.0-0.61.0.txt → upgrading-0.44.0-0.62.0.txt} +120 -3
  133. package/llms/{upgrading-0.62.0-0.78.0.txt → upgrading-0.63.0-0.83.0.txt} +181 -120
  134. package/llms/{upgrading-0.79.0-0.103.13.txt → upgrading-0.84.0-0.104.0.txt} +124 -181
  135. package/llms/upgrading.txt +4 -4
  136. package/llms/xlsx.txt +107 -0
  137. package/llms-full.txt +390 -34
  138. package/llms.txt +15 -11
  139. package/package.json +27 -9
  140. 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 };
@@ -25,12 +25,12 @@ import {
25
25
  } from "./index-htxh46ej.js";
26
26
  import {
27
27
  writeContainedFile
28
- } from "./index-j8kf56wx.js";
28
+ } from "./index-q968hy6y.js";
29
29
  import {
30
30
  openPinnedDirectory,
31
31
  isSafeEntryName,
32
32
  containedEntryMetadata
33
- } from "./index-x0ddbj85.js";
33
+ } from "./index-arjmb6de.js";
34
34
  import {
35
35
  collectToolSurface
36
36
  } from "./index-86nbfysb.js";
@@ -1348,6 +1348,8 @@ function groupKey(value) {
1348
1348
  return ABSENT;
1349
1349
  if (value === null)
1350
1350
  return "null";
1351
+ if (value === "null" || value === ABSENT)
1352
+ return JSON.stringify(value);
1351
1353
  if (typeof value === "object")
1352
1354
  return JSON.stringify(value);
1353
1355
  return String(value);
@@ -1355,7 +1357,20 @@ function groupKey(value) {
1355
1357
  function ordered(totals, top) {
1356
1358
  const entries = [...totals].sort(([leftKey, left], [rightKey, right]) => right === left ? leftKey.localeCompare(rightKey) : right - left);
1357
1359
  const sliced = top === undefined ? entries : entries.slice(0, top);
1358
- return Object.fromEntries(sliced);
1360
+ return {
1361
+ kind: "json",
1362
+ data: Object.fromEntries(sliced),
1363
+ order: sliced.map(([key]) => key)
1364
+ };
1365
+ }
1366
+ function stringifyGroups(data, order, compact) {
1367
+ if (!isRecord(data) || order.length === 0)
1368
+ return JSON.stringify(data);
1369
+ const lines = order.map((key) => `${JSON.stringify(key)}:${compact ? "" : " "}${JSON.stringify(data[key])}`);
1370
+ return compact ? `{${lines.join(",")}}` : `{
1371
+ ${lines.join(`,
1372
+ `)}
1373
+ }`;
1359
1374
  }
1360
1375
  function numericValue(value, field) {
1361
1376
  if (isAbsent(value))
@@ -1440,7 +1455,7 @@ function renderCliView2(data, view) {
1440
1455
  const key = groupKey(readField(record, path));
1441
1456
  totals.set(key, (totals.get(key) ?? 0) + 1);
1442
1457
  }
1443
- return { kind: "json", data: ordered(totals, view.top) };
1458
+ return ordered(totals, view.top);
1444
1459
  }
1445
1460
  const path = assertFieldPresent(records, view.field);
1446
1461
  if (view.by === undefined) {
@@ -1455,7 +1470,7 @@ function renderCliView2(data, view) {
1455
1470
  const key = groupKey(readField(record, byPath));
1456
1471
  totals.set(key, (totals.get(key) ?? 0) + (numericValue(readField(record, path), view.field) ?? 0));
1457
1472
  }
1458
- return { kind: "json", data: ordered(totals, view.top) };
1473
+ return ordered(totals, view.top);
1459
1474
  }
1460
1475
 
1461
1476
  // src/tools/operations/wait-core.ts
@@ -2350,6 +2365,11 @@ async function emitManagedResult(session, command, initial, options) {
2350
2365
  stdout(viewed.text);
2351
2366
  return exit(downloadsOk ? 0 : 1);
2352
2367
  }
2368
+ if (viewed.order) {
2369
+ stdout(`${stringifyGroups(viewed.data, viewed.order, options.json === true)}
2370
+ `);
2371
+ return exit(downloadsOk ? 0 : 1);
2372
+ }
2353
2373
  result = { ...result, data: viewed.data };
2354
2374
  }
2355
2375
  const exitCode = emitResult2(result, { stdout, stderr }, emitOptionsFor(config, options.json, command));