@interf/compiler 0.9.1 → 0.9.3
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/README.md +9 -9
- package/agent-skills/interf-actions/SKILL.md +3 -0
- package/agent-skills/interf-actions/references/cli.md +13 -13
- package/{builtin-workflows/interf → builtin-methods/interf-default}/README.md +2 -2
- package/builtin-methods/interf-default/improve/SKILL.md +18 -0
- package/{builtin-workflows/interf/workflow.json → builtin-methods/interf-default/method.json} +4 -4
- package/{builtin-workflows/interf/workflow.schema.json → builtin-methods/interf-default/method.schema.json} +2 -2
- package/dist/cli/commands/check-draft.d.ts +6 -6
- package/dist/cli/commands/check-draft.js +5 -5
- package/dist/cli/commands/compile-controller.d.ts +7 -7
- package/dist/cli/commands/compile-controller.js +35 -38
- package/dist/cli/commands/compile.d.ts +3 -3
- package/dist/cli/commands/compile.js +23 -21
- package/dist/cli/commands/compiled-flow.d.ts +11 -11
- package/dist/cli/commands/compiled-flow.js +33 -30
- package/dist/cli/commands/create-method-wizard.d.ts +76 -0
- package/dist/cli/commands/{create-workflow-wizard.js → create-method-wizard.js} +153 -163
- package/dist/cli/commands/create.d.ts +3 -3
- package/dist/cli/commands/create.js +44 -45
- package/dist/cli/commands/default.js +1 -1
- package/dist/cli/commands/executor-flow.d.ts +6 -6
- package/dist/cli/commands/executor-flow.js +1 -1
- package/dist/cli/commands/init.d.ts +2 -2
- package/dist/cli/commands/init.js +139 -118
- package/dist/cli/commands/list.js +11 -10
- package/dist/cli/commands/preparation-selection.d.ts +3 -3
- package/dist/cli/commands/source-config-wizard.d.ts +9 -9
- package/dist/cli/commands/source-config-wizard.js +43 -43
- package/dist/cli/commands/status.js +36 -9
- package/dist/cli/commands/test-flow.d.ts +15 -15
- package/dist/cli/commands/test-flow.js +29 -219
- package/dist/cli/commands/test.d.ts +2 -2
- package/dist/cli/commands/test.js +50 -51
- package/dist/cli/commands/verify.js +7 -7
- package/dist/cli/commands/web.js +41 -28
- package/dist/compiler-ui/404.html +1 -0
- package/dist/compiler-ui/__next.__PAGE__.txt +10 -0
- package/dist/compiler-ui/__next._full.txt +20 -0
- package/dist/compiler-ui/__next._head.txt +5 -0
- package/dist/compiler-ui/__next._index.txt +5 -0
- package/dist/compiler-ui/__next._tree.txt +5 -0
- package/dist/compiler-ui/_next/static/chunks/06yhdspx~ca5-.js +5 -0
- package/{apps/compiler-ui/.next/static/chunks/13g~4mamjft.c.css → dist/compiler-ui/_next/static/chunks/0c9mu7yldxyyg.css} +1 -1
- package/{apps/compiler-ui/.next/static/chunks/0fgt_8knmicoz.js → dist/compiler-ui/_next/static/chunks/15mks7ry_cupt.js} +15 -21
- package/{apps/compiler-ui/.next/static/chunks/turbopack-109rtik40vwh5.js → dist/compiler-ui/_next/static/chunks/turbopack-0.uq1k8c0j4s..js} +1 -1
- package/dist/compiler-ui/_not-found/__next._full.txt +15 -0
- package/dist/compiler-ui/_not-found/__next._head.txt +5 -0
- package/dist/compiler-ui/_not-found/__next._index.txt +5 -0
- package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +5 -0
- package/dist/compiler-ui/_not-found/__next._not-found.txt +5 -0
- package/dist/compiler-ui/_not-found/__next._tree.txt +2 -0
- package/dist/compiler-ui/_not-found.html +1 -0
- package/dist/compiler-ui/_not-found.txt +15 -0
- package/{apps/compiler-ui/.next/server/app → dist/compiler-ui}/index.html +1 -1
- package/dist/compiler-ui/index.txt +20 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.js +5 -3
- package/dist/packages/agents/index.d.ts +1 -1
- package/dist/packages/agents/lib/args.d.ts +2 -2
- package/dist/packages/agents/lib/compiled-bootstrap.js +7 -6
- package/dist/packages/agents/lib/execution-profile.d.ts +5 -5
- package/dist/packages/agents/lib/execution-profile.js +7 -6
- package/dist/packages/agents/lib/executors.d.ts +13 -13
- package/dist/packages/agents/lib/preflight.d.ts +1 -0
- package/dist/packages/agents/lib/preflight.js +32 -9
- package/dist/packages/agents/lib/shells.d.ts +25 -24
- package/dist/packages/agents/lib/shells.js +161 -154
- package/dist/packages/agents/lib/types.d.ts +2 -2
- package/dist/packages/compiler/artifact-counts.d.ts +1 -0
- package/dist/packages/compiler/artifact-counts.js +30 -0
- package/dist/packages/compiler/compiled-paths.d.ts +4 -7
- package/dist/packages/compiler/compiled-paths.js +9 -15
- package/dist/packages/compiler/compiled-pipeline.d.ts +11 -12
- package/dist/packages/compiler/compiled-pipeline.js +22 -22
- package/dist/packages/compiler/compiled-schema.d.ts +20 -20
- package/dist/packages/compiler/compiled-schema.js +29 -29
- package/dist/packages/compiler/compiled-stage-plan.d.ts +4 -4
- package/dist/packages/compiler/compiled-stage-plan.js +8 -8
- package/dist/packages/compiler/compiled-stage-runner.d.ts +5 -5
- package/dist/packages/compiler/compiled-stage-runner.js +7 -7
- package/dist/packages/compiler/compiled-target.d.ts +5 -5
- package/dist/packages/compiler/compiled-target.js +5 -5
- package/dist/packages/compiler/index.d.ts +3 -3
- package/dist/packages/compiler/index.js +2 -2
- package/dist/packages/compiler/lib/schema.d.ts +62 -247
- package/dist/packages/compiler/lib/schema.js +56 -174
- package/dist/packages/compiler/{workflows.d.ts → method-runs.d.ts} +4 -4
- package/dist/packages/compiler/{workflows.js → method-runs.js} +4 -3
- package/dist/packages/compiler/raw-snapshot.d.ts +0 -7
- package/dist/packages/compiler/raw-snapshot.js +0 -1
- package/dist/packages/compiler/reset.js +3 -3
- package/dist/packages/compiler/runtime-acceptance.js +9 -16
- package/dist/packages/compiler/runtime-contracts.js +9 -9
- package/dist/packages/compiler/runtime-prompt.js +4 -4
- package/dist/packages/compiler/runtime-reconcile.d.ts +2 -2
- package/dist/packages/compiler/runtime-reconcile.js +3 -3
- package/dist/packages/compiler/runtime-runs.js +9 -9
- package/dist/packages/compiler/runtime-types.d.ts +8 -7
- package/dist/packages/compiler/state-health.js +26 -35
- package/dist/packages/compiler/state-view.js +6 -6
- package/dist/packages/compiler/validate-compiled.d.ts +5 -5
- package/dist/packages/compiler/validate-compiled.js +56 -64
- package/dist/packages/compiler/validate.d.ts +2 -2
- package/dist/packages/compiler/validate.js +22 -14
- package/dist/packages/contracts/index.d.ts +2 -0
- package/dist/packages/contracts/index.js +1 -0
- package/dist/packages/contracts/lib/schema.d.ts +205 -0
- package/dist/packages/contracts/lib/schema.js +101 -0
- package/dist/packages/execution/index.d.ts +2 -2
- package/dist/packages/execution/index.js +1 -1
- package/dist/packages/execution/lib/schema.d.ts +80 -83
- package/dist/packages/execution/lib/schema.js +25 -48
- package/dist/packages/local-service/action-values.d.ts +0 -1
- package/dist/packages/local-service/action-values.js +0 -1
- package/dist/packages/local-service/client.d.ts +4 -4
- package/dist/packages/local-service/client.js +4 -4
- package/dist/packages/local-service/index.d.ts +3 -3
- package/dist/packages/local-service/index.js +2 -2
- package/dist/packages/local-service/lib/schema.d.ts +536 -974
- package/dist/packages/local-service/lib/schema.js +43 -160
- package/dist/packages/local-service/run-observability.d.ts +6 -0
- package/dist/packages/local-service/run-observability.js +592 -0
- package/dist/packages/local-service/runtime.d.ts +19 -23
- package/dist/packages/local-service/runtime.js +302 -880
- package/dist/packages/local-service/server.d.ts +1 -0
- package/dist/packages/local-service/server.js +25 -20
- package/dist/packages/method-authoring/index.d.ts +4 -0
- package/dist/packages/method-authoring/index.js +4 -0
- package/dist/packages/{workflow-authoring/lib/workflow-edit-utils.d.ts → method-authoring/lib/method-edit-utils.d.ts} +3 -3
- package/dist/packages/method-authoring/method-authoring.d.ts +24 -0
- package/dist/packages/method-authoring/method-authoring.js +116 -0
- package/dist/packages/method-authoring/method-edit-session.d.ts +18 -0
- package/dist/packages/method-authoring/method-edit-session.js +125 -0
- package/dist/packages/method-authoring/method-improvement.d.ts +23 -0
- package/dist/packages/{workflow-authoring/workflow-improvement.js → method-authoring/method-improvement.js} +63 -63
- package/dist/packages/{workflow-package/builtin-compiled-workflow.d.ts → method-package/builtin-compiled-method.d.ts} +1 -1
- package/dist/packages/{workflow-package/builtin-compiled-workflow.js → method-package/builtin-compiled-method.js} +17 -17
- package/dist/packages/{workflow-package → method-package}/context-interface.d.ts +12 -12
- package/dist/packages/{workflow-package → method-package}/context-interface.js +19 -19
- package/dist/packages/method-package/index.d.ts +11 -0
- package/dist/packages/method-package/index.js +11 -0
- package/dist/packages/method-package/interf-method-package.d.ts +31 -0
- package/dist/packages/{workflow-package/interf-workflow-package.js → method-package/interf-method-package.js} +145 -145
- package/dist/packages/{workflow-package → method-package}/lib/package-root.js +1 -1
- package/dist/packages/method-package/local-methods.d.ts +64 -0
- package/dist/packages/method-package/local-methods.js +466 -0
- package/dist/packages/method-package/method-definitions.d.ts +83 -0
- package/dist/packages/method-package/method-definitions.js +205 -0
- package/dist/packages/{workflow-package/workflow-helpers.d.ts → method-package/method-helpers.d.ts} +10 -10
- package/dist/packages/{workflow-package/workflow-helpers.js → method-package/method-helpers.js} +22 -26
- package/dist/packages/method-package/method-review-paths.d.ts +10 -0
- package/dist/packages/{workflow-package/workflow-review-paths.js → method-package/method-review-paths.js} +4 -4
- package/dist/packages/{workflow-package/workflow-stage-runner.d.ts → method-package/method-stage-runner.d.ts} +12 -11
- package/dist/packages/{workflow-package/workflow-stage-runner.js → method-package/method-stage-runner.js} +6 -6
- package/dist/packages/methods/index.d.ts +2 -0
- package/dist/packages/methods/index.js +2 -0
- package/dist/packages/methods/method-resolution.d.ts +6 -0
- package/dist/packages/methods/method-resolution.js +7 -0
- package/dist/packages/project-model/index.d.ts +1 -4
- package/dist/packages/project-model/index.js +0 -3
- package/dist/packages/project-model/interf-detect.d.ts +1 -5
- package/dist/packages/project-model/interf-detect.js +7 -18
- package/dist/packages/project-model/interf-scaffold.d.ts +2 -2
- package/dist/packages/project-model/interf-scaffold.js +38 -39
- package/dist/packages/project-model/interf.d.ts +1 -2
- package/dist/packages/project-model/interf.js +1 -2
- package/dist/packages/project-model/lib/schema.d.ts +2 -66
- package/dist/packages/project-model/lib/schema.js +5 -23
- package/dist/packages/project-model/project-paths.d.ts +9 -10
- package/dist/packages/project-model/project-paths.js +14 -17
- package/dist/packages/project-model/source-config.d.ts +11 -18
- package/dist/packages/project-model/source-config.js +42 -60
- package/dist/packages/project-model/source-folders.d.ts +4 -4
- package/dist/packages/project-model/source-folders.js +10 -10
- package/dist/packages/testing/index.d.ts +2 -2
- package/dist/packages/testing/index.js +1 -1
- package/dist/packages/testing/lib/schema.d.ts +11 -11
- package/dist/packages/testing/lib/schema.js +8 -9
- package/dist/packages/testing/readiness-check-run.d.ts +67 -0
- package/dist/packages/testing/readiness-check-run.js +258 -0
- package/dist/packages/testing/test-execution.d.ts +3 -3
- package/dist/packages/testing/test-execution.js +5 -5
- package/dist/packages/testing/test-paths.js +6 -6
- package/dist/packages/testing/test-profile-presets.js +2 -2
- package/dist/packages/testing/test-sandbox.js +10 -11
- package/dist/packages/testing/test-targets.d.ts +1 -1
- package/dist/packages/testing/test-targets.js +8 -7
- package/dist/packages/testing/test-types.d.ts +1 -1
- package/package.json +16 -33
- package/apps/compiler-ui/.next/static/chunks/0ti_66mx7~w2-.js +0 -5
- package/builtin-workflows/interf/improve/SKILL.md +0 -18
- package/dist/cli/commands/create-workflow-wizard.d.ts +0 -76
- package/dist/packages/project-model/compiled-paths.d.ts +0 -1
- package/dist/packages/project-model/compiled-paths.js +0 -1
- package/dist/packages/project-model/compiled-raw.d.ts +0 -1
- package/dist/packages/project-model/compiled-raw.js +0 -1
- package/dist/packages/project-model/compiled-reset.d.ts +0 -1
- package/dist/packages/project-model/compiled-reset.js +0 -1
- package/dist/packages/shared/index.d.ts +0 -7
- package/dist/packages/shared/index.js +0 -7
- package/dist/packages/shared/util.d.ts +0 -3
- package/dist/packages/shared/util.js +0 -3
- package/dist/packages/testing/test-matrices.d.ts +0 -90
- package/dist/packages/testing/test-matrices.js +0 -96
- package/dist/packages/workflow-authoring/index.d.ts +0 -4
- package/dist/packages/workflow-authoring/index.js +0 -4
- package/dist/packages/workflow-authoring/workflow-authoring.d.ts +0 -24
- package/dist/packages/workflow-authoring/workflow-authoring.js +0 -82
- package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +0 -18
- package/dist/packages/workflow-authoring/workflow-edit-session.js +0 -91
- package/dist/packages/workflow-authoring/workflow-improvement.d.ts +0 -23
- package/dist/packages/workflow-package/index.d.ts +0 -11
- package/dist/packages/workflow-package/index.js +0 -11
- package/dist/packages/workflow-package/interf-workflow-package.d.ts +0 -31
- package/dist/packages/workflow-package/local-workflows.d.ts +0 -64
- package/dist/packages/workflow-package/local-workflows.js +0 -457
- package/dist/packages/workflow-package/workflow-definitions.d.ts +0 -82
- package/dist/packages/workflow-package/workflow-definitions.js +0 -211
- package/dist/packages/workflow-package/workflow-review-paths.d.ts +0 -10
- /package/{builtin-workflows/interf → builtin-methods/interf-default}/compile/stages/shape/SKILL.md +0 -0
- /package/{builtin-workflows/interf → builtin-methods/interf-default}/compile/stages/structure/SKILL.md +0 -0
- /package/{builtin-workflows/interf → builtin-methods/interf-default}/compile/stages/summarize/SKILL.md +0 -0
- /package/{builtin-workflows/interf → builtin-methods/interf-default}/use/query/SKILL.md +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/03~yq9q893hmn.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/06z~l3kwb891e.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/08g7lvje.te.u.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/08m7vf5asqlsm.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0_i-3_5l9t2qe.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0b-ywny_j0g~0.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0b52v41o1gixx.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0gpzgsv0w.q~m.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0ilwfezfvu6~-.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0n51hrfoufc7g.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0xxmf45eskdt~.css +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/0y5z3t-z1c8ks.js.map +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/14wtz~vq25~qq.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/turbopack-10e~t1yzi4svj.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/chunks/turbopack-worker-0sjn--fhq~1cg.js +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/media/GeistMono_Variable.p.17jn9btb_52pq.woff2 +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/media/Geist_Variable-s.p.0-te~ja_gpvcf.woff2 +0 -0
- /package/{apps/compiler-ui/.next → dist/compiler-ui/_next}/static/media/worker.102zas1s52_pf.js +0 -0
- /package/{apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J → dist/compiler-ui/_next/static/pIZnDsV3Je6hdC3cOsGdK}/_buildManifest.js +0 -0
- /package/{apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J → dist/compiler-ui/_next/static/pIZnDsV3Je6hdC3cOsGdK}/_clientMiddlewareManifest.js +0 -0
- /package/{apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J → dist/compiler-ui/_next/static/pIZnDsV3Je6hdC3cOsGdK}/_ssgManifest.js +0 -0
- /package/dist/packages/compiler/{workflow-primitives.d.ts → method-primitives.d.ts} +0 -0
- /package/dist/packages/compiler/{workflow-primitives.js → method-primitives.js} +0 -0
- /package/dist/packages/{workflow-authoring/lib/workflow-edit-utils.js → method-authoring/lib/method-edit-utils.js} +0 -0
- /package/dist/packages/{workflow-package → method-package}/lib/package-root.d.ts +0 -0
- /package/dist/packages/{workflow-package/workflow-stage-policy.d.ts → method-package/method-stage-policy.d.ts} +0 -0
- /package/dist/packages/{workflow-package/workflow-stage-policy.js → method-package/method-stage-policy.js} +0 -0
|
@@ -4,22 +4,24 @@ import { CompileRunSchema, } from "../execution/lib/schema.js";
|
|
|
4
4
|
import { createRunEventId, createRunEventTimestamp, } from "../execution/events.js";
|
|
5
5
|
import { compiledRuntimeRunHistoryPath, compiledRuntimeRoot, testRootForCompiled, } from "../compiler/compiled-paths.js";
|
|
6
6
|
import { loadState, } from "../compiler/state.js";
|
|
7
|
-
import {
|
|
7
|
+
import { RuntimeRunSchema, } from "../compiler/lib/schema.js";
|
|
8
|
+
import { ReadinessStateSchema, } from "../contracts/lib/schema.js";
|
|
8
9
|
import { discoverSourceFiles, } from "../compiler/discovery.js";
|
|
9
10
|
import { ensurePortableContextScaffold, readInterfConfig, } from "../project-model/interf.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { findSourcePreparationConfig, fingerprintReadinessChecks, listSourcePreparationConfigs, loadSourceFolderConfig, DEFAULT_METHOD_ID, methodIdForSourcePreparationConfig, resolveConfiguredSourceFolderPath, resolveSourcePreparationPath, syncCompiledInterfConfigFromSourcePreparationConfig, upsertSourcePreparationConfig, } from "../project-model/source-config.js";
|
|
12
|
+
import { defaultPreparationNameForPath, listSourceFolderChoices, normalizeSourcePreparationPathForConfig, } from "../project-model/source-folders.js";
|
|
13
|
+
import { portableContextPath, } from "../project-model/project-paths.js";
|
|
14
|
+
import { getCompiledMethod, listCompiledMethodChoices, } from "../method-package/method-definitions.js";
|
|
15
|
+
import { resolveMethodPackageSourcePath, } from "../method-package/local-methods.js";
|
|
15
16
|
import { resolveAgent, detectAgents, supportsAutomatedRuns, } from "../agents/lib/detection.js";
|
|
16
17
|
import { AGENTS, } from "../agents/lib/constants.js";
|
|
17
18
|
import { loadUserConfig, saveUserConfig, } from "../agents/lib/user-config.js";
|
|
18
|
-
import {
|
|
19
|
+
import { readSavedReadinessCheckRun, } from "../testing/readiness-check-run.js";
|
|
19
20
|
import { createCompiledTestTarget, } from "../testing/test-targets.js";
|
|
20
|
-
import { ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalPlanSchema, ActionProposalResourceSchema, CompileRunCreateRequestSchema, CompileRunResourceSchema,
|
|
21
|
+
import { ActionProposalApprovalRequestSchema, ActionProposalCreateRequestSchema, ActionProposalPlanSchema, ActionProposalResourceSchema, CompileRunCreateRequestSchema, CompileRunResourceSchema, MethodResourceSchema, LocalExecutorStatusSchema, LocalExecutorSelectRequestSchema, LocalServiceHealthSchema, PreparationReadinessStateSchema, LocalRunHandlerResultSchema, LocalJobEventAppendRequestSchema, LocalJobRunCreateRequestSchema, LocalJobRunResourceSchema, SourceFileResourceSchema, WorkspaceFileResourceSchema, PortableContextResourceSchema, PreparationSetupCreateRequestSchema, PreparationResourceSchema, ReadinessCheckDraftCreateRequestSchema, ReadinessCheckDraftResultSchema, TestRunCreateRequestSchema, TestRunResourceSchema, MethodAuthoringCreateRequestSchema, MethodAuthoringResultSchema, } from "./lib/schema.js";
|
|
21
22
|
import { buildLocalServiceUrl, } from "./routes.js";
|
|
22
23
|
import { methodAuthoringTaskPrompt, MethodAuthoringActionValuesSchema, PreparationSetupActionValuesSchema, } from "./action-values.js";
|
|
24
|
+
import { compileRunToObservability, jobRunToObservability, testRunToObservability, uniqueArtifacts, } from "./run-observability.js";
|
|
23
25
|
function createRunId(prefix) {
|
|
24
26
|
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
25
27
|
}
|
|
@@ -39,6 +41,22 @@ function writeJsonFile(filePath, value) {
|
|
|
39
41
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
40
42
|
writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
41
43
|
}
|
|
44
|
+
function sanitizeActionProposalPlan(value) {
|
|
45
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
46
|
+
return value;
|
|
47
|
+
const plan = { ...value };
|
|
48
|
+
for (const key of ["preparation", "method", "title", "summary", "assistant_message", "command_preview"]) {
|
|
49
|
+
const current = plan[key];
|
|
50
|
+
if (current === null || current === undefined) {
|
|
51
|
+
delete plan[key];
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (typeof current === "string" && current.trim().length === 0) {
|
|
55
|
+
delete plan[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return plan;
|
|
59
|
+
}
|
|
42
60
|
function compileRunsRoot(compiledPath) {
|
|
43
61
|
return join(compiledRuntimeRoot(compiledPath), "compile-runs");
|
|
44
62
|
}
|
|
@@ -152,110 +170,6 @@ function detectedExecutorOptions(currentAgentName) {
|
|
|
152
170
|
current: agent.name === currentAgentName,
|
|
153
171
|
}));
|
|
154
172
|
}
|
|
155
|
-
function uniqueArtifacts(artifacts) {
|
|
156
|
-
const seen = new Set();
|
|
157
|
-
const result = [];
|
|
158
|
-
for (const artifact of artifacts) {
|
|
159
|
-
const key = `${artifact.role}:${artifact.stage_id ?? ""}:${artifact.path}`;
|
|
160
|
-
if (seen.has(key))
|
|
161
|
-
continue;
|
|
162
|
-
seen.add(key);
|
|
163
|
-
result.push(artifact);
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
function observableRunStatus(status) {
|
|
168
|
-
if (status === "queued" || status === "pending")
|
|
169
|
-
return "queued";
|
|
170
|
-
if (status === "running")
|
|
171
|
-
return "running";
|
|
172
|
-
if (status === "failed")
|
|
173
|
-
return "failed";
|
|
174
|
-
if (status === "cancelled")
|
|
175
|
-
return "cancelled";
|
|
176
|
-
return "succeeded";
|
|
177
|
-
}
|
|
178
|
-
function workflowTraceRunStatus(status) {
|
|
179
|
-
if (status === "queued" || status === "pending")
|
|
180
|
-
return "pending";
|
|
181
|
-
if (status === "running")
|
|
182
|
-
return "running";
|
|
183
|
-
if (status === "failed")
|
|
184
|
-
return "failed";
|
|
185
|
-
if (status === "cancelled")
|
|
186
|
-
return "cancelled";
|
|
187
|
-
return "completed";
|
|
188
|
-
}
|
|
189
|
-
function safeWorkflowNamePart(value) {
|
|
190
|
-
return value
|
|
191
|
-
.replace(/[^a-zA-Z0-9._/-]+/g, "-")
|
|
192
|
-
.replace(/\/+/g, "/")
|
|
193
|
-
.replace(/^-+|-+$/g, "")
|
|
194
|
-
|| "run";
|
|
195
|
-
}
|
|
196
|
-
function workflowTraceName(runType, name) {
|
|
197
|
-
return `workflow//./interf/${runType}//${safeWorkflowNamePart(name)}`;
|
|
198
|
-
}
|
|
199
|
-
function workflowStepName(runType, label) {
|
|
200
|
-
return `step//./interf/${runType}//${safeWorkflowNamePart(label)}`;
|
|
201
|
-
}
|
|
202
|
-
function structuredWorkflowError(message) {
|
|
203
|
-
return {
|
|
204
|
-
message: message || "Run failed.",
|
|
205
|
-
code: "INTERF_RUN_ERROR",
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function traceEvent(runId, eventType, createdAt, index, eventData, correlationId) {
|
|
209
|
-
return {
|
|
210
|
-
runId,
|
|
211
|
-
eventId: `${runId}:event:${index}`,
|
|
212
|
-
eventType,
|
|
213
|
-
specVersion: 1,
|
|
214
|
-
createdAt: createdAt ?? createRunEventTimestamp(),
|
|
215
|
-
...(correlationId ? { correlationId } : {}),
|
|
216
|
-
...(eventData === undefined ? {} : { eventData }),
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
function traceStreamChunk(runId, index, createdAt, text, data) {
|
|
220
|
-
return {
|
|
221
|
-
streamId: `${runId}:events`,
|
|
222
|
-
chunkId: `${runId}:events:${index}`,
|
|
223
|
-
index,
|
|
224
|
-
createdAt: createdAt ?? createRunEventTimestamp(),
|
|
225
|
-
text,
|
|
226
|
-
...(data === undefined ? {} : { data }),
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
function buildTraceStreamChunks(runId, events) {
|
|
230
|
-
return events.map((event, index) => traceStreamChunk(runId, index, event.timestamp, JSON.stringify({
|
|
231
|
-
time: event.timestamp ?? null,
|
|
232
|
-
type: event.type,
|
|
233
|
-
scope: event.stage_id ?? event.step_id ?? event.type,
|
|
234
|
-
message: event.message ?? event.summary ?? event.error ?? event.type,
|
|
235
|
-
}), event));
|
|
236
|
-
}
|
|
237
|
-
function proofChecksForCompileRun(run) {
|
|
238
|
-
return run.stages.flatMap((stage) => (stage.latest_proof?.checks ?? []).map((check) => ({
|
|
239
|
-
...check,
|
|
240
|
-
detail: check.detail ?? `${stage.stage_label ?? stage.stage_id} / ${stage.status}`,
|
|
241
|
-
})));
|
|
242
|
-
}
|
|
243
|
-
function agentLabelForJob(job) {
|
|
244
|
-
return job.agent?.display_name ?? job.agent?.name ?? null;
|
|
245
|
-
}
|
|
246
|
-
function jobTypeLabelForMetric(type) {
|
|
247
|
-
if (type === "readiness-check-draft")
|
|
248
|
-
return "Readiness-check draft";
|
|
249
|
-
if (type === "method-authoring")
|
|
250
|
-
return "Method draft";
|
|
251
|
-
if (type === "method-improvement")
|
|
252
|
-
return "Method improvement";
|
|
253
|
-
if (type === "compile")
|
|
254
|
-
return "Compile";
|
|
255
|
-
if (type === "test")
|
|
256
|
-
return "Readiness check";
|
|
257
|
-
return "Local job";
|
|
258
|
-
}
|
|
259
173
|
function stageArtifactRefs(stageId, artifacts) {
|
|
260
174
|
return (artifacts ?? []).map((path) => ({
|
|
261
175
|
path,
|
|
@@ -314,15 +228,6 @@ function logsForRuntimeRun(run) {
|
|
|
314
228
|
contract_path: run.contract_path,
|
|
315
229
|
};
|
|
316
230
|
}
|
|
317
|
-
function stageTracePayload(stage) {
|
|
318
|
-
return {
|
|
319
|
-
status: stage.status,
|
|
320
|
-
...(stage.summary ? { summary: stage.summary } : {}),
|
|
321
|
-
...(stage.artifacts.length > 0 ? { artifacts: stage.artifacts } : {}),
|
|
322
|
-
...(stage.logs ? { logs: stage.logs } : {}),
|
|
323
|
-
...(stage.latest_proof ? { proof: stage.latest_proof } : {}),
|
|
324
|
-
};
|
|
325
|
-
}
|
|
326
231
|
function timestampKey(value) {
|
|
327
232
|
const parsed = Date.parse(value ?? "");
|
|
328
233
|
return Number.isFinite(parsed) ? parsed : 0;
|
|
@@ -495,481 +400,6 @@ function applyEventToLocalJob(run, event) {
|
|
|
495
400
|
events: [...run.events, event],
|
|
496
401
|
};
|
|
497
402
|
}
|
|
498
|
-
function compileRunToObservability(run) {
|
|
499
|
-
const artifacts = uniqueArtifacts(run.stages.flatMap((stage) => stage.artifacts));
|
|
500
|
-
const proof = proofChecksForCompileRun(run);
|
|
501
|
-
const executor = run.stages.find((stage) => stage.executor)?.executor ?? null;
|
|
502
|
-
const traceStatus = workflowTraceRunStatus(run.status);
|
|
503
|
-
const workflowName = workflowTraceName("compile", run.method);
|
|
504
|
-
const completedAt = run.finished_at ?? (traceStatus === "completed" || traceStatus === "failed" || traceStatus === "cancelled"
|
|
505
|
-
? run.started_at ?? run.created_at
|
|
506
|
-
: undefined);
|
|
507
|
-
let eventIndex = 0;
|
|
508
|
-
const events = [
|
|
509
|
-
traceEvent(run.run_id, "run_created", run.created_at, eventIndex++, {
|
|
510
|
-
deploymentId: "local-interf",
|
|
511
|
-
workflowName,
|
|
512
|
-
input: {
|
|
513
|
-
kind: "compile",
|
|
514
|
-
preparation: run.preparation,
|
|
515
|
-
method: run.method,
|
|
516
|
-
source_path: run.source_path,
|
|
517
|
-
},
|
|
518
|
-
executionContext: {
|
|
519
|
-
backend: run.backend,
|
|
520
|
-
executor,
|
|
521
|
-
},
|
|
522
|
-
}),
|
|
523
|
-
];
|
|
524
|
-
if (run.started_at) {
|
|
525
|
-
events.push(traceEvent(run.run_id, "run_started", run.started_at, eventIndex++, {
|
|
526
|
-
workflowName,
|
|
527
|
-
input: {
|
|
528
|
-
preparation: run.preparation,
|
|
529
|
-
method: run.method,
|
|
530
|
-
},
|
|
531
|
-
executionContext: {
|
|
532
|
-
backend: run.backend,
|
|
533
|
-
executor,
|
|
534
|
-
},
|
|
535
|
-
}));
|
|
536
|
-
}
|
|
537
|
-
for (const stage of run.stages) {
|
|
538
|
-
const stepName = workflowStepName("compile", stage.stage_label ?? stage.stage_id);
|
|
539
|
-
const stepCreatedAt = stage.started_at ?? run.started_at ?? run.created_at;
|
|
540
|
-
events.push(traceEvent(run.run_id, "step_created", stepCreatedAt, eventIndex++, {
|
|
541
|
-
stepName,
|
|
542
|
-
input: {
|
|
543
|
-
stage_id: stage.stage_id,
|
|
544
|
-
stage_label: stage.stage_label ?? null,
|
|
545
|
-
stage_index: stage.stage_index ?? null,
|
|
546
|
-
stage_total: stage.stage_total ?? null,
|
|
547
|
-
reads: stage.contract?.reads ?? [],
|
|
548
|
-
writes: stage.contract?.writes ?? [],
|
|
549
|
-
acceptance: stage.contract?.acceptance ?? null,
|
|
550
|
-
executor: stage.executor ?? null,
|
|
551
|
-
},
|
|
552
|
-
}, stage.stage_id));
|
|
553
|
-
if (stage.started_at || stage.status !== "queued") {
|
|
554
|
-
events.push(traceEvent(run.run_id, "step_started", stage.started_at ?? stepCreatedAt, eventIndex++, {
|
|
555
|
-
attempt: 1,
|
|
556
|
-
}, stage.stage_id));
|
|
557
|
-
}
|
|
558
|
-
if (stage.status === "failed") {
|
|
559
|
-
events.push(traceEvent(run.run_id, "step_failed", stage.finished_at ?? run.finished_at ?? stepCreatedAt, eventIndex++, {
|
|
560
|
-
error: structuredWorkflowError(stage.failure ?? stage.summary),
|
|
561
|
-
output: stageTracePayload(stage),
|
|
562
|
-
}, stage.stage_id));
|
|
563
|
-
}
|
|
564
|
-
else if (stage.status === "succeeded" || stage.status === "skipped") {
|
|
565
|
-
events.push(traceEvent(run.run_id, "step_completed", stage.finished_at ?? run.finished_at ?? stepCreatedAt, eventIndex++, {
|
|
566
|
-
result: stageTracePayload(stage),
|
|
567
|
-
}, stage.stage_id));
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
if (traceStatus === "completed") {
|
|
571
|
-
events.push(traceEvent(run.run_id, "run_completed", completedAt, eventIndex++, {
|
|
572
|
-
output: {
|
|
573
|
-
portable_context_path: run.portable_context_path,
|
|
574
|
-
artifacts,
|
|
575
|
-
proof,
|
|
576
|
-
latest_proof: run.latest_proof ?? null,
|
|
577
|
-
},
|
|
578
|
-
}));
|
|
579
|
-
}
|
|
580
|
-
else if (traceStatus === "failed") {
|
|
581
|
-
events.push(traceEvent(run.run_id, "run_failed", completedAt, eventIndex++, {
|
|
582
|
-
error: structuredWorkflowError(run.stages.find((stage) => stage.failure)?.failure ?? run.latest_proof?.summary),
|
|
583
|
-
}));
|
|
584
|
-
}
|
|
585
|
-
else if (traceStatus === "cancelled") {
|
|
586
|
-
events.push(traceEvent(run.run_id, "run_cancelled", completedAt, eventIndex++));
|
|
587
|
-
}
|
|
588
|
-
return RunObservabilityResourceSchema.parse({
|
|
589
|
-
kind: "interf-run-observability",
|
|
590
|
-
version: 1,
|
|
591
|
-
run_id: run.run_id,
|
|
592
|
-
run_type: "compile",
|
|
593
|
-
title: `Prepare ${run.preparation}`,
|
|
594
|
-
status: observableRunStatus(run.status),
|
|
595
|
-
preparation: run.preparation,
|
|
596
|
-
method: run.method,
|
|
597
|
-
source_path: run.source_path,
|
|
598
|
-
output_path: run.portable_context_path,
|
|
599
|
-
executor,
|
|
600
|
-
agent_label: executor?.display_name ?? run.backend,
|
|
601
|
-
created_at: run.created_at,
|
|
602
|
-
started_at: run.started_at ?? null,
|
|
603
|
-
finished_at: run.finished_at ?? null,
|
|
604
|
-
metrics: [
|
|
605
|
-
{ label: "Preparation", value: run.preparation },
|
|
606
|
-
{ label: "Method", value: run.method },
|
|
607
|
-
{ label: "Executor", value: executor?.display_name ?? run.backend },
|
|
608
|
-
{ label: "Stages", value: `${run.stages.filter((stage) => stage.status === "succeeded").length}/${run.stages.length}` },
|
|
609
|
-
{ label: "Proof", value: `${proof.filter((check) => check.ok).length}/${proof.length}` },
|
|
610
|
-
{ label: "Artifacts", value: String(artifacts.length) },
|
|
611
|
-
],
|
|
612
|
-
artifacts,
|
|
613
|
-
proof,
|
|
614
|
-
trace: {
|
|
615
|
-
run: {
|
|
616
|
-
runId: run.run_id,
|
|
617
|
-
status: traceStatus,
|
|
618
|
-
deploymentId: "local-interf",
|
|
619
|
-
workflowName,
|
|
620
|
-
specVersion: 1,
|
|
621
|
-
executionContext: {
|
|
622
|
-
product: "Interf",
|
|
623
|
-
run_type: "compile",
|
|
624
|
-
preparation: run.preparation,
|
|
625
|
-
method: run.method,
|
|
626
|
-
backend: run.backend,
|
|
627
|
-
executor,
|
|
628
|
-
},
|
|
629
|
-
input: {
|
|
630
|
-
preparation: run.preparation,
|
|
631
|
-
method: run.method,
|
|
632
|
-
source_path: run.source_path,
|
|
633
|
-
},
|
|
634
|
-
...(traceStatus === "completed"
|
|
635
|
-
? {
|
|
636
|
-
output: {
|
|
637
|
-
portable_context_path: run.portable_context_path,
|
|
638
|
-
artifacts,
|
|
639
|
-
proof,
|
|
640
|
-
},
|
|
641
|
-
}
|
|
642
|
-
: {}),
|
|
643
|
-
...(traceStatus === "failed" ? { error: structuredWorkflowError(run.stages.find((stage) => stage.failure)?.failure) } : {}),
|
|
644
|
-
...(run.started_at ? { startedAt: run.started_at } : {}),
|
|
645
|
-
...(completedAt ? { completedAt } : {}),
|
|
646
|
-
createdAt: run.created_at,
|
|
647
|
-
updatedAt: completedAt ?? run.started_at ?? run.created_at,
|
|
648
|
-
},
|
|
649
|
-
events,
|
|
650
|
-
streams: buildTraceStreamChunks(run.run_id, run.events),
|
|
651
|
-
},
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
function testRunToObservability(run) {
|
|
655
|
-
const traceStatus = workflowTraceRunStatus(run.status);
|
|
656
|
-
const title = `Check readiness ${run.preparation}`;
|
|
657
|
-
const workflowName = workflowTraceName("test", title);
|
|
658
|
-
const completedAt = run.finished_at ?? (traceStatus === "completed" || traceStatus === "failed" || traceStatus === "cancelled"
|
|
659
|
-
? run.started_at ?? new Date().toISOString()
|
|
660
|
-
: undefined);
|
|
661
|
-
const raw = run.comparison?.raw ?? null;
|
|
662
|
-
const compiled = run.comparison?.compiled ?? null;
|
|
663
|
-
const proofCandidates = [
|
|
664
|
-
raw
|
|
665
|
-
? {
|
|
666
|
-
id: `${run.run_id}-source-files`,
|
|
667
|
-
label: "source files baseline",
|
|
668
|
-
ok: raw.ok ?? raw.passed_cases === raw.total_cases,
|
|
669
|
-
detail: `${raw.passed_cases}/${raw.total_cases} checks`,
|
|
670
|
-
}
|
|
671
|
-
: null,
|
|
672
|
-
compiled
|
|
673
|
-
? {
|
|
674
|
-
id: `${run.run_id}-portable-context`,
|
|
675
|
-
label: "portable context",
|
|
676
|
-
ok: compiled.ok ?? compiled.passed_cases === compiled.total_cases,
|
|
677
|
-
detail: `${compiled.passed_cases}/${compiled.total_cases} checks`,
|
|
678
|
-
}
|
|
679
|
-
: null,
|
|
680
|
-
];
|
|
681
|
-
const proof = proofCandidates.filter((value) => value !== null);
|
|
682
|
-
const artifacts = uniqueArtifacts([
|
|
683
|
-
...(raw?.run_path ? [{ path: raw.run_path, role: "test", label: "source files readiness run" }] : []),
|
|
684
|
-
...(compiled?.run_path ? [{ path: compiled.run_path, role: "test", label: "portable context readiness run" }] : []),
|
|
685
|
-
]);
|
|
686
|
-
let eventIndex = 0;
|
|
687
|
-
const events = [
|
|
688
|
-
traceEvent(run.run_id, "run_created", run.started_at, eventIndex++, {
|
|
689
|
-
deploymentId: "local-interf",
|
|
690
|
-
workflowName,
|
|
691
|
-
input: {
|
|
692
|
-
kind: "test",
|
|
693
|
-
preparation: run.preparation,
|
|
694
|
-
mode: run.mode,
|
|
695
|
-
},
|
|
696
|
-
}),
|
|
697
|
-
];
|
|
698
|
-
if (run.started_at) {
|
|
699
|
-
events.push(traceEvent(run.run_id, "run_started", run.started_at, eventIndex++, {
|
|
700
|
-
workflowName,
|
|
701
|
-
input: {
|
|
702
|
-
preparation: run.preparation,
|
|
703
|
-
mode: run.mode,
|
|
704
|
-
},
|
|
705
|
-
}));
|
|
706
|
-
}
|
|
707
|
-
const targetStepCandidates = [
|
|
708
|
-
raw
|
|
709
|
-
? {
|
|
710
|
-
id: "source-files-baseline",
|
|
711
|
-
label: "Source files baseline",
|
|
712
|
-
status: raw.ok ?? raw.passed_cases === raw.total_cases ? "succeeded" : "failed",
|
|
713
|
-
input: raw.target ?? { type: "source-files", path: run.source_path ?? null },
|
|
714
|
-
output: raw,
|
|
715
|
-
}
|
|
716
|
-
: null,
|
|
717
|
-
compiled
|
|
718
|
-
? {
|
|
719
|
-
id: "portable-context-check",
|
|
720
|
-
label: "Portable context",
|
|
721
|
-
status: compiled.ok ?? compiled.passed_cases === compiled.total_cases ? "succeeded" : "failed",
|
|
722
|
-
input: compiled.target ?? { type: "portable-context", path: run.portable_context_path ?? null },
|
|
723
|
-
output: compiled,
|
|
724
|
-
}
|
|
725
|
-
: null,
|
|
726
|
-
];
|
|
727
|
-
const targetSteps = targetStepCandidates.filter((value) => value !== null);
|
|
728
|
-
if (targetSteps.length === 0) {
|
|
729
|
-
targetSteps.push({
|
|
730
|
-
id: "check-readiness",
|
|
731
|
-
label: "Run readiness checks",
|
|
732
|
-
status: run.status === "failed" ? "failed" : "succeeded",
|
|
733
|
-
input: {
|
|
734
|
-
preparation: run.preparation,
|
|
735
|
-
mode: run.mode,
|
|
736
|
-
},
|
|
737
|
-
output: run.comparison ?? null,
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
for (const step of targetSteps) {
|
|
741
|
-
const timestamp = run.started_at ?? run.finished_at ?? new Date().toISOString();
|
|
742
|
-
events.push(traceEvent(run.run_id, "step_created", timestamp, eventIndex++, {
|
|
743
|
-
stepName: workflowStepName("test", step.label),
|
|
744
|
-
input: step.input,
|
|
745
|
-
}, step.id));
|
|
746
|
-
events.push(traceEvent(run.run_id, "step_started", timestamp, eventIndex++, {
|
|
747
|
-
attempt: 1,
|
|
748
|
-
}, step.id));
|
|
749
|
-
events.push(traceEvent(run.run_id, step.status === "failed" ? "step_failed" : "step_completed", run.finished_at ?? timestamp, eventIndex++, step.status === "failed"
|
|
750
|
-
? { error: structuredWorkflowError(run.error ?? `${step.label} did not pass.`), output: step.output }
|
|
751
|
-
: { result: step.output }, step.id));
|
|
752
|
-
}
|
|
753
|
-
if (traceStatus === "completed") {
|
|
754
|
-
events.push(traceEvent(run.run_id, "run_completed", completedAt, eventIndex++, {
|
|
755
|
-
output: {
|
|
756
|
-
comparison: run.comparison,
|
|
757
|
-
proof,
|
|
758
|
-
},
|
|
759
|
-
}));
|
|
760
|
-
}
|
|
761
|
-
else if (traceStatus === "failed") {
|
|
762
|
-
events.push(traceEvent(run.run_id, "run_failed", completedAt, eventIndex++, {
|
|
763
|
-
error: structuredWorkflowError(run.error),
|
|
764
|
-
}));
|
|
765
|
-
}
|
|
766
|
-
else if (traceStatus === "cancelled") {
|
|
767
|
-
events.push(traceEvent(run.run_id, "run_cancelled", completedAt, eventIndex++));
|
|
768
|
-
}
|
|
769
|
-
return RunObservabilityResourceSchema.parse({
|
|
770
|
-
kind: "interf-run-observability",
|
|
771
|
-
version: 1,
|
|
772
|
-
run_id: run.run_id,
|
|
773
|
-
run_type: "test",
|
|
774
|
-
title,
|
|
775
|
-
status: observableRunStatus(run.status),
|
|
776
|
-
preparation: run.preparation,
|
|
777
|
-
method: compiled?.target?.workflow ?? null,
|
|
778
|
-
source_path: run.source_path ?? null,
|
|
779
|
-
output_path: run.portable_context_path ?? null,
|
|
780
|
-
created_at: run.started_at ?? completedAt ?? new Date().toISOString(),
|
|
781
|
-
started_at: run.started_at ?? null,
|
|
782
|
-
finished_at: run.finished_at ?? null,
|
|
783
|
-
metrics: [
|
|
784
|
-
{ label: "Preparation", value: run.preparation },
|
|
785
|
-
{ label: "Mode", value: run.mode },
|
|
786
|
-
{ label: "Readiness checks", value: compiled ? `${compiled.passed_cases}/${compiled.total_cases}` : raw ? `${raw.passed_cases}/${raw.total_cases}` : "0/0" },
|
|
787
|
-
{ label: "Source files", value: raw ? `${raw.passed_cases}/${raw.total_cases}` : "-" },
|
|
788
|
-
{ label: "Portable context", value: compiled ? `${compiled.passed_cases}/${compiled.total_cases}` : "-" },
|
|
789
|
-
],
|
|
790
|
-
artifacts,
|
|
791
|
-
proof,
|
|
792
|
-
trace: {
|
|
793
|
-
run: {
|
|
794
|
-
runId: run.run_id,
|
|
795
|
-
status: traceStatus,
|
|
796
|
-
deploymentId: "local-interf",
|
|
797
|
-
workflowName,
|
|
798
|
-
specVersion: 1,
|
|
799
|
-
executionContext: {
|
|
800
|
-
product: "Interf",
|
|
801
|
-
run_type: "test",
|
|
802
|
-
preparation: run.preparation,
|
|
803
|
-
mode: run.mode,
|
|
804
|
-
},
|
|
805
|
-
input: {
|
|
806
|
-
preparation: run.preparation,
|
|
807
|
-
mode: run.mode,
|
|
808
|
-
source_path: run.source_path ?? null,
|
|
809
|
-
portable_context_path: run.portable_context_path ?? null,
|
|
810
|
-
},
|
|
811
|
-
...(traceStatus === "completed" ? { output: { comparison: run.comparison, proof } } : {}),
|
|
812
|
-
...(traceStatus === "failed" ? { error: structuredWorkflowError(run.error) } : {}),
|
|
813
|
-
...(run.started_at ? { startedAt: run.started_at } : {}),
|
|
814
|
-
...(completedAt ? { completedAt } : {}),
|
|
815
|
-
createdAt: run.started_at ?? completedAt ?? new Date().toISOString(),
|
|
816
|
-
updatedAt: completedAt ?? run.started_at ?? new Date().toISOString(),
|
|
817
|
-
},
|
|
818
|
-
events,
|
|
819
|
-
streams: buildTraceStreamChunks(run.run_id, run.events ?? []),
|
|
820
|
-
},
|
|
821
|
-
});
|
|
822
|
-
}
|
|
823
|
-
function jobRunToObservability(job) {
|
|
824
|
-
const runType = (job.job_type === "preparation-setup" ||
|
|
825
|
-
job.job_type === "readiness-check-draft" ||
|
|
826
|
-
job.job_type === "method-authoring" ||
|
|
827
|
-
job.job_type === "method-improvement"
|
|
828
|
-
? job.job_type
|
|
829
|
-
: "job");
|
|
830
|
-
const executor = job.agent
|
|
831
|
-
? {
|
|
832
|
-
kind: "local-agent",
|
|
833
|
-
name: job.agent.name,
|
|
834
|
-
display_name: job.agent.display_name,
|
|
835
|
-
command: job.agent.command ?? null,
|
|
836
|
-
}
|
|
837
|
-
: null;
|
|
838
|
-
const traceStatus = workflowTraceRunStatus(job.status);
|
|
839
|
-
const workflowName = workflowTraceName(runType, job.title);
|
|
840
|
-
const completedAt = job.finished_at ?? (traceStatus === "completed" || traceStatus === "failed" || traceStatus === "cancelled"
|
|
841
|
-
? job.started_at ?? job.created_at
|
|
842
|
-
: undefined);
|
|
843
|
-
let eventIndex = 0;
|
|
844
|
-
const events = [
|
|
845
|
-
traceEvent(job.run_id, "run_created", job.created_at, eventIndex++, {
|
|
846
|
-
deploymentId: "local-interf",
|
|
847
|
-
workflowName,
|
|
848
|
-
input: {
|
|
849
|
-
job_type: job.job_type,
|
|
850
|
-
preparation: job.preparation ?? null,
|
|
851
|
-
method: job.method ?? null,
|
|
852
|
-
},
|
|
853
|
-
executionContext: {
|
|
854
|
-
executor,
|
|
855
|
-
},
|
|
856
|
-
}),
|
|
857
|
-
];
|
|
858
|
-
if (job.started_at) {
|
|
859
|
-
events.push(traceEvent(job.run_id, "run_started", job.started_at, eventIndex++, {
|
|
860
|
-
workflowName,
|
|
861
|
-
input: {
|
|
862
|
-
job_type: job.job_type,
|
|
863
|
-
preparation: job.preparation ?? null,
|
|
864
|
-
},
|
|
865
|
-
executionContext: {
|
|
866
|
-
executor,
|
|
867
|
-
},
|
|
868
|
-
}));
|
|
869
|
-
}
|
|
870
|
-
for (const step of job.steps) {
|
|
871
|
-
const timestamp = step.started_at ?? job.started_at ?? job.created_at;
|
|
872
|
-
events.push(traceEvent(job.run_id, "step_created", timestamp, eventIndex++, {
|
|
873
|
-
stepName: workflowStepName(runType, step.label),
|
|
874
|
-
input: step.input ?? {
|
|
875
|
-
step_id: step.id,
|
|
876
|
-
label: step.label,
|
|
877
|
-
},
|
|
878
|
-
}, step.id));
|
|
879
|
-
if (step.started_at || step.status !== "queued") {
|
|
880
|
-
events.push(traceEvent(job.run_id, "step_started", step.started_at ?? timestamp, eventIndex++, {
|
|
881
|
-
attempt: 1,
|
|
882
|
-
}, step.id));
|
|
883
|
-
}
|
|
884
|
-
if (step.status === "failed") {
|
|
885
|
-
events.push(traceEvent(job.run_id, "step_failed", step.finished_at ?? completedAt ?? timestamp, eventIndex++, {
|
|
886
|
-
error: structuredWorkflowError(step.summary ?? job.error),
|
|
887
|
-
output: step.output ?? null,
|
|
888
|
-
}, step.id));
|
|
889
|
-
}
|
|
890
|
-
else if (step.status === "succeeded") {
|
|
891
|
-
events.push(traceEvent(job.run_id, "step_completed", step.finished_at ?? completedAt ?? timestamp, eventIndex++, {
|
|
892
|
-
result: step.output ?? {
|
|
893
|
-
summary: step.summary ?? null,
|
|
894
|
-
},
|
|
895
|
-
}, step.id));
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
if (traceStatus === "completed") {
|
|
899
|
-
events.push(traceEvent(job.run_id, "run_completed", completedAt, eventIndex++, {
|
|
900
|
-
output: job.result ?? {
|
|
901
|
-
output_path: job.output_path ?? null,
|
|
902
|
-
},
|
|
903
|
-
}));
|
|
904
|
-
}
|
|
905
|
-
else if (traceStatus === "failed") {
|
|
906
|
-
events.push(traceEvent(job.run_id, "run_failed", completedAt, eventIndex++, {
|
|
907
|
-
error: structuredWorkflowError(job.error),
|
|
908
|
-
}));
|
|
909
|
-
}
|
|
910
|
-
else if (traceStatus === "cancelled") {
|
|
911
|
-
events.push(traceEvent(job.run_id, "run_cancelled", completedAt, eventIndex++));
|
|
912
|
-
}
|
|
913
|
-
const outputPath = job.output_path ?? (typeof job.result?.path === "string" ? job.result.path : null);
|
|
914
|
-
const artifacts = uniqueArtifacts(outputPath ? [{ path: outputPath, role: "output" }] : []);
|
|
915
|
-
return RunObservabilityResourceSchema.parse({
|
|
916
|
-
kind: "interf-run-observability",
|
|
917
|
-
version: 1,
|
|
918
|
-
run_id: job.run_id,
|
|
919
|
-
run_type: runType,
|
|
920
|
-
title: job.title,
|
|
921
|
-
status: observableRunStatus(job.status),
|
|
922
|
-
preparation: job.preparation ?? null,
|
|
923
|
-
method: job.method ?? null,
|
|
924
|
-
source_path: job.source_path ?? null,
|
|
925
|
-
output_path: outputPath,
|
|
926
|
-
executor,
|
|
927
|
-
agent_label: agentLabelForJob(job),
|
|
928
|
-
created_at: job.created_at,
|
|
929
|
-
started_at: job.started_at ?? null,
|
|
930
|
-
finished_at: job.finished_at ?? null,
|
|
931
|
-
metrics: [
|
|
932
|
-
{ label: "Kind", value: jobTypeLabelForMetric(job.job_type) },
|
|
933
|
-
{ label: "Executor", value: agentLabelForJob(job) ?? "local executor" },
|
|
934
|
-
{ label: "Phases", value: `${job.steps.filter((step) => step.status === "succeeded").length}/${job.steps.length}` },
|
|
935
|
-
{ label: "Preparation", value: job.preparation ?? "-" },
|
|
936
|
-
{ label: "Method", value: job.method ?? "-" },
|
|
937
|
-
],
|
|
938
|
-
artifacts,
|
|
939
|
-
proof: [],
|
|
940
|
-
trace: {
|
|
941
|
-
run: {
|
|
942
|
-
runId: job.run_id,
|
|
943
|
-
status: traceStatus,
|
|
944
|
-
deploymentId: "local-interf",
|
|
945
|
-
workflowName,
|
|
946
|
-
specVersion: 1,
|
|
947
|
-
executionContext: {
|
|
948
|
-
product: "Interf",
|
|
949
|
-
run_type: runType,
|
|
950
|
-
job_type: job.job_type,
|
|
951
|
-
preparation: job.preparation ?? null,
|
|
952
|
-
method: job.method ?? null,
|
|
953
|
-
executor,
|
|
954
|
-
},
|
|
955
|
-
input: {
|
|
956
|
-
job_type: job.job_type,
|
|
957
|
-
preparation: job.preparation ?? null,
|
|
958
|
-
method: job.method ?? null,
|
|
959
|
-
source_path: job.source_path ?? null,
|
|
960
|
-
},
|
|
961
|
-
...(traceStatus === "completed" ? { output: job.result ?? { output_path: outputPath } } : {}),
|
|
962
|
-
...(traceStatus === "failed" ? { error: structuredWorkflowError(job.error) } : {}),
|
|
963
|
-
...(job.started_at ? { startedAt: job.started_at } : {}),
|
|
964
|
-
...(completedAt ? { completedAt } : {}),
|
|
965
|
-
createdAt: job.created_at,
|
|
966
|
-
updatedAt: completedAt ?? job.started_at ?? job.created_at,
|
|
967
|
-
},
|
|
968
|
-
events,
|
|
969
|
-
streams: buildTraceStreamChunks(job.run_id, job.events),
|
|
970
|
-
},
|
|
971
|
-
});
|
|
972
|
-
}
|
|
973
403
|
function slugFromText(value) {
|
|
974
404
|
const slug = value
|
|
975
405
|
.toLowerCase()
|
|
@@ -989,12 +419,23 @@ function numberValue(values, key) {
|
|
|
989
419
|
}
|
|
990
420
|
function testModeFromValues(values) {
|
|
991
421
|
const value = stringValue(values, "mode") ?? stringValue(values, "target");
|
|
422
|
+
if (value === "source-files")
|
|
423
|
+
return "raw";
|
|
424
|
+
if (value === "portable-context")
|
|
425
|
+
return "compiled";
|
|
992
426
|
return value === "raw" || value === "compiled" || value === "both" ? value : null;
|
|
993
427
|
}
|
|
994
428
|
function testModeValue(values, defaultMode = "both") {
|
|
995
429
|
return testModeFromValues(values) ?? defaultMode;
|
|
996
430
|
}
|
|
997
|
-
function
|
|
431
|
+
function testModeCliTarget(mode) {
|
|
432
|
+
if (mode === "raw")
|
|
433
|
+
return "source-files";
|
|
434
|
+
if (mode === "compiled")
|
|
435
|
+
return "portable-context";
|
|
436
|
+
return "both";
|
|
437
|
+
}
|
|
438
|
+
function methodIdForProposal(message, values) {
|
|
998
439
|
const explicit = stringValue(values, "method_id") ??
|
|
999
440
|
stringValue(values, "method");
|
|
1000
441
|
return explicit ?? `custom-${slugFromText(message)}`;
|
|
@@ -1003,35 +444,35 @@ function actionValueMethodTaskPrompt(values) {
|
|
|
1003
444
|
const parsed = MethodAuthoringActionValuesSchema.safeParse(values);
|
|
1004
445
|
return parsed.success ? methodAuthoringTaskPrompt(parsed.data) : null;
|
|
1005
446
|
}
|
|
1006
|
-
function
|
|
447
|
+
function preparationSetupPathValue(values) {
|
|
1007
448
|
return stringValue(values, "path") ??
|
|
1008
449
|
stringValue(values, "source_folder_path") ??
|
|
1009
450
|
stringValue(values, "source_path") ??
|
|
1010
451
|
stringValue(values, "source_folder") ??
|
|
1011
452
|
stringValue(values, "folder");
|
|
1012
453
|
}
|
|
1013
|
-
function
|
|
454
|
+
function preparationSetupNameValue(values) {
|
|
1014
455
|
const parsed = PreparationSetupActionValuesSchema.safeParse(values);
|
|
1015
456
|
return parsed.success ? parsed.data.name : stringValue(values, "name") ??
|
|
1016
457
|
stringValue(values, "preparation") ??
|
|
1017
458
|
stringValue(values, "preparation_name");
|
|
1018
459
|
}
|
|
1019
|
-
function actionCommandPreview(actionType,
|
|
460
|
+
function actionCommandPreview(actionType, preparationName, methodId, values) {
|
|
1020
461
|
if (actionType === "preparation-setup") {
|
|
1021
|
-
const
|
|
1022
|
-
const pathPart =
|
|
1023
|
-
return pathPart ? `interf init # source: ${pathPart}${
|
|
462
|
+
const preparationPart = preparationName ? ` # Preparation: ${preparationName}` : "";
|
|
463
|
+
const pathPart = preparationSetupPathValue(values);
|
|
464
|
+
return pathPart ? `interf init # source: ${pathPart}${preparationPart}` : `interf init${preparationPart}`;
|
|
1024
465
|
}
|
|
1025
466
|
if (actionType === "compile") {
|
|
1026
|
-
const
|
|
1027
|
-
return
|
|
1028
|
-
? `interf compile --preparation ${
|
|
1029
|
-
: `interf compile${
|
|
467
|
+
const methodSuffix = methodId ? ` # Method: ${methodId}` : "";
|
|
468
|
+
return preparationName
|
|
469
|
+
? `interf compile --preparation ${preparationName}${methodSuffix}`
|
|
470
|
+
: `interf compile${methodSuffix}`;
|
|
1030
471
|
}
|
|
1031
472
|
if (actionType === "test") {
|
|
1032
|
-
const mode = testModeValue(values);
|
|
1033
|
-
return
|
|
1034
|
-
? `interf test --preparation ${
|
|
473
|
+
const mode = testModeCliTarget(testModeValue(values));
|
|
474
|
+
return preparationName
|
|
475
|
+
? `interf test --preparation ${preparationName} --target ${mode}`
|
|
1035
476
|
: `interf test --target ${mode}`;
|
|
1036
477
|
}
|
|
1037
478
|
if (actionType === "readiness-check-draft") {
|
|
@@ -1042,28 +483,28 @@ function actionCommandPreview(actionType, datasetName, workflowId, values) {
|
|
|
1042
483
|
}
|
|
1043
484
|
return "Try: create a Preparation, prepare, check readiness, draft readiness checks, or draft a Method.";
|
|
1044
485
|
}
|
|
1045
|
-
function hasCompiledTestTarget(sourcePath,
|
|
1046
|
-
const compiledPath = portableContextPath(sourcePath,
|
|
486
|
+
function hasCompiledTestTarget(sourcePath, preparationConfig) {
|
|
487
|
+
const compiledPath = portableContextPath(sourcePath, preparationConfig.name);
|
|
1047
488
|
if (!existsSync(compiledPath))
|
|
1048
489
|
return false;
|
|
1049
|
-
return createCompiledTestTarget(compiledPath,
|
|
490
|
+
return createCompiledTestTarget(compiledPath, preparationConfig.name, methodIdForSourcePreparationConfig(preparationConfig) ?? DEFAULT_METHOD_ID).eligible;
|
|
1050
491
|
}
|
|
1051
|
-
function actionAssistantMessage(actionType,
|
|
1052
|
-
const
|
|
492
|
+
function actionAssistantMessage(actionType, preparationName, commandPreview) {
|
|
493
|
+
const preparationSuffix = preparationName ? ` for Preparation "${preparationName}"` : "";
|
|
1053
494
|
if (actionType === "preparation-setup") {
|
|
1054
|
-
return `Interf prepared a Preparation setup proposal${
|
|
495
|
+
return `Interf prepared a Preparation setup proposal${preparationSuffix}. Approve to save the source folder and create the portable-context scaffold. CLI equivalent: ${commandPreview}`;
|
|
1055
496
|
}
|
|
1056
497
|
if (actionType === "compile") {
|
|
1057
|
-
return `Interf prepared a prepare-run proposal${
|
|
498
|
+
return `Interf prepared a prepare-run proposal${preparationSuffix}. Approve to submit it through the local Interf service and watch the run in Interf. CLI equivalent: ${commandPreview}`;
|
|
1058
499
|
}
|
|
1059
500
|
if (actionType === "test") {
|
|
1060
|
-
return `Interf prepared a readiness-check proposal${
|
|
501
|
+
return `Interf prepared a readiness-check proposal${preparationSuffix}. Approve to run the requested target against saved readiness checks. CLI equivalent: ${commandPreview}`;
|
|
1061
502
|
}
|
|
1062
503
|
if (actionType === "readiness-check-draft") {
|
|
1063
|
-
return `Interf prepared a readiness-check draft proposal${
|
|
504
|
+
return `Interf prepared a readiness-check draft proposal${preparationSuffix}. Approve to ask the configured local executor to draft checks as a visible run. CLI equivalent: ${commandPreview}`;
|
|
1064
505
|
}
|
|
1065
506
|
if (actionType === "method-authoring" || actionType === "method-improvement") {
|
|
1066
|
-
return `Interf prepared a Method draft proposal${
|
|
507
|
+
return `Interf prepared a Method draft proposal${preparationSuffix}. Approve to draft a reusable local Method as a visible run. CLI equivalent: ${commandPreview}`;
|
|
1067
508
|
}
|
|
1068
509
|
return "I could not map that to a safe Interf action. Ask for one action in plain English, such as create a Preparation, prepare the data, check readiness, draft readiness checks, or draft a Method.";
|
|
1069
510
|
}
|
|
@@ -1111,27 +552,25 @@ function readinessStateToPreparationReadiness(readiness) {
|
|
|
1111
552
|
checks: readiness.checks.map((check) => ({ ...check })),
|
|
1112
553
|
});
|
|
1113
554
|
}
|
|
1114
|
-
function
|
|
1115
|
-
const
|
|
1116
|
-
const latestTestRunId = resource.latest_test_run_id ?? null;
|
|
1117
|
-
const methodId = methodIdForSourcePreparationConfig(resource.dataset);
|
|
555
|
+
function buildPreparationResource(rootPath, preparation, readiness, latestCompileRunId, latestTestRunId) {
|
|
556
|
+
const methodId = methodIdForSourcePreparationConfig(preparation);
|
|
1118
557
|
return PreparationResourceSchema.parse({
|
|
1119
|
-
id:
|
|
1120
|
-
name:
|
|
1121
|
-
preparation
|
|
1122
|
-
source_path:
|
|
558
|
+
id: preparation.name,
|
|
559
|
+
name: preparation.name,
|
|
560
|
+
preparation,
|
|
561
|
+
source_path: resolveSourcePreparationPath(rootPath, preparation),
|
|
1123
562
|
method_id: methodId,
|
|
1124
|
-
checks:
|
|
563
|
+
checks: preparation.checks,
|
|
1125
564
|
portable_context: {
|
|
1126
|
-
preparation:
|
|
1127
|
-
path:
|
|
1128
|
-
exists:
|
|
565
|
+
preparation: preparation.name,
|
|
566
|
+
path: readiness.portable_context_path,
|
|
567
|
+
exists: readiness.portable_context_path !== null,
|
|
1129
568
|
method_id: methodId,
|
|
1130
569
|
latest_compile_run_id: latestCompileRunId,
|
|
1131
570
|
latest_test_run_id: latestTestRunId,
|
|
1132
571
|
},
|
|
1133
|
-
portable_context_path:
|
|
1134
|
-
readiness: readinessStateToPreparationReadiness(
|
|
572
|
+
portable_context_path: readiness.portable_context_path,
|
|
573
|
+
readiness: readinessStateToPreparationReadiness(readiness),
|
|
1135
574
|
runs: {
|
|
1136
575
|
latest_compile_run_id: latestCompileRunId,
|
|
1137
576
|
latest_test_run_id: latestTestRunId,
|
|
@@ -1140,7 +579,7 @@ function datasetResourceToPreparationResource(rootPath, resource) {
|
|
|
1140
579
|
latest_test_run_id: latestTestRunId,
|
|
1141
580
|
});
|
|
1142
581
|
}
|
|
1143
|
-
function
|
|
582
|
+
function buildMethodResource(resource) {
|
|
1144
583
|
return MethodResourceSchema.parse({
|
|
1145
584
|
id: resource.id,
|
|
1146
585
|
method_id: resource.id,
|
|
@@ -1149,7 +588,7 @@ function workflowPackageResourceToMethodResource(resource) {
|
|
|
1149
588
|
...(resource.hint ? { hint: resource.hint } : {}),
|
|
1150
589
|
source_kind: resource.source_kind,
|
|
1151
590
|
built_in: resource.built_in,
|
|
1152
|
-
active_for_preparations: resource.
|
|
591
|
+
active_for_preparations: resource.active_for_preparations,
|
|
1153
592
|
stages: resource.stages,
|
|
1154
593
|
});
|
|
1155
594
|
}
|
|
@@ -1183,31 +622,17 @@ export class LocalServiceRuntime {
|
|
|
1183
622
|
...(this.packageVersion ? { package_version: this.packageVersion } : {}),
|
|
1184
623
|
});
|
|
1185
624
|
}
|
|
1186
|
-
|
|
625
|
+
listPreparations() {
|
|
1187
626
|
const config = loadSourceFolderConfig(this.rootPath);
|
|
1188
|
-
return
|
|
1189
|
-
const compileRuns = this.
|
|
1190
|
-
const testRuns = this.
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
return DatasetResourceSchema.parse({
|
|
1194
|
-
dataset,
|
|
1195
|
-
portable_context_path: existsSync(path) ? path : null,
|
|
1196
|
-
readiness,
|
|
1197
|
-
latest_compile_run_id: compileRuns[0]?.run_id ?? null,
|
|
1198
|
-
latest_test_run_id: testRuns[0]?.run_id ?? null,
|
|
1199
|
-
});
|
|
627
|
+
return listSourcePreparationConfigs(config).map((preparation) => {
|
|
628
|
+
const compileRuns = this.listCompileRunsForPreparation(preparation.name);
|
|
629
|
+
const testRuns = this.listTestRunsForPreparation(preparation.name);
|
|
630
|
+
const readiness = this.computePreparationReadiness(preparation);
|
|
631
|
+
return buildPreparationResource(this.rootPath, preparation, readiness, compileRuns[0]?.run_id ?? null, testRuns[0]?.run_id ?? null);
|
|
1200
632
|
});
|
|
1201
633
|
}
|
|
1202
|
-
getDataset(datasetName) {
|
|
1203
|
-
return this.listDatasets().find((dataset) => dataset.dataset.name === datasetName) ?? null;
|
|
1204
|
-
}
|
|
1205
|
-
listPreparations() {
|
|
1206
|
-
return this.listDatasets().map((resource) => datasetResourceToPreparationResource(this.rootPath, resource));
|
|
1207
|
-
}
|
|
1208
634
|
getPreparation(preparationName) {
|
|
1209
|
-
|
|
1210
|
-
return dataset ? datasetResourceToPreparationResource(this.rootPath, dataset) : null;
|
|
635
|
+
return this.listPreparations().find((preparation) => preparation.name === preparationName) ?? null;
|
|
1211
636
|
}
|
|
1212
637
|
listPreparationReadiness() {
|
|
1213
638
|
return this.listReadiness().map(readinessStateToPreparationReadiness);
|
|
@@ -1218,21 +643,23 @@ export class LocalServiceRuntime {
|
|
|
1218
643
|
}
|
|
1219
644
|
listReadiness() {
|
|
1220
645
|
const config = loadSourceFolderConfig(this.rootPath);
|
|
1221
|
-
return
|
|
646
|
+
return listSourcePreparationConfigs(config).map((preparation) => this.computePreparationReadiness(preparation));
|
|
1222
647
|
}
|
|
1223
|
-
getReadiness(
|
|
1224
|
-
const
|
|
1225
|
-
return
|
|
648
|
+
getReadiness(preparationName) {
|
|
649
|
+
const preparation = findSourcePreparationConfig(loadSourceFolderConfig(this.rootPath), preparationName);
|
|
650
|
+
return preparation ? this.computePreparationReadiness(preparation) : null;
|
|
1226
651
|
}
|
|
1227
|
-
|
|
652
|
+
computePreparationReadiness(preparation) {
|
|
1228
653
|
const generatedAt = new Date().toISOString();
|
|
1229
|
-
const compiledPath = portableContextPath(this.rootPath,
|
|
654
|
+
const compiledPath = portableContextPath(this.rootPath, preparation.name);
|
|
1230
655
|
const contextExists = existsSync(compiledPath);
|
|
1231
|
-
const
|
|
1232
|
-
const
|
|
1233
|
-
const
|
|
1234
|
-
const
|
|
1235
|
-
const
|
|
656
|
+
const compiledTarget = createCompiledTestTarget(compiledPath, preparation.name, methodIdForSourcePreparationConfig(preparation) ?? DEFAULT_METHOD_ID);
|
|
657
|
+
const contextReady = compiledTarget.eligible;
|
|
658
|
+
const compileRun = this.listCompileRunsForPreparation(preparation.name)[0] ?? null;
|
|
659
|
+
const testRun = this.listTestRunsForPreparation(preparation.name)[0] ?? null;
|
|
660
|
+
const comparison = this.readLatestComparison(preparation.name);
|
|
661
|
+
const configuredChecks = preparation.checks.length;
|
|
662
|
+
const currentFingerprint = configuredChecks > 0 ? fingerprintReadinessChecks(preparation.checks) : null;
|
|
1236
663
|
const comparisonFingerprint = comparison?.checks_fingerprint ?? null;
|
|
1237
664
|
const sourceResult = readinessTargetResult(comparison?.raw, currentFingerprint, comparisonFingerprint);
|
|
1238
665
|
const contextResult = readinessTargetResult(comparison?.compiled, currentFingerprint, comparisonFingerprint);
|
|
@@ -1244,19 +671,19 @@ export class LocalServiceRuntime {
|
|
|
1244
671
|
ok: false,
|
|
1245
672
|
status: "not-built",
|
|
1246
673
|
summary: "No compile run has built portable context yet.",
|
|
1247
|
-
artifact_path:
|
|
674
|
+
artifact_path: contextReady ? compiledPath : null,
|
|
1248
675
|
};
|
|
1249
676
|
}
|
|
1250
677
|
if (compileRun.status === "succeeded") {
|
|
1251
678
|
return {
|
|
1252
679
|
gate: "compile-run",
|
|
1253
|
-
ok:
|
|
1254
|
-
status:
|
|
1255
|
-
summary:
|
|
680
|
+
ok: contextReady,
|
|
681
|
+
status: contextReady ? "built" : "failed",
|
|
682
|
+
summary: contextReady
|
|
1256
683
|
? "Latest compile run built portable context."
|
|
1257
684
|
: "Latest compile run finished, but portable context is missing.",
|
|
1258
685
|
run_id: compileRun.run_id,
|
|
1259
|
-
artifact_path:
|
|
686
|
+
artifact_path: contextReady ? compiledPath : null,
|
|
1260
687
|
};
|
|
1261
688
|
}
|
|
1262
689
|
if (compileRun.status === "queued" || compileRun.status === "running") {
|
|
@@ -1277,7 +704,7 @@ export class LocalServiceRuntime {
|
|
|
1277
704
|
? "Latest compile run was cancelled."
|
|
1278
705
|
: "Latest compile run failed.",
|
|
1279
706
|
run_id: compileRun.run_id,
|
|
1280
|
-
artifact_path:
|
|
707
|
+
artifact_path: contextReady ? compiledPath : null,
|
|
1281
708
|
};
|
|
1282
709
|
})();
|
|
1283
710
|
const checks = [
|
|
@@ -1288,12 +715,12 @@ export class LocalServiceRuntime {
|
|
|
1288
715
|
},
|
|
1289
716
|
{
|
|
1290
717
|
gate: "portable-context",
|
|
1291
|
-
ok:
|
|
1292
|
-
status:
|
|
1293
|
-
summary:
|
|
1294
|
-
? "Portable context
|
|
1295
|
-
: "Portable context
|
|
1296
|
-
artifact_path:
|
|
718
|
+
ok: contextReady,
|
|
719
|
+
status: contextReady ? "built" : "not-built",
|
|
720
|
+
summary: contextReady
|
|
721
|
+
? "Portable context is built."
|
|
722
|
+
: "Portable context has not been built.",
|
|
723
|
+
artifact_path: contextReady ? compiledPath : null,
|
|
1297
724
|
},
|
|
1298
725
|
compileCheck,
|
|
1299
726
|
{
|
|
@@ -1320,7 +747,7 @@ export class LocalServiceRuntime {
|
|
|
1320
747
|
return "checking";
|
|
1321
748
|
if (compileRun?.status === "failed" || compileRun?.status === "cancelled")
|
|
1322
749
|
return "failed";
|
|
1323
|
-
if (!compileRun || !
|
|
750
|
+
if (!compileRun || !contextReady)
|
|
1324
751
|
return "not-built";
|
|
1325
752
|
if (configuredChecks === 0)
|
|
1326
753
|
return "not-configured";
|
|
@@ -1335,11 +762,11 @@ export class LocalServiceRuntime {
|
|
|
1335
762
|
kind: "interf-readiness-state",
|
|
1336
763
|
version: 1,
|
|
1337
764
|
generated_at: generatedAt,
|
|
1338
|
-
preparation:
|
|
765
|
+
preparation: preparation.name,
|
|
1339
766
|
status,
|
|
1340
767
|
ready,
|
|
1341
768
|
summary: readinessSummaryForStatus(status),
|
|
1342
|
-
portable_context_path:
|
|
769
|
+
portable_context_path: contextReady ? compiledPath : null,
|
|
1343
770
|
latest_compile_run_id: compileRun?.run_id ?? null,
|
|
1344
771
|
latest_test_run_id: testRun?.run_id ?? null,
|
|
1345
772
|
compile: compileCheck,
|
|
@@ -1353,12 +780,12 @@ export class LocalServiceRuntime {
|
|
|
1353
780
|
checks,
|
|
1354
781
|
});
|
|
1355
782
|
}
|
|
1356
|
-
listSourceFiles(
|
|
1357
|
-
const
|
|
1358
|
-
.filter((
|
|
1359
|
-
return
|
|
1360
|
-
const sourceFolderPath =
|
|
1361
|
-
const compiledPath = portableContextPath(this.rootPath,
|
|
783
|
+
listSourceFiles(preparationName) {
|
|
784
|
+
const preparations = listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath))
|
|
785
|
+
.filter((preparation) => !preparationName || preparation.name === preparationName);
|
|
786
|
+
return preparations.flatMap((preparation) => {
|
|
787
|
+
const sourceFolderPath = resolveSourcePreparationPath(this.rootPath, preparation);
|
|
788
|
+
const compiledPath = portableContextPath(this.rootPath, preparation.name);
|
|
1362
789
|
return discoverSourceFiles(sourceFolderPath, compiledPath).sourceFiles.map((relativePath) => {
|
|
1363
790
|
const absolutePath = join(sourceFolderPath, relativePath);
|
|
1364
791
|
let sizeBytes = 0;
|
|
@@ -1373,7 +800,7 @@ export class LocalServiceRuntime {
|
|
|
1373
800
|
modifiedAt = null;
|
|
1374
801
|
}
|
|
1375
802
|
return SourceFileResourceSchema.parse({
|
|
1376
|
-
preparation:
|
|
803
|
+
preparation: preparation.name,
|
|
1377
804
|
path: relativePath,
|
|
1378
805
|
absolute_path: absolutePath,
|
|
1379
806
|
size_bytes: sizeBytes,
|
|
@@ -1406,24 +833,22 @@ export class LocalServiceRuntime {
|
|
|
1406
833
|
});
|
|
1407
834
|
});
|
|
1408
835
|
}
|
|
1409
|
-
|
|
1410
|
-
const
|
|
1411
|
-
const choices =
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
active_for_datasets: activeForDatasets,
|
|
1426
|
-
stages: workflow.stages.map((stage) => ({
|
|
836
|
+
listMethods() {
|
|
837
|
+
const preparations = listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath));
|
|
838
|
+
const choices = listCompiledMethodChoices(this.rootPath);
|
|
839
|
+
return choices.map((method) => {
|
|
840
|
+
const activeForPreparations = preparations
|
|
841
|
+
.filter((preparation) => (methodIdForSourcePreparationConfig(preparation) ?? DEFAULT_METHOD_ID) === method.id)
|
|
842
|
+
.map((preparation) => preparation.name);
|
|
843
|
+
return buildMethodResource({
|
|
844
|
+
id: method.id,
|
|
845
|
+
path: resolveMethodPackageSourcePath(this.rootPath, method.id) ?? method.id,
|
|
846
|
+
label: method.label,
|
|
847
|
+
hint: method.hint,
|
|
848
|
+
source_kind: method.scope === "builtin" ? "builtin" : "local",
|
|
849
|
+
built_in: method.scope === "builtin",
|
|
850
|
+
active_for_preparations: activeForPreparations,
|
|
851
|
+
stages: method.stages.map((stage) => ({
|
|
1427
852
|
id: stage.id,
|
|
1428
853
|
label: stage.label,
|
|
1429
854
|
description: stage.description,
|
|
@@ -1436,15 +861,8 @@ export class LocalServiceRuntime {
|
|
|
1436
861
|
});
|
|
1437
862
|
});
|
|
1438
863
|
}
|
|
1439
|
-
getWorkflowPackage(workflowId) {
|
|
1440
|
-
return this.listWorkflowPackages().find((workflow) => workflow.id === workflowId) ?? null;
|
|
1441
|
-
}
|
|
1442
|
-
listMethods() {
|
|
1443
|
-
return this.listWorkflowPackages().map(workflowPackageResourceToMethodResource);
|
|
1444
|
-
}
|
|
1445
864
|
getMethod(methodId) {
|
|
1446
|
-
|
|
1447
|
-
return workflowPackage ? workflowPackageResourceToMethodResource(workflowPackage) : null;
|
|
865
|
+
return this.listMethods().find((method) => method.id === methodId) ?? null;
|
|
1448
866
|
}
|
|
1449
867
|
listJobs() {
|
|
1450
868
|
return newestJobFirst(listJsonFiles(localJobsRoot(this.rootPath))
|
|
@@ -1713,16 +1131,20 @@ export class LocalServiceRuntime {
|
|
|
1713
1131
|
void this.runReadinessCheckDraftInBackground(request, job.run_id);
|
|
1714
1132
|
return this.getJob(job.run_id) ?? job;
|
|
1715
1133
|
}
|
|
1716
|
-
async
|
|
1717
|
-
const request =
|
|
1718
|
-
const
|
|
1719
|
-
const methodId = methodIdForSourcePreparationConfig(
|
|
1720
|
-
const
|
|
1721
|
-
|
|
1134
|
+
async createPreparationSetupRun(requestValue) {
|
|
1135
|
+
const request = PreparationSetupCreateRequestSchema.parse(requestValue);
|
|
1136
|
+
const preparationConfig = request.preparation;
|
|
1137
|
+
const methodId = methodIdForSourcePreparationConfig(preparationConfig) ?? "interf-default";
|
|
1138
|
+
const normalizedPreparationConfig = {
|
|
1139
|
+
...preparationConfig,
|
|
1140
|
+
method: methodId,
|
|
1141
|
+
};
|
|
1142
|
+
const sourceFolderPath = resolveSourcePreparationPath(this.rootPath, preparationConfig);
|
|
1143
|
+
const outputPath = portableContextPath(this.rootPath, preparationConfig.name);
|
|
1722
1144
|
const job = this.createJobRun({
|
|
1723
1145
|
job_type: "preparation-setup",
|
|
1724
|
-
title: `Create Preparation ${
|
|
1725
|
-
preparation:
|
|
1146
|
+
title: `Create Preparation ${preparationConfig.name}`,
|
|
1147
|
+
preparation: preparationConfig.name,
|
|
1726
1148
|
method: methodId,
|
|
1727
1149
|
source_path: sourceFolderPath,
|
|
1728
1150
|
output_path: outputPath,
|
|
@@ -1732,8 +1154,8 @@ export class LocalServiceRuntime {
|
|
|
1732
1154
|
id: "validate-source",
|
|
1733
1155
|
label: "Validate source folder",
|
|
1734
1156
|
input: {
|
|
1735
|
-
preparation:
|
|
1736
|
-
path:
|
|
1157
|
+
preparation: preparationConfig.name,
|
|
1158
|
+
path: preparationConfig.path,
|
|
1737
1159
|
},
|
|
1738
1160
|
},
|
|
1739
1161
|
{
|
|
@@ -1760,12 +1182,12 @@ export class LocalServiceRuntime {
|
|
|
1760
1182
|
step_id: "validate-source",
|
|
1761
1183
|
message: "Validating source folder.",
|
|
1762
1184
|
input: {
|
|
1763
|
-
path:
|
|
1185
|
+
path: preparationConfig.path,
|
|
1764
1186
|
source_folder_path: sourceFolderPath,
|
|
1765
1187
|
},
|
|
1766
1188
|
});
|
|
1767
1189
|
if (!existsSync(sourceFolderPath) || !statSync(sourceFolderPath).isDirectory()) {
|
|
1768
|
-
throw new Error(`Source folder "${
|
|
1190
|
+
throw new Error(`Source folder "${preparationConfig.path}" is not available.`);
|
|
1769
1191
|
}
|
|
1770
1192
|
this.appendJobRunEvent(job.run_id, {
|
|
1771
1193
|
type: "step.completed",
|
|
@@ -1781,18 +1203,18 @@ export class LocalServiceRuntime {
|
|
|
1781
1203
|
step_id: "write-config",
|
|
1782
1204
|
message: "Saving Preparation in the control plane config.",
|
|
1783
1205
|
input: {
|
|
1784
|
-
preparation:
|
|
1785
|
-
path:
|
|
1206
|
+
preparation: preparationConfig.name,
|
|
1207
|
+
path: preparationConfig.path,
|
|
1786
1208
|
},
|
|
1787
1209
|
});
|
|
1788
|
-
|
|
1210
|
+
upsertSourcePreparationConfig(this.rootPath, normalizedPreparationConfig);
|
|
1789
1211
|
this.appendJobRunEvent(job.run_id, {
|
|
1790
1212
|
type: "step.completed",
|
|
1791
1213
|
step_id: "write-config",
|
|
1792
1214
|
message: "Preparation config saved.",
|
|
1793
1215
|
output: {
|
|
1794
1216
|
config_path: join(this.rootPath, "interf", "interf.json"),
|
|
1795
|
-
preparation:
|
|
1217
|
+
preparation: preparationConfig.name,
|
|
1796
1218
|
},
|
|
1797
1219
|
});
|
|
1798
1220
|
activeStep = "prepare-scaffold";
|
|
@@ -1805,8 +1227,8 @@ export class LocalServiceRuntime {
|
|
|
1805
1227
|
method: methodId,
|
|
1806
1228
|
},
|
|
1807
1229
|
});
|
|
1808
|
-
const compiledPath = ensurePortableContextScaffold(this.rootPath,
|
|
1809
|
-
|
|
1230
|
+
const compiledPath = ensurePortableContextScaffold(this.rootPath, normalizedPreparationConfig.name, methodId);
|
|
1231
|
+
syncCompiledInterfConfigFromSourcePreparationConfig(compiledPath, normalizedPreparationConfig);
|
|
1810
1232
|
this.appendJobRunEvent(job.run_id, {
|
|
1811
1233
|
type: "step.completed",
|
|
1812
1234
|
step_id: "prepare-scaffold",
|
|
@@ -1816,13 +1238,13 @@ export class LocalServiceRuntime {
|
|
|
1816
1238
|
},
|
|
1817
1239
|
});
|
|
1818
1240
|
this.setJobRunResult(job.run_id, {
|
|
1819
|
-
preparation:
|
|
1241
|
+
preparation: normalizedPreparationConfig,
|
|
1820
1242
|
source_folder_path: sourceFolderPath,
|
|
1821
1243
|
portable_context_path: compiledPath,
|
|
1822
1244
|
});
|
|
1823
1245
|
this.appendJobRunEvent(job.run_id, {
|
|
1824
1246
|
type: "job.completed",
|
|
1825
|
-
message: `Preparation ${
|
|
1247
|
+
message: `Preparation ${preparationConfig.name} is ready for Interf runs.`,
|
|
1826
1248
|
});
|
|
1827
1249
|
}
|
|
1828
1250
|
catch (error) {
|
|
@@ -1842,8 +1264,8 @@ export class LocalServiceRuntime {
|
|
|
1842
1264
|
}
|
|
1843
1265
|
return this.getJob(job.run_id) ?? job;
|
|
1844
1266
|
}
|
|
1845
|
-
async
|
|
1846
|
-
const request =
|
|
1267
|
+
async createMethodAuthoringRun(requestValue) {
|
|
1268
|
+
const request = MethodAuthoringCreateRequestSchema.parse(requestValue);
|
|
1847
1269
|
const job = this.createJobRun({
|
|
1848
1270
|
job_type: "method-authoring",
|
|
1849
1271
|
title: `Draft Method ${request.method_id}`,
|
|
@@ -1908,25 +1330,26 @@ export class LocalServiceRuntime {
|
|
|
1908
1330
|
task_prompt: request.task_prompt,
|
|
1909
1331
|
},
|
|
1910
1332
|
});
|
|
1911
|
-
void this.
|
|
1333
|
+
void this.runMethodAuthoringInBackground(request, job.run_id);
|
|
1912
1334
|
return this.getJob(job.run_id) ?? job;
|
|
1913
1335
|
}
|
|
1914
1336
|
listPortableContexts() {
|
|
1915
|
-
return
|
|
1337
|
+
return listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath))
|
|
1338
|
+
.map((preparation) => this.getPortableContext(preparation.name))
|
|
1916
1339
|
.filter((context) => context !== null);
|
|
1917
1340
|
}
|
|
1918
|
-
getPortableContext(
|
|
1919
|
-
const
|
|
1920
|
-
if (!
|
|
1341
|
+
getPortableContext(preparationName) {
|
|
1342
|
+
const preparation = findSourcePreparationConfig(loadSourceFolderConfig(this.rootPath), preparationName);
|
|
1343
|
+
if (!preparation)
|
|
1921
1344
|
return null;
|
|
1922
|
-
const path = portableContextPath(this.rootPath,
|
|
1345
|
+
const path = portableContextPath(this.rootPath, preparation.name);
|
|
1923
1346
|
const config = readInterfConfig(path);
|
|
1924
|
-
const compileRuns = this.
|
|
1925
|
-
const testRuns = this.
|
|
1926
|
-
const readiness = this.
|
|
1927
|
-
const method = config?.method ??
|
|
1347
|
+
const compileRuns = this.listCompileRunsForPreparation(preparation.name);
|
|
1348
|
+
const testRuns = this.listTestRunsForPreparation(preparation.name);
|
|
1349
|
+
const readiness = this.computePreparationReadiness(preparation);
|
|
1350
|
+
const method = config?.method ?? methodIdForSourcePreparationConfig(preparation);
|
|
1928
1351
|
return PortableContextResourceSchema.parse({
|
|
1929
|
-
preparation:
|
|
1352
|
+
preparation: preparation.name,
|
|
1930
1353
|
path,
|
|
1931
1354
|
exists: existsSync(path),
|
|
1932
1355
|
readiness,
|
|
@@ -1937,10 +1360,11 @@ export class LocalServiceRuntime {
|
|
|
1937
1360
|
});
|
|
1938
1361
|
}
|
|
1939
1362
|
listCompileRuns() {
|
|
1940
|
-
return newestCompileFirst(
|
|
1363
|
+
return newestCompileFirst(listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath))
|
|
1364
|
+
.flatMap((preparation) => this.listCompileRunsForPreparation(preparation.name))).map((run) => CompileRunResourceSchema.parse({ run }));
|
|
1941
1365
|
}
|
|
1942
|
-
|
|
1943
|
-
const compiledPath = portableContextPath(this.rootPath,
|
|
1366
|
+
listCompileRunsForPreparation(preparationName) {
|
|
1367
|
+
const compiledPath = portableContextPath(this.rootPath, preparationName);
|
|
1944
1368
|
return newestCompileFirst(listJsonFiles(compileRunsRoot(compiledPath))
|
|
1945
1369
|
.map(readCompileRunAt)
|
|
1946
1370
|
.filter((run) => run !== null));
|
|
@@ -1971,47 +1395,50 @@ export class LocalServiceRuntime {
|
|
|
1971
1395
|
}
|
|
1972
1396
|
async createCompileRun(requestValue) {
|
|
1973
1397
|
const request = CompileRunCreateRequestSchema.parse(requestValue);
|
|
1974
|
-
const
|
|
1398
|
+
const preparationConfig = this.resolvePreparationConfig(request.preparation, {
|
|
1975
1399
|
method: request.method,
|
|
1976
1400
|
max_attempts: request.max_attempts,
|
|
1977
1401
|
max_loops: request.max_loops,
|
|
1978
1402
|
});
|
|
1979
|
-
const compiledPath = this.ensureCompiledForRun(
|
|
1403
|
+
const compiledPath = this.ensureCompiledForRun(preparationConfig);
|
|
1980
1404
|
const runId = createRunId("compile");
|
|
1981
1405
|
const now = new Date().toISOString();
|
|
1982
|
-
const
|
|
1406
|
+
const method = getCompiledMethod(methodIdForSourcePreparationConfig(preparationConfig) ?? DEFAULT_METHOD_ID, {
|
|
1983
1407
|
sourcePath: this.rootPath,
|
|
1984
1408
|
});
|
|
1985
|
-
const stageTotal =
|
|
1409
|
+
const stageTotal = method.stages.length;
|
|
1986
1410
|
const run = CompileRunSchema.parse({
|
|
1987
1411
|
kind: "interf-compile-run",
|
|
1988
1412
|
version: 1,
|
|
1989
1413
|
run_id: runId,
|
|
1990
1414
|
status: "running",
|
|
1991
|
-
preparation:
|
|
1992
|
-
method:
|
|
1415
|
+
preparation: preparationConfig.name,
|
|
1416
|
+
method: method.id,
|
|
1993
1417
|
backend: "native",
|
|
1994
|
-
source_path:
|
|
1418
|
+
source_path: resolveSourcePreparationPath(this.rootPath, preparationConfig),
|
|
1995
1419
|
portable_context_path: compiledPath,
|
|
1996
1420
|
created_at: now,
|
|
1997
1421
|
started_at: now,
|
|
1998
|
-
stages:
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
stage_total: stageTotal,
|
|
2004
|
-
status: "queued",
|
|
2005
|
-
contract: {
|
|
1422
|
+
stages: method.stages
|
|
1423
|
+
.map((stage, index) => {
|
|
1424
|
+
return {
|
|
1425
|
+
run_id: runId,
|
|
1426
|
+
stage_id: stage.id,
|
|
2006
1427
|
stage_label: stage.label,
|
|
2007
1428
|
stage_index: index,
|
|
2008
1429
|
stage_total: stageTotal,
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
1430
|
+
status: "queued",
|
|
1431
|
+
contract: {
|
|
1432
|
+
stage_label: stage.label,
|
|
1433
|
+
stage_index: index,
|
|
1434
|
+
stage_total: stageTotal,
|
|
1435
|
+
reads: stage.reads,
|
|
1436
|
+
writes: stage.writes,
|
|
1437
|
+
...(stage.acceptance ? { acceptance: stage.acceptance } : {}),
|
|
1438
|
+
},
|
|
1439
|
+
artifacts: [],
|
|
1440
|
+
};
|
|
1441
|
+
}),
|
|
2015
1442
|
events: [],
|
|
2016
1443
|
});
|
|
2017
1444
|
this.writeCompileRun(compiledPath, run);
|
|
@@ -2020,8 +1447,8 @@ export class LocalServiceRuntime {
|
|
|
2020
1447
|
event_id: createRunEventId("event"),
|
|
2021
1448
|
run_id: runId,
|
|
2022
1449
|
timestamp: now,
|
|
2023
|
-
preparation:
|
|
2024
|
-
method:
|
|
1450
|
+
preparation: preparationConfig.name,
|
|
1451
|
+
method: method.id,
|
|
2025
1452
|
portable_context_path: compiledPath,
|
|
2026
1453
|
backend: "native",
|
|
2027
1454
|
});
|
|
@@ -2032,17 +1459,18 @@ export class LocalServiceRuntime {
|
|
|
2032
1459
|
runId,
|
|
2033
1460
|
sourcePath: this.rootPath,
|
|
2034
1461
|
compiledPath,
|
|
2035
|
-
|
|
1462
|
+
preparationConfig,
|
|
2036
1463
|
events: sink,
|
|
2037
1464
|
});
|
|
2038
1465
|
const saved = this.readCompileRun(compiledPath, runId) ?? run;
|
|
2039
1466
|
return CompileRunResourceSchema.parse({ run: saved });
|
|
2040
1467
|
}
|
|
2041
1468
|
listTestRuns() {
|
|
2042
|
-
return newestFirst(
|
|
1469
|
+
return newestFirst(listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath))
|
|
1470
|
+
.flatMap((preparation) => this.listTestRunsForPreparation(preparation.name)));
|
|
2043
1471
|
}
|
|
2044
|
-
|
|
2045
|
-
const compiledPath = portableContextPath(this.rootPath,
|
|
1472
|
+
listTestRunsForPreparation(preparationName) {
|
|
1473
|
+
const compiledPath = portableContextPath(this.rootPath, preparationName);
|
|
2046
1474
|
return newestFirst(listJsonFiles(testRunsRoot(compiledPath))
|
|
2047
1475
|
.map(readTestRunAt)
|
|
2048
1476
|
.filter((run) => run !== null));
|
|
@@ -2052,15 +1480,15 @@ export class LocalServiceRuntime {
|
|
|
2052
1480
|
}
|
|
2053
1481
|
async createTestRun(requestValue) {
|
|
2054
1482
|
const request = TestRunCreateRequestSchema.parse(requestValue);
|
|
2055
|
-
const
|
|
2056
|
-
const compiledPath = portableContextPath(this.rootPath,
|
|
2057
|
-
const compiledTarget = createCompiledTestTarget(compiledPath,
|
|
1483
|
+
const preparationConfig = this.resolvePreparationConfig(request.preparation);
|
|
1484
|
+
const compiledPath = portableContextPath(this.rootPath, preparationConfig.name);
|
|
1485
|
+
const compiledTarget = createCompiledTestTarget(compiledPath, preparationConfig.name, methodIdForSourcePreparationConfig(preparationConfig) ?? DEFAULT_METHOD_ID);
|
|
2058
1486
|
const runId = createRunId("test");
|
|
2059
1487
|
const now = new Date().toISOString();
|
|
2060
1488
|
const initial = TestRunResourceSchema.parse({
|
|
2061
1489
|
run_id: runId,
|
|
2062
1490
|
status: "running",
|
|
2063
|
-
preparation:
|
|
1491
|
+
preparation: preparationConfig.name,
|
|
2064
1492
|
mode: request.mode,
|
|
2065
1493
|
source_path: this.rootPath,
|
|
2066
1494
|
portable_context_path: compiledTarget.eligible ? compiledPath : null,
|
|
@@ -2073,7 +1501,7 @@ export class LocalServiceRuntime {
|
|
|
2073
1501
|
runId,
|
|
2074
1502
|
sourcePath: this.rootPath,
|
|
2075
1503
|
compiledPath,
|
|
2076
|
-
|
|
1504
|
+
preparationConfig,
|
|
2077
1505
|
}, initial);
|
|
2078
1506
|
return initial;
|
|
2079
1507
|
}
|
|
@@ -2120,7 +1548,7 @@ export class LocalServiceRuntime {
|
|
|
2120
1548
|
throw new Error("No test-run handler is configured for this local service.");
|
|
2121
1549
|
}
|
|
2122
1550
|
const result = LocalRunHandlerResultSchema.parse(await this.handlers.createTestRun(request, context));
|
|
2123
|
-
const comparison = this.readLatestComparison(context.
|
|
1551
|
+
const comparison = result.comparison ?? this.readLatestComparison(context.preparationConfig.name);
|
|
2124
1552
|
const resultEvent = comparison
|
|
2125
1553
|
? this.checksEvaluatedEvent(context.runId, comparison)
|
|
2126
1554
|
: null;
|
|
@@ -2133,13 +1561,13 @@ export class LocalServiceRuntime {
|
|
|
2133
1561
|
...(!result.ok ? { error: result.error ?? "Readiness check failed." } : {}),
|
|
2134
1562
|
});
|
|
2135
1563
|
this.writeTestRun(context.compiledPath, nextWithoutReadiness);
|
|
2136
|
-
const readiness = this.
|
|
1564
|
+
const readiness = this.computePreparationReadiness(context.preparationConfig);
|
|
2137
1565
|
const next = TestRunResourceSchema.parse({
|
|
2138
1566
|
...nextWithoutReadiness,
|
|
2139
1567
|
readiness,
|
|
2140
1568
|
events: [
|
|
2141
1569
|
...nextWithoutReadiness.events,
|
|
2142
|
-
this.readinessUpdatedEvent(context.runId, context.
|
|
1570
|
+
this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, readiness),
|
|
2143
1571
|
],
|
|
2144
1572
|
});
|
|
2145
1573
|
this.writeTestRun(context.compiledPath, next);
|
|
@@ -2152,11 +1580,11 @@ export class LocalServiceRuntime {
|
|
|
2152
1580
|
error: error instanceof Error ? error.message : String(error),
|
|
2153
1581
|
});
|
|
2154
1582
|
this.writeTestRun(context.compiledPath, failedWithoutReadiness);
|
|
2155
|
-
const readiness = this.
|
|
1583
|
+
const readiness = this.computePreparationReadiness(context.preparationConfig);
|
|
2156
1584
|
const next = TestRunResourceSchema.parse({
|
|
2157
1585
|
...failedWithoutReadiness,
|
|
2158
1586
|
readiness,
|
|
2159
|
-
events: [this.readinessUpdatedEvent(context.runId, context.
|
|
1587
|
+
events: [this.readinessUpdatedEvent(context.runId, context.preparationConfig.name, readiness)],
|
|
2160
1588
|
});
|
|
2161
1589
|
this.writeTestRun(context.compiledPath, next);
|
|
2162
1590
|
}
|
|
@@ -2213,12 +1641,12 @@ export class LocalServiceRuntime {
|
|
|
2213
1641
|
});
|
|
2214
1642
|
}
|
|
2215
1643
|
}
|
|
2216
|
-
async
|
|
1644
|
+
async runMethodAuthoringInBackground(request, runId) {
|
|
2217
1645
|
try {
|
|
2218
|
-
if (!this.handlers.
|
|
1646
|
+
if (!this.handlers.createMethodAuthoringRun) {
|
|
2219
1647
|
throw new Error("No Method-authoring handler is configured for this local service.");
|
|
2220
1648
|
}
|
|
2221
|
-
const result =
|
|
1649
|
+
const result = MethodAuthoringResultSchema.parse(await this.handlers.createMethodAuthoringRun(request, this.jobRunContext(runId)));
|
|
2222
1650
|
this.setJobRunResult(runId, result);
|
|
2223
1651
|
this.appendJobRunEvent(runId, {
|
|
2224
1652
|
type: result.status === "executor-failed" ? "step.failed" : "step.completed",
|
|
@@ -2295,12 +1723,12 @@ export class LocalServiceRuntime {
|
|
|
2295
1723
|
},
|
|
2296
1724
|
};
|
|
2297
1725
|
}
|
|
2298
|
-
|
|
2299
|
-
const
|
|
2300
|
-
if (!
|
|
1726
|
+
defaultPreparationName() {
|
|
1727
|
+
const preparation = listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath))[0];
|
|
1728
|
+
if (!preparation) {
|
|
2301
1729
|
throw new Error("No Preparation is saved in this control plane folder.");
|
|
2302
1730
|
}
|
|
2303
|
-
return
|
|
1731
|
+
return preparation.name;
|
|
2304
1732
|
}
|
|
2305
1733
|
async planActionProposal(request) {
|
|
2306
1734
|
if (!this.handlers.planActionProposal) {
|
|
@@ -2310,17 +1738,17 @@ export class LocalServiceRuntime {
|
|
|
2310
1738
|
assistant_message: "No local action planner is configured for this Interf Workspace.",
|
|
2311
1739
|
});
|
|
2312
1740
|
}
|
|
2313
|
-
const
|
|
1741
|
+
const preparations = listSourcePreparationConfigs(loadSourceFolderConfig(this.rootPath));
|
|
2314
1742
|
let rawPlan;
|
|
2315
1743
|
try {
|
|
2316
1744
|
rawPlan = await this.handlers.planActionProposal(request, {
|
|
2317
1745
|
sourcePath: this.rootPath,
|
|
2318
|
-
|
|
2319
|
-
preparationHealth:
|
|
2320
|
-
const readinessChecks =
|
|
2321
|
-
const portableContextReady = hasCompiledTestTarget(this.rootPath,
|
|
1746
|
+
preparations,
|
|
1747
|
+
preparationHealth: preparations.map((preparation) => {
|
|
1748
|
+
const readinessChecks = preparation.checks?.length ?? 0;
|
|
1749
|
+
const portableContextReady = hasCompiledTestTarget(this.rootPath, preparation);
|
|
2322
1750
|
return {
|
|
2323
|
-
name:
|
|
1751
|
+
name: preparation.name,
|
|
2324
1752
|
readiness_checks: readinessChecks,
|
|
2325
1753
|
portable_context_ready: portableContextReady,
|
|
2326
1754
|
can_check_readiness: readinessChecks > 0 && portableContextReady,
|
|
@@ -2342,7 +1770,7 @@ export class LocalServiceRuntime {
|
|
|
2342
1770
|
assistant_message: ACTION_PLANNER_CLARIFICATION_MESSAGE,
|
|
2343
1771
|
});
|
|
2344
1772
|
}
|
|
2345
|
-
const parsed = ActionProposalPlanSchema.safeParse(rawPlan);
|
|
1773
|
+
const parsed = ActionProposalPlanSchema.safeParse(sanitizeActionProposalPlan(rawPlan));
|
|
2346
1774
|
if (parsed.success)
|
|
2347
1775
|
return parsed.data;
|
|
2348
1776
|
return ActionProposalPlanSchema.parse({
|
|
@@ -2351,9 +1779,9 @@ export class LocalServiceRuntime {
|
|
|
2351
1779
|
assistant_message: ACTION_PLANNER_CLARIFICATION_MESSAGE,
|
|
2352
1780
|
});
|
|
2353
1781
|
}
|
|
2354
|
-
|
|
1782
|
+
buildPreparationSetupRequest(request, plan, values) {
|
|
2355
1783
|
const sourceFolderChoices = listSourceFolderChoices(this.rootPath);
|
|
2356
|
-
const selectedPath =
|
|
1784
|
+
const selectedPath = preparationSetupPathValue(values) ??
|
|
2357
1785
|
(sourceFolderChoices.length === 1 ? sourceFolderChoices[0].value : null);
|
|
2358
1786
|
if (!selectedPath) {
|
|
2359
1787
|
return {
|
|
@@ -2362,30 +1790,30 @@ export class LocalServiceRuntime {
|
|
|
2362
1790
|
}
|
|
2363
1791
|
let normalizedPath;
|
|
2364
1792
|
try {
|
|
2365
|
-
normalizedPath =
|
|
1793
|
+
normalizedPath = normalizeSourcePreparationPathForConfig(this.rootPath, selectedPath);
|
|
2366
1794
|
}
|
|
2367
1795
|
catch (error) {
|
|
2368
1796
|
return {
|
|
2369
1797
|
error: error instanceof Error ? error.message : String(error),
|
|
2370
1798
|
};
|
|
2371
1799
|
}
|
|
2372
|
-
const explicitName =
|
|
2373
|
-
const
|
|
1800
|
+
const explicitName = preparationSetupNameValue(values) ?? plan.preparation ?? request.preparation;
|
|
1801
|
+
const preparationName = explicitName
|
|
2374
1802
|
? slugFromText(explicitName)
|
|
2375
|
-
:
|
|
2376
|
-
const
|
|
2377
|
-
const
|
|
2378
|
-
const
|
|
1803
|
+
: defaultPreparationNameForPath(normalizedPath);
|
|
1804
|
+
const requestMethodId = stringValue(request.values, "method");
|
|
1805
|
+
const valueMethodId = stringValue(values, "method");
|
|
1806
|
+
const methodId = requestMethodId ?? plan.method ?? valueMethodId ?? "interf-default";
|
|
2379
1807
|
try {
|
|
2380
1808
|
return {
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
request:
|
|
1809
|
+
preparationName,
|
|
1810
|
+
methodId,
|
|
1811
|
+
request: PreparationSetupCreateRequestSchema.parse({
|
|
2384
1812
|
preparation: {
|
|
2385
|
-
name:
|
|
1813
|
+
name: preparationName,
|
|
2386
1814
|
path: normalizedPath,
|
|
2387
1815
|
about: stringValue(values, "about") ?? stringValue(values, "task_prompt") ?? request.message,
|
|
2388
|
-
method:
|
|
1816
|
+
method: methodId,
|
|
2389
1817
|
checks: [],
|
|
2390
1818
|
},
|
|
2391
1819
|
}),
|
|
@@ -2433,7 +1861,7 @@ export class LocalServiceRuntime {
|
|
|
2433
1861
|
...(request.values ?? {}),
|
|
2434
1862
|
};
|
|
2435
1863
|
if (actionType === "preparation-setup") {
|
|
2436
|
-
const setup = this.
|
|
1864
|
+
const setup = this.buildPreparationSetupRequest(request, plan, proposalValues);
|
|
2437
1865
|
if ("error" in setup) {
|
|
2438
1866
|
return ActionProposalResourceSchema.parse({
|
|
2439
1867
|
kind: "interf-action-proposal",
|
|
@@ -2461,7 +1889,7 @@ export class LocalServiceRuntime {
|
|
|
2461
1889
|
});
|
|
2462
1890
|
}
|
|
2463
1891
|
const commandPreview = plan.command_preview ??
|
|
2464
|
-
actionCommandPreview(actionType, setup.
|
|
1892
|
+
actionCommandPreview(actionType, setup.preparationName, setup.methodId, {
|
|
2465
1893
|
...proposalValues,
|
|
2466
1894
|
path: setup.request.preparation.path,
|
|
2467
1895
|
});
|
|
@@ -2471,13 +1899,13 @@ export class LocalServiceRuntime {
|
|
|
2471
1899
|
proposal_id: createActionProposalId(),
|
|
2472
1900
|
status: "awaiting_approval",
|
|
2473
1901
|
action_type: actionType,
|
|
2474
|
-
title: plan.title ?? `Create Preparation ${setup.
|
|
1902
|
+
title: plan.title ?? `Create Preparation ${setup.preparationName}`,
|
|
2475
1903
|
summary: plan.summary ?? "Save this source folder as an Interf Preparation.",
|
|
2476
|
-
assistant_message: plan.assistant_message ?? actionAssistantMessage(actionType, setup.
|
|
1904
|
+
assistant_message: plan.assistant_message ?? actionAssistantMessage(actionType, setup.preparationName, commandPreview),
|
|
2477
1905
|
command_preview: commandPreview,
|
|
2478
1906
|
message: request.message,
|
|
2479
|
-
preparation: setup.
|
|
2480
|
-
method: setup.
|
|
1907
|
+
preparation: setup.preparationName,
|
|
1908
|
+
method: setup.methodId,
|
|
2481
1909
|
request: setup.request,
|
|
2482
1910
|
created_at: now,
|
|
2483
1911
|
updated_at: now,
|
|
@@ -2488,18 +1916,16 @@ export class LocalServiceRuntime {
|
|
|
2488
1916
|
error: null,
|
|
2489
1917
|
});
|
|
2490
1918
|
}
|
|
2491
|
-
const
|
|
2492
|
-
const
|
|
2493
|
-
const
|
|
2494
|
-
stringValue(request.values, "method")
|
|
2495
|
-
|
|
2496
|
-
const plannedWorkflowId = plan.method ??
|
|
1919
|
+
const preparationConfig = this.resolvePreparationConfig(plan.preparation ?? request.preparation ?? this.defaultPreparationName());
|
|
1920
|
+
const preparationPath = resolveSourcePreparationPath(this.rootPath, preparationConfig);
|
|
1921
|
+
const requestedMethodId = stringValue(request.values, "method_id") ??
|
|
1922
|
+
stringValue(request.values, "method");
|
|
1923
|
+
const plannedMethodId = plan.method ??
|
|
2497
1924
|
stringValue(plan.values, "method_id") ??
|
|
2498
|
-
stringValue(plan.values, "method")
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
: requestedWorkflowId ?? plannedWorkflowId ?? methodIdForSourcePreparationConfig(datasetConfig);
|
|
1925
|
+
stringValue(plan.values, "method");
|
|
1926
|
+
const methodId = actionType === "method-authoring"
|
|
1927
|
+
? requestedMethodId ?? plannedMethodId ?? methodIdForProposal(request.message, proposalValues)
|
|
1928
|
+
: requestedMethodId ?? plannedMethodId ?? methodIdForSourcePreparationConfig(preparationConfig);
|
|
2503
1929
|
const clarifyResolvedAction = (options) => ActionProposalResourceSchema.parse({
|
|
2504
1930
|
kind: "interf-action-proposal",
|
|
2505
1931
|
version: 1,
|
|
@@ -2510,8 +1936,8 @@ export class LocalServiceRuntime {
|
|
|
2510
1936
|
summary: options.summary,
|
|
2511
1937
|
assistant_message: options.assistantMessage,
|
|
2512
1938
|
message: request.message,
|
|
2513
|
-
preparation:
|
|
2514
|
-
method:
|
|
1939
|
+
preparation: preparationConfig.name,
|
|
1940
|
+
method: methodId ?? null,
|
|
2515
1941
|
request: {
|
|
2516
1942
|
message: request.message,
|
|
2517
1943
|
...(proposalValues ? { values: proposalValues } : {}),
|
|
@@ -2526,65 +1952,65 @@ export class LocalServiceRuntime {
|
|
|
2526
1952
|
});
|
|
2527
1953
|
if (actionType === "test") {
|
|
2528
1954
|
const requestedMode = testModeFromValues(proposalValues);
|
|
2529
|
-
const hasReadinessChecks = (
|
|
2530
|
-
const portableContextReady = hasCompiledTestTarget(this.rootPath,
|
|
1955
|
+
const hasReadinessChecks = (preparationConfig.checks ?? []).length > 0;
|
|
1956
|
+
const portableContextReady = hasCompiledTestTarget(this.rootPath, preparationConfig);
|
|
2531
1957
|
if (!hasReadinessChecks) {
|
|
2532
1958
|
return clarifyResolvedAction({
|
|
2533
|
-
title: `Add readiness checks for ${
|
|
1959
|
+
title: `Add readiness checks for ${preparationConfig.name}`,
|
|
2534
1960
|
summary: "Readiness cannot be checked until this Preparation has saved checks.",
|
|
2535
|
-
assistantMessage: `Preparation "${
|
|
1961
|
+
assistantMessage: `Preparation "${preparationConfig.name}" does not have saved readiness checks yet. Ask me to draft readiness checks after the Source Folder is prepared, or add readiness guidance first.`,
|
|
2536
1962
|
});
|
|
2537
1963
|
}
|
|
2538
1964
|
if (!portableContextReady && requestedMode !== "raw") {
|
|
2539
1965
|
return clarifyResolvedAction({
|
|
2540
|
-
title: `Prepare ${
|
|
1966
|
+
title: `Prepare ${preparationConfig.name} first`,
|
|
2541
1967
|
summary: "Readiness checks need portable context unless you explicitly ask for a source-files-only baseline.",
|
|
2542
|
-
assistantMessage: `Preparation "${
|
|
1968
|
+
assistantMessage: `Preparation "${preparationConfig.name}" has no prepared portable context yet. Prepare it first; after that Interf can check readiness. If you specifically want a source-files-only baseline, ask for source files only.`,
|
|
2543
1969
|
});
|
|
2544
1970
|
}
|
|
2545
1971
|
}
|
|
2546
1972
|
const actionRequest = (() => {
|
|
2547
1973
|
if (actionType === "compile") {
|
|
2548
1974
|
return {
|
|
2549
|
-
preparation:
|
|
2550
|
-
...(
|
|
1975
|
+
preparation: preparationConfig.name,
|
|
1976
|
+
...(methodId ? { method: methodId } : {}),
|
|
2551
1977
|
};
|
|
2552
1978
|
}
|
|
2553
1979
|
if (actionType === "test") {
|
|
2554
|
-
const defaultMode = hasCompiledTestTarget(this.rootPath,
|
|
1980
|
+
const defaultMode = hasCompiledTestTarget(this.rootPath, preparationConfig) ? "both" : "raw";
|
|
2555
1981
|
return {
|
|
2556
|
-
preparation:
|
|
1982
|
+
preparation: preparationConfig.name,
|
|
2557
1983
|
mode: testModeValue(proposalValues, defaultMode),
|
|
2558
1984
|
};
|
|
2559
1985
|
}
|
|
2560
1986
|
if (actionType === "readiness-check-draft") {
|
|
2561
1987
|
return {
|
|
2562
|
-
preparation:
|
|
2563
|
-
source_folder_path:
|
|
2564
|
-
about: stringValue(proposalValues, "about") ??
|
|
1988
|
+
preparation: preparationConfig.name,
|
|
1989
|
+
source_folder_path: preparationPath,
|
|
1990
|
+
about: stringValue(proposalValues, "about") ?? preparationConfig.about ?? request.message,
|
|
2565
1991
|
target_count: Math.max(1, Math.min(8, Math.round(numberValue(proposalValues, "target_count") ?? 4))),
|
|
2566
1992
|
};
|
|
2567
1993
|
}
|
|
2568
1994
|
return {
|
|
2569
|
-
preparation:
|
|
2570
|
-
source_folder_path:
|
|
2571
|
-
method_id:
|
|
2572
|
-
label: stringValue(proposalValues, "label") ?? `Custom ${
|
|
1995
|
+
preparation: preparationConfig.name,
|
|
1996
|
+
source_folder_path: preparationPath,
|
|
1997
|
+
method_id: methodId,
|
|
1998
|
+
label: stringValue(proposalValues, "label") ?? `Custom ${preparationConfig.name}`,
|
|
2573
1999
|
hint: stringValue(proposalValues, "hint") ?? request.message,
|
|
2574
2000
|
task_prompt: actionValueMethodTaskPrompt(proposalValues) ?? stringValue(proposalValues, "task_prompt") ?? request.message,
|
|
2575
|
-
checks:
|
|
2001
|
+
checks: preparationConfig.checks ?? [],
|
|
2576
2002
|
};
|
|
2577
2003
|
})();
|
|
2578
2004
|
const title = (() => {
|
|
2579
2005
|
if (plan.title)
|
|
2580
2006
|
return plan.title;
|
|
2581
2007
|
if (actionType === "compile")
|
|
2582
|
-
return `Prepare ${
|
|
2008
|
+
return `Prepare ${preparationConfig.name}`;
|
|
2583
2009
|
if (actionType === "test")
|
|
2584
|
-
return `Check readiness for ${
|
|
2010
|
+
return `Check readiness for ${preparationConfig.name}`;
|
|
2585
2011
|
if (actionType === "readiness-check-draft")
|
|
2586
|
-
return `Draft readiness checks for ${
|
|
2587
|
-
return `Draft Method ${
|
|
2012
|
+
return `Draft readiness checks for ${preparationConfig.name}`;
|
|
2013
|
+
return `Draft Method ${methodId}`;
|
|
2588
2014
|
})();
|
|
2589
2015
|
const summary = (() => {
|
|
2590
2016
|
if (plan.summary)
|
|
@@ -2600,7 +2026,7 @@ export class LocalServiceRuntime {
|
|
|
2600
2026
|
const previewValues = actionType === "test"
|
|
2601
2027
|
? { mode: actionRequest.mode }
|
|
2602
2028
|
: proposalValues;
|
|
2603
|
-
const commandPreview = plan.command_preview ?? actionCommandPreview(actionType,
|
|
2029
|
+
const commandPreview = plan.command_preview ?? actionCommandPreview(actionType, preparationConfig.name, methodId, previewValues);
|
|
2604
2030
|
return ActionProposalResourceSchema.parse({
|
|
2605
2031
|
kind: "interf-action-proposal",
|
|
2606
2032
|
version: 1,
|
|
@@ -2609,11 +2035,11 @@ export class LocalServiceRuntime {
|
|
|
2609
2035
|
action_type: actionType,
|
|
2610
2036
|
title,
|
|
2611
2037
|
summary,
|
|
2612
|
-
assistant_message: plan.assistant_message ?? actionAssistantMessage(actionType,
|
|
2038
|
+
assistant_message: plan.assistant_message ?? actionAssistantMessage(actionType, preparationConfig.name, commandPreview),
|
|
2613
2039
|
command_preview: commandPreview,
|
|
2614
2040
|
message: request.message,
|
|
2615
|
-
preparation:
|
|
2616
|
-
method:
|
|
2041
|
+
preparation: preparationConfig.name,
|
|
2042
|
+
method: methodId,
|
|
2617
2043
|
request: actionRequest,
|
|
2618
2044
|
created_at: now,
|
|
2619
2045
|
updated_at: now,
|
|
@@ -2643,7 +2069,7 @@ export class LocalServiceRuntime {
|
|
|
2643
2069
|
};
|
|
2644
2070
|
}
|
|
2645
2071
|
if (proposal.action_type === "preparation-setup") {
|
|
2646
|
-
const job = await this.
|
|
2072
|
+
const job = await this.createPreparationSetupRun(proposal.request);
|
|
2647
2073
|
return {
|
|
2648
2074
|
runId: job.run_id,
|
|
2649
2075
|
runType: "job-run",
|
|
@@ -2656,29 +2082,29 @@ export class LocalServiceRuntime {
|
|
|
2656
2082
|
runType: "job-run",
|
|
2657
2083
|
};
|
|
2658
2084
|
}
|
|
2659
|
-
const job = await this.
|
|
2085
|
+
const job = await this.createMethodAuthoringRun(proposal.request);
|
|
2660
2086
|
return {
|
|
2661
2087
|
runId: job.run_id,
|
|
2662
2088
|
runType: "job-run",
|
|
2663
2089
|
};
|
|
2664
2090
|
}
|
|
2665
|
-
|
|
2666
|
-
const
|
|
2667
|
-
if (!
|
|
2668
|
-
throw new Error(`Preparation "${
|
|
2091
|
+
resolvePreparationConfig(preparationName, overrides = {}) {
|
|
2092
|
+
const preparation = findSourcePreparationConfig(loadSourceFolderConfig(this.rootPath), preparationName);
|
|
2093
|
+
if (!preparation) {
|
|
2094
|
+
throw new Error(`Preparation "${preparationName}" is not saved in this control plane folder.`);
|
|
2669
2095
|
}
|
|
2670
|
-
const method = overrides.method ??
|
|
2096
|
+
const method = overrides.method ?? methodIdForSourcePreparationConfig(preparation) ?? undefined;
|
|
2671
2097
|
return {
|
|
2672
|
-
...
|
|
2098
|
+
...preparation,
|
|
2673
2099
|
...(method ? { method } : {}),
|
|
2674
2100
|
...(typeof overrides.max_attempts === "number" ? { max_attempts: overrides.max_attempts } : {}),
|
|
2675
2101
|
...(typeof overrides.max_loops === "number" ? { max_loops: overrides.max_loops } : {}),
|
|
2676
2102
|
};
|
|
2677
2103
|
}
|
|
2678
|
-
ensureCompiledForRun(
|
|
2679
|
-
const
|
|
2680
|
-
const compiledPath = ensurePortableContextScaffold(this.rootPath,
|
|
2681
|
-
|
|
2104
|
+
ensureCompiledForRun(preparationConfig) {
|
|
2105
|
+
const methodId = methodIdForSourcePreparationConfig(preparationConfig) ?? DEFAULT_METHOD_ID;
|
|
2106
|
+
const compiledPath = ensurePortableContextScaffold(this.rootPath, preparationConfig.name, methodId);
|
|
2107
|
+
syncCompiledInterfConfigFromSourcePreparationConfig(compiledPath, preparationConfig);
|
|
2682
2108
|
return compiledPath;
|
|
2683
2109
|
}
|
|
2684
2110
|
readCompileRun(compiledPath, runId) {
|
|
@@ -2802,12 +2228,8 @@ export class LocalServiceRuntime {
|
|
|
2802
2228
|
});
|
|
2803
2229
|
}
|
|
2804
2230
|
}
|
|
2805
|
-
readLatestComparison(
|
|
2806
|
-
|
|
2807
|
-
if (!existsSync(latestPath))
|
|
2808
|
-
return null;
|
|
2809
|
-
const parsed = TestRunComparisonSchema.safeParse(readJsonFile(latestPath));
|
|
2810
|
-
return parsed.success ? parsed.data : null;
|
|
2231
|
+
readLatestComparison(preparationName) {
|
|
2232
|
+
return readSavedReadinessCheckRun(this.rootPath, preparationName);
|
|
2811
2233
|
}
|
|
2812
2234
|
checksEvaluatedEvent(runId, comparison) {
|
|
2813
2235
|
const target = comparison.compiled ?? comparison.raw;
|