@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
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// input: none (static message table slice)
|
|
2
|
+
// output: providersEn / providersZh — custom PI provider copy
|
|
3
|
+
// pos: L0 locale slice for user-defined provider management
|
|
4
|
+
// >>> If I am updated, add the same keys to both objects and update the parent CORTEX.md <<<
|
|
5
|
+
export const providersEn = {
|
|
6
|
+
// --- custom provider CLI ---
|
|
7
|
+
'provider.cli.description': 'Manage user-defined PI providers (self-hosted or proxied endpoints).',
|
|
8
|
+
'provider.cli.listDescription': 'List the providers you have defined',
|
|
9
|
+
'provider.cli.addDescription': 'Create or update a provider',
|
|
10
|
+
'provider.cli.removeDescription': 'Delete a provider and its gateway route',
|
|
11
|
+
'provider.cli.nameDescription': 'Provider name, letters, digits, dash and underscore only',
|
|
12
|
+
'provider.cli.apiDescription': 'Request protocol the endpoint speaks',
|
|
13
|
+
'provider.cli.urlDescription': 'Upstream endpoint URL, stored in the gateway route',
|
|
14
|
+
'provider.cli.keyDescription': 'Upstream API key, or - to read it from stdin',
|
|
15
|
+
'provider.cli.modelDescription': 'Model id offered by the endpoint, repeatable',
|
|
16
|
+
'provider.cli.jsonDescription': 'Print the result as JSON',
|
|
17
|
+
'provider.cli.dryRunDescription': 'Report what would be removed without removing it',
|
|
18
|
+
'provider.cli.helpDescription': 'Show this help',
|
|
19
|
+
'provider.cli.exampleAdd': 'Define a local endpoint that speaks the Anthropic protocol',
|
|
20
|
+
'provider.cli.exampleAddPiped': 'Define a provider whose key comes from a secret store',
|
|
21
|
+
'provider.cli.exampleList': 'Show every provider you have defined',
|
|
22
|
+
'provider.cli.exampleRemove': 'Preview a deletion before running it',
|
|
23
|
+
'provider.cli.unknownSubcommand': 'Unknown subcommand: `${command}`',
|
|
24
|
+
'provider.cli.unknownFlag': 'Unknown flag: `${flag}`',
|
|
25
|
+
'provider.cli.missingFlag': 'Missing required flag: `${flag}`',
|
|
26
|
+
'provider.cli.flagNeedsValue': 'Flag `${flag}` needs a value',
|
|
27
|
+
'provider.cli.notFound': 'No such custom provider: `${name}`',
|
|
28
|
+
'provider.cli.writeFailed': 'Could not write the provider files — see the server log for the reason.',
|
|
29
|
+
'provider.cli.validValues': 'Valid values:',
|
|
30
|
+
'provider.cli.hint': 'Hint:',
|
|
31
|
+
'provider.cli.listEmpty': 'No custom providers defined.',
|
|
32
|
+
'provider.cli.listItem': '${name} ${api} ${upstream}',
|
|
33
|
+
'provider.cli.listItemUnrouted': '${name} ${api} (no gateway route)',
|
|
34
|
+
'provider.cli.added': 'Saved provider `${name}` — routed through the gateway to ${upstream}.',
|
|
35
|
+
'provider.cli.removed': 'Removed provider `${name}`.',
|
|
36
|
+
// --- chat command (!login custom) ---
|
|
37
|
+
'provider.chat.usage': 'Usage: `!login custom [list | add <name> <api> <url> <model…> | remove <name>]`',
|
|
38
|
+
'provider.chat.keyNotice': 'An upstream key is never typed into a channel — add one with `cortex auth provider add --key -` or in Web settings.',
|
|
39
|
+
// --- validation issues, shared by every surface ---
|
|
40
|
+
'provider.issue.name-required': 'A provider name is required.',
|
|
41
|
+
'provider.issue.name-charset': 'A provider name may use letters, digits, dash and underscore only.',
|
|
42
|
+
'provider.issue.name-reserved': 'That name belongs to a built-in PI provider — pick another.',
|
|
43
|
+
'provider.issue.api-invalid': 'Unknown request protocol.',
|
|
44
|
+
'provider.issue.upstream-required': 'An upstream URL is required.',
|
|
45
|
+
'provider.issue.upstream-scheme': 'The upstream URL must start with http:// or https://.',
|
|
46
|
+
'provider.issue.models-required': 'Define at least one model id.',
|
|
47
|
+
'provider.issue.model-id-required': 'Every model needs an id.',
|
|
48
|
+
'provider.issue.model-id-duplicate': 'Model ids must be unique.',
|
|
49
|
+
'provider.issue.not-found': 'No such custom provider.',
|
|
50
|
+
'provider.issue.write-failed': 'Writing the provider files failed.',
|
|
51
|
+
};
|
|
52
|
+
export const providersZh = {
|
|
53
|
+
'provider.cli.description': '管理自定义 PI provider(自建或代理的推理端点)。',
|
|
54
|
+
'provider.cli.listDescription': '列出已定义的 provider',
|
|
55
|
+
'provider.cli.addDescription': '新建或更新一个 provider',
|
|
56
|
+
'provider.cli.removeDescription': '删除一个 provider 及其网关路由',
|
|
57
|
+
'provider.cli.nameDescription': 'provider 名称,仅限字母、数字、连字符和下划线',
|
|
58
|
+
'provider.cli.apiDescription': '端点使用的请求协议',
|
|
59
|
+
'provider.cli.urlDescription': '上游端点地址,保存在网关路由里',
|
|
60
|
+
'provider.cli.keyDescription': '上游 API key,填 - 表示从标准输入读取',
|
|
61
|
+
'provider.cli.modelDescription': '端点提供的模型 id,可重复',
|
|
62
|
+
'provider.cli.jsonDescription': '以 JSON 输出结果',
|
|
63
|
+
'provider.cli.dryRunDescription': '只显示会删除什么,不真的删除',
|
|
64
|
+
'provider.cli.helpDescription': '显示帮助',
|
|
65
|
+
'provider.cli.exampleAdd': '定义一个使用 Anthropic 协议的本地端点',
|
|
66
|
+
'provider.cli.exampleAddPiped': '定义一个从密钥库取 key 的 provider',
|
|
67
|
+
'provider.cli.exampleList': '查看已定义的全部 provider',
|
|
68
|
+
'provider.cli.exampleRemove': '删除前先预览',
|
|
69
|
+
'provider.cli.unknownSubcommand': '未知子命令:`${command}`',
|
|
70
|
+
'provider.cli.unknownFlag': '未知参数:`${flag}`',
|
|
71
|
+
'provider.cli.missingFlag': '缺少必填参数:`${flag}`',
|
|
72
|
+
'provider.cli.flagNeedsValue': '参数 `${flag}` 需要一个值',
|
|
73
|
+
'provider.cli.notFound': '没有这个自定义 provider:`${name}`',
|
|
74
|
+
'provider.cli.writeFailed': '写入 provider 配置失败——原因见服务端日志。',
|
|
75
|
+
'provider.cli.validValues': '可选值:',
|
|
76
|
+
'provider.cli.hint': '提示:',
|
|
77
|
+
'provider.cli.listEmpty': '尚未定义任何自定义 provider。',
|
|
78
|
+
'provider.cli.listItem': '${name} ${api} ${upstream}',
|
|
79
|
+
'provider.cli.listItemUnrouted': '${name} ${api} (没有网关路由)',
|
|
80
|
+
'provider.cli.added': '已保存 provider `${name}`——经网关路由到 ${upstream}。',
|
|
81
|
+
'provider.cli.removed': '已删除 provider `${name}`。',
|
|
82
|
+
'provider.chat.usage': '用法:`!login custom [list | add <名称> <协议> <地址> <模型…> | remove <名称>]`',
|
|
83
|
+
'provider.chat.keyNotice': '上游密钥不要打进聊天——请用 `cortex auth provider add --key -` 或 Web 设置页添加。',
|
|
84
|
+
'provider.issue.name-required': '必须填写 provider 名称。',
|
|
85
|
+
'provider.issue.name-charset': 'provider 名称只能使用字母、数字、连字符和下划线。',
|
|
86
|
+
'provider.issue.name-reserved': '这个名字属于 PI 内置 provider,请换一个。',
|
|
87
|
+
'provider.issue.api-invalid': '未知的请求协议。',
|
|
88
|
+
'provider.issue.upstream-required': '必须填写上游地址。',
|
|
89
|
+
'provider.issue.upstream-scheme': '上游地址必须以 http:// 或 https:// 开头。',
|
|
90
|
+
'provider.issue.models-required': '至少定义一个模型 id。',
|
|
91
|
+
'provider.issue.model-id-required': '每个模型都需要 id。',
|
|
92
|
+
'provider.issue.model-id-duplicate': '模型 id 不能重复。',
|
|
93
|
+
'provider.issue.not-found': '没有这个自定义 provider。',
|
|
94
|
+
'provider.issue.write-failed': '写入 provider 配置失败。',
|
|
95
|
+
};
|
package/dist/core/locales/zh.js
CHANGED
|
@@ -9,6 +9,7 @@ import { schedulingZh } from './slices/scheduling.js';
|
|
|
9
9
|
import { interactionsZh } from './slices/interactions.js';
|
|
10
10
|
import { startupZh } from './slices/startup.js';
|
|
11
11
|
import { initZh } from './slices/init.js';
|
|
12
|
+
import { providersZh } from './slices/providers.js';
|
|
12
13
|
/** Simplified-Chinese translations, aggregated from per-cluster slices. Must provide every
|
|
13
14
|
* MessageKey (compiler-enforced via Record<MessageKey,string>) and add none. ${param}
|
|
14
15
|
* placeholders and `code`/*bold* markdown are preserved verbatim from the en slices. */
|
|
@@ -20,4 +21,5 @@ export const zh = {
|
|
|
20
21
|
...interactionsZh,
|
|
21
22
|
...startupZh,
|
|
22
23
|
...initZh,
|
|
24
|
+
...providersZh,
|
|
23
25
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type FSWatcher } from 'node:fs';
|
|
2
|
+
export declare const WATCH_FALLBACK_MS = 5000;
|
|
3
|
+
export interface WatchMonitor {
|
|
4
|
+
close(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface ResilientWatchOptions {
|
|
7
|
+
label: string;
|
|
8
|
+
startWatching: () => FSWatcher[];
|
|
9
|
+
poll?: () => void;
|
|
10
|
+
warn?: (message: string) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface SnapshotWatchOptions {
|
|
13
|
+
label: string;
|
|
14
|
+
snapshot: () => string | null;
|
|
15
|
+
startWatching: (onChange: () => void) => FSWatcher[];
|
|
16
|
+
onChange: () => void;
|
|
17
|
+
warn?: (message: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface FileWatchOptions {
|
|
20
|
+
label: string;
|
|
21
|
+
filePath: string;
|
|
22
|
+
onChange: () => void;
|
|
23
|
+
warn?: (message: string) => void;
|
|
24
|
+
unref?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function createResilientWatchMonitor(options: ResilientWatchOptions): WatchMonitor;
|
|
27
|
+
export declare function createSnapshotWatchMonitor(options: SnapshotWatchOptions): WatchMonitor;
|
|
28
|
+
export declare function createFileWatchMonitor(options: FileWatchOptions): WatchMonitor;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// input: fs.watch factories and filesystem snapshots
|
|
2
|
+
// output: watcher monitors with polling fallback and cleanup
|
|
3
|
+
// pos: Shared resilient filesystem watch lifecycle
|
|
4
|
+
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
|
+
import { readFileSync, watch } from 'node:fs';
|
|
6
|
+
import { createHash } from 'node:crypto';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
export const WATCH_FALLBACK_MS = 5_000;
|
|
9
|
+
function formatWatchError(error) {
|
|
10
|
+
if (!(error instanceof Error))
|
|
11
|
+
return String(error);
|
|
12
|
+
const code = error.code;
|
|
13
|
+
return code ? `${code}: ${error.message}` : error.message;
|
|
14
|
+
}
|
|
15
|
+
function closeWatchers(watchers) {
|
|
16
|
+
for (const watcher of watchers.splice(0)) {
|
|
17
|
+
try {
|
|
18
|
+
watcher.close();
|
|
19
|
+
}
|
|
20
|
+
catch { }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function pollSafely(options, warn) {
|
|
24
|
+
try {
|
|
25
|
+
options.poll?.();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
warn(`${options.label} polling failed (${formatWatchError(error)})`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function startPolling(state, options, warn) {
|
|
32
|
+
state.pollTimer = setInterval(() => pollSafely(options, warn), WATCH_FALLBACK_MS);
|
|
33
|
+
state.pollTimer.unref?.();
|
|
34
|
+
}
|
|
35
|
+
function failWatchMonitor(state, options, warn, error) {
|
|
36
|
+
if (state.failed || state.closed)
|
|
37
|
+
return;
|
|
38
|
+
state.failed = true;
|
|
39
|
+
closeWatchers(state.watchers);
|
|
40
|
+
const detail = formatWatchError(error);
|
|
41
|
+
if (!options.poll)
|
|
42
|
+
return warn(`${options.label} watcher failed (${detail}); watcher disabled`);
|
|
43
|
+
warn(`${options.label} watcher failed (${detail}); polling every ${WATCH_FALLBACK_MS}ms`);
|
|
44
|
+
startPolling(state, options, warn);
|
|
45
|
+
}
|
|
46
|
+
function closeWatchMonitor(state) {
|
|
47
|
+
state.closed = true;
|
|
48
|
+
closeWatchers(state.watchers);
|
|
49
|
+
if (state.pollTimer)
|
|
50
|
+
clearInterval(state.pollTimer);
|
|
51
|
+
state.pollTimer = null;
|
|
52
|
+
}
|
|
53
|
+
export function createResilientWatchMonitor(options) {
|
|
54
|
+
const state = { watchers: [], pollTimer: null, failed: false, closed: false };
|
|
55
|
+
const warn = options.warn ?? console.warn;
|
|
56
|
+
const fallBack = (error) => failWatchMonitor(state, options, warn, error);
|
|
57
|
+
try {
|
|
58
|
+
state.watchers = options.startWatching();
|
|
59
|
+
for (const watcher of state.watchers)
|
|
60
|
+
watcher.on('error', fallBack);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
fallBack(error);
|
|
64
|
+
}
|
|
65
|
+
return { close: () => closeWatchMonitor(state) };
|
|
66
|
+
}
|
|
67
|
+
export function createSnapshotWatchMonitor(options) {
|
|
68
|
+
let observedSnapshot = options.snapshot();
|
|
69
|
+
const reconcile = () => {
|
|
70
|
+
const nextSnapshot = options.snapshot();
|
|
71
|
+
if (nextSnapshot === observedSnapshot)
|
|
72
|
+
return;
|
|
73
|
+
observedSnapshot = nextSnapshot;
|
|
74
|
+
options.onChange();
|
|
75
|
+
};
|
|
76
|
+
const monitor = createResilientWatchMonitor({
|
|
77
|
+
label: options.label,
|
|
78
|
+
startWatching: () => options.startWatching(reconcile),
|
|
79
|
+
poll: reconcile,
|
|
80
|
+
warn: options.warn,
|
|
81
|
+
});
|
|
82
|
+
reconcile();
|
|
83
|
+
return monitor;
|
|
84
|
+
}
|
|
85
|
+
function fileStamp(filePath) {
|
|
86
|
+
try {
|
|
87
|
+
return createHash('sha256').update(readFileSync(filePath)).digest('hex');
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export function createFileWatchMonitor(options) {
|
|
94
|
+
const filename = path.basename(options.filePath);
|
|
95
|
+
return createSnapshotWatchMonitor({
|
|
96
|
+
label: options.label,
|
|
97
|
+
snapshot: () => fileStamp(options.filePath),
|
|
98
|
+
onChange: options.onChange,
|
|
99
|
+
warn: options.warn,
|
|
100
|
+
startWatching: (onChange) => {
|
|
101
|
+
const watcher = watch(path.dirname(options.filePath), (_event, changed) => {
|
|
102
|
+
if (changed === null || changed.toString() === filename)
|
|
103
|
+
onChange();
|
|
104
|
+
});
|
|
105
|
+
if (options.unref)
|
|
106
|
+
watcher.unref();
|
|
107
|
+
return [watcher];
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
package/dist/core/settings.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
// input: CONFIG_DIR, settings spec,
|
|
2
|
-
// output: validated settings, disk updates,
|
|
3
|
-
// pos:
|
|
1
|
+
// input: CONFIG_DIR, settings spec, env, resilient file monitor
|
|
2
|
+
// output: validated settings, disk updates, hot reload, test reset
|
|
3
|
+
// pos: File-backed runtime settings boundary
|
|
4
4
|
// >>> 一旦我被更新,务必更新我的开头注释与所属文件夹 CORTEX.md <<<
|
|
5
|
-
import { readFileSync
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { AsyncMutex } from './async-mutex.js';
|
|
8
8
|
import { atomicWrite } from './atomic-write.js';
|
|
9
9
|
import { createLogger } from './log.js';
|
|
10
10
|
import { CONFIG_DIR } from './paths.js';
|
|
11
|
+
import { createFileWatchMonitor } from './resilient-watch.js';
|
|
11
12
|
import { SETTINGS_SPEC, } from './settings-spec.js';
|
|
12
13
|
export { SETTINGS_SPEC, } from './settings-spec.js';
|
|
13
14
|
const log = createLogger('settings');
|
|
@@ -21,7 +22,7 @@ let initialized = false;
|
|
|
21
22
|
let cachedOverrides = {};
|
|
22
23
|
let cachedSettings = null;
|
|
23
24
|
let cachedSettingsSnapshot = null;
|
|
24
|
-
let
|
|
25
|
+
let settingsMonitor = null;
|
|
25
26
|
let reloadTimer = null;
|
|
26
27
|
let selfWriting = false;
|
|
27
28
|
const typeValidators = {
|
|
@@ -153,20 +154,14 @@ function reloadSettings() {
|
|
|
153
154
|
log.error(`Hot-reload settings.json failed: ${error.message} — keeping previous settings`);
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
|
-
function handleWatchEvent(filename) {
|
|
157
|
-
if (filename !== null && filename.toString() !== 'settings.json')
|
|
158
|
-
return;
|
|
159
|
-
scheduleReload();
|
|
160
|
-
}
|
|
161
157
|
function startWatcher() {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
}
|
|
158
|
+
settingsMonitor = createFileWatchMonitor({
|
|
159
|
+
label: 'settings.json',
|
|
160
|
+
filePath: SETTINGS_FILE,
|
|
161
|
+
onChange: scheduleReload,
|
|
162
|
+
warn: (message) => log.error(message),
|
|
163
|
+
unref: true,
|
|
164
|
+
});
|
|
170
165
|
}
|
|
171
166
|
function initialize() {
|
|
172
167
|
if (initialized)
|
|
@@ -186,8 +181,8 @@ export function resetSettingsForTests() {
|
|
|
186
181
|
if (reloadTimer)
|
|
187
182
|
clearTimeout(reloadTimer);
|
|
188
183
|
reloadTimer = null;
|
|
189
|
-
|
|
190
|
-
|
|
184
|
+
settingsMonitor?.close();
|
|
185
|
+
settingsMonitor = null;
|
|
191
186
|
initialized = false;
|
|
192
187
|
cachedOverrides = {};
|
|
193
188
|
cachedSettings = null;
|
|
@@ -6,6 +6,12 @@ export interface AuthNoticeAction {
|
|
|
6
6
|
provider: string;
|
|
7
7
|
authType: 'oauth' | 'api_key';
|
|
8
8
|
}
|
|
9
|
+
/** A control the user can act on from a chat notice. Unlike AuthNoticeAction (an ephemeral
|
|
10
|
+
* live-tail hint) this is persisted with the message: the window it refers to can outlive a
|
|
11
|
+
* page reload by hours. */
|
|
12
|
+
export interface NoticeAction {
|
|
13
|
+
kind: 'cancel-resume';
|
|
14
|
+
}
|
|
9
15
|
/** Backend-neutral snapshot of the tokens currently occupying an agent's context window. */
|
|
10
16
|
export interface ContextUsage {
|
|
11
17
|
usedTokens: number | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NormalizedEvent } from '../../agent-adapter/normalize/event-types.js';
|
|
2
|
-
import type { AgentProcessSpawner, McpComposition } from '../../agent-adapter/types.js';
|
|
2
|
+
import type { AgentProcessSpawner, Backend, McpComposition } from '../../agent-adapter/types.js';
|
|
3
3
|
export type ThreadId = string;
|
|
4
4
|
export type AgentSlotId = string;
|
|
5
5
|
export type ThreadStatus = 'running' | 'waiting' | 'rate_limited' | 'completed' | 'failed' | 'cancelled' | 'aborted';
|
|
@@ -404,17 +404,35 @@ export interface BenchmarkThreadEvent {
|
|
|
404
404
|
event: NormalizedEvent;
|
|
405
405
|
}
|
|
406
406
|
export interface BenchmarkThreadRunOptions {
|
|
407
|
-
/** Absolute grader workspace
|
|
407
|
+
/** Absolute shared writable grader workspace. It is the default cwd of a benchmark step's
|
|
408
|
+
* backend process, and the cwd of every step unless `resolveStepWorkspace` places that step
|
|
409
|
+
* somewhere else. */
|
|
408
410
|
workspaceCwd: string;
|
|
409
411
|
/** Frozen trial profile; benchmark templates cannot select a different identity. */
|
|
410
412
|
resolvedProfileName: string;
|
|
411
|
-
|
|
413
|
+
/** The backend the trial's compiled arm declares. A step whose profile disagrees is a protocol
|
|
414
|
+
* violation, not a fallback. */
|
|
415
|
+
expectedBackend: Backend;
|
|
412
416
|
expectedModel: string;
|
|
413
417
|
disableHooks: true;
|
|
414
418
|
disableControlPlane: true;
|
|
415
419
|
failFastOnRateLimit: true;
|
|
416
420
|
/** Optional containment-aware process boundary forwarded to every step. */
|
|
417
421
|
spawner?: AgentProcessSpawner;
|
|
422
|
+
/** Per-step workspace placement: returns the cwd this step's backend process must run in.
|
|
423
|
+
* Absent → every step runs in `workspaceCwd`. */
|
|
424
|
+
resolveStepWorkspace?: (input: {
|
|
425
|
+
agentSlotId: AgentSlotId;
|
|
426
|
+
stepIndex: number;
|
|
427
|
+
}) => string;
|
|
428
|
+
/** Step-boundary settlement of whatever `resolveStepWorkspace` placed: invoked once per step
|
|
429
|
+
* after its process exited and before the next transition is evaluated, on the error path too. */
|
|
430
|
+
settleStepWorkspace?: (input: {
|
|
431
|
+
agentSlotId: AgentSlotId;
|
|
432
|
+
stepIndex: number;
|
|
433
|
+
stage: string | null;
|
|
434
|
+
terminalText: string | null;
|
|
435
|
+
}) => void;
|
|
418
436
|
/** Required trajectory sink invoked synchronously for every normalized event. */
|
|
419
437
|
requiredEventSink?: (input: BenchmarkThreadEvent) => void;
|
|
420
438
|
limits?: {
|
|
@@ -7,7 +7,9 @@ import path from 'node:path';
|
|
|
7
7
|
import { formatError, formatHelp } from '../../core/cli-utils.js';
|
|
8
8
|
import { runOneShotAgent } from './runner.js';
|
|
9
9
|
import { resolveSupervisorBinary } from './supervisor.js';
|
|
10
|
-
const AGENT_SLOTS = [
|
|
10
|
+
const AGENT_SLOTS = [
|
|
11
|
+
'parent', 'benchmark-coder', 'benchmark-reviewer', 'benchmark-fixer',
|
|
12
|
+
];
|
|
11
13
|
const OUTPUT_FORMATS = ['jsonl'];
|
|
12
14
|
const ROOT_RUN_ID_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
13
15
|
const VALUE_FLAGS = new Set([
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { ResolvedTrialPolicy } from '../benchmark/resolved-policy.js';
|
|
2
|
+
import { type ProposalIntent } from '../benchmark/variant-proposal.js';
|
|
3
|
+
import type { TrialThreadAdapterInput } from '../benchmark/trial-thread-adapter.js';
|
|
4
|
+
import { type CoderReviewVariant } from '../benchmark/workspace-lease.js';
|
|
1
5
|
import { type LocalThreadRuntimeDeps } from '../threads/local-runtime-deps.js';
|
|
2
6
|
interface BenchmarkThreadRequest {
|
|
3
7
|
workspaceCwd: string;
|
|
@@ -7,6 +11,19 @@ interface BenchmarkThreadRequest {
|
|
|
7
11
|
profileName: string;
|
|
8
12
|
rootRunId: string;
|
|
9
13
|
trajectoryRoot: string;
|
|
14
|
+
/** Absolute container path of the arm-resolution document the parent's `agent-run` was given.
|
|
15
|
+
* The production route always carries it — the `/2` thread-policy document makes it structurally
|
|
16
|
+
* required at the producer — and it is the single input the whole trial-adapter route is derived
|
|
17
|
+
* from. It stays optional here for the same reason `trialRoot` does: the requirement belongs at
|
|
18
|
+
* the producer, and enforcing it here would refuse the shipped policy-supplied route.
|
|
19
|
+
* Design section 16 (16.3.2) PW1 / PW1-PLACE. */
|
|
20
|
+
runConfigPath?: string;
|
|
21
|
+
/** Absolute trial root. Required for a variant that places a role in a disposable snapshot. */
|
|
22
|
+
trialRoot?: string;
|
|
23
|
+
/** Fixes each role's workspace placement. Absent → every step runs in the shared workspace. */
|
|
24
|
+
coderReviewVariant?: CoderReviewVariant;
|
|
25
|
+
/** The frozen trial policy this thread runs under. Absent → the shipped single-backend path. */
|
|
26
|
+
trialPolicy?: ResolvedTrialPolicy;
|
|
10
27
|
limits: {
|
|
11
28
|
maxSteps: number;
|
|
12
29
|
maxCostUsd: number;
|
|
@@ -27,6 +44,20 @@ export interface BenchmarkThreadResult {
|
|
|
27
44
|
costUsd: number;
|
|
28
45
|
durationMs: number;
|
|
29
46
|
summary: string;
|
|
47
|
+
/** What this pipeline concluded, decided and never applied. Null for a run that declares no
|
|
48
|
+
* coder-review variant and therefore has no verdict-speaking role. */
|
|
49
|
+
proposal: ProposalIntent | null;
|
|
30
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Everything the per-step trial adapter needs, derived from the two paths the request carries and
|
|
53
|
+
* from nothing else: the compiled policy and the resolved run config from ONE call of the shipped
|
|
54
|
+
* loader over the arm-resolution document, the pinned trial paths from the trial root, and the
|
|
55
|
+
* supervisor from the shipped resolver. The policy is RE-COMPILED here, in the process that will
|
|
56
|
+
* run the thread, rather than transported — which is what makes the parent role-hash equality a
|
|
57
|
+
* comparison of two independent compiles instead of a tautology. A request that carried a
|
|
58
|
+
* pre-built `ResolvedAgentRunConfig`, `PinnedTrialPaths` or supervisor descriptor would let a
|
|
59
|
+
* caller supply what production must derive. Design section 16 (16.3.2) PW1 and PW2.
|
|
60
|
+
*/
|
|
61
|
+
export declare function trialThreadAdapterInput(runConfigPath: string, trialRoot: string): TrialThreadAdapterInput;
|
|
31
62
|
export declare function runBenchmarkThread(request: BenchmarkThreadRequest, overrides?: Partial<LocalThreadRuntimeDeps>): Promise<BenchmarkThreadResult>;
|
|
32
63
|
export {};
|