@interf/compiler 0.7.2 → 0.9.1
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 +141 -99
- package/TRADEMARKS.md +1 -1
- package/agent-skills/interf-actions/SKILL.md +71 -0
- package/agent-skills/interf-actions/references/cli.md +190 -0
- package/apps/compiler-ui/.next/server/app/index.html +1 -0
- package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_buildManifest.js +11 -0
- package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_clientMiddlewareManifest.js +1 -0
- package/apps/compiler-ui/.next/static/XWKL548yXD_UOG4ID9G3J/_ssgManifest.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/03~yq9q893hmn.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/06z~l3kwb891e.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/08g7lvje.te.u.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/08m7vf5asqlsm.js +91 -0
- package/apps/compiler-ui/.next/static/chunks/0_i-3_5l9t2qe.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0b-ywny_j0g~0.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0b52v41o1gixx.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0fgt_8knmicoz.js +124 -0
- package/apps/compiler-ui/.next/static/chunks/0gpzgsv0w.q~m.js +31 -0
- package/apps/compiler-ui/.next/static/chunks/0ilwfezfvu6~-.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0n51hrfoufc7g.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/0ti_66mx7~w2-.js +5 -0
- package/apps/compiler-ui/.next/static/chunks/0xxmf45eskdt~.css +1 -0
- package/apps/compiler-ui/.next/static/chunks/0y5z3t-z1c8ks.js.map +5 -0
- package/apps/compiler-ui/.next/static/chunks/13g~4mamjft.c.css +3 -0
- package/apps/compiler-ui/.next/static/chunks/14wtz~vq25~qq.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/turbopack-109rtik40vwh5.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/turbopack-10e~t1yzi4svj.js +1 -0
- package/apps/compiler-ui/.next/static/chunks/turbopack-worker-0sjn--fhq~1cg.js +1 -0
- package/apps/compiler-ui/.next/static/media/GeistMono_Variable.p.17jn9btb_52pq.woff2 +0 -0
- package/apps/compiler-ui/.next/static/media/Geist_Variable-s.p.0-te~ja_gpvcf.woff2 +0 -0
- package/apps/compiler-ui/.next/static/media/worker.102zas1s52_pf.js +109 -0
- package/builtin-workflows/interf/README.md +8 -8
- package/builtin-workflows/interf/compile/stages/shape/SKILL.md +6 -6
- package/builtin-workflows/interf/compile/stages/structure/SKILL.md +1 -1
- package/builtin-workflows/interf/improve/SKILL.md +2 -2
- package/builtin-workflows/interf/use/query/SKILL.md +2 -2
- package/builtin-workflows/interf/workflow.json +9 -9
- package/builtin-workflows/interf/workflow.schema.json +2 -2
- package/dist/cli/commands/check-draft.d.ts +5 -4
- package/dist/cli/commands/check-draft.js +18 -17
- package/dist/cli/commands/compile-controller.d.ts +3 -0
- package/dist/cli/commands/compile-controller.js +53 -45
- package/dist/cli/commands/compile.js +83 -27
- package/dist/cli/commands/compiled-flow.d.ts +3 -0
- package/dist/cli/commands/compiled-flow.js +9 -7
- package/dist/cli/commands/control-path.d.ts +11 -0
- package/dist/cli/commands/control-path.js +72 -0
- package/dist/cli/commands/create-workflow-wizard.d.ts +12 -0
- package/dist/cli/commands/create-workflow-wizard.js +232 -66
- package/dist/cli/commands/create.js +70 -46
- package/dist/cli/commands/default.js +5 -3
- package/dist/cli/commands/doctor.js +5 -5
- package/dist/cli/commands/executor-flow.js +1 -1
- package/dist/cli/commands/init.js +362 -101
- package/dist/cli/commands/list.js +8 -7
- package/dist/cli/commands/preparation-selection.d.ts +6 -0
- package/dist/cli/commands/preparation-selection.js +11 -0
- package/dist/cli/commands/reset.js +3 -3
- package/dist/cli/commands/source-config-wizard.d.ts +4 -4
- package/dist/cli/commands/source-config-wizard.js +175 -200
- package/dist/cli/commands/status.js +116 -8
- package/dist/cli/commands/test-flow.d.ts +1 -1
- package/dist/cli/commands/test-flow.js +35 -33
- package/dist/cli/commands/test.d.ts +4 -0
- package/dist/cli/commands/test.js +95 -58
- package/dist/cli/commands/verify.js +7 -7
- package/dist/cli/commands/web.d.ts +11 -0
- package/dist/cli/commands/web.js +373 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +3 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/packages/agents/lib/execution.js +4 -2
- package/dist/packages/agents/lib/executors.d.ts +1 -0
- package/dist/packages/agents/lib/executors.js +1 -0
- package/dist/packages/agents/lib/render.d.ts +2 -2
- package/dist/packages/agents/lib/render.js +10 -9
- package/dist/packages/agents/lib/shells.d.ts +3 -11
- package/dist/packages/agents/lib/shells.js +58 -106
- package/dist/packages/agents/lib/types.d.ts +1 -0
- package/dist/packages/compiler/compiled-paths.d.ts +4 -1
- package/dist/packages/compiler/compiled-paths.js +8 -2
- package/dist/packages/compiler/compiled-pipeline.d.ts +7 -0
- package/dist/packages/compiler/compiled-pipeline.js +15 -4
- package/dist/packages/compiler/compiled-schema.js +1 -1
- package/dist/packages/compiler/compiled-stage-plan.d.ts +2 -2
- package/dist/packages/compiler/compiled-stage-plan.js +4 -4
- package/dist/packages/compiler/compiled-stage-runner.d.ts +5 -0
- package/dist/packages/compiler/compiled-stage-runner.js +50 -2
- package/dist/packages/compiler/compiled-target.d.ts +1 -1
- package/dist/packages/compiler/compiled-target.js +2 -2
- package/dist/packages/compiler/lib/schema.d.ts +161 -1
- package/dist/packages/compiler/lib/schema.js +87 -1
- package/dist/packages/compiler/raw-snapshot.d.ts +9 -2
- package/dist/packages/compiler/runtime-acceptance.js +1 -1
- package/dist/packages/compiler/runtime-contracts.js +2 -2
- package/dist/packages/compiler/runtime-prompt.js +7 -7
- package/dist/packages/compiler/runtime-reconcile.js +3 -3
- package/dist/packages/compiler/runtime-runs.js +3 -0
- package/dist/packages/compiler/runtime-types.d.ts +1 -0
- package/dist/packages/compiler/state-health.js +1 -1
- package/dist/packages/compiler/state-view.js +2 -2
- package/dist/packages/compiler/validate-compiled.js +11 -9
- package/dist/packages/execution/adapters.d.ts +15 -0
- package/dist/packages/execution/adapters.js +1 -0
- package/dist/packages/execution/events.d.ts +8 -0
- package/dist/packages/execution/events.js +16 -0
- package/dist/packages/execution/index.d.ts +9 -0
- package/dist/packages/execution/index.js +6 -0
- package/dist/packages/execution/lib/schema.d.ts +1554 -0
- package/dist/packages/execution/lib/schema.js +319 -0
- package/dist/packages/local-service/action-values.d.ts +23 -0
- package/dist/packages/local-service/action-values.js +31 -0
- package/dist/packages/local-service/client.d.ts +119 -0
- package/dist/packages/local-service/client.js +356 -0
- package/dist/packages/local-service/index.d.ts +15 -0
- package/dist/packages/local-service/index.js +11 -0
- package/dist/packages/local-service/lib/schema.d.ts +7355 -0
- package/dist/packages/local-service/lib/schema.js +636 -0
- package/dist/packages/local-service/routes.d.ts +27 -0
- package/dist/packages/local-service/routes.js +32 -0
- package/dist/packages/local-service/runtime.d.ts +134 -0
- package/dist/packages/local-service/runtime.js +2841 -0
- package/dist/packages/local-service/server.d.ts +17 -0
- package/dist/packages/local-service/server.js +572 -0
- package/dist/packages/project-model/index.d.ts +2 -1
- package/dist/packages/project-model/index.js +1 -0
- package/dist/packages/project-model/interf-detect.d.ts +6 -2
- package/dist/packages/project-model/interf-detect.js +48 -19
- package/dist/packages/project-model/interf-scaffold.d.ts +1 -0
- package/dist/packages/project-model/interf-scaffold.js +39 -17
- package/dist/packages/project-model/interf.d.ts +2 -2
- package/dist/packages/project-model/interf.js +2 -2
- package/dist/packages/project-model/lib/schema.d.ts +80 -6
- package/dist/packages/project-model/lib/schema.js +29 -19
- package/dist/packages/project-model/project-paths.d.ts +3 -1
- package/dist/packages/project-model/project-paths.js +6 -2
- package/dist/packages/project-model/source-config.d.ts +25 -11
- package/dist/packages/project-model/source-config.js +152 -82
- package/dist/packages/project-model/source-folders.d.ts +11 -0
- package/dist/packages/project-model/source-folders.js +110 -0
- package/dist/packages/testing/test-execution.js +5 -5
- package/dist/packages/testing/test-paths.js +4 -3
- package/dist/packages/workflow-authoring/workflow-authoring.d.ts +4 -6
- package/dist/packages/workflow-authoring/workflow-authoring.js +46 -85
- package/dist/packages/workflow-authoring/workflow-edit-session.d.ts +2 -0
- package/dist/packages/workflow-authoring/workflow-edit-session.js +83 -49
- package/dist/packages/workflow-authoring/workflow-improvement.js +2 -1
- package/dist/packages/workflow-package/context-interface.js +2 -2
- package/dist/packages/workflow-package/interf-workflow-package.d.ts +6 -0
- package/dist/packages/workflow-package/interf-workflow-package.js +115 -8
- package/dist/packages/workflow-package/local-workflows.js +33 -17
- package/dist/packages/workflow-package/workflow-definitions.d.ts +5 -5
- package/dist/packages/workflow-package/workflow-definitions.js +23 -22
- package/dist/packages/workflow-package/workflow-helpers.js +10 -6
- package/dist/packages/workflow-package/workflow-review-paths.js +5 -1
- package/dist/packages/workflow-package/workflow-stage-runner.d.ts +1 -0
- package/dist/packages/workflow-package/workflow-stage-runner.js +2 -0
- package/package.json +18 -4
- package/dist/cli/commands/dataset-selection.d.ts +0 -6
- package/dist/cli/commands/dataset-selection.js +0 -11
- package/dist/lib/agent-args.d.ts +0 -1
- package/dist/lib/agent-args.js +0 -1
- package/dist/lib/agent-constants.d.ts +0 -1
- package/dist/lib/agent-constants.js +0 -1
- package/dist/lib/agent-detection.d.ts +0 -1
- package/dist/lib/agent-detection.js +0 -1
- package/dist/lib/agent-execution.d.ts +0 -1
- package/dist/lib/agent-execution.js +0 -1
- package/dist/lib/agent-logs.d.ts +0 -1
- package/dist/lib/agent-logs.js +0 -1
- package/dist/lib/agent-preflight.d.ts +0 -1
- package/dist/lib/agent-preflight.js +0 -1
- package/dist/lib/agent-render.d.ts +0 -1
- package/dist/lib/agent-render.js +0 -1
- package/dist/lib/agent-shells.d.ts +0 -1
- package/dist/lib/agent-shells.js +0 -1
- package/dist/lib/agent-status.d.ts +0 -1
- package/dist/lib/agent-status.js +0 -1
- package/dist/lib/agent-types.d.ts +0 -1
- package/dist/lib/agent-types.js +0 -1
- package/dist/lib/agents.d.ts +0 -1
- package/dist/lib/agents.js +0 -1
- package/dist/lib/builtin-compiled-workflow.d.ts +0 -1
- package/dist/lib/builtin-compiled-workflow.js +0 -1
- package/dist/lib/chart-guidance.d.ts +0 -1
- package/dist/lib/chart-guidance.js +0 -1
- package/dist/lib/compiled-compile.d.ts +0 -1
- package/dist/lib/compiled-compile.js +0 -1
- package/dist/lib/compiled-paths.d.ts +0 -1
- package/dist/lib/compiled-paths.js +0 -3
- package/dist/lib/compiled-raw.d.ts +0 -1
- package/dist/lib/compiled-raw.js +0 -3
- package/dist/lib/compiled-reset.d.ts +0 -1
- package/dist/lib/compiled-reset.js +0 -3
- package/dist/lib/compiled-schema.d.ts +0 -1
- package/dist/lib/compiled-schema.js +0 -1
- package/dist/lib/discovery.d.ts +0 -1
- package/dist/lib/discovery.js +0 -1
- package/dist/lib/execution-profile.d.ts +0 -1
- package/dist/lib/execution-profile.js +0 -1
- package/dist/lib/executors.d.ts +0 -1
- package/dist/lib/executors.js +0 -1
- package/dist/lib/filesystem.d.ts +0 -1
- package/dist/lib/filesystem.js +0 -1
- package/dist/lib/interf-bootstrap.d.ts +0 -1
- package/dist/lib/interf-bootstrap.js +0 -3
- package/dist/lib/interf-detect.d.ts +0 -1
- package/dist/lib/interf-detect.js +0 -3
- package/dist/lib/interf-scaffold.d.ts +0 -1
- package/dist/lib/interf-scaffold.js +0 -3
- package/dist/lib/interf-workflow-package.d.ts +0 -1
- package/dist/lib/interf-workflow-package.js +0 -1
- package/dist/lib/interf.d.ts +0 -1
- package/dist/lib/interf.js +0 -3
- package/dist/lib/local-workflows.d.ts +0 -1
- package/dist/lib/local-workflows.js +0 -1
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +0 -1
- package/dist/lib/package-root.d.ts +0 -1
- package/dist/lib/package-root.js +0 -1
- package/dist/lib/parse.d.ts +0 -1
- package/dist/lib/parse.js +0 -1
- package/dist/lib/project-paths.d.ts +0 -1
- package/dist/lib/project-paths.js +0 -3
- package/dist/lib/runtime-acceptance.d.ts +0 -1
- package/dist/lib/runtime-acceptance.js +0 -1
- package/dist/lib/runtime-contracts.d.ts +0 -1
- package/dist/lib/runtime-contracts.js +0 -1
- package/dist/lib/runtime-inventory.d.ts +0 -1
- package/dist/lib/runtime-inventory.js +0 -1
- package/dist/lib/runtime-paths.d.ts +0 -1
- package/dist/lib/runtime-paths.js +0 -1
- package/dist/lib/runtime-prompt.d.ts +0 -1
- package/dist/lib/runtime-prompt.js +0 -1
- package/dist/lib/runtime-reconcile.d.ts +0 -1
- package/dist/lib/runtime-reconcile.js +0 -1
- package/dist/lib/runtime-runs.d.ts +0 -1
- package/dist/lib/runtime-runs.js +0 -1
- package/dist/lib/runtime-types.d.ts +0 -1
- package/dist/lib/runtime-types.js +0 -1
- package/dist/lib/runtime.d.ts +0 -1
- package/dist/lib/runtime.js +0 -1
- package/dist/lib/schema.d.ts +0 -4
- package/dist/lib/schema.js +0 -6
- package/dist/lib/source-config.d.ts +0 -1
- package/dist/lib/source-config.js +0 -3
- package/dist/lib/state-artifacts.d.ts +0 -1
- package/dist/lib/state-artifacts.js +0 -1
- package/dist/lib/state-health.d.ts +0 -1
- package/dist/lib/state-health.js +0 -1
- package/dist/lib/state-io.d.ts +0 -1
- package/dist/lib/state-io.js +0 -1
- package/dist/lib/state-paths.d.ts +0 -1
- package/dist/lib/state-paths.js +0 -1
- package/dist/lib/state-view.d.ts +0 -1
- package/dist/lib/state-view.js +0 -1
- package/dist/lib/state.d.ts +0 -1
- package/dist/lib/state.js +0 -1
- package/dist/lib/test-execution.d.ts +0 -1
- package/dist/lib/test-execution.js +0 -3
- package/dist/lib/test-matrices.d.ts +0 -1
- package/dist/lib/test-matrices.js +0 -3
- package/dist/lib/test-paths.d.ts +0 -1
- package/dist/lib/test-paths.js +0 -3
- package/dist/lib/test-profile-presets.d.ts +0 -1
- package/dist/lib/test-profile-presets.js +0 -3
- package/dist/lib/test-sandbox.d.ts +0 -1
- package/dist/lib/test-sandbox.js +0 -3
- package/dist/lib/test-specs.d.ts +0 -1
- package/dist/lib/test-specs.js +0 -3
- package/dist/lib/test-targets.d.ts +0 -1
- package/dist/lib/test-targets.js +0 -3
- package/dist/lib/test-types.d.ts +0 -1
- package/dist/lib/test-types.js +0 -3
- package/dist/lib/test.d.ts +0 -1
- package/dist/lib/test.js +0 -3
- package/dist/lib/util.d.ts +0 -1
- package/dist/lib/util.js +0 -1
- package/dist/lib/validate-compiled.d.ts +0 -1
- package/dist/lib/validate-compiled.js +0 -1
- package/dist/lib/validate-helpers.d.ts +0 -1
- package/dist/lib/validate-helpers.js +0 -1
- package/dist/lib/validate.d.ts +0 -1
- package/dist/lib/validate.js +0 -1
- package/dist/lib/workflow-authoring.d.ts +0 -1
- package/dist/lib/workflow-authoring.js +0 -1
- package/dist/lib/workflow-definitions.d.ts +0 -1
- package/dist/lib/workflow-definitions.js +0 -1
- package/dist/lib/workflow-edit-session.d.ts +0 -1
- package/dist/lib/workflow-edit-session.js +0 -1
- package/dist/lib/workflow-edit-utils.d.ts +0 -1
- package/dist/lib/workflow-edit-utils.js +0 -1
- package/dist/lib/workflow-helpers.d.ts +0 -1
- package/dist/lib/workflow-helpers.js +0 -1
- package/dist/lib/workflow-improvement.d.ts +0 -1
- package/dist/lib/workflow-improvement.js +0 -1
- package/dist/lib/workflow-primitives.d.ts +0 -1
- package/dist/lib/workflow-primitives.js +0 -1
- package/dist/lib/workflow-review-paths.d.ts +0 -1
- package/dist/lib/workflow-review-paths.js +0 -1
- package/dist/lib/workflow-stage-policy.d.ts +0 -1
- package/dist/lib/workflow-stage-policy.js +0 -1
- package/dist/lib/workflow-stage-runner.d.ts +0 -1
- package/dist/lib/workflow-stage-runner.js +0 -1
- package/dist/lib/workflows.d.ts +0 -1
- package/dist/lib/workflows.js +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Server } from "node:http";
|
|
2
|
+
import { type LocalServiceRunHandlers, type LocalServiceRuntime } from "./runtime.js";
|
|
3
|
+
export interface StartLocalServiceOptions {
|
|
4
|
+
rootPath?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
packageVersion?: string;
|
|
8
|
+
handlers?: Partial<LocalServiceRunHandlers>;
|
|
9
|
+
}
|
|
10
|
+
export interface StartedLocalService {
|
|
11
|
+
runtime: LocalServiceRuntime;
|
|
12
|
+
server: Server;
|
|
13
|
+
url: string;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function createLocalServiceServer(runtime: LocalServiceRuntime): Server;
|
|
17
|
+
export declare function startLocalService(options?: StartLocalServiceOptions): Promise<StartedLocalService>;
|
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
import { createServer } from "node:http";
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { dirname, extname, join, normalize, resolve, sep } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { LocalServiceConfigSchema, LocalServiceDiscoverySchema, LocalServiceInstancePointerSchema, OpenPathRequestSchema, RunCreateRequestSchema, } from "./lib/schema.js";
|
|
7
|
+
import { assertPathWithinRoot, } from "../shared/path-guards.js";
|
|
8
|
+
import { createLocalServiceRuntime, } from "./runtime.js";
|
|
9
|
+
import { LOCAL_SERVICE_DEFAULT_HOST, LOCAL_SERVICE_DEFAULT_PORT, LOCAL_SERVICE_INSTANCE_POINTER_PATH, LOCAL_SERVICE_ROUTES, } from "./routes.js";
|
|
10
|
+
function packageRoot() {
|
|
11
|
+
return resolve(dirname(fileURLToPath(import.meta.url)), "..", "..", "..");
|
|
12
|
+
}
|
|
13
|
+
function compilerUiAssetBuildRoot() {
|
|
14
|
+
const explicit = process.env.INTERF_COMPILER_UI_ASSETS?.trim();
|
|
15
|
+
if (explicit)
|
|
16
|
+
return resolve(explicit);
|
|
17
|
+
return join(packageRoot(), "apps", "compiler-ui", ".next");
|
|
18
|
+
}
|
|
19
|
+
function compilerUiPublicRoots() {
|
|
20
|
+
const explicit = process.env.INTERF_COMPILER_UI_ASSETS?.trim();
|
|
21
|
+
if (explicit) {
|
|
22
|
+
const assetRoot = resolve(explicit);
|
|
23
|
+
return [join(assetRoot, "public"), join(dirname(assetRoot), "public")];
|
|
24
|
+
}
|
|
25
|
+
return [join(packageRoot(), "apps", "compiler-ui", "public")];
|
|
26
|
+
}
|
|
27
|
+
function localInstancePointerPath(rootPath) {
|
|
28
|
+
return join(rootPath, ...LOCAL_SERVICE_INSTANCE_POINTER_PATH);
|
|
29
|
+
}
|
|
30
|
+
function writeLocalInstancePointer(rootPath, pointer) {
|
|
31
|
+
const pointerPath = localInstancePointerPath(rootPath);
|
|
32
|
+
mkdirSync(dirname(pointerPath), { recursive: true });
|
|
33
|
+
const parsed = LocalServiceInstancePointerSchema.parse(pointer);
|
|
34
|
+
writeFileSync(pointerPath, `${JSON.stringify(parsed, null, 2)}\n`);
|
|
35
|
+
}
|
|
36
|
+
function removeLocalInstancePointer(rootPath, serviceUrl) {
|
|
37
|
+
const pointerPath = localInstancePointerPath(rootPath);
|
|
38
|
+
if (!existsSync(pointerPath))
|
|
39
|
+
return;
|
|
40
|
+
try {
|
|
41
|
+
const pointer = LocalServiceInstancePointerSchema.parse(JSON.parse(readFileSync(pointerPath, "utf8")));
|
|
42
|
+
if (pointer.service_url !== serviceUrl || pointer.pid !== process.pid)
|
|
43
|
+
return;
|
|
44
|
+
rmSync(pointerPath, { force: true });
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function contentType(filePath) {
|
|
51
|
+
switch (extname(filePath)) {
|
|
52
|
+
case ".html":
|
|
53
|
+
return "text/html; charset=utf-8";
|
|
54
|
+
case ".js":
|
|
55
|
+
return "text/javascript; charset=utf-8";
|
|
56
|
+
case ".css":
|
|
57
|
+
return "text/css; charset=utf-8";
|
|
58
|
+
case ".json":
|
|
59
|
+
return "application/json; charset=utf-8";
|
|
60
|
+
case ".svg":
|
|
61
|
+
return "image/svg+xml";
|
|
62
|
+
case ".png":
|
|
63
|
+
return "image/png";
|
|
64
|
+
case ".ico":
|
|
65
|
+
return "image/x-icon";
|
|
66
|
+
case ".txt":
|
|
67
|
+
return "text/plain; charset=utf-8";
|
|
68
|
+
default:
|
|
69
|
+
return "application/octet-stream";
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function writeHeaders(res, statusCode, headers = {}) {
|
|
73
|
+
res.writeHead(statusCode, {
|
|
74
|
+
"access-control-allow-origin": "*",
|
|
75
|
+
"access-control-allow-methods": "GET,POST,PATCH,OPTIONS",
|
|
76
|
+
"access-control-allow-headers": "content-type",
|
|
77
|
+
...headers,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function sendJson(res, statusCode, value) {
|
|
81
|
+
writeHeaders(res, statusCode, {
|
|
82
|
+
"content-type": "application/json; charset=utf-8",
|
|
83
|
+
});
|
|
84
|
+
res.end(`${JSON.stringify(value, null, 2)}\n`);
|
|
85
|
+
}
|
|
86
|
+
function sendText(res, statusCode, value) {
|
|
87
|
+
writeHeaders(res, statusCode, {
|
|
88
|
+
"content-type": "text/plain; charset=utf-8",
|
|
89
|
+
});
|
|
90
|
+
res.end(value);
|
|
91
|
+
}
|
|
92
|
+
function sendError(res, statusCode, message) {
|
|
93
|
+
sendJson(res, statusCode, {
|
|
94
|
+
error: {
|
|
95
|
+
message,
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function resolveOpenPath(allowedRoots, pathValue) {
|
|
100
|
+
const roots = allowedRoots.map((root) => resolve(root));
|
|
101
|
+
const targetPath = resolve(pathValue);
|
|
102
|
+
for (const root of roots) {
|
|
103
|
+
try {
|
|
104
|
+
return assertPathWithinRoot(root, targetPath, "Open path");
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
throw new Error(`Open path must stay inside ${roots.join(" or ")}: ${targetPath}`);
|
|
111
|
+
}
|
|
112
|
+
async function openLocalPath(allowedRoots, pathValue) {
|
|
113
|
+
const targetPath = resolveOpenPath(allowedRoots, pathValue);
|
|
114
|
+
if (!existsSync(targetPath)) {
|
|
115
|
+
throw new Error(`Path does not exist: ${targetPath}`);
|
|
116
|
+
}
|
|
117
|
+
if (process.env.INTERF_OPEN_PATH_DRY_RUN === "1") {
|
|
118
|
+
return targetPath;
|
|
119
|
+
}
|
|
120
|
+
const isDirectory = statSync(targetPath).isDirectory();
|
|
121
|
+
const command = process.platform === "darwin"
|
|
122
|
+
? "open"
|
|
123
|
+
: process.platform === "win32"
|
|
124
|
+
? "explorer.exe"
|
|
125
|
+
: "xdg-open";
|
|
126
|
+
const args = process.platform === "darwin"
|
|
127
|
+
? (isDirectory ? [targetPath] : ["-R", targetPath])
|
|
128
|
+
: process.platform === "win32"
|
|
129
|
+
? (isDirectory ? [targetPath] : ["/select,", targetPath])
|
|
130
|
+
: [isDirectory ? targetPath : dirname(targetPath)];
|
|
131
|
+
await new Promise((resolveOpen, rejectOpen) => {
|
|
132
|
+
const child = spawn(command, args, {
|
|
133
|
+
detached: true,
|
|
134
|
+
stdio: "ignore",
|
|
135
|
+
});
|
|
136
|
+
child.once("error", rejectOpen);
|
|
137
|
+
child.once("spawn", () => {
|
|
138
|
+
child.unref();
|
|
139
|
+
resolveOpen();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
return targetPath;
|
|
143
|
+
}
|
|
144
|
+
function parseRequestUrl(req) {
|
|
145
|
+
return new URL(req.url ?? "/", "http://127.0.0.1");
|
|
146
|
+
}
|
|
147
|
+
function safeStaticPath(root, relativePath) {
|
|
148
|
+
const normalized = normalize(relativePath).replace(/^(\.\.(?:\/|\\|$))+/, "");
|
|
149
|
+
const absolute = resolve(root, normalized);
|
|
150
|
+
const resolvedRoot = resolve(root);
|
|
151
|
+
if (absolute !== resolvedRoot && !absolute.startsWith(`${resolvedRoot}${sep}`)) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return absolute;
|
|
155
|
+
}
|
|
156
|
+
function sendFile(res, filePath) {
|
|
157
|
+
if (!existsSync(filePath))
|
|
158
|
+
return false;
|
|
159
|
+
try {
|
|
160
|
+
if (!statSync(filePath).isFile())
|
|
161
|
+
return false;
|
|
162
|
+
writeHeaders(res, 200, {
|
|
163
|
+
"content-type": contentType(filePath),
|
|
164
|
+
});
|
|
165
|
+
res.end(readFileSync(filePath));
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function sendCompilerUiAsset(req, res, _runtime) {
|
|
173
|
+
const buildRoot = compilerUiAssetBuildRoot();
|
|
174
|
+
const url = parseRequestUrl(req);
|
|
175
|
+
if (url.pathname === "/") {
|
|
176
|
+
const indexPath = join(buildRoot, "server", "app", "index.html");
|
|
177
|
+
if (sendFile(res, indexPath))
|
|
178
|
+
return true;
|
|
179
|
+
sendText(res, 503, "Interf UI assets are missing. Run `npm run web:build`, then restart `interf web`.\n");
|
|
180
|
+
return true;
|
|
181
|
+
}
|
|
182
|
+
if (url.pathname.startsWith("/_next/static/")) {
|
|
183
|
+
const relativePath = url.pathname.slice("/_next/static/".length);
|
|
184
|
+
const assetPath = safeStaticPath(join(buildRoot, "static"), relativePath);
|
|
185
|
+
if (assetPath && sendFile(res, assetPath))
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
for (const publicRoot of compilerUiPublicRoots()) {
|
|
189
|
+
const assetPath = safeStaticPath(publicRoot, url.pathname.slice(1));
|
|
190
|
+
if (assetPath && sendFile(res, assetPath))
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
async function readJsonBody(req) {
|
|
196
|
+
const chunks = [];
|
|
197
|
+
for await (const chunk of req) {
|
|
198
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
199
|
+
}
|
|
200
|
+
const raw = Buffer.concat(chunks).toString("utf8").trim();
|
|
201
|
+
if (!raw)
|
|
202
|
+
return {};
|
|
203
|
+
return JSON.parse(raw);
|
|
204
|
+
}
|
|
205
|
+
async function routeApi(req, res, runtime) {
|
|
206
|
+
const url = parseRequestUrl(req);
|
|
207
|
+
const path = url.pathname;
|
|
208
|
+
const method = req.method ?? "GET";
|
|
209
|
+
if (method === "OPTIONS") {
|
|
210
|
+
writeHeaders(res, 204);
|
|
211
|
+
res.end();
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
if (method === "GET" && path === "/health") {
|
|
215
|
+
sendJson(res, 200, runtime.health());
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.api) {
|
|
219
|
+
sendJson(res, 200, LocalServiceDiscoverySchema.parse({
|
|
220
|
+
kind: "interf-local-service-discovery",
|
|
221
|
+
version: 1,
|
|
222
|
+
resources: {
|
|
223
|
+
preparations: LOCAL_SERVICE_ROUTES.preparations,
|
|
224
|
+
methods: LOCAL_SERVICE_ROUTES.methods,
|
|
225
|
+
runs: LOCAL_SERVICE_ROUTES.runs,
|
|
226
|
+
readiness: LOCAL_SERVICE_ROUTES.readiness,
|
|
227
|
+
portable_contexts: LOCAL_SERVICE_ROUTES.portableContexts,
|
|
228
|
+
source_files: LOCAL_SERVICE_ROUTES.sourceFiles,
|
|
229
|
+
workspace_files: LOCAL_SERVICE_ROUTES.workspaceFiles,
|
|
230
|
+
action_proposals: LOCAL_SERVICE_ROUTES.actionProposals,
|
|
231
|
+
executor: LOCAL_SERVICE_ROUTES.executor,
|
|
232
|
+
},
|
|
233
|
+
}));
|
|
234
|
+
return true;
|
|
235
|
+
}
|
|
236
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.preparations) {
|
|
237
|
+
sendJson(res, 200, { preparations: runtime.listPreparations() });
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.workspaceFiles) {
|
|
241
|
+
sendJson(res, 200, { workspace_files: runtime.listWorkspaceFiles() });
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.readiness) {
|
|
245
|
+
sendJson(res, 200, { readiness: runtime.listPreparationReadiness() });
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.sourceFiles) {
|
|
249
|
+
const preparation = url.searchParams.get("preparation");
|
|
250
|
+
sendJson(res, 200, { source_files: runtime.listSourceFiles(preparation) });
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
if (method === "POST" && path === LOCAL_SERVICE_ROUTES.openPath) {
|
|
254
|
+
const body = OpenPathRequestSchema.parse(await readJsonBody(req));
|
|
255
|
+
const health = runtime.health();
|
|
256
|
+
const allowedRoots = [
|
|
257
|
+
runtime.rootPath,
|
|
258
|
+
...(health.source_folder_path ? [health.source_folder_path] : []),
|
|
259
|
+
];
|
|
260
|
+
const openedPath = await openLocalPath(allowedRoots, body.path);
|
|
261
|
+
sendJson(res, 202, { opened: true, path: openedPath });
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
const preparationMatch = path.match(/^\/v1\/preparations\/([^/]+)$/);
|
|
265
|
+
if (method === "GET" && preparationMatch?.[1]) {
|
|
266
|
+
const preparation = runtime.getPreparation(decodeURIComponent(preparationMatch[1]));
|
|
267
|
+
if (!preparation)
|
|
268
|
+
sendError(res, 404, "Preparation not found.");
|
|
269
|
+
else
|
|
270
|
+
sendJson(res, 200, preparation);
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
const preparationReadinessMatch = path.match(/^\/v1\/preparations\/([^/]+)\/readiness$/);
|
|
274
|
+
if (method === "GET" && preparationReadinessMatch?.[1]) {
|
|
275
|
+
const readiness = runtime.getPreparationReadiness(decodeURIComponent(preparationReadinessMatch[1]));
|
|
276
|
+
if (!readiness)
|
|
277
|
+
sendError(res, 404, "Preparation not found.");
|
|
278
|
+
else
|
|
279
|
+
sendJson(res, 200, readiness);
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.methods) {
|
|
283
|
+
sendJson(res, 200, { methods: runtime.listMethods() });
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
const methodMatch = path.match(/^\/v1\/methods\/([^/]+)$/);
|
|
287
|
+
if (method === "GET" && methodMatch?.[1]) {
|
|
288
|
+
const methodResource = runtime.getMethod(decodeURIComponent(methodMatch[1]));
|
|
289
|
+
if (!methodResource)
|
|
290
|
+
sendError(res, 404, "Method not found.");
|
|
291
|
+
else
|
|
292
|
+
sendJson(res, 200, methodResource);
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
if (method === "GET" && path === "/v1/jobs") {
|
|
296
|
+
sendJson(res, 200, { jobs: runtime.listJobs() });
|
|
297
|
+
return true;
|
|
298
|
+
}
|
|
299
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.executor) {
|
|
300
|
+
sendJson(res, 200, runtime.getExecutorStatus());
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
if (method === "POST" && path === LOCAL_SERVICE_ROUTES.executor) {
|
|
304
|
+
const body = await readJsonBody(req);
|
|
305
|
+
sendJson(res, 202, runtime.selectExecutor(body));
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
308
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.actionProposals) {
|
|
309
|
+
sendJson(res, 200, { action_proposals: runtime.listActionProposals() });
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
if (method === "POST" && path === LOCAL_SERVICE_ROUTES.actionProposals) {
|
|
313
|
+
const body = await readJsonBody(req);
|
|
314
|
+
sendJson(res, 202, await runtime.createActionProposal(body));
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
const actionProposalMatch = path.match(/^\/v1\/action-proposals\/([^/]+)(?:\/([^/]+))?$/);
|
|
318
|
+
if (actionProposalMatch?.[1]) {
|
|
319
|
+
const proposalId = decodeURIComponent(actionProposalMatch[1]);
|
|
320
|
+
const child = actionProposalMatch[2];
|
|
321
|
+
if (method === "GET" && !child) {
|
|
322
|
+
const proposal = runtime.getActionProposal(proposalId);
|
|
323
|
+
if (!proposal)
|
|
324
|
+
sendError(res, 404, "Action proposal not found.");
|
|
325
|
+
else
|
|
326
|
+
sendJson(res, 200, proposal);
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
if (method === "POST" && child === "decision") {
|
|
330
|
+
const body = await readJsonBody(req);
|
|
331
|
+
const proposal = await runtime.decideActionProposal(proposalId, body);
|
|
332
|
+
if (!proposal)
|
|
333
|
+
sendError(res, 404, "Action proposal not found.");
|
|
334
|
+
else
|
|
335
|
+
sendJson(res, 202, proposal);
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.runs) {
|
|
340
|
+
sendJson(res, 200, { runs: runtime.listRunObservability() });
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
if (method === "POST" && path === LOCAL_SERVICE_ROUTES.runs) {
|
|
344
|
+
const request = RunCreateRequestSchema.parse(await readJsonBody(req));
|
|
345
|
+
if (request.run_type === "compile" || request.run_type === "prepare") {
|
|
346
|
+
const { run_type: _ignoredRunType, ...compileRequest } = request;
|
|
347
|
+
const resource = await runtime.createCompileRun(compileRequest);
|
|
348
|
+
sendJson(res, 202, runtime.getRunObservability(resource.run.run_id) ?? resource);
|
|
349
|
+
return true;
|
|
350
|
+
}
|
|
351
|
+
const { run_type: _ignoredRunType, ...testRequest } = request;
|
|
352
|
+
const resource = await runtime.createTestRun(testRequest);
|
|
353
|
+
sendJson(res, 202, runtime.getRunObservability(resource.run_id) ?? resource);
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
const observableRunMatch = path.match(/^\/v1\/runs\/([^/]+)$/);
|
|
357
|
+
if (method === "GET" && observableRunMatch?.[1]) {
|
|
358
|
+
const run = runtime.getRunObservability(decodeURIComponent(observableRunMatch[1]));
|
|
359
|
+
if (!run)
|
|
360
|
+
sendError(res, 404, "Run not found.");
|
|
361
|
+
else
|
|
362
|
+
sendJson(res, 200, run);
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
if (method === "POST" && path === "/v1/jobs") {
|
|
366
|
+
const body = await readJsonBody(req);
|
|
367
|
+
sendJson(res, 202, runtime.createJobRun(body));
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
const jobMatch = path.match(/^\/v1\/jobs\/([^/]+)(?:\/([^/]+))?$/);
|
|
371
|
+
if (jobMatch?.[1]) {
|
|
372
|
+
const runId = decodeURIComponent(jobMatch[1]);
|
|
373
|
+
const child = jobMatch[2];
|
|
374
|
+
if (method === "GET" && !child) {
|
|
375
|
+
const job = runtime.getJob(runId);
|
|
376
|
+
if (!job)
|
|
377
|
+
sendError(res, 404, "Job run not found.");
|
|
378
|
+
else
|
|
379
|
+
sendJson(res, 200, job);
|
|
380
|
+
return true;
|
|
381
|
+
}
|
|
382
|
+
if (method === "GET" && child === "events") {
|
|
383
|
+
const events = runtime.getJobEvents(runId);
|
|
384
|
+
if (!events)
|
|
385
|
+
sendError(res, 404, "Job run not found.");
|
|
386
|
+
else
|
|
387
|
+
sendJson(res, 200, { events });
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
if (method === "POST" && child === "events") {
|
|
391
|
+
const body = await readJsonBody(req);
|
|
392
|
+
const job = runtime.appendJobRunEvent(runId, body);
|
|
393
|
+
if (!job)
|
|
394
|
+
sendError(res, 404, "Job run not found.");
|
|
395
|
+
else
|
|
396
|
+
sendJson(res, 202, job);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (method === "POST" && path === "/v1/readiness-check-drafts") {
|
|
401
|
+
const body = await readJsonBody(req);
|
|
402
|
+
const job = await runtime.createReadinessCheckDraftRun(body);
|
|
403
|
+
sendJson(res, 202, job);
|
|
404
|
+
return true;
|
|
405
|
+
}
|
|
406
|
+
if (method === "POST" &&
|
|
407
|
+
path === LOCAL_SERVICE_ROUTES.methodAuthoringRuns) {
|
|
408
|
+
const body = await readJsonBody(req);
|
|
409
|
+
const job = await runtime.createWorkflowAuthoringRun(body);
|
|
410
|
+
sendJson(res, 202, job);
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
if (method === "GET" && path === "/v1/compile-runs") {
|
|
414
|
+
sendJson(res, 200, { compile_runs: runtime.listCompileRuns() });
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
if (method === "POST" && path === "/v1/compile-runs") {
|
|
418
|
+
const body = await readJsonBody(req);
|
|
419
|
+
const resource = await runtime.createCompileRun(body);
|
|
420
|
+
sendJson(res, 202, resource);
|
|
421
|
+
return true;
|
|
422
|
+
}
|
|
423
|
+
const compileRunMatch = path.match(/^\/v1\/compile-runs\/([^/]+)(?:\/([^/]+))?$/);
|
|
424
|
+
if (compileRunMatch?.[1]) {
|
|
425
|
+
const runId = decodeURIComponent(compileRunMatch[1]);
|
|
426
|
+
const child = compileRunMatch[2];
|
|
427
|
+
if (method === "GET" && !child) {
|
|
428
|
+
const run = runtime.getCompileRun(runId);
|
|
429
|
+
if (!run)
|
|
430
|
+
sendError(res, 404, "Compile run not found.");
|
|
431
|
+
else
|
|
432
|
+
sendJson(res, 200, run);
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
if (method === "GET" && child === "events") {
|
|
436
|
+
const events = runtime.getCompileRunEvents(runId);
|
|
437
|
+
if (!events)
|
|
438
|
+
sendError(res, 404, "Compile run not found.");
|
|
439
|
+
else
|
|
440
|
+
sendJson(res, 200, { events });
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
if (method === "GET" && child === "proof") {
|
|
444
|
+
const proof = runtime.getCompileRunProof(runId);
|
|
445
|
+
if (!proof)
|
|
446
|
+
sendError(res, 404, "Compile run not found.");
|
|
447
|
+
else
|
|
448
|
+
sendJson(res, 200, { proof });
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
if (method === "GET" && child === "artifacts") {
|
|
452
|
+
const artifacts = runtime.getCompileRunArtifacts(runId);
|
|
453
|
+
if (!artifacts)
|
|
454
|
+
sendError(res, 404, "Compile run not found.");
|
|
455
|
+
else
|
|
456
|
+
sendJson(res, 200, { artifacts });
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
if (method === "POST" && child === "cancel") {
|
|
460
|
+
sendError(res, 501, "Compile-run cancellation is not implemented yet.");
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (method === "GET" && path === "/v1/test-runs") {
|
|
465
|
+
sendJson(res, 200, { test_runs: runtime.listTestRuns() });
|
|
466
|
+
return true;
|
|
467
|
+
}
|
|
468
|
+
if (method === "POST" && path === "/v1/test-runs") {
|
|
469
|
+
const body = await readJsonBody(req);
|
|
470
|
+
const resource = await runtime.createTestRun(body);
|
|
471
|
+
sendJson(res, 202, resource);
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
474
|
+
const testRunMatch = path.match(/^\/v1\/test-runs\/([^/]+)$/);
|
|
475
|
+
if (method === "GET" && testRunMatch?.[1]) {
|
|
476
|
+
const run = runtime.getTestRun(decodeURIComponent(testRunMatch[1]));
|
|
477
|
+
if (!run)
|
|
478
|
+
sendError(res, 404, "Readiness check run not found.");
|
|
479
|
+
else
|
|
480
|
+
sendJson(res, 200, run);
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
if (method === "GET" && path === "/v1/portable-contexts") {
|
|
484
|
+
sendJson(res, 200, { portable_contexts: runtime.listPortableContexts() });
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
const portableContextMatch = path.match(/^\/v1\/portable-contexts\/([^/]+)$/);
|
|
488
|
+
if (method === "GET" && portableContextMatch?.[1]) {
|
|
489
|
+
const context = runtime.getPortableContext(decodeURIComponent(portableContextMatch[1]));
|
|
490
|
+
if (!context)
|
|
491
|
+
sendError(res, 404, "Portable context not found.");
|
|
492
|
+
else
|
|
493
|
+
sendJson(res, 200, context);
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
export function createLocalServiceServer(runtime) {
|
|
499
|
+
return createServer((req, res) => {
|
|
500
|
+
void (async () => {
|
|
501
|
+
try {
|
|
502
|
+
const routed = await routeApi(req, res, runtime);
|
|
503
|
+
if (routed)
|
|
504
|
+
return;
|
|
505
|
+
if (sendCompilerUiAsset(req, res, runtime))
|
|
506
|
+
return;
|
|
507
|
+
sendText(res, 404, "Not found.\n");
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
sendError(res, 500, error instanceof Error ? error.message : String(error));
|
|
511
|
+
}
|
|
512
|
+
})();
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function resolvePort(optionPort) {
|
|
516
|
+
if (typeof optionPort === "number")
|
|
517
|
+
return optionPort;
|
|
518
|
+
const envPort = Number.parseInt(process.env.INTERF_SERVICE_PORT ?? "", 10);
|
|
519
|
+
return Number.isInteger(envPort) ? envPort : LOCAL_SERVICE_DEFAULT_PORT;
|
|
520
|
+
}
|
|
521
|
+
export async function startLocalService(options = {}) {
|
|
522
|
+
const config = LocalServiceConfigSchema.parse({
|
|
523
|
+
host: options.host ?? process.env.INTERF_SERVICE_HOST ?? LOCAL_SERVICE_DEFAULT_HOST,
|
|
524
|
+
port: resolvePort(options.port),
|
|
525
|
+
});
|
|
526
|
+
const rootPath = options.rootPath ?? process.cwd();
|
|
527
|
+
const runtime = createLocalServiceRuntime({
|
|
528
|
+
rootPath,
|
|
529
|
+
host: config.host,
|
|
530
|
+
port: config.port,
|
|
531
|
+
packageVersion: options.packageVersion,
|
|
532
|
+
handlers: options.handlers,
|
|
533
|
+
});
|
|
534
|
+
const server = createLocalServiceServer(runtime);
|
|
535
|
+
await new Promise((resolveListen, rejectListen) => {
|
|
536
|
+
const onError = (error) => {
|
|
537
|
+
server.off("listening", onListening);
|
|
538
|
+
rejectListen(error);
|
|
539
|
+
};
|
|
540
|
+
const onListening = () => {
|
|
541
|
+
server.off("error", onError);
|
|
542
|
+
resolveListen();
|
|
543
|
+
};
|
|
544
|
+
server.once("error", onError);
|
|
545
|
+
server.once("listening", onListening);
|
|
546
|
+
server.listen(config.port, config.host);
|
|
547
|
+
});
|
|
548
|
+
const url = runtime.health().service_url;
|
|
549
|
+
writeLocalInstancePointer(rootPath, {
|
|
550
|
+
service_url: url,
|
|
551
|
+
host: config.host,
|
|
552
|
+
port: config.port,
|
|
553
|
+
pid: process.pid,
|
|
554
|
+
control_path: resolve(rootPath),
|
|
555
|
+
started_at: new Date().toISOString(),
|
|
556
|
+
});
|
|
557
|
+
return {
|
|
558
|
+
runtime,
|
|
559
|
+
server,
|
|
560
|
+
url,
|
|
561
|
+
close: () => new Promise((resolveClose, rejectClose) => {
|
|
562
|
+
server.close((error) => {
|
|
563
|
+
if (error) {
|
|
564
|
+
rejectClose(error);
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
removeLocalInstancePointer(rootPath, url);
|
|
568
|
+
resolveClose();
|
|
569
|
+
});
|
|
570
|
+
}),
|
|
571
|
+
};
|
|
572
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * as schema from "./lib/schema.js";
|
|
2
2
|
export * as sourceConfig from "./source-config.js";
|
|
3
|
+
export * as sourceFolders from "./source-folders.js";
|
|
3
4
|
export * as interf from "./interf.js";
|
|
4
5
|
export * as detect from "./interf-detect.js";
|
|
5
6
|
export * as bootstrap from "./interf-bootstrap.js";
|
|
@@ -8,4 +9,4 @@ export * as compiledPaths from "./compiled-paths.js";
|
|
|
8
9
|
export * as projectPaths from "./project-paths.js";
|
|
9
10
|
export * as compiledRaw from "./compiled-raw.js";
|
|
10
11
|
export * as compiledReset from "./compiled-reset.js";
|
|
11
|
-
export type { InterfConfig, SourceDatasetConfig,
|
|
12
|
+
export type { InterfConfig, MethodId, PreparationName, SourceDatasetConfig, SourceFolderBinding, SourcePreparationConfig, SourceReadinessCheck, SourceFolderConfig, } from "./lib/schema.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * as schema from "./lib/schema.js";
|
|
2
2
|
export * as sourceConfig from "./source-config.js";
|
|
3
|
+
export * as sourceFolders from "./source-folders.js";
|
|
3
4
|
export * as interf from "./interf.js";
|
|
4
5
|
export * as detect from "./interf-detect.js";
|
|
5
6
|
export * as bootstrap from "./interf-bootstrap.js";
|
|
@@ -6,10 +6,14 @@ export interface ResolvedCompiled {
|
|
|
6
6
|
config: InterfConfig;
|
|
7
7
|
}
|
|
8
8
|
export declare const INTERF_CONTAINER_NAME = "interf";
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const METHOD_CONTAINER_NAME = "methods";
|
|
10
|
+
export declare const WORKFLOW_CONTAINER_NAME = "methods";
|
|
11
|
+
export declare const LEGACY_WORKFLOW_CONTAINER_NAME = "workflows";
|
|
10
12
|
export declare const TEST_CONTAINER_NAME = "tests";
|
|
11
13
|
export declare const INTERF_CONFIG_FILE = "interf.json";
|
|
12
|
-
export declare const
|
|
14
|
+
export declare const METHOD_PACKAGE_DIR = "method";
|
|
15
|
+
export declare const WORKFLOW_PACKAGE_DIR = "method";
|
|
16
|
+
export declare const LEGACY_WORKFLOW_PACKAGE_DIR = "workflow";
|
|
13
17
|
export declare function readInterfConfig(dirPath: string): InterfConfig | null;
|
|
14
18
|
export declare function hasSourceFolderInput(config: InterfConfig | null | undefined): config is InterfConfig & {
|
|
15
19
|
source: {
|