stitchkit 0.125.0 → 0.126.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 (76) hide show
  1. package/CHANGELOG.md +71 -1
  2. package/dist/agent-runtime/branch-contract.d.ts +5 -0
  3. package/dist/agent-runtime/branch-contract.d.ts.map +1 -1
  4. package/dist/agent-runtime/branch-identities.d.ts +18 -0
  5. package/dist/agent-runtime/branch-identities.d.ts.map +1 -1
  6. package/dist/agent-runtime/branch-messages.d.ts +9 -2
  7. package/dist/agent-runtime/branch-messages.d.ts.map +1 -1
  8. package/dist/agent-runtime/branch-provider.d.ts.map +1 -1
  9. package/dist/agent-runtime/branch-source.d.ts +1 -1
  10. package/dist/agent-runtime/branch-source.d.ts.map +1 -1
  11. package/dist/agent-runtime/store-branch.d.ts.map +1 -1
  12. package/dist/agent-runtime/store-conformance-branch.d.ts.map +1 -1
  13. package/dist/application/watch-hub-core.d.ts +2 -1
  14. package/dist/application/watch-hub-core.d.ts.map +1 -1
  15. package/dist/application/watch-hub-source.d.ts +2 -0
  16. package/dist/application/watch-hub-source.d.ts.map +1 -1
  17. package/dist/application/watch-hub.d.ts +20 -1
  18. package/dist/application/watch-hub.d.ts.map +1 -1
  19. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  20. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  21. package/dist/entrypoints/agent-runtime/sqlite/bun.js +4 -4
  22. package/dist/entrypoints/agent-runtime/sqlite/node.js +4 -4
  23. package/dist/entrypoints/agent-runtime/testing.js +31 -7
  24. package/dist/entrypoints/agent-runtime.js +4 -4
  25. package/dist/entrypoints/application.d.ts +1 -1
  26. package/dist/entrypoints/application.d.ts.map +1 -1
  27. package/dist/entrypoints/application.js +55 -8
  28. package/dist/entrypoints/bin/upgrade-cli.js +2 -0
  29. package/dist/entrypoints/files/packaging.js +2 -2
  30. package/dist/entrypoints/node.js +2 -1
  31. package/dist/entrypoints/process.js +2 -2
  32. package/dist/entrypoints/server.d.ts +1 -1
  33. package/dist/entrypoints/server.d.ts.map +1 -1
  34. package/dist/entrypoints/server.js +7 -7
  35. package/dist/entrypoints/tools/mcp.js +3 -1
  36. package/dist/entrypoints/tools/toolkit.js +3 -1
  37. package/dist/entrypoints/tools.js +4 -4
  38. package/dist/{index-gbj964dt.js → index-103dp7fz.js} +54 -31
  39. package/dist/{index-fgzbc06j.js → index-48acz7z0.js} +1 -1
  40. package/dist/{index-8wzhmgpa.js → index-4efxzrht.js} +1 -1
  41. package/dist/{index-cj5f0x4y.js → index-57ppvpw0.js} +1 -1
  42. package/dist/{index-7q05ag0z.js → index-7zksb1ty.js} +1 -1
  43. package/dist/{index-568w258r.js → index-a6w6mwda.js} +1 -1
  44. package/dist/{index-0sg3wnzr.js → index-ft2wvst5.js} +101 -32
  45. package/dist/{index-gdqawggb.js → index-jjvr9f15.js} +14 -0
  46. package/dist/{index-pq7rkwkk.js → index-m200b8hs.js} +65 -12
  47. package/dist/{index-r8swbw1x.js → index-pa9bhefy.js} +1 -1
  48. package/dist/internal/coalesced-task.d.ts +14 -2
  49. package/dist/internal/coalesced-task.d.ts.map +1 -1
  50. package/dist/internal/upgrade-affects.d.ts.map +1 -1
  51. package/dist/process/group-settlement.d.ts +2 -0
  52. package/dist/process/group-settlement.d.ts.map +1 -1
  53. package/dist/server/context.d.ts +2 -2
  54. package/dist/server/context.d.ts.map +1 -1
  55. package/dist/server/create.d.ts.map +1 -1
  56. package/dist/server/error-dispatch.d.ts +2 -0
  57. package/dist/server/error-dispatch.d.ts.map +1 -1
  58. package/dist/server/handler-state.d.ts +3 -0
  59. package/dist/server/handler-state.d.ts.map +1 -1
  60. package/dist/server/middleware/cors.d.ts +48 -3
  61. package/dist/server/middleware/cors.d.ts.map +1 -1
  62. package/dist/server/types.d.ts +8 -2
  63. package/dist/server/types.d.ts.map +1 -1
  64. package/llms/agent-runtime.2.txt +30 -0
  65. package/llms/agent-runtime.4.txt +1 -1
  66. package/llms/application.3.txt +9 -3
  67. package/llms/live.txt +28 -1
  68. package/llms/server.3.txt +2 -1
  69. package/llms/server.5.txt +3 -1
  70. package/llms/server.txt +44 -1
  71. package/llms/stitchkit.txt +3 -3
  72. package/llms/{upgrading-0.106.0-0.125.0.txt → upgrading-0.106.0-0.126.0.txt} +42 -3
  73. package/llms/upgrading.txt +1 -1
  74. package/llms-full.txt +159 -11
  75. package/llms.txt +5 -5
  76. package/package.json +4 -4
@@ -4,7 +4,7 @@ import {
4
4
  AgentSandboxRestrictionSchema2,
5
5
  AgentSandboxGradeSchema2,
6
6
  AGENT_CODING_TOOL_NAMES
7
- } from "./index-8wzhmgpa.js";
7
+ } from "./index-4efxzrht.js";
8
8
  import {
9
9
  AgentRecordIdSchema2,
10
10
  AgentRecordVersionSchema2,
@@ -56,6 +56,20 @@ import {
56
56
  // src/agent-runtime/branch-contract.ts
57
57
  import { z } from "zod";
58
58
  var Hash = z.string().regex(/^[a-f0-9]{64}$/);
59
+ var BranchApplicationFileSchema = z.object({
60
+ reference: z.string().min(1),
61
+ destinationReference: z.string().min(1)
62
+ }).strict();
63
+ var BranchApplicationFilesSchema = z.array(BranchApplicationFileSchema).superRefine((files, ctx) => {
64
+ for (const field of ["reference", "destinationReference"]) {
65
+ const values = files.map((file) => file[field]);
66
+ if (new Set(values).size !== values.length)
67
+ ctx.addIssue({
68
+ code: "custom",
69
+ message: `Branch application files repeat a ${field}`
70
+ });
71
+ }
72
+ });
59
73
  var BranchAgentConversationInputSchema2 = z.object({
60
74
  requestKey: AgentRecordIdSchema2,
61
75
  destinationConversationId: AgentRecordIdSchema2,
@@ -70,7 +84,9 @@ var BranchAgentConversationInputSchema2 = z.object({
70
84
  bytes: z.custom((value) => value instanceof Uint8Array)
71
85
  }).strict()
72
86
  ]),
73
- artifactAuthorization: AgentCodingToolAuthorizationSchema2.optional()
87
+ artifactAuthorization: AgentCodingToolAuthorizationSchema2.optional(),
88
+ applicationFiles: BranchApplicationFilesSchema.optional(),
89
+ applicationKeys: z.array(z.string().min(1)).optional()
74
90
  }).strict();
75
91
  var AgentConversationBranchReceiptSchema2 = z.object({
76
92
  schemaVersion: z.literal(1),
@@ -979,9 +995,9 @@ import { z as z8 } from "zod";
979
995
 
980
996
  // src/agent-runtime/branch-messages.ts
981
997
  import { z as z5 } from "zod";
982
- function branchOpaqueJson(value) {
998
+ function branchOpaqueJson(ids, value) {
983
999
  if (Array.isArray(value))
984
- return value.map(branchOpaqueJson);
1000
+ return value.map((entry) => branchOpaqueJson(ids, entry));
985
1001
  if (value !== null && typeof value === "object") {
986
1002
  for (const key of [
987
1003
  "reference",
@@ -994,11 +1010,16 @@ function branchOpaqueJson(value) {
994
1010
  "operationId",
995
1011
  "artifactId"
996
1012
  ]) {
997
- if (key in value)
998
- throw new TypeError(`Branch cannot rekey an opaque payload containing ${key}`);
1013
+ if (!(key in value))
1014
+ continue;
1015
+ const entry = value[key];
1016
+ if (!ids.isApplicationKey(key))
1017
+ throw new TypeError(`Branch cannot rekey an opaque payload containing ${key}; declare it in applicationKeys if it is application data`);
1018
+ if (typeof entry === "string" && ids.isSourceIdentity(entry))
1019
+ throw new TypeError(`Branch cannot carry a source identity under the application key ${key}`);
999
1020
  }
1000
1021
  for (const entry of Object.values(value))
1001
- branchOpaqueJson(entry);
1022
+ branchOpaqueJson(ids, entry);
1002
1023
  }
1003
1024
  return value;
1004
1025
  }
@@ -1040,15 +1061,15 @@ function branchToolJson(ids, name, value, output) {
1040
1061
  }
1041
1062
  };
1042
1063
  }
1043
- return branchOpaqueJson(value);
1064
+ return branchOpaqueJson(ids, value);
1044
1065
  }
1045
1066
  function branchPart(ids, part) {
1046
1067
  switch (part.type) {
1047
1068
  case "file":
1048
- return { ...part, reference: ids.reference("spill", part.reference) };
1069
+ return { ...part, reference: ids.fileReference(part.reference) };
1049
1070
  case "tool-call": {
1050
1071
  if (part.provider)
1051
- branchOpaqueJson(part.provider.data);
1072
+ branchOpaqueJson(ids, part.provider.data);
1052
1073
  return {
1053
1074
  ...part,
1054
1075
  callId: ids.reference("call", part.callId),
@@ -1060,7 +1081,7 @@ function branchPart(ids, part) {
1060
1081
  ...part,
1061
1082
  callId: ids.reference("call", part.callId),
1062
1083
  ...part.output !== undefined && {
1063
- output: part.outcome === "success" ? branchToolJson(ids, part.toolName, part.output, true) : branchOpaqueJson(part.output)
1084
+ output: part.outcome === "success" ? branchToolJson(ids, part.toolName, part.output, true) : branchOpaqueJson(ids, part.output)
1064
1085
  }
1065
1086
  };
1066
1087
  case "tool-approval-request":
@@ -1075,7 +1096,7 @@ function branchPart(ids, part) {
1075
1096
  throw new TypeError("Branch cannot rekey an opaque provider part");
1076
1097
  case "reasoning":
1077
1098
  if (part.provider)
1078
- branchOpaqueJson(part.provider.data);
1099
+ branchOpaqueJson(ids, part.provider.data);
1079
1100
  return part;
1080
1101
  default:
1081
1102
  return part;
@@ -1091,7 +1112,7 @@ function branchMessage(ids, sourceConversationId, message) {
1091
1112
  ...message.runId && { runId: ids.reference("run", message.runId) },
1092
1113
  parts: message.parts.map((part) => branchPart(ids, part)),
1093
1114
  ...message.metadata && {
1094
- metadata: z5.record(z5.string(), z5.json()).parse(branchOpaqueJson(message.metadata))
1115
+ metadata: z5.record(z5.string(), z5.json()).parse(branchOpaqueJson(ids, message.metadata))
1095
1116
  }
1096
1117
  };
1097
1118
  }
@@ -1174,7 +1195,7 @@ function branchObservation(ids, kind, raw) {
1174
1195
  if (!value || canonicalAgentJson2(value) !== canonicalAgentJson2(raw))
1175
1196
  throw new TypeError("Branch cannot rekey opaque durability payload");
1176
1197
  if ("encoded" in value)
1177
- branchOpaqueJson(z6.json().parse(JSON.parse(value.encoded)));
1198
+ branchOpaqueJson(ids, z6.json().parse(JSON.parse(value.encoded)));
1178
1199
  return {
1179
1200
  ...value,
1180
1201
  runId: ids.reference("run", value.runId),
@@ -1189,7 +1210,7 @@ function branchObservation(ids, kind, raw) {
1189
1210
  }).strict().parse(raw);
1190
1211
  if (kind === "state/set") {
1191
1212
  const value = State.parse(raw);
1192
- branchOpaqueJson(value.value);
1213
+ branchOpaqueJson(ids, value.value);
1193
1214
  return value;
1194
1215
  }
1195
1216
  if (kind === "retry/scheduled" || kind === "retry/started")
@@ -1205,9 +1226,9 @@ function branchObservation(ids, kind, raw) {
1205
1226
  if (kind.startsWith("child/")) {
1206
1227
  const value = Child.parse(raw);
1207
1228
  if (value.budget)
1208
- branchOpaqueJson(value.budget);
1229
+ branchOpaqueJson(ids, value.budget);
1209
1230
  if (value.input)
1210
- branchOpaqueJson(value.input);
1231
+ branchOpaqueJson(ids, value.input);
1211
1232
  return {
1212
1233
  ...value,
1213
1234
  ...value.childConversationId && {
@@ -1244,13 +1265,13 @@ import { createHash as createHash3 } from "node:crypto";
1244
1265
  function hash(value) {
1245
1266
  return createHash3("sha256").update(canonicalAgentJson2(value)).digest("hex");
1246
1267
  }
1247
- function checkFileData(value) {
1268
+ function checkFileData(ids, value) {
1248
1269
  if (value === null || typeof value !== "object" || Array.isArray(value))
1249
1270
  return;
1250
1271
  if (value.type === "reference" && "reference" in value)
1251
- branchOpaqueJson(value.reference);
1272
+ branchOpaqueJson(ids, value.reference);
1252
1273
  else if (!("type" in value) && value.binary !== true)
1253
- branchOpaqueJson(value);
1274
+ branchOpaqueJson(ids, value);
1254
1275
  }
1255
1276
 
1256
1277
  class BranchProvider {
@@ -1265,16 +1286,16 @@ class BranchProvider {
1265
1286
  if (hash(value.message) !== value.sha256)
1266
1287
  throw new TypeError("Branch provider message digest is inconsistent");
1267
1288
  if (value.message.providerOptions)
1268
- branchOpaqueJson(value.message.providerOptions);
1289
+ branchOpaqueJson(this.ids, value.message.providerOptions);
1269
1290
  const message = {
1270
1291
  ...value.message,
1271
1292
  content: typeof value.message.content === "string" ? value.message.content : value.message.content.map((part) => {
1272
1293
  if ("providerOptions" in part && part.providerOptions)
1273
- branchOpaqueJson(part.providerOptions);
1294
+ branchOpaqueJson(this.ids, part.providerOptions);
1274
1295
  if (part.type === "file" || part.type === "reasoning-file")
1275
- checkFileData(part.data);
1296
+ checkFileData(this.ids, part.data);
1276
1297
  if (part.type === "image")
1277
- checkFileData(part.image);
1298
+ checkFileData(this.ids, part.image);
1278
1299
  if (part.type === "tool-call")
1279
1300
  return {
1280
1301
  ...part,
@@ -1283,19 +1304,19 @@ class BranchProvider {
1283
1304
  };
1284
1305
  if (part.type === "tool-result") {
1285
1306
  if ("providerOptions" in part.output && part.output.providerOptions)
1286
- branchOpaqueJson(part.output.providerOptions);
1307
+ branchOpaqueJson(this.ids, part.output.providerOptions);
1287
1308
  if (part.output.type === "error-json")
1288
- branchOpaqueJson(part.output.value);
1309
+ branchOpaqueJson(this.ids, part.output.value);
1289
1310
  if (part.output.type === "content")
1290
1311
  for (const item of part.output.value) {
1291
1312
  if (item.providerOptions)
1292
- branchOpaqueJson(item.providerOptions);
1313
+ branchOpaqueJson(this.ids, item.providerOptions);
1293
1314
  if (item.type === "file")
1294
- checkFileData(item.data);
1315
+ checkFileData(this.ids, item.data);
1295
1316
  if ("providerReference" in item)
1296
- branchOpaqueJson(item.providerReference);
1317
+ branchOpaqueJson(this.ids, item.providerReference);
1297
1318
  if ("fileId" in item && typeof item.fileId !== "string")
1298
- branchOpaqueJson(item.fileId);
1319
+ branchOpaqueJson(this.ids, item.fileId);
1299
1320
  }
1300
1321
  return {
1301
1322
  ...part,
@@ -1567,6 +1588,8 @@ class BranchIdentities {
1567
1588
  sourceConversationId;
1568
1589
  definitions = new Map;
1569
1590
  references = new Map;
1591
+ applicationFiles = new Map;
1592
+ applicationKeys = new Set;
1570
1593
  constructor(conversationId, requestKey, sourceConversationId) {
1571
1594
  this.conversationId = conversationId;
1572
1595
  this.requestKey = requestKey;
@@ -1588,6 +1611,36 @@ class BranchIdentities {
1588
1611
  this.references.set(kind, referenced);
1589
1612
  return target;
1590
1613
  }
1614
+ declareApplicationFiles(files) {
1615
+ for (const file of files) {
1616
+ if (this.definitions.get("spill")?.has(file.reference))
1617
+ throw new TypeError("Branch application file reference is also a spill reference");
1618
+ this.applicationFiles.set(file.reference, file.destinationReference);
1619
+ }
1620
+ }
1621
+ declareApplicationKeys(keys) {
1622
+ for (const key of keys)
1623
+ this.applicationKeys.add(key);
1624
+ }
1625
+ isApplicationKey(key) {
1626
+ return this.applicationKeys.has(key);
1627
+ }
1628
+ isSourceIdentity(value) {
1629
+ if (value === this.sourceConversationId)
1630
+ return true;
1631
+ for (const values of this.definitions.values())
1632
+ if (values.has(value))
1633
+ return true;
1634
+ return false;
1635
+ }
1636
+ fileReference(source) {
1637
+ if (this.definitions.get("spill")?.has(source))
1638
+ return this.reference("spill", source);
1639
+ const target = this.applicationFiles.get(source);
1640
+ if (target === undefined)
1641
+ throw new TypeError("Branch contains a foreign or missing file reference");
1642
+ return target;
1643
+ }
1591
1644
  referenced(kind) {
1592
1645
  return this.references.get(kind) ?? new Set;
1593
1646
  }
@@ -1707,7 +1760,11 @@ function boundary(events, throughRunId) {
1707
1760
  }
1708
1761
  throw new TypeError("Branch boundary run has no exact settled event");
1709
1762
  }
1710
- function prepareBranchSource(bytes, source) {
1763
+ function prepareBranchSource(bytes, {
1764
+ source,
1765
+ applicationFiles = [],
1766
+ applicationKeys = []
1767
+ }) {
1711
1768
  const archive = decodeAgentConversationArchive2(bytes);
1712
1769
  if (source.kind === "conversation" && source.conversationId !== archive.conversationId)
1713
1770
  throw new TypeError("Branch source identity changed");
@@ -1739,6 +1796,8 @@ function prepareBranchSource(bytes, source) {
1739
1796
  const validationIds = new BranchIdentities("branch-validation", "branch-validation", archive.conversationId);
1740
1797
  for (const spill of allSpills)
1741
1798
  validationIds.define("spill", spill.reference);
1799
+ validationIds.declareApplicationFiles(applicationFiles);
1800
+ validationIds.declareApplicationKeys(applicationKeys);
1742
1801
  rekeyBranchEvents(validationIds, archive.conversationId, archive.events, full.retainedMessages);
1743
1802
  for (const spill of allSpills) {
1744
1803
  if (spill.runId)
@@ -1758,6 +1817,8 @@ function prepareBranchSource(bytes, source) {
1758
1817
  const selectedIds = new BranchIdentities("branch-validation", "branch-validation", archive.conversationId);
1759
1818
  for (const spill of allSpills)
1760
1819
  selectedIds.define("spill", spill.reference);
1820
+ selectedIds.declareApplicationFiles(applicationFiles);
1821
+ selectedIds.declareApplicationKeys(applicationKeys);
1761
1822
  rekeyBranchEvents(selectedIds, archive.conversationId, events, replay.retainedMessages);
1762
1823
  const references = selectedIds.referenced("spill");
1763
1824
  const spills = allSpills.filter((spill) => references.has(spill.reference));
@@ -1796,6 +1857,12 @@ async function branchConversation(driver, raw) {
1796
1857
  };
1797
1858
  const fingerprint = branchHash({
1798
1859
  ...input,
1860
+ ...input.applicationFiles && {
1861
+ applicationFiles: input.applicationFiles.toSorted((left, right) => left.reference.localeCompare(right.reference))
1862
+ },
1863
+ ...input.applicationKeys && {
1864
+ applicationKeys: [...new Set(input.applicationKeys)].sort()
1865
+ },
1799
1866
  source: input.source.kind === "archive" ? {
1800
1867
  kind: "archive",
1801
1868
  digest: createHash7("sha256").update(input.source.bytes).digest("hex")
@@ -1819,7 +1886,7 @@ async function branchConversation(driver, raw) {
1819
1886
  if (input.source.kind === "conversation" && !await driver.head.load(tx, input.source.conversationId) && (await driver.events.list(tx, { conversationId: input.source.conversationId, limit: 1 })).items.length === 0)
1820
1887
  throw new TypeError("Branch source conversation was not found");
1821
1888
  const bytes = input.source.kind === "archive" ? input.source.bytes : await exportConversationIn(driver, tx, input.source.conversationId);
1822
- const source = prepareBranchSource(bytes, input.source);
1889
+ const source = prepareBranchSource(bytes, input);
1823
1890
  if (source.conversationId === input.destinationConversationId)
1824
1891
  throw new TypeError("Branch requires a new conversation identity");
1825
1892
  if (source.spills.length > 0 && (!input.artifactAuthorization || !driver.archive))
@@ -1827,6 +1894,8 @@ async function branchConversation(driver, raw) {
1827
1894
  const ids = new BranchIdentities(input.destinationConversationId, input.requestKey, source.conversationId);
1828
1895
  for (const spill of source.spills)
1829
1896
  ids.define("spill", spill.reference);
1897
+ ids.declareApplicationFiles(input.applicationFiles ?? []);
1898
+ ids.declareApplicationKeys(input.applicationKeys ?? []);
1830
1899
  const events = rekeyBranchEvents(ids, source.conversationId, source.events, source.replay.retainedMessages);
1831
1900
  const replay = replayBranchEvents(input.destinationConversationId, events);
1832
1901
  if (replay.baseline?.compacted?.length && !driver.history.restore)
@@ -129,6 +129,18 @@ function observationFailureReason(cause) {
129
129
  const signal = "signal" in cause && typeof cause.signal === "string" ? cause.signal : undefined;
130
130
  return (errnoOf(cause) ?? signal ?? cause.name).slice(0, 32);
131
131
  }
132
+ var GROUP_EXIT_QUICK_LOOKS = 8;
133
+ async function groupLeavesShortly(pid, deadline) {
134
+ for (let look = 0;look < GROUP_EXIT_QUICK_LOOKS; look += 1) {
135
+ const remaining = deadline - performance.now();
136
+ if (remaining <= 0)
137
+ return false;
138
+ await sleep(Math.min(1, remaining));
139
+ if (!processGroupExists(pid))
140
+ return true;
141
+ }
142
+ return false;
143
+ }
132
144
  async function waitForProcessGroupExit(pid, deadline, killLiveMembers) {
133
145
  if (pid === undefined)
134
146
  return;
@@ -148,6 +160,8 @@ async function waitForProcessGroupExit(pid, deadline, killLiveMembers) {
148
160
  throw new GroupSettlementError("Command process group settlement was not confirmed after SIGKILL", { ...observation(), failure: "deadline" });
149
161
  if (!processGroupExists(pid))
150
162
  return;
163
+ if (observations === 0 && await groupLeavesShortly(pid, deadline))
164
+ return;
151
165
  const table = await processGroups(remaining);
152
166
  observations++;
153
167
  if (!hasLiveGroupMember(table, pid))
@@ -1,7 +1,59 @@
1
1
  // src/server/middleware/cors.ts
2
+ import { z } from "zod";
3
+ var CorsOriginDecisionSchema = z.union([
4
+ z.literal(false),
5
+ z.object({ credentials: z.boolean() }).strict()
6
+ ]);
7
+ function isOriginPolicy(config) {
8
+ return typeof config.origin === "function";
9
+ }
10
+ function isSerializedOrigin(origin) {
11
+ if (!URL.canParse(origin))
12
+ return false;
13
+ const url = new URL(origin);
14
+ return url.host !== "" && origin === `${url.protocol}//${url.host}`;
15
+ }
16
+ function resolveRequestCors(config, origin) {
17
+ if (!isOriginPolicy(config)) {
18
+ return {
19
+ headers: corsHeaders2(config, origin),
20
+ safelistedBody: config.origin === undefined || config.origin === "*" ? "no-allow-list" : isOriginAllowed(config, origin) ? "allowed" : "refused"
21
+ };
22
+ }
23
+ if (!origin || !isSerializedOrigin(origin))
24
+ return deniedRequestCors(config);
25
+ return askPolicy(config, origin);
26
+ }
27
+ async function askPolicy(config, origin) {
28
+ const parsed = CorsOriginDecisionSchema.safeParse(await config.origin(origin));
29
+ if (!parsed.success) {
30
+ throw new TypeError("[stitchkit] cors: an origin resolver must answer false or { credentials: boolean }");
31
+ }
32
+ if (parsed.data === false)
33
+ return deniedRequestCors(config);
34
+ return {
35
+ headers: {
36
+ ...permissionHeaders(config, origin, parsed.data.credentials),
37
+ Vary: "Origin"
38
+ },
39
+ safelistedBody: parsed.data.credentials ? "allowed" : "refused"
40
+ };
41
+ }
42
+ function deniedRequestCors(config) {
43
+ return {
44
+ headers: { ...permissionHeaders(config, undefined, false), Vary: "Origin" },
45
+ safelistedBody: "refused"
46
+ };
47
+ }
2
48
  var DEFAULT_CORS_ALLOW_HEADERS2 = "Content-Type, Authorization, X-Trace-Id, traceparent, tracestate";
3
49
  var DEFAULT_CORS_EXPOSE_HEADERS2 = "Content-Disposition, Content-Length, Content-Range, Accept-Ranges, ETag, Last-Modified, X-Request-Id, X-Build-Id";
4
50
  function assertCorsConfig(config) {
51
+ if (isOriginPolicy(config)) {
52
+ if (config.credentials !== undefined) {
53
+ throw new Error("[stitchkit] cors: an origin resolver decides credentials per origin; remove `credentials`.");
54
+ }
55
+ return;
56
+ }
5
57
  if (config.credentials && (config.origin === undefined || config.origin === "*")) {
6
58
  throw new Error("[stitchkit] cors: `credentials: true` cannot be combined with a wildcard origin. " + "Set `origin` to an explicit string or list.");
7
59
  }
@@ -36,7 +88,13 @@ function isOriginAllowed(config, requestOrigin) {
36
88
  return allowed.some((origin) => origin.toLowerCase() === lower);
37
89
  }
38
90
  function corsHeaders2(config, requestOrigin) {
39
- const allowOrigin = resolveOrigin(config, requestOrigin);
91
+ const headers = permissionHeaders(config, resolveOrigin(config, requestOrigin), config.credentials === true);
92
+ if (Array.isArray(config.origin)) {
93
+ headers.Vary = "Origin";
94
+ }
95
+ return headers;
96
+ }
97
+ function permissionHeaders(config, allowOrigin, credentials) {
40
98
  const headers = {
41
99
  "Access-Control-Allow-Methods": config.methods ?? "GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS",
42
100
  "Access-Control-Allow-Headers": config.headers ?? DEFAULT_CORS_ALLOW_HEADERS2
@@ -47,13 +105,10 @@ function corsHeaders2(config, requestOrigin) {
47
105
  }
48
106
  if (allowOrigin !== undefined) {
49
107
  headers["Access-Control-Allow-Origin"] = allowOrigin;
50
- if (config.credentials) {
108
+ if (credentials) {
51
109
  headers["Access-Control-Allow-Credentials"] = "true";
52
110
  }
53
111
  }
54
- if (Array.isArray(config.origin)) {
55
- headers.Vary = "Origin";
56
- }
57
112
  return headers;
58
113
  }
59
114
  function corsPreflightResponse2(config, req) {
@@ -62,13 +117,11 @@ function corsPreflightResponse2(config, req) {
62
117
  headers: corsHeaders2(config, req.headers.get("origin"))
63
118
  });
64
119
  }
65
- function requestCorsHeaders(cors, req) {
66
- if (!cors)
67
- return {};
68
- return corsHeaders2(cors, req.headers.get("origin"));
120
+ function requestCorsHeaders(cors) {
121
+ return cors ? { ...cors.headers } : {};
69
122
  }
70
- function applyCors(res, cors, req) {
71
- const extra = requestCorsHeaders(cors, req);
123
+ function applyCors(res, cors) {
124
+ const extra = requestCorsHeaders(cors);
72
125
  if (Object.keys(extra).length === 0)
73
126
  return res;
74
127
  try {
@@ -101,4 +154,4 @@ function setCorsHeader(headers, key, value) {
101
154
  headers.set("Vary", `${existing}, ${value}`);
102
155
  }
103
156
 
104
- export { DEFAULT_CORS_ALLOW_HEADERS2, DEFAULT_CORS_EXPOSE_HEADERS2, assertCorsConfig, isOriginAllowed, corsHeaders2, corsPreflightResponse2, requestCorsHeaders, applyCors };
157
+ export { resolveRequestCors, deniedRequestCors, DEFAULT_CORS_ALLOW_HEADERS2, DEFAULT_CORS_EXPOSE_HEADERS2, assertCorsConfig, corsHeaders2, corsPreflightResponse2, requestCorsHeaders, applyCors };
@@ -17,7 +17,7 @@ import {
17
17
  replaceMessage,
18
18
  ArchiveSpillSchema,
19
19
  createAgentRuntimeStore2
20
- } from "./index-0sg3wnzr.js";
20
+ } from "./index-ft2wvst5.js";
21
21
 
22
22
  // src/agent-runtime/store-memory.ts
23
23
  import { z as z2 } from "zod";
@@ -3,13 +3,25 @@ export interface CoalescedTask {
3
3
  readonly running: boolean;
4
4
  /** A trigger arrived that no pass has served yet. */
5
5
  readonly pending: boolean;
6
+ /** Milliseconds until the pass after a failure may start; `0` when nothing holds it. */
7
+ readonly retryInMs: number;
6
8
  trigger(): void;
7
9
  pauseRetry(): void;
8
10
  close(): void;
9
11
  }
10
- /** One job per key; hints during work become one trailing pass, failures retain retry. */
12
+ /** What a pass that neither succeeded nor failed returns: its work was abandoned. */
13
+ export declare const ABANDONED_PASS: unique symbol;
14
+ /**
15
+ * One job per key; hints during work become one trailing pass, failures retain retry.
16
+ *
17
+ * The pause after a failure belongs to the job, not to whoever is asking: a
18
+ * paused retry keeps the moment it is due, and a trigger before that moment
19
+ * waits for it instead of running at once. A pass that returns
20
+ * {@link ABANDONED_PASS} stays dirty and leaves the failure count alone.
21
+ */
11
22
  export declare function createCoalescedTask(config: {
12
- run(): Promise<void>;
23
+ /** Resolves with {@link ABANDONED_PASS} for abandoned work; any other value is a completed pass. */
24
+ run(): Promise<unknown>;
13
25
  active(): boolean;
14
26
  onError(error: unknown): void;
15
27
  backoff: BackoffPolicy;
@@ -1 +1 @@
1
- {"version":3,"file":"coalesced-task.d.ts","sourceRoot":"","sources":["../../src/internal/coalesced-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,WAAW,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,OAAO,IAAI,IAAI,CAAC;IAChB,UAAU,IAAI,IAAI,CAAC;IACnB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,MAAM,IAAI,OAAO,CAAC;IAClB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;CACxB,GAAG,aAAa,CAuDhB"}
1
+ {"version":3,"file":"coalesced-task.d.ts","sourceRoot":"","sources":["../../src/internal/coalesced-task.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,WAAW,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,IAAI,IAAI,CAAC;IAChB,UAAU,IAAI,IAAI,CAAC;IACnB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,qFAAqF;AACrF,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,oGAAoG;IACpG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACxB,MAAM,IAAI,OAAO,CAAC;IAClB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,aAAa,CAAC;CACxB,GAAG,aAAa,CAyEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade-affects.d.ts","sourceRoot":"","sources":["../../src/internal/upgr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"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,sEAAsE;AACtE,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAC5B;IACE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACpD,GACD;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC;AAEjE,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAOD,yEAAyE;AACzE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,SAAkB,IAAI,yBAAyB;CAChD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,uBAAuB,EAAE,CA6BxE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAmBhF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAiBtE;AA+DD,+FAA+F;AAC/F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,EAAE,CAGrE"}
@@ -2,6 +2,8 @@
2
2
  export declare function hasLiveGroupMember(table: string, group: number): boolean;
3
3
  /** A bounded name for what stopped the observation; caller messages stay out of diagnostics. */
4
4
  export declare function observationFailureReason(cause: unknown): string;
5
+ /** How many times the kernel is asked, a millisecond apart, before the first process-table snapshot. */
6
+ export declare const GROUP_EXIT_QUICK_LOOKS = 8;
5
7
  /** A delivered SIGKILL is asynchronous; do not report cleanup until every group member is dead. */
6
8
  export declare function waitForProcessGroupExit(pid: number | undefined, deadline: number, killLiveMembers?: () => Promise<boolean>): Promise<void>;
7
9
  //# sourceMappingURL=group-settlement.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"group-settlement.d.ts","sourceRoot":"","sources":["../../src/process/group-settlement.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQxE;AAgBD,gGAAgG;AAChG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAK/D;AAED,mGAAmG;AACnG,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,MAAM,EAChB,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAmDf"}
1
+ {"version":3,"file":"group-settlement.d.ts","sourceRoot":"","sources":["../../src/process/group-settlement.ts"],"names":[],"mappings":"AAMA,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAQxE;AAgBD,gGAAgG;AAChG,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAK/D;AAED,wGAAwG;AACxG,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAaxC,mGAAmG;AACnG,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,QAAQ,EAAE,MAAM,EAChB,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,IAAI,CAAC,CAuDf"}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { RuntimeContext } from '../contract/runtime-context.js';
6
6
  import { type ClientIpOptions } from '../internal/request.js';
7
- import { type CorsConfig } from './middleware/cors.js';
7
+ import type { RequestCors } from './middleware/cors.js';
8
8
  import { type MultipartLifecycle } from './multipart.js';
9
9
  import type { AuthorizationContext, MethodDef } from './types.js';
10
10
  /**
@@ -26,6 +26,6 @@ export declare function buildBaseContext(req: Request, url: URL, pathParams: Rec
26
26
  */
27
27
  export declare function parsePathParamsInto(ctx: RuntimeContext, method: MethodDef): void;
28
28
  /** Parse query, JSON or multipart payload after pre-body authorization. */
29
- export declare function parseRequestPayloadInto(ctx: RuntimeContext, req: Request, url: URL, method: MethodDef, maxJsonBodyBytes?: number, cors?: CorsConfig): Promise<MultipartLifecycle | undefined>;
29
+ export declare function parseRequestPayloadInto(ctx: RuntimeContext, req: Request, url: URL, method: MethodDef, maxJsonBodyBytes?: number, cors?: RequestCors): Promise<MultipartLifecycle | undefined>;
30
30
  export declare function buildErrorContext(req: Request, url: URL, traceId: string, clientIp: ClientIpOptions): RuntimeContext;
31
31
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/server/context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,KAAK,eAAe,EAAmC,MAAM,qBAAqB,CAAC;AAG5F,OAAO,EAAE,KAAK,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,KAAK,kBAAkB,EAAkB,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA2C/D;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE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;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAIhF;AAED,2EAA2E;AAC3E,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,SAAS,EACjB,gBAAgB,CAAC,EAAE,MAAM,EACzB,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA8BzC;AAED,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,GACxB,cAAc,CAYhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/server/create.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAC7C,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,YAAY,CAAC,OAAO,CAAC,CA0DvB"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/server/create.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAsBH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D,wBAAgB,aAAa,CAAC,OAAO,GAAG,OAAO,EAC7C,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,YAAY,CAAC,OAAO,CAAC,CA0DvB"}
@@ -1,6 +1,7 @@
1
1
  import type { RuntimeContext } from '../contract/runtime-context.js';
2
2
  import type { ClientIpOptions } from '../internal/request.js';
3
3
  import type { CompleteRequest, HandlerState, RespondError } from './handler-state.js';
4
+ import { type RequestCors } from './middleware/cors.js';
4
5
  import type { LifecycleHooks, MethodDef, StitchLogger } from './types.js';
5
6
  /** What the error path needs to know about the request it answers. */
6
7
  export interface ErrorRequest {
@@ -9,6 +10,7 @@ export interface ErrorRequest {
9
10
  traceId: string;
10
11
  clientIp: ClientIpOptions;
11
12
  complete: CompleteRequest;
13
+ cors: RequestCors | undefined;
12
14
  }
13
15
  /**
14
16
  * The request's error responder. Matched group policy, global policy, then the
@@ -1 +1 @@
1
- {"version":3,"file":"error-dispatch.d.ts","sourceRoot":"","sources":["../../src/server/error-dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI3D,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA0BvE,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,eAAe,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAC1C,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAC5B,OAAO,EAAE,YAAY,GACpB,YAAY,CA2Dd;AAED,2FAA2F;AAC3F,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,YAAY,GAAG,IAAI,C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AQ,KAAK,QAAQ,CAAC;CAC3C,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAqBhC"}
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { RuntimeContext } from '../contract/runtime-context.js';
8
8
  import { type ClientIpOptions } from '../internal/request.js';
9
+ import { type RequestCors } from './middleware/cors.js';
9
10
  import type { RouteMap } from './router.js';
10
11
  import type { HandlerConfig, LifecycleHooks, LoggingConfig, MethodDef, StitchLogger } from './types.js';
11
12
  export interface HandlerState<TServer> {
@@ -39,6 +40,8 @@ export interface RequestState<TServer> {
39
40
  ipAddress: string | undefined;
40
41
  complete: CompleteRequest;
41
42
  respondError: RespondError;
43
+ /** This request's CORS answer; absent when the handler has no CORS config. */
44
+ cors: RequestCors | undefined;
42
45
  }
43
46
  export declare function createHandlerState<TServer>(config: HandlerConfig<TServer>): HandlerState<TServer>;
44
47
  //# sourceMappingURL=handler-state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler-state.d.ts","sourceRoot":"","sources":["../../src/server/handler-state.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,qBAAqB,CAAC;AAI3E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,SAAS,EACT,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,YAAY,CAAC,OAAO;IACnC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;IACrC,KAAK,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;IACvC,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,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