@sema-agent/server 7.79.3 → 7.80.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/dist/boot/stage-07-capability-layer.js +2 -1
- package/dist/capabilities/skills.d.ts +10 -0
- package/dist/capabilities/skills.js +3 -1
- package/dist/http/admission.js +3 -1
- package/dist/http/dispatch.js +28 -8
- package/dist/http/resume-legs.js +4 -3
- package/dist/http/route-ctx.d.ts +101 -4
- package/dist/http/route-ctx.js +4 -0
- package/dist/http/route-table.d.ts +71 -43
- package/dist/http/route-table.js +111 -187
- package/dist/http/routes/a2a-serve.d.ts +18 -3
- package/dist/http/routes/a2a-serve.js +25 -23
- package/dist/http/routes/admin-config-refresh.d.ts +9 -2
- package/dist/http/routes/admin-config-refresh.js +32 -31
- package/dist/http/routes/admin-drain.d.ts +9 -2
- package/dist/http/routes/admin-drain.js +32 -31
- package/dist/http/routes/admin-memory-optout.d.ts +28 -2
- package/dist/http/routes/admin-memory-optout.js +27 -40
- package/dist/http/routes/adoption.d.ts +15 -2
- package/dist/http/routes/adoption.js +52 -52
- package/dist/http/routes/agents-roster.d.ts +9 -2
- package/dist/http/routes/agents-roster.js +82 -80
- package/dist/http/routes/approvals-assistant.d.ts +58 -5
- package/dist/http/routes/approvals-assistant.js +38 -39
- package/dist/http/routes/attachments.d.ts +22 -2
- package/dist/http/routes/attachments.js +81 -72
- package/dist/http/routes/capabilities.d.ts +21 -2
- package/dist/http/routes/capabilities.js +174 -170
- package/dist/http/routes/config-catalog.d.ts +9 -2
- package/dist/http/routes/config-catalog.js +28 -31
- package/dist/http/routes/devices.d.ts +24 -2
- package/dist/http/routes/devices.js +19 -21
- package/dist/http/routes/diagnostics.d.ts +9 -2
- package/dist/http/routes/diagnostics.js +41 -43
- package/dist/http/routes/fleet.d.ts +11 -2
- package/dist/http/routes/fleet.js +23 -22
- package/dist/http/routes/images.d.ts +63 -9
- package/dist/http/routes/images.js +53 -46
- package/dist/http/routes/leader.d.ts +20 -2
- package/dist/http/routes/leader.js +43 -40
- package/dist/http/routes/memory-bundle.d.ts +15 -2
- package/dist/http/routes/memory-bundle.js +38 -38
- package/dist/http/routes/memory-compliance.d.ts +16 -4
- package/dist/http/routes/memory-compliance.js +44 -45
- package/dist/http/routes/memory-consolidation.d.ts +14 -2
- package/dist/http/routes/memory-consolidation.js +66 -66
- package/dist/http/routes/memory-origin.d.ts +23 -4
- package/dist/http/routes/memory-origin.js +65 -65
- package/dist/http/routes/memory-policy.d.ts +21 -2
- package/dist/http/routes/memory-policy.js +119 -115
- package/dist/http/routes/notify-wake.d.ts +21 -11
- package/dist/http/routes/notify-wake.js +118 -116
- package/dist/http/routes/observability.d.ts +16 -2
- package/dist/http/routes/observability.js +54 -51
- package/dist/http/routes/retention-ops.d.ts +19 -2
- package/dist/http/routes/retention-ops.js +20 -22
- package/dist/http/routes/rules.d.ts +36 -2
- package/dist/http/routes/rules.js +22 -24
- package/dist/http/routes/run-memory-capture.d.ts +10 -3
- package/dist/http/routes/run-memory-capture.js +84 -84
- package/dist/http/routes/runs.d.ts +102 -22
- package/dist/http/routes/runs.js +79 -96
- package/dist/http/routes/session-sync.d.ts +41 -2
- package/dist/http/routes/session-sync.js +26 -24
- package/dist/http/routes/sessions-list.d.ts +16 -2
- package/dist/http/routes/sessions-list.js +78 -75
- package/dist/http/routes/sessions.d.ts +77 -2
- package/dist/http/routes/sessions.js +50 -47
- package/dist/http/routes/shared-memory.d.ts +19 -2
- package/dist/http/routes/shared-memory.js +65 -63
- package/dist/http/routes/side-query.d.ts +11 -2
- package/dist/http/routes/side-query.js +81 -79
- package/dist/http/routes/tasks.d.ts +17 -2
- package/dist/http/routes/tasks.js +18 -11
- package/dist/http/routes/trace-usage.d.ts +40 -2
- package/dist/http/routes/trace-usage.js +46 -35
- package/dist/http/routes/workflows.d.ts +35 -3
- package/dist/http/routes/workflows.js +29 -29
- package/dist/http/wire-types.d.ts +15 -9
- package/dist/parked-decide.d.ts +9 -0
- package/dist/parked-decide.js +3 -3
- package/dist/run-local.js +2 -1
- package/dist/spec-fields.js +33 -30
- package/dist/task-cwd.d.ts +21 -0
- package/dist/task-cwd.js +3 -0
- package/dist/trace/core-keyset-guard.d.ts +6 -1
- package/dist/trace/project.d.ts +20 -0
- package/dist/trace/project.js +15 -1
- package/package.json +2 -2
package/dist/http/route-table.js
CHANGED
|
@@ -1,195 +1,88 @@
|
|
|
1
|
-
import { handleCapabilities } from "./routes/capabilities.js";
|
|
2
|
-
import { handleObservability } from "./routes/observability.js";
|
|
3
|
-
import { handleDiagnostics } from "./routes/diagnostics.js";
|
|
4
|
-
import { handleAdoption } from "./routes/adoption.js";
|
|
5
|
-
import { handleRetention } from "./routes/retention-ops.js";
|
|
6
|
-
import { handleAdminDrain } from "./routes/admin-drain.js";
|
|
7
|
-
import { handleDevices } from "./routes/devices.js";
|
|
8
|
-
import { handleAdminConfigRefresh } from "./routes/admin-config-refresh.js";
|
|
9
|
-
import { handleConfigCatalog } from "./routes/config-catalog.js";
|
|
10
|
-
import { handleMemoryOptOut } from "./routes/admin-memory-optout.js";
|
|
11
|
-
import { handleMemoryPolicy } from "./routes/memory-policy.js";
|
|
12
|
-
import { handleMemoryBundle } from "./routes/memory-bundle.js";
|
|
13
|
-
import { handleMemoryCompliance } from "./routes/memory-compliance.js";
|
|
14
|
-
import { handleMemoryOrigin } from "./routes/memory-origin.js";
|
|
15
|
-
import { handleMemoryConsolidation } from "./routes/memory-consolidation.js";
|
|
16
|
-
import { handleSharedMemory } from "./routes/shared-memory.js";
|
|
17
|
-
import { handleRules } from "./routes/rules.js";
|
|
18
|
-
import { handleSessionsList } from "./routes/sessions-list.js";
|
|
19
|
-
import { handleAgentRoster } from "./routes/agents-roster.js";
|
|
20
|
-
import { handleSessions } from "./routes/sessions.js";
|
|
21
|
-
import { handleSessionSync } from "./routes/session-sync.js";
|
|
22
|
-
import { handleAttachments } from "./routes/attachments.js";
|
|
23
|
-
import { handleFleet } from "./routes/fleet.js";
|
|
24
|
-
import { handleA2aServe, handleA2a } from "./routes/a2a-serve.js";
|
|
25
|
-
import { handleTraceUsage } from "./routes/trace-usage.js";
|
|
26
|
-
import { handleWorkflows, handleWorkflowAgentSteer } from "./routes/workflows.js";
|
|
27
|
-
import { handleNotifyWake,
|
|
28
|
-
import { handleApprovalsAssistant,
|
|
29
|
-
import { handleRuns, handleRunVerbs,
|
|
30
|
-
import { handleRunMemoryCapture } from "./routes/run-memory-capture.js";
|
|
31
|
-
import { handleSideQuery } from "./routes/side-query.js";
|
|
32
|
-
import { handleTasks } from "./routes/tasks.js";
|
|
33
|
-
import { handleLeader } from "./routes/leader.js";
|
|
34
|
-
import { handleImages } from "./routes/images.js";
|
|
1
|
+
import { handleCapabilities, CAPABILITIES_ROUTES } from "./routes/capabilities.js";
|
|
2
|
+
import { handleObservability, OBSERVABILITY_ROUTES } from "./routes/observability.js";
|
|
3
|
+
import { handleDiagnostics, DIAGNOSTICS_ROUTES } from "./routes/diagnostics.js";
|
|
4
|
+
import { handleAdoption, ADOPTION_ROUTES } from "./routes/adoption.js";
|
|
5
|
+
import { handleRetention, RETENTION_ROUTES } from "./routes/retention-ops.js";
|
|
6
|
+
import { handleAdminDrain, ADMIN_DRAIN_ROUTES } from "./routes/admin-drain.js";
|
|
7
|
+
import { handleDevices, DEVICES_ROUTES } from "./routes/devices.js";
|
|
8
|
+
import { handleAdminConfigRefresh, ADMIN_CONFIG_REFRESH_ROUTES } from "./routes/admin-config-refresh.js";
|
|
9
|
+
import { handleConfigCatalog, CONFIG_CATALOG_ROUTES } from "./routes/config-catalog.js";
|
|
10
|
+
import { handleMemoryOptOut, MEMORY_OPTOUT_ROUTES } from "./routes/admin-memory-optout.js";
|
|
11
|
+
import { handleMemoryPolicy, MEMORY_POLICY_ROUTES } from "./routes/memory-policy.js";
|
|
12
|
+
import { handleMemoryBundle, MEMORY_BUNDLE_ROUTES } from "./routes/memory-bundle.js";
|
|
13
|
+
import { handleMemoryCompliance, MEMORY_COMPLIANCE_ROUTES } from "./routes/memory-compliance.js";
|
|
14
|
+
import { handleMemoryOrigin, MEMORY_ORIGIN_ROUTES } from "./routes/memory-origin.js";
|
|
15
|
+
import { handleMemoryConsolidation, MEMORY_CONSOLIDATION_ROUTES } from "./routes/memory-consolidation.js";
|
|
16
|
+
import { handleSharedMemory, SHARED_MEMORY_ROUTES } from "./routes/shared-memory.js";
|
|
17
|
+
import { handleRules, RULES_ROUTES } from "./routes/rules.js";
|
|
18
|
+
import { handleSessionsList, SESSIONS_LIST_ROUTES } from "./routes/sessions-list.js";
|
|
19
|
+
import { handleAgentRoster, AGENT_ROSTER_ROUTES } from "./routes/agents-roster.js";
|
|
20
|
+
import { handleSessions, SESSIONS_ROUTES } from "./routes/sessions.js";
|
|
21
|
+
import { handleSessionSync, SESSION_SYNC_ROUTES } from "./routes/session-sync.js";
|
|
22
|
+
import { handleAttachments, ATTACHMENTS_ROUTES } from "./routes/attachments.js";
|
|
23
|
+
import { handleFleet, FLEET_ROUTES } from "./routes/fleet.js";
|
|
24
|
+
import { handleA2aServe, handleA2a, A2A_SERVE_ROUTES, A2A_RPC_ROUTES } from "./routes/a2a-serve.js";
|
|
25
|
+
import { handleTraceUsage, TRACE_USAGE_ROUTES } from "./routes/trace-usage.js";
|
|
26
|
+
import { handleWorkflows, handleWorkflowAgentSteer, WORKFLOWS_ROUTES, WORKFLOW_AGENT_STEER_ROUTES } from "./routes/workflows.js";
|
|
27
|
+
import { handleNotifyWake, NOTIFY_WAKE_ROUTES } from "./routes/notify-wake.js";
|
|
28
|
+
import { handleApprovalsAssistant, APPROVALS_ASSISTANT_ROUTES } from "./routes/approvals-assistant.js";
|
|
29
|
+
import { handleRuns, handleRunVerbs, RUNS_ROUTES, RUN_VERBS_ROUTES } from "./routes/runs.js";
|
|
30
|
+
import { handleRunMemoryCapture, RUN_MEMORY_CAPTURE_ROUTES } from "./routes/run-memory-capture.js";
|
|
31
|
+
import { handleSideQuery, SIDE_QUERY_ROUTES } from "./routes/side-query.js";
|
|
32
|
+
import { handleTasks, TASKS_ROUTES } from "./routes/tasks.js";
|
|
33
|
+
import { handleLeader, LEADER_ROUTES } from "./routes/leader.js";
|
|
34
|
+
import { handleImages, IMAGES_ROUTES } from "./routes/images.js";
|
|
35
|
+
function row(spec) {
|
|
36
|
+
return spec;
|
|
37
|
+
}
|
|
35
38
|
export const ROUTES = [
|
|
36
|
-
{ handler: handleTraceUsage, position: "pre-credential", label: "trace-usage" },
|
|
37
|
-
{ handler: handleWorkflows, position: "pre-credential", label: "workflows" },
|
|
38
|
-
{ handler: handleFleet, position: "pre-credential", label: "fleet" },
|
|
39
|
-
{ handler: handleA2aServe, position: "pre-credential", label: "a2a-serve" },
|
|
40
|
-
{ handler: handleCapabilities, position: "post-credential", label: "capabilities" },
|
|
41
|
-
{ handler: handleSideQuery, position: "post-credential", label: "side-query" },
|
|
42
|
-
{ handler: handleTasks, position: "post-credential", label: "tasks" },
|
|
43
|
-
{ handler: handleRuns, position: "post-credential", label: "runs" },
|
|
44
|
-
{ handler: handleA2a, position: "post-credential", label: "a2a" },
|
|
45
|
-
{ handler: handleWorkflowAgentSteer, position: "post-credential", label: "workflow-agent-steer" },
|
|
46
|
-
{ handler: handleRunVerbs, position: "post-credential", label: "run-verbs" },
|
|
47
|
-
{ handler: handleRunMemoryCapture, position: "post-credential", label: "run-memory-capture" },
|
|
48
|
-
{ handler: handleLeader, position: "post-credential", label: "leader" },
|
|
49
|
-
{ handler: handleImages, position: "post-credential", label: "images" },
|
|
50
|
-
{ handler: handleApprovalsAssistant, position: "post-credential", label: "approvals-assistant" },
|
|
51
|
-
{ handler: handleObservability, position: "post-credential", label: "observability" },
|
|
52
|
-
{ handler: handleDiagnostics, position: "post-credential", label: "diagnostics" },
|
|
53
|
-
{ handler: handleAdoption, position: "post-credential", label: "adoption" },
|
|
54
|
-
{ handler: handleRetention, position: "post-credential", label: "retention" },
|
|
55
|
-
{ handler: handleAdminDrain, position: "post-credential", label: "admin-drain" },
|
|
56
|
-
{ handler: handleDevices, position: "post-credential", label: "devices" },
|
|
57
|
-
{ handler: handleAdminConfigRefresh, position: "post-credential", label: "admin-config-refresh" },
|
|
58
|
-
{ handler: handleConfigCatalog, position: "post-credential", label: "config-catalog" },
|
|
59
|
-
{ handler: handleMemoryOptOut, position: "post-credential", label: "memory-opt-out" },
|
|
60
|
-
{ handler: handleMemoryPolicy, position: "post-credential", label: "memory-policy" },
|
|
61
|
-
{ handler: handleMemoryBundle, position: "post-credential", label: "memory-bundle" },
|
|
62
|
-
{ handler: handleMemoryCompliance, position: "post-credential", label: "memory-compliance" },
|
|
63
|
-
{ handler: handleMemoryOrigin, position: "post-credential", label: "memory-origin" },
|
|
64
|
-
{ handler: handleMemoryConsolidation, position: "post-credential", label: "memory-consolidation", enabled: (deps) => Boolean(deps.memoryConsolidation) },
|
|
65
|
-
{ handler: handleRules, position: "post-credential", label: "rules" },
|
|
66
|
-
{ handler: handleSharedMemory, position: "post-credential", label: "shared-memory", enabled: (deps) => Boolean(deps.sharedMemoryStore) && Boolean(deps.orgMemoryDirectory) },
|
|
67
|
-
{ handler: handleSessionsList, position: "post-credential", label: "sessions-list" },
|
|
68
|
-
{ handler: handleAgentRoster, position: "post-credential", label: "agent-roster" },
|
|
69
|
-
{ handler: handleSessions, position: "post-credential", label: "sessions" },
|
|
70
|
-
{ handler: handleSessionSync, position: "post-credential", label: "session-sync" },
|
|
71
|
-
{ handler: handleAttachments, position: "post-credential", label: "attachments" },
|
|
72
|
-
{ handler: handleNotifyWake, position: "post-credential", label: "notify-wake" },
|
|
39
|
+
row({ handler: handleTraceUsage, decls: TRACE_USAGE_ROUTES, position: "pre-credential", label: "trace-usage" }),
|
|
40
|
+
row({ handler: handleWorkflows, decls: WORKFLOWS_ROUTES, position: "pre-credential", label: "workflows" }),
|
|
41
|
+
row({ handler: handleFleet, decls: FLEET_ROUTES, position: "pre-credential", label: "fleet" }),
|
|
42
|
+
row({ handler: handleA2aServe, decls: A2A_SERVE_ROUTES, position: "pre-credential", label: "a2a-serve" }),
|
|
43
|
+
row({ handler: handleCapabilities, decls: CAPABILITIES_ROUTES, position: "post-credential", label: "capabilities" }),
|
|
44
|
+
row({ handler: handleSideQuery, decls: SIDE_QUERY_ROUTES, position: "post-credential", label: "side-query" }),
|
|
45
|
+
row({ handler: handleTasks, decls: TASKS_ROUTES, position: "post-credential", label: "tasks" }),
|
|
46
|
+
row({ handler: handleRuns, decls: RUNS_ROUTES, position: "post-credential", label: "runs" }),
|
|
47
|
+
row({ handler: handleA2a, decls: A2A_RPC_ROUTES, position: "post-credential", label: "a2a" }),
|
|
48
|
+
row({ handler: handleWorkflowAgentSteer, decls: WORKFLOW_AGENT_STEER_ROUTES, position: "post-credential", label: "workflow-agent-steer" }),
|
|
49
|
+
row({ handler: handleRunVerbs, decls: RUN_VERBS_ROUTES, position: "post-credential", label: "run-verbs" }),
|
|
50
|
+
row({ handler: handleRunMemoryCapture, decls: RUN_MEMORY_CAPTURE_ROUTES, position: "post-credential", label: "run-memory-capture" }),
|
|
51
|
+
row({ handler: handleLeader, decls: LEADER_ROUTES, position: "post-credential", label: "leader", enabled: (deps) => Boolean(deps.leaderEndpoint) }),
|
|
52
|
+
row({ handler: handleImages, decls: IMAGES_ROUTES, position: "post-credential", label: "images" }),
|
|
53
|
+
row({ handler: handleApprovalsAssistant, decls: APPROVALS_ASSISTANT_ROUTES, position: "post-credential", label: "approvals-assistant", enabled: (deps) => Boolean(deps.checkpointStore) }),
|
|
54
|
+
row({ handler: handleObservability, decls: OBSERVABILITY_ROUTES, position: "post-credential", label: "observability" }),
|
|
55
|
+
row({ handler: handleDiagnostics, decls: DIAGNOSTICS_ROUTES, position: "post-credential", label: "diagnostics", enabled: (deps) => Boolean(deps.staticWiring) }),
|
|
56
|
+
row({ handler: handleAdoption, decls: ADOPTION_ROUTES, position: "post-credential", label: "adoption" }),
|
|
57
|
+
row({ handler: handleRetention, decls: RETENTION_ROUTES, position: "post-credential", label: "retention" }),
|
|
58
|
+
row({ handler: handleAdminDrain, decls: ADMIN_DRAIN_ROUTES, position: "post-credential", label: "admin-drain" }),
|
|
59
|
+
row({ handler: handleDevices, decls: DEVICES_ROUTES, position: "post-credential", label: "devices" }),
|
|
60
|
+
row({ handler: handleAdminConfigRefresh, decls: ADMIN_CONFIG_REFRESH_ROUTES, position: "post-credential", label: "admin-config-refresh" }),
|
|
61
|
+
row({ handler: handleConfigCatalog, decls: CONFIG_CATALOG_ROUTES, position: "post-credential", label: "config-catalog", enabled: (deps) => deps.config.configCatalogEnabled === true }),
|
|
62
|
+
row({ handler: handleMemoryOptOut, decls: MEMORY_OPTOUT_ROUTES, position: "post-credential", label: "memory-opt-out" }),
|
|
63
|
+
row({ handler: handleMemoryPolicy, decls: MEMORY_POLICY_ROUTES, position: "post-credential", label: "memory-policy" }),
|
|
64
|
+
row({ handler: handleMemoryBundle, decls: MEMORY_BUNDLE_ROUTES, position: "post-credential", label: "memory-bundle" }),
|
|
65
|
+
row({ handler: handleMemoryCompliance, decls: MEMORY_COMPLIANCE_ROUTES, position: "post-credential", label: "memory-compliance" }),
|
|
66
|
+
row({ handler: handleMemoryOrigin, decls: MEMORY_ORIGIN_ROUTES, position: "post-credential", label: "memory-origin" }),
|
|
67
|
+
row({ handler: handleMemoryConsolidation, decls: MEMORY_CONSOLIDATION_ROUTES, position: "post-credential", label: "memory-consolidation", enabled: (deps) => Boolean(deps.memoryConsolidation) }),
|
|
68
|
+
row({ handler: handleRules, decls: RULES_ROUTES, position: "post-credential", label: "rules" }),
|
|
69
|
+
row({ handler: handleSharedMemory, decls: SHARED_MEMORY_ROUTES, position: "post-credential", label: "shared-memory", enabled: (deps) => Boolean(deps.sharedMemoryStore) && Boolean(deps.orgMemoryDirectory) }),
|
|
70
|
+
row({ handler: handleSessionsList, decls: SESSIONS_LIST_ROUTES, position: "post-credential", label: "sessions-list" }),
|
|
71
|
+
row({ handler: handleAgentRoster, decls: AGENT_ROSTER_ROUTES, position: "post-credential", label: "agent-roster" }),
|
|
72
|
+
row({ handler: handleSessions, decls: SESSIONS_ROUTES, position: "post-credential", label: "sessions" }),
|
|
73
|
+
row({ handler: handleSessionSync, decls: SESSION_SYNC_ROUTES, position: "post-credential", label: "session-sync" }),
|
|
74
|
+
row({ handler: handleAttachments, decls: ATTACHMENTS_ROUTES, position: "post-credential", label: "attachments" }),
|
|
75
|
+
row({ handler: handleNotifyWake, decls: NOTIFY_WAKE_ROUTES, position: "post-credential", label: "notify-wake" }),
|
|
73
76
|
];
|
|
74
77
|
export const PRE_CREDENTIAL_ROUTES = ROUTES.filter((r) => r.position === "pre-credential");
|
|
75
78
|
export const POST_CREDENTIAL_ROUTES = ROUTES.filter((r) => r.position === "post-credential");
|
|
76
|
-
|
|
77
|
-
{ path: "/health" },
|
|
78
|
-
{ path: "/metrics" },
|
|
79
|
-
{ path: "/metrics/summary" },
|
|
80
|
-
{ path: "/metrics/plan-cache" },
|
|
81
|
-
{ path: "/v1/models" },
|
|
82
|
-
{ path: "/v1/tasks", billable: true },
|
|
83
|
-
{ path: "/v1/tasks/stream", billable: true },
|
|
84
|
-
{ path: "/v1/tasks/source-summary" },
|
|
85
|
-
{ path: "/v1/runs", billable: true },
|
|
86
|
-
{ path: "/v1/sessions" },
|
|
87
|
-
{ path: "/v1/approvals" },
|
|
88
|
-
{ path: "/v1/approvals/stream" },
|
|
89
|
-
{ path: "/v1/assistant/inbox" },
|
|
90
|
-
{ path: "/v1/assistant/tasks" },
|
|
91
|
-
{ path: "/v1/usage" },
|
|
92
|
-
{ path: "/v1/policy" },
|
|
93
|
-
{ path: "/v1/capabilities" },
|
|
94
|
-
{ path: "/v1/images" },
|
|
95
|
-
{ path: "/v1/images/bakes" },
|
|
96
|
-
{ path: "/v1/images/bakes/claim" },
|
|
97
|
-
{ path: "/v1/images/select" },
|
|
98
|
-
{ path: "/v1/images/register" },
|
|
99
|
-
{ path: "/v1/workflows" },
|
|
100
|
-
{ path: "/v1/attachments" },
|
|
101
|
-
{ path: "/v1/leader", billable: true },
|
|
102
|
-
{ path: "/v1/outcomes" },
|
|
103
|
-
{ path: "/v1/side-query", billable: true },
|
|
104
|
-
{ path: "/v1/devices", credentialGated: ["GET"] },
|
|
105
|
-
{ path: "/v1/fleet/stream" },
|
|
106
|
-
{ path: "/v1/memory/export", credentialGated: ["POST"] },
|
|
107
|
-
{ path: "/v1/sendfile-links" },
|
|
108
|
-
{ path: "/v1/memory/import", credentialGated: ["POST"] },
|
|
109
|
-
{ path: "/v1/memory/erase", credentialGated: ["POST"] },
|
|
110
|
-
{ path: "/v1/memory/origin/external", credentialGated: ["GET"] },
|
|
111
|
-
{ path: "/v1/memory/origin/clearances", credentialGated: ["GET"] },
|
|
112
|
-
{ path: "/v1/shared-memory/stores" },
|
|
113
|
-
{ path: "/v1/diagnostics/wiring" },
|
|
114
|
-
{ path: "/v1/adoption", credentialGated: ["POST"] },
|
|
115
|
-
{ path: "/v1/admin/drain" },
|
|
116
|
-
{ path: "/v1/admin/config/refresh" },
|
|
117
|
-
{ path: "/v1/config/catalog" },
|
|
118
|
-
{ path: "/v1/admin/memory-optout", credentialGated: ["GET", "PUT"] },
|
|
119
|
-
{ path: "/v1/admin/memory/consolidation/run", billable: true },
|
|
120
|
-
{ path: "/v1/admin/memory/consolidation" },
|
|
121
|
-
{ path: "/v1/rules/cc-import/prepare" },
|
|
122
|
-
{ path: "/v1/rules/cc-import/redeem" },
|
|
123
|
-
{ path: "/v1/rules/local-import/prepare" },
|
|
124
|
-
{ path: "/v1/rules/local-import/redeem" },
|
|
125
|
-
{ path: "/v1/rules", credentialGated: ["DELETE"] },
|
|
126
|
-
{ path: "/.well-known/agent-card.json" },
|
|
127
|
-
{ path: "/v1/a2a", billable: true, methodDispatched: true },
|
|
128
|
-
{ path: "/v1/agents/roster" },
|
|
129
|
-
{ path: "/v1/ops/retention/audit" },
|
|
130
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/steer$/, label: "/v1/runs/:id/steer" },
|
|
131
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/memory\/capture-optout$/, label: "/v1/runs/:id/memory/capture-optout" },
|
|
132
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/interrupt$/, label: "/v1/runs/:id/interrupt" },
|
|
133
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/detach$/, label: "/v1/runs/:id/detach" },
|
|
134
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/cancel$/, label: "/v1/runs/:id/cancel" },
|
|
135
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/compact$/, label: "/v1/runs/:id/compact" },
|
|
136
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/events$/, label: "/v1/runs/:id/events" },
|
|
137
|
-
{ pattern: RUN_SUBAGENT_RESUME_RE, label: "/v1/runs/:id/subagents/:sub/*", billable: true },
|
|
138
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/subagents\/[^/]+\/(steer|resume|output|stream)$/, label: "/v1/runs/:id/subagents/:sub/*" },
|
|
139
|
-
{ pattern: /^\/v1\/runs\/[^/]+\/tasks\/[^/]+\/(output|stop)$/, label: "/v1/runs/:id/tasks/:tid/*" },
|
|
140
|
-
{ pattern: /^\/v1\/runs\/[^/]+$/, label: "/v1/runs/:id" },
|
|
141
|
-
{ pattern: /^\/v1\/images\/bakes\/[^/]+\/events$/, label: "/v1/images/bakes/:id/events" },
|
|
142
|
-
{ pattern: /^\/v1\/images\/bakes\/[^/]+\/cancel$/, label: "/v1/images/bakes/:id/cancel" },
|
|
143
|
-
{ pattern: /^\/v1\/images\/bakes\/[^/]+\/claim$/, label: "/v1/images/bakes/:id/claim" },
|
|
144
|
-
{ pattern: /^\/v1\/images\/bakes\/[^/]+\/ingest$/, label: "/v1/images/bakes/:id/ingest" },
|
|
145
|
-
{ pattern: /^\/v1\/images\/bakes\/[^/]+$/, label: "/v1/images/bakes/:id" },
|
|
146
|
-
{ pattern: /^\/v1\/images\/digests\/[^/]+$/, label: "/v1/images/digests/:digest" },
|
|
147
|
-
{ pattern: /^\/v1\/images\/[^/]+$/, label: "/v1/images/:profile" },
|
|
148
|
-
{ pattern: /^\/v1\/approvals\/[^/]+\/decide$/, label: "/v1/approvals/:id/decide" },
|
|
149
|
-
{ pattern: /^\/v1\/approvals\/[^/]+\/exemptions(\/[^/]+)?$/, label: "/v1/approvals/:id/exemptions" },
|
|
150
|
-
{ pattern: SESSION_WAKE_RE, label: "/v1/sessions/:id/$verb", billable: true },
|
|
151
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/(wake|fork|init|notify|events|head|mcp|a2a|policy|settings)$/, label: "/v1/sessions/:id/$verb" },
|
|
152
|
-
{ pattern: /^\/v1\/admin\/memory-optout\/[^/]+$/, label: "/v1/admin/memory-optout/:principal" },
|
|
153
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/memory\/erase$/, label: "/v1/sessions/:id/memory/erase" },
|
|
154
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/memory-status$/, label: "/v1/sessions/:id/memory-status" },
|
|
155
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/sync\/(manifest|entries|plan)$/, label: "/v1/sessions/:id/sync/$verb" },
|
|
156
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/sync\/import(\/[^/]+\/entries)?$/, label: "/v1/sessions/:id/sync/import" },
|
|
157
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/sync\/blobs(\/[^/]+)?$/, label: "/v1/sessions/:id/sync/blobs" },
|
|
158
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/sync\/history\/blobs\/[^/]+$/, label: "/v1/sessions/:id/sync/history/blobs/:hash" },
|
|
159
|
-
{ pattern: /^\/v1\/sessions\/[^/]+\/workspace(\/[^/]+(\/(tree|file|archive))?)?$/, label: "/v1/sessions/:id/workspace" },
|
|
160
|
-
{ pattern: /^\/v1\/sessions\/[^/]+$/, label: "/v1/sessions/:id" },
|
|
161
|
-
{ pattern: /^\/v1\/assistant\/tasks\/[^/]+\/preempt$/, label: "/v1/assistant/tasks/:id/preempt" },
|
|
162
|
-
{ pattern: ASSISTANT_RESUME_RE, label: "/v1/assistant/tasks/:id/resume", billable: true },
|
|
163
|
-
{ pattern: ASSISTANT_PLAN_REVIEW_RE, label: "/v1/assistant/tasks/:id/plan_review", billable: true },
|
|
164
|
-
{ pattern: /^\/v1\/elicitations\/[^/]+\/respond$/, label: "/v1/elicitations/:id/respond" },
|
|
165
|
-
{ pattern: /^\/v1\/questions\/[^/]+\/respond$/, label: "/v1/questions/:id/respond" },
|
|
166
|
-
{ pattern: /^\/v1\/tool-approvals\/[^/]+\/respond$/, label: "/v1/tool-approvals/:id/respond" },
|
|
167
|
-
{ pattern: /^\/v1\/workflows\/[^/]+\/agents\/[^/]+\/steer$/, label: "/v1/workflows/:id/agents/:aid/steer" },
|
|
168
|
-
{ pattern: /^\/v1\/workflows\/[^/]+\/(stream|journal)$/, label: "/v1/workflows/:id/$sub" },
|
|
169
|
-
{ pattern: /^\/v1\/workflows\/[^/]+$/, label: "/v1/workflows/:id" },
|
|
170
|
-
{ pattern: /^\/v1\/tasks\/[^/]+\/asks\/[^/]+\/decision$/, label: "/v1/tasks/:id/asks/:askId/decision" },
|
|
171
|
-
{ pattern: /^\/v1\/tasks\/[^/]+\/tool-results\/[^/]+$/, label: "/v1/tasks/:id/tool-results/:ref" },
|
|
172
|
-
{ pattern: /^\/v1\/tasks\/[^/]+\/(turns|stream|artifacts)$/, label: "/v1/tasks/:id/$sub" },
|
|
173
|
-
{ pattern: /^\/v1\/leader\/[^/]+$/, label: "/v1/leader/:id" },
|
|
174
|
-
{ pattern: /^\/v1\/devices\/sessions\/[^/]+\/rebind$/, label: "/v1/devices/sessions/:id/rebind" },
|
|
175
|
-
{ pattern: /^\/v1\/devices\/sessions\/[^/]+$/, label: "/v1/devices/sessions/:id", credentialGated: ["GET"] },
|
|
176
|
-
{ pattern: /^\/v1\/attachments\/[^/]+$/, label: "/v1/attachments/:id" },
|
|
177
|
-
{ pattern: /^\/v1\/capabilities\/scenarios\/[^/]+$/, label: "/v1/capabilities/scenarios/:name" },
|
|
178
|
-
{ pattern: /^\/v1\/adoption\/[^/]+$/, label: "/v1/adoption/:id" },
|
|
179
|
-
{ pattern: /^\/v1\/ops\/retention\/holds\/[^/]*$/, label: "/v1/ops/retention/holds/:domain" },
|
|
180
|
-
{ pattern: /^\/v1\/memory\/sync\/[^/]+$/, label: "/v1/memory/sync/:scope" },
|
|
181
|
-
{ pattern: /^\/v1\/memory\/entries\/[^/]+\/provenance$/, label: "/v1/memory/entries/:entryId/provenance", credentialGated: ["GET"] },
|
|
182
|
-
{ pattern: /^\/v1\/memory\/origin\/entries\/[^/]+\/clear$/, label: "/v1/memory/origin/entries/:entryId/clear" },
|
|
183
|
-
{ pattern: /^\/v1\/usage\/(summary|series|breakdown)$/, label: "/v1/usage/$sub" },
|
|
184
|
-
{ pattern: /^\/v1\/shared-memory\/stores\/[^/]+\/documents$/, label: "/v1/shared-memory/stores/:store/documents" },
|
|
185
|
-
{ pattern: /^\/v1\/shared-memory\/stores\/[^/]+\/document$/, label: "/v1/shared-memory/stores/:store/document" },
|
|
186
|
-
{ prefix: "/v1/approvals", billable: true },
|
|
187
|
-
{ prefix: "/v1/rules/cc-import/", credentialGated: ["POST"] },
|
|
188
|
-
{ prefix: "/v1/rules/local-import/", credentialGated: ["POST"] },
|
|
189
|
-
{ prefix: "/v1/memory/origin/entries/", credentialGated: ["POST"] },
|
|
190
|
-
{ prefix: "/v1/devices/", credentialGated: ["POST"] },
|
|
191
|
-
{ prefix: "/v1/admin/memory-optout/", credentialGated: ["PUT", "DELETE"] },
|
|
79
|
+
const PIPELINE_ROUTES = [
|
|
80
|
+
{ id: "health", path: "/health", methods: ["GET"] },
|
|
81
|
+
{ id: "metrics", path: "/metrics", methods: ["GET"] },
|
|
82
|
+
{ id: "metrics-summary", path: "/metrics/summary", methods: ["GET"] },
|
|
83
|
+
{ id: "metrics-plan-cache", path: "/metrics/plan-cache", methods: ["GET"] },
|
|
192
84
|
];
|
|
85
|
+
export const ROUTE_DECLARATIONS = [...PIPELINE_ROUTES, ...ROUTES.flatMap((r) => r.decls)];
|
|
193
86
|
function declMatches(d, url) {
|
|
194
87
|
if ("path" in d)
|
|
195
88
|
return url === d.path;
|
|
@@ -197,6 +90,14 @@ function declMatches(d, url) {
|
|
|
197
90
|
return url.startsWith(d.prefix);
|
|
198
91
|
return d.pattern.test(url);
|
|
199
92
|
}
|
|
93
|
+
const isDispatchDecl = (d) => !("prefix" in d);
|
|
94
|
+
export function matchDecl(d, url) {
|
|
95
|
+
if ("path" in d)
|
|
96
|
+
return url === d.path ? NO_PARAMS : null;
|
|
97
|
+
const m = d.pattern.exec(url);
|
|
98
|
+
return m === null ? null : (m.groups ?? NO_PARAMS);
|
|
99
|
+
}
|
|
100
|
+
const NO_PARAMS = Object.freeze({});
|
|
200
101
|
const LABEL_BY_PATH = new Map(ROUTE_DECLARATIONS.flatMap((d) => ("path" in d ? [[d.path, d.path]] : [])));
|
|
201
102
|
const SHAPED_LABEL_DECLS = ROUTE_DECLARATIONS.filter((d) => !("path" in d) && typeof d.label === "string");
|
|
202
103
|
const BILLABLE_DECLS = ROUTE_DECLARATIONS.filter((d) => d.billable === true);
|
|
@@ -232,4 +133,27 @@ export function isCredentialGatedRewrite(method, url) {
|
|
|
232
133
|
export function isMethodDispatchedSubmitPath(url) {
|
|
233
134
|
return METHOD_DISPATCHED_DECLS.some((d) => declMatches(d, url));
|
|
234
135
|
}
|
|
136
|
+
export function lookupRoute(decls, url, method) {
|
|
137
|
+
let hit = null;
|
|
138
|
+
let params = NO_PARAMS;
|
|
139
|
+
const allow = [];
|
|
140
|
+
for (const pass of PATH_FIRST) {
|
|
141
|
+
for (const d of decls) {
|
|
142
|
+
if (!isDispatchDecl(d) || ("path" in d) !== pass)
|
|
143
|
+
continue;
|
|
144
|
+
const p = matchDecl(d, url);
|
|
145
|
+
if (p === null)
|
|
146
|
+
continue;
|
|
147
|
+
for (const m of d.methods)
|
|
148
|
+
if (!allow.includes(m))
|
|
149
|
+
allow.push(m);
|
|
150
|
+
if (hit === null && d.methods.includes(method)) {
|
|
151
|
+
hit = d;
|
|
152
|
+
params = p;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { decl: hit, params, allow };
|
|
157
|
+
}
|
|
158
|
+
const PATH_FIRST = [true, false];
|
|
235
159
|
//# sourceMappingURL=route-table.js.map
|
|
@@ -2,7 +2,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
|
|
|
2
2
|
import { type A2ATaskState } from "@sema-agent/core";
|
|
3
3
|
import type { A2aServeConfig } from "../../config-types.js";
|
|
4
4
|
import { type RunRecord } from "../../plugins/store-contracts.js";
|
|
5
|
-
import type { RouteCtx } from "../route-ctx.js";
|
|
5
|
+
import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
6
6
|
/** 本实现说的 A2A 协议版本 —— 卡的 `protocolVersion` 与每条 RPC 响应的 `a2a-version` 头同源(单点)。 */
|
|
7
7
|
export declare const A2A_PROTOCOL_VERSION = "1.0";
|
|
8
8
|
/** 版本头名。**读**请求侧的它只是诊断材料(开集容忍:认识与否都照常答),**写**响应侧的它是我们自报
|
|
@@ -34,7 +34,7 @@ export declare function buildAgentCard(serve: A2aServeConfig): A2aAgentCard;
|
|
|
34
34
|
* 「域名词干 ⊆ 某个 capability 位名」。两个名字都取成 `capabilities.a2aServe` 的**子串**
|
|
35
35
|
* (`a2aServe` / `a2a`),于是两条都被那道门如实认出来 —— 而不是去放宽那道门的判据。
|
|
36
36
|
*/
|
|
37
|
-
export declare function handleA2aServe(req: IncomingMessage, res: ServerResponse,
|
|
37
|
+
export declare function handleA2aServe(req: IncomingMessage, res: ServerResponse, match: RouteMatch<A2aServeRouteId>, ctx: RouteCtx): Promise<void>;
|
|
38
38
|
/**
|
|
39
39
|
* 🔴 **反枚举不变式([ref])在本模块的执行点**:`tasks/get` 的「这条 task 不存在」与「这条 task 不是
|
|
40
40
|
* 你的」必须**逐字节**同形 —— 同一个 code、同一条 message、同一个(缺席的)data。两臂共用**这一个**
|
|
@@ -68,8 +68,23 @@ export declare function a2aStateForRun(run: Pick<RunRecord, "status" | "errorCod
|
|
|
68
68
|
* 命名(`handleA2a`,与 `handleA2aServe` 同族):见域入口①的命名注 —— 两个名字都取成
|
|
69
69
|
* `capabilities.a2aServe` 的子串,好让 `route-shape-roster` 层E 如实认出它们。
|
|
70
70
|
*/
|
|
71
|
-
export declare function handleA2a(req: IncomingMessage, res: ServerResponse,
|
|
71
|
+
export declare function handleA2a(req: IncomingMessage, res: ServerResponse, match: RouteMatch<A2aRpcRouteId>, ctx: RouteCtx): Promise<void>;
|
|
72
72
|
/** 九词闭集的对外可见锚(测试用它证明我们只发闭集词;也让「加一个自造词」在这里就被看见)。 */
|
|
73
73
|
export declare const A2A_SERVE_TASK_STATES: readonly A2ATaskState[];
|
|
74
|
+
export declare const A2A_SERVE_ROUTES: readonly [{
|
|
75
|
+
readonly id: "a2a-agent-card";
|
|
76
|
+
readonly path: "/.well-known/agent-card.json";
|
|
77
|
+
readonly methods: readonly ["GET"];
|
|
78
|
+
}];
|
|
79
|
+
/** 本域可分派行的 `id` 闭集 —— handler 的 `switch` 按它判穷尽(漏一口 = 编译红)。 */
|
|
80
|
+
export type A2aServeRouteId = RouteIdsOf<typeof A2A_SERVE_ROUTES>;
|
|
81
|
+
export declare const A2A_RPC_ROUTES: readonly [{
|
|
82
|
+
readonly id: "a2a-rpc";
|
|
83
|
+
readonly path: "/v1/a2a";
|
|
84
|
+
readonly billable: true;
|
|
85
|
+
readonly methodDispatched: true;
|
|
86
|
+
readonly methods: readonly ["POST"];
|
|
87
|
+
}];
|
|
88
|
+
export type A2aRpcRouteId = RouteIdsOf<typeof A2A_RPC_ROUTES>;
|
|
74
89
|
export {};
|
|
75
90
|
//# sourceMappingURL=a2a-serve.d.ts.map
|
|
@@ -7,6 +7,7 @@ import { HttpError } from "../../security.js";
|
|
|
7
7
|
import { scopedIdempotencyKey } from "../idempotency.js";
|
|
8
8
|
import { sendJson, sendError } from "../send.js";
|
|
9
9
|
import { gatedPrincipal, sendPrincipalRefusal } from "../principal-gate.js";
|
|
10
|
+
import { assertNever } from "../route-ctx.js";
|
|
10
11
|
import { createDurableRun } from "./runs.js";
|
|
11
12
|
export const A2A_PROTOCOL_VERSION = "1.0";
|
|
12
13
|
export const A2A_VERSION_HEADER = "a2a-version";
|
|
@@ -20,24 +21,22 @@ export function buildAgentCard(serve) {
|
|
|
20
21
|
skills: serve.skills.map((s) => ({ id: s.id, name: s.name ?? s.id, ...(s.description !== undefined ? { description: s.description } : {}) })),
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
|
-
export async function handleA2aServe(req, res,
|
|
24
|
-
const miss = { fell: false };
|
|
25
|
-
await handleA2aServeBody(req, res, url, ctx, miss);
|
|
26
|
-
return !miss.fell;
|
|
27
|
-
}
|
|
28
|
-
async function handleA2aServeBody(req, res, url, ctx, miss) {
|
|
24
|
+
export async function handleA2aServe(req, res, match, ctx) {
|
|
29
25
|
const { deps } = ctx;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
switch (match.decl.id) {
|
|
27
|
+
case "a2a-agent-card": {
|
|
28
|
+
const serve = deps.config.a2aServe;
|
|
29
|
+
if (!serve) {
|
|
30
|
+
sendError(res, 404, "not_found.route", "not found");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
res.setHeader(A2A_VERSION_HEADER, A2A_PROTOCOL_VERSION);
|
|
34
|
+
sendJson(res, 200, buildAgentCard(serve));
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return;
|
|
37
|
+
default:
|
|
38
|
+
return assertNever(match.decl.id);
|
|
39
39
|
}
|
|
40
|
-
miss.fell = true;
|
|
41
40
|
}
|
|
42
41
|
const JSONRPC_PARSE_ERROR = -32700;
|
|
43
42
|
const JSONRPC_INVALID_REQUEST = -32600;
|
|
@@ -324,16 +323,13 @@ const A2A_METHODS = {
|
|
|
324
323
|
"message/send": handleMessageSend,
|
|
325
324
|
"tasks/get": handleTasksGet,
|
|
326
325
|
};
|
|
327
|
-
export async function handleA2a(req, res,
|
|
328
|
-
const miss = { fell: false };
|
|
329
|
-
await handleA2aRpcBody(req, res, url, ctx, miss);
|
|
330
|
-
return !miss.fell;
|
|
331
|
-
}
|
|
332
|
-
async function handleA2aRpcBody(req, res, url, ctx, miss) {
|
|
326
|
+
export async function handleA2a(req, res, match, ctx) {
|
|
333
327
|
const { deps } = ctx;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
328
|
+
switch (match.decl.id) {
|
|
329
|
+
case "a2a-rpc":
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
return assertNever(match.decl.id);
|
|
337
333
|
}
|
|
338
334
|
const serve = deps.config.a2aServe;
|
|
339
335
|
if (!serve) {
|
|
@@ -409,4 +405,10 @@ function sendRpc(res, body) {
|
|
|
409
405
|
sendJson(res, 200, body);
|
|
410
406
|
}
|
|
411
407
|
export const A2A_SERVE_TASK_STATES = A2A_TASK_STATES;
|
|
408
|
+
export const A2A_SERVE_ROUTES = [
|
|
409
|
+
{ id: "a2a-agent-card", path: "/.well-known/agent-card.json", methods: ["GET"] },
|
|
410
|
+
];
|
|
411
|
+
export const A2A_RPC_ROUTES = [
|
|
412
|
+
{ id: "a2a-rpc", path: "/v1/a2a", billable: true, methodDispatched: true, methods: ["POST"] },
|
|
413
|
+
];
|
|
412
414
|
//# sourceMappingURL=a2a-serve.js.map
|
|
@@ -14,7 +14,14 @@
|
|
|
14
14
|
* 回执会让运维以为配置已经拉过了,那比拒绝糟得多。
|
|
15
15
|
*/
|
|
16
16
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
17
|
-
import type { RouteCtx } from "../route-ctx.js";
|
|
17
|
+
import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
18
18
|
export declare const ADMIN_CONFIG_REFRESH_PATH = "/v1/admin/config/refresh";
|
|
19
|
-
export declare function handleAdminConfigRefresh(req: IncomingMessage, res: ServerResponse,
|
|
19
|
+
export declare function handleAdminConfigRefresh(req: IncomingMessage, res: ServerResponse, match: RouteMatch<AdminConfigRefreshRouteId>, ctx: RouteCtx): Promise<void>;
|
|
20
|
+
export declare const ADMIN_CONFIG_REFRESH_ROUTES: readonly [{
|
|
21
|
+
readonly id: "admin-config-refresh";
|
|
22
|
+
readonly path: "/v1/admin/config/refresh";
|
|
23
|
+
readonly methods: readonly ["POST"];
|
|
24
|
+
}];
|
|
25
|
+
/** 本域可分派行的 `id` 闭集 —— handler 的 `switch` 按它判穷尽(漏一口 = 编译红)。 */
|
|
26
|
+
export type AdminConfigRefreshRouteId = RouteIdsOf<typeof ADMIN_CONFIG_REFRESH_ROUTES>;
|
|
20
27
|
//# sourceMappingURL=admin-config-refresh.d.ts.map
|
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import { sendJson, sendError } from "../send.js";
|
|
2
2
|
import { gatedPrincipal, explicitOperatorOk, sendPrincipalRefusal } from "../principal-gate.js";
|
|
3
|
+
import { assertNever } from "../route-ctx.js";
|
|
3
4
|
export const ADMIN_CONFIG_REFRESH_PATH = "/v1/admin/config/refresh";
|
|
4
5
|
const OPERATOR_ONLY_MESSAGE = "config refresh is operator-only: the caller principal is not in OPERATOR_PRINCIPALS (an empty list means NO one is an operator — configure it to enable this endpoint)";
|
|
5
|
-
export async function handleAdminConfigRefresh(req, res,
|
|
6
|
-
const miss = { fell: false };
|
|
7
|
-
await handleAdminConfigRefreshBody(req, res, url, ctx, miss);
|
|
8
|
-
return !miss.fell;
|
|
9
|
-
}
|
|
10
|
-
async function handleAdminConfigRefreshBody(req, res, url, ctx, miss) {
|
|
6
|
+
export async function handleAdminConfigRefresh(req, res, match, ctx) {
|
|
11
7
|
const { deps } = ctx;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
switch (match.decl.id) {
|
|
9
|
+
case "admin-config-refresh": {
|
|
10
|
+
const principal = gatedPrincipal(req, deps.config);
|
|
11
|
+
if (deps.config.requirePrincipal && !principal) {
|
|
12
|
+
sendPrincipalRefusal(res, req, deps.config);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (!explicitOperatorOk(principal, deps.config.operatorPrincipals)) {
|
|
16
|
+
sendError(res, 403, "auth.operator_only", OPERATOR_ONLY_MESSAGE);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const trigger = deps.configRefreshNow;
|
|
20
|
+
const outcome = trigger ? await trigger() : "not-wired";
|
|
21
|
+
if (outcome === "failed") {
|
|
22
|
+
sendError(res, 502, "internal.config_refresh_failed", "the config refresh tick failed (source unreachable / unreadable / apply error) — the live config is unchanged; see the worker's sema_registry_refresh_failed log line for the cause");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (outcome === "not-wired") {
|
|
26
|
+
sendError(res, 409, "config.refresh_unavailable", "this deployment has no config pipeline to refresh — set CONFIG_CENTER (remote control plane) or CONFIG_PROVIDER=local (config.d on disk); an env-only worker has nothing to pull");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const gen = deps.configApplyState?.();
|
|
30
|
+
sendJson(res, 200, { triggered: true, targetVersion: gen?.configTargetVersion ?? 0, appliedVersion: gen?.configAppliedVersion ?? 0 });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return assertNever(match.decl.id);
|
|
35
35
|
}
|
|
36
|
-
const gen = deps.configApplyState?.();
|
|
37
|
-
sendJson(res, 200, { triggered: true, targetVersion: gen?.configTargetVersion ?? 0, appliedVersion: gen?.configAppliedVersion ?? 0 });
|
|
38
36
|
}
|
|
37
|
+
export const ADMIN_CONFIG_REFRESH_ROUTES = [
|
|
38
|
+
{ id: "admin-config-refresh", path: ADMIN_CONFIG_REFRESH_PATH, methods: ["POST"] },
|
|
39
|
+
];
|
|
39
40
|
//# sourceMappingURL=admin-config-refresh.js.map
|
|
@@ -31,9 +31,16 @@
|
|
|
31
31
|
* 有用的因由说不出来,取舍要属主拍。
|
|
32
32
|
*/
|
|
33
33
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
34
|
-
import type { RouteCtx } from "../route-ctx.js";
|
|
34
|
+
import type { RouteCtx, RouteMatch, RouteIdsOf } from "../route-ctx.js";
|
|
35
35
|
export declare const ADMIN_DRAIN_PATH = "/v1/admin/drain";
|
|
36
36
|
/** 上限与 approvals 的 reason 族同量级(消费面同为人读短句;非同一常量——两面语义无关,独立演化)。 */
|
|
37
37
|
export declare const MAX_DRAIN_REASON_CHARS = 256;
|
|
38
|
-
export declare function handleAdminDrain(req: IncomingMessage, res: ServerResponse,
|
|
38
|
+
export declare function handleAdminDrain(req: IncomingMessage, res: ServerResponse, match: RouteMatch<AdminDrainRouteId>, ctx: RouteCtx): Promise<void>;
|
|
39
|
+
export declare const ADMIN_DRAIN_ROUTES: readonly [{
|
|
40
|
+
readonly id: "admin-drain";
|
|
41
|
+
readonly path: "/v1/admin/drain";
|
|
42
|
+
readonly methods: readonly ["POST"];
|
|
43
|
+
}];
|
|
44
|
+
type AdminDrainRouteId = RouteIdsOf<typeof ADMIN_DRAIN_ROUTES>;
|
|
45
|
+
export {};
|
|
39
46
|
//# sourceMappingURL=admin-drain.d.ts.map
|