@foldrun/core 2.4.0 → 2.6.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 (149) hide show
  1. package/dist/src/agent-activity.d.ts +5 -0
  2. package/dist/src/agent-activity.js +31 -0
  3. package/dist/src/agent-import.js +2 -2
  4. package/dist/src/agent-tools.js +2 -2
  5. package/dist/src/agents-md.d.ts +5 -1
  6. package/dist/src/agents-md.js +42 -18
  7. package/dist/src/alerts.d.ts +60 -0
  8. package/dist/src/alerts.js +161 -0
  9. package/dist/src/browser-pod.js +4 -0
  10. package/dist/src/capture.d.ts +23 -0
  11. package/dist/src/capture.js +80 -0
  12. package/dist/src/compare.d.ts +57 -0
  13. package/dist/src/compare.js +116 -0
  14. package/dist/src/completions.js +26 -3
  15. package/dist/src/deploy.d.ts +36 -1
  16. package/dist/src/deploy.js +237 -13
  17. package/dist/src/egress.d.ts +16 -1
  18. package/dist/src/evals.d.ts +27 -2
  19. package/dist/src/evals.js +62 -19
  20. package/dist/src/flow-lint.d.ts +14 -0
  21. package/dist/src/flow-lint.js +35 -0
  22. package/dist/src/flow-patterns.js +29 -14
  23. package/dist/src/frontmatter-fields.d.ts +27 -0
  24. package/dist/src/frontmatter-fields.js +60 -3
  25. package/dist/src/frontmatter-guard.d.ts +19 -0
  26. package/dist/src/frontmatter-guard.js +67 -0
  27. package/dist/src/frontmatter-schema.d.ts +2 -2
  28. package/dist/src/frontmatter-schema.js +33 -2
  29. package/dist/src/frontmatter-text.d.ts +31 -0
  30. package/dist/src/frontmatter-text.js +102 -0
  31. package/dist/src/history.d.ts +4 -0
  32. package/dist/src/history.js +15 -0
  33. package/dist/src/hooks.js +1 -1
  34. package/dist/src/insights.d.ts +30 -0
  35. package/dist/src/insights.js +152 -0
  36. package/dist/src/issues.d.ts +140 -0
  37. package/dist/src/issues.js +302 -0
  38. package/dist/src/judge-verdict.d.ts +19 -0
  39. package/dist/src/judge-verdict.js +54 -0
  40. package/dist/src/library.js +1 -1
  41. package/dist/src/limits.d.ts +8 -0
  42. package/dist/src/limits.js +36 -5
  43. package/dist/src/linkable.js +1 -1
  44. package/dist/src/matter.d.ts +42 -0
  45. package/dist/src/matter.js +132 -0
  46. package/dist/src/model-credential.d.ts +14 -0
  47. package/dist/src/model-credential.js +40 -0
  48. package/dist/src/network.d.ts +12 -1
  49. package/dist/src/network.js +35 -8
  50. package/dist/src/notify.d.ts +16 -0
  51. package/dist/src/notify.js +17 -7
  52. package/dist/src/okf.js +1 -1
  53. package/dist/src/online-checks.d.ts +76 -0
  54. package/dist/src/online-checks.js +432 -0
  55. package/dist/src/operator.d.ts +277 -0
  56. package/dist/src/operator.js +176 -2
  57. package/dist/src/otel-config.d.ts +18 -0
  58. package/dist/src/otel-config.js +69 -0
  59. package/dist/src/otel.d.ts +38 -0
  60. package/dist/src/otel.js +85 -0
  61. package/dist/src/outcome.d.ts +40 -0
  62. package/dist/src/outcome.js +77 -0
  63. package/dist/src/package.js +9 -2
  64. package/dist/src/platform.d.ts +1 -1
  65. package/dist/src/prompt-layers.d.ts +30 -0
  66. package/dist/src/prompt-layers.js +77 -0
  67. package/dist/src/provider-health.js +2 -2
  68. package/dist/src/providers.d.ts +5 -0
  69. package/dist/src/providers.js +2 -2
  70. package/dist/src/run-container.d.ts +25 -2
  71. package/dist/src/run-container.js +61 -6
  72. package/dist/src/runner.d.ts +53 -2
  73. package/dist/src/runner.js +471 -102
  74. package/dist/src/runs-filter.d.ts +48 -0
  75. package/dist/src/runs-filter.js +73 -0
  76. package/dist/src/scan.d.ts +30 -1
  77. package/dist/src/scan.js +145 -14
  78. package/dist/src/starter.js +27 -2
  79. package/dist/src/step-exec.d.ts +39 -3
  80. package/dist/src/step-exec.js +118 -15
  81. package/dist/src/store.d.ts +144 -3
  82. package/dist/src/store.js +150 -7
  83. package/dist/src/tokens.d.ts +38 -0
  84. package/dist/src/tokens.js +57 -0
  85. package/dist/src/tool-names.js +1 -1
  86. package/dist/src/tool-programs.js +1 -1
  87. package/dist/src/trace-tree.d.ts +40 -0
  88. package/dist/src/trace-tree.js +156 -0
  89. package/dist/src/translator.d.ts +8 -0
  90. package/dist/src/translator.js +7 -2
  91. package/dist/src/trigger-log.d.ts +1 -1
  92. package/dist/src/workspace-check.d.ts +18 -0
  93. package/dist/src/workspace-check.js +34 -0
  94. package/package.json +2 -2
  95. package/src/agent-activity.ts +32 -0
  96. package/src/agent-import.ts +2 -2
  97. package/src/agent-tools.ts +2 -2
  98. package/src/agents-md.ts +39 -14
  99. package/src/alerts.ts +190 -0
  100. package/src/browser-pod.ts +3 -0
  101. package/src/capture.ts +88 -0
  102. package/src/compare.ts +146 -0
  103. package/src/completions.ts +27 -3
  104. package/src/deploy.ts +238 -12
  105. package/src/egress.ts +12 -2
  106. package/src/evals.ts +64 -19
  107. package/src/flow-lint.ts +36 -0
  108. package/src/flow-patterns.ts +26 -13
  109. package/src/frontmatter-fields.ts +83 -3
  110. package/src/frontmatter-guard.ts +70 -0
  111. package/src/frontmatter-schema.ts +33 -4
  112. package/src/frontmatter-text.ts +109 -0
  113. package/src/history.ts +13 -0
  114. package/src/hooks.ts +1 -1
  115. package/src/insights.ts +174 -0
  116. package/src/issues.ts +396 -0
  117. package/src/judge-verdict.ts +52 -0
  118. package/src/library.ts +1 -1
  119. package/src/limits.ts +38 -5
  120. package/src/linkable.ts +1 -1
  121. package/src/matter.ts +145 -0
  122. package/src/model-credential.ts +45 -0
  123. package/src/network.ts +35 -7
  124. package/src/notify.ts +22 -7
  125. package/src/okf.ts +1 -1
  126. package/src/online-checks.ts +450 -0
  127. package/src/operator.ts +213 -3
  128. package/src/otel-config.ts +67 -0
  129. package/src/otel.ts +100 -0
  130. package/src/outcome.ts +90 -0
  131. package/src/package.ts +8 -2
  132. package/src/platform.ts +1 -1
  133. package/src/prompt-layers.ts +90 -0
  134. package/src/provider-health.ts +2 -2
  135. package/src/providers.ts +7 -2
  136. package/src/run-container.ts +77 -8
  137. package/src/runner.ts +477 -79
  138. package/src/runs-filter.ts +88 -0
  139. package/src/scan.ts +153 -14
  140. package/src/starter.ts +27 -2
  141. package/src/step-exec.ts +168 -17
  142. package/src/store.ts +268 -9
  143. package/src/tokens.ts +68 -0
  144. package/src/tool-names.ts +1 -1
  145. package/src/tool-programs.ts +1 -1
  146. package/src/trace-tree.ts +187 -0
  147. package/src/translator.ts +13 -2
  148. package/src/trigger-log.ts +1 -0
  149. package/src/workspace-check.ts +41 -0
@@ -33,6 +33,46 @@ export declare function slotPool(size: number): {
33
33
  acquire: () => Promise<void>;
34
34
  release: () => void;
35
35
  };
36
+ export declare function markResponding(step: StepRecord): void;
37
+ /**
38
+ * Is this step's prompt in the cache yet? An entry is readable from the
39
+ * moment the response to the request that wrote it begins streaming
40
+ * (Anthropic's prompt-caching docs), which is what `responding` marks.
41
+ * The first text, tool call or recorded model call says the same a little
42
+ * later, for an executor that cannot see the stream (the stub, an older
43
+ * driver). Resolves on the first of those, or when the step is over
44
+ * without one (a refusal before the first turn, a failed start).
45
+ */
46
+ export declare function untilFirstReply(step: StepRecord, done: Promise<unknown>, pollMs?: number): Promise<void>;
47
+ /**
48
+ * Steps of one agent launched together share a prompt prefix — tools and
49
+ * system prompt — and that is what the model's cache keeps. The cache is
50
+ * written by the first request that carries a prefix and readable only
51
+ * once that response has begun, so N copies started at once all write it
52
+ * and none reads: a fan-out of twenty paid twenty cold prefixes. The gate
53
+ * lets the first instance of each agent go alone and holds its siblings
54
+ * until its first response has begun (or it ended); then they all start
55
+ * and read what it wrote — Claude Code holds a workflow's fan-out the same
56
+ * way. Not a fixed delay: a sandbox takes seconds to start before its
57
+ * first model call, so a timer from launch would release the siblings
58
+ * before there was anything to read. Keyed by agent and model, since a
59
+ * cache is per model.
60
+ */
61
+ export declare function warmGate(launching: StepRecord[], pollMs?: number): {
62
+ /** Claim the step's place — synchronously, before anything awaits, or
63
+ * the copies that reach their first await together would all find no
64
+ * lead and all go (a `parallel:` pool's acquire was exactly that).
65
+ * The first of its agent leads and gets null; a later one gets the
66
+ * lead's gate to await before it starts; a lone step gets null too. */
67
+ claim(step: StepRecord): Promise<void> | null;
68
+ /** A lead that will not run after all (the run was stopped while it
69
+ * waited for a pool slot) still opens its gate — or its siblings,
70
+ * which also wake to the stop, would wait on it forever. */
71
+ release(step: StepRecord): void;
72
+ /** Run the step; a lead opens its agent's gate on its first reply (or
73
+ * its end), whatever else happens to it. */
74
+ run(step: StepRecord, launch: () => Promise<void>): Promise<void>;
75
+ };
36
76
  export interface DiscoveredSkill {
37
77
  name: string;
38
78
  description: string;
@@ -258,6 +298,8 @@ grantsOnly?: boolean): {
258
298
  * reported by the step, not here, so it lands in the run's trace. */
259
299
  clock: ClockChoice;
260
300
  systemPrompt: string;
301
+ /** What the record keeps of each layer of that prompt. */
302
+ promptLayers: import("./tokens.ts").PromptLayerRecord[];
261
303
  allowed: string[];
262
304
  disabled: string[];
263
305
  unknownTools: string[];
@@ -280,6 +322,7 @@ grantsOnly?: boolean): {
280
322
  ask: {
281
323
  timeoutSec: number;
282
324
  } | null;
325
+ peers: boolean;
283
326
  runtime: {
284
327
  log: string[];
285
328
  error: string | null;
@@ -328,6 +371,7 @@ grantsOnly?: boolean): {
328
371
  maxTokensParam?: "max_tokens" | "max_completion_tokens";
329
372
  reasoningEffort?: boolean;
330
373
  params?: Record<string, unknown>;
374
+ cacheKey?: string;
331
375
  label?: string;
332
376
  egress?: string;
333
377
  timezone: string;
@@ -340,6 +384,7 @@ grantsOnly?: boolean): {
340
384
  maxTokensParam?: "max_tokens" | "max_completion_tokens";
341
385
  reasoningEffort?: boolean;
342
386
  params?: Record<string, unknown>;
387
+ cacheKey?: string;
343
388
  label?: string;
344
389
  egress?: string;
345
390
  timezone: string;
@@ -583,7 +628,13 @@ export interface Reconciliation {
583
628
  * outlives any process. A run whose person already answered is not waiting,
584
629
  * and is picked back up — see below.
585
630
  */
586
- export declare function reconcileRuns(tenant: string, now?: number, live?: ReadonlySet<string>): Reconciliation[];
631
+ /** Told when a run reconcile closed, or resumed and saw to its end — so the
632
+ * platform settles, notifies and chains it as it would a run its worker
633
+ * drove (a run closed here had spent tokens, and nobody was charged or
634
+ * told). Not told when a resumed run parks again: whatever resumes it next
635
+ * goes through the worker. */
636
+ export type ReconcileEnd = (tenant: string, workspace: string, runId: string) => void | Promise<void>;
637
+ export declare function reconcileRuns(tenant: string, now?: number, live?: ReadonlySet<string>, onEnd?: ReconcileEnd): Reconciliation[];
587
638
  /**
588
639
  * The same, for every account this installation holds.
589
640
  *
@@ -591,7 +642,7 @@ export declare function reconcileRuns(tenant: string, now?: number, live?: Reado
591
642
  * one hard-coded account left every other account's interrupted runs marked
592
643
  * `running` forever, with no process left to finish them.
593
644
  */
594
- export declare function reconcileAllRuns(now?: number, live?: ReadonlySet<string>): Reconciliation[];
645
+ export declare function reconcileAllRuns(now?: number, live?: ReadonlySet<string>, onEnd?: ReconcileEnd): Reconciliation[];
595
646
  /**
596
647
  * Wait for a run to stop being in progress.
597
648
  *