create-principles-disciple 1.147.18 → 1.148.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/_release/product-identity.json +1 -1
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/config/pd-config-store.js +6 -6
- package/console/dist/server/index.d.ts +20 -0
- package/console/dist/server/index.js +104 -84
- package/console/dist/server/models/ApprovalsConsoleModel.d.ts +1 -1
- package/console/dist/server/models/ApprovalsConsoleModel.js +5 -2
- package/console/dist/server/models/GovernanceExperienceCollector.js +2 -1
- package/console/dist/server/models/GovernanceProjectionCollector.js +11 -10
- package/console/dist/server/models/IntentPageModel.js +1 -1
- package/console/dist/server/models/OwnerDecisionViewModel.d.ts +3 -2
- package/console/dist/server/models/OwnerDecisionViewModel.js +8 -7
- package/console/dist/server/routes/activations.js +5 -5
- package/console/dist/server/routes/approvals-grouped.js +2 -2
- package/console/dist/server/routes/approvals.js +7 -7
- package/console/dist/server/routes/config.d.ts +4 -4
- package/console/dist/server/routes/config.js +5 -5
- package/console/dist/server/routes/evidence-chain.d.ts +1 -1
- package/console/dist/server/routes/evidence-outcomes.d.ts +2 -2
- package/console/dist/server/routes/examiner.d.ts +12 -12
- package/console/dist/server/routes/examiner.js +2 -2
- package/console/dist/server/routes/failed-tasks.d.ts +4 -4
- package/console/dist/server/routes/failed-tasks.js +10 -10
- package/console/dist/server/routes/governance.d.ts +1 -1
- package/console/dist/server/routes/governance.js +3 -3
- package/console/dist/server/routes/intent-decisions.d.ts +6 -6
- package/console/dist/server/routes/intent-decisions.js +13 -13
- package/console/dist/server/routes/intent.js +6 -6
- package/console/dist/server/routes/lifecycle.js +3 -3
- package/console/dist/server/routes/onboarding.d.ts +1 -1
- package/console/dist/server/routes/onboarding.js +4 -4
- package/console/dist/server/routes/owner-decision.d.ts +5 -5
- package/console/dist/server/routes/owner-decision.js +3 -3
- package/console/dist/server/routes/owner-decisions.d.ts +3 -3
- package/console/dist/server/routes/owner-decisions.js +3 -3
- package/console/dist/server/routes/owner-identity.d.ts +1 -1
- package/console/dist/server/routes/owner-identity.js +1 -1
- package/console/dist/server/routes/principles.d.ts +4 -3
- package/console/dist/server/routes/principles.js +5 -4
- package/console/dist/server/routes/receipts.d.ts +2 -2
- package/console/dist/server/routes/receipts.js +4 -4
- package/console/dist/server.d.ts +2 -1
- package/console/dist/server.js +9 -1
- package/console/dist/shared/prompt-injection-contract.d.ts +1 -1
- package/console/dist/web/assets/app.js +23 -23
- package/core/dist/index.d.ts +1 -1
- package/core/dist/index.d.ts.map +1 -1
- package/core/dist/index.js +3 -2
- package/core/dist/index.js.map +1 -1
- package/core/dist/runtime/activation/approval-review-guard.d.ts +2 -2
- package/core/dist/runtime/activation/approval-review-guard.d.ts.map +1 -1
- package/core/dist/runtime/activation/approval-review-guard.js +6 -1
- package/core/dist/runtime/activation/approval-review-guard.js.map +1 -1
- package/core/dist/runtime/activation/prompt-budget-policy.d.ts +9 -1
- package/core/dist/runtime/activation/prompt-budget-policy.d.ts.map +1 -1
- package/core/dist/runtime/activation/prompt-budget-policy.js +9 -1
- package/core/dist/runtime/activation/prompt-budget-policy.js.map +1 -1
- package/core/dist/runtime/activation/recovery-control-surfaces.d.ts +1 -1
- package/core/dist/runtime/activation/recovery-control-surfaces.js +2 -2
- package/core/dist/runtime/activation/recovery-control-surfaces.js.map +1 -1
- package/core/dist/runtime/adapter/output-schema-registry.d.ts +1 -1
- package/core/dist/runtime/adapter/output-schema-registry.d.ts.map +1 -1
- package/core/dist/runtime/adapter/output-schema-registry.js +23 -18
- package/core/dist/runtime/adapter/output-schema-registry.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/schema-json-converter.d.ts +1 -1
- package/core/dist/runtime/adapter/schema-json-converter.js +1 -1
- package/core/dist/runtime/adapter/tools/diagnostician-tool.js +1 -1
- package/core/dist/runtime/adapter/tools/diagnostician-tool.js.map +1 -1
- package/core/dist/runtime/diagnostician-output.d.ts +2 -2
- package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-output.js +1 -1
- package/core/dist/runtime/diagnostician-output.js.map +1 -1
- package/core/dist/runtime/feature-flags/plugin-surface-registry.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/plugin-surface-registry.js +10 -0
- package/core/dist/runtime/feature-flags/plugin-surface-registry.js.map +1 -1
- package/core/dist/runtime/governance-experience-contract.d.ts +4 -4
- package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience-contract.js +3 -2
- package/core/dist/runtime/governance-experience-contract.js.map +1 -1
- package/core/dist/runtime/governance-experience.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience.js +2 -1
- package/core/dist/runtime/governance-experience.js.map +1 -1
- package/core/dist/runtime/governance-projection-contract.d.ts +14 -14
- package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-projection-contract.js +4 -3
- package/core/dist/runtime/governance-projection-contract.js.map +1 -1
- package/core/dist/runtime/governance-projection.d.ts.map +1 -1
- package/core/dist/runtime/governance-projection.js +2 -1
- package/core/dist/runtime/governance-projection.js.map +1 -1
- package/core/dist/runtime/index.d.ts +2 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +2 -3
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/artificer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-runner.js +3 -2
- package/core/dist/runtime/internalization/artificer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.js +3 -2
- package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.js +3 -2
- package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.js +4 -3
- package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.js +3 -2
- package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.js +3 -2
- package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.js +3 -2
- package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.js +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js +3 -2
- package/core/dist/runtime/internalization/rollout-reviewer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/router-context-evidence.d.ts +1 -1
- package/core/dist/runtime/internalization/router-context-evidence.d.ts.map +1 -1
- package/core/dist/runtime/internalization/router-context-evidence.js +4 -1
- package/core/dist/runtime/internalization/router-context-evidence.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +3 -2
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/learning-lab/actor-action-output.d.ts +1 -1
- package/core/dist/runtime/learning-lab/actor-action-output.d.ts.map +1 -1
- package/core/dist/runtime/learning-lab/actor-action-output.js +1 -1
- package/core/dist/runtime/learning-lab/actor-action-output.js.map +1 -1
- package/core/dist/runtime/observer/correction-observer.d.ts.map +1 -1
- package/core/dist/runtime/observer/correction-observer.js +3 -2
- package/core/dist/runtime/observer/correction-observer.js.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +2 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +8 -8
- package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view.js +10 -9
- package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-evaluation-output.d.ts +1 -1
- package/core/dist/runtime/principle-reuse/reuse-evaluation-output.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-evaluation-output.js +1 -1
- package/core/dist/runtime/principle-reuse/reuse-evaluation-output.js.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-evaluation-runner.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-evaluation-runner.js +5 -4
- package/core/dist/runtime/principle-reuse/reuse-evaluation-runner.js.map +1 -1
- package/core/dist/runtime/schema-version.d.ts +30 -14
- package/core/dist/runtime/schema-version.d.ts.map +1 -1
- package/core/dist/runtime/schema-version.js +33 -13
- package/core/dist/runtime/schema-version.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts +32 -1
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +819 -47
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/dist/utils/config-file-io.d.ts +27 -1
- package/dist/utils/config-file-io.d.ts.map +1 -1
- package/dist/utils/config-file-io.js +78 -3
- package/dist/utils/config-file-io.js.map +1 -1
- package/host-runtime/dist/prompt-injection-budget-observation.js +10 -8
- package/host-runtime/dist/signal-classifier.d.ts +3 -1
- package/host-runtime/dist/signal-classifier.js +5 -3
- package/host-runtime/package.json +1 -1
- package/package.json +3 -3
- package/pd-cli/package.json +1 -1
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/package.json +1 -1
- package/plugin/dist/bundle.js +441 -441
- package/plugin/dist/core/event-log.d.ts +5 -0
- package/plugin/dist/governance-audit.js +2 -2
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/rulehost-evidence.js +9 -9
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installers/workbuddy-host-installer.js +819 -47
- package/release-manager/dist/utils/config-file-io.js +78 -3
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/package.json +1 -1
|
@@ -187,7 +187,7 @@ export class IntentPageModel {
|
|
|
187
187
|
return {
|
|
188
188
|
ok: false,
|
|
189
189
|
reason: 'not_found',
|
|
190
|
-
nextAction: `${getIntentFilename(lang)} does not exist. Create it first using POST /api/
|
|
190
|
+
nextAction: `${getIntentFilename(lang)} does not exist. Create it first using POST /api/intent/init.`,
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
193
|
if ('oversized' in read) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
|
|
1
2
|
import type { OwnerDecisionViewCore } from '@principles/core/runtime';
|
|
2
3
|
export interface OwnerDecisionInboxItem {
|
|
3
4
|
principleId: string;
|
|
@@ -15,7 +16,7 @@ export interface OwnerDecisionInboxItem {
|
|
|
15
16
|
nextAction: OwnerDecisionViewCore['nextAction'];
|
|
16
17
|
}
|
|
17
18
|
export interface OwnerDecisionInboxResponse {
|
|
18
|
-
schemaVersion:
|
|
19
|
+
schemaVersion: typeof RUNTIME_CONTRACT_SCHEMA_VERSION;
|
|
19
20
|
generatedAt: string;
|
|
20
21
|
totalPrinciples: number;
|
|
21
22
|
groups: {
|
|
@@ -42,7 +43,7 @@ export declare class OwnerDecisionViewModel {
|
|
|
42
43
|
getInbox(now?: string): Promise<OwnerDecisionInboxResponse>;
|
|
43
44
|
/** Compact per-principle projection for the Library list (§11.2). */
|
|
44
45
|
getLibraryCompact(now?: string): Promise<{
|
|
45
|
-
schemaVersion:
|
|
46
|
+
schemaVersion: typeof RUNTIME_CONTRACT_SCHEMA_VERSION;
|
|
46
47
|
generatedAt: string;
|
|
47
48
|
entries: Record<string, {
|
|
48
49
|
decisionState: OwnerDecisionViewCore['decisionState'];
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
/* eslint-disable @typescript-eslint/class-methods-use-this -- lifecycle-style methods; kept on the model for cohesion */
|
|
20
20
|
import * as fs from 'node:fs';
|
|
21
21
|
import * as path from 'node:path';
|
|
22
|
+
import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
|
|
22
23
|
import { GovernanceProjectionCollector, isRecord, readOwnString, } from './GovernanceProjectionCollector.js';
|
|
23
24
|
import { deriveOwnerDecisionView, } from '@principles/core/runtime';
|
|
24
25
|
import { SqliteConnection } from '@principles/core/runtime';
|
|
@@ -44,7 +45,7 @@ export class OwnerDecisionViewModel {
|
|
|
44
45
|
// No readable ledger: degrade observably instead of an empty success
|
|
45
46
|
// (SPEC §15 — an unavailable ledger is not "zero principles, all fine").
|
|
46
47
|
return {
|
|
47
|
-
schemaVersion:
|
|
48
|
+
schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, generatedAt: now, totalPrinciples: 0,
|
|
48
49
|
groups: { decision: [], blocked: [], recovery: [] },
|
|
49
50
|
historicalUnknown: { count: 0, reasonText: '' },
|
|
50
51
|
degraded: { reason: 'principle ledger unavailable', nextAction: '检查原则账本文件。' },
|
|
@@ -53,7 +54,7 @@ export class OwnerDecisionViewModel {
|
|
|
53
54
|
const principlesTree = GovernanceProjectionCollector.principleTreeFromLedger(ledgerParsed);
|
|
54
55
|
if (principlesTree === null) {
|
|
55
56
|
return {
|
|
56
|
-
schemaVersion:
|
|
57
|
+
schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, generatedAt: now, totalPrinciples: 0,
|
|
57
58
|
groups: { decision: [], blocked: [], recovery: [] },
|
|
58
59
|
historicalUnknown: { count: 0, reasonText: '' },
|
|
59
60
|
degraded: { reason: 'principle ledger unavailable', nextAction: '检查原则账本文件。' },
|
|
@@ -105,7 +106,7 @@ export class OwnerDecisionViewModel {
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
return {
|
|
108
|
-
schemaVersion:
|
|
109
|
+
schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION,
|
|
109
110
|
generatedAt: now,
|
|
110
111
|
totalPrinciples: total,
|
|
111
112
|
groups: { decision, blocked, recovery },
|
|
@@ -125,11 +126,11 @@ export class OwnerDecisionViewModel {
|
|
|
125
126
|
ledgerParsed = this.parseLedger();
|
|
126
127
|
}
|
|
127
128
|
catch {
|
|
128
|
-
return { schemaVersion:
|
|
129
|
+
return { schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, generatedAt: now, entries: {}, degraded: { reason: 'principle ledger unavailable' } };
|
|
129
130
|
}
|
|
130
131
|
const principlesTree = GovernanceProjectionCollector.principleTreeFromLedger(ledgerParsed);
|
|
131
132
|
if (principlesTree === null) {
|
|
132
|
-
return { schemaVersion:
|
|
133
|
+
return { schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, generatedAt: now, entries: {}, degraded: { reason: 'principle ledger unavailable' } };
|
|
133
134
|
}
|
|
134
135
|
const entries = {};
|
|
135
136
|
for (const principleId of Object.keys(principlesTree).sort()) {
|
|
@@ -146,7 +147,7 @@ export class OwnerDecisionViewModel {
|
|
|
146
147
|
// Skip unreadable entries — the Library falls back to neutral copy.
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
|
-
return { schemaVersion:
|
|
150
|
+
return { schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION, generatedAt: now, entries };
|
|
150
151
|
}
|
|
151
152
|
// ── input assembly ────────────────────────────────────────────────────────
|
|
152
153
|
async collectInputs(principleId, now) {
|
|
@@ -274,7 +275,7 @@ export class OwnerDecisionViewModel {
|
|
|
274
275
|
scope: 'principle entry',
|
|
275
276
|
});
|
|
276
277
|
return {
|
|
277
|
-
schemaVersion:
|
|
278
|
+
schemaVersion: RUNTIME_CONTRACT_SCHEMA_VERSION,
|
|
278
279
|
principleId,
|
|
279
280
|
asOf: now,
|
|
280
281
|
ledger: {
|
|
@@ -92,11 +92,11 @@ async function readJson(req) {
|
|
|
92
92
|
// ── Route handler ────────────────────────────────────────────────────────────
|
|
93
93
|
/* eslint-disable @typescript-eslint/max-params */
|
|
94
94
|
export async function handleActivationsRoute(req, res, workspaceDir, subPath, authority) {
|
|
95
|
-
// GET /api/
|
|
95
|
+
// GET /api/activations
|
|
96
96
|
if (req.method === 'GET' && (subPath === '' || subPath === '/')) {
|
|
97
97
|
// PD_PROMPT_CAPACITY_V1 R-A1: request-level target host for the
|
|
98
98
|
// per-activation injection statuses (route-unconfirmed rows otherwise).
|
|
99
|
-
const url = new URL(req.url ?? '/api/
|
|
99
|
+
const url = new URL(req.url ?? '/api/activations', 'http://localhost');
|
|
100
100
|
let targetHost;
|
|
101
101
|
const rawHost = url.searchParams.get('host');
|
|
102
102
|
if (rawHost !== null) {
|
|
@@ -260,7 +260,7 @@ export async function handleActivationsRoute(req, res, workspaceDir, subPath, au
|
|
|
260
260
|
}
|
|
261
261
|
return;
|
|
262
262
|
}
|
|
263
|
-
// POST /api/
|
|
263
|
+
// POST /api/activations/:id/propose-revision
|
|
264
264
|
// PD_PROMPT_CAPACITY_V1 R-B3: Owner-initiated "modify to injectable version"
|
|
265
265
|
// on a live prompt activation — new validated artifact version + a NORMAL
|
|
266
266
|
// pending approval (the atomic replacement happens on approve).
|
|
@@ -329,7 +329,7 @@ export async function handleActivationsRoute(req, res, workspaceDir, subPath, au
|
|
|
329
329
|
}
|
|
330
330
|
return;
|
|
331
331
|
}
|
|
332
|
-
// POST /api/
|
|
332
|
+
// POST /api/activations/:id/disable
|
|
333
333
|
const disableExec = /^\/([^/]+)\/disable$/.exec(subPath);
|
|
334
334
|
if (req.method === 'POST' && disableExec) {
|
|
335
335
|
const [, rawId] = disableExec;
|
|
@@ -389,7 +389,7 @@ export async function handleActivationsRoute(req, res, workspaceDir, subPath, au
|
|
|
389
389
|
}
|
|
390
390
|
return;
|
|
391
391
|
}
|
|
392
|
-
sendNotFound(res, `Route /api/
|
|
392
|
+
sendNotFound(res, `Route /api/activations${subPath} not found`);
|
|
393
393
|
}
|
|
394
394
|
export function disposeActivationsModels() {
|
|
395
395
|
for (const model of models.values()) {
|
|
@@ -12,7 +12,7 @@ function getModel(workspaceDir) {
|
|
|
12
12
|
}
|
|
13
13
|
export async function handleApprovalsGroupedRoute(req, res, workspaceDir) {
|
|
14
14
|
if (req.method !== 'GET') {
|
|
15
|
-
sendNotFound(res, 'Route /api/
|
|
15
|
+
sendNotFound(res, 'Route /api/approvals/grouped not found');
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
// PD_PROMPT_CAPACITY_V1 R-A1: request-level target host for the capacity
|
|
@@ -20,7 +20,7 @@ export async function handleApprovalsGroupedRoute(req, res, workspaceDir) {
|
|
|
20
20
|
// applicable hosts would take different routes. No new persisted config.
|
|
21
21
|
// The roster is the host-runtime one (openclaw|codex|workbuddy) — the
|
|
22
22
|
// focus page offers all three, so the API must accept all three.
|
|
23
|
-
const url = new URL(req.url ?? '/api/
|
|
23
|
+
const url = new URL(req.url ?? '/api/approvals/grouped', 'http://localhost');
|
|
24
24
|
let targetHost;
|
|
25
25
|
const rawHost = url.searchParams.get('host');
|
|
26
26
|
if (rawHost !== null) {
|
|
@@ -39,7 +39,7 @@ function parseJsonBody(body, res) {
|
|
|
39
39
|
/* eslint-disable @typescript-eslint/max-params */
|
|
40
40
|
export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
41
41
|
const model = getModel(workspaceDir);
|
|
42
|
-
// GET /api/
|
|
42
|
+
// GET /api/approvals - list all approvals (MVP proven channels only)
|
|
43
43
|
if (req.method === 'GET' && (subPath === '' || subPath === '/')) {
|
|
44
44
|
try {
|
|
45
45
|
const query = parseQuery(req.url ?? '');
|
|
@@ -71,7 +71,7 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
71
71
|
}
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
// GET /api/
|
|
74
|
+
// GET /api/approvals/:id - detail
|
|
75
75
|
const detailMatch = /^[/]([^/]+)$/.exec(subPath);
|
|
76
76
|
if (req.method === 'GET' && detailMatch) {
|
|
77
77
|
const [, rawId] = detailMatch;
|
|
@@ -100,7 +100,7 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
100
100
|
}
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
|
-
// POST /api/
|
|
103
|
+
// POST /api/approvals/:id/approve
|
|
104
104
|
const approveMatch = /^[/]([^/]+)[/]approve$/.exec(subPath);
|
|
105
105
|
if (req.method === 'POST' && approveMatch) {
|
|
106
106
|
const [, rawId] = approveMatch;
|
|
@@ -209,7 +209,7 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
209
209
|
}
|
|
210
210
|
return;
|
|
211
211
|
}
|
|
212
|
-
// POST /api/
|
|
212
|
+
// POST /api/approvals/:id/reject
|
|
213
213
|
const rejectMatch = /^[/]([^/]+)[/]reject$/.exec(subPath);
|
|
214
214
|
if (req.method === 'POST' && rejectMatch) {
|
|
215
215
|
const [, rawId] = rejectMatch;
|
|
@@ -272,7 +272,7 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
272
272
|
}
|
|
273
273
|
return;
|
|
274
274
|
}
|
|
275
|
-
// POST /api/
|
|
275
|
+
// POST /api/approvals/:id/reopen — reset a terminal approval back to
|
|
276
276
|
// pending so the Owner can decide again (EP002-R4 follow-up: the clean
|
|
277
277
|
// re-activation path for a deliberately deactivated intervention — reopen,
|
|
278
278
|
// then a fresh Console approve re-dispatches through the verified chain).
|
|
@@ -312,7 +312,7 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
312
312
|
}
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
|
-
// POST /api/
|
|
315
|
+
// POST /api/approvals/:id/edit — edit a pending approval's artifact (P1 #2 fix)
|
|
316
316
|
const editMatch = /^[/]([^/]+)[/]edit$/.exec(subPath);
|
|
317
317
|
if (req.method === 'POST' && editMatch) {
|
|
318
318
|
const [, rawId] = editMatch;
|
|
@@ -388,7 +388,7 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
388
388
|
}
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
|
-
sendNotFound(res, 'Route /api/
|
|
391
|
+
sendNotFound(res, 'Route /api/approvals' + subPath + ' not found');
|
|
392
392
|
}
|
|
393
393
|
export function disposeApprovalsModels() {
|
|
394
394
|
for (const model of models.values()) {
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Config API Routes — PRI-309
|
|
3
3
|
*
|
|
4
4
|
* Console backend APIs for the Control Center:
|
|
5
|
-
* - GET /api/
|
|
6
|
-
* - GET /api/
|
|
7
|
-
* - PATCH /api/
|
|
8
|
-
* - GET /api/
|
|
5
|
+
* - GET /api/config/summary — redacted config summary
|
|
6
|
+
* - GET /api/config/catalog — available runtime/model catalog
|
|
7
|
+
* - PATCH /api/config/agents/:name/binding — update agent runtime binding
|
|
8
|
+
* - GET /api/config/readiness/:name — readiness test for agent
|
|
9
9
|
*
|
|
10
10
|
* Security:
|
|
11
11
|
* - Never returns raw provider objects, tokens, API keys, or env values
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Config API Routes — PRI-309
|
|
3
3
|
*
|
|
4
4
|
* Console backend APIs for the Control Center:
|
|
5
|
-
* - GET /api/
|
|
6
|
-
* - GET /api/
|
|
7
|
-
* - PATCH /api/
|
|
8
|
-
* - GET /api/
|
|
5
|
+
* - GET /api/config/summary — redacted config summary
|
|
6
|
+
* - GET /api/config/catalog — available runtime/model catalog
|
|
7
|
+
* - PATCH /api/config/agents/:name/binding — update agent runtime binding
|
|
8
|
+
* - GET /api/config/readiness/:name — readiness test for agent
|
|
9
9
|
*
|
|
10
10
|
* Security:
|
|
11
11
|
* - Never returns raw provider objects, tokens, API keys, or env values
|
|
@@ -358,5 +358,5 @@ export async function handleConfigRoute(req, res, ctx) {
|
|
|
358
358
|
return;
|
|
359
359
|
}
|
|
360
360
|
// 404 fallback
|
|
361
|
-
sendNotFound(res, `Route /api/
|
|
361
|
+
sendNotFound(res, `Route /api/config${subPath} not found`);
|
|
362
362
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Evidence Chain API — exposes behavior evidence chain records for the Pain page.
|
|
3
3
|
*
|
|
4
|
-
* GET /api/
|
|
4
|
+
* GET /api/evidence-chain
|
|
5
5
|
* Returns evidence chain records from pain_events, tasks, candidates, and ledger.
|
|
6
6
|
*/
|
|
7
7
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PD v2 Phase 1 — /api/
|
|
2
|
+
* PD v2 Phase 1 — /api/evidence/outcomes 路由(ADR-0027 §2.3, SPEC §13.4)。
|
|
3
3
|
*
|
|
4
|
-
* POST /api/
|
|
4
|
+
* POST /api/evidence/outcomes — Owner 结果反馈入账
|
|
5
5
|
*
|
|
6
6
|
* 最小获授权事实入口:Owner 可以对一个已存在的 Behavior Episode 提交
|
|
7
7
|
* 明确的结果观察/反馈。安全模型(复用 owner-decisions 的模式):
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Surface:
|
|
11
11
|
* v0.9 (offline-first, semantics unchanged):
|
|
12
|
-
* GET /api/
|
|
13
|
-
* GET /api/
|
|
14
|
-
* POST /api/
|
|
15
|
-
* GET /api/
|
|
16
|
-
* POST /api/
|
|
17
|
-
* POST /api/
|
|
18
|
-
* GET /api/
|
|
19
|
-
* POST /api/
|
|
12
|
+
* GET /api/examiner/overview
|
|
13
|
+
* GET /api/examiner/principles
|
|
14
|
+
* POST /api/examiner/studies (v0.10.1: + suiteKey)
|
|
15
|
+
* GET /api/examiner/studies/:studyId
|
|
16
|
+
* POST /api/examiner/studies/:studyId/preflight
|
|
17
|
+
* POST /api/examiner/studies/:studyId/run (offline-stub, synchronous)
|
|
18
|
+
* GET /api/examiner/studies/:studyId/report
|
|
19
|
+
* POST /api/examiner/studies/:studyId/report
|
|
20
20
|
* v0.10.1:
|
|
21
|
-
* GET /api/
|
|
22
|
-
* GET /api/
|
|
23
|
-
* GET /api/
|
|
24
|
-
* POST /api/
|
|
21
|
+
* GET /api/examiner/principles/:id/evidence — production evidence aggregate
|
|
22
|
+
* GET /api/examiner/suites — challenge-suite catalog
|
|
23
|
+
* GET /api/examiner/hosts/openclaw/readiness — host readiness projection
|
|
24
|
+
* POST /api/examiner/studies/:studyId/run — modes 'host-dry-run' /
|
|
25
25
|
* 'f2-real-host' follow the §12.3 async contract: 202 + runId, state
|
|
26
26
|
* derived from the study ledger, one live run per study, restart
|
|
27
27
|
* recovery, RESULT_UNKNOWN never auto-retried, f2 gated on an APPROVED
|
|
@@ -541,8 +541,8 @@ export async function handleExaminerRoute(req, res, workspaceDir, subPath) {
|
|
|
541
541
|
}
|
|
542
542
|
return;
|
|
543
543
|
}
|
|
544
|
-
sendNotFound(res, `Route /api/
|
|
544
|
+
sendNotFound(res, `Route /api/examiner/studies/:studyId${rest} not found`);
|
|
545
545
|
return;
|
|
546
546
|
}
|
|
547
|
-
sendNotFound(res, `Route /api/
|
|
547
|
+
sendNotFound(res, `Route /api/examiner${subPath} not found`);
|
|
548
548
|
}
|
|
@@ -20,12 +20,12 @@ export type FailedTasksContext = {
|
|
|
20
20
|
sqliteTaskStore?: SqliteTaskStore;
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
|
-
* Handle requests to `/api/
|
|
23
|
+
* Handle requests to `/api/failed-tasks*`.
|
|
24
24
|
*
|
|
25
25
|
* Routes:
|
|
26
|
-
* GET /api/
|
|
27
|
-
* GET /api/
|
|
28
|
-
* POST /api/
|
|
26
|
+
* GET /api/failed-tasks — list failed/needs_human_review tasks
|
|
27
|
+
* GET /api/failed-tasks/:id — fetch single task detail (task + runs + lastError)
|
|
28
|
+
* POST /api/failed-tasks/:id/recover — Owner recovery (failed | needs_human_review → pending)
|
|
29
29
|
* other methods — 405 Method Not Allowed
|
|
30
30
|
*
|
|
31
31
|
* Feature flag gates (checked before any DB access so a disabled flag
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// failed-tasks.ts
|
|
2
|
-
// Server route for /api/
|
|
2
|
+
// Server route for /api/failed-tasks/*
|
|
3
3
|
//
|
|
4
4
|
// Lists tasks in 'failed' or 'needs_human_review' status and fetches single-task
|
|
5
5
|
// detail (task record + run history + last error category). Gated by the
|
|
6
6
|
// failed_tasks_observability feature flag.
|
|
7
7
|
//
|
|
8
|
-
// Governance Recovery Actions v1: POST /api/
|
|
8
|
+
// Governance Recovery Actions v1: POST /api/failed-tasks/:id/recover lets the
|
|
9
9
|
// Owner recover a task from the Console. failed → pending reuses
|
|
10
10
|
// RecoverySweepService.recoverFailedTask; needs_human_review → pending reuses
|
|
11
11
|
// the extracted owner-retry sequence (ownerRetryNeedsHumanReviewTask — the same
|
|
@@ -366,12 +366,12 @@ async function dispatchRecovery(workspaceDir, taskId, force) {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
/**
|
|
369
|
-
* Handle requests to `/api/
|
|
369
|
+
* Handle requests to `/api/failed-tasks*`.
|
|
370
370
|
*
|
|
371
371
|
* Routes:
|
|
372
|
-
* GET /api/
|
|
373
|
-
* GET /api/
|
|
374
|
-
* POST /api/
|
|
372
|
+
* GET /api/failed-tasks — list failed/needs_human_review tasks
|
|
373
|
+
* GET /api/failed-tasks/:id — fetch single task detail (task + runs + lastError)
|
|
374
|
+
* POST /api/failed-tasks/:id/recover — Owner recovery (failed | needs_human_review → pending)
|
|
375
375
|
* other methods — 405 Method Not Allowed
|
|
376
376
|
*
|
|
377
377
|
* Feature flag gates (checked before any DB access so a disabled flag
|
|
@@ -392,7 +392,7 @@ export async function handleFailedTasksRoute(req, res, ctx) {
|
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
// Collection: GET /api/
|
|
395
|
+
// Collection: GET /api/failed-tasks
|
|
396
396
|
if (subPath === '' || subPath === '/') {
|
|
397
397
|
if (method !== 'GET') {
|
|
398
398
|
sendMethodNotAllowed(res);
|
|
@@ -489,7 +489,7 @@ export async function handleFailedTasksRoute(req, res, ctx) {
|
|
|
489
489
|
}
|
|
490
490
|
return;
|
|
491
491
|
}
|
|
492
|
-
// Recovery: POST /api/
|
|
492
|
+
// Recovery: POST /api/failed-tasks/:id/recover (Governance Recovery
|
|
493
493
|
// Actions v1). Checked before the generic /:id detail branch.
|
|
494
494
|
// eslint-disable-next-line @typescript-eslint/prefer-regexp-exec -- String#match is semantically identical for a non-global regex; the repo's security write-gate false-positives on `<expr>.exec(userInput)` as command injection, so RegExp#exec is not writable here.
|
|
495
495
|
const recoverMatch = subPath.match(/^\/([^/]+)\/recover$/);
|
|
@@ -569,7 +569,7 @@ export async function handleFailedTasksRoute(req, res, ctx) {
|
|
|
569
569
|
}
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
|
-
// Detail: GET /api/
|
|
572
|
+
// Detail: GET /api/failed-tasks/:id
|
|
573
573
|
const decodedId = decodeTaskIdSegment(subPath.replace(/^\//, ''));
|
|
574
574
|
if (!decodedId.ok) {
|
|
575
575
|
sendError(res, 400, 'invalid_encoding', 'task id path segment is not valid percent-encoding');
|
|
@@ -577,7 +577,7 @@ export async function handleFailedTasksRoute(req, res, ctx) {
|
|
|
577
577
|
}
|
|
578
578
|
const id = decodedId.value;
|
|
579
579
|
if (id.length === 0) {
|
|
580
|
-
sendNotFound(res, `Route /api/
|
|
580
|
+
sendNotFound(res, `Route /api/failed-tasks${subPath} not found`);
|
|
581
581
|
return;
|
|
582
582
|
}
|
|
583
583
|
if (method !== 'GET') {
|
|
@@ -17,7 +17,7 @@ export declare function resolveOwnerConfigSnapshot(authConfig: {
|
|
|
17
17
|
isEnabled(): boolean;
|
|
18
18
|
}, identity: OwnerIdentityResolved): OwnerConfigSnapshot;
|
|
19
19
|
/**
|
|
20
|
-
* GET /api/
|
|
20
|
+
* GET /api/governance/experience — read-only Governance Experience Snapshot
|
|
21
21
|
* v1.5.1 (PRI-585).
|
|
22
22
|
*
|
|
23
23
|
* Flag contract (SPEC §14.1): with `governance_experience_v1` disabled the
|
|
@@ -38,7 +38,7 @@ export function resolveOwnerConfigSnapshot(authConfig, identity) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
* GET /api/
|
|
41
|
+
* GET /api/governance/experience — read-only Governance Experience Snapshot
|
|
42
42
|
* v1.5.1 (PRI-585).
|
|
43
43
|
*
|
|
44
44
|
* Flag contract (SPEC §14.1): with `governance_experience_v1` disabled the
|
|
@@ -47,7 +47,7 @@ export function resolveOwnerConfigSnapshot(authConfig, identity) {
|
|
|
47
47
|
*/
|
|
48
48
|
export async function handleGovernanceExperienceRoute(req, res, ctx) {
|
|
49
49
|
if (req.method !== 'GET') {
|
|
50
|
-
sendError(res, 405, 'method_not_allowed', 'Use GET for /api/
|
|
50
|
+
sendError(res, 405, 'method_not_allowed', 'Use GET for /api/governance/experience.', { nextAction: 'Retry with GET.' });
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
// Gate first — flag-off must not touch the database, ledger, or config files.
|
|
@@ -66,7 +66,7 @@ export async function handleGovernanceExperienceRoute(req, res, ctx) {
|
|
|
66
66
|
}
|
|
67
67
|
export async function handleGovernanceRoute(req, res, workspaceDir) {
|
|
68
68
|
if (req.method !== 'GET') {
|
|
69
|
-
sendNotFound(res, 'Route /api/
|
|
69
|
+
sendNotFound(res, 'Route /api/governance/queue not found');
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
const model = getModel(workspaceDir);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* IntentDecisions route — HTTP surface for IntentDecisionRecord (PRI-470, SPEC §21.7).
|
|
3
3
|
*
|
|
4
4
|
* Endpoints (all gated by the `intent_engineering` feature flag):
|
|
5
|
-
* - POST /api/
|
|
6
|
-
* - GET /api/
|
|
7
|
-
* - GET /api/
|
|
8
|
-
* - GET /api/
|
|
9
|
-
* - GET /api/
|
|
10
|
-
* - POST /api/
|
|
5
|
+
* - POST /api/intent-decisions → create (201) or idempotent replay (200)
|
|
6
|
+
* - GET /api/intent-decisions?painId=… → list by painId
|
|
7
|
+
* - GET /api/intent-decisions?taskId=… → list by taskId
|
|
8
|
+
* - GET /api/intent-decisions/summary → tallied summary (MUST precede /:id)
|
|
9
|
+
* - GET /api/intent-decisions/:id → single record
|
|
10
|
+
* - POST /api/intent-decisions/:id/follow-up → dispatch governed follow-up (PRI-471)
|
|
11
11
|
*
|
|
12
12
|
* PRI-471 follow-up types (SPEC §22.1.4):
|
|
13
13
|
* - link_candidate — record which existing principle candidate the Owner
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* IntentDecisions route — HTTP surface for IntentDecisionRecord (PRI-470, SPEC §21.7).
|
|
3
3
|
*
|
|
4
4
|
* Endpoints (all gated by the `intent_engineering` feature flag):
|
|
5
|
-
* - POST /api/
|
|
6
|
-
* - GET /api/
|
|
7
|
-
* - GET /api/
|
|
8
|
-
* - GET /api/
|
|
9
|
-
* - GET /api/
|
|
10
|
-
* - POST /api/
|
|
5
|
+
* - POST /api/intent-decisions → create (201) or idempotent replay (200)
|
|
6
|
+
* - GET /api/intent-decisions?painId=… → list by painId
|
|
7
|
+
* - GET /api/intent-decisions?taskId=… → list by taskId
|
|
8
|
+
* - GET /api/intent-decisions/summary → tallied summary (MUST precede /:id)
|
|
9
|
+
* - GET /api/intent-decisions/:id → single record
|
|
10
|
+
* - POST /api/intent-decisions/:id/follow-up → dispatch governed follow-up (PRI-471)
|
|
11
11
|
*
|
|
12
12
|
* PRI-471 follow-up types (SPEC §22.1.4):
|
|
13
13
|
* - link_candidate — record which existing principle candidate the Owner
|
|
@@ -190,7 +190,7 @@ const FOLLOW_UP_TYPES = new Set([
|
|
|
190
190
|
'generate_patch_proposal',
|
|
191
191
|
]);
|
|
192
192
|
/**
|
|
193
|
-
* Validate the body of POST /api/
|
|
193
|
+
* Validate the body of POST /api/intent-decisions/:id/follow-up.
|
|
194
194
|
*
|
|
195
195
|
* Body shape: `{ type: 'link_candidate' | 'guide_rulehost' | 'generate_patch_proposal', candidateId?: string }`
|
|
196
196
|
*
|
|
@@ -260,7 +260,7 @@ export async function handleIntentDecisionsRoute(req, res, workspaceDir, subPath
|
|
|
260
260
|
if (!checkFlag(workspaceDir, res))
|
|
261
261
|
return;
|
|
262
262
|
const model = getModel(workspaceDir);
|
|
263
|
-
// POST /api/
|
|
263
|
+
// POST /api/intent-decisions — create / idempotent replay
|
|
264
264
|
if (req.method === 'POST' && (subPath === '' || subPath === '/')) {
|
|
265
265
|
try {
|
|
266
266
|
const body = await readBody(req);
|
|
@@ -299,7 +299,7 @@ export async function handleIntentDecisionsRoute(req, res, workspaceDir, subPath
|
|
|
299
299
|
}
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
|
-
// GET /api/
|
|
302
|
+
// GET /api/intent-decisions — list by painId OR taskId (exactly one required)
|
|
303
303
|
if (req.method === 'GET' && (subPath === '' || subPath === '/')) {
|
|
304
304
|
try {
|
|
305
305
|
const query = parseQuery(req.url ?? '');
|
|
@@ -337,7 +337,7 @@ export async function handleIntentDecisionsRoute(req, res, workspaceDir, subPath
|
|
|
337
337
|
}
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
|
-
// GET /api/
|
|
340
|
+
// GET /api/intent-decisions/summary — MUST be matched before /:id
|
|
341
341
|
if (req.method === 'GET' && subPath === '/summary') {
|
|
342
342
|
try {
|
|
343
343
|
const summary = await model.getSummary();
|
|
@@ -348,7 +348,7 @@ export async function handleIntentDecisionsRoute(req, res, workspaceDir, subPath
|
|
|
348
348
|
}
|
|
349
349
|
return;
|
|
350
350
|
}
|
|
351
|
-
// GET /api/
|
|
351
|
+
// GET /api/intent-decisions/:id — single record
|
|
352
352
|
const detailMatch = /^[/]([^/]+)$/.exec(subPath);
|
|
353
353
|
if (req.method === 'GET' && detailMatch) {
|
|
354
354
|
const [, rawId] = detailMatch;
|
|
@@ -377,7 +377,7 @@ export async function handleIntentDecisionsRoute(req, res, workspaceDir, subPath
|
|
|
377
377
|
}
|
|
378
378
|
return;
|
|
379
379
|
}
|
|
380
|
-
// POST /api/
|
|
380
|
+
// POST /api/intent-decisions/:id/follow-up — PRI-471 governed follow-up
|
|
381
381
|
// (SPEC §22.1.4). MUST be matched before the catch-all 404 below.
|
|
382
382
|
const followUpMatch = /^[/]([^/]+)[/]follow-up$/.exec(subPath);
|
|
383
383
|
if (req.method === 'POST' && followUpMatch) {
|
|
@@ -486,7 +486,7 @@ export async function handleIntentDecisionsRoute(req, res, workspaceDir, subPath
|
|
|
486
486
|
}
|
|
487
487
|
return;
|
|
488
488
|
}
|
|
489
|
-
sendNotFound(res, 'Route /api/
|
|
489
|
+
sendNotFound(res, 'Route /api/intent-decisions' + subPath + ' not found');
|
|
490
490
|
}
|
|
491
491
|
/**
|
|
492
492
|
* Dispose hook for graceful shutdown — clears the per-workspace model cache.
|
|
@@ -36,7 +36,7 @@ export async function handleIntentRoute(req, res, ctx) {
|
|
|
36
36
|
const { workspaceDir, subPath } = ctx;
|
|
37
37
|
const lang = parseLang(req);
|
|
38
38
|
try {
|
|
39
|
-
// ── GET /api/
|
|
39
|
+
// ── GET /api/intent — read Intent summary ──────────────────────────
|
|
40
40
|
if (req.method === 'GET' && subPath === '') {
|
|
41
41
|
const flagEnabled = loadFlagEnabled(workspaceDir);
|
|
42
42
|
const model = getModel(workspaceDir);
|
|
@@ -44,7 +44,7 @@ export async function handleIntentRoute(req, res, ctx) {
|
|
|
44
44
|
sendSuccess(res, summary);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
// ── GET /api/
|
|
47
|
+
// ── GET /api/intent/content — read raw INTENT.md for editing ─────────
|
|
48
48
|
if (req.method === 'GET' && subPath === '/content') {
|
|
49
49
|
const flagEnabled = loadFlagEnabled(workspaceDir);
|
|
50
50
|
if (!flagEnabled) {
|
|
@@ -77,7 +77,7 @@ export async function handleIntentRoute(req, res, ctx) {
|
|
|
77
77
|
sendSuccess(res, { content: result.content, path: result.path });
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
// ── GET /api/
|
|
80
|
+
// ── GET /api/intent/versions — list version history ────────────────
|
|
81
81
|
if (req.method === 'GET' && subPath === '/versions') {
|
|
82
82
|
const model = getModel(workspaceDir);
|
|
83
83
|
const result = await model.getVersions(lang);
|
|
@@ -88,7 +88,7 @@ export async function handleIntentRoute(req, res, ctx) {
|
|
|
88
88
|
sendSuccess(res, { versions: result.versions });
|
|
89
89
|
return;
|
|
90
90
|
}
|
|
91
|
-
// ── POST /api/
|
|
91
|
+
// ── POST /api/intent/init — create INTENT.md template ──────────────
|
|
92
92
|
if (req.method === 'POST' && subPath === '/init') {
|
|
93
93
|
const flagEnabled = loadFlagEnabled(workspaceDir);
|
|
94
94
|
if (!flagEnabled) {
|
|
@@ -145,7 +145,7 @@ export async function handleIntentRoute(req, res, ctx) {
|
|
|
145
145
|
}
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
// ── PUT /api/
|
|
148
|
+
// ── PUT /api/intent/content — save INTENT.md content ───────────────
|
|
149
149
|
if (req.method === 'PUT' && subPath === '/content') {
|
|
150
150
|
const flagEnabled = loadFlagEnabled(workspaceDir);
|
|
151
151
|
if (!flagEnabled) {
|
|
@@ -211,7 +211,7 @@ export async function handleIntentRoute(req, res, ctx) {
|
|
|
211
211
|
return;
|
|
212
212
|
}
|
|
213
213
|
// ── Unknown sub-path ──────────────────────────────────────────────────
|
|
214
|
-
sendError(res, 404, 'not_found', `Route /api/
|
|
214
|
+
sendError(res, 404, 'not_found', `Route /api/intent${subPath} not found`);
|
|
215
215
|
}
|
|
216
216
|
catch (err) {
|
|
217
217
|
sendError(res, 500, 'intent_route_error', err instanceof Error ? err.message : 'Unknown error');
|
|
@@ -12,10 +12,10 @@ function getModel(workspaceDir) {
|
|
|
12
12
|
/* eslint-disable @typescript-eslint/max-params */
|
|
13
13
|
export async function handleLifecycleRoute(req, res, workspaceDir, subPath) {
|
|
14
14
|
if (req.method !== 'GET') {
|
|
15
|
-
sendNotFound(res, `Route /api/
|
|
15
|
+
sendNotFound(res, `Route /api/lifecycle${subPath} not found`);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
|
-
// GET /api/
|
|
18
|
+
// GET /api/lifecycle/principles/:principleId
|
|
19
19
|
const principleMatch = /^[/]principles[/]([^/]+)$/.exec(subPath);
|
|
20
20
|
if (principleMatch) {
|
|
21
21
|
const [, rawId] = principleMatch;
|
|
@@ -64,7 +64,7 @@ export async function handleLifecycleRoute(req, res, workspaceDir, subPath) {
|
|
|
64
64
|
}
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
sendNotFound(res, `Route /api/
|
|
67
|
+
sendNotFound(res, `Route /api/lifecycle${subPath} not found`);
|
|
68
68
|
}
|
|
69
69
|
export function disposeLifecycleModels() {
|
|
70
70
|
models.clear();
|