@promptdriven/runtime-client 0.0.0-stage → 1.1.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.
- package/LICENSE +7 -0
- package/README.md +42 -2
- package/package.json +28 -4
- package/src/index.mjs +1 -0
- package/src/runtime/agent-ask.mjs +187 -0
- package/src/runtime/agent-chat.mjs +152 -0
- package/src/runtime/agent-coverage.mjs +97 -0
- package/src/runtime/agent-guide.mjs +152 -0
- package/src/runtime/agent-judge.mjs +71 -0
- package/src/runtime/agent-packet.mjs +62 -0
- package/src/runtime/agent-project.mjs +93 -0
- package/src/runtime/contract-refs.mjs +519 -0
- package/src/runtime/contracts.mjs +138 -0
- package/src/runtime/index.mjs +974 -0
- package/src/runtime/lint-call-preflight.mjs +19 -0
- package/src/runtime/lint-compatibility-display.mjs +62 -0
- package/src/runtime/live-local-bridge.mjs +178 -0
- package/src/runtime/live-local.mjs +181 -0
- package/src/runtime/product-composition.mjs +384 -0
- package/src/runtime/run-program.mjs +797 -0
- package/src/runtime/runtime-binding-plan.mjs +145 -0
- package/src/runtime/runtime-bindings.mjs +81 -0
- package/src/runtime/runtime-check-plan.mjs +411 -0
- package/src/runtime/runtime-client.mjs +8114 -0
- package/src/runtime/runtime-lint-receipt.mjs +25 -0
- package/src/runtime/runtime-markdown.mjs +215 -0
- package/src/runtime/runtime-outcome.mjs +468 -0
- package/src/runtime/runtime-output.mjs +752 -0
- package/src/runtime/runtime-preflight.mjs +3832 -0
- package/src/runtime/runtime-slots.mjs +462 -0
- package/src/runtime/runtime-workspace-migration.mjs +70 -0
- package/src/runtime/runtime-workspace.mjs +52 -0
- package/src/runtime/scenario-json.mjs +257 -0
- package/src/runtime/secret-redaction.mjs +54 -0
- package/src/runtime/try-doors.mjs +597 -0
- package/src/runtime/try-http.mjs +285 -0
- package/src/runtime/try-mcp.mjs +223 -0
- package/src/runtime/try-session.mjs +95 -0
- package/src/runtime/try-update-policy.mjs +43 -0
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
// Generated from prompts/cli/runtime-entry.prompt.md (sha256: 4dfc22f130b60bcad7f0d180c951547c6d50efd298ef310434f12dc1f974a010).
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
4
|
+
|
|
5
|
+
const req = createRequire(import.meta.url);
|
|
6
|
+
|
|
7
|
+
export const LIMITS = Object.freeze({ bytes: 10_485_760, files: 10_000 });
|
|
8
|
+
export const TEST_SCHEMA = 'prompt-runtime.program-scenario.v1';
|
|
9
|
+
const APP_MAP_SCHEMA = 'prompt-runtime.app-map.v1';
|
|
10
|
+
const ENGINE_SHA = 'eae2202a68d00ab762fcbbf1eba0d8607a132a15';
|
|
11
|
+
export const DRAFT_SERVER_TEXT = 'The server does not run draft prompts yet. Approve the prompt first, or wait for the server update.';
|
|
12
|
+
export const STALE_HINT = 'the text changed after approval: update the prompt and ask the person to approve it again';
|
|
13
|
+
export const staleHint = `pdd: ${STALE_HINT}.`;
|
|
14
|
+
export const PROVIDER_TEXT = 'the AI provider failed during the run. It is not a failed check. Do not send it again yet.';
|
|
15
|
+
export const CHECK_STATES = Object.freeze(['waiting', 'sent', 'passed', 'failed', 'refused', 'partial', 'not run']);
|
|
16
|
+
export const OPEN_STATES = new Set(['queued', 'running', 'sent']);
|
|
17
|
+
|
|
18
|
+
export class PreflightError extends Error {
|
|
19
|
+
constructor(exitCode, message) {
|
|
20
|
+
const Real = runtimePreflightSlice().PreflightError;
|
|
21
|
+
return new Real(exitCode, message);
|
|
22
|
+
}
|
|
23
|
+
static [Symbol.hasInstance](value) {
|
|
24
|
+
return value instanceof runtimePreflightSlice().PreflightError;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let scenarioJsonModule = null;
|
|
29
|
+
export function runtimeScenarioJsonSlice() {
|
|
30
|
+
return (scenarioJsonModule ??= req('./scenario-json.mjs'));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let workspaceModule = null;
|
|
34
|
+
export function runtimeWorkspaceSlice() {
|
|
35
|
+
return (workspaceModule ??= req('./runtime-workspace.mjs'));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let outcomeModule = null;
|
|
39
|
+
export function runtimeOutcomeSlice() {
|
|
40
|
+
return (outcomeModule ??= req('./runtime-outcome.mjs'));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let outputModule = null;
|
|
44
|
+
export function runtimeOutputSlice() {
|
|
45
|
+
return (outputModule ??= req('./runtime-output.mjs'));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let preflightModule = null;
|
|
49
|
+
export function runtimePreflightSlice() {
|
|
50
|
+
return (preflightModule ??= req('./runtime-preflight.mjs'));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let agentPacketModule = null;
|
|
54
|
+
export function runtimeAgentPacketSlice() {
|
|
55
|
+
return (agentPacketModule ??= req('./agent-packet.mjs'));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let checkPlanModule = null;
|
|
59
|
+
export function runtimeCheckPlanSlice() {
|
|
60
|
+
return (checkPlanModule ??= req('./runtime-check-plan.mjs'));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let runtimeClientModule = null;
|
|
64
|
+
export function runtimeClientSlice() {
|
|
65
|
+
return (runtimeClientModule ??= req('./runtime-client.mjs'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function exactIntegerLeaves(...args) {
|
|
69
|
+
return runtimeScenarioJsonSlice().exactIntegerLeaves(...args);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function exactValue(...args) {
|
|
73
|
+
return runtimeScenarioJsonSlice().exactValue(...args);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function jsonSafe(...args) {
|
|
77
|
+
return runtimeScenarioJsonSlice().jsonSafe(...args);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function parseScenarioJson(...args) {
|
|
81
|
+
return runtimeScenarioJsonSlice().parseScenarioJson(...args);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function roundedNumberTokens(...args) {
|
|
85
|
+
return runtimeScenarioJsonSlice().roundedNumberTokens(...args);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function stringifyScenarioJson(...args) {
|
|
89
|
+
return runtimeScenarioJsonSlice().stringifyScenarioJson(...args);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function withExactIntegers(...args) {
|
|
93
|
+
return runtimeScenarioJsonSlice().withExactIntegers(...args);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function allowsRuntimePath(...args) {
|
|
97
|
+
return runtimeWorkspaceSlice().allowsRuntimePath(...args);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function loadRuntimeWorkspace(...args) {
|
|
101
|
+
return runtimeWorkspaceSlice().loadRuntimeWorkspace(...args);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function requireRuntimePath(...args) {
|
|
105
|
+
return runtimeWorkspaceSlice().requireRuntimePath(...args);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function hasProgress(...args) {
|
|
109
|
+
return runtimeOutcomeSlice().hasProgress(...args);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function outcomeDone(...args) {
|
|
113
|
+
return runtimeOutcomeSlice().outcomeDone(...args);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function outcomeFor(...args) {
|
|
117
|
+
return runtimeOutcomeSlice().outcomeFor(...args);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function outcomeOverall(...args) {
|
|
121
|
+
return runtimeOutcomeSlice().outcomeOverall(...args);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function outcomeText(...args) {
|
|
125
|
+
return runtimeOutcomeSlice().outcomeText(...args);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function progressText(...args) {
|
|
129
|
+
return runtimeOutcomeSlice().progressText(...args);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function resultOutcome(...args) {
|
|
133
|
+
return runtimeOutcomeSlice().resultOutcome(...args);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function resultOverall(...args) {
|
|
137
|
+
return runtimeOutcomeSlice().resultOverall(...args);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function causeText(...args) {
|
|
141
|
+
return runtimeOutputSlice().causeText(...args);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function cleanText(...args) {
|
|
145
|
+
return runtimeOutputSlice().cleanText(...args);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function coverageText(...args) {
|
|
149
|
+
return runtimeOutputSlice().coverageText(...args);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function jsonRow(...args) {
|
|
153
|
+
return runtimeOutputSlice().jsonRow(...args);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function progressTicker(...args) {
|
|
157
|
+
return runtimeOutputSlice().progressTicker(...args);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function projectAnswer(...args) {
|
|
161
|
+
return runtimeOutputSlice().projectAnswer(...args);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export function refusalView(...args) {
|
|
165
|
+
return runtimeOutputSlice().refusalView(...args);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function renderJson(...args) {
|
|
169
|
+
return runtimeOutputSlice().renderJson(...args);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function renderText(...args) {
|
|
173
|
+
return runtimeOutputSlice().renderText(...args);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function sinceText(...args) {
|
|
177
|
+
return runtimeOutputSlice().sinceText(...args);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function stepTimeLimit(...args) {
|
|
181
|
+
return runtimeOutputSlice().stepTimeLimit(...args);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function storyLines(...args) {
|
|
185
|
+
return runtimeOutputSlice().storyLines(...args);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function summaryLine(...args) {
|
|
189
|
+
return runtimeOutputSlice().summaryLine(...args);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function tryUsage(...args) {
|
|
193
|
+
return runtimeOutputSlice().tryUsage(...args);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export function tryUsageHeaders(...args) {
|
|
197
|
+
return runtimeOutputSlice().tryUsageHeaders(...args);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function tryUsageLine(...args) {
|
|
201
|
+
return runtimeOutputSlice().tryUsageLine(...args);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export function validLink(...args) {
|
|
205
|
+
return runtimeOutputSlice().validLink(...args);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function captureSource(...args) {
|
|
209
|
+
return runtimePreflightSlice().captureSource(...args);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function checkInput(...args) {
|
|
213
|
+
return runtimePreflightSlice().checkInput(...args);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function createStrictSourceAccess(...args) {
|
|
217
|
+
return runtimePreflightSlice().createStrictSourceAccess(...args);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function defaultMaxCalls(...args) {
|
|
221
|
+
return runtimePreflightSlice().defaultMaxCalls(...args);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function discoveryRefusal(...args) {
|
|
225
|
+
return runtimePreflightSlice().discoveryRefusal(...args);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function discoveryVisibleFiles(...args) {
|
|
229
|
+
return runtimePreflightSlice().discoveryVisibleFiles(...args);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function exactNumberSpelling(...args) {
|
|
233
|
+
return runtimePreflightSlice().exactNumberSpelling(...args);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function executableInterfaceText(...args) {
|
|
237
|
+
return runtimePreflightSlice().executableInterfaceText(...args);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function fillHashes(...args) {
|
|
241
|
+
return runtimePreflightSlice().fillHashes(...args);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function findTests(...args) {
|
|
245
|
+
return runtimePreflightSlice().findTests(...args);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function formatSize(...args) {
|
|
249
|
+
return runtimePreflightSlice().formatSize(...args);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function formatWarningLines(...args) {
|
|
253
|
+
return runtimePreflightSlice().formatWarningLines(...args);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function gitFiles(...args) {
|
|
257
|
+
return runtimePreflightSlice().gitFiles(...args);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function hasPromptInterface(...args) {
|
|
261
|
+
return runtimePreflightSlice().hasPromptInterface(...args);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function interfaceBlocks(...args) {
|
|
265
|
+
return runtimePreflightSlice().interfaceBlocks(...args);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function interfaceFormatWarnings(...args) {
|
|
269
|
+
return runtimePreflightSlice().interfaceFormatWarnings(...args);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function interfaceKindProblems(...args) {
|
|
273
|
+
return runtimePreflightSlice().interfaceKindProblems(...args);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function interfaceSchemaProblems(...args) {
|
|
277
|
+
return runtimePreflightSlice().interfaceSchemaProblems(...args);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function isSecretPath(...args) {
|
|
281
|
+
return runtimePreflightSlice().isSecretPath(...args);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function numberWarnings(...args) {
|
|
285
|
+
return runtimePreflightSlice().numberWarnings(...args);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function otherFiles(...args) {
|
|
289
|
+
return runtimePreflightSlice().otherFiles(...args);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function parsePromptFrontmatter(...args) {
|
|
293
|
+
return runtimePreflightSlice().parsePromptFrontmatter(...args);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function preflight(...args) {
|
|
297
|
+
return runtimePreflightSlice().preflight(...args);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function promptMarkdownTargets(...args) {
|
|
301
|
+
return runtimePreflightSlice().promptMarkdownTargets(...args);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function promptRefusal(...args) {
|
|
305
|
+
return runtimePreflightSlice().promptRefusal(...args);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function promptSchemaRefusals(...args) {
|
|
309
|
+
return runtimePreflightSlice().promptSchemaRefusals(...args);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function proseSha256(...args) {
|
|
313
|
+
return runtimePreflightSlice().proseSha256(...args);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function readPrompt(...args) {
|
|
317
|
+
return runtimePreflightSlice().readPrompt(...args);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function scenarioShapeRefusal(...args) {
|
|
321
|
+
return runtimePreflightSlice().scenarioShapeRefusal(...args);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export function schemaKeywordWarningLines(...args) {
|
|
325
|
+
return runtimePreflightSlice().schemaKeywordWarningLines(...args);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function sha256(...args) {
|
|
329
|
+
return runtimePreflightSlice().sha256(...args);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export function sharedSourceFiles(...args) {
|
|
333
|
+
return runtimePreflightSlice().sharedSourceFiles(...args);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function sourceFilePort(...args) {
|
|
337
|
+
return runtimePreflightSlice().sourceFilePort(...args);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export function storyCriteria(...args) {
|
|
341
|
+
return runtimePreflightSlice().storyCriteria(...args);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function tarFiles(...args) {
|
|
345
|
+
return runtimePreflightSlice().tarFiles(...args);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export function buildAgentInput(...args) {
|
|
349
|
+
return runtimeAgentPacketSlice().buildAgentInput(...args);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function baselineReport(input) {
|
|
353
|
+
return runtimeCheckPlanSlice().baselineReport(input);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export function buildCheckPlan(input, ports) {
|
|
357
|
+
return runtimeCheckPlanSlice().buildCheckPlan(input, ports);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function checkPlanResults(plan, rows) {
|
|
361
|
+
return runtimeCheckPlanSlice().checkPlanResults(plan, rows);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export function checkPlanResultLines(result) {
|
|
365
|
+
return runtimeCheckPlanSlice().checkPlanResultLines(result);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export function selectCheckTests(plan, options) {
|
|
369
|
+
return runtimeCheckPlanSlice().selectCheckTests(plan, options);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
let productCompositionModule = null;
|
|
373
|
+
function loadProductComposition() {
|
|
374
|
+
return (productCompositionModule ??= req('./product-composition.mjs'));
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function composeProductTry(input, ports) {
|
|
378
|
+
return loadProductComposition().composeProductTry(input, ports);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function productTapCallBound(map, ports) {
|
|
382
|
+
return loadProductComposition().productTapCallBound(map, ports);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export function selectJourneys(tests, selector, ports) {
|
|
386
|
+
return loadProductComposition().selectJourneys(tests, selector, ports);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
let agentGuideModule = null;
|
|
390
|
+
function loadAgentGuide() {
|
|
391
|
+
return (agentGuideModule ??= req('./agent-guide.mjs'));
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export function createTryGuide(options) {
|
|
395
|
+
return loadAgentGuide().createTryGuide(options);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
let agentProjectModule = null;
|
|
399
|
+
function loadAgentProject() {
|
|
400
|
+
return (agentProjectModule ??= req('./agent-project.mjs'));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export function buildProjectCard(input) {
|
|
404
|
+
return loadAgentProject().buildProjectCard(input);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export function readAgentScenarios(input, ports) {
|
|
408
|
+
return loadAgentProject().readAgentScenarios(input, ports);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
export async function runJobs(input, ports) {
|
|
412
|
+
const { runJobs: run } = await import('./runtime-slots.mjs');
|
|
413
|
+
return run(input, ports);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
let contractsModule = null;
|
|
417
|
+
function loadContracts() {
|
|
418
|
+
return (contractsModule ??= req('./contracts.mjs'));
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
export function runContracts(input, ports) {
|
|
422
|
+
return loadContracts().runContracts(input, ports);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let tryMcpModule = null;
|
|
426
|
+
function loadTryMcp() {
|
|
427
|
+
return (tryMcpModule ??= req('./try-mcp.mjs'));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export function createTryTools(input, ports) {
|
|
431
|
+
return loadTryMcp().createTryTools(input, ports);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
export async function runMcp(input, ports) {
|
|
435
|
+
const { runMcp: run } = await import('./try-mcp.mjs');
|
|
436
|
+
return run(input, ports);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export async function openCli(context, test, sessionId, options) {
|
|
440
|
+
const { openCli: open } = await import('./try-doors.mjs');
|
|
441
|
+
return open(context, test, sessionId, options);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export async function openServe(context, test, sessionId, options) {
|
|
445
|
+
const { openServe: open } = await import('./try-http.mjs');
|
|
446
|
+
return open(context, test, sessionId, options);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
export async function runShim(descriptorPath, argv, ports) {
|
|
450
|
+
const { runShim: run } = await import('./try-doors.mjs');
|
|
451
|
+
return run(descriptorPath, argv, ports);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export async function saveLast(input) {
|
|
455
|
+
const { saveLast: save } = await import('./try-doors.mjs');
|
|
456
|
+
return save(input);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export function defaultLineReader(stdin) {
|
|
460
|
+
return runtimeClientSlice().defaultLineReader(stdin);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export function runtimeOrigin(env) {
|
|
464
|
+
return runtimeClientSlice().runtimeOrigin(env);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export function readContractHistory(input, ports) {
|
|
468
|
+
return runtimeClientSlice().readContractHistory(input, ports);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export function runtimeWorkspaceMigrationStore(input, given) {
|
|
472
|
+
return runtimeClientSlice().runtimeWorkspaceMigrationStore(input, given);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
export function saveDoorCaseResult(root, saved, options) {
|
|
476
|
+
return runtimeClientSlice().saveDoorCaseResult(root, saved, options);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export function saveDoorCase(root, saved, options) {
|
|
480
|
+
return runtimeClientSlice().saveDoorCase(root, saved, options);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
export function createSavedStoryEvidenceReader(ports = {}) {
|
|
484
|
+
return runtimeClientSlice().createSavedStoryEvidenceReader(ports);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export async function loadRuntimeClient() {
|
|
488
|
+
const { DEFAULT_RUNTIME_URL: defaultUrl, checkRuntimeHealth: checkHealth, runtimeOrigin: origin } = await import('./runtime-client.mjs');
|
|
489
|
+
return { DEFAULT_RUNTIME_URL: defaultUrl, checkRuntimeHealth: checkHealth, runtimeOrigin: origin };
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export async function checkRuntimeHealth(input, ports) {
|
|
493
|
+
const { checkRuntimeHealth: check } = await import('./runtime-client.mjs');
|
|
494
|
+
return check(input, ports);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
export async function resendableStoryChecks(input, ports) {
|
|
498
|
+
const { resendableStoryChecks: read } = await import('./runtime-client.mjs');
|
|
499
|
+
return read(input, ports);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export async function savedStoryEvidence(input, ports) {
|
|
503
|
+
const { savedStoryEvidence: read } = await import('./runtime-client.mjs');
|
|
504
|
+
return read(input, ports);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export async function acquireRuntimeBatchLock(folder, options) {
|
|
508
|
+
const { acquireRuntimeBatchLock: acquire } = await import('./runtime-client.mjs');
|
|
509
|
+
return acquire(folder, options);
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export async function acquireCaseWriteOwnership(input, ports) {
|
|
513
|
+
const { acquireCaseWriteOwnership: acquire } = await import('./runtime-client.mjs');
|
|
514
|
+
return acquire(input, ports);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export async function applyPendingCase(input, ports) {
|
|
518
|
+
const { applyPendingCase: apply } = await import('./runtime-client.mjs');
|
|
519
|
+
return apply(input, ports);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
export async function applyPendingCaseWithHandoff(input, ports) {
|
|
523
|
+
const { applyPendingCaseWithHandoff: apply } = await import('./runtime-client.mjs');
|
|
524
|
+
return apply(input, ports);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export async function runCheck(input, ports) {
|
|
528
|
+
const { runCheck: run } = await import('./runtime-client.mjs');
|
|
529
|
+
return run(input, ports);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
export async function runProgram(input = {}, ports) {
|
|
533
|
+
const { runProgram: execute } = await import('./run-program.mjs');
|
|
534
|
+
return execute(input, ports);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export async function run(input = {}, ports) {
|
|
538
|
+
return runProgram(input, ports);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
let programModule;
|
|
542
|
+
function programPolicy() { return programModule ??= req('./run-program.mjs'); }
|
|
543
|
+
export function prepareProgramInvocation(input) { return programPolicy().prepareProgramInvocation(input); }
|
|
544
|
+
export function planProgramSession(input) { return programPolicy().planProgramSession(input); }
|
|
545
|
+
export function planProgramCase(input) { return programPolicy().planProgramCase(input); }
|
|
546
|
+
|
|
547
|
+
export async function runTry(input, ports) {
|
|
548
|
+
const { runTry: run } = await import('./runtime-client.mjs');
|
|
549
|
+
return run(input, ports);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export async function runDoorCall(descriptor, input, ports) {
|
|
553
|
+
const { runDoorCall: run } = await import('./runtime-client.mjs');
|
|
554
|
+
return run(descriptor, input, ports);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
export async function readTryOwner(input, ports) {
|
|
558
|
+
const { readTryOwner: read } = await import('./runtime-client.mjs');
|
|
559
|
+
return read(input, ports);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export async function observeTryCall(input, ports) {
|
|
563
|
+
const { observeTryCall: observe } = await import('./runtime-client.mjs');
|
|
564
|
+
return observe(input, ports);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export async function askAgent(input, ports) {
|
|
568
|
+
const { askAgent: ask } = await import('./agent-ask.mjs');
|
|
569
|
+
return ask(input, ports);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export async function createAgentBridge(context, test, tryId, options, link, seamPorts) {
|
|
573
|
+
const { createAgentBridge: create } = await import('./agent-chat.mjs');
|
|
574
|
+
return create(context, test, tryId, options, link, seamPorts);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export async function migrateRuntimeWorkspace(input, ports) {
|
|
578
|
+
const { migrateRuntimeWorkspace: migrate } = await import('./runtime-workspace-migration.mjs');
|
|
579
|
+
return migrate(input, ports);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
const isPlainObject = value =>
|
|
583
|
+
value !== null &&
|
|
584
|
+
typeof value === 'object' &&
|
|
585
|
+
!Array.isArray(value) &&
|
|
586
|
+
(Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
587
|
+
|
|
588
|
+
function commandWords(input = {}) {
|
|
589
|
+
if (Array.isArray(input?.words)) return [...input.words];
|
|
590
|
+
if (Array.isArray(input?.tests)) {
|
|
591
|
+
return input.tests
|
|
592
|
+
.map(item => (typeof item === 'string' ? item : item?.path ?? item?.story))
|
|
593
|
+
.filter(item => typeof item === 'string' && item.length > 0);
|
|
594
|
+
}
|
|
595
|
+
return [];
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
function buildCheckInput(input = {}, { defaultCache = false, extraOptions = {} } = {}) {
|
|
599
|
+
const cwd = input?.cwd ?? input?.root;
|
|
600
|
+
const options = { ...(input?.options ?? {}), ...extraOptions };
|
|
601
|
+
return {
|
|
602
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
603
|
+
words: commandWords(input),
|
|
604
|
+
options,
|
|
605
|
+
cache: input?.cache ?? defaultCache,
|
|
606
|
+
...(input?.client !== undefined ? { client: input.client } : {}),
|
|
607
|
+
...(input?.workflow !== undefined ? { workflow: input.workflow } : {}),
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
const LOCAL_WHAT_FLAGS = Object.freeze({
|
|
612
|
+
files: '--files',
|
|
613
|
+
'explain-bindings': '--explain-bindings',
|
|
614
|
+
});
|
|
615
|
+
|
|
616
|
+
const SIMULATE_MODES = new Set(['open', 'cli', 'serve', 'save-last', 'stop']);
|
|
617
|
+
|
|
618
|
+
export async function check(input = {}, ports) {
|
|
619
|
+
const extraOptions =
|
|
620
|
+
input?.affected === true && input?.options?.['--affected'] === undefined ? { '--affected': true } : {};
|
|
621
|
+
return runCheck(buildCheckInput(input, { defaultCache: true, extraOptions }), ports);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
export async function lint(input = {}, ports) {
|
|
625
|
+
const extraOptions = {
|
|
626
|
+
'--lint': true,
|
|
627
|
+
...(input?.local === true && input?.options?.['--local'] === undefined ? { '--local': true } : {}),
|
|
628
|
+
};
|
|
629
|
+
return runCheck(buildCheckInput(input, { defaultCache: true, extraOptions }), ports);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
export async function read(input = {}, ports) {
|
|
633
|
+
const cwd = input?.cwd ?? input?.root;
|
|
634
|
+
const target = input?.call_id ?? input?.batch;
|
|
635
|
+
const words = Array.isArray(input?.words)
|
|
636
|
+
? [...input.words]
|
|
637
|
+
: target !== undefined && target !== null && target !== ''
|
|
638
|
+
? [String(target)]
|
|
639
|
+
: [];
|
|
640
|
+
return runCheck(
|
|
641
|
+
{
|
|
642
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
643
|
+
words,
|
|
644
|
+
options: { ...(input?.options ?? {}), '--read': true },
|
|
645
|
+
cache: input?.cache ?? false,
|
|
646
|
+
...(input?.client !== undefined ? { client: input.client } : {}),
|
|
647
|
+
...(input?.workflow !== undefined ? { workflow: input.workflow } : {}),
|
|
648
|
+
},
|
|
649
|
+
ports,
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
export async function retry(input = {}, ports) {
|
|
654
|
+
const cwd = input?.cwd ?? input?.root;
|
|
655
|
+
const words = Array.isArray(input?.words) ? [...input.words] : [];
|
|
656
|
+
const retryTarget = input?.batch ?? input?.options?.['--retry'];
|
|
657
|
+
return runCheck(
|
|
658
|
+
{
|
|
659
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
660
|
+
words,
|
|
661
|
+
options: {
|
|
662
|
+
...(input?.options ?? {}),
|
|
663
|
+
...(retryTarget !== undefined ? { '--retry': retryTarget } : {}),
|
|
664
|
+
},
|
|
665
|
+
cache: input?.cache ?? false,
|
|
666
|
+
...(input?.client !== undefined ? { client: input.client } : {}),
|
|
667
|
+
...(input?.workflow !== undefined ? { workflow: input.workflow } : {}),
|
|
668
|
+
},
|
|
669
|
+
ports,
|
|
670
|
+
);
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
export async function local(input = {}, ports) {
|
|
674
|
+
const flag = LOCAL_WHAT_FLAGS[input?.what];
|
|
675
|
+
if (!flag) {
|
|
676
|
+
throw new RangeError(`Unsupported local inspection mode: ${String(input?.what)}`);
|
|
677
|
+
}
|
|
678
|
+
const extraOptions = { [flag]: true };
|
|
679
|
+
return runCheck({ ...buildCheckInput(input, { defaultCache: false, extraOptions }), cache: false }, ports);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
export async function simulate(input = {}, ports) {
|
|
683
|
+
if (input?.mode !== undefined && !SIMULATE_MODES.has(input.mode)) {
|
|
684
|
+
throw new RangeError(`Unsupported simulate mode: ${String(input.mode)}`);
|
|
685
|
+
}
|
|
686
|
+
const cwd = input?.cwd ?? input?.root;
|
|
687
|
+
const options = { ...(input?.options ?? {}) };
|
|
688
|
+
if (input?.mode === 'cli') options['--cli'] = true;
|
|
689
|
+
else if (input?.mode === 'serve' && options['--serve'] === undefined) options['--serve'] = input?.port ?? true;
|
|
690
|
+
else if (input?.mode === 'save-last') options['--save-last'] = true;
|
|
691
|
+
else if (input?.mode === 'stop') options['--stop'] = true;
|
|
692
|
+
const testWord =
|
|
693
|
+
typeof input?.test === 'string' && input.test.length > 0
|
|
694
|
+
? input.test
|
|
695
|
+
: input?.test && typeof input.test === 'object' && typeof (input.test.path ?? input.test.story) === 'string'
|
|
696
|
+
? input.test.path ?? input.test.story
|
|
697
|
+
: null;
|
|
698
|
+
const words = Array.isArray(input?.words)
|
|
699
|
+
? [...input.words]
|
|
700
|
+
: testWord !== null
|
|
701
|
+
? [testWord]
|
|
702
|
+
: commandWords(input);
|
|
703
|
+
return runTry({ ...(cwd !== undefined ? { cwd } : {}), words, options }, ports);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export async function jobs(input = {}, ports) {
|
|
707
|
+
const env = input?.env ?? ports?.env;
|
|
708
|
+
return runJobs({ ...(input ?? {}), ...(env !== undefined ? { env } : {}) }, ports);
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
export async function health(input = {}, ports) {
|
|
712
|
+
const env = input?.env ?? ports?.env;
|
|
713
|
+
return checkRuntimeHealth({ ...(input ?? {}), ...(env !== undefined ? { env } : {}) }, ports);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export async function mcp(input = {}, ports) {
|
|
717
|
+
const cwd = input?.cwd ?? input?.root;
|
|
718
|
+
const words = Array.isArray(input?.words) ? [...input.words] : input?.story ? [input.story] : [];
|
|
719
|
+
const env = input?.env ?? ports?.env;
|
|
720
|
+
return runMcp(
|
|
721
|
+
{
|
|
722
|
+
...(cwd !== undefined ? { cwd } : {}),
|
|
723
|
+
words,
|
|
724
|
+
...(env !== undefined ? { env } : {}),
|
|
725
|
+
},
|
|
726
|
+
ports,
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
export function contracts(input = {}, ports) {
|
|
731
|
+
const cwd = input?.cwd ?? input?.root;
|
|
732
|
+
const words = Array.isArray(input?.words) ? [...input.words] : input?.sync ? ['sync'] : [];
|
|
733
|
+
const options =
|
|
734
|
+
input?.options !== undefined
|
|
735
|
+
? {
|
|
736
|
+
...input.options,
|
|
737
|
+
...(input?.write !== undefined && input.options['--write'] === undefined ? { '--write': input.write } : {}),
|
|
738
|
+
}
|
|
739
|
+
: input?.write !== undefined
|
|
740
|
+
? { '--write': input.write }
|
|
741
|
+
: {};
|
|
742
|
+
return runContracts({ ...(cwd !== undefined ? { cwd } : {}), words, options }, ports);
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
function parseInterfaceBlockMatch(match) {
|
|
746
|
+
let parsed = null;
|
|
747
|
+
try {
|
|
748
|
+
const candidate = JSON.parse(match[1]);
|
|
749
|
+
if (isPlainObject(candidate)) parsed = candidate;
|
|
750
|
+
} catch {
|
|
751
|
+
parsed = null;
|
|
752
|
+
}
|
|
753
|
+
return {
|
|
754
|
+
raw: match[0],
|
|
755
|
+
json: parsed,
|
|
756
|
+
status: typeof parsed?.status === 'string' ? parsed.status : null,
|
|
757
|
+
prose_sha256: typeof parsed?.prose_sha256 === 'string' ? parsed.prose_sha256 : null,
|
|
758
|
+
start: match.indices[0][0],
|
|
759
|
+
end: match.indices[0][1],
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function topLevelStringSpans(body) {
|
|
764
|
+
const skipString = start => {
|
|
765
|
+
let i = start + 1;
|
|
766
|
+
while (i < body.length) {
|
|
767
|
+
if (body[i] === '\\') {
|
|
768
|
+
i += 2;
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
if (body[i] === '"') return i + 1;
|
|
772
|
+
i += 1;
|
|
773
|
+
}
|
|
774
|
+
return -1;
|
|
775
|
+
};
|
|
776
|
+
const spans = new Map();
|
|
777
|
+
const counts = new Map();
|
|
778
|
+
let depth = 0;
|
|
779
|
+
for (let i = 0; i < body.length; ) {
|
|
780
|
+
const ch = body[i];
|
|
781
|
+
if (ch === '"') {
|
|
782
|
+
const end = skipString(i);
|
|
783
|
+
if (end < 0) return null;
|
|
784
|
+
const after = /^\s*:\s*/.exec(body.slice(end));
|
|
785
|
+
if (depth === 1 && after) {
|
|
786
|
+
const key = JSON.parse(body.slice(i, end));
|
|
787
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
788
|
+
const valStart = end + after[0].length;
|
|
789
|
+
if (body[valStart] === '"') {
|
|
790
|
+
const valEnd = skipString(valStart);
|
|
791
|
+
if (valEnd < 0) return null;
|
|
792
|
+
spans.set(key, [valStart, valEnd]);
|
|
793
|
+
i = valEnd;
|
|
794
|
+
continue;
|
|
795
|
+
}
|
|
796
|
+
spans.delete(key);
|
|
797
|
+
}
|
|
798
|
+
i = end;
|
|
799
|
+
continue;
|
|
800
|
+
}
|
|
801
|
+
if (ch === '{' || ch === '[') depth += 1;
|
|
802
|
+
else if (ch === '}' || ch === ']') depth -= 1;
|
|
803
|
+
i += 1;
|
|
804
|
+
}
|
|
805
|
+
return { spans, counts };
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function setInterfaceStatusImpl(text, { status, prose_sha256: nextDigest } = {}) {
|
|
809
|
+
if (typeof text !== 'string' || typeof status !== 'string') return null;
|
|
810
|
+
if (nextDigest !== undefined && typeof nextDigest !== 'string') return null;
|
|
811
|
+
const preflightSlice = runtimePreflightSlice();
|
|
812
|
+
const blocks = preflightSlice.interfaceBlocks(text);
|
|
813
|
+
if (blocks.length !== 1) return null;
|
|
814
|
+
const [start, end] = blocks[0].indices[1];
|
|
815
|
+
const body = blocks[0][1];
|
|
816
|
+
const expectedDigest = preflightSlice.proseSha256(text);
|
|
817
|
+
let value;
|
|
818
|
+
try {
|
|
819
|
+
value = JSON.parse(body);
|
|
820
|
+
} catch {
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
if (!isPlainObject(value)) return null;
|
|
824
|
+
const parsedSpans = topLevelStringSpans(body);
|
|
825
|
+
if (!parsedSpans) return null;
|
|
826
|
+
const { spans, counts } = parsedSpans;
|
|
827
|
+
if (counts.get('status') !== 1 || counts.get('prose_sha256') !== 1) return null;
|
|
828
|
+
const statusSpan = spans.get('status');
|
|
829
|
+
const digestSpan = spans.get('prose_sha256');
|
|
830
|
+
if (!statusSpan || !digestSpan) return null;
|
|
831
|
+
const edits = [[...statusSpan, JSON.stringify(status)]];
|
|
832
|
+
if (nextDigest !== undefined) edits.push([...digestSpan, JSON.stringify(nextDigest)]);
|
|
833
|
+
edits.sort((a, b) => b[0] - a[0]);
|
|
834
|
+
const changed = edits.reduce(
|
|
835
|
+
(acc, [from, to, replacement]) => acc.slice(0, from) + replacement + acc.slice(to),
|
|
836
|
+
body,
|
|
837
|
+
);
|
|
838
|
+
const next = text.slice(0, start) + changed + text.slice(end);
|
|
839
|
+
try {
|
|
840
|
+
const expectedValue = {
|
|
841
|
+
...value,
|
|
842
|
+
status,
|
|
843
|
+
...(nextDigest !== undefined ? { prose_sha256: nextDigest } : {}),
|
|
844
|
+
};
|
|
845
|
+
const nextBlocks = preflightSlice.interfaceBlocks(next);
|
|
846
|
+
if (nextBlocks.length !== 1 || preflightSlice.proseSha256(next) !== expectedDigest) return null;
|
|
847
|
+
return isDeepStrictEqual(JSON.parse(changed), expectedValue) &&
|
|
848
|
+
isDeepStrictEqual(JSON.parse(nextBlocks[0][1]), expectedValue)
|
|
849
|
+
? next
|
|
850
|
+
: null;
|
|
851
|
+
} catch {
|
|
852
|
+
return null;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
export const format = Object.freeze({
|
|
857
|
+
parseScenario(text) {
|
|
858
|
+
return runtimeScenarioJsonSlice().parseScenarioJson(text);
|
|
859
|
+
},
|
|
860
|
+
stringifyScenario(doc, space) {
|
|
861
|
+
return runtimeScenarioJsonSlice().stringifyScenarioJson(doc, space);
|
|
862
|
+
},
|
|
863
|
+
exactValue(value) {
|
|
864
|
+
return runtimeScenarioJsonSlice().exactValue(value);
|
|
865
|
+
},
|
|
866
|
+
isScenario(text) {
|
|
867
|
+
if (typeof text !== 'string') return false;
|
|
868
|
+
try {
|
|
869
|
+
const doc = runtimeScenarioJsonSlice().parseScenarioJson(text);
|
|
870
|
+
return isPlainObject(doc) && doc.schema_version === TEST_SCHEMA;
|
|
871
|
+
} catch {
|
|
872
|
+
return false;
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
interfaceBlocks(text) {
|
|
876
|
+
return runtimePreflightSlice().interfaceBlocks(String(text ?? '')).map(parseInterfaceBlockMatch);
|
|
877
|
+
},
|
|
878
|
+
proseSha256(text) {
|
|
879
|
+
return runtimePreflightSlice().proseSha256(text);
|
|
880
|
+
},
|
|
881
|
+
interfaceProblems(json) {
|
|
882
|
+
return runtimePreflightSlice().interfaceSchemaProblems(json);
|
|
883
|
+
},
|
|
884
|
+
setInterfaceStatus(text, fields) {
|
|
885
|
+
return setInterfaceStatusImpl(text, fields);
|
|
886
|
+
},
|
|
887
|
+
storyCriteria(text) {
|
|
888
|
+
return runtimePreflightSlice().storyCriteria(text);
|
|
889
|
+
},
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
export const source = Object.freeze({
|
|
893
|
+
identity({ root, tests, ...options } = {}, ports) {
|
|
894
|
+
const normalizedTests = Array.isArray(tests)
|
|
895
|
+
? tests
|
|
896
|
+
.map(item => (typeof item === 'string' ? item : item?.path ?? item?.story))
|
|
897
|
+
.filter(item => typeof item === 'string')
|
|
898
|
+
: tests;
|
|
899
|
+
return captureSource(
|
|
900
|
+
root,
|
|
901
|
+
{ ...(normalizedTests !== undefined ? { tests: normalizedTests } : {}), ...options },
|
|
902
|
+
ports,
|
|
903
|
+
);
|
|
904
|
+
},
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
export const saved = Object.freeze({
|
|
908
|
+
results(input = {}, ports) {
|
|
909
|
+
return savedStoryEvidence(input, ports);
|
|
910
|
+
},
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
export const workspace = Object.freeze({
|
|
914
|
+
policy(input) {
|
|
915
|
+
return runtimeWorkspaceSlice().loadRuntimeWorkspace(input);
|
|
916
|
+
},
|
|
917
|
+
allows(policy, path) {
|
|
918
|
+
return runtimeWorkspaceSlice().allowsRuntimePath(policy, path);
|
|
919
|
+
},
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
export function render(result, { as = 'table' } = {}, ports) {
|
|
923
|
+
if (as === 'table') return renderText(result, ports);
|
|
924
|
+
if (as === 'json') return renderJson(result, ports);
|
|
925
|
+
if (as === 'story-lines') return storyLines(Array.isArray(result) ? result : result?.rows ?? [], ports);
|
|
926
|
+
if (as === 'summary') {
|
|
927
|
+
return summaryLine(
|
|
928
|
+
Array.isArray(result) ? result : result?.rows ?? [],
|
|
929
|
+
Array.isArray(result) ? null : result?.story ?? null,
|
|
930
|
+
ports,
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
throw new RangeError(`Unsupported render format: ${String(as)}`);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
export function version() {
|
|
937
|
+
return {
|
|
938
|
+
package: '@promptdriven/runtime-client',
|
|
939
|
+
api_version: 1,
|
|
940
|
+
formats: { scenario: TEST_SCHEMA, app_map: APP_MAP_SCHEMA },
|
|
941
|
+
limits: { ...LIMITS },
|
|
942
|
+
engine_sha: ENGINE_SHA,
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
export function failedCheckCount(...args) {
|
|
947
|
+
return runtimeOutcomeSlice().failedCheckCount(...args);
|
|
948
|
+
}
|
|
949
|
+
export function providerText(...args) {
|
|
950
|
+
return runtimeOutcomeSlice().providerText(...args);
|
|
951
|
+
}
|
|
952
|
+
export function estimateCheckCalls(...args) {
|
|
953
|
+
return runtimeCheckPlanSlice().estimateCheckCalls(...args);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
export function evaluateCheckBudget(...args) {
|
|
957
|
+
return runtimeCheckPlanSlice().evaluateCheckBudget(...args);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
export async function executeLocalCommand(input, ports) {
|
|
961
|
+
return (await import('./live-local.mjs')).executeLocalCommand(input, ports);
|
|
962
|
+
}
|
|
963
|
+
export function validateLocalManifest(manifest) {
|
|
964
|
+
return req('./live-local.mjs').validateLocalManifest(manifest);
|
|
965
|
+
}
|
|
966
|
+
export function compileLocalManifest(config, options) {
|
|
967
|
+
return req('./live-local.mjs').compileLocalManifest(config, options);
|
|
968
|
+
}
|
|
969
|
+
export function validateLocalRequest(manifest, request) {
|
|
970
|
+
return req('./live-local.mjs').validateLocalRequest(manifest, request);
|
|
971
|
+
}
|
|
972
|
+
export async function createLocalCommandBridge(input, ports) {
|
|
973
|
+
return (await import('./live-local-bridge.mjs')).createLocalCommandBridge(input, ports);
|
|
974
|
+
}
|