@interf/compiler 0.33.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -226
- package/dist/cli/commands/agents.js +1 -32
- package/dist/cli/commands/benchmark.d.ts +2 -3
- package/dist/cli/commands/benchmark.js +1 -31
- package/dist/cli/commands/build-plan.js +26 -50
- package/dist/cli/commands/build.d.ts +2 -3
- package/dist/cli/commands/build.js +1 -31
- package/dist/cli/commands/graphs.js +177 -32
- package/dist/cli/commands/mcp.d.ts +1 -0
- package/dist/cli/commands/mcp.js +223 -126
- package/dist/cli/commands/project.js +10 -36
- package/dist/cli/commands/reset.d.ts +2 -3
- package/dist/cli/commands/reset.js +1 -22
- package/dist/cli/commands/runs.js +86 -33
- package/dist/cli/commands/status.js +3 -24
- package/dist/cli/commands/traces.js +1 -29
- package/dist/cli/commands/wizard.js +17 -29
- package/dist/cli/lib/http-client.d.ts +39 -0
- package/dist/cli/lib/http-client.js +73 -0
- package/dist/packages/build-plans/authoring/brief.d.ts +25 -4
- package/dist/packages/build-plans/authoring/build-plan-authoring.d.ts +42 -1
- package/dist/packages/build-plans/authoring/build-plan-authoring.js +470 -63
- package/dist/packages/build-plans/authoring/build-plan-edit-session.d.ts +9 -0
- package/dist/packages/build-plans/authoring/build-plan-edit-session.js +27 -10
- package/dist/packages/build-plans/authoring/build-plan-improvement.js +62 -8
- package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.d.ts +1 -0
- package/dist/packages/build-plans/package/build-plan-definitions.d.ts +0 -1
- package/dist/packages/build-plans/package/build-plan-definitions.js +5 -3
- package/dist/packages/build-plans/package/build-plan-stage-runner.d.ts +1 -0
- package/dist/packages/build-plans/package/build-plan-stage-runner.js +2 -1
- package/dist/packages/build-plans/package/builtin-build-plan.d.ts +2 -2
- package/dist/packages/build-plans/package/builtin-build-plan.js +3 -3
- package/dist/packages/build-plans/package/context-interface.d.ts +3 -0
- package/dist/packages/build-plans/package/context-interface.js +5 -5
- package/dist/packages/build-plans/package/interf-build-plan-package.js +22 -22
- package/dist/packages/build-plans/package/local-build-plans.d.ts +10 -5
- package/dist/packages/build-plans/package/local-build-plans.js +57 -32
- package/dist/packages/contracts/index.d.ts +4 -3
- package/dist/packages/contracts/index.js +2 -1
- package/dist/packages/contracts/lib/context-graph-layer.d.ts +161 -0
- package/dist/packages/contracts/lib/context-graph-layer.js +216 -0
- package/dist/packages/contracts/lib/project-paths.d.ts +7 -0
- package/dist/packages/contracts/lib/project-paths.js +9 -0
- package/dist/packages/contracts/lib/project-schema.d.ts +264 -1
- package/dist/packages/contracts/lib/project-schema.js +38 -13
- package/dist/packages/contracts/lib/schema.d.ts +556 -23
- package/dist/packages/contracts/lib/schema.js +279 -18
- package/dist/packages/contracts/utils/filesystem.d.ts +1 -0
- package/dist/packages/contracts/utils/filesystem.js +29 -1
- package/dist/packages/projects/lib/schema.d.ts +6 -8
- package/dist/packages/projects/lib/schema.js +3 -1
- package/dist/packages/projects/source-config.d.ts +0 -5
- package/dist/packages/projects/source-config.js +9 -22
- package/dist/packages/runtime/actions/fields.d.ts +4 -0
- package/dist/packages/runtime/actions/form-builders.js +79 -31
- package/dist/packages/runtime/actions/form-validators.js +9 -3
- package/dist/packages/runtime/actions/helpers.js +3 -3
- package/dist/packages/runtime/actions/registry.d.ts +1 -1
- package/dist/packages/runtime/actions/registry.js +1 -1
- package/dist/packages/runtime/actions/requests.d.ts +1 -1
- package/dist/packages/runtime/actions/requests.js +12 -6
- package/dist/packages/runtime/actions/schemas.d.ts +7 -0
- package/dist/packages/runtime/actions/schemas.js +1 -0
- package/dist/packages/runtime/agent-handoff.js +8 -7
- package/dist/packages/runtime/agents/lib/execution-profile.d.ts +14 -0
- package/dist/packages/runtime/agents/lib/execution-profile.js +23 -0
- package/dist/packages/runtime/agents/lib/execution.js +14 -8
- package/dist/packages/runtime/agents/lib/executors.d.ts +1 -0
- package/dist/packages/runtime/agents/lib/executors.js +11 -2
- package/dist/packages/runtime/agents/lib/logs.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/logs.js +32 -8
- package/dist/packages/runtime/agents/lib/preflight.js +4 -1
- package/dist/packages/runtime/agents/lib/render.d.ts +18 -0
- package/dist/packages/runtime/agents/lib/render.js +44 -18
- package/dist/packages/runtime/agents/lib/shell-templates.js +105 -63
- package/dist/packages/runtime/agents/lib/shells.d.ts +29 -0
- package/dist/packages/runtime/agents/lib/shells.js +158 -32
- package/dist/packages/runtime/agents/lib/source-context-scan.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/source-context-scan.js +388 -0
- package/dist/packages/runtime/agents/lib/status.js +1 -14
- package/dist/packages/runtime/agents/lib/string-utils.d.ts +16 -0
- package/dist/packages/runtime/agents/lib/string-utils.js +36 -0
- package/dist/packages/runtime/agents/lib/types.d.ts +1 -0
- package/dist/packages/runtime/agents/providers/codex.js +2 -0
- package/dist/packages/runtime/agents/role-executors.js +2 -1
- package/dist/packages/runtime/auth/session-store.js +11 -3
- package/dist/packages/runtime/benchmark-question-draft.d.ts +3 -0
- package/dist/packages/runtime/benchmark-question-draft.js +57 -28
- package/dist/packages/runtime/build/artifact-status.d.ts +1 -1
- package/dist/packages/runtime/build/artifact-status.js +1 -1
- package/dist/packages/runtime/build/build-evidence.d.ts +2 -1
- package/dist/packages/runtime/build/build-evidence.js +11 -5
- package/dist/packages/runtime/build/build-pipeline.js +89 -5
- package/dist/packages/runtime/build/build-stage-plan.js +3 -1
- package/dist/packages/runtime/build/build-stage-runner.js +169 -32
- package/dist/packages/runtime/build/build-target.d.ts +3 -0
- package/dist/packages/runtime/build/build-target.js +25 -1
- package/dist/packages/runtime/build/check-evaluator.d.ts +1 -1
- package/dist/packages/runtime/build/check-evaluator.js +655 -4
- package/dist/packages/runtime/build/context-graph-paths.d.ts +13 -0
- package/dist/packages/runtime/build/context-graph-paths.js +27 -0
- package/dist/packages/runtime/build/index.d.ts +2 -2
- package/dist/packages/runtime/build/index.js +2 -2
- package/dist/packages/runtime/build/inspect-map.d.ts +10 -0
- package/dist/packages/runtime/build/inspect-map.js +270 -0
- package/dist/packages/runtime/build/lib/schema.d.ts +246 -53
- package/dist/packages/runtime/build/lib/schema.js +173 -15
- package/dist/packages/runtime/build/native-entrypoint.d.ts +2 -0
- package/dist/packages/runtime/build/native-entrypoint.js +286 -0
- package/dist/packages/runtime/build/runtime-contracts.js +9 -3
- package/dist/packages/runtime/build/runtime-log-paths.d.ts +3 -0
- package/dist/packages/runtime/build/runtime-log-paths.js +16 -0
- package/dist/packages/runtime/build/runtime-prompt.js +6 -4
- package/dist/packages/runtime/build/runtime-runs.js +63 -10
- package/dist/packages/runtime/build/runtime-types.d.ts +4 -1
- package/dist/packages/runtime/build/runtime.d.ts +3 -1
- package/dist/packages/runtime/build/runtime.js +3 -1
- package/dist/packages/runtime/build/source-files.js +11 -2
- package/dist/packages/runtime/build/source-inventory.d.ts +1 -0
- package/dist/packages/runtime/build/source-inventory.js +246 -7
- package/dist/packages/runtime/build/source-manifest.d.ts +11 -0
- package/dist/packages/runtime/build/source-manifest.js +30 -2
- package/dist/packages/runtime/build/stage-evidence.js +80 -11
- package/dist/packages/runtime/build/stage-manifest.d.ts +45 -0
- package/dist/packages/runtime/build/stage-manifest.js +1125 -0
- package/dist/packages/runtime/build/stage-reuse.js +12 -0
- package/dist/packages/runtime/build/stage-session.d.ts +81 -0
- package/dist/packages/runtime/build/stage-session.js +308 -0
- package/dist/packages/runtime/build/state-io.js +10 -11
- package/dist/packages/runtime/build/state-view.js +1 -1
- package/dist/packages/runtime/build/state.d.ts +1 -1
- package/dist/packages/runtime/build/state.js +1 -1
- package/dist/packages/runtime/build/summary-coverage-index.d.ts +21 -0
- package/dist/packages/runtime/build/summary-coverage-index.js +189 -0
- package/dist/packages/runtime/build/traces.js +3 -3
- package/dist/packages/runtime/build/validate-context-graph.d.ts +1 -1
- package/dist/packages/runtime/build/validate-context-graph.js +5 -5
- package/dist/packages/runtime/build/validate.d.ts +1 -1
- package/dist/packages/runtime/build/validate.js +1 -1
- package/dist/packages/runtime/client.d.ts +3 -3
- package/dist/packages/runtime/client.js +8 -13
- package/dist/packages/runtime/context-checks.js +13 -0
- package/dist/packages/runtime/context-graph-scaffold.js +2 -1
- package/dist/packages/runtime/context-graph-semantic-graph.d.ts +9 -0
- package/dist/packages/runtime/context-graph-semantic-graph.js +416 -0
- package/dist/packages/runtime/execution/lib/schema.d.ts +34 -31
- package/dist/packages/runtime/index.d.ts +2 -2
- package/dist/packages/runtime/index.js +1 -1
- package/dist/packages/runtime/native-run-handlers.d.ts +38 -0
- package/dist/packages/runtime/native-run-handlers.js +52 -33
- package/dist/packages/runtime/plan-artifact-contract.js +1 -1
- package/dist/packages/runtime/project-source-state.d.ts +4 -4
- package/dist/packages/runtime/project-source-state.js +5 -2
- package/dist/packages/runtime/project-store.d.ts +5 -0
- package/dist/packages/runtime/project-store.js +30 -3
- package/dist/packages/runtime/requested-artifacts.js +1 -1
- package/dist/packages/runtime/run-observability.js +9 -4
- package/dist/packages/runtime/runtime-action-proposals.js +3 -3
- package/dist/packages/runtime/runtime-build-plans.js +47 -3
- package/dist/packages/runtime/runtime-build-runs.js +9 -16
- package/dist/packages/runtime/runtime-caches.d.ts +26 -0
- package/dist/packages/runtime/runtime-caches.js +47 -0
- package/dist/packages/runtime/runtime-jobs.js +6 -6
- package/dist/packages/runtime/runtime-project-mutations.js +1 -0
- package/dist/packages/runtime/runtime-project-reads.d.ts +4 -1
- package/dist/packages/runtime/runtime-project-reads.js +229 -36
- package/dist/packages/runtime/runtime-proposal-helpers.js +6 -6
- package/dist/packages/runtime/runtime-resource-builders.d.ts +4 -2
- package/dist/packages/runtime/runtime-resource-builders.js +16 -14
- package/dist/packages/runtime/runtime-status.d.ts +14 -0
- package/dist/packages/runtime/runtime-status.js +15 -0
- package/dist/packages/runtime/runtime-verify-runs.js +6 -5
- package/dist/packages/runtime/runtime.d.ts +439 -22
- package/dist/packages/runtime/runtime.js +16 -2
- package/dist/packages/runtime/schemas/actions.d.ts +24 -0
- package/dist/packages/runtime/schemas/agents.d.ts +28 -0
- package/dist/packages/runtime/schemas/agents.js +33 -0
- package/dist/packages/runtime/schemas/build-plans.d.ts +181 -8
- package/dist/packages/runtime/schemas/build-plans.js +36 -2
- package/dist/packages/runtime/schemas/context-graphs.d.ts +1522 -0
- package/dist/packages/runtime/schemas/context-graphs.js +110 -0
- package/dist/packages/runtime/schemas/files.d.ts +7 -347
- package/dist/packages/runtime/schemas/files.js +1 -24
- package/dist/packages/runtime/schemas/index.d.ts +1 -0
- package/dist/packages/runtime/schemas/index.js +1 -0
- package/dist/packages/runtime/schemas/jobs.js +4 -0
- package/dist/packages/runtime/schemas/projects.d.ts +48 -21
- package/dist/packages/runtime/schemas/projects.js +34 -10
- package/dist/packages/runtime/schemas/runs.d.ts +1009 -240
- package/dist/packages/runtime/schemas/runs.js +17 -0
- package/dist/packages/runtime/service/openapi.js +1 -0
- package/dist/packages/runtime/service/operations.d.ts +1666 -145
- package/dist/packages/runtime/service/operations.js +147 -17
- package/dist/packages/runtime/service/routes.d.ts +11 -3
- package/dist/packages/runtime/service/routes.js +11 -3
- package/dist/packages/runtime/service/server-app-boot.js +2 -2
- package/dist/packages/runtime/service/server-helpers.d.ts +11 -0
- package/dist/packages/runtime/service/server-helpers.js +19 -0
- package/dist/packages/runtime/service/server-routes-action-proposals.js +4 -2
- package/dist/packages/runtime/service/server-routes-agents.js +19 -85
- package/dist/packages/runtime/service/server-routes-build-plans.js +14 -11
- package/dist/packages/runtime/service/server-routes-project-context.js +102 -7
- package/dist/packages/runtime/service/server-routes-project-jobs.js +19 -12
- package/dist/packages/runtime/service/server-routes-project-runs.js +5 -2
- package/dist/packages/runtime/service/server-routes-projects.js +6 -2
- package/dist/packages/runtime/service/server-routes-runs.js +11 -4
- package/dist/packages/runtime/verify/lib/schema.js +12 -0
- package/dist/packages/runtime/verify/test-file-guard.d.ts +2 -0
- package/dist/packages/runtime/verify/test-file-guard.js +29 -0
- package/dist/packages/runtime/verify/verify-execution.d.ts +7 -0
- package/dist/packages/runtime/verify/verify-execution.js +109 -35
- package/dist/packages/runtime/verify/verify-paths.d.ts +1 -0
- package/dist/packages/runtime/verify/verify-paths.js +4 -0
- package/dist/packages/runtime/verify/verify-specs.js +49 -39
- package/dist/packages/runtime/wire-schemas.d.ts +1 -1
- package/dist/packages/runtime/wire-schemas.js +1 -1
- package/package.json +2 -8
- package/public-repo/CONTRIBUTING.md +10 -3
- package/public-repo/README.md +122 -226
- package/public-repo/build-plans/interf-default/README.md +15 -12
- package/public-repo/build-plans/interf-default/build/stages/entrypoint/SKILL.md +74 -0
- package/public-repo/build-plans/interf-default/build/stages/knowledge/SKILL.md +95 -0
- package/public-repo/build-plans/interf-default/build/stages/summarize/SKILL.md +38 -5
- package/public-repo/build-plans/interf-default/build-plan.json +27 -23
- package/public-repo/build-plans/interf-default/build-plan.schema.json +24 -20
- package/public-repo/build-plans/interf-default/use/query/SKILL.md +8 -7
- package/public-repo/openapi/local-service.openapi.json +11637 -4213
- package/public-repo/skills/interf/SKILL.md +174 -134
- package/dist/packages/runtime/build/runtime-paths.d.ts +0 -8
- package/dist/packages/runtime/build/runtime-paths.js +0 -26
- package/dist/packages/runtime/build/state-paths.d.ts +0 -7
- package/dist/packages/runtime/build/state-paths.js +0 -22
- package/public-repo/build-plans/interf-default/build/stages/shape/SKILL.md +0 -34
- package/public-repo/build-plans/interf-default/build/stages/structure/SKILL.md +0 -28
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { TracesSchema } from "../../contracts/lib/project-schema.js";
|
|
3
|
-
import { BuildEvidenceResourceSchema, ProjectIdSchema, } from "../../contracts/lib/schema.js";
|
|
4
|
-
import {
|
|
2
|
+
import { ContextGraphHandoffSchema, TracesSchema, } from "../../contracts/lib/project-schema.js";
|
|
3
|
+
import { BuildEvidenceResourceSchema, GraphOutputCountsSchema, GraphManifestStageSummarySchema, GraphReadinessRollupSchema, MetricCountSchema, ProjectIdSchema, ResourceRefSchema, } from "../../contracts/lib/schema.js";
|
|
4
|
+
import { BuildRunResourceSchema, ContextGraphResourceSchema, ContextGraphSessionResponseSchema, ContextGraphSessionsResponseSchema, InstanceResourceSchema, LocalJobRunResourceSchema, LocalServiceHealthSchema, ProjectCreateRequestSchema, ProjectBuildPlanAuthoringCreateRequestSchema, ProjectBuildRunCreateRequestSchema, ProjectListResponseSchema, ProjectResourceSchema, ProjectWireShapeSchema, ReadinessResourceSchema, RunArtifactsResponseSchema, RunEventsResponseSchema, RunStatusResourceSchema, SourceFileListResponseSchema, SourceManifestResourceSchema, } from "../schemas/index.js";
|
|
5
5
|
const EmptyObjectSchema = z.object({}).strict();
|
|
6
6
|
const OpenApiDocumentSchema = z.record(z.string(), z.unknown());
|
|
7
|
-
const
|
|
8
|
-
.
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const ContextGraphStagesResponseSchema = z.object({
|
|
8
|
+
stages: z.array(GraphManifestStageSummarySchema),
|
|
9
|
+
readiness: GraphReadinessRollupSchema.nullable(),
|
|
10
|
+
primary_metrics: z.array(MetricCountSchema),
|
|
11
|
+
}).strict();
|
|
12
|
+
const ContextGraphResourcesResponseSchema = z.object({
|
|
13
|
+
resources: z.array(ResourceRefSchema),
|
|
14
|
+
entrypoints: z.array(ResourceRefSchema),
|
|
15
|
+
graph_outputs: GraphOutputCountsSchema.nullable(),
|
|
16
|
+
}).strict();
|
|
17
|
+
const ContextGraphResourceRefResponseSchema = z.object({
|
|
18
|
+
resource: ResourceRefSchema,
|
|
19
|
+
stage: GraphManifestStageSummarySchema.nullable(),
|
|
20
|
+
linked_resources: z.array(ResourceRefSchema),
|
|
21
|
+
}).strict();
|
|
13
22
|
const ProjectIdParameter = {
|
|
14
23
|
name: "project_id",
|
|
15
24
|
in: "path",
|
|
@@ -31,6 +40,20 @@ const ContextGraphFilePathParameter = {
|
|
|
31
40
|
description: "Relative file path inside the latest Context Graph.",
|
|
32
41
|
schema: z.string().min(1),
|
|
33
42
|
};
|
|
43
|
+
const ContextGraphResourceIdParameter = {
|
|
44
|
+
name: "resource_id",
|
|
45
|
+
in: "path",
|
|
46
|
+
required: true,
|
|
47
|
+
description: "ResourceRef id from the latest Context Graph manifest.",
|
|
48
|
+
schema: z.string().min(1),
|
|
49
|
+
};
|
|
50
|
+
const StageRunIdParameter = {
|
|
51
|
+
name: "stage_run_id",
|
|
52
|
+
in: "path",
|
|
53
|
+
required: true,
|
|
54
|
+
description: "Stage execution session id from the latest Build run.",
|
|
55
|
+
schema: z.string().min(1),
|
|
56
|
+
};
|
|
34
57
|
const RunFilePathParameter = {
|
|
35
58
|
name: "path",
|
|
36
59
|
in: "query",
|
|
@@ -72,13 +95,24 @@ export const SERVICE_OPERATIONS = [
|
|
|
72
95
|
response_schema: OpenApiDocumentSchema,
|
|
73
96
|
success_status: 200,
|
|
74
97
|
},
|
|
98
|
+
{
|
|
99
|
+
id: "listProjects",
|
|
100
|
+
method: "GET",
|
|
101
|
+
path: "/v1/projects",
|
|
102
|
+
tags: ["Projects"],
|
|
103
|
+
summary: "List Projects",
|
|
104
|
+
description: "Return Projects registered on this instance with Source bindings, intent, Build Plan selection, and Context Graph locators.",
|
|
105
|
+
visibility: "app",
|
|
106
|
+
response_schema: ProjectListResponseSchema,
|
|
107
|
+
success_status: 200,
|
|
108
|
+
},
|
|
75
109
|
{
|
|
76
110
|
id: "createProject",
|
|
77
111
|
method: "POST",
|
|
78
112
|
path: "/v1/projects",
|
|
79
113
|
tags: ["Projects"],
|
|
80
114
|
summary: "Create Project",
|
|
81
|
-
description: "Create a Project bound to one Source. Project ids may be generated by clients.",
|
|
115
|
+
description: "Create a Project bound to one Source and one agent task intent. Project ids may be generated by clients.",
|
|
82
116
|
visibility: "app",
|
|
83
117
|
workflow_step: 1,
|
|
84
118
|
request_schema: ProjectCreateRequestSchema,
|
|
@@ -94,7 +128,7 @@ export const SERVICE_OPERATIONS = [
|
|
|
94
128
|
description: "Read one Project to confirm its Source binding, selected Build Plan, readiness, and latest Context Graph.",
|
|
95
129
|
visibility: "app",
|
|
96
130
|
parameters: [ProjectIdParameter],
|
|
97
|
-
response_schema:
|
|
131
|
+
response_schema: ProjectResourceSchema,
|
|
98
132
|
success_status: 200,
|
|
99
133
|
},
|
|
100
134
|
{
|
|
@@ -103,11 +137,11 @@ export const SERVICE_OPERATIONS = [
|
|
|
103
137
|
path: "/v1/projects/{project_id}/build-plan-drafts",
|
|
104
138
|
tags: ["Build Plans"],
|
|
105
139
|
summary: "Prepare Build Plan",
|
|
106
|
-
description: "Draft a Build Plan from the
|
|
140
|
+
description: "Draft a Build Plan from the Project intent, requested outputs, and coverage expectations. This does not run a Build.",
|
|
107
141
|
visibility: "app",
|
|
108
142
|
workflow_step: 2,
|
|
109
143
|
parameters: [ProjectIdParameter],
|
|
110
|
-
request_schema:
|
|
144
|
+
request_schema: ProjectBuildPlanAuthoringCreateRequestSchema,
|
|
111
145
|
response_schema: LocalJobRunResourceSchema,
|
|
112
146
|
success_status: 202,
|
|
113
147
|
},
|
|
@@ -149,6 +183,18 @@ export const SERVICE_OPERATIONS = [
|
|
|
149
183
|
response_schema: RunArtifactsResponseSchema,
|
|
150
184
|
success_status: 200,
|
|
151
185
|
},
|
|
186
|
+
{
|
|
187
|
+
id: "getRunEvents",
|
|
188
|
+
method: "GET",
|
|
189
|
+
path: "/v1/runs/{run_id}/events",
|
|
190
|
+
tags: ["Runs"],
|
|
191
|
+
summary: "Get Run events",
|
|
192
|
+
description: "Read the durable event log for a Build run: stage start/pass/fail, files processed, artifacts written, evidence, checks, and readiness. Use compact status for polling; read events to inspect or replay what happened.",
|
|
193
|
+
visibility: "app",
|
|
194
|
+
parameters: [RunIdParameter],
|
|
195
|
+
response_schema: RunEventsResponseSchema,
|
|
196
|
+
success_status: 200,
|
|
197
|
+
},
|
|
152
198
|
{
|
|
153
199
|
id: "readRunFile",
|
|
154
200
|
method: "GET",
|
|
@@ -168,12 +214,84 @@ export const SERVICE_OPERATIONS = [
|
|
|
168
214
|
path: "/v1/projects/{project_id}/context-graph",
|
|
169
215
|
tags: ["Context Graphs"],
|
|
170
216
|
summary: "Get latest Context Graph",
|
|
171
|
-
description: "Return the latest successful Context Graph locator
|
|
217
|
+
description: "Return the latest successful Context Graph locator, GraphManifest, primary metrics, StageManifest summaries, entrypoints, and ready/not ready rollup for a Project.",
|
|
172
218
|
visibility: "app",
|
|
173
219
|
parameters: [ProjectIdParameter],
|
|
174
220
|
response_schema: ContextGraphResourceSchema,
|
|
175
221
|
success_status: 200,
|
|
176
222
|
},
|
|
223
|
+
{
|
|
224
|
+
id: "listContextGraphStages",
|
|
225
|
+
method: "GET",
|
|
226
|
+
path: "/v1/projects/{project_id}/context-graph/stages",
|
|
227
|
+
tags: ["Context Graphs"],
|
|
228
|
+
summary: "List Context Graph StageManifests",
|
|
229
|
+
description: "Return StageManifest summaries for the latest Context Graph.",
|
|
230
|
+
visibility: "app",
|
|
231
|
+
parameters: [ProjectIdParameter],
|
|
232
|
+
response_schema: ContextGraphStagesResponseSchema,
|
|
233
|
+
success_status: 200,
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
id: "listContextGraphResources",
|
|
237
|
+
method: "GET",
|
|
238
|
+
path: "/v1/projects/{project_id}/context-graph/resources",
|
|
239
|
+
tags: ["Context Graphs"],
|
|
240
|
+
summary: "List Context Graph resources",
|
|
241
|
+
description: "Return the ResourceRef index from the latest GraphManifest.",
|
|
242
|
+
visibility: "app",
|
|
243
|
+
parameters: [ProjectIdParameter],
|
|
244
|
+
response_schema: ContextGraphResourcesResponseSchema,
|
|
245
|
+
success_status: 200,
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: "listContextGraphSessions",
|
|
249
|
+
method: "GET",
|
|
250
|
+
path: "/v1/projects/{project_id}/context-graph/sessions",
|
|
251
|
+
tags: ["Context Graphs"],
|
|
252
|
+
summary: "List Context Graph execution sessions",
|
|
253
|
+
description: "Return replayable per-stage execution shell sessions for the latest Build run, including workspace, prompt, logs, validation attempts, and stage contract paths.",
|
|
254
|
+
visibility: "app",
|
|
255
|
+
parameters: [ProjectIdParameter],
|
|
256
|
+
response_schema: ContextGraphSessionsResponseSchema,
|
|
257
|
+
success_status: 200,
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
id: "getContextGraphResource",
|
|
261
|
+
method: "GET",
|
|
262
|
+
path: "/v1/projects/{project_id}/context-graph/resources/{resource_id}",
|
|
263
|
+
tags: ["Context Graphs"],
|
|
264
|
+
summary: "Get Context Graph resource",
|
|
265
|
+
description: "Return one ResourceRef from the latest GraphManifest for inspector drilldown.",
|
|
266
|
+
visibility: "app",
|
|
267
|
+
parameters: [ProjectIdParameter, ContextGraphResourceIdParameter],
|
|
268
|
+
response_schema: ContextGraphResourceRefResponseSchema,
|
|
269
|
+
success_status: 200,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: "getContextGraphSession",
|
|
273
|
+
method: "GET",
|
|
274
|
+
path: "/v1/projects/{project_id}/context-graph/sessions/{stage_run_id}",
|
|
275
|
+
tags: ["Context Graphs"],
|
|
276
|
+
summary: "Get Context Graph execution session",
|
|
277
|
+
description: "Return one replayable stage execution shell session for inspector drilldown.",
|
|
278
|
+
visibility: "app",
|
|
279
|
+
parameters: [ProjectIdParameter, StageRunIdParameter],
|
|
280
|
+
response_schema: ContextGraphSessionResponseSchema,
|
|
281
|
+
success_status: 200,
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: "getProjectReadiness",
|
|
285
|
+
method: "GET",
|
|
286
|
+
path: "/v1/projects/{project_id}/readiness",
|
|
287
|
+
tags: ["Context Graphs"],
|
|
288
|
+
summary: "Get Project readiness",
|
|
289
|
+
description: "Read the ready/not ready verdict for the latest Context Graph against the Project intent.",
|
|
290
|
+
visibility: "app",
|
|
291
|
+
parameters: [ProjectIdParameter],
|
|
292
|
+
response_schema: ReadinessResourceSchema,
|
|
293
|
+
success_status: 200,
|
|
294
|
+
},
|
|
177
295
|
{
|
|
178
296
|
id: "listSourceFiles",
|
|
179
297
|
method: "GET",
|
|
@@ -198,13 +316,25 @@ export const SERVICE_OPERATIONS = [
|
|
|
198
316
|
response_schema: SourceManifestResourceSchema,
|
|
199
317
|
success_status: 200,
|
|
200
318
|
},
|
|
319
|
+
{
|
|
320
|
+
id: "getContextGraphEntrypoint",
|
|
321
|
+
method: "GET",
|
|
322
|
+
path: "/v1/projects/{project_id}/context-graph/entrypoint",
|
|
323
|
+
tags: ["Context Graphs"],
|
|
324
|
+
summary: "Get Context Graph entrypoint",
|
|
325
|
+
description: "Return the primary downstream entrypoint for the latest Context Graph. Agents should start from home.md.",
|
|
326
|
+
visibility: "app",
|
|
327
|
+
parameters: [ProjectIdParameter],
|
|
328
|
+
response_schema: ContextGraphHandoffSchema,
|
|
329
|
+
success_status: 200,
|
|
330
|
+
},
|
|
201
331
|
{
|
|
202
332
|
id: "readContextGraphFile",
|
|
203
333
|
method: "GET",
|
|
204
334
|
path: "/v1/projects/{project_id}/context-graph/file",
|
|
205
335
|
tags: ["Context Graphs"],
|
|
206
336
|
summary: "Read Context Graph file",
|
|
207
|
-
description: "Read one file from the latest Context Graph by relative path. Start with
|
|
337
|
+
description: "Read one file from the latest Context Graph by relative path. Start with home.md; use knowledge/ for task-specific notes and summaries/ for source-backed coverage.",
|
|
208
338
|
visibility: "app",
|
|
209
339
|
parameters: [ProjectIdParameter, ContextGraphFilePathParameter],
|
|
210
340
|
response_schema: z.string(),
|
|
@@ -228,8 +358,8 @@ export const SERVICE_OPERATIONS = [
|
|
|
228
358
|
method: "GET",
|
|
229
359
|
path: "/v1/projects/{project_id}/context-graph/evidence",
|
|
230
360
|
tags: ["Context Graphs"],
|
|
231
|
-
summary: "Get
|
|
232
|
-
description: "Read
|
|
361
|
+
summary: "Get graph diagnostics",
|
|
362
|
+
description: "Read supplemental diagnostic rows for the latest Context Graph. GraphManifest primary metrics are the authoritative coverage summary.",
|
|
233
363
|
visibility: "app",
|
|
234
364
|
parameters: [ProjectIdParameter],
|
|
235
365
|
response_schema: BuildEvidenceResourceSchema,
|
|
@@ -57,15 +57,23 @@ export declare const PROJECT_SUBRESOURCES: {
|
|
|
57
57
|
readonly contextGraph: "context-graph";
|
|
58
58
|
/** First-class traces surface — per-claim provenance back to source. */
|
|
59
59
|
readonly traces: "context-graph/traces";
|
|
60
|
-
/**
|
|
60
|
+
/** Stage Manifest summaries for the latest Context Graph. */
|
|
61
|
+
readonly contextGraphStages: "context-graph/stages";
|
|
62
|
+
/** Replayable stage execution shell sessions for the latest Build run. */
|
|
63
|
+
readonly contextGraphSessions: "context-graph/sessions";
|
|
64
|
+
/** ResourceRef index for the latest Context Graph. */
|
|
65
|
+
readonly contextGraphResources: "context-graph/resources";
|
|
66
|
+
/** Supplemental graph diagnostics. Graph Manifest metrics are authoritative. */
|
|
61
67
|
readonly buildEvidence: "context-graph/evidence";
|
|
68
|
+
/** Primary downstream graph entrypoint. */
|
|
69
|
+
readonly contextGraphEntrypoint: "context-graph/entrypoint";
|
|
62
70
|
/** Read a single Context Graph file using a query param: `?path=<relpath>`. */
|
|
63
71
|
readonly contextGraphFile: "context-graph/file";
|
|
64
72
|
/** Drift state for the Project's Source binding. */
|
|
65
73
|
readonly sourceState: "source-state";
|
|
66
74
|
/**
|
|
67
|
-
*
|
|
68
|
-
* and
|
|
75
|
+
* Per-output detail. Returns the latest status, contributing stages,
|
|
76
|
+
* and diagnostics for a Build Plan-declared requested output:
|
|
69
77
|
* GET /v1/projects/<id>/artifacts/<artifact-id>
|
|
70
78
|
*/
|
|
71
79
|
readonly artifacts: "artifacts";
|
|
@@ -58,15 +58,23 @@ export const PROJECT_SUBRESOURCES = {
|
|
|
58
58
|
contextGraph: "context-graph",
|
|
59
59
|
/** First-class traces surface — per-claim provenance back to source. */
|
|
60
60
|
traces: "context-graph/traces",
|
|
61
|
-
/**
|
|
61
|
+
/** Stage Manifest summaries for the latest Context Graph. */
|
|
62
|
+
contextGraphStages: "context-graph/stages",
|
|
63
|
+
/** Replayable stage execution shell sessions for the latest Build run. */
|
|
64
|
+
contextGraphSessions: "context-graph/sessions",
|
|
65
|
+
/** ResourceRef index for the latest Context Graph. */
|
|
66
|
+
contextGraphResources: "context-graph/resources",
|
|
67
|
+
/** Supplemental graph diagnostics. Graph Manifest metrics are authoritative. */
|
|
62
68
|
buildEvidence: "context-graph/evidence",
|
|
69
|
+
/** Primary downstream graph entrypoint. */
|
|
70
|
+
contextGraphEntrypoint: "context-graph/entrypoint",
|
|
63
71
|
/** Read a single Context Graph file using a query param: `?path=<relpath>`. */
|
|
64
72
|
contextGraphFile: "context-graph/file",
|
|
65
73
|
/** Drift state for the Project's Source binding. */
|
|
66
74
|
sourceState: "source-state",
|
|
67
75
|
/**
|
|
68
|
-
*
|
|
69
|
-
* and
|
|
76
|
+
* Per-output detail. Returns the latest status, contributing stages,
|
|
77
|
+
* and diagnostics for a Build Plan-declared requested output:
|
|
70
78
|
* GET /v1/projects/<id>/artifacts/<artifact-id>
|
|
71
79
|
*/
|
|
72
80
|
artifacts: "artifacts",
|
|
@@ -35,12 +35,12 @@ export function sendDesktopAppBoot(req, res, runtime) {
|
|
|
35
35
|
<script id="interf-app-boot" type="application/json">${json}</script>
|
|
36
36
|
</head>
|
|
37
37
|
<body>
|
|
38
|
-
<p>Interf local service is running
|
|
38
|
+
<p>Interf local service is running.</p>
|
|
39
39
|
</body>
|
|
40
40
|
</html>
|
|
41
41
|
`);
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
44
|
export function sendServiceNotFound(res) {
|
|
45
|
-
sendText(res, 404, "Not found.
|
|
45
|
+
sendText(res, 404, "Not found. Interf local service is running.\n");
|
|
46
46
|
}
|
|
@@ -25,3 +25,14 @@ export declare function sendError(res: ServerResponse, statusCode: number, conte
|
|
|
25
25
|
export declare function sendErrorResponse(res: ServerResponse, error: unknown, fallbackStatus?: number): void;
|
|
26
26
|
export declare function readJsonBody(req: IncomingMessage): Promise<unknown>;
|
|
27
27
|
export declare function parseRequestUrl(req: IncomingMessage): URL;
|
|
28
|
+
/**
|
|
29
|
+
* Decode a single percent-encoded path segment, or send a structured 400 and
|
|
30
|
+
* return `null`. `decodeURIComponent` throws a `URIError` on malformed input
|
|
31
|
+
* (e.g. a truncated escape like `%E0%A4%A`); left unguarded that crashes the
|
|
32
|
+
* handler into an uncaught 500. Routing every guarded call site through this
|
|
33
|
+
* helper keeps the decode semantics and the 400 message single-sourced.
|
|
34
|
+
*
|
|
35
|
+
* `label` names the id in the error message, e.g. `"Run id"` ->
|
|
36
|
+
* `"Run id is not valid URI-encoded UTF-8."`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeOr400(res: ServerResponse, raw: string, label: string): string | null;
|
|
@@ -87,3 +87,22 @@ export async function readJsonBody(req) {
|
|
|
87
87
|
export function parseRequestUrl(req) {
|
|
88
88
|
return new URL(req.url ?? "/", "http://127.0.0.1");
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Decode a single percent-encoded path segment, or send a structured 400 and
|
|
92
|
+
* return `null`. `decodeURIComponent` throws a `URIError` on malformed input
|
|
93
|
+
* (e.g. a truncated escape like `%E0%A4%A`); left unguarded that crashes the
|
|
94
|
+
* handler into an uncaught 500. Routing every guarded call site through this
|
|
95
|
+
* helper keeps the decode semantics and the 400 message single-sourced.
|
|
96
|
+
*
|
|
97
|
+
* `label` names the id in the error message, e.g. `"Run id"` ->
|
|
98
|
+
* `"Run id is not valid URI-encoded UTF-8."`.
|
|
99
|
+
*/
|
|
100
|
+
export function decodeOr400(res, raw, label) {
|
|
101
|
+
try {
|
|
102
|
+
return decodeURIComponent(raw);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
sendError(res, 400, `${label} is not valid URI-encoded UTF-8.`);
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LOCAL_SERVICE_ROUTES } from "./routes.js";
|
|
2
|
-
import { readJsonBody, sendError, sendJson, } from "./server-helpers.js";
|
|
2
|
+
import { decodeOr400, readJsonBody, sendError, sendJson, } from "./server-helpers.js";
|
|
3
3
|
import { listStoredProjects } from "../project-store.js";
|
|
4
4
|
export async function tryHandleActionProposals(req, res, runtime, path, method) {
|
|
5
5
|
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.actionProposals) {
|
|
@@ -17,7 +17,9 @@ export async function tryHandleActionProposals(req, res, runtime, path, method)
|
|
|
17
17
|
}
|
|
18
18
|
const actionProposalMatch = path.match(/^\/v1\/action-proposals\/([^/]+)(?:\/([^/]+))?$/);
|
|
19
19
|
if (actionProposalMatch?.[1]) {
|
|
20
|
-
const proposalId =
|
|
20
|
+
const proposalId = decodeOr400(res, actionProposalMatch[1], "Action proposal id");
|
|
21
|
+
if (proposalId === null)
|
|
22
|
+
return true;
|
|
21
23
|
const child = actionProposalMatch[2];
|
|
22
24
|
const firstProject = listStoredProjects()[0];
|
|
23
25
|
const projectDataDir = firstProject?.projectDataDir ?? runtime.rootPath;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import { InterfMcpHandoffSchema } from "../schemas/index.js";
|
|
2
|
+
import { AgentPrefsPatchSchema, AgentRoleMapPatchSchema, CustomAgentRegisterRequestSchema, InterfMcpHandoffSchema, } from "../schemas/index.js";
|
|
3
3
|
import { buildInterfMcpHandoff } from "../agent-handoff.js";
|
|
4
4
|
import { buildLocalServiceUrl, LOCAL_SERVICE_ROUTES } from "./routes.js";
|
|
5
|
-
import { readJsonBody, sendError, sendJson, } from "./server-helpers.js";
|
|
5
|
+
import { decodeOr400, readJsonBody, sendError, sendJson, } from "./server-helpers.js";
|
|
6
6
|
import { packageRoot } from "./server-api-files.js";
|
|
7
7
|
export async function tryHandleExecutor(req, res, runtime, path, method) {
|
|
8
8
|
if (method === "GET" && path === LOCAL_SERVICE_ROUTES.executor) {
|
|
@@ -24,28 +24,8 @@ export async function tryHandleAgents(req, res, runtime, path, method) {
|
|
|
24
24
|
}
|
|
25
25
|
if (method === "POST") {
|
|
26
26
|
try {
|
|
27
|
-
const body = (await readJsonBody(req));
|
|
28
|
-
|
|
29
|
-
sendError(res, 400, "Request body must be a JSON object.");
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
if (!body.name || typeof body.name !== "string") {
|
|
33
|
-
sendError(res, 400, "Missing required field: name");
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
if (!body.display_name || typeof body.display_name !== "string") {
|
|
37
|
-
sendError(res, 400, "Missing required field: display_name");
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
if (!body.command || typeof body.command !== "string") {
|
|
41
|
-
sendError(res, 400, "Missing required field: command");
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
const updated = runtime.registerCustomAgent({
|
|
45
|
-
name: body.name,
|
|
46
|
-
display_name: body.display_name,
|
|
47
|
-
command: body.command,
|
|
48
|
-
});
|
|
27
|
+
const body = CustomAgentRegisterRequestSchema.parse(await readJsonBody(req));
|
|
28
|
+
const updated = runtime.registerCustomAgent(body);
|
|
49
29
|
sendJson(res, 201, updated);
|
|
50
30
|
}
|
|
51
31
|
catch (error) {
|
|
@@ -90,19 +70,7 @@ export async function tryHandleAgents(req, res, runtime, path, method) {
|
|
|
90
70
|
}
|
|
91
71
|
if (method === "PATCH") {
|
|
92
72
|
try {
|
|
93
|
-
const
|
|
94
|
-
if (!body || typeof body !== "object") {
|
|
95
|
-
sendError(res, 400, "Request body must be a JSON object.");
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
const patch = {};
|
|
99
|
-
for (const [role, value] of Object.entries(body)) {
|
|
100
|
-
if (typeof value !== "string") {
|
|
101
|
-
sendError(res, 400, `Role-map values must be strings (or "" to clear). Got ${typeof value} for role "${role}".`);
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
patch[role] = value;
|
|
105
|
-
}
|
|
73
|
+
const patch = AgentRoleMapPatchSchema.parse(await readJsonBody(req));
|
|
106
74
|
const updated = runtime.patchAgentsRoleMap(patch);
|
|
107
75
|
sendJson(res, 200, updated);
|
|
108
76
|
}
|
|
@@ -117,7 +85,9 @@ export async function tryHandleAgents(req, res, runtime, path, method) {
|
|
|
117
85
|
// effort) for built-ins or custom agents alike.
|
|
118
86
|
const agentMatch = path.match(/^\/v1\/agents\/([^/]+)$/);
|
|
119
87
|
if (agentMatch?.[1] && method === "DELETE") {
|
|
120
|
-
const name =
|
|
88
|
+
const name = decodeOr400(res, agentMatch[1], "Agent name");
|
|
89
|
+
if (name === null)
|
|
90
|
+
return true;
|
|
121
91
|
try {
|
|
122
92
|
const updated = runtime.unregisterCustomAgent(name);
|
|
123
93
|
sendJson(res, 200, updated);
|
|
@@ -130,61 +100,25 @@ export async function tryHandleAgents(req, res, runtime, path, method) {
|
|
|
130
100
|
return true;
|
|
131
101
|
}
|
|
132
102
|
if (agentMatch?.[1] && method === "PATCH") {
|
|
133
|
-
const name =
|
|
103
|
+
const name = decodeOr400(res, agentMatch[1], "Agent name");
|
|
104
|
+
if (name === null)
|
|
105
|
+
return true;
|
|
134
106
|
try {
|
|
135
|
-
const body = (await readJsonBody(req));
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
107
|
+
const body = AgentPrefsPatchSchema.parse(await readJsonBody(req));
|
|
108
|
+
// Normalize the validated patch into the stored prefs shape, preserving
|
|
109
|
+
// the prior wire tolerance: an empty env_vars map is omitted, and a `""`
|
|
110
|
+
// or `null` model/effort clears that pref.
|
|
140
111
|
const prefs = {};
|
|
141
112
|
if ("env_vars" in body) {
|
|
142
113
|
const value = body.env_vars;
|
|
143
|
-
if (value
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
else if (typeof value === "object" && !Array.isArray(value)) {
|
|
147
|
-
const entries = {};
|
|
148
|
-
for (const [k, v] of Object.entries(value)) {
|
|
149
|
-
if (typeof v !== "string") {
|
|
150
|
-
sendError(res, 400, `env_vars values must be strings. Got ${typeof v} for "${k}".`);
|
|
151
|
-
return true;
|
|
152
|
-
}
|
|
153
|
-
entries[k] = v;
|
|
154
|
-
}
|
|
155
|
-
if (Object.keys(entries).length > 0)
|
|
156
|
-
prefs.env_vars = entries;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
sendError(res, 400, "env_vars must be an object of string→string entries.");
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
114
|
+
if (value && Object.keys(value).length > 0)
|
|
115
|
+
prefs.env_vars = value;
|
|
162
116
|
}
|
|
163
117
|
if ("model" in body) {
|
|
164
|
-
|
|
165
|
-
if (value === null || value === "" || value === undefined) {
|
|
166
|
-
prefs.model = null;
|
|
167
|
-
}
|
|
168
|
-
else if (typeof value === "string") {
|
|
169
|
-
prefs.model = value;
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
sendError(res, 400, "model must be a string or null.");
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
118
|
+
prefs.model = body.model === "" ? null : body.model ?? null;
|
|
175
119
|
}
|
|
176
120
|
if ("effort" in body) {
|
|
177
|
-
|
|
178
|
-
if (value === null || value === "" || value === undefined) {
|
|
179
|
-
prefs.effort = null;
|
|
180
|
-
}
|
|
181
|
-
else if (typeof value === "string") {
|
|
182
|
-
prefs.effort = value;
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
sendError(res, 400, "effort must be a string or null.");
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
121
|
+
prefs.effort = body.effort === "" ? null : body.effort ?? null;
|
|
188
122
|
}
|
|
189
123
|
const updated = runtime.setAgentPrefs(name, prefs);
|
|
190
124
|
sendJson(res, 200, updated);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BuildPlanSaveRequestSchema } from "../schemas/index.js";
|
|
2
2
|
import { LOCAL_SERVICE_ROUTES } from "./routes.js";
|
|
3
|
-
import { readJsonBody, sendError, sendJson, } from "./server-helpers.js";
|
|
3
|
+
import { decodeOr400, readJsonBody, sendError, sendJson, } from "./server-helpers.js";
|
|
4
4
|
import { isTraversalRelativePath, safeApiFilePath, sendApiFile, } from "./server-api-files.js";
|
|
5
5
|
import { findInstanceBuildPlan, listInstanceBuildPlanRuns, listInstanceBuildPlans, resolveInstanceBuildPlanPackageRoot, } from "./server-instance-helpers.js";
|
|
6
6
|
import { installUserBuildPlan } from "../../build-plans/package/user-build-plans.js";
|
|
@@ -30,7 +30,10 @@ export async function tryHandleBuildPlans(req, res, runtime, path, method) {
|
|
|
30
30
|
}
|
|
31
31
|
const buildPlanMatch = path.match(/^\/v1\/build-plans\/([^/]+)$/);
|
|
32
32
|
if (method === "GET" && buildPlanMatch?.[1]) {
|
|
33
|
-
const
|
|
33
|
+
const buildPlanId = decodeOr400(res, buildPlanMatch[1], "Build Plan id");
|
|
34
|
+
if (buildPlanId === null)
|
|
35
|
+
return true;
|
|
36
|
+
const buildPlanResource = findInstanceBuildPlan(runtime, buildPlanId);
|
|
34
37
|
if (!buildPlanResource)
|
|
35
38
|
sendError(res, 404, "Build Plan not found.");
|
|
36
39
|
else
|
|
@@ -39,7 +42,10 @@ export async function tryHandleBuildPlans(req, res, runtime, path, method) {
|
|
|
39
42
|
}
|
|
40
43
|
const buildPlanRunsMatch = path.match(/^\/v1\/build-plans\/([^/]+)\/runs$/);
|
|
41
44
|
if (method === "GET" && buildPlanRunsMatch?.[1]) {
|
|
42
|
-
const
|
|
45
|
+
const buildPlanId = decodeOr400(res, buildPlanRunsMatch[1], "Build Plan id");
|
|
46
|
+
if (buildPlanId === null)
|
|
47
|
+
return true;
|
|
48
|
+
const runs = listInstanceBuildPlanRuns(runtime, buildPlanId);
|
|
43
49
|
sendJson(res, 200, { runs });
|
|
44
50
|
return true;
|
|
45
51
|
}
|
|
@@ -51,15 +57,12 @@ export async function tryHandleBuildPlans(req, res, runtime, path, method) {
|
|
|
51
57
|
// the resolved root.
|
|
52
58
|
const buildPlanFilesMatch = path.match(/^\/v1\/build-plans\/([^/]+)\/files\/(.+)$/);
|
|
53
59
|
if (method === "GET" && buildPlanFilesMatch?.[1] && buildPlanFilesMatch[2]) {
|
|
54
|
-
const buildPlanId =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
catch {
|
|
60
|
-
sendError(res, 400, "File path is not valid URI-encoded UTF-8.");
|
|
60
|
+
const buildPlanId = decodeOr400(res, buildPlanFilesMatch[1], "Build Plan id");
|
|
61
|
+
if (buildPlanId === null)
|
|
62
|
+
return true;
|
|
63
|
+
const relPath = decodeOr400(res, buildPlanFilesMatch[2], "File path");
|
|
64
|
+
if (relPath === null)
|
|
61
65
|
return true;
|
|
62
|
-
}
|
|
63
66
|
if (isTraversalRelativePath(relPath)) {
|
|
64
67
|
sendError(res, 400, "File path escapes Build Plan root.");
|
|
65
68
|
return true;
|