@foldrun/core 0.2.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 (166) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +239 -0
  3. package/dist/index.d.ts +32 -0
  4. package/dist/index.js +43 -0
  5. package/dist/src/agent-tools.d.ts +31 -0
  6. package/dist/src/agent-tools.js +99 -0
  7. package/dist/src/agents-md.d.ts +9 -0
  8. package/dist/src/agents-md.js +83 -0
  9. package/dist/src/api-tools.d.ts +38 -0
  10. package/dist/src/api-tools.js +313 -0
  11. package/dist/src/approvals.d.ts +39 -0
  12. package/dist/src/approvals.js +103 -0
  13. package/dist/src/arrange.d.ts +8 -0
  14. package/dist/src/arrange.js +40 -0
  15. package/dist/src/catalog.d.ts +108 -0
  16. package/dist/src/catalog.js +255 -0
  17. package/dist/src/completions.d.ts +61 -0
  18. package/dist/src/completions.js +578 -0
  19. package/dist/src/confine.d.ts +31 -0
  20. package/dist/src/confine.js +298 -0
  21. package/dist/src/container.d.ts +30 -0
  22. package/dist/src/container.js +172 -0
  23. package/dist/src/context-tools.d.ts +81 -0
  24. package/dist/src/context-tools.js +347 -0
  25. package/dist/src/deploy.d.ts +100 -0
  26. package/dist/src/deploy.js +377 -0
  27. package/dist/src/egress.d.ts +75 -0
  28. package/dist/src/egress.js +133 -0
  29. package/dist/src/evals.d.ts +150 -0
  30. package/dist/src/evals.js +651 -0
  31. package/dist/src/flow-lint.d.ts +16 -0
  32. package/dist/src/flow-lint.js +177 -0
  33. package/dist/src/git-hook.d.ts +1 -0
  34. package/dist/src/git-hook.js +70 -0
  35. package/dist/src/git.d.ts +37 -0
  36. package/dist/src/git.js +101 -0
  37. package/dist/src/gitrepo.d.ts +95 -0
  38. package/dist/src/gitrepo.js +355 -0
  39. package/dist/src/history.d.ts +82 -0
  40. package/dist/src/history.js +259 -0
  41. package/dist/src/kinds.d.ts +95 -0
  42. package/dist/src/kinds.js +421 -0
  43. package/dist/src/library.d.ts +94 -0
  44. package/dist/src/library.js +341 -0
  45. package/dist/src/linkable.d.ts +20 -0
  46. package/dist/src/linkable.js +113 -0
  47. package/dist/src/model-probe.d.ts +21 -0
  48. package/dist/src/model-probe.js +81 -0
  49. package/dist/src/notify.d.ts +61 -0
  50. package/dist/src/notify.js +252 -0
  51. package/dist/src/oauth-presets.d.ts +13 -0
  52. package/dist/src/oauth-presets.js +39 -0
  53. package/dist/src/okf.d.ts +220 -0
  54. package/dist/src/okf.js +656 -0
  55. package/dist/src/openapi.d.ts +66 -0
  56. package/dist/src/openapi.js +342 -0
  57. package/dist/src/paths.d.ts +33 -0
  58. package/dist/src/paths.js +78 -0
  59. package/dist/src/platform.d.ts +32 -0
  60. package/dist/src/platform.js +48 -0
  61. package/dist/src/providers.d.ts +47 -0
  62. package/dist/src/providers.js +114 -0
  63. package/dist/src/refs.d.ts +20 -0
  64. package/dist/src/refs.js +78 -0
  65. package/dist/src/run-container.d.ts +227 -0
  66. package/dist/src/run-container.js +760 -0
  67. package/dist/src/runner.d.ts +241 -0
  68. package/dist/src/runner.js +3215 -0
  69. package/dist/src/runtime.d.ts +41 -0
  70. package/dist/src/runtime.js +357 -0
  71. package/dist/src/script-tools.d.ts +62 -0
  72. package/dist/src/script-tools.js +296 -0
  73. package/dist/src/secret-files.d.ts +12 -0
  74. package/dist/src/secret-files.js +92 -0
  75. package/dist/src/secrets.d.ts +147 -0
  76. package/dist/src/secrets.js +626 -0
  77. package/dist/src/starter.d.ts +21 -0
  78. package/dist/src/starter.js +399 -0
  79. package/dist/src/step-exec.d.ts +136 -0
  80. package/dist/src/step-exec.js +391 -0
  81. package/dist/src/storage.d.ts +123 -0
  82. package/dist/src/storage.js +640 -0
  83. package/dist/src/store.d.ts +1052 -0
  84. package/dist/src/store.js +2378 -0
  85. package/dist/src/tar.d.ts +30 -0
  86. package/dist/src/tar.js +111 -0
  87. package/dist/src/tool-names.d.ts +39 -0
  88. package/dist/src/tool-names.js +79 -0
  89. package/dist/src/tool-programs.d.ts +18 -0
  90. package/dist/src/tool-programs.js +52 -0
  91. package/dist/src/tool-test.d.ts +19 -0
  92. package/dist/src/tool-test.js +335 -0
  93. package/dist/src/translator.d.ts +159 -0
  94. package/dist/src/translator.js +986 -0
  95. package/dist/src/triggers.d.ts +60 -0
  96. package/dist/src/triggers.js +270 -0
  97. package/dist/src/webhook.d.ts +47 -0
  98. package/dist/src/webhook.js +148 -0
  99. package/index.ts +44 -0
  100. package/package.json +64 -0
  101. package/src/agent-tools.ts +138 -0
  102. package/src/agents-md.ts +81 -0
  103. package/src/api-tools.ts +389 -0
  104. package/src/approvals.ts +129 -0
  105. package/src/arrange.ts +42 -0
  106. package/src/catalog.ts +321 -0
  107. package/src/completions.ts +652 -0
  108. package/src/confine.ts +350 -0
  109. package/src/container.ts +220 -0
  110. package/src/context-tools.ts +435 -0
  111. package/src/deploy.ts +458 -0
  112. package/src/egress.ts +176 -0
  113. package/src/evals.ts +812 -0
  114. package/src/flow-lint.ts +215 -0
  115. package/src/git-hook.ts +73 -0
  116. package/src/git.ts +117 -0
  117. package/src/gitrepo.ts +391 -0
  118. package/src/history.ts +329 -0
  119. package/src/kinds.ts +507 -0
  120. package/src/library.ts +419 -0
  121. package/src/linkable.ts +123 -0
  122. package/src/model-probe.ts +112 -0
  123. package/src/notify.ts +281 -0
  124. package/src/oauth-presets.ts +54 -0
  125. package/src/okf.ts +768 -0
  126. package/src/openapi.ts +383 -0
  127. package/src/paths.ts +79 -0
  128. package/src/platform.ts +87 -0
  129. package/src/providers.ts +147 -0
  130. package/src/refs.ts +83 -0
  131. package/src/run-container.ts +883 -0
  132. package/src/runner.ts +3446 -0
  133. package/src/runtime.ts +404 -0
  134. package/src/script-tools.ts +383 -0
  135. package/src/secret-files.ts +101 -0
  136. package/src/secrets.ts +799 -0
  137. package/src/starter.ts +415 -0
  138. package/src/step-exec.ts +498 -0
  139. package/src/storage.ts +771 -0
  140. package/src/store.ts +2985 -0
  141. package/src/tar.ts +124 -0
  142. package/src/tool-names.ts +91 -0
  143. package/src/tool-programs.ts +65 -0
  144. package/src/tool-test.ts +401 -0
  145. package/src/translator.ts +1029 -0
  146. package/src/triggers.ts +287 -0
  147. package/src/webhook.ts +183 -0
  148. package/templates/blog-desk/AGENTS.md +13 -0
  149. package/templates/blog-desk/agents/researcher/agent.md +11 -0
  150. package/templates/blog-desk/agents/writer/agent.md +8 -0
  151. package/templates/blog-desk/evals/writer-quality.md +10 -0
  152. package/templates/blog-desk/flows/publish.md +10 -0
  153. package/templates/blog-desk/knowledge/house-style.md +9 -0
  154. package/templates/blog-desk/knowledge/index.md +9 -0
  155. package/templates/hello/AGENTS.md +18 -0
  156. package/templates/hello/agents/curator/agent.md +32 -0
  157. package/templates/hello/agents/notetaker/agent.md +24 -0
  158. package/templates/hello/evals/house-style.md +16 -0
  159. package/templates/hello/flows/memory-review.md +7 -0
  160. package/templates/hello/flows/note.md +7 -0
  161. package/templates/hello/knowledge/house-style.md +15 -0
  162. package/templates/hello/knowledge/index.md +9 -0
  163. package/templates/hello/skills/plain-english/SKILL.md +11 -0
  164. package/templates/hello/state/publishing.md +7 -0
  165. package/templates/hello/tools/wordcount/run.py +13 -0
  166. package/templates/hello/tools/wordcount/tool.md +22 -0
@@ -0,0 +1,150 @@
1
+ import { type Effort } from "./store.ts";
2
+ export type Assertion = {
3
+ type: "contains";
4
+ value: string;
5
+ } | {
6
+ type: "not-contains";
7
+ value: string;
8
+ } | {
9
+ type: "matches";
10
+ value: string;
11
+ } | {
12
+ type: "file";
13
+ value: string;
14
+ } | {
15
+ type: "run";
16
+ value: string;
17
+ } | {
18
+ type: "judge";
19
+ value: string;
20
+ };
21
+ export interface EvalCase {
22
+ name: string;
23
+ task: string;
24
+ expect: Assertion[];
25
+ }
26
+ export interface EvalInfo {
27
+ name: string;
28
+ file: string;
29
+ /** The agent under test, or null when a flow is. */
30
+ agent: string | null;
31
+ flow: string | null;
32
+ /** Model for the judge. Cases run the agent on its own model. */
33
+ model: string;
34
+ /** Effort for the judge. PASS/FAIL against one sentence is not deep work,
35
+ * so this is one of the few places a low default is the right one. */
36
+ effort: Effort | null;
37
+ /** When it runs. `deploy` (default): after every push, with the rest.
38
+ * `manual`: only when a person presses Run or the CLI asks — for a flow
39
+ * eval that costs a whole run and touches real systems every time. */
40
+ trigger: "deploy" | "manual";
41
+ cases: EvalCase[];
42
+ }
43
+ export declare function parseEval(file: string, raw: string): EvalInfo;
44
+ export declare function listEvals(tenant: string, workspace: string): EvalInfo[];
45
+ /**
46
+ * Turn a finished run into a regression case.
47
+ *
48
+ * A run that worked is the best test of the agent that did it: the task is
49
+ * on record, and so is the answer. This writes both into `evals/` — the task
50
+ * verbatim, the answer as a rubric the judge holds the next run to — so a
51
+ * later edit to the markdown that changes the conclusion shows up as a red
52
+ * case rather than as a customer noticing. Appends to the target's
53
+ * regressions file when there is one, so a flow collects its cases in one
54
+ * place instead of one file per press.
55
+ */
56
+ export declare function promoteRunToEval(tenant: string, workspace: string, runId: string, opts?: {
57
+ evalName?: string;
58
+ caseName?: string;
59
+ expect?: string[];
60
+ by?: string;
61
+ }): {
62
+ file: string;
63
+ created: boolean;
64
+ caseName: string;
65
+ };
66
+ export interface AssertionResult {
67
+ assertion: Assertion;
68
+ passed: boolean;
69
+ detail: string;
70
+ }
71
+ export interface CaseResult {
72
+ name: string;
73
+ task: string;
74
+ runId: string | null;
75
+ passed: boolean;
76
+ /** Set when the agent itself failed, before any assertion could run. */
77
+ error: string | null;
78
+ assertions: AssertionResult[];
79
+ costUsd: number;
80
+ }
81
+ export interface EvalResult {
82
+ eval: string;
83
+ startedAt: string;
84
+ finishedAt: string;
85
+ passed: number;
86
+ failed: number;
87
+ costUsd: number;
88
+ cases: CaseResult[];
89
+ /** Why the eval could not run at all — a missing secret, an agent that
90
+ * failed to load. Set only when `cases` is empty for that reason, so a
91
+ * 0-of-n result says what went wrong instead of looking like n wrong
92
+ * answers. */
93
+ error?: string;
94
+ }
95
+ export declare function runEval(tenant: string, workspace: string, info: EvalInfo): Promise<EvalResult>;
96
+ /**
97
+ * The latest result, and one line of history.
98
+ *
99
+ * `<eval>.json` is the latest run, overwritten each time — what the evals
100
+ * page shows. `history.jsonl` is every run, one line each, stamped with the
101
+ * commit the workspace was running. That stamp is the whole feature: a score
102
+ * with no commit says quality changed; a score with one says WHICH change.
103
+ * Manual runs are stamped too — the commit on record is whatever deploy put
104
+ * there — so a button press and a post-deploy run land in the same series.
105
+ */
106
+ export declare function writeEvalResult(tenant: string, workspace: string, result: EvalResult, commit?: string | null): void;
107
+ export interface EvalHistoryEntry {
108
+ eval: string;
109
+ at: string;
110
+ /** The commit the workspace was running. Null on an install that has
111
+ * never deployed from git — the series still exists, just unattributed. */
112
+ commit: string | null;
113
+ passed: number;
114
+ failed: number;
115
+ costUsd: number;
116
+ }
117
+ export declare function readEvalHistory(tenant: string, workspace: string): EvalHistoryEntry[];
118
+ export interface EvalTrend {
119
+ eval: string;
120
+ /** Newest first. */
121
+ latest: EvalHistoryEntry;
122
+ /** The most recent run on a DIFFERENT commit — the comparison that names a
123
+ * change. Null when every run so far was on the same commit. */
124
+ previous: EvalHistoryEntry | null;
125
+ /** Pass count now minus pass count on the previous commit. */
126
+ delta: number | null;
127
+ }
128
+ /**
129
+ * Per eval: where it stands, and against which commit that is a change.
130
+ *
131
+ * Compares to the last run on a different commit rather than the last run,
132
+ * because two runs on one commit differ only by the model's mood — and a
133
+ * "regression" that is really variance would teach people to ignore the
134
+ * real ones.
135
+ */
136
+ export declare function evalTrends(tenant: string, workspace: string): EvalTrend[];
137
+ /**
138
+ * Run every eval against what was just deployed, stamped with its commit.
139
+ *
140
+ * Fire-and-forget from the deploy: a deploy answers in milliseconds and an
141
+ * eval takes minutes and money, so the two are never in one request. Runs
142
+ * one at a time — evals are model calls and a deploy should not fan out
143
+ * into all of them at once. A second deploy while one is still evaluating
144
+ * waits its turn behind the lock rather than doubling the spend.
145
+ */
146
+ export declare function evaluateDeployed(tenant: string, workspace: string, commit?: string | null): Promise<{
147
+ ran: number;
148
+ skipped: string | null;
149
+ }>;
150
+ export declare function readEvalResult(tenant: string, workspace: string, name: string): EvalResult | null;