@sema-agent/server 7.79.1 → 7.79.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boot/late-binds.d.ts +35 -0
- package/dist/boot/late-binds.js +20 -0
- package/dist/boot/stage-01-config.d.ts +7 -0
- package/dist/boot/stage-01-config.js +60 -0
- package/dist/boot/stage-02-registry-pull.d.ts +10 -0
- package/dist/boot/stage-02-registry-pull.js +11 -0
- package/dist/boot/stage-03-store-backend.d.ts +32 -0
- package/dist/boot/stage-03-store-backend.js +11 -0
- package/dist/boot/stage-04-stores.d.ts +69 -0
- package/dist/boot/stage-04-stores.js +49 -0
- package/dist/boot/stage-05-execution-env.d.ts +82 -0
- package/dist/boot/stage-05-execution-env.js +20 -0
- package/dist/boot/stage-06-runners.d.ts +143 -0
- package/dist/boot/stage-06-runners.js +207 -0
- package/dist/boot/stage-07-capability-layer.d.ts +157 -0
- package/dist/boot/stage-07-capability-layer.js +162 -0
- package/dist/boot/stage-08-reapers.d.ts +172 -0
- package/dist/boot/stage-08-reapers.js +78 -0
- package/dist/boot/stage-09-leader.d.ts +204 -0
- package/dist/boot/stage-09-leader.js +47 -0
- package/dist/boot/stage-10-http-server.d.ts +204 -0
- package/dist/boot/stage-10-http-server.js +289 -0
- package/dist/config-invariants.d.ts +9 -0
- package/dist/config-invariants.js +7 -1
- package/dist/config-types.d.ts +1 -1
- package/dist/http/dispatch.d.ts +9 -73
- package/dist/http/dispatch.js +12 -281
- package/dist/http/route-table.d.ts +113 -0
- package/dist/http/route-table.js +235 -0
- package/dist/http/routes/admin-memory-optout.d.ts +1 -1
- package/dist/http/routes/memory-compliance.d.ts +1 -1
- package/dist/http/routes/memory-origin.d.ts +1 -1
- package/dist/http/routes/rules.js +4 -4
- package/dist/http/server.d.ts +2 -1
- package/dist/http/server.js +2 -1
- package/dist/main.js +20 -870
- package/dist/service-version.d.ts +5 -0
- package/dist/service-version.js +12 -0
- package/dist/trace/redact.d.ts +16 -6
- package/dist/trace/redact.js +568 -246
- package/package.json +1 -1
|
@@ -0,0 +1,235 @@
|
|
|
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, SESSION_WAKE_RE } from "./routes/notify-wake.js";
|
|
28
|
+
import { handleApprovalsAssistant, ASSISTANT_RESUME_RE, ASSISTANT_PLAN_REVIEW_RE } from "./routes/approvals-assistant.js";
|
|
29
|
+
import { handleRuns, handleRunVerbs, RUN_SUBAGENT_RESUME_RE } from "./routes/runs.js";
|
|
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";
|
|
35
|
+
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" },
|
|
73
|
+
];
|
|
74
|
+
export const PRE_CREDENTIAL_ROUTES = ROUTES.filter((r) => r.position === "pre-credential");
|
|
75
|
+
export const POST_CREDENTIAL_ROUTES = ROUTES.filter((r) => r.position === "post-credential");
|
|
76
|
+
export const ROUTE_DECLARATIONS = [
|
|
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"] },
|
|
192
|
+
];
|
|
193
|
+
function declMatches(d, url) {
|
|
194
|
+
if ("path" in d)
|
|
195
|
+
return url === d.path;
|
|
196
|
+
if ("prefix" in d)
|
|
197
|
+
return url.startsWith(d.prefix);
|
|
198
|
+
return d.pattern.test(url);
|
|
199
|
+
}
|
|
200
|
+
const LABEL_BY_PATH = new Map(ROUTE_DECLARATIONS.flatMap((d) => ("path" in d ? [[d.path, d.path]] : [])));
|
|
201
|
+
const SHAPED_LABEL_DECLS = ROUTE_DECLARATIONS.filter((d) => !("path" in d) && typeof d.label === "string");
|
|
202
|
+
const BILLABLE_DECLS = ROUTE_DECLARATIONS.filter((d) => d.billable === true);
|
|
203
|
+
const METHOD_DISPATCHED_DECLS = ROUTE_DECLARATIONS.filter((d) => d.methodDispatched === true);
|
|
204
|
+
const CREDENTIAL_GATED_BY_METHOD = (() => {
|
|
205
|
+
const m = new Map();
|
|
206
|
+
for (const d of ROUTE_DECLARATIONS)
|
|
207
|
+
for (const method of d.credentialGated ?? []) {
|
|
208
|
+
const bucket = m.get(method);
|
|
209
|
+
if (bucket === undefined)
|
|
210
|
+
m.set(method, [d]);
|
|
211
|
+
else
|
|
212
|
+
bucket.push(d);
|
|
213
|
+
}
|
|
214
|
+
return m;
|
|
215
|
+
})();
|
|
216
|
+
export function routeLabel(_method, url) {
|
|
217
|
+
const exact = LABEL_BY_PATH.get(url);
|
|
218
|
+
if (exact !== undefined)
|
|
219
|
+
return exact;
|
|
220
|
+
for (const d of SHAPED_LABEL_DECLS)
|
|
221
|
+
if (declMatches(d, url))
|
|
222
|
+
return d.label;
|
|
223
|
+
return "other";
|
|
224
|
+
}
|
|
225
|
+
export function isBillableSubmitPath(url) {
|
|
226
|
+
return BILLABLE_DECLS.some((d) => declMatches(d, url));
|
|
227
|
+
}
|
|
228
|
+
export function isCredentialGatedRewrite(method, url) {
|
|
229
|
+
const rows = CREDENTIAL_GATED_BY_METHOD.get(method.toUpperCase());
|
|
230
|
+
return rows !== undefined && rows.some((d) => declMatches(d, url));
|
|
231
|
+
}
|
|
232
|
+
export function isMethodDispatchedSubmitPath(url) {
|
|
233
|
+
return METHOD_DISPATCHED_DECLS.some((d) => declMatches(d, url));
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=route-table.js.map
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
43
43
|
import type { RouteCtx } from "../route-ctx.js";
|
|
44
44
|
export declare const ADMIN_MEMORY_OPTOUT_PATH = "/v1/admin/memory-optout";
|
|
45
|
-
/** 带参口(`:principal`)⇒
|
|
45
|
+
/** 带参口(`:principal`)⇒ 路由声明表(`http/route-table.ts`)里走 `pattern` 行,不是 `path` 行。 */
|
|
46
46
|
export declare const ADMIN_MEMORY_OPTOUT_OVERRIDE_RE: RegExp;
|
|
47
47
|
export declare function handleMemoryOptOut(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
48
48
|
//# sourceMappingURL=admin-memory-optout.d.ts.map
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
97
97
|
import type { RouteCtx } from "../route-ctx.js";
|
|
98
98
|
export declare const MEMORY_ERASE_PATH = "/v1/memory/erase";
|
|
99
|
-
/** 单条出处读面。带参路径 ⇒
|
|
99
|
+
/** 单条出处读面。带参路径 ⇒ 路由声明表(`http/route-table.ts`)里走 `pattern` 行,不是 `path` 行。 */
|
|
100
100
|
export declare const MEMORY_PROVENANCE_RE: RegExp;
|
|
101
101
|
export declare function handleMemoryCompliance(req: IncomingMessage, res: ServerResponse, url: string, ctx: RouteCtx): Promise<boolean>;
|
|
102
102
|
//# sourceMappingURL=memory-compliance.d.ts.map
|
|
@@ -82,7 +82,7 @@ import { type OriginClearanceRow } from "@sema-agent/core";
|
|
|
82
82
|
import type { RouteCtx } from "../route-ctx.js";
|
|
83
83
|
export declare const MEMORY_ORIGIN_EXTERNAL_PATH = "/v1/memory/origin/external";
|
|
84
84
|
export declare const MEMORY_ORIGIN_CLEARANCES_PATH = "/v1/memory/origin/clearances";
|
|
85
|
-
/** 带参写口 ⇒
|
|
85
|
+
/** 带参写口 ⇒ 路由声明表(`http/route-table.ts`)里走 `pattern` 行,不是 `path` 行。 */
|
|
86
86
|
export declare const MEMORY_ORIGIN_CLEAR_RE: RegExp;
|
|
87
87
|
/**
|
|
88
88
|
* 一条清标行 → wire 的**显式白名单**(F-7)。全文理由见文件头「为什么是白名单」。
|
|
@@ -92,10 +92,10 @@ async function handleRulesBody(req, res, url, ctx, miss) {
|
|
|
92
92
|
const { readJson, rateLimited } = ctx.helpers;
|
|
93
93
|
const isPrepare = req.method === "POST" && url === RULES_CC_IMPORT_PREPARE_PATH;
|
|
94
94
|
const isRedeem = req.method === "POST" && url === RULES_CC_IMPORT_REDEEM_PATH;
|
|
95
|
-
const isLocalPrepare = req.method === "POST" && url ===
|
|
96
|
-
const isLocalRedeem = req.method === "POST" && url ===
|
|
97
|
-
const isList = req.method === "GET" && url ===
|
|
98
|
-
const isRevoke = req.method === "DELETE" && url ===
|
|
95
|
+
const isLocalPrepare = req.method === "POST" && url === RULES_LOCAL_IMPORT_PREPARE_PATH;
|
|
96
|
+
const isLocalRedeem = req.method === "POST" && url === RULES_LOCAL_IMPORT_REDEEM_PATH;
|
|
97
|
+
const isList = req.method === "GET" && url === RULES_PATH;
|
|
98
|
+
const isRevoke = req.method === "DELETE" && url === RULES_PATH;
|
|
99
99
|
if (!isPrepare && !isRedeem && !isList && !isRevoke && !isLocalPrepare && !isLocalRedeem) {
|
|
100
100
|
miss.fell = true;
|
|
101
101
|
return;
|
package/dist/http/server.d.ts
CHANGED
|
@@ -35,7 +35,8 @@ export { cascadeConfig };
|
|
|
35
35
|
import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
|
|
36
36
|
export { coarseStatusForState, errorCodeForExit };
|
|
37
37
|
import { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills } from "./admission.js";
|
|
38
|
-
import {
|
|
38
|
+
import { hasServiceAuth } from "./dispatch.js";
|
|
39
|
+
import { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath } from "./route-table.js";
|
|
39
40
|
export { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth };
|
|
40
41
|
export { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills };
|
|
41
42
|
import { explicitOperatorOk, isOperator } from "./principal-gate.js";
|
package/dist/http/server.js
CHANGED
|
@@ -22,7 +22,8 @@ import { sendError, httpErrorCode, msg } from "./send.js";
|
|
|
22
22
|
import { createRequestGuards } from "./request-guards.js";
|
|
23
23
|
import { createAdmission, MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills } from "./admission.js";
|
|
24
24
|
import { createResumeLegs } from "./resume-legs.js";
|
|
25
|
-
import { createDispatch,
|
|
25
|
+
import { createDispatch, hasServiceAuth } from "./dispatch.js";
|
|
26
|
+
import { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath } from "./route-table.js";
|
|
26
27
|
import { createApprovalSweeps } from "./approval-sweeps.js";
|
|
27
28
|
export { routeLabel, isBillableSubmitPath, isCredentialGatedRewrite, isMethodDispatchedSubmitPath, hasServiceAuth };
|
|
28
29
|
export { MAX_SKILL_CONTENT_CHARS, MAX_SYSTEM_PROMPT_CHARS, MAX_OUTPUT_SCHEMA_CHARS, validateUserSkills };
|