@cortex-agent/server 2026.8.3-2 → 2026.8.6
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/defaults/config/thread-templates/agents/benchmark-coder.json +2 -2
- package/defaults/config/thread-templates/agents/benchmark-fixer.json +17 -0
- package/defaults/config/thread-templates/agents/benchmark-reviewer.json +5 -5
- package/defaults/config/thread-templates/templates/benchmark-coder-review-fix.json +21 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +1 -0
- package/defaults/prompts/directives/benchmark-coder.md +1 -0
- package/defaults/prompts/directives/benchmark-fixer.md +1 -0
- package/defaults/prompts/directives/benchmark-reviewer.md +1 -0
- package/defaults/prompts/systemPrompts/benchmark-coder.md +1 -0
- package/defaults/prompts/systemPrompts/benchmark-fixer.md +1 -0
- package/defaults/prompts/systemPrompts/benchmark-reviewer.md +1 -0
- package/dist/agent-adapter/capabilities.d.ts +32 -1
- package/dist/agent-adapter/capabilities.js +39 -1
- package/dist/agent-adapter/claude/adapter.d.ts +15 -0
- package/dist/agent-adapter/claude/adapter.js +29 -7
- package/dist/agent-adapter/claude/spawn-args.d.ts +5 -2
- package/dist/agent-adapter/claude/spawn-args.js +29 -6
- package/dist/agent-adapter/index.js +11 -1
- package/dist/agent-adapter/normalize/tool-names.d.ts +4 -0
- package/dist/agent-adapter/normalize/tool-names.js +10 -0
- package/dist/agent-adapter/pi/adapter.d.ts +20 -8
- package/dist/agent-adapter/pi/adapter.js +130 -35
- package/dist/agent-adapter/pi/agent-dir.d.ts +20 -53
- package/dist/agent-adapter/pi/agent-dir.js +48 -89
- package/dist/agent-adapter/pi/custom-catalog.d.ts +10 -0
- package/dist/agent-adapter/pi/custom-catalog.js +42 -0
- package/dist/agent-adapter/pi/defaults.d.ts +9 -0
- package/dist/agent-adapter/pi/defaults.js +14 -4
- package/dist/agent-adapter/pi/discovery.d.ts +1 -3
- package/dist/agent-adapter/pi/discovery.js +3 -15
- package/dist/agent-adapter/pi/event-parser.js +8 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +13 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +31 -6
- package/dist/agent-adapter/pi/mcp-duration.d.ts +28 -0
- package/dist/agent-adapter/pi/mcp-duration.js +48 -0
- package/dist/agent-adapter/pi/policy-guard.d.ts +40 -0
- package/dist/agent-adapter/pi/policy-guard.js +111 -0
- package/dist/agent-adapter/pi/providers-config.d.ts +62 -0
- package/dist/agent-adapter/pi/providers-config.js +101 -0
- package/dist/agent-adapter/pi/quota-probe.d.ts +11 -0
- package/dist/agent-adapter/pi/quota-probe.js +36 -0
- package/dist/agent-adapter/pi/quota-sink.d.ts +25 -0
- package/dist/agent-adapter/pi/quota-sink.js +31 -0
- package/dist/agent-adapter/pi/session-files.d.ts +2 -0
- package/dist/agent-adapter/pi/session-files.js +19 -0
- package/dist/agent-adapter/pi/session-support.d.ts +14 -3
- package/dist/agent-adapter/pi/session-support.js +8 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +11 -1
- package/dist/agent-adapter/pi/spawn-args.js +13 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -2
- package/dist/agent-adapter/pi/tool-shims.js +32 -21
- package/dist/agent-adapter/pi/web-search.js +36 -8
- package/dist/agent-adapter/types.d.ts +14 -0
- package/dist/core/locales/en.d.ts +54 -1
- package/dist/core/locales/en.js +2 -0
- package/dist/core/locales/slices/commands.d.ts +12 -1
- package/dist/core/locales/slices/commands.js +24 -2
- package/dist/core/locales/slices/providers.d.ts +45 -0
- package/dist/core/locales/slices/providers.js +95 -0
- package/dist/core/locales/zh.js +2 -0
- package/dist/core/resilient-watch.d.ts +28 -0
- package/dist/core/resilient-watch.js +110 -0
- package/dist/core/settings.js +15 -20
- package/dist/core/types/agent-types.d.ts +6 -0
- package/dist/core/types/thread-types.d.ts +21 -3
- package/dist/domain/agent-run/agent-run-cli.js +3 -1
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.d.ts +31 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.js +231 -24
- package/dist/domain/agent-run/benchmark-thread-identity.d.ts +15 -2
- package/dist/domain/agent-run/benchmark-thread-identity.js +123 -34
- package/dist/domain/agent-run/identity.d.ts +5 -0
- package/dist/domain/agent-run/identity.js +4 -1
- package/dist/domain/agent-run/journal.d.ts +3 -2
- package/dist/domain/agent-run/manifest.js +11 -4
- package/dist/domain/agent-run/pinned-node-process.d.ts +4 -0
- package/dist/domain/agent-run/pinned-node-process.js +9 -0
- package/dist/domain/agent-run/role-surface.d.ts +2 -2
- package/dist/domain/agent-run/role-surface.js +7 -3
- package/dist/domain/agent-run/run-config.d.ts +10 -1
- package/dist/domain/agent-run/run-config.js +57 -6
- package/dist/domain/agent-run/runner.js +149 -31
- package/dist/domain/agents/facade.d.ts +37 -122
- package/dist/domain/agents/facade.js +47 -115
- package/dist/domain/agents/spawn-config.d.ts +135 -0
- package/dist/domain/agents/spawn-config.js +121 -0
- package/dist/domain/benchmark/accounting-reconciliation.d.ts +98 -0
- package/dist/domain/benchmark/accounting-reconciliation.js +218 -0
- package/dist/domain/benchmark/arm-schema.d.ts +43 -0
- package/dist/domain/benchmark/arm-schema.js +243 -0
- package/dist/domain/benchmark/capabilities.d.ts +4 -0
- package/dist/domain/benchmark/capabilities.js +54 -0
- package/dist/domain/benchmark/decimal-text.d.ts +27 -0
- package/dist/domain/benchmark/decimal-text.js +67 -0
- package/dist/domain/benchmark/lease-echo.d.ts +43 -0
- package/dist/domain/benchmark/lease-echo.js +56 -0
- package/dist/domain/benchmark/policy-backed-runtime-deps.d.ts +14 -0
- package/dist/domain/benchmark/policy-backed-runtime-deps.js +47 -0
- package/dist/domain/benchmark/policy-compiler.d.ts +68 -0
- package/dist/domain/benchmark/policy-compiler.js +680 -0
- package/dist/domain/benchmark/resolved-policy.d.ts +110 -0
- package/dist/domain/benchmark/resolved-policy.js +195 -0
- package/dist/domain/benchmark/trial-adapter-factory.d.ts +38 -0
- package/dist/domain/benchmark/trial-adapter-factory.js +165 -0
- package/dist/domain/benchmark/trial-thread-adapter.d.ts +25 -0
- package/dist/domain/benchmark/trial-thread-adapter.js +106 -0
- package/dist/domain/benchmark/variant-proposal.d.ts +45 -0
- package/dist/domain/benchmark/variant-proposal.js +42 -0
- package/dist/domain/benchmark/workspace-lease.d.ts +99 -0
- package/dist/domain/benchmark/workspace-lease.js +272 -0
- package/dist/domain/costs/codex-quota.d.ts +29 -0
- package/dist/domain/costs/codex-quota.js +102 -0
- package/dist/domain/costs/cost-tracker.d.ts +48 -9
- package/dist/domain/costs/cost-tracker.js +74 -18
- package/dist/domain/costs/rate-limit-throttle.d.ts +23 -1
- package/dist/domain/costs/rate-limit-throttle.js +61 -6
- package/dist/domain/costs/resume-registry.d.ts +3 -1
- package/dist/domain/costs/resume-registry.js +10 -1
- package/dist/domain/mcp/tools/benchmark-thread-run.d.ts +26 -2
- package/dist/domain/mcp/tools/benchmark-thread-run.js +63 -20
- package/dist/domain/mcp/tools/cost.js +15 -6
- package/dist/domain/pi-providers/custom-provider-model.d.ts +53 -0
- package/dist/domain/pi-providers/custom-provider-model.js +122 -0
- package/dist/domain/pi-providers/custom-provider-service.d.ts +59 -0
- package/dist/domain/pi-providers/custom-provider-service.js +143 -0
- package/dist/domain/pi-providers/gateway-route-store.d.ts +23 -0
- package/dist/domain/pi-providers/gateway-route-store.js +78 -0
- package/dist/domain/pi-providers/index.d.ts +4 -0
- package/dist/domain/pi-providers/index.js +8 -0
- package/dist/domain/pi-providers/models-json-store.d.ts +6 -0
- package/dist/domain/pi-providers/models-json-store.js +77 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +4 -1
- package/dist/domain/scheduling/jobs/_shared.js +11 -2
- package/dist/domain/scheduling/jobs/scheduled-task.js +1 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +49 -54
- package/dist/domain/sessions/session-lifecycle.d.ts +22 -0
- package/dist/domain/sessions/session-lifecycle.js +20 -1
- package/dist/domain/system/system-notice.d.ts +4 -1
- package/dist/domain/system/system-notice.js +6 -2
- package/dist/domain/tasks/dispatch-utils.d.ts +0 -4
- package/dist/domain/tasks/dispatch-utils.js +24 -37
- package/dist/domain/threads/runner.d.ts +16 -1
- package/dist/domain/threads/runner.js +62 -8
- package/dist/domain/threads/template-loader.d.ts +5 -0
- package/dist/domain/threads/template-loader.js +120 -36
- package/dist/domain/threads/template-validate.d.ts +244 -0
- package/dist/domain/threads/template-validate.js +574 -0
- package/dist/domain/threads/template-validate.parity.d.ts +1 -0
- package/dist/domain/threads/template-validate.parity.js +47 -0
- package/dist/domain/threads/template-writer.d.ts +55 -0
- package/dist/domain/threads/template-writer.js +131 -0
- package/dist/domain/ui-service/app-router.d.ts +143 -1
- package/dist/domain/ui-service/app-router.js +29 -3
- package/dist/domain/ui-service/input-schemas.d.ts +228 -4
- package/dist/domain/ui-service/input-schemas.js +132 -1
- package/dist/domain/ui-service/mutate/config.d.ts +10 -1
- package/dist/domain/ui-service/mutate/config.js +45 -5
- package/dist/domain/ui-service/mutate/custom-providers.d.ts +8 -0
- package/dist/domain/ui-service/mutate/custom-providers.js +37 -0
- package/dist/domain/ui-service/mutate/profiles.d.ts +21 -0
- package/dist/domain/ui-service/mutate/profiles.js +156 -0
- package/dist/domain/ui-service/mutate/schedules.d.ts +2 -1
- package/dist/domain/ui-service/mutate/schedules.js +53 -3
- package/dist/domain/ui-service/mutate/sessions.d.ts +2 -1
- package/dist/domain/ui-service/mutate/sessions.js +25 -1
- package/dist/domain/ui-service/mutate/system.d.ts +2 -1
- package/dist/domain/ui-service/mutate/system.js +17 -3
- package/dist/domain/ui-service/mutate/thread-templates.d.ts +4 -0
- package/dist/domain/ui-service/mutate/thread-templates.js +71 -0
- package/dist/domain/ui-service/query/config.js +30 -0
- package/dist/domain/ui-service/query/custom-providers.d.ts +8 -0
- package/dist/domain/ui-service/query/custom-providers.js +13 -0
- package/dist/domain/ui-service/query/machine-detail.d.ts +2 -0
- package/dist/domain/ui-service/query/machine-detail.js +56 -0
- package/dist/domain/ui-service/query/machine-probe.d.ts +18 -0
- package/dist/domain/ui-service/query/machine-probe.js +136 -0
- package/dist/domain/ui-service/query/schedules.js +5 -0
- package/dist/domain/ui-service/query/sessions.js +8 -2
- package/dist/domain/ui-service/query/thread-template-detail.d.ts +8 -0
- package/dist/domain/ui-service/query/thread-template-detail.js +94 -0
- package/dist/domain/ui-service/query/thread-templates.d.ts +5 -3
- package/dist/domain/ui-service/query/thread-templates.js +44 -7
- package/dist/domain/ui-service/types.d.ts +298 -7
- package/dist/domain/ui-service/ui-service.js +27 -3
- package/dist/entry/app.js +24 -3
- package/dist/entry/auth-cli.d.ts +4 -1
- package/dist/entry/auth-cli.js +10 -2
- package/dist/entry/cli-help.js +6 -2
- package/dist/entry/cli.js +2 -1
- package/dist/entry/daemon.d.ts +0 -11
- package/dist/entry/daemon.js +5 -49
- package/dist/entry/provider-cli.d.ts +16 -0
- package/dist/entry/provider-cli.js +203 -0
- package/dist/events/event-types.d.ts +2 -1
- package/dist/orchestration/agent-runner.js +3 -2
- package/dist/orchestration/routing/commands/cost.d.ts +8 -0
- package/dist/orchestration/routing/commands/cost.js +93 -21
- package/dist/orchestration/routing/commands/login-custom.d.ts +26 -0
- package/dist/orchestration/routing/commands/login-custom.js +89 -0
- package/dist/orchestration/routing/commands/login.d.ts +3 -0
- package/dist/orchestration/routing/commands/login.js +7 -0
- package/dist/orchestration/routing/message-router.js +48 -33
- package/dist/orchestration/routing/webhook.js +1 -1
- package/dist/orchestration/session-events.d.ts +2 -1
- package/dist/orchestration/session-events.js +1 -0
- package/dist/orchestration/thread-callback.js +1 -1
- package/dist/store/conversation-history-repo.d.ts +5 -1
- package/dist/store/conversation-history-repo.js +2 -1
- package/dist/store/cost-repo.d.ts +17 -0
- package/dist/store/cost-repo.js +47 -5
- package/dist/store/profile-repo.d.ts +0 -10
- package/dist/store/profile-repo.js +34 -56
- package/dist/store/session-registry-repo.d.ts +12 -0
- package/dist/store/session-registry-repo.js +16 -0
- package/package.json +1 -1
- package/web/dist/assets/index-DYMfaAi4.css +1 -0
- package/web/dist/assets/index-uOoZjGKa.js +141 -0
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-XqBCYtkw.js +0 -139
- package/web/dist/assets/index-zpf3OSKC.css +0 -1
|
@@ -73,7 +73,11 @@ export declare const authStatusInput: z.ZodObject<{}, z.core.$strip>;
|
|
|
73
73
|
export declare const authFlowStateInput: z.ZodObject<{
|
|
74
74
|
flowId: z.ZodString;
|
|
75
75
|
}, z.core.$strip>;
|
|
76
|
+
export declare const authCustomProvidersInput: z.ZodObject<{}, z.core.$strip>;
|
|
76
77
|
export declare const machinesListInput: z.ZodObject<{}, z.core.$strip>;
|
|
78
|
+
export declare const machineDetailInput: z.ZodObject<{
|
|
79
|
+
machine: z.ZodString;
|
|
80
|
+
}, z.core.$strip>;
|
|
77
81
|
export declare const skillsListInput: z.ZodObject<{}, z.core.$strip>;
|
|
78
82
|
export declare const threadTemplatesGetInput: z.ZodObject<{}, z.core.$strip>;
|
|
79
83
|
export declare const systemDaemonStatusInput: z.ZodObject<{}, z.core.$strip>;
|
|
@@ -111,6 +115,28 @@ export declare const authLogoutInput: z.ZodObject<{
|
|
|
111
115
|
api_key: "api_key";
|
|
112
116
|
}>;
|
|
113
117
|
}, z.core.$strip>;
|
|
118
|
+
export declare const authUpsertCustomProviderInput: z.ZodObject<{
|
|
119
|
+
name: z.ZodString;
|
|
120
|
+
api: z.ZodEnum<{
|
|
121
|
+
"anthropic-messages": "anthropic-messages";
|
|
122
|
+
"openai-responses": "openai-responses";
|
|
123
|
+
"openai-completions": "openai-completions";
|
|
124
|
+
"google-generative-ai": "google-generative-ai";
|
|
125
|
+
}>;
|
|
126
|
+
upstreamUrl: z.ZodString;
|
|
127
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
128
|
+
models: z.ZodArray<z.ZodObject<{
|
|
129
|
+
id: z.ZodString;
|
|
130
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
131
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
reasoning: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
135
|
+
compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
export declare const authRemoveCustomProviderInput: z.ZodObject<{
|
|
138
|
+
name: z.ZodString;
|
|
139
|
+
}, z.core.$strip>;
|
|
114
140
|
export declare const projectsCreateInput: z.ZodObject<{
|
|
115
141
|
name: z.ZodString;
|
|
116
142
|
}, z.core.$strip>;
|
|
@@ -157,6 +183,9 @@ export declare const sessionsRespondPlanInput: z.ZodObject<{
|
|
|
157
183
|
approved: z.ZodBoolean;
|
|
158
184
|
feedback: z.ZodOptional<z.ZodString>;
|
|
159
185
|
}, z.core.$strip>;
|
|
186
|
+
export declare const sessionsCancelResumeInput: z.ZodObject<{
|
|
187
|
+
sessionId: z.ZodString;
|
|
188
|
+
}, z.core.$strip>;
|
|
160
189
|
export declare const sessionsRewindInput: z.ZodObject<{
|
|
161
190
|
sessionId: z.ZodString;
|
|
162
191
|
turnIndex: z.ZodNumber;
|
|
@@ -218,6 +247,15 @@ export declare const scheduleAddInput: z.ZodObject<{
|
|
|
218
247
|
wait: "wait";
|
|
219
248
|
}>>;
|
|
220
249
|
}, z.core.$strip>;
|
|
250
|
+
export declare const scheduleUpdateInput: z.ZodObject<{
|
|
251
|
+
scheduleId: z.ZodString;
|
|
252
|
+
message: z.ZodOptional<z.ZodString>;
|
|
253
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
254
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
255
|
+
intervalMs: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
time: z.ZodOptional<z.ZodString>;
|
|
257
|
+
dayOfWeek: z.ZodOptional<z.ZodNumber>;
|
|
258
|
+
}, z.core.$strip>;
|
|
221
259
|
export declare const taskActionInput: z.ZodObject<{
|
|
222
260
|
projectId: z.ZodString;
|
|
223
261
|
taskId: z.ZodString;
|
|
@@ -234,10 +272,11 @@ export declare const taskBlockInput: z.ZodObject<{
|
|
|
234
272
|
}, z.core.$strip>;
|
|
235
273
|
export declare const configSetInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
236
274
|
section: z.ZodLiteral<"budget">;
|
|
237
|
-
|
|
275
|
+
project: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
276
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
238
277
|
daily_usd: z.ZodNumber;
|
|
239
278
|
monthly_usd: z.ZodNumber;
|
|
240
|
-
}, z.core.$strip
|
|
279
|
+
}, z.core.$strip>>>;
|
|
241
280
|
}, z.core.$strip>, z.ZodObject<{
|
|
242
281
|
section: z.ZodLiteral<"profiles">;
|
|
243
282
|
value: z.ZodObject<{
|
|
@@ -322,6 +361,76 @@ export declare const hooksTestInput: z.ZodObject<{
|
|
|
322
361
|
id: z.ZodString;
|
|
323
362
|
payload: z.ZodString;
|
|
324
363
|
}, z.core.$strip>;
|
|
364
|
+
export declare const profilesCreateInput: z.ZodObject<{
|
|
365
|
+
model: z.ZodString;
|
|
366
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
367
|
+
claude: "claude";
|
|
368
|
+
pi: "pi";
|
|
369
|
+
}>>;
|
|
370
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
371
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
372
|
+
thinking: z.ZodOptional<z.ZodString>;
|
|
373
|
+
claudeBackend: z.ZodOptional<z.ZodEnum<{
|
|
374
|
+
print: "print";
|
|
375
|
+
tui: "tui";
|
|
376
|
+
}>>;
|
|
377
|
+
extraOption: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
378
|
+
name: z.ZodString;
|
|
379
|
+
}, z.core.$strip>;
|
|
380
|
+
export declare const profilesUpdateInput: z.ZodObject<{
|
|
381
|
+
model: z.ZodString;
|
|
382
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
383
|
+
claude: "claude";
|
|
384
|
+
pi: "pi";
|
|
385
|
+
}>>;
|
|
386
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
387
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
388
|
+
thinking: z.ZodOptional<z.ZodString>;
|
|
389
|
+
claudeBackend: z.ZodOptional<z.ZodEnum<{
|
|
390
|
+
print: "print";
|
|
391
|
+
tui: "tui";
|
|
392
|
+
}>>;
|
|
393
|
+
extraOption: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
394
|
+
name: z.ZodString;
|
|
395
|
+
}, z.core.$strip>;
|
|
396
|
+
export declare const profilesRemoveInput: z.ZodObject<{
|
|
397
|
+
name: z.ZodString;
|
|
398
|
+
}, z.core.$strip>;
|
|
399
|
+
export declare const threadTemplatesDetailInput: z.ZodObject<{
|
|
400
|
+
kind: z.ZodEnum<{
|
|
401
|
+
template: "template";
|
|
402
|
+
agent: "agent";
|
|
403
|
+
shell: "shell";
|
|
404
|
+
}>;
|
|
405
|
+
name: z.ZodString;
|
|
406
|
+
}, z.core.$strip>;
|
|
407
|
+
export declare const threadTemplatesValidateInput: z.ZodObject<{
|
|
408
|
+
kind: z.ZodEnum<{
|
|
409
|
+
template: "template";
|
|
410
|
+
agent: "agent";
|
|
411
|
+
shell: "shell";
|
|
412
|
+
}>;
|
|
413
|
+
name: z.ZodString;
|
|
414
|
+
body: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
415
|
+
}, z.core.$strip>;
|
|
416
|
+
export declare const threadTemplatesSaveInput: z.ZodObject<{
|
|
417
|
+
kind: z.ZodEnum<{
|
|
418
|
+
template: "template";
|
|
419
|
+
agent: "agent";
|
|
420
|
+
shell: "shell";
|
|
421
|
+
}>;
|
|
422
|
+
name: z.ZodString;
|
|
423
|
+
body: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
424
|
+
baseHash: z.ZodOptional<z.ZodString>;
|
|
425
|
+
}, z.core.$strip>;
|
|
426
|
+
export declare const threadTemplatesRemoveInput: z.ZodObject<{
|
|
427
|
+
kind: z.ZodEnum<{
|
|
428
|
+
template: "template";
|
|
429
|
+
agent: "agent";
|
|
430
|
+
shell: "shell";
|
|
431
|
+
}>;
|
|
432
|
+
name: z.ZodString;
|
|
433
|
+
}, z.core.$strip>;
|
|
325
434
|
export declare const approvalsApproveInput: z.ZodObject<{
|
|
326
435
|
id: z.ZodString;
|
|
327
436
|
}, z.core.$strip>;
|
|
@@ -361,6 +470,9 @@ export declare const systemRestartInput: z.ZodObject<{
|
|
|
361
470
|
hard: "hard";
|
|
362
471
|
}>;
|
|
363
472
|
}, z.core.$strip>;
|
|
473
|
+
export declare const systemClearRateLimitInput: z.ZodObject<{
|
|
474
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
475
|
+
}, z.core.$strip>;
|
|
364
476
|
export declare const approvalsRequestInput: z.ZodObject<{
|
|
365
477
|
kind: z.ZodEnum<{
|
|
366
478
|
"reconnect-platform": "reconnect-platform";
|
|
@@ -450,10 +562,22 @@ export declare const queryInputSchemas: {
|
|
|
450
562
|
'auth.flowState': z.ZodObject<{
|
|
451
563
|
flowId: z.ZodString;
|
|
452
564
|
}, z.core.$strip>;
|
|
565
|
+
'auth.customProviders': z.ZodObject<{}, z.core.$strip>;
|
|
453
566
|
'hooks.list': z.ZodObject<{}, z.core.$strip>;
|
|
454
567
|
'machines.list': z.ZodObject<{}, z.core.$strip>;
|
|
568
|
+
'machines.detail': z.ZodObject<{
|
|
569
|
+
machine: z.ZodString;
|
|
570
|
+
}, z.core.$strip>;
|
|
455
571
|
'skills.list': z.ZodObject<{}, z.core.$strip>;
|
|
456
572
|
'threadTemplates.get': z.ZodObject<{}, z.core.$strip>;
|
|
573
|
+
'threadTemplates.detail': z.ZodObject<{
|
|
574
|
+
kind: z.ZodEnum<{
|
|
575
|
+
template: "template";
|
|
576
|
+
agent: "agent";
|
|
577
|
+
shell: "shell";
|
|
578
|
+
}>;
|
|
579
|
+
name: z.ZodString;
|
|
580
|
+
}, z.core.$strip>;
|
|
457
581
|
'system.daemonStatus': z.ZodObject<{}, z.core.$strip>;
|
|
458
582
|
'system.rateLimitStatus': z.ZodObject<{}, z.core.$strip>;
|
|
459
583
|
};
|
|
@@ -518,6 +642,9 @@ export declare const mutateInputSchemas: {
|
|
|
518
642
|
approved: z.ZodBoolean;
|
|
519
643
|
feedback: z.ZodOptional<z.ZodString>;
|
|
520
644
|
}, z.core.$strip>;
|
|
645
|
+
'sessions.cancelResume': z.ZodObject<{
|
|
646
|
+
sessionId: z.ZodString;
|
|
647
|
+
}, z.core.$strip>;
|
|
521
648
|
'sessions.rewind': z.ZodObject<{
|
|
522
649
|
sessionId: z.ZodString;
|
|
523
650
|
turnIndex: z.ZodNumber;
|
|
@@ -568,6 +695,15 @@ export declare const mutateInputSchemas: {
|
|
|
568
695
|
wait: "wait";
|
|
569
696
|
}>>;
|
|
570
697
|
}, z.core.$strip>;
|
|
698
|
+
'schedules.update': z.ZodObject<{
|
|
699
|
+
scheduleId: z.ZodString;
|
|
700
|
+
message: z.ZodOptional<z.ZodString>;
|
|
701
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
702
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
703
|
+
intervalMs: z.ZodOptional<z.ZodNumber>;
|
|
704
|
+
time: z.ZodOptional<z.ZodString>;
|
|
705
|
+
dayOfWeek: z.ZodOptional<z.ZodNumber>;
|
|
706
|
+
}, z.core.$strip>;
|
|
571
707
|
'tasks.claim': z.ZodObject<{
|
|
572
708
|
projectId: z.ZodString;
|
|
573
709
|
taskId: z.ZodString;
|
|
@@ -639,10 +775,11 @@ export declare const mutateInputSchemas: {
|
|
|
639
775
|
}, z.core.$strip>;
|
|
640
776
|
'config.set': z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
641
777
|
section: z.ZodLiteral<"budget">;
|
|
642
|
-
|
|
778
|
+
project: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
779
|
+
value: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
643
780
|
daily_usd: z.ZodNumber;
|
|
644
781
|
monthly_usd: z.ZodNumber;
|
|
645
|
-
}, z.core.$strip
|
|
782
|
+
}, z.core.$strip>>>;
|
|
646
783
|
}, z.core.$strip>, z.ZodObject<{
|
|
647
784
|
section: z.ZodLiteral<"profiles">;
|
|
648
785
|
value: z.ZodObject<{
|
|
@@ -705,6 +842,28 @@ export declare const mutateInputSchemas: {
|
|
|
705
842
|
api_key: "api_key";
|
|
706
843
|
}>;
|
|
707
844
|
}, z.core.$strip>;
|
|
845
|
+
'auth.upsertCustomProvider': z.ZodObject<{
|
|
846
|
+
name: z.ZodString;
|
|
847
|
+
api: z.ZodEnum<{
|
|
848
|
+
"anthropic-messages": "anthropic-messages";
|
|
849
|
+
"openai-responses": "openai-responses";
|
|
850
|
+
"openai-completions": "openai-completions";
|
|
851
|
+
"google-generative-ai": "google-generative-ai";
|
|
852
|
+
}>;
|
|
853
|
+
upstreamUrl: z.ZodString;
|
|
854
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
855
|
+
models: z.ZodArray<z.ZodObject<{
|
|
856
|
+
id: z.ZodString;
|
|
857
|
+
contextWindow: z.ZodOptional<z.ZodNumber>;
|
|
858
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
|
859
|
+
reasoning: z.ZodOptional<z.ZodBoolean>;
|
|
860
|
+
}, z.core.$strip>>;
|
|
861
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
862
|
+
compat: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
863
|
+
}, z.core.$strip>;
|
|
864
|
+
'auth.removeCustomProvider': z.ZodObject<{
|
|
865
|
+
name: z.ZodString;
|
|
866
|
+
}, z.core.$strip>;
|
|
708
867
|
'hooks.create': z.ZodObject<{
|
|
709
868
|
event: z.ZodString;
|
|
710
869
|
matcher: z.ZodOptional<z.ZodString>;
|
|
@@ -756,6 +915,68 @@ export declare const mutateInputSchemas: {
|
|
|
756
915
|
id: z.ZodString;
|
|
757
916
|
payload: z.ZodString;
|
|
758
917
|
}, z.core.$strip>;
|
|
918
|
+
'profiles.create': z.ZodObject<{
|
|
919
|
+
model: z.ZodString;
|
|
920
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
921
|
+
claude: "claude";
|
|
922
|
+
pi: "pi";
|
|
923
|
+
}>>;
|
|
924
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
925
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
926
|
+
thinking: z.ZodOptional<z.ZodString>;
|
|
927
|
+
claudeBackend: z.ZodOptional<z.ZodEnum<{
|
|
928
|
+
print: "print";
|
|
929
|
+
tui: "tui";
|
|
930
|
+
}>>;
|
|
931
|
+
extraOption: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
932
|
+
name: z.ZodString;
|
|
933
|
+
}, z.core.$strip>;
|
|
934
|
+
'profiles.update': z.ZodObject<{
|
|
935
|
+
model: z.ZodString;
|
|
936
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
937
|
+
claude: "claude";
|
|
938
|
+
pi: "pi";
|
|
939
|
+
}>>;
|
|
940
|
+
mode: z.ZodOptional<z.ZodString>;
|
|
941
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
942
|
+
thinking: z.ZodOptional<z.ZodString>;
|
|
943
|
+
claudeBackend: z.ZodOptional<z.ZodEnum<{
|
|
944
|
+
print: "print";
|
|
945
|
+
tui: "tui";
|
|
946
|
+
}>>;
|
|
947
|
+
extraOption: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
948
|
+
name: z.ZodString;
|
|
949
|
+
}, z.core.$strip>;
|
|
950
|
+
'profiles.remove': z.ZodObject<{
|
|
951
|
+
name: z.ZodString;
|
|
952
|
+
}, z.core.$strip>;
|
|
953
|
+
'threadTemplates.validate': z.ZodObject<{
|
|
954
|
+
kind: z.ZodEnum<{
|
|
955
|
+
template: "template";
|
|
956
|
+
agent: "agent";
|
|
957
|
+
shell: "shell";
|
|
958
|
+
}>;
|
|
959
|
+
name: z.ZodString;
|
|
960
|
+
body: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
961
|
+
}, z.core.$strip>;
|
|
962
|
+
'threadTemplates.save': z.ZodObject<{
|
|
963
|
+
kind: z.ZodEnum<{
|
|
964
|
+
template: "template";
|
|
965
|
+
agent: "agent";
|
|
966
|
+
shell: "shell";
|
|
967
|
+
}>;
|
|
968
|
+
name: z.ZodString;
|
|
969
|
+
body: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
970
|
+
baseHash: z.ZodOptional<z.ZodString>;
|
|
971
|
+
}, z.core.$strip>;
|
|
972
|
+
'threadTemplates.remove': z.ZodObject<{
|
|
973
|
+
kind: z.ZodEnum<{
|
|
974
|
+
template: "template";
|
|
975
|
+
agent: "agent";
|
|
976
|
+
shell: "shell";
|
|
977
|
+
}>;
|
|
978
|
+
name: z.ZodString;
|
|
979
|
+
}, z.core.$strip>;
|
|
759
980
|
'system.restart': z.ZodObject<{
|
|
760
981
|
kind: z.ZodEnum<{
|
|
761
982
|
force: "force";
|
|
@@ -763,4 +984,7 @@ export declare const mutateInputSchemas: {
|
|
|
763
984
|
hard: "hard";
|
|
764
985
|
}>;
|
|
765
986
|
}, z.core.$strip>;
|
|
987
|
+
'system.clearRateLimit': z.ZodObject<{
|
|
988
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
989
|
+
}, z.core.$strip>;
|
|
766
990
|
};
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { SETTINGS_SPEC } from '../../core/settings-spec.js';
|
|
7
|
+
// Import the leaf model module, not the pi-providers barrel: this file is bundled for the browser
|
|
8
|
+
// through @cortex-agent/ui-contract, and that module is pure data with no imports of its own.
|
|
9
|
+
import { CUSTOM_PROVIDER_APIS, CUSTOM_PROVIDER_NAME_RE, } from '../pi-providers/custom-provider-model.js';
|
|
7
10
|
// ── Query input schemas ───────────────────────────────────────────
|
|
8
11
|
export const projectsListInput = z.object({});
|
|
9
12
|
export const sessionsListInput = z.object({
|
|
@@ -67,7 +70,11 @@ export const authStatusInput = z.object({});
|
|
|
67
70
|
export const authFlowStateInput = z.object({
|
|
68
71
|
flowId: z.string().min(1),
|
|
69
72
|
});
|
|
73
|
+
export const authCustomProvidersInput = z.object({});
|
|
70
74
|
export const machinesListInput = z.object({});
|
|
75
|
+
export const machineDetailInput = z.object({
|
|
76
|
+
machine: z.string().min(1),
|
|
77
|
+
});
|
|
71
78
|
export const skillsListInput = z.object({});
|
|
72
79
|
export const threadTemplatesGetInput = z.object({});
|
|
73
80
|
export const systemDaemonStatusInput = z.object({});
|
|
@@ -97,6 +104,29 @@ export const authLogoutInput = z.object({
|
|
|
97
104
|
provider: z.string().min(1),
|
|
98
105
|
authType: z.enum(['api_key', 'oauth']),
|
|
99
106
|
});
|
|
107
|
+
// ── auth.upsertCustomProvider / auth.removeCustomProvider ─────────
|
|
108
|
+
// Shape gate only. The SEMANTIC rules — reserved provider names, upstream scheme, duplicate model
|
|
109
|
+
// ids — stay with validateCustomProvider(), which every surface (Web, chat, CLI) runs, so the rule
|
|
110
|
+
// set has one home and one message table.
|
|
111
|
+
const customProviderName = z.string().min(1).regex(CUSTOM_PROVIDER_NAME_RE);
|
|
112
|
+
export const authUpsertCustomProviderInput = z.object({
|
|
113
|
+
name: customProviderName,
|
|
114
|
+
api: z.enum(CUSTOM_PROVIDER_APIS),
|
|
115
|
+
upstreamUrl: z.string().min(1),
|
|
116
|
+
/** Omitted keeps the stored upstream key; an empty string clears it. */
|
|
117
|
+
apiKey: z.string().optional(),
|
|
118
|
+
models: z.array(z.object({
|
|
119
|
+
id: z.string().min(1),
|
|
120
|
+
contextWindow: z.number().int().positive().optional(),
|
|
121
|
+
maxTokens: z.number().int().positive().optional(),
|
|
122
|
+
reasoning: z.boolean().optional(),
|
|
123
|
+
})).min(1),
|
|
124
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
125
|
+
compat: z.record(z.string(), z.unknown()).optional(),
|
|
126
|
+
});
|
|
127
|
+
export const authRemoveCustomProviderInput = z.object({
|
|
128
|
+
name: customProviderName,
|
|
129
|
+
});
|
|
100
130
|
// Presence/type guard only; deep name validation (traversal / reserved / separators) lives in
|
|
101
131
|
// ProjectStore.createProject so the rule has one source of truth.
|
|
102
132
|
export const projectsCreateInput = z.object({
|
|
@@ -141,6 +171,9 @@ export const sessionsRespondPlanInput = z.object({
|
|
|
141
171
|
approved: z.boolean(),
|
|
142
172
|
feedback: z.string().optional(),
|
|
143
173
|
});
|
|
174
|
+
export const sessionsCancelResumeInput = z.object({
|
|
175
|
+
sessionId: z.string(),
|
|
176
|
+
});
|
|
144
177
|
export const sessionsRewindInput = z.object({
|
|
145
178
|
sessionId: z.string(),
|
|
146
179
|
turnIndex: z.number().int().min(0),
|
|
@@ -204,6 +237,17 @@ export const scheduleAddInput = z
|
|
|
204
237
|
ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['delay'], message: 'delay is required for type=once' });
|
|
205
238
|
}
|
|
206
239
|
});
|
|
240
|
+
// schedules.update — a partial patch; per-type field-allowedness needs the persisted task, so it
|
|
241
|
+
// lives in the handler (handleUpdateSchedule), not here. Value shapes mirror scheduleAddInput.
|
|
242
|
+
export const scheduleUpdateInput = z.object({
|
|
243
|
+
scheduleId: z.string(),
|
|
244
|
+
message: z.string().min(1).optional(),
|
|
245
|
+
projectId: z.string().optional(),
|
|
246
|
+
profile: z.string().optional(),
|
|
247
|
+
intervalMs: z.number().int().positive().optional(),
|
|
248
|
+
time: z.string().regex(/^\d{2}:\d{2}$/).optional(),
|
|
249
|
+
dayOfWeek: z.number().int().min(0).max(6).optional(),
|
|
250
|
+
});
|
|
207
251
|
export const taskActionInput = z.object({
|
|
208
252
|
projectId: z.string(),
|
|
209
253
|
taskId: z.string(),
|
|
@@ -242,13 +286,29 @@ const settingsValueInput = z.object(settingsShape).partial().strict()
|
|
|
242
286
|
// config.set: a discriminated union of the safely-writable sections. `budget` numbers must be
|
|
243
287
|
// finite and positive; `profiles` selects an existing default; `settings` accepts only finite,
|
|
244
288
|
// spec-typed partial overrides. Any section or settings key outside this union is rejected.
|
|
289
|
+
//
|
|
290
|
+
// `budget` targets the global limits by default, or one project's override when `project` is given.
|
|
291
|
+
// Overrides are pair-only (both limits or neither), so `value` is never partial. An ABSENT (or
|
|
292
|
+
// null) `value` means "clear this project's override" — meaningless, and destructive-looking,
|
|
293
|
+
// without a `project`, so that combination is rejected. Both `project` and `value` accept null as
|
|
294
|
+
// well as undefined because the generated tRPC client types collapse nullable optionals to
|
|
295
|
+
// `undefined`, while direct in-process callers naturally pass null.
|
|
245
296
|
export const configSetInput = z.discriminatedUnion('section', [
|
|
246
297
|
z.object({
|
|
247
298
|
section: z.literal('budget'),
|
|
299
|
+
project: z.string().min(1).nullish(),
|
|
248
300
|
value: z.object({
|
|
249
301
|
daily_usd: z.number().finite().positive(),
|
|
250
302
|
monthly_usd: z.number().finite().positive(),
|
|
251
|
-
}),
|
|
303
|
+
}).nullish(),
|
|
304
|
+
}).superRefine((v, ctx) => {
|
|
305
|
+
if (v.value == null && !v.project) {
|
|
306
|
+
ctx.addIssue({
|
|
307
|
+
code: z.ZodIssueCode.custom,
|
|
308
|
+
path: ['value'],
|
|
309
|
+
message: 'a budget write without a value clears a per-project override and requires `project`',
|
|
310
|
+
});
|
|
311
|
+
}
|
|
252
312
|
}),
|
|
253
313
|
z.object({
|
|
254
314
|
section: z.literal('profiles'),
|
|
@@ -310,6 +370,59 @@ export const hooksTestInput = z.object({
|
|
|
310
370
|
id: z.string().min(1),
|
|
311
371
|
payload: z.string(),
|
|
312
372
|
});
|
|
373
|
+
// ── profiles.* ────────────────────────────────────────────────────
|
|
374
|
+
// CRUD over the `profiles` map of profiles.json. This schema is the SHAPE gate only (types, name
|
|
375
|
+
// charset, flag prefix); the SEMANTIC rules — pi requires a provider, thinking levels are
|
|
376
|
+
// backend-specific, defaultProfile must exist — stay with validateProfilesFile(), which the mutate
|
|
377
|
+
// handlers run over the assembled file so the server has exactly one profile validator.
|
|
378
|
+
// `extraEnv` and `fallback[]` are absent by construction: extraEnv values are secret-bearing (the
|
|
379
|
+
// read DTO returns keys only) and fallback is a nested chain with no editor. Both round-trip
|
|
380
|
+
// untouched through an update.
|
|
381
|
+
const profileSafeName = z.string().regex(/^[a-zA-Z0-9_-]+$/, 'may contain only letters, digits, - and _');
|
|
382
|
+
const profileDraftShape = {
|
|
383
|
+
model: z.string().min(1),
|
|
384
|
+
backend: z.enum(['claude', 'pi']).optional(),
|
|
385
|
+
mode: profileSafeName.optional(),
|
|
386
|
+
provider: profileSafeName.optional(),
|
|
387
|
+
thinking: z.string().min(1).optional(),
|
|
388
|
+
claudeBackend: z.enum(['print', 'tui']).optional(),
|
|
389
|
+
extraOption: z.record(z.string().startsWith('--'), z.string()).optional(),
|
|
390
|
+
};
|
|
391
|
+
export const profilesCreateInput = z.object({
|
|
392
|
+
name: profileSafeName.min(1),
|
|
393
|
+
...profileDraftShape,
|
|
394
|
+
});
|
|
395
|
+
export const profilesUpdateInput = z.object({
|
|
396
|
+
name: profileSafeName.min(1),
|
|
397
|
+
...profileDraftShape,
|
|
398
|
+
});
|
|
399
|
+
export const profilesRemoveInput = z.object({
|
|
400
|
+
name: profileSafeName.min(1),
|
|
401
|
+
});
|
|
402
|
+
// threadTemplates.detail / validate / save / remove — the thread-template editing surface.
|
|
403
|
+
// The name pattern mirrors template-writer's: the filename IS the entity identity, so anything
|
|
404
|
+
// that could escape the config directory is rejected before it reaches the writer.
|
|
405
|
+
const threadTemplateKind = z.enum(['template', 'agent', 'shell']);
|
|
406
|
+
const threadTemplateName = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]*$/);
|
|
407
|
+
export const threadTemplatesDetailInput = z.object({
|
|
408
|
+
kind: threadTemplateKind,
|
|
409
|
+
name: threadTemplateName,
|
|
410
|
+
});
|
|
411
|
+
export const threadTemplatesValidateInput = z.object({
|
|
412
|
+
kind: threadTemplateKind,
|
|
413
|
+
name: threadTemplateName,
|
|
414
|
+
body: z.record(z.string(), z.unknown()),
|
|
415
|
+
});
|
|
416
|
+
export const threadTemplatesSaveInput = z.object({
|
|
417
|
+
kind: threadTemplateKind,
|
|
418
|
+
name: threadTemplateName,
|
|
419
|
+
body: z.record(z.string(), z.unknown()),
|
|
420
|
+
baseHash: z.string().optional(),
|
|
421
|
+
});
|
|
422
|
+
export const threadTemplatesRemoveInput = z.object({
|
|
423
|
+
kind: threadTemplateKind,
|
|
424
|
+
name: threadTemplateName,
|
|
425
|
+
});
|
|
313
426
|
export const approvalsApproveInput = z.object({
|
|
314
427
|
id: z.string(),
|
|
315
428
|
});
|
|
@@ -349,6 +462,10 @@ export const approvalsRejectInput = z.object({
|
|
|
349
462
|
export const systemRestartInput = z.object({
|
|
350
463
|
kind: z.enum(['soft', 'hard', 'force']),
|
|
351
464
|
});
|
|
465
|
+
export const systemClearRateLimitInput = z.object({
|
|
466
|
+
/** Provider key to clear; omit to clear every throttled provider. */
|
|
467
|
+
provider: z.string().optional(),
|
|
468
|
+
});
|
|
352
469
|
export const approvalsRequestInput = z
|
|
353
470
|
.object({
|
|
354
471
|
kind: z.enum(['reconnect-platform', 'add-machine']),
|
|
@@ -385,10 +502,13 @@ export const queryInputSchemas = {
|
|
|
385
502
|
'config.get': configGetInput,
|
|
386
503
|
'auth.status': authStatusInput,
|
|
387
504
|
'auth.flowState': authFlowStateInput,
|
|
505
|
+
'auth.customProviders': authCustomProvidersInput,
|
|
388
506
|
'hooks.list': hooksListInput,
|
|
389
507
|
'machines.list': machinesListInput,
|
|
508
|
+
'machines.detail': machineDetailInput,
|
|
390
509
|
'skills.list': skillsListInput,
|
|
391
510
|
'threadTemplates.get': threadTemplatesGetInput,
|
|
511
|
+
'threadTemplates.detail': threadTemplatesDetailInput,
|
|
392
512
|
'system.daemonStatus': systemDaemonStatusInput,
|
|
393
513
|
'system.rateLimitStatus': systemRateLimitStatusInput,
|
|
394
514
|
};
|
|
@@ -403,6 +523,7 @@ export const mutateInputSchemas = {
|
|
|
403
523
|
'sessions.markRead': sessionsMarkReadInput,
|
|
404
524
|
'sessions.answerQuestion': sessionsAnswerQuestionInput,
|
|
405
525
|
'sessions.respondPlan': sessionsRespondPlanInput,
|
|
526
|
+
'sessions.cancelResume': sessionsCancelResumeInput,
|
|
406
527
|
'sessions.rewind': sessionsRewindInput,
|
|
407
528
|
'threads.cancel': threadsCancelInput,
|
|
408
529
|
'executions.cancel': executionsCancelInput,
|
|
@@ -410,6 +531,7 @@ export const mutateInputSchemas = {
|
|
|
410
531
|
'schedules.resume': scheduleActionInput,
|
|
411
532
|
'schedules.remove': scheduleActionInput,
|
|
412
533
|
'schedules.add': scheduleAddInput,
|
|
534
|
+
'schedules.update': scheduleUpdateInput,
|
|
413
535
|
'tasks.claim': taskActionInput,
|
|
414
536
|
'tasks.unclaim': taskActionInput,
|
|
415
537
|
'tasks.complete': taskCompleteInput,
|
|
@@ -430,10 +552,19 @@ export const mutateInputSchemas = {
|
|
|
430
552
|
'auth.respondPrompt': authRespondPromptInput,
|
|
431
553
|
'auth.cancelFlow': authCancelFlowInput,
|
|
432
554
|
'auth.logout': authLogoutInput,
|
|
555
|
+
'auth.upsertCustomProvider': authUpsertCustomProviderInput,
|
|
556
|
+
'auth.removeCustomProvider': authRemoveCustomProviderInput,
|
|
433
557
|
'hooks.create': hooksCreateInput,
|
|
434
558
|
'hooks.update': hooksUpdateInput,
|
|
435
559
|
'hooks.setEnabled': hooksSetEnabledInput,
|
|
436
560
|
'hooks.remove': hooksRemoveInput,
|
|
437
561
|
'hooks.test': hooksTestInput,
|
|
562
|
+
'profiles.create': profilesCreateInput,
|
|
563
|
+
'profiles.update': profilesUpdateInput,
|
|
564
|
+
'profiles.remove': profilesRemoveInput,
|
|
565
|
+
'threadTemplates.validate': threadTemplatesValidateInput,
|
|
566
|
+
'threadTemplates.save': threadTemplatesSaveInput,
|
|
567
|
+
'threadTemplates.remove': threadTemplatesRemoveInput,
|
|
438
568
|
'system.restart': systemRestartInput,
|
|
569
|
+
'system.clearRateLimit': systemClearRateLimitInput,
|
|
439
570
|
};
|
|
@@ -3,8 +3,17 @@ import type { UiServiceDeps, Result, ConfigSetArgs, ConfigSetReturn, BudgetValue
|
|
|
3
3
|
* Validate and atomically write budget.json into `configDir`. Pure over its dir argument
|
|
4
4
|
* (hermetically testable against a temp dir). Re-validates through the same zod schema the router
|
|
5
5
|
* uses, so a direct call (bypassing the router) cannot persist an illegal budget — it throws.
|
|
6
|
+
*
|
|
7
|
+
* READ-MODIFY-WRITE, not overwrite: budget.json carries the global limits AND a per-project
|
|
8
|
+
* override map, and each write targets exactly one of them. A global write preserves every
|
|
9
|
+
* override; a project write preserves the globals and the sibling overrides; an absent/null
|
|
10
|
+
* `value` (project form only) deletes that one override.
|
|
11
|
+
*
|
|
12
|
+
* Project ids are NOT checked for existence here — this function stays hermetic over `configDir`
|
|
13
|
+
* and has no project registry. The UI picks from a real project list, and the `!budget` command,
|
|
14
|
+
* where typos are likely, validates against projectStore before calling into the domain.
|
|
6
15
|
*/
|
|
7
|
-
export declare function writeBudget(configDir: string, value
|
|
16
|
+
export declare function writeBudget(configDir: string, value?: BudgetValue | null, project?: string | null): Promise<void>;
|
|
8
17
|
/**
|
|
9
18
|
* Re-point profiles.json `defaultProfile`, PRESERVING every other field. Pure over its dir
|
|
10
19
|
* argument. The target MUST already exist in the file's `profiles` map — the write can only SELECT
|
|
@@ -7,18 +7,55 @@ import fs from 'node:fs/promises';
|
|
|
7
7
|
import { CONFIG_DIR } from '../../../core/paths.js';
|
|
8
8
|
import { atomicWrite } from '../../../core/atomic-write.js';
|
|
9
9
|
import { updateSettings } from '../../../core/settings.js';
|
|
10
|
+
import { costRepo } from '../../../store/cost-repo.js';
|
|
10
11
|
import { configSetInput } from '../input-schemas.js';
|
|
11
12
|
/**
|
|
12
13
|
* Validate and atomically write budget.json into `configDir`. Pure over its dir argument
|
|
13
14
|
* (hermetically testable against a temp dir). Re-validates through the same zod schema the router
|
|
14
15
|
* uses, so a direct call (bypassing the router) cannot persist an illegal budget — it throws.
|
|
16
|
+
*
|
|
17
|
+
* READ-MODIFY-WRITE, not overwrite: budget.json carries the global limits AND a per-project
|
|
18
|
+
* override map, and each write targets exactly one of them. A global write preserves every
|
|
19
|
+
* override; a project write preserves the globals and the sibling overrides; an absent/null
|
|
20
|
+
* `value` (project form only) deletes that one override.
|
|
21
|
+
*
|
|
22
|
+
* Project ids are NOT checked for existence here — this function stays hermetic over `configDir`
|
|
23
|
+
* and has no project registry. The UI picks from a real project list, and the `!budget` command,
|
|
24
|
+
* where typos are likely, validates against projectStore before calling into the domain.
|
|
15
25
|
*/
|
|
16
|
-
export async function writeBudget(configDir, value) {
|
|
17
|
-
const parsed = configSetInput.parse({ section: 'budget', value });
|
|
26
|
+
export async function writeBudget(configDir, value, project) {
|
|
27
|
+
const parsed = configSetInput.parse({ section: 'budget', project: project ?? null, value });
|
|
18
28
|
if (parsed.section !== 'budget')
|
|
19
29
|
throw new Error('unreachable: budget branch');
|
|
20
|
-
const
|
|
21
|
-
|
|
30
|
+
const file = path.join(configDir, 'budget.json');
|
|
31
|
+
let current = {};
|
|
32
|
+
try {
|
|
33
|
+
const raw = JSON.parse(await fs.readFile(file, 'utf8'));
|
|
34
|
+
if (raw && typeof raw === 'object' && !Array.isArray(raw))
|
|
35
|
+
current = raw;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Missing or malformed budget.json — start from an empty object rather than fail the write.
|
|
39
|
+
}
|
|
40
|
+
const projects = current.projects && typeof current.projects === 'object' && !Array.isArray(current.projects)
|
|
41
|
+
? { ...current.projects }
|
|
42
|
+
: {};
|
|
43
|
+
let next;
|
|
44
|
+
if (parsed.project) {
|
|
45
|
+
if (parsed.value == null)
|
|
46
|
+
delete projects[parsed.project];
|
|
47
|
+
else
|
|
48
|
+
projects[parsed.project] = parsed.value;
|
|
49
|
+
next = { ...current, projects };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// The schema already rejects a missing value without a project.
|
|
53
|
+
next = { ...current, ...parsed.value, projects };
|
|
54
|
+
}
|
|
55
|
+
// `projects` is always emitted, even empty — the domain write path (costRepo, used by !budget)
|
|
56
|
+
// serialises the whole BudgetConfig and would do the same, and one consistent on-disk shape
|
|
57
|
+
// beats a file whose keys depend on which surface last wrote it.
|
|
58
|
+
await atomicWrite(file, JSON.stringify(next, null, 2) + '\n');
|
|
22
59
|
}
|
|
23
60
|
/**
|
|
24
61
|
* Re-point profiles.json `defaultProfile`, PRESERVING every other field. Pure over its dir
|
|
@@ -56,7 +93,10 @@ export async function handleConfigSet(_deps, args) {
|
|
|
56
93
|
}
|
|
57
94
|
try {
|
|
58
95
|
if (parsed.data.section === 'budget') {
|
|
59
|
-
await writeBudget(CONFIG_DIR, parsed.data.value);
|
|
96
|
+
await writeBudget(CONFIG_DIR, parsed.data.value, parsed.data.project);
|
|
97
|
+
// budget.json was written out-of-band (atomicWrite, not through costRepo), so the cached
|
|
98
|
+
// in-process budget must be dropped or the new limits would not apply until restart.
|
|
99
|
+
costRepo.invalidateBudget();
|
|
60
100
|
return { ok: true, data: { written: true, section: 'budget' } };
|
|
61
101
|
}
|
|
62
102
|
if (parsed.data.section === 'profiles') {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type CustomProviderView } from '../../pi-providers/index.js';
|
|
2
|
+
import type { AuthRemoveCustomProviderArgs, AuthRemoveCustomProviderReturn, AuthUpsertCustomProviderArgs, Result, UiServiceDeps } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create or edit a provider. `apiKey` is optional on purpose: leaving it out keeps the stored
|
|
5
|
+
* upstream secret, so an edit form need not ask the operator to retype a key it never displays.
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleCustomProviderUpsert(deps: UiServiceDeps, args: AuthUpsertCustomProviderArgs): Promise<Result<CustomProviderView>>;
|
|
8
|
+
export declare function handleCustomProviderRemove(deps: UiServiceDeps, args: AuthRemoveCustomProviderArgs): Promise<Result<AuthRemoveCustomProviderReturn>>;
|