@alisio/core 0.5.2 → 0.7.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 (204) hide show
  1. package/dist/analysis/janitor.d.ts +48 -0
  2. package/dist/analysis/janitor.js +170 -18
  3. package/dist/analysis/jobs.d.ts +11 -2
  4. package/dist/analysis/jobs.js +13 -0
  5. package/dist/analysis/oci.d.ts +11 -2
  6. package/dist/analysis/oci.js +20 -4
  7. package/dist/analysis/python/sources.js +2 -1
  8. package/dist/analysis/rerun.d.ts +1 -1
  9. package/dist/analysis/status.d.ts +3 -1
  10. package/dist/analysis/status.js +3 -0
  11. package/dist/application.d.ts +28 -2
  12. package/dist/application.js +189 -4
  13. package/dist/changelog/data.js +42 -0
  14. package/dist/config.d.ts +110 -2
  15. package/dist/config.js +188 -6
  16. package/dist/core/call-internals.d.ts +22 -0
  17. package/dist/core/call-internals.js +9 -0
  18. package/dist/core/contracts.d.ts +2 -2
  19. package/dist/core/runner.js +111 -38
  20. package/dist/eval/canonical.d.ts +14 -0
  21. package/dist/eval/canonical.js +40 -0
  22. package/dist/eval/cassette.d.ts +180 -0
  23. package/dist/eval/cassette.js +424 -0
  24. package/dist/eval/compare.d.ts +147 -0
  25. package/dist/eval/compare.js +436 -0
  26. package/dist/eval/engine.d.ts +144 -0
  27. package/dist/eval/engine.js +728 -0
  28. package/dist/eval/export.d.ts +40 -0
  29. package/dist/eval/export.js +90 -0
  30. package/dist/eval/fingerprint.d.ts +88 -0
  31. package/dist/eval/fingerprint.js +186 -0
  32. package/dist/eval/normalize.d.ts +68 -0
  33. package/dist/eval/normalize.js +138 -0
  34. package/dist/eval/paths.d.ts +11 -0
  35. package/dist/eval/paths.js +50 -0
  36. package/dist/eval/plan.d.ts +26 -0
  37. package/dist/eval/plan.js +44 -0
  38. package/dist/eval/report.d.ts +53 -0
  39. package/dist/eval/report.js +258 -0
  40. package/dist/eval/run-suite.d.ts +68 -0
  41. package/dist/eval/run-suite.js +94 -0
  42. package/dist/eval/secrets.d.ts +12 -0
  43. package/dist/eval/secrets.js +45 -0
  44. package/dist/eval/stats.d.ts +17 -0
  45. package/dist/eval/stats.js +50 -0
  46. package/dist/eval/suite.d.ts +20 -0
  47. package/dist/eval/suite.js +165 -0
  48. package/dist/eval/variants.d.ts +35 -0
  49. package/dist/eval/variants.js +137 -0
  50. package/dist/eval/verifiers.d.ts +49 -0
  51. package/dist/eval/verifiers.js +264 -0
  52. package/dist/forge/broker.d.ts +51 -0
  53. package/dist/forge/broker.js +244 -0
  54. package/dist/forge/budget.d.ts +27 -0
  55. package/dist/forge/budget.js +60 -0
  56. package/dist/forge/catalog-view.d.ts +24 -0
  57. package/dist/forge/catalog-view.js +43 -0
  58. package/dist/forge/errors.d.ts +26 -0
  59. package/dist/forge/errors.js +49 -0
  60. package/dist/forge/guides/javascript.d.ts +25 -0
  61. package/dist/forge/guides/javascript.js +90 -0
  62. package/dist/forge/guides/provider.d.ts +42 -0
  63. package/dist/forge/guides/provider.js +96 -0
  64. package/dist/forge/guides/python-environment.d.ts +15 -0
  65. package/dist/forge/guides/python-environment.js +81 -0
  66. package/dist/forge/guides/python.d.ts +38 -0
  67. package/dist/forge/guides/python.js +170 -0
  68. package/dist/forge/javascript/engine.d.ts +44 -0
  69. package/dist/forge/javascript/engine.js +229 -0
  70. package/dist/forge/javascript/hosts/factory.d.ts +25 -0
  71. package/dist/forge/javascript/hosts/factory.js +21 -0
  72. package/dist/forge/javascript/hosts/framing.d.ts +17 -0
  73. package/dist/forge/javascript/hosts/framing.js +49 -0
  74. package/dist/forge/javascript/hosts/isolate-main.d.ts +9 -0
  75. package/dist/forge/javascript/hosts/isolate-main.js +63 -0
  76. package/dist/forge/javascript/hosts/process-entry.d.ts +1 -0
  77. package/dist/forge/javascript/hosts/process-entry.js +3 -0
  78. package/dist/forge/javascript/hosts/process-host.d.ts +33 -0
  79. package/dist/forge/javascript/hosts/process-host.js +160 -0
  80. package/dist/forge/javascript/hosts/worker-entry.d.ts +1 -0
  81. package/dist/forge/javascript/hosts/worker-entry.js +3 -0
  82. package/dist/forge/javascript/hosts/worker-host.d.ts +27 -0
  83. package/dist/forge/javascript/hosts/worker-host.js +116 -0
  84. package/dist/forge/javascript/prelude.d.ts +2 -0
  85. package/dist/forge/javascript/prelude.js +333 -0
  86. package/dist/forge/javascript/probe.d.ts +2 -0
  87. package/dist/forge/javascript/probe.js +53 -0
  88. package/dist/forge/javascript/runtime-manifest.d.ts +14 -0
  89. package/dist/forge/javascript/runtime-manifest.js +14 -0
  90. package/dist/forge/javascript/vm-runner.d.ts +21 -0
  91. package/dist/forge/javascript/vm-runner.js +301 -0
  92. package/dist/forge/javascript/wasm-asset.d.ts +8 -0
  93. package/dist/forge/javascript/wasm-asset.js +8 -0
  94. package/dist/forge/javascript/wasm.d.ts +15 -0
  95. package/dist/forge/javascript/wasm.js +54 -0
  96. package/dist/forge/journal.d.ts +105 -0
  97. package/dist/forge/journal.js +174 -0
  98. package/dist/forge/kernel.d.ts +76 -0
  99. package/dist/forge/kernel.js +339 -0
  100. package/dist/forge/limits.d.ts +38 -0
  101. package/dist/forge/limits.js +73 -0
  102. package/dist/forge/nested.d.ts +96 -0
  103. package/dist/forge/nested.js +214 -0
  104. package/dist/forge/ports.d.ts +120 -0
  105. package/dist/forge/ports.js +1 -0
  106. package/dist/forge/progress.d.ts +24 -0
  107. package/dist/forge/progress.js +76 -0
  108. package/dist/forge/protocol.d.ts +110 -0
  109. package/dist/forge/protocol.js +171 -0
  110. package/dist/forge/python/backend-selector.d.ts +38 -0
  111. package/dist/forge/python/backend-selector.js +111 -0
  112. package/dist/forge/python/backend.d.ts +89 -0
  113. package/dist/forge/python/backend.js +1 -0
  114. package/dist/forge/python/engine.d.ts +84 -0
  115. package/dist/forge/python/engine.js +279 -0
  116. package/dist/forge/python/frame-parser.d.ts +24 -0
  117. package/dist/forge/python/frame-parser.js +107 -0
  118. package/dist/forge/python/frame-transport.d.ts +40 -0
  119. package/dist/forge/python/frame-transport.js +101 -0
  120. package/dist/forge/python/import-scan.d.ts +22 -0
  121. package/dist/forge/python/import-scan.js +133 -0
  122. package/dist/forge/python/managed-backend.d.ts +30 -0
  123. package/dist/forge/python/managed-backend.js +111 -0
  124. package/dist/forge/python/oci-backend.d.ts +27 -0
  125. package/dist/forge/python/oci-backend.js +84 -0
  126. package/dist/forge/python/pyodide-backend.d.ts +40 -0
  127. package/dist/forge/python/pyodide-backend.js +289 -0
  128. package/dist/forge/python/pyodide-install.d.ts +41 -0
  129. package/dist/forge/python/pyodide-install.js +167 -0
  130. package/dist/forge/python/pyodide-manifest.d.ts +42 -0
  131. package/dist/forge/python/pyodide-manifest.js +376 -0
  132. package/dist/forge/python/pyodide-runner-source.d.ts +2 -0
  133. package/dist/forge/python/pyodide-runner-source.js +3 -0
  134. package/dist/forge/python/rss.d.ts +2 -0
  135. package/dist/forge/python/rss.js +33 -0
  136. package/dist/forge/python/scratch-copy.d.ts +6 -0
  137. package/dist/forge/python/scratch-copy.js +61 -0
  138. package/dist/forge/python/settle.d.ts +6 -0
  139. package/dist/forge/python/settle.js +21 -0
  140. package/dist/forge/python/status.d.ts +8 -0
  141. package/dist/forge/python/status.js +15 -0
  142. package/dist/forge/python/wasm-node.d.ts +59 -0
  143. package/dist/forge/python/wasm-node.js +220 -0
  144. package/dist/forge/python/wiring.d.ts +39 -0
  145. package/dist/forge/python/wiring.js +47 -0
  146. package/dist/forge/registry.d.ts +26 -0
  147. package/dist/forge/registry.js +83 -0
  148. package/dist/forge/result.d.ts +58 -0
  149. package/dist/forge/result.js +86 -0
  150. package/dist/forge/routing-rule.d.ts +19 -0
  151. package/dist/forge/routing-rule.js +31 -0
  152. package/dist/forge/runtime.d.ts +64 -0
  153. package/dist/forge/runtime.js +88 -0
  154. package/dist/forge/scratch-files.d.ts +36 -0
  155. package/dist/forge/scratch-files.js +94 -0
  156. package/dist/forge/scratch-provider.d.ts +41 -0
  157. package/dist/forge/scratch-provider.js +79 -0
  158. package/dist/forge/scratch-quota.d.ts +8 -0
  159. package/dist/forge/scratch-quota.js +25 -0
  160. package/dist/forge/selector.d.ts +35 -0
  161. package/dist/forge/selector.js +51 -0
  162. package/dist/forge/session-dir.d.ts +59 -0
  163. package/dist/forge/session-dir.js +239 -0
  164. package/dist/forge/session-path.d.ts +31 -0
  165. package/dist/forge/session-path.js +61 -0
  166. package/dist/forge/slots.d.ts +16 -0
  167. package/dist/forge/slots.js +47 -0
  168. package/dist/forge/state-delta.d.ts +54 -0
  169. package/dist/forge/state-delta.js +99 -0
  170. package/dist/forge/state-machine.d.ts +20 -0
  171. package/dist/forge/state-machine.js +40 -0
  172. package/dist/forge/state-store.d.ts +25 -0
  173. package/dist/forge/state-store.js +50 -0
  174. package/dist/forge/task-log.d.ts +9 -0
  175. package/dist/forge/task-log.js +42 -0
  176. package/dist/forge/verdict.d.ts +20 -0
  177. package/dist/forge/verdict.js +28 -0
  178. package/dist/forge-isolate.d.ts +6 -0
  179. package/dist/forge-isolate.js +6 -0
  180. package/dist/index.d.ts +23 -1
  181. package/dist/index.js +23 -1
  182. package/dist/permissions/decide.d.ts +42 -0
  183. package/dist/permissions/decide.js +24 -0
  184. package/dist/plan/exit-plan.js +2 -1
  185. package/dist/resources/context.d.ts +2 -1
  186. package/dist/resources/context.js +2 -1
  187. package/dist/runtime/access.d.ts +34 -0
  188. package/dist/runtime/access.js +80 -0
  189. package/dist/runtime/ids.d.ts +21 -0
  190. package/dist/runtime/ids.js +41 -1
  191. package/dist/runtime/process.d.ts +2 -1
  192. package/dist/runtime/process.js +5 -5
  193. package/dist/runtime/store.d.ts +11 -0
  194. package/dist/runtime/store.js +106 -2
  195. package/dist/tools/analysis.d.ts +25 -2
  196. package/dist/tools/analysis.js +315 -267
  197. package/dist/tools/execute.js +6 -7
  198. package/dist/tools/forge-guide.d.ts +6 -0
  199. package/dist/tools/forge-guide.js +60 -0
  200. package/dist/tools/js-run.d.ts +19 -0
  201. package/dist/tools/js-run.js +126 -0
  202. package/dist/tools/standard.d.ts +7 -1
  203. package/dist/tools/standard.js +44 -43
  204. package/package.json +7 -2
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Live engine of the reliability lab (specs/010 Phase 2): runs ONE task repetition through the
3
+ * real Application (runner, tools, store) on a throwaway copy of its fixture and returns an
4
+ * `EvalRunRecord` with the conditions it was measured under.
5
+ *
6
+ * What the isolation guarantees, and what it does not:
7
+ * - The fixture is copied; the original is never touched. Config, state, home and tmp live in the
8
+ * run directory and the process environment points at them while the application exists.
9
+ * - File tools are mediated: a write to `../x` or to an absolute path outside the copy is refused
10
+ * (`safePath`). That is path confinement, NOT an OS sandbox.
11
+ * - A granted `process` effect (or a `command` verifier) runs with the user's privileges and can
12
+ * write anywhere the user can. When `process` is granted the "nothing outside changes" claim does
13
+ * not hold. A subprocess is not a sandbox.
14
+ *
15
+ * Runs never overlap: `ALISIO_CONFIG_HOME`/`ALISIO_STATE_HOME` are process-global, so `runTask`
16
+ * serializes concurrent callers.
17
+ */
18
+ import type { EvalBudget, EvalRunRecord, EvalTask, ModelProvider, RunEvent } from "@alisio/sdk";
19
+ import { type BuiltinPlugin, createApplication } from "../application.ts";
20
+ import { type Config } from "../config.ts";
21
+ import type { RunOptions } from "../core/runner.ts";
22
+ import { type Cassette, CassetteRecorder } from "./cassette.ts";
23
+ import type { LoadedSuite } from "./suite.ts";
24
+ export type EvalApplication = Awaited<ReturnType<typeof createApplication>>;
25
+ type BudgetKey = NonNullable<EvalRunRecord["budgetExceeded"]>;
26
+ /** The run was refused before it started (policy, `full` without opt-in, unsafe fixture). */
27
+ export declare class EvalRunRefusedError extends Error {
28
+ constructor(message: string);
29
+ }
30
+ /** Abort reason of the engine's own budgets (`maxWallMs`, `maxToolCalls`). */
31
+ export declare class EvalBudgetExceeded extends Error {
32
+ readonly budget: BudgetKey;
33
+ constructor(budget: BudgetKey);
34
+ }
35
+ /** Effects the invoker (the person or CI job running the lab) holds. A task can never exceed them. */
36
+ export interface InvokerPermissions {
37
+ write: boolean;
38
+ process: boolean;
39
+ external: boolean;
40
+ analysis: boolean;
41
+ readOnly?: boolean;
42
+ }
43
+ /**
44
+ * `live` talks to `provider`; `record` is a live run whose provider calls are also written into the
45
+ * `CassetteRecorder` passed as `cassette`; `replay` serves the recorded `Cassette` passed as
46
+ * `cassette` and needs no provider. Record and replay install a seeded id source for the run (so
47
+ * session, plan and execution ids do not depend on fresh randomness) and wait for the model
48
+ * catalog before the first request (so the output limit does not depend on a race).
49
+ */
50
+ export type EvalRunMode = "live" | "record" | "replay";
51
+ export interface RunTaskOptions {
52
+ suite: LoadedSuite;
53
+ /**
54
+ * Already resolved by the caller; injected into the application (no network lookups here).
55
+ * Required except in `replay` mode, where the cassette supplies the provider.
56
+ */
57
+ provider?: ModelProvider;
58
+ mode?: EvalRunMode;
59
+ cassette?: CassetteRecorder | Cassette;
60
+ /** Receives every `RunEvent` of the run (tests and tooling; the engine keeps its own counts). */
61
+ onEvent?: (event: RunEvent) => void;
62
+ /**
63
+ * Written (stripped of plugins, skills, MCP, extra roots, scratch root and memory `dbPath`) as the global
64
+ * config layer of the run. Phase 3 variant overrides (D15) MUST be applied to this object before
65
+ * calling: the `configHash` is computed from what is written.
66
+ */
67
+ config: Config;
68
+ /** Orders runs only. The provider never receives it, so it is not determinism. */
69
+ seed: number;
70
+ repetition: number;
71
+ invoker: InvokerPermissions;
72
+ /** Required for a task asking for `full`, regardless of what the invoker holds. */
73
+ allowSuiteFull?: boolean;
74
+ keep?: boolean;
75
+ builtins?: BuiltinPlugin[];
76
+ /** Turns `task.agent` into run options; without it a task naming an agent ends `error`. */
77
+ resolveAgent?: (app: EvalApplication, agent: string) => RunOptions | Promise<RunOptions>;
78
+ /** Parent of the run directory (default `os.tmpdir()`). */
79
+ tmpRoot?: string;
80
+ }
81
+ /**
82
+ * Which top-level config keys feed `configHash`. The `satisfies` clause fails the typecheck, and
83
+ * `tests/eval-engine.test.ts` fails at runtime, when a key is added to the schema without being
84
+ * classified here: a new setting must be consciously hashed or excluded.
85
+ */
86
+ export declare const CONFIG_HASH_COVERAGE: {
87
+ readonly limits: "hashed";
88
+ readonly compaction: "hashed";
89
+ readonly context: "hashed";
90
+ readonly forge: "hashed";
91
+ readonly analysis: "hashed";
92
+ readonly websearch: "hashed";
93
+ readonly decisions: "hashed";
94
+ readonly skillOverrides: "hashed";
95
+ readonly schemaVersion: "excluded";
96
+ readonly provider: "excluded";
97
+ readonly plugins: "excluded";
98
+ readonly skills: "excluded";
99
+ readonly additionalDirectories: "excluded";
100
+ readonly mcp: "excluded";
101
+ readonly builtinPlugins: "excluded";
102
+ readonly pluginOverrides: "excluded";
103
+ readonly pluginHooks: "excluded";
104
+ readonly tasks: "excluded";
105
+ readonly goal: "excluded";
106
+ readonly plan: "excluded";
107
+ readonly tui: "excluded";
108
+ readonly agents: "excluded";
109
+ readonly web: "excluded";
110
+ };
111
+ export interface ConfigHashExtras {
112
+ /** The effective policy of the run after the invoker check and `readOnly`. */
113
+ policy: {
114
+ write: boolean;
115
+ process: boolean;
116
+ external: boolean;
117
+ analysis: boolean;
118
+ readOnly?: boolean;
119
+ };
120
+ approvalMode: string;
121
+ budget: EvalBudget;
122
+ /** Ids of the built-in plugins handed to the application (kept only when not disabled). */
123
+ builtinIds: string[];
124
+ }
125
+ /**
126
+ * `sha256:` of the allowlisted effective configuration plus policy, approval mode, budget and
127
+ * enabled built-ins. Excludes secrets, env names, plugin options, absolute paths, endpoints, the
128
+ * provider and the model (those are separate columns of the run record).
129
+ */
130
+ export declare function computeConfigHash(config: Config, extras: ConfigHashExtras): string;
131
+ /**
132
+ * Throws the same `EvalRunRefusedError` `runTask` would, without running anything. Lets a caller
133
+ * refuse a whole batch up front instead of discovering a refusal after earlier runs finished.
134
+ */
135
+ export declare function checkTaskPolicy(task: EvalTask, opts: Pick<RunTaskOptions, "invoker" | "allowSuiteFull">): void;
136
+ /**
137
+ * Runs one repetition of `task`. Refusals (`EvalRunRefusedError`) reject before anything is
138
+ * created; infrastructure failures resolve with `status: "error"` and `error` set.
139
+ */
140
+ export declare function runTask(task: EvalTask, opts: RunTaskOptions): Promise<{
141
+ record: EvalRunRecord;
142
+ keptDir?: string;
143
+ }>;
144
+ export {};