@foldrun/core 0.3.0 → 0.4.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 (83) hide show
  1. package/README.md +27 -10
  2. package/dist/src/approvals.d.ts +104 -1
  3. package/dist/src/approvals.js +192 -2
  4. package/dist/src/budget.d.ts +32 -0
  5. package/dist/src/budget.js +177 -0
  6. package/dist/src/catalog.js +2 -1
  7. package/dist/src/confine.js +6 -1
  8. package/dist/src/egress.d.ts +19 -2
  9. package/dist/src/egress.js +2 -1
  10. package/dist/src/evals.d.ts +4 -0
  11. package/dist/src/evals.js +20 -11
  12. package/dist/src/flow-lint.d.ts +4 -0
  13. package/dist/src/flow-lint.js +108 -0
  14. package/dist/src/host-env.d.ts +8 -0
  15. package/dist/src/host-env.js +48 -0
  16. package/dist/src/json-schema.d.ts +12 -0
  17. package/dist/src/json-schema.js +202 -0
  18. package/dist/src/library.js +13 -1
  19. package/dist/src/notify.d.ts +79 -1
  20. package/dist/src/notify.js +243 -9
  21. package/dist/src/paths.d.ts +5 -0
  22. package/dist/src/paths.js +32 -0
  23. package/dist/src/platform.d.ts +102 -2
  24. package/dist/src/platform.js +18 -2
  25. package/dist/src/provider-health.d.ts +55 -0
  26. package/dist/src/provider-health.js +232 -0
  27. package/dist/src/run-container.d.ts +57 -4
  28. package/dist/src/run-container.js +147 -41
  29. package/dist/src/runner.d.ts +39 -3
  30. package/dist/src/runner.js +422 -73
  31. package/dist/src/script-tools.d.ts +12 -0
  32. package/dist/src/script-tools.js +10 -2
  33. package/dist/src/secret-health.d.ts +59 -0
  34. package/dist/src/secret-health.js +155 -0
  35. package/dist/src/secrets.d.ts +19 -1
  36. package/dist/src/secrets.js +44 -12
  37. package/dist/src/starter.js +3 -0
  38. package/dist/src/step-exec.d.ts +47 -1
  39. package/dist/src/step-exec.js +155 -60
  40. package/dist/src/store.d.ts +276 -3
  41. package/dist/src/store.js +552 -26
  42. package/dist/src/tar.js +2 -1
  43. package/dist/src/test-mode.d.ts +111 -0
  44. package/dist/src/test-mode.js +285 -0
  45. package/dist/src/tool-test.js +48 -21
  46. package/dist/src/translator.js +2 -1
  47. package/dist/src/trigger-log.d.ts +43 -0
  48. package/dist/src/trigger-log.js +122 -0
  49. package/dist/src/triggers.d.ts +20 -0
  50. package/dist/src/triggers.js +91 -10
  51. package/dist/src/webhook.d.ts +15 -3
  52. package/dist/src/webhook.js +11 -11
  53. package/package.json +4 -4
  54. package/src/approvals.ts +253 -2
  55. package/src/budget.ts +178 -0
  56. package/src/catalog.ts +2 -1
  57. package/src/confine.ts +6 -1
  58. package/src/egress.ts +20 -4
  59. package/src/evals.ts +25 -9
  60. package/src/flow-lint.ts +118 -0
  61. package/src/host-env.ts +51 -0
  62. package/src/json-schema.ts +184 -0
  63. package/src/library.ts +13 -1
  64. package/src/notify.ts +272 -11
  65. package/src/paths.ts +29 -0
  66. package/src/platform.ts +107 -3
  67. package/src/provider-health.ts +274 -0
  68. package/src/run-container.ts +175 -36
  69. package/src/runner.ts +435 -65
  70. package/src/script-tools.ts +18 -2
  71. package/src/secret-health.ts +185 -0
  72. package/src/secrets.ts +44 -10
  73. package/src/starter.ts +3 -0
  74. package/src/step-exec.ts +128 -13
  75. package/src/storage.ts +8 -2
  76. package/src/store.ts +746 -25
  77. package/src/tar.ts +2 -1
  78. package/src/test-mode.ts +311 -0
  79. package/src/tool-test.ts +49 -20
  80. package/src/translator.ts +2 -1
  81. package/src/trigger-log.ts +159 -0
  82. package/src/triggers.ts +92 -10
  83. package/src/webhook.ts +17 -11
@@ -1,4 +1,4 @@
1
- import { type FlowStep, type RunRecord } from "./store.ts";
1
+ import { type FlowStep, type RunRecord, type StepRecord } from "./store.ts";
2
2
  /** How much of the earlier groups' output a step is handed, in characters.
3
3
  * Newest groups are kept when the total is over it. */
4
4
  export declare const CONTEXT_CHARS = 30000;
@@ -12,6 +12,17 @@ export declare const DESK_RUNS_CAP = 100;
12
12
  * step is most likely to be about.
13
13
  */
14
14
  export declare function joinEarlierGroups(groupResults: (string | null)[], gi: number, cap?: number): string | null;
15
+ /**
16
+ * `parallel: N` — a pool of N slots the instances of one fan-out share.
17
+ * Fan-out always ran every instance at once, and still does unless the
18
+ * step says otherwise: twenty browser steps against one site, or one
19
+ * vendor's rate limit, is what the cap is for. Nothing is rented while an
20
+ * instance waits for a slot.
21
+ */
22
+ export declare function slotPool(size: number): {
23
+ acquire: () => Promise<void>;
24
+ release: () => void;
25
+ };
15
26
  export interface DiscoveredSkill {
16
27
  name: string;
17
28
  description: string;
@@ -102,6 +113,20 @@ export declare function applicableSkills<T extends {
102
113
  */
103
114
  export declare function saysUntilMarker(result: string | null, until: string): boolean;
104
115
  export declare function resolveDocLinks(text: string, workspaceRoot: string): string;
116
+ /**
117
+ * Write one attempt onto the step's history and re-total the step.
118
+ *
119
+ * runStep reports the attempt it just ran — its cost, tokens and sandbox
120
+ * seconds — by assigning the step's fields. Those become this attempt's row;
121
+ * the step's fields then become the sum of every row, which is what the
122
+ * run's spend, the flow's budget: and the platform's bill read. A retried
123
+ * step used to carry only its last attempt's cost, so a `retry: 2` step
124
+ * could spend three shares while reporting one.
125
+ */
126
+ export declare function recordAttempt(step: StepRecord, n: number, status: "completed" | "failed", startedAt: string, eventsBefore: number,
127
+ /** The attempt re-attached to a sandbox a previous driver left: same
128
+ * attempt, so its row is replaced rather than repeated. */
129
+ reattach?: boolean): void;
105
130
  /**
106
131
  * Copy a directory tree by reading and writing the bytes.
107
132
  *
@@ -132,8 +157,19 @@ export declare const OVERLOAD_RETRIES = 3;
132
157
  */
133
158
  export declare function isTransientOverload(text: string): boolean;
134
159
  export declare function backoffMs(attempt: number, text?: string, random?: () => number): number;
135
- export declare function createFlowRun(tenant: string, workspace: string, steps: FlowStep[], flowName: string, status: "queued" | "running", tags?: string[]): RunRecord;
136
- export declare function startFlowRun(tenant: string, workspace: string, steps: FlowStep[], flowName: string, modelOverride?: string | null, tags?: string[], effortOverride?: string | null): RunRecord;
160
+ /**
161
+ * `schema: <path>` — the file, read and parsed, or null. Agent-relative like
162
+ * every other path in a flow (`../../schemas/lead.json`), confined to the
163
+ * workspace: a schema is the author's document, never something a step
164
+ * can point outside.
165
+ */
166
+ export declare function readSchemaFile(workspaceRoot: string, rel: string): Record<string, unknown> | boolean | null;
167
+ export declare function createFlowRun(tenant: string, workspace: string, steps: FlowStep[], flowName: string, status: "queued" | "running", tags?: string[], startedBy?: string | null, opts?: {
168
+ test?: boolean;
169
+ }): RunRecord;
170
+ export declare function startFlowRun(tenant: string, workspace: string, steps: FlowStep[], flowName: string, modelOverride?: string | null, tags?: string[], effortOverride?: string | null, startedBy?: string | null, opts?: {
171
+ test?: boolean;
172
+ }): RunRecord;
137
173
  /**
138
174
  * Drive a run to completion: groups in order, approval gates, retries.
139
175
  *