@stackfactor/agent-utils 1.13.4 → 1.32.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 (252) hide show
  1. package/README.md +667 -23
  2. package/dist/cjs/agentProto.d.ts +13 -3
  3. package/dist/cjs/agentProto.d.ts.map +1 -1
  4. package/dist/cjs/agentProto.js +25 -4
  5. package/dist/cjs/backoff.d.ts +17 -0
  6. package/dist/cjs/backoff.d.ts.map +1 -0
  7. package/dist/cjs/backoff.js +26 -0
  8. package/dist/cjs/cancellation.d.ts +22 -0
  9. package/dist/cjs/cancellation.d.ts.map +1 -0
  10. package/dist/cjs/cancellation.js +36 -0
  11. package/dist/cjs/cli.d.ts +3 -0
  12. package/dist/cjs/cli.d.ts.map +1 -0
  13. package/dist/cjs/cli.js +85 -0
  14. package/dist/cjs/client.d.ts +11 -0
  15. package/dist/cjs/client.d.ts.map +1 -1
  16. package/dist/cjs/client.js +27 -0
  17. package/dist/cjs/const.d.ts +23 -0
  18. package/dist/cjs/const.d.ts.map +1 -1
  19. package/dist/cjs/const.js +23 -0
  20. package/dist/cjs/daemon.d.ts +94 -0
  21. package/dist/cjs/daemon.d.ts.map +1 -0
  22. package/dist/cjs/daemon.js +507 -0
  23. package/dist/cjs/daemonConfig.d.ts +45 -0
  24. package/dist/cjs/daemonConfig.d.ts.map +1 -0
  25. package/dist/cjs/daemonConfig.js +148 -0
  26. package/dist/cjs/daemonEnv.d.ts +10 -0
  27. package/dist/cjs/daemonEnv.d.ts.map +1 -0
  28. package/dist/cjs/daemonEnv.js +12 -0
  29. package/dist/cjs/durable/clientTool.d.ts +39 -0
  30. package/dist/cjs/durable/clientTool.d.ts.map +1 -0
  31. package/dist/cjs/durable/clientTool.js +90 -0
  32. package/dist/cjs/durable/index.d.ts +9 -0
  33. package/dist/cjs/durable/index.d.ts.map +1 -0
  34. package/dist/cjs/durable/index.js +16 -0
  35. package/dist/cjs/durable/journal.d.ts +218 -0
  36. package/dist/cjs/durable/journal.d.ts.map +1 -0
  37. package/dist/cjs/durable/journal.js +392 -0
  38. package/dist/cjs/durable/pause.d.ts +84 -0
  39. package/dist/cjs/durable/pause.d.ts.map +1 -0
  40. package/dist/cjs/durable/pause.js +241 -0
  41. package/dist/cjs/durable/resume.d.ts +27 -0
  42. package/dist/cjs/durable/resume.d.ts.map +1 -0
  43. package/dist/cjs/durable/resume.js +80 -0
  44. package/dist/cjs/durable/snapshotSaver.d.ts +38 -0
  45. package/dist/cjs/durable/snapshotSaver.d.ts.map +1 -0
  46. package/dist/cjs/durable/snapshotSaver.js +81 -0
  47. package/dist/cjs/durable/step.d.ts +28 -0
  48. package/dist/cjs/durable/step.d.ts.map +1 -0
  49. package/dist/cjs/durable/step.js +43 -0
  50. package/dist/cjs/index.d.ts +30 -7
  51. package/dist/cjs/index.d.ts.map +1 -1
  52. package/dist/cjs/index.js +28 -1
  53. package/dist/cjs/infrastructure.d.ts +50 -0
  54. package/dist/cjs/infrastructure.d.ts.map +1 -0
  55. package/dist/cjs/infrastructure.js +163 -0
  56. package/dist/cjs/langChain.d.ts +15 -3
  57. package/dist/cjs/langChain.d.ts.map +1 -1
  58. package/dist/cjs/langChain.js +986 -180
  59. package/dist/cjs/learningActivityMedia.d.ts +196 -0
  60. package/dist/cjs/learningActivityMedia.d.ts.map +1 -0
  61. package/dist/cjs/learningActivityMedia.js +861 -0
  62. package/dist/cjs/learningContentPlan.d.ts +105 -0
  63. package/dist/cjs/learningContentPlan.d.ts.map +1 -0
  64. package/dist/cjs/learningContentPlan.js +305 -0
  65. package/dist/cjs/learningContentThread.d.ts +184 -0
  66. package/dist/cjs/learningContentThread.d.ts.map +1 -0
  67. package/dist/cjs/learningContentThread.js +407 -0
  68. package/dist/cjs/logger.d.ts +1 -0
  69. package/dist/cjs/logger.d.ts.map +1 -1
  70. package/dist/cjs/logger.js +17 -3
  71. package/dist/cjs/modelRates.d.ts +40 -0
  72. package/dist/cjs/modelRates.d.ts.map +1 -0
  73. package/dist/cjs/modelRates.js +76 -0
  74. package/dist/cjs/referenceContext.d.ts +4 -145
  75. package/dist/cjs/referenceContext.d.ts.map +1 -1
  76. package/dist/cjs/referenceContext.js +16 -251
  77. package/dist/cjs/retry.d.ts +64 -0
  78. package/dist/cjs/retry.d.ts.map +1 -0
  79. package/dist/cjs/retry.js +138 -0
  80. package/dist/cjs/runtimeContext.d.ts +8 -1
  81. package/dist/cjs/runtimeContext.d.ts.map +1 -1
  82. package/dist/cjs/runtimeContext.js +3 -1
  83. package/dist/cjs/serve.d.ts +3 -2
  84. package/dist/cjs/serve.d.ts.map +1 -1
  85. package/dist/cjs/serve.js +32 -2
  86. package/dist/cjs/sourceStore.d.ts +378 -0
  87. package/dist/cjs/sourceStore.d.ts.map +1 -0
  88. package/dist/cjs/sourceStore.js +872 -0
  89. package/dist/cjs/stackfactorKnowledge.d.ts +91 -7
  90. package/dist/cjs/stackfactorKnowledge.d.ts.map +1 -1
  91. package/dist/cjs/stackfactorKnowledge.js +108 -44
  92. package/dist/cjs/tavily.d.ts +108 -4
  93. package/dist/cjs/tavily.d.ts.map +1 -1
  94. package/dist/cjs/tavily.js +242 -21
  95. package/dist/cjs/usage.d.ts.map +1 -1
  96. package/dist/cjs/usage.js +9 -15
  97. package/dist/cjs/version.d.ts +3 -0
  98. package/dist/cjs/version.d.ts.map +1 -0
  99. package/dist/cjs/version.js +5 -0
  100. package/dist/cjs/workflow/bookkeeping.d.ts +78 -0
  101. package/dist/cjs/workflow/bookkeeping.d.ts.map +1 -0
  102. package/dist/cjs/workflow/bookkeeping.js +75 -0
  103. package/dist/cjs/workflow/index.d.ts +13 -0
  104. package/dist/cjs/workflow/index.d.ts.map +1 -0
  105. package/dist/cjs/workflow/index.js +51 -0
  106. package/dist/cjs/workflow/limits.d.ts +52 -0
  107. package/dist/cjs/workflow/limits.d.ts.map +1 -0
  108. package/dist/cjs/workflow/limits.js +62 -0
  109. package/dist/cjs/workflow/platformTransport.d.ts +39 -0
  110. package/dist/cjs/workflow/platformTransport.d.ts.map +1 -0
  111. package/dist/cjs/workflow/platformTransport.js +115 -0
  112. package/dist/cjs/workflow/retrying.d.ts +44 -0
  113. package/dist/cjs/workflow/retrying.d.ts.map +1 -0
  114. package/dist/cjs/workflow/retrying.js +82 -0
  115. package/dist/cjs/workflow/run.d.ts +195 -0
  116. package/dist/cjs/workflow/run.d.ts.map +1 -0
  117. package/dist/cjs/workflow/run.js +858 -0
  118. package/dist/cjs/workflow/testing/index.d.ts +3 -0
  119. package/dist/cjs/workflow/testing/index.d.ts.map +1 -0
  120. package/dist/cjs/workflow/testing/index.js +6 -0
  121. package/dist/cjs/workflow/testing/memoryTransport.d.ts +203 -0
  122. package/dist/cjs/workflow/testing/memoryTransport.d.ts.map +1 -0
  123. package/dist/cjs/workflow/testing/memoryTransport.js +1171 -0
  124. package/dist/cjs/workflow/transport.d.ts +219 -0
  125. package/dist/cjs/workflow/transport.d.ts.map +1 -0
  126. package/dist/cjs/workflow/transport.js +19 -0
  127. package/dist/esm/agentProto.d.ts +13 -3
  128. package/dist/esm/agentProto.d.ts.map +1 -1
  129. package/dist/esm/agentProto.js +23 -3
  130. package/dist/esm/backoff.d.ts +17 -0
  131. package/dist/esm/backoff.d.ts.map +1 -0
  132. package/dist/esm/backoff.js +22 -0
  133. package/dist/esm/cancellation.d.ts +22 -0
  134. package/dist/esm/cancellation.d.ts.map +1 -0
  135. package/dist/esm/cancellation.js +27 -0
  136. package/dist/esm/cli.d.ts +3 -0
  137. package/dist/esm/cli.d.ts.map +1 -0
  138. package/dist/esm/cli.js +80 -0
  139. package/dist/esm/client.d.ts +11 -0
  140. package/dist/esm/client.d.ts.map +1 -1
  141. package/dist/esm/client.js +25 -1
  142. package/dist/esm/const.d.ts +23 -0
  143. package/dist/esm/const.d.ts.map +1 -1
  144. package/dist/esm/const.js +23 -0
  145. package/dist/esm/daemon.d.ts +94 -0
  146. package/dist/esm/daemon.d.ts.map +1 -0
  147. package/dist/esm/daemon.js +499 -0
  148. package/dist/esm/daemonConfig.d.ts +45 -0
  149. package/dist/esm/daemonConfig.d.ts.map +1 -0
  150. package/dist/esm/daemonConfig.js +142 -0
  151. package/dist/esm/daemonEnv.d.ts +10 -0
  152. package/dist/esm/daemonEnv.d.ts.map +1 -0
  153. package/dist/esm/daemonEnv.js +9 -0
  154. package/dist/esm/durable/clientTool.d.ts +39 -0
  155. package/dist/esm/durable/clientTool.d.ts.map +1 -0
  156. package/dist/esm/durable/clientTool.js +82 -0
  157. package/dist/esm/durable/index.d.ts +9 -0
  158. package/dist/esm/durable/index.d.ts.map +1 -0
  159. package/dist/esm/durable/index.js +8 -0
  160. package/dist/esm/durable/journal.d.ts +218 -0
  161. package/dist/esm/durable/journal.d.ts.map +1 -0
  162. package/dist/esm/durable/journal.js +374 -0
  163. package/dist/esm/durable/pause.d.ts +84 -0
  164. package/dist/esm/durable/pause.d.ts.map +1 -0
  165. package/dist/esm/durable/pause.js +226 -0
  166. package/dist/esm/durable/resume.d.ts +27 -0
  167. package/dist/esm/durable/resume.d.ts.map +1 -0
  168. package/dist/esm/durable/resume.js +72 -0
  169. package/dist/esm/durable/snapshotSaver.d.ts +38 -0
  170. package/dist/esm/durable/snapshotSaver.d.ts.map +1 -0
  171. package/dist/esm/durable/snapshotSaver.js +77 -0
  172. package/dist/esm/durable/step.d.ts +28 -0
  173. package/dist/esm/durable/step.d.ts.map +1 -0
  174. package/dist/esm/durable/step.js +36 -0
  175. package/dist/esm/index.d.ts +30 -7
  176. package/dist/esm/index.d.ts.map +1 -1
  177. package/dist/esm/index.js +20 -4
  178. package/dist/esm/infrastructure.d.ts +50 -0
  179. package/dist/esm/infrastructure.d.ts.map +1 -0
  180. package/dist/esm/infrastructure.js +156 -0
  181. package/dist/esm/langChain.d.ts +15 -3
  182. package/dist/esm/langChain.d.ts.map +1 -1
  183. package/dist/esm/langChain.js +984 -179
  184. package/dist/esm/learningActivityMedia.d.ts +196 -0
  185. package/dist/esm/learningActivityMedia.d.ts.map +1 -0
  186. package/dist/esm/learningActivityMedia.js +807 -0
  187. package/dist/esm/learningContentPlan.d.ts +105 -0
  188. package/dist/esm/learningContentPlan.d.ts.map +1 -0
  189. package/dist/esm/learningContentPlan.js +299 -0
  190. package/dist/esm/learningContentThread.d.ts +184 -0
  191. package/dist/esm/learningContentThread.d.ts.map +1 -0
  192. package/dist/esm/learningContentThread.js +364 -0
  193. package/dist/esm/logger.d.ts +1 -0
  194. package/dist/esm/logger.d.ts.map +1 -1
  195. package/dist/esm/logger.js +17 -3
  196. package/dist/esm/modelRates.d.ts +40 -0
  197. package/dist/esm/modelRates.d.ts.map +1 -0
  198. package/dist/esm/modelRates.js +68 -0
  199. package/dist/esm/referenceContext.d.ts +4 -145
  200. package/dist/esm/referenceContext.d.ts.map +1 -1
  201. package/dist/esm/referenceContext.js +16 -243
  202. package/dist/esm/retry.d.ts +64 -0
  203. package/dist/esm/retry.d.ts.map +1 -0
  204. package/dist/esm/retry.js +127 -0
  205. package/dist/esm/runtimeContext.d.ts +8 -1
  206. package/dist/esm/runtimeContext.d.ts.map +1 -1
  207. package/dist/esm/runtimeContext.js +3 -1
  208. package/dist/esm/serve.d.ts +3 -2
  209. package/dist/esm/serve.d.ts.map +1 -1
  210. package/dist/esm/serve.js +33 -3
  211. package/dist/esm/sourceStore.d.ts +378 -0
  212. package/dist/esm/sourceStore.d.ts.map +1 -0
  213. package/dist/esm/sourceStore.js +855 -0
  214. package/dist/esm/stackfactorKnowledge.d.ts +91 -7
  215. package/dist/esm/stackfactorKnowledge.d.ts.map +1 -1
  216. package/dist/esm/stackfactorKnowledge.js +101 -41
  217. package/dist/esm/tavily.d.ts +108 -4
  218. package/dist/esm/tavily.d.ts.map +1 -1
  219. package/dist/esm/tavily.js +237 -20
  220. package/dist/esm/usage.d.ts.map +1 -1
  221. package/dist/esm/usage.js +9 -15
  222. package/dist/esm/version.d.ts +3 -0
  223. package/dist/esm/version.d.ts.map +1 -0
  224. package/dist/esm/version.js +2 -0
  225. package/dist/esm/workflow/bookkeeping.d.ts +78 -0
  226. package/dist/esm/workflow/bookkeeping.d.ts.map +1 -0
  227. package/dist/esm/workflow/bookkeeping.js +67 -0
  228. package/dist/esm/workflow/index.d.ts +13 -0
  229. package/dist/esm/workflow/index.d.ts.map +1 -0
  230. package/dist/esm/workflow/index.js +10 -0
  231. package/dist/esm/workflow/limits.d.ts +52 -0
  232. package/dist/esm/workflow/limits.d.ts.map +1 -0
  233. package/dist/esm/workflow/limits.js +59 -0
  234. package/dist/esm/workflow/platformTransport.d.ts +39 -0
  235. package/dist/esm/workflow/platformTransport.d.ts.map +1 -0
  236. package/dist/esm/workflow/platformTransport.js +110 -0
  237. package/dist/esm/workflow/retrying.d.ts +44 -0
  238. package/dist/esm/workflow/retrying.d.ts.map +1 -0
  239. package/dist/esm/workflow/retrying.js +73 -0
  240. package/dist/esm/workflow/run.d.ts +195 -0
  241. package/dist/esm/workflow/run.d.ts.map +1 -0
  242. package/dist/esm/workflow/run.js +850 -0
  243. package/dist/esm/workflow/testing/index.d.ts +3 -0
  244. package/dist/esm/workflow/testing/index.d.ts.map +1 -0
  245. package/dist/esm/workflow/testing/index.js +2 -0
  246. package/dist/esm/workflow/testing/memoryTransport.d.ts +203 -0
  247. package/dist/esm/workflow/testing/memoryTransport.d.ts.map +1 -0
  248. package/dist/esm/workflow/testing/memoryTransport.js +1167 -0
  249. package/dist/esm/workflow/transport.d.ts +219 -0
  250. package/dist/esm/workflow/transport.d.ts.map +1 -0
  251. package/dist/esm/workflow/transport.js +16 -0
  252. package/package.json +8 -7
@@ -0,0 +1,59 @@
1
+ const KIB = 1024;
2
+ const MIB = 1024 * KIB;
3
+ /**
4
+ * The limits the platform enforces on an agent workflow (runner spec §2):
5
+ * backend-core's `INTEGRATIONS.WORKFLOW` values, every number and pattern of
6
+ * it, plus the lease's default length (`AGENT_POOL.TASK_LEASE_DEFAULT_SECONDS`,
7
+ * which agent pools §13 put in place of `SERVICE_LEASE_SECONDS` and
8
+ * `JOB_LEASE_DEFAULT_SECONDS`). The in-memory transport enforces them, and a
9
+ * turn can plan around them (declare fewer waits, keep `state` small).
10
+ *
11
+ * Core's contract test asserts its constants equal these (runner spec §6,
12
+ * change 3), so the two cannot drift without a failing test. Frozen, so no
13
+ * agent can loosen a limit for every other caller in the process.
14
+ */
15
+ export const LIMITS = Object.freeze({
16
+ // Record size (design §5.1).
17
+ STATE_MAX_BYTES: MIB,
18
+ INBOX_MAX: 200,
19
+ INBOX_EVENT_DATA_MAX_BYTES: 8 * KIB,
20
+ SIGNAL_INPUT_MAX_BYTES: 64 * KIB,
21
+ OPEN_WAITS_MAX: 50,
22
+ OPEN_INPUT_WAITS_MAX: 16,
23
+ OPEN_WAITS_MAX_BYTES: 4 * MIB,
24
+ SETTLED_WAITS_KEPT: 100,
25
+ CHECKPOINT_MAX_BYTES: 64 * MIB,
26
+ // Timing (W4).
27
+ QUEUED_RUN_RETRY_SECONDS: 60,
28
+ ENDED_RETENTION_DAYS: 30,
29
+ // Turn budget (W12).
30
+ MAX_TURNS: 1000,
31
+ MAX_TURNS_PER_HOUR: 60,
32
+ MIN_TIMER_SECONDS: 60,
33
+ INPUT_MAX_ATTEMPTS: 3,
34
+ WORKFLOW_SWEEP_PER_TENANT: 500,
35
+ // Names (§6.2).
36
+ KEY_PATTERN: /^[A-Za-z0-9._:-]{0,128}$/,
37
+ WAIT_TAG_PATTERN: /^[A-Za-z0-9._:-]{1,64}$/,
38
+ WAIT_FIELD_MAX_CHARS: 128,
39
+ CODE_MAX_CHARS: 256,
40
+ CONTACTS_MAX: 20,
41
+ ADDRESSEES_MAX: 20,
42
+ // Questions and answers (§6.1).
43
+ MAX_QUESTIONS_PER_WAIT: 20,
44
+ QUESTIONS_MAX_BYTES: 256 * KIB,
45
+ ANSWERS_MAX_BYTES: 256 * KIB,
46
+ TITLE_MAX_CHARS: 200,
47
+ QUESTION_MAX_CHARS: 2000,
48
+ DETAILS_MAX_CHARS: 20000,
49
+ CHOICES_MAX: 20,
50
+ CHOICE_MAX_CHARS: 200,
51
+ ANSWER_TEXT_MAX_CHARS: 20000,
52
+ REJECT_MESSAGE_MAX_CHARS: 4000,
53
+ // Tool waits (interactive tool calls, I2, §3.3).
54
+ TOOL_WAIT_DEFAULT_DEADLINE_SECONDS: 900,
55
+ TOOL_NAME_MAX_CHARS: 128,
56
+ TOOL_ERROR_MESSAGE_MAX_CHARS: 4000,
57
+ // The lease's length when the integration sets no task timeout (pools §13).
58
+ TASK_LEASE_DEFAULT_SECONDS: 7200,
59
+ });
@@ -0,0 +1,39 @@
1
+ import { integration as clientIntegration } from "@stackfactor/client-api";
2
+ import type { WorkflowTransport } from "./transport.js";
3
+ /** client-api's calls for an agent workflow (client-api `integration`, design §9). */
4
+ export type WorkflowCalls = Pick<typeof clientIntegration, "getWorkflow" | "leaseWorkflow" | "takeWorkflowInbox" | "saveWorkflowState" | "releaseWorkflow" | "endWorkflow" | "letGoWorkflow" | "reopenWorkflow" | "deleteWorkflow" | "cancelWorkflowWait" | "signalWorkflow" | "saveWorkflowCheckpoint" | "getWorkflowCheckpoint">;
5
+ /**
6
+ * A rejection as agent code may see it: the message, the method and path, and
7
+ * what retrying and the runner classify by (`isAxiosError`, a string `code`
8
+ * or a numeric structured one, `response.status`, and the platform's own
9
+ * `response.data.error` / `message`). Never `config` (the AGENT token, the
10
+ * request body), `request`, or the response's headers.
11
+ */
12
+ export declare const sanitized: (error: any, operation: string) => Error;
13
+ /**
14
+ * The transport that calls the platform (runner spec §7): client-api's call
15
+ * for each agent route, with the run's AGENT token, which names the run and
16
+ * so its workflow. client-api resolves each route's answered 404s and 409s
17
+ * as their bodies; here each becomes the flag the runner reads, so no
18
+ * caller looks at an error code:
19
+ *
20
+ * - a 404 `AGENT_WORKFLOW_NOT_FOUND`: `get` answers null; `lease` and
21
+ * `reopen` answer `missing` (none, and none created; for a bound run, its
22
+ * workflow was deleted); every other route `gone` (an administrator
23
+ * deleted the workflow under the run, §6.2);
24
+ * - a 409 version mismatch: `versionMismatch`, for save, release and end;
25
+ * - `getCheckpoint`'s 404 `AGENT_WORKFLOW_NO_CHECKPOINT`: null.
26
+ *
27
+ * Every other answer passes through as the route sent it, and every
28
+ * rejection (401, 409 not holder, 413, 400, 422, a network failure) comes
29
+ * through for {@link retrying} and the runner to classify, as a
30
+ * {@link sanitized} error: an axios error carries the AGENT token
31
+ * (`config.headers.authorization`) and the request's body (the state, or the
32
+ * gzipped checkpoint with learner files), and the error flows to the agent's
33
+ * `onError`, to a rejected `checkpoint()` and to `main`'s rejection.
34
+ *
35
+ * @param token - The run's AGENT token (`request.authToken`)
36
+ * @param calls - client-api's calls; swappable in tests
37
+ */
38
+ export declare const platformTransport: (token: string, calls?: WorkflowCalls) => WorkflowTransport;
39
+ //# sourceMappingURL=platformTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformTransport.d.ts","sourceRoot":"","sources":["../../../src/workflow/platformTransport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE3E,OAAO,KAAK,EAaV,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAExB,sFAAsF;AACtF,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,OAAO,iBAAiB,EACtB,aAAa,GACb,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,iBAAiB,GACjB,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,oBAAoB,GACpB,gBAAgB,GAChB,wBAAwB,GACxB,uBAAuB,CAC1B,CAAC;AAWF;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,GAAG,EAAE,WAAW,MAAM,KAAG,KAiBzD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,MAAM,EACb,QAAO,aAAiC,KACvC,iBAgDF,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { integration as clientIntegration } from "@stackfactor/client-api";
2
+ import { WORKFLOW_OPERATIONS } from "./transport.js";
3
+ const NOT_FOUND = "AGENT_WORKFLOW_NOT_FOUND";
4
+ const NO_CHECKPOINT = "AGENT_WORKFLOW_NO_CHECKPOINT";
5
+ const VERSION_MISMATCH = "AGENT_WORKFLOW_VERSION_MISMATCH";
6
+ const errorOf = (answer) => answer?.error;
7
+ const textOf = (value) => typeof value === "string" ? value.slice(0, 500) : undefined;
8
+ /**
9
+ * A rejection as agent code may see it: the message, the method and path, and
10
+ * what retrying and the runner classify by (`isAxiosError`, a string `code`
11
+ * or a numeric structured one, `response.status`, and the platform's own
12
+ * `response.data.error` / `message`). Never `config` (the AGENT token, the
13
+ * request body), `request`, or the response's headers.
14
+ */
15
+ export const sanitized = (error, operation) => {
16
+ const method = textOf(error?.config?.method)?.toUpperCase();
17
+ const path = textOf(error?.config?.url);
18
+ const where = method && path ? `${method} ${path}` : operation;
19
+ const out = new Error(`${textOf(error?.message) ?? "the platform call failed"} (${where})`);
20
+ out.name = error?.name === "AxiosError" ? "AxiosError" : "WorkflowTransportError";
21
+ if (error?.isAxiosError)
22
+ out.isAxiosError = true;
23
+ if (typeof error?.code === "string" || typeof error?.code === "number")
24
+ out.code = error.code;
25
+ const status = error?.response?.status;
26
+ if (typeof status === "number") {
27
+ const data = error.response.data;
28
+ out.response = {
29
+ status,
30
+ data: { ...(textOf(data?.error) ? { error: textOf(data.error) } : {}), ...(textOf(data?.message) ? { message: textOf(data.message) } : {}) },
31
+ };
32
+ }
33
+ return out;
34
+ };
35
+ /**
36
+ * The transport that calls the platform (runner spec §7): client-api's call
37
+ * for each agent route, with the run's AGENT token, which names the run and
38
+ * so its workflow. client-api resolves each route's answered 404s and 409s
39
+ * as their bodies; here each becomes the flag the runner reads, so no
40
+ * caller looks at an error code:
41
+ *
42
+ * - a 404 `AGENT_WORKFLOW_NOT_FOUND`: `get` answers null; `lease` and
43
+ * `reopen` answer `missing` (none, and none created; for a bound run, its
44
+ * workflow was deleted); every other route `gone` (an administrator
45
+ * deleted the workflow under the run, §6.2);
46
+ * - a 409 version mismatch: `versionMismatch`, for save, release and end;
47
+ * - `getCheckpoint`'s 404 `AGENT_WORKFLOW_NO_CHECKPOINT`: null.
48
+ *
49
+ * Every other answer passes through as the route sent it, and every
50
+ * rejection (401, 409 not holder, 413, 400, 422, a network failure) comes
51
+ * through for {@link retrying} and the runner to classify, as a
52
+ * {@link sanitized} error: an axios error carries the AGENT token
53
+ * (`config.headers.authorization`) and the request's body (the state, or the
54
+ * gzipped checkpoint with learner files), and the error flows to the agent's
55
+ * `onError`, to a rejected `checkpoint()` and to `main`'s rejection.
56
+ *
57
+ * @param token - The run's AGENT token (`request.authToken`)
58
+ * @param calls - client-api's calls; swappable in tests
59
+ */
60
+ export const platformTransport = (token, calls = clientIntegration) => {
61
+ const gone = (answer) => (errorOf(answer) === NOT_FOUND ? { gone: true } : answer);
62
+ const written = (answer, flag) => {
63
+ if (errorOf(answer) === NOT_FOUND)
64
+ return { gone: true };
65
+ if (errorOf(answer) === VERSION_MISMATCH)
66
+ return { [flag]: false, versionMismatch: true };
67
+ return answer;
68
+ };
69
+ const raw = {
70
+ get: async (key) => {
71
+ const answer = await calls.getWorkflow(key, token);
72
+ return errorOf(answer) === NOT_FOUND ? null : answer;
73
+ },
74
+ lease: async (body) => {
75
+ const answer = await calls.leaseWorkflow(body, token);
76
+ return (errorOf(answer) === NOT_FOUND ? { taken: false, missing: true } : answer);
77
+ },
78
+ take: async () => gone(await calls.takeWorkflowInbox(token)),
79
+ save: async (body) => written(await calls.saveWorkflowState(body, token), "saved"),
80
+ release: async (body) => written(await calls.releaseWorkflow(body, token), "released"),
81
+ end: async (body) => written(await calls.endWorkflow(body, token), "ended"),
82
+ letGo: async () => gone(await calls.letGoWorkflow(token)),
83
+ reopen: async () => {
84
+ const answer = await calls.reopenWorkflow(token);
85
+ return (errorOf(answer) === NOT_FOUND ? { reopened: false, missing: true } : answer);
86
+ },
87
+ delete: async () => gone(await calls.deleteWorkflow(token)),
88
+ cancelWait: async (waitId) => gone(await calls.cancelWorkflowWait(waitId, token)),
89
+ signal: async (body) => await calls.signalWorkflow(body, token),
90
+ saveCheckpoint: async (bytes) => gone(await calls.saveWorkflowCheckpoint(bytes, token)),
91
+ getCheckpoint: async () => {
92
+ const answer = await calls.getWorkflowCheckpoint(token);
93
+ if (errorOf(answer) === NO_CHECKPOINT)
94
+ return null;
95
+ return gone(answer);
96
+ },
97
+ };
98
+ const guarded = {};
99
+ for (const name of WORKFLOW_OPERATIONS) {
100
+ guarded[name] = async (...args) => {
101
+ try {
102
+ return await raw[name](...args);
103
+ }
104
+ catch (error) {
105
+ throw sanitized(error, name);
106
+ }
107
+ };
108
+ }
109
+ return guarded;
110
+ };
@@ -0,0 +1,44 @@
1
+ import type { WorkflowTransport } from "./transport.js";
2
+ export interface RetryOptions {
3
+ /** Retries after the first attempt. Default 3. */
4
+ retries?: number;
5
+ /** The first retry's wait; each later one doubles it. Default 500 ms. */
6
+ baseMs?: number;
7
+ /** How to wait; swappable in tests. */
8
+ sleep?: (ms: number) => Promise<void>;
9
+ /** Jitter source in [0, 1); swappable in tests. */
10
+ random?: () => number;
11
+ }
12
+ /**
13
+ * True for a failure that is no answer at all: a 5xx, or a network error (no
14
+ * HTTP response, and either an axios error or a string error code such as
15
+ * `ECONNRESET`). Every 4xx is an answer, 429 and 408 included (runner spec
16
+ * §7: "4xx never retried"), and so is an error with neither signature (a bug,
17
+ * or client-api refusing a body before any request), and one whose `code` is
18
+ * a number (errorHandling's structured errors carry their HTTP status there).
19
+ */
20
+ export declare const isTransient: (error: any) => boolean;
21
+ /**
22
+ * What a log line may say about a failed call: its HTTP status or its error
23
+ * code, never the error itself, whose message, config and request carry the
24
+ * run's token and, for a write, the whole state.
25
+ */
26
+ export declare const failureOf: (error: any) => string;
27
+ /**
28
+ * `transport` with each call made again while it fails transiently (runner
29
+ * spec §7, lifted from agent-utils #60's `retryingTransport`): network errors
30
+ * and 5xx answers are retried `retries` times (3), waiting
31
+ * `baseMs`·2^(n−1) before retry n (500 ms, 1 s, 2 s) plus up to half that
32
+ * again at random, so the runs of one burst do not retry in the same
33
+ * instant. Answers are never retried, whether resolved or rejected (401, 4xx,
34
+ * the answered 404s and 409s). After the last retry the last error is
35
+ * rethrown unchanged.
36
+ *
37
+ * Every call is safe to make again (runner spec §7): a lease and a take
38
+ * answer a holder that asks twice with the same answer; let-go, delete,
39
+ * cancel and signal answer a repeat with the same outcome; and a save,
40
+ * release or end whose first try landed is recognised by the runner from its
41
+ * last-write stamp.
42
+ */
43
+ export declare const retrying: (transport: WorkflowTransport, options?: RetryOptions) => WorkflowTransport;
44
+ //# sourceMappingURL=retrying.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retrying.d.ts","sourceRoot":"","sources":["../../../src/workflow/retrying.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,mDAAmD;IACnD,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,GAAG,KAAG,OAIxC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,OAAO,GAAG,KAAG,MAKtC,CAAC;AAIF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,WAAW,iBAAiB,EAAE,UAAS,YAAiB,KAAG,iBA6BnF,CAAC"}
@@ -0,0 +1,73 @@
1
+ import logger from "../logger.js";
2
+ import { WORKFLOW_OPERATIONS } from "./transport.js";
3
+ /**
4
+ * True for a failure that is no answer at all: a 5xx, or a network error (no
5
+ * HTTP response, and either an axios error or a string error code such as
6
+ * `ECONNRESET`). Every 4xx is an answer, 429 and 408 included (runner spec
7
+ * §7: "4xx never retried"), and so is an error with neither signature (a bug,
8
+ * or client-api refusing a body before any request), and one whose `code` is
9
+ * a number (errorHandling's structured errors carry their HTTP status there).
10
+ */
11
+ export const isTransient = (error) => {
12
+ const status = error?.response?.status;
13
+ if (typeof status === "number")
14
+ return status >= 500;
15
+ return Boolean(error?.isAxiosError) || typeof error?.code === "string";
16
+ };
17
+ /**
18
+ * What a log line may say about a failed call: its HTTP status or its error
19
+ * code, never the error itself, whose message, config and request carry the
20
+ * run's token and, for a write, the whole state.
21
+ */
22
+ export const failureOf = (error) => {
23
+ const status = error?.response?.status;
24
+ if (typeof status === "number")
25
+ return `HTTP ${status}`;
26
+ if (typeof error?.code === "string")
27
+ return error.code;
28
+ return "no response";
29
+ };
30
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
31
+ /**
32
+ * `transport` with each call made again while it fails transiently (runner
33
+ * spec §7, lifted from agent-utils #60's `retryingTransport`): network errors
34
+ * and 5xx answers are retried `retries` times (3), waiting
35
+ * `baseMs`·2^(n−1) before retry n (500 ms, 1 s, 2 s) plus up to half that
36
+ * again at random, so the runs of one burst do not retry in the same
37
+ * instant. Answers are never retried, whether resolved or rejected (401, 4xx,
38
+ * the answered 404s and 409s). After the last retry the last error is
39
+ * rethrown unchanged.
40
+ *
41
+ * Every call is safe to make again (runner spec §7): a lease and a take
42
+ * answer a holder that asks twice with the same answer; let-go, delete,
43
+ * cancel and signal answer a repeat with the same outcome; and a save,
44
+ * release or end whose first try landed is recognised by the runner from its
45
+ * last-write stamp.
46
+ */
47
+ export const retrying = (transport, options = {}) => {
48
+ const retries = Math.max(0, options.retries ?? 3);
49
+ const baseMs = options.baseMs ?? 500;
50
+ const sleep = options.sleep ?? delay;
51
+ const random = options.random ?? Math.random;
52
+ const attempts = retries + 1;
53
+ const call = async (name, make) => {
54
+ for (let attempt = 1;; attempt++) {
55
+ try {
56
+ return await make();
57
+ }
58
+ catch (error) {
59
+ if (attempt >= attempts || !isTransient(error))
60
+ throw error;
61
+ const backoff = baseMs * 2 ** (attempt - 1);
62
+ const wait = Math.floor(backoff + (random() * backoff) / 2);
63
+ logger.log(null, logger.levels.warn, `workflow: the platform's ${name} failed (${failureOf(error)}) on attempt ${attempt} of ${attempts}; trying again in ${wait}ms`);
64
+ await sleep(wait);
65
+ }
66
+ }
67
+ };
68
+ const wrapped = {};
69
+ for (const name of WORKFLOW_OPERATIONS) {
70
+ wrapped[name] = (...args) => call(name, () => transport[name](...args));
71
+ }
72
+ return wrapped;
73
+ };
@@ -0,0 +1,195 @@
1
+ import type { AgentMain } from "../serve.js";
2
+ import type { OutboxEntry } from "./bookkeeping.js";
3
+ import type { InteractiveInput, OpenWait, PlatformInput, WaitDecl, Workflow, WorkflowTransport } from "./transport.js";
4
+ /** `decide`'s answers: run the input, drop it, reopen or create the workflow for it, or delete the workflow. */
5
+ export type Decision = "run" | "ignore" | "reopen" | "create" | "delete";
6
+ export type { InteractiveInput };
7
+ /**
8
+ * What a turn is handed: an `event` or a `resume` as the platform hands it
9
+ * (§6.3), or an interactive request: an INTERACTIVE run's own (its `id` the
10
+ * run's) or one taken from the inbox (its `id` the entry's).
11
+ */
12
+ export type WorkflowInput = PlatformInput;
13
+ /**
14
+ * What happens after a turn. `{}` releases with no change to waits;
15
+ * `{ end: true }` ends the workflow; `{ delete: true }` deletes it.
16
+ */
17
+ export interface Next {
18
+ /** Waits to declare, written with the turn's `done` (§6.2). */
19
+ wait?: WaitDecl[];
20
+ /** Open waits to cancel. One not in the answer's `cancelled` had already settled: its resume will come. */
21
+ cancel?: string[];
22
+ /** Who is told of a halt or a failed input (§6.2); the latest turn that names them wins. */
23
+ contacts?: string[];
24
+ /**
25
+ * Whether to wait for a quick resolution of this turn's waits (§4). Default:
26
+ * true when the turn declared an `input` wait, else false. Waiting happens
27
+ * only while `options.linger.maxMs` is above 0 (off by default, pools §13).
28
+ */
29
+ linger?: boolean;
30
+ end?: boolean;
31
+ delete?: boolean;
32
+ }
33
+ /** A turn's answer: the agent's next state and what happens next. */
34
+ export interface TurnResult {
35
+ state: unknown;
36
+ next?: Next;
37
+ /**
38
+ * The run's outcome (I6): when this turn's `next` is `{ end: true }` and it
39
+ * is the run's last, `main` returns `{ …summary, result }`, or for a round
40
+ * of an interactive workflow the result itself (Ruling 22), and `serve()` /
41
+ * `runOnce()` settle the run with it. Ignored when the turn does not end
42
+ * the workflow. JSON, bounded by the settle route's inline limit.
43
+ */
44
+ result?: unknown;
45
+ }
46
+ export interface CheckpointOptions {
47
+ /** Waits declared mid-turn, without `done` (a `signal` wait before the tool gets its correlation, §7.6). */
48
+ waits?: WaitDecl[];
49
+ cancel?: string[];
50
+ contacts?: string[];
51
+ /** Also send the outbox under the lease now, and save again with the sent entries removed. */
52
+ send?: boolean;
53
+ }
54
+ export type CheckpointFn = (state: unknown, options?: CheckpointOptions) => Promise<{
55
+ waits: {
56
+ waitId: string;
57
+ }[];
58
+ cancelled: string[];
59
+ }>;
60
+ /** Notifications a turn queues; each `key` is the same however often the turn runs. */
61
+ export interface Outbox {
62
+ add(entries: OutboxEntry | OutboxEntry[]): void;
63
+ }
64
+ export interface TurnArgs {
65
+ input: WorkflowInput;
66
+ /** `decide`'s answer for the run's own input; null for an inbox entry and for a resume run's own input. */
67
+ decision: Decision | null;
68
+ /** The agent's state: never the runner's bookkeeping. */
69
+ state: unknown;
70
+ checkpoint: CheckpointFn;
71
+ outbox: Outbox;
72
+ /** The workflow's open waits, as this run knows them. */
73
+ openWaits: OpenWait[];
74
+ }
75
+ export interface Handlers {
76
+ /** Which workflow the run's own input belongs to, and whether a missing one may be created. Default: key "", no create. */
77
+ open?: (input: WorkflowInput) => {
78
+ key?: string;
79
+ create?: boolean;
80
+ } | Promise<{
81
+ key?: string;
82
+ create?: boolean;
83
+ }>;
84
+ /** Before the lease, with the workflow as read (or null). Must be total; a throw is logged and taken as "run". */
85
+ decide?: (args: {
86
+ input: WorkflowInput;
87
+ workflow: Workflow | null;
88
+ }) => Decision | Promise<Decision>;
89
+ /** One input under the lease. */
90
+ turn: (args: TurnArgs) => TurnResult | Promise<TurnResult>;
91
+ /** A turn that threw. Default: let-go, so the platform runs the input again from the last saved state. */
92
+ onError?: (args: {
93
+ input: WorkflowInput;
94
+ error: unknown;
95
+ state: unknown;
96
+ /** Gives the lease up, re-queuing the input; what the default does. */
97
+ letGo: () => Promise<void>;
98
+ }) => void | Promise<void>;
99
+ /** Sends one outbox entry. Required once a turn adds one; receivers deduplicate on its key. */
100
+ send?: (entry: OutboxEntry) => void | Promise<void>;
101
+ }
102
+ export interface LingerOptions {
103
+ /** How long after a turn to keep waiting for its waits to resolve. Default 0: off (pools §13). */
104
+ maxMs?: number;
105
+ /** How often to take the inbox while waiting. Default 5000. */
106
+ pollMs?: number;
107
+ }
108
+ export interface Clock {
109
+ now(): number;
110
+ /** Waits `ms`, or less when `signal` aborts. */
111
+ sleep(ms: number, signal?: AbortSignal | null): Promise<void>;
112
+ }
113
+ /**
114
+ * Where the run's own input comes from. The default, {@link messageAdapter},
115
+ * reads the run message `serve()` and `runOnce()` bind as `params.data`; a
116
+ * pool worker will supply its claimed task's payload instead (pools §13).
117
+ */
118
+ export interface RunStart {
119
+ kind: "event" | "interactive" | "resume" | "inbox";
120
+ /** The run's own id (its batch job). */
121
+ batchJobId: string | null;
122
+ /** Bound to its workflow from its creation (a resume or queued-input run): `open` is not consulted, no key is sent. */
123
+ bound: boolean;
124
+ /** The run's own input as known before the lease, for `open` and `decide`; null when it has none of its own here. */
125
+ input: WorkflowInput | null;
126
+ }
127
+ export type InputAdapter = (params: any, request: any) => RunStart;
128
+ export interface RunOptions {
129
+ linger?: LingerOptions;
130
+ /** Default: `retrying(platformTransport(request.authToken))`. */
131
+ transport?: WorkflowTransport;
132
+ adapter?: InputAdapter;
133
+ clock?: Clock;
134
+ }
135
+ /**
136
+ * How the run ended: `released`, `ended` and `deleted` say how this run let
137
+ * the workflow go; `deferred`, `handled`, `missing`, `already-ended` and
138
+ * `halted` are the lease's answers (`halted` also when a later take answered
139
+ * it, the run then releasing what it had); `ignored` is `decide`'s answer;
140
+ * `gone` means an administrator deleted the workflow.
141
+ */
142
+ export type RunOutcome = "released" | "ended" | "deleted" | "deferred" | "handled" | "missing" | "already-ended" | "halted" | "ignored" | "gone";
143
+ /**
144
+ * What `main` returns: logged, and the run's result. A run whose outcome is a
145
+ * caller's answer (an INTERACTIVE run, or any round of a workflow an
146
+ * interactive call created, as its lease answer says) returns only `result`
147
+ * (Ruling 22); its summary is logged.
148
+ */
149
+ export interface RunSummary {
150
+ workflowId: string | null;
151
+ outcome: RunOutcome;
152
+ turns: number;
153
+ lingered: {
154
+ ms: number;
155
+ resolved: boolean;
156
+ } | null;
157
+ /**
158
+ * The last turn's `result`, when that turn answered `{ end: true }` and the
159
+ * run let the workflow go accordingly: `ended`, or `halted` (the end
160
+ * released instead, W4). Absent otherwise.
161
+ */
162
+ result?: unknown;
163
+ }
164
+ /**
165
+ * The run's own input from its run message (runner spec §3 "How it plugs
166
+ * in"): `params.data` is the run record's `steps[0].data` as backend-core's
167
+ * `getExecutionEnvelope` builds it, the same for a SERVICE and a JOB run.
168
+ * `trigger: "RESUME"` is a resume run, bound from its creation; its input (the
169
+ * wait's outcome) is not in the message and comes from the lease. `trigger:
170
+ * "INBOX"` is a queued-input run, with no input of its own. `trigger:
171
+ * "INTERACTIVE"` (or `params.contentType` "INTERACTIVE") is a synchronous
172
+ * agent call made a run (I1): its input is `{ type: "interactive", id: <run
173
+ * id>, payload: params.data.payload }`, what the caller asked for. Anything
174
+ * else is a platform event (a scheduled run's included). Before the lease an
175
+ * event has no inbox entry, so its `id` is the run's own; the turn is handed
176
+ * the platform's input, whose `id` is its entry.
177
+ *
178
+ * An INTERACTIVE run arrives claimed by the platform, as every run reaches
179
+ * `main` claimed (by `serve()`'s caller or by `runOnce()`): the runner never
180
+ * claims.
181
+ */
182
+ export declare const messageAdapter: InputAdapter;
183
+ /**
184
+ * `workflow.run(handlers, options)` (runner spec §3): an ordinary agent
185
+ * `main`, so `serve()` (SERVICE) and `runOnce()` (JOB) run it as they run any
186
+ * agent, and settle the run with what it returns. The agent writes `decide`
187
+ * and `turn`; the runner owns the lease, the inbox loop one entry per take,
188
+ * the end-of-turn saves with the outbox sent under the lease, release, end
189
+ * and delete, let-go on a failed turn, the last-write stamp, and the wait
190
+ * for a quick resolution (off unless `linger.maxMs` is set, and never past
191
+ * the lease's `until`). The runner never claims the run: `serve()` and
192
+ * `runOnce()` own its lifecycle.
193
+ */
194
+ export declare const run: (handlers: Handlers, options?: RunOptions) => AgentMain;
195
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/workflow/run.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAcjE,OAAO,KAAK,EAEV,gBAAgB,EAGhB,QAAQ,EACR,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AAIxB,gHAAgH;AAChH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAIzE,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC;IAClB,2GAA2G;IAC3G,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4FAA4F;IAC5F,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;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