evolcore 0.0.40 → 0.0.41-test.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -1
- package/bin/codex-managed-hook.mjs +11 -0
- package/bin/ec-safe-output.js +11 -1
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +20 -43
- package/dist/agents/claude-runner.js +197 -197
- package/dist/agents/codex-runner.js +535 -259
- package/dist/agents/ecagent-runner.js +31 -12
- package/dist/agents/gemini-runner.js +27 -7
- package/dist/agents/runner-types.js +11 -3
- package/dist/aun/ability-device-routing.js +26 -0
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -13
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/msg/managed-operation.js +72 -11
- package/dist/aun/msg/p2p.js +32 -7
- package/dist/aun/service-proxy.js +36 -12
- package/dist/aun/storage/download.js +30 -0
- package/dist/aun/storage/index.js +14 -6
- package/dist/channels/aun.js +367 -24
- package/dist/channels/daemon.js +39 -5
- package/dist/cli/agent-command.js +2 -0
- package/dist/cli/agent-create.js +98 -19
- package/dist/cli/agent.js +10 -3
- package/dist/cli/aun-commands.js +85 -41
- package/dist/cli/daemon-commands.js +678 -688
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +48 -4
- package/dist/cli/managed-command-guard.js +4 -0
- package/dist/cli/model.js +40 -40
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +17 -0
- package/dist/cli/role.js +85 -0
- package/dist/cli/session-command.js +128 -13
- package/dist/cli/stats.js +60 -4
- package/dist/cli/trigger-command.js +2 -2
- package/dist/config/access-policy.js +8 -1
- package/dist/config/boot-log.js +38 -1
- package/dist/config/config-field-policy.js +5 -32
- package/dist/config/config-manager.js +46 -39
- package/dist/config/config-operation-service.js +8 -11
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +89 -595
- package/dist/config/peer-role-resolver.js +15 -11
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/resolved-config-op.js +3 -0
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +686 -25
- package/dist/config-store.js +79 -3
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +3 -1
- package/dist/core/agent-application-service.js +11 -1
- package/dist/core/agent-ipc-registration.js +4 -0
- package/dist/core/agent-runtime.js +1 -1
- package/dist/core/auth/agent-delegation.js +82 -6
- package/dist/core/auth/auth-gateway.js +1 -1
- package/dist/core/auth/authorization-audit.js +37 -9
- package/dist/core/auth/delegation-authorization.js +3 -1
- package/dist/core/auth/operation-authorizer.js +15 -0
- package/dist/core/auth/operation-catalog.js +39 -6
- package/dist/core/command/agent-control.js +94 -19
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +2 -1
- package/dist/core/command/command-handler.js +105 -145
- package/dist/core/command/connect-menu.js +31 -2
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +6 -6
- package/dist/core/command/menu-handler.js +87 -163
- package/dist/core/command/menu-protocol.js +9 -2
- package/dist/core/command/role-menu.js +148 -30
- package/dist/core/command/slash-gate.js +13 -10
- package/dist/core/command/slash-handler.js +157 -352
- package/dist/core/daemon-control.js +8 -14
- package/dist/core/event-catalog.js +15 -0
- package/dist/core/evolagent-registry.js +4 -4
- package/dist/core/evolagent.js +2 -2
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/ipc-registration.js +24 -3
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +1 -1
- package/dist/core/memory/consolidation-trigger.js +190 -190
- package/dist/core/memory/consolidation.js +316 -29
- package/dist/core/memory/forget-log.js +96 -0
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +44 -39
- package/dist/core/message/aun-ipc-sender.js +34 -7
- package/dist/core/message/aun-request-registry.js +97 -3
- package/dist/core/message/im-renderer.js +11 -4
- package/dist/core/message/message-admission.js +97 -8
- package/dist/core/message/message-bridge.js +71 -24
- package/dist/core/message/message-log.js +55 -0
- package/dist/core/message/message-queue.js +5 -5
- package/dist/core/message/response-engine.js +387 -144
- package/dist/core/model/catalog-service.js +4 -2
- package/dist/core/model/config-scope.js +24 -64
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +37 -47
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +25 -23
- package/dist/core/permission/ec-command-parser.js +138 -5
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +42 -10
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +197 -0
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +168 -14
- package/dist/core/session/session-mapper.js +2 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +6 -1
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +79 -17
- package/dist/ipc.js +189 -17
- package/dist/paths.js +4 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +485 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +15 -0
- package/dist/stats/index.js +2 -2
- package/dist/stats/price-resolver.js +304 -5
- package/dist/stats/query.js +82 -3
- package/dist/stats/writer.js +38 -5
- package/dist/trigger/feedback.js +18 -7
- package/dist/trigger/manager.js +20 -3
- package/dist/trigger/parser.js +6 -3
- package/dist/trigger/patch.js +1 -1
- package/dist/trigger/system-definitions.js +43 -7
- package/dist/trigger/validation.js +13 -5
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +16 -2
- package/dist/utils/logger.js +24 -5
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +5 -3
- package/dist/utils/upgrade-jobs.js +45 -5
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/ABILITY_CALLING.md +20 -2
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +2 -1
- package/kits/docs/evolcore/agent-create.md +3 -2
- package/kits/docs/evolcore/agent.md +1 -1
- package/kits/docs/evolcore/config.md +18 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/event.md +1 -0
- package/kits/docs/evolcore/fs.md +16 -0
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +36 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +21 -8
- package/kits/docs/evolcore/session.md +14 -0
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +23 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +260 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +3 -7
- package/kits/skills/aid-ability/SKILL.md +35 -6
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-trigger/SKILL.md +13 -5
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/session-capsule/recovery.md +5 -0
- package/kits/templates/session-capsule/renew.md +5 -0
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/bootstrap.md +6 -6
- package/kits/templates/system-fragments/channel.md +1 -1
- package/kits/templates/system-fragments/memory.md +4 -4
- package/package.json +7 -3
- package/dist/stats/billing.js +0 -215
|
@@ -104,7 +104,7 @@ export function parseModelList(json, _url) {
|
|
|
104
104
|
}
|
|
105
105
|
const BUILTIN_IDS = {
|
|
106
106
|
codex: ['gpt-5.5', 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.3-codex', 'gpt-5.2'],
|
|
107
|
-
claude: ['claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001', 'deepseek-v4-
|
|
107
|
+
claude: ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-5-5', 'claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001', 'claude-fable-5', 'claude-fable-5-1', 'deepseek-v4.1-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'glm-5.3', 'glm-5.3-flash', 'glm-5.3-flashx', 'glm-5.2'],
|
|
108
108
|
ecagent: ['claude-sonnet-4-6'],
|
|
109
109
|
gemini: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'],
|
|
110
110
|
};
|
|
@@ -359,7 +359,9 @@ export class ModelCatalogService {
|
|
|
359
359
|
diagnostics.push({ code: auth ? 'AUTH_FAILED' : 'GATEWAY_UNAVAILABLE', message: auth ? '当前模型网关鉴权失败' : '当前模型网关不可用或响应格式不支持', ...(status ? { status } : {}) });
|
|
360
360
|
if (previous?.source === 'gateway')
|
|
361
361
|
return { ...previous, freshness: 'stale', diagnostics: [...diagnostics, { code: 'STALE_CACHE', message: '使用同一连接的最近成功目录' }] };
|
|
362
|
-
|
|
362
|
+
// 有显式 provider 时,鉴权失败返回空网关目录(提示是凭据问题);环境变量
|
|
363
|
+
// 兜底(无 providerId)则继续往下回落内置清单,避免兜底变成空列表。
|
|
364
|
+
if (auth && context.providerId)
|
|
363
365
|
return this.make(context, 'gateway', 'fallback', [], diagnostics);
|
|
364
366
|
}
|
|
365
367
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* config-scope: model/effort
|
|
2
|
+
* config-scope: model/effort 的读写,以及角色 permissionMode 解析。
|
|
3
3
|
*
|
|
4
4
|
* 所有参数统一在 config.json。
|
|
5
5
|
* 存储经 ConfigManager(全项目唯一合并实现点)。本模块是面向 CLI / 运行时的薄封装:
|
|
6
6
|
* 把"作用域 + baseagent"语义映射到 config 链的读写。
|
|
7
7
|
*
|
|
8
|
-
* model/effort
|
|
8
|
+
* model/effort 只在 Agent 级配置:
|
|
9
9
|
* agent agents/<self>/config.json → baseagents.<ba>.{model,effort}
|
|
10
|
-
* 角色
|
|
11
|
-
*
|
|
12
|
-
* global(历史保留):全局 model 作用域已退场,只读 agent 兜底。
|
|
10
|
+
* 角色 角色策略 → 只约束 Agent 级模型(白名单/固定模型),不提供模型
|
|
11
|
+
* 关系级与 defaults 都不承载模型参数;Agent 级未设置模型即无模型可用。
|
|
13
12
|
*
|
|
14
|
-
*
|
|
13
|
+
* 改 Agent 级后,该 Agent 所有会话的下一条消息即时生效(运行时每条消息解析,不缓存)。
|
|
15
14
|
*
|
|
16
15
|
* 详见 docs/config/
|
|
17
16
|
*/
|
|
@@ -82,60 +81,30 @@ export function activeBaseagent(self) {
|
|
|
82
81
|
catch { /* fall through */ }
|
|
83
82
|
return 'claude';
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
throw new ModelScopeError('NO_GLOBAL_SCOPE', '全局 model 作用域已退场:请用 --self 逐 agent 设置');
|
|
95
|
-
}
|
|
96
|
-
if (scope === 'agent') {
|
|
97
|
-
requireSelf(sel);
|
|
98
|
-
const target = ConfigTarget.Agent;
|
|
99
|
-
const cur = read(target, { self: sel.self }) || {};
|
|
100
|
-
applyBaPatch(cur, ba, ef, patch);
|
|
101
|
-
ensureFile(target, { self: sel.self });
|
|
102
|
-
write(target, cur, { self: sel.self });
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (scope === 'role') {
|
|
106
|
-
throw new ModelScopeError('ROLE_POLICY_MANAGED', '角色模型策略只能通过角色策略编辑器修改');
|
|
107
|
-
}
|
|
108
|
-
// relation
|
|
109
|
-
requirePeer(sel);
|
|
110
|
-
const target = ConfigTarget.Relation;
|
|
111
|
-
const selr = { self: sel.self, peerKey: sel.peerKey };
|
|
112
|
-
const cur = read(target, selr) || {};
|
|
113
|
-
applyBaPatch(cur, ba, ef, patch);
|
|
114
|
-
ensureFile(target, selr);
|
|
115
|
-
write(target, cur, selr);
|
|
116
|
-
}
|
|
117
|
-
function applyBaPatch(cfg, ba, ef, patch) {
|
|
118
|
-
cfg.baseagents = cfg.baseagents || {};
|
|
119
|
-
applyBaPatchTo(cfg.baseagents, ba, ef, patch);
|
|
120
|
-
}
|
|
121
|
-
function applyBaPatchTo(block, ba, ef, patch) {
|
|
122
|
-
block[ba] = block[ba] || {};
|
|
123
|
-
const sub = block[ba];
|
|
84
|
+
// ── 写:Agent 级 ──────────────────────────────────────────────────────
|
|
85
|
+
/** 写入 Agent 级 baseagents.<ba>.{model,effort}。patch 中 undefined 不动;显式 null 删除字段。 */
|
|
86
|
+
export function writeAgentModelConfig(self, ba, patch) {
|
|
87
|
+
if (!self)
|
|
88
|
+
throw new ModelScopeError('AGENT_NOT_FOUND', '模型参数只能在 Agent 级设置,需要 --self');
|
|
89
|
+
const target = ConfigTarget.Agent;
|
|
90
|
+
const cur = read(target, { self }) || {};
|
|
91
|
+
const baseagents = (cur.baseagents || {});
|
|
92
|
+
const block = { ...(baseagents[ba] || {}) };
|
|
124
93
|
if (patch.model === null)
|
|
125
|
-
delete
|
|
94
|
+
delete block.model;
|
|
126
95
|
else if (patch.model !== undefined)
|
|
127
|
-
|
|
96
|
+
block.model = patch.model;
|
|
128
97
|
if (patch.effort === null)
|
|
129
|
-
delete
|
|
98
|
+
delete block.effort;
|
|
130
99
|
else if (patch.effort !== undefined)
|
|
131
|
-
|
|
100
|
+
block.effort = patch.effort;
|
|
101
|
+
cur.baseagents = { ...baseagents, [ba]: block };
|
|
102
|
+
ensureFile(target, { self });
|
|
103
|
+
write(target, cur, { self });
|
|
132
104
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (scope === 'global')
|
|
137
|
-
return;
|
|
138
|
-
writeScope(scope, sel, ba, { model: null, effort: null });
|
|
105
|
+
/** 清除 Agent 级 model+effort。清除后该 Agent 没有模型可用,直到重新设置。 */
|
|
106
|
+
export function clearAgentModelConfig(self, ba) {
|
|
107
|
+
writeAgentModelConfig(self, ba, { model: null, effort: null });
|
|
139
108
|
}
|
|
140
109
|
// ── permissionMode 解析 ────────────────────────────────────────────────────
|
|
141
110
|
const FALLBACK_PERMISSION_MODE = 'readonly';
|
|
@@ -151,12 +120,3 @@ export function resolvePermissionMode(sel) {
|
|
|
151
120
|
return FALLBACK_PERMISSION_MODE;
|
|
152
121
|
}
|
|
153
122
|
}
|
|
154
|
-
// ── helpers ──────────────────────────────────────────────────────────────────
|
|
155
|
-
function requireSelf(sel) {
|
|
156
|
-
if (!sel.self)
|
|
157
|
-
throw new ModelScopeError('AGENT_NOT_FOUND', 'agent 作用域需要 --self');
|
|
158
|
-
}
|
|
159
|
-
function requirePeer(sel) {
|
|
160
|
-
if (!sel.self || !sel.peerKey)
|
|
161
|
-
throw new ModelScopeError('PEER_WITHOUT_SELF', '关系作用域需要 --self + --peer');
|
|
162
|
-
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* field-scope: 顶层配置字段的多作用域读写(通用框架)。
|
|
3
3
|
*
|
|
4
4
|
* 与 config-scope.ts(model 专用,处理 baseagents/roles 嵌套结构)互补:
|
|
5
|
-
* - config-scope:model/effort → config.json
|
|
5
|
+
* - config-scope:model/effort → Agent 级 config.json 的 baseagents 嵌套结构(只此一级)
|
|
6
6
|
* - field-scope:顶层字段(如 responseMode / responseModeParams)→ config.json(H 链)
|
|
7
7
|
*
|
|
8
8
|
* 复用 config-scope 的作用域判定与 peer 归一化(同一套语义,不重复造)。
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* owns refreshes and snapshots. Runners in the daemon use that same instance.
|
|
4
4
|
*/
|
|
5
5
|
import path from 'node:path';
|
|
6
|
-
import { resolveAnthropicConfig, resolveEcagentConfig, resolveOpenaiConfig, loadCodexSettings } from '../../agents/baseagent.js';
|
|
7
|
-
import { buildModelRequestHeaders } from '../../agents/request-identity.js';
|
|
8
6
|
import { activeBaseagent } from './config-scope.js';
|
|
9
7
|
import { resolveEffective } from '../../config/config-manager.js';
|
|
8
|
+
import { readRuntimeEnvironmentVariable } from '../../config/runtime-env.js';
|
|
10
9
|
import { loadDefaults } from '../../config-store.js';
|
|
11
10
|
import net from 'node:net';
|
|
12
11
|
import fs from 'node:fs';
|
|
@@ -87,6 +86,11 @@ function resolveProviderCatalogBaseagent(serviceType, requested) {
|
|
|
87
86
|
}
|
|
88
87
|
return baseagent;
|
|
89
88
|
}
|
|
89
|
+
function adaptProviderCatalogModels(models, provider, baseagent) {
|
|
90
|
+
return baseagent
|
|
91
|
+
? adaptCatalogModels(models, baseagent)
|
|
92
|
+
: adaptServiceCatalogModels(models, provider.serviceType, provider.style);
|
|
93
|
+
}
|
|
90
94
|
export async function getProviderCatalog(providerId, serviceType, refresh = false, management = false, requestedBaseagent) {
|
|
91
95
|
const selected = requestedBaseagent
|
|
92
96
|
? resolveProviderServiceForBaseagent(providerId, requestedBaseagent, serviceType)
|
|
@@ -97,9 +101,7 @@ export async function getProviderCatalog(providerId, serviceType, refresh = fals
|
|
|
97
101
|
if (management)
|
|
98
102
|
return snapshot;
|
|
99
103
|
const overridden = applyProviderModelOverrides(snapshot, selected.modelOverrides);
|
|
100
|
-
return { ...overridden, models: baseagent
|
|
101
|
-
? adaptCatalogModels(overridden.models, baseagent)
|
|
102
|
-
: adaptServiceCatalogModels(overridden.models, effectiveServiceType, selected.style) };
|
|
104
|
+
return { ...overridden, models: adaptProviderCatalogModels(overridden.models, selected, baseagent) };
|
|
103
105
|
};
|
|
104
106
|
if (!daemonOwner) {
|
|
105
107
|
const snapshot = await queryDaemonCatalog(undefined, undefined, refresh, { providerId, serviceType: effectiveServiceType });
|
|
@@ -117,54 +119,42 @@ export async function getLocalProviderCatalog(providerId, serviceType, refresh =
|
|
|
117
119
|
export function previewProviderCatalog(provider, requestedBaseagent) {
|
|
118
120
|
const baseagent = resolveProviderCatalogBaseagent(provider.serviceType, requestedBaseagent);
|
|
119
121
|
return new ModelCatalogService().get({ ...provider, scope: '<provider-preview>', baseagent: '' }, true)
|
|
120
|
-
.then(snapshot => ({ ...snapshot, models: baseagent
|
|
121
|
-
? adaptCatalogModels(snapshot.models, baseagent)
|
|
122
|
-
: adaptServiceCatalogModels(snapshot.models, provider.serviceType, provider.style) }));
|
|
122
|
+
.then(snapshot => ({ ...snapshot, models: adaptProviderCatalogModels(snapshot.models, provider, baseagent) }));
|
|
123
123
|
}
|
|
124
124
|
export function resolveCatalogContext(self, ba) {
|
|
125
125
|
const baseagent = ba || activeBaseagent(self);
|
|
126
|
-
const context = { scope: self || '<
|
|
127
|
-
const config = self ? resolveEffective({ self }, { cache: true
|
|
128
|
-
const block = (config
|
|
126
|
+
const context = { scope: self || '<none>', baseagent };
|
|
127
|
+
const config = self ? resolveEffective({ self }, { cache: true }) : loadDefaults();
|
|
128
|
+
const block = (config?.baseagents ?? {});
|
|
129
129
|
const selected = block[baseagent];
|
|
130
|
-
if (providerIsConfigured(selected)) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
queryParams: provider.queryParams,
|
|
142
|
-
modelOverrides: provider.modelOverrides,
|
|
143
|
-
});
|
|
144
|
-
return context;
|
|
145
|
-
}
|
|
146
|
-
try {
|
|
147
|
-
const cfg = { agents: block };
|
|
148
|
-
const resolved = baseagent === 'codex' ? resolveOpenaiConfig(cfg, block.codex)
|
|
149
|
-
: baseagent === 'claude' ? resolveAnthropicConfig(cfg, block.claude)
|
|
150
|
-
: baseagent === 'ecagent' ? resolveEcagentConfig(cfg, block.ecagent) : undefined;
|
|
151
|
-
if (resolved) {
|
|
152
|
-
Object.assign(context, { baseUrl: resolved.baseUrl, apiKey: resolved.apiKey, authType: 'authType' in resolved ? resolved.authType : undefined, queryParams: resolved.queryParams,
|
|
153
|
-
provider: 'provider' in resolved ? resolved.provider : undefined,
|
|
154
|
-
headers: buildModelRequestHeaders({ baseagent: baseagent, baseUrl: resolved.baseUrl, agentAid: self, configuredHeaders: resolved.headers }) });
|
|
130
|
+
if (!providerIsConfigured(selected)) {
|
|
131
|
+
// 没有显式 provider 时,回落到 base agent 自身的端点(环境变量),让目录也能
|
|
132
|
+
// 读到网关真实清单,而不是只剩内置候选。runtime-env 目前只管理 ANTHROPIC_*
|
|
133
|
+
// 这组变量,故仅对 claude 生效;其余 baseagent 或变量缺失时维持内置兜底。
|
|
134
|
+
if (baseagent === 'claude') {
|
|
135
|
+
const envBaseUrl = readRuntimeEnvironmentVariable('ANTHROPIC_BASE_URL', self).value;
|
|
136
|
+
if (envBaseUrl) {
|
|
137
|
+
const envApiKey = readRuntimeEnvironmentVariable('ANTHROPIC_AUTH_TOKEN', self).value
|
|
138
|
+
?? readRuntimeEnvironmentVariable('ANTHROPIC_API_KEY', self).value;
|
|
139
|
+
return { ...context, baseUrl: envBaseUrl, apiKey: envApiKey, style: 'claude' };
|
|
140
|
+
}
|
|
155
141
|
}
|
|
142
|
+
// 模型选择只在 Agent 级且必须指向 provider;没有 provider 就没有目录可查。
|
|
143
|
+
return { ...context, configUnavailable: true };
|
|
156
144
|
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
145
|
+
const provider = resolveProviderServiceForBaseagent(selected.provider, baseagent);
|
|
146
|
+
Object.assign(context, {
|
|
147
|
+
provider: provider.providerId,
|
|
148
|
+
providerId: provider.providerId,
|
|
149
|
+
providerServiceType: provider.serviceType,
|
|
150
|
+
catalogPath: provider.catalogPath,
|
|
151
|
+
style: provider.style,
|
|
152
|
+
baseUrl: provider.baseUrl,
|
|
153
|
+
apiKey: provider.apiKey,
|
|
154
|
+
headers: provider.headers,
|
|
155
|
+
queryParams: provider.queryParams,
|
|
156
|
+
modelOverrides: provider.modelOverrides,
|
|
157
|
+
});
|
|
168
158
|
return context;
|
|
169
159
|
}
|
|
170
160
|
/** Query the catalog for a host-level default connection, without Agent scope. */
|
|
@@ -19,7 +19,7 @@ async function fetchWithTimeout(url, opts, timeoutMs) {
|
|
|
19
19
|
}
|
|
20
20
|
function resolveGatewayCreds(self, baseagent) {
|
|
21
21
|
try {
|
|
22
|
-
const config = self ? resolveEffective({ self }, { cache: true
|
|
22
|
+
const config = self ? resolveEffective({ self }, { cache: true }) : { baseagents: {} };
|
|
23
23
|
const block = config.baseagents || {};
|
|
24
24
|
if (baseagent === 'codex') {
|
|
25
25
|
const codexCfg = block.codex || {};
|
|
@@ -155,7 +155,8 @@ export async function runModelCheck(input) {
|
|
|
155
155
|
log(catalog.freshness !== 'fresh'
|
|
156
156
|
? { label: '模型列表', ok: false, detail: `目录已降级,来源 ${catalog.source}(${modelIds.length} 个)` }
|
|
157
157
|
: { label: '模型列表', ok: true, detail: `来源: ${catalog.source},共 ${modelIds.length} 个模型` });
|
|
158
|
-
|
|
158
|
+
// 模型只在 Agent 级配置,不按对端解析。
|
|
159
|
+
const selector = { self: input.self };
|
|
159
160
|
const modelResolution = resolveEffectiveFieldWithSource(`baseagents.${input.baseagent}.model`, selector, { cache: true });
|
|
160
161
|
const modelDecision = constrainResolvedModelForRole({
|
|
161
162
|
selfAid: input.self,
|
|
@@ -169,7 +170,7 @@ export async function runModelCheck(input) {
|
|
|
169
170
|
: modelResolution.source?.target;
|
|
170
171
|
log(configuredModel
|
|
171
172
|
? { label: '配置模型', ok: true, detail: `${configuredModel}(来源: ${configuredModelSource ?? '未知'})` }
|
|
172
|
-
: { label: '配置模型', ok:
|
|
173
|
+
: { label: '配置模型', ok: false, detail: 'Agent 级未配置模型,该 Agent 无模型可用(owner/admin 用 /model 设置)' });
|
|
173
174
|
const probeResults = [];
|
|
174
175
|
if (baseUrl) {
|
|
175
176
|
const aliases = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { catalogEfforts, getCatalog, getProviderCatalog, resolveCatalogModel } from './model-catalog.js';
|
|
2
|
-
import {
|
|
2
|
+
import { resolveEffective } from '../../config/config-manager.js';
|
|
3
3
|
import { providerServiceTypeForBaseagent, providerServiceTypeForPurpose, resolveServiceSelection } from '../../config/providers.js';
|
|
4
4
|
export const MAX_FALLBACK_MODELS = 3;
|
|
5
5
|
function isRecord(value) {
|
|
@@ -42,9 +42,12 @@ function configuredFallbacks(raw) {
|
|
|
42
42
|
}
|
|
43
43
|
return { candidates, rejected };
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
/** 降级链只在 Agent 级 baseagents.<ba>.fallback 配置;没有 Agent 作用域就没有降级链。 */
|
|
46
|
+
export function configuredFallbackModels(baseagent, selfAid) {
|
|
47
|
+
if (!selfAid)
|
|
48
|
+
return { candidates: [], rejected: [] };
|
|
49
|
+
const effective = resolveEffective({ self: selfAid }, { cache: true });
|
|
50
|
+
const block = isRecord(effective?.baseagents) ? effective.baseagents[baseagent] : undefined;
|
|
48
51
|
return configuredFallbacks(isRecord(block) ? block.fallback : undefined);
|
|
49
52
|
}
|
|
50
53
|
async function eligibleCandidates(input) {
|
|
@@ -115,12 +118,12 @@ async function eligibleCandidates(input) {
|
|
|
115
118
|
}
|
|
116
119
|
export async function eligibleFallbackModels(input) {
|
|
117
120
|
const effective = input.selfAid
|
|
118
|
-
? resolveEffective({ self: input.selfAid }, { cache: true
|
|
119
|
-
:
|
|
121
|
+
? resolveEffective({ self: input.selfAid }, { cache: true })
|
|
122
|
+
: undefined;
|
|
120
123
|
const selection = effective?.baseagents?.[input.baseagent];
|
|
121
124
|
return eligibleCandidates({
|
|
122
125
|
...input,
|
|
123
|
-
configured: configuredFallbackModels(input.baseagent),
|
|
126
|
+
configured: configuredFallbackModels(input.baseagent, input.selfAid),
|
|
124
127
|
serviceType: input.baseagent,
|
|
125
128
|
catalogBaseagent: input.baseagent,
|
|
126
129
|
catalogProviderServiceType: selection?.providerServiceType,
|
|
@@ -88,13 +88,14 @@ export function validateModelSelectionForRole(opts) {
|
|
|
88
88
|
return { ok: true, model: targetModel };
|
|
89
89
|
}
|
|
90
90
|
export function constrainResolvedModelForRole(opts) {
|
|
91
|
+
// 角色策略只约束 Agent 级已配置的模型,不提供模型:Agent 级没有模型就是无模型可用。
|
|
92
|
+
if (!opts.model)
|
|
93
|
+
return { model: undefined, constrained: false };
|
|
91
94
|
const permission = getRoleModelPermission(opts.role, opts.baseagent, opts.selfAid);
|
|
92
95
|
if (!permission.constrained)
|
|
93
96
|
return { model: opts.model, constrained: false };
|
|
94
97
|
if (!permission.allowOverride)
|
|
95
98
|
return { model: permission.defaultModel || opts.model, constrained: true };
|
|
96
|
-
if (!opts.model)
|
|
97
|
-
return { model: permission.defaultModel, constrained: true };
|
|
98
99
|
if (isModelAllowedForRoleBaseagent(opts.role, opts.baseagent, opts.model, opts.resolveModelId, opts.selfAid)) {
|
|
99
100
|
return { model: opts.model, constrained: false };
|
|
100
101
|
}
|
|
@@ -9,8 +9,6 @@ import { logger } from '../../utils/logger.js';
|
|
|
9
9
|
import { hasTrustedPrincipal } from '../auth/authenticated-actor.js';
|
|
10
10
|
export const OWNERSHIP_CACHE_MAX_AGE_MS = 30 * 60_000;
|
|
11
11
|
export const OWNERSHIP_AUTHORIZATION_MAX_AGE_MS = 5 * 60_000;
|
|
12
|
-
// Background refreshes should heal a short outage without retrying on every tool call.
|
|
13
|
-
const OWNERSHIP_BACKGROUND_REFRESH_MIN_INTERVAL_MS = 60_000;
|
|
14
12
|
const CREATION_BIND_OPERATION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
15
13
|
/** Only use the task returned by this create's bind call. Never select a latest task. */
|
|
16
14
|
export function creationOwnershipBinding(task, subjectAid, ownerAid) {
|
|
@@ -298,20 +296,11 @@ export class OwnerResolver {
|
|
|
298
296
|
const initialEpoch = subject.epoch;
|
|
299
297
|
const initialCheckedAt = subject.view.checkedAt;
|
|
300
298
|
const maxAgeMs = options.maxAgeMs ?? this.options.lifetimeMs ?? OWNERSHIP_CACHE_MAX_AGE_MS;
|
|
301
|
-
const isFresh = () =>
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
&& checkedAt !== undefined && checkedAt <= now && (validUntil ?? 0) > now
|
|
306
|
-
&& now - checkedAt < maxAgeMs;
|
|
307
|
-
};
|
|
308
|
-
if (!refreshing && !options.force && isFresh()) {
|
|
309
|
-
if (options.allowTransient
|
|
310
|
-
&& this.now() - (subject.lastRefreshAttemptAt ?? 0) >= OWNERSHIP_BACKGROUND_REFRESH_MIN_INTERVAL_MS) {
|
|
311
|
-
this.schedule(subjectAid, subject, true);
|
|
312
|
-
}
|
|
299
|
+
const isFresh = () => this.isCacheFresh(subject, maxAgeMs);
|
|
300
|
+
// A valid cache never schedules a supplementary consensus check; identity
|
|
301
|
+
// verification only runs when the cache is stale or an operation forces it.
|
|
302
|
+
if (!refreshing && !options.force && isFresh())
|
|
313
303
|
return this.snapshot(subjectAid);
|
|
314
|
-
}
|
|
315
304
|
const attemptId = inFlight?.attemptId ?? ++subject.query;
|
|
316
305
|
const attemptedAt = inFlight?.attemptedAt ?? this.now();
|
|
317
306
|
const promise = refreshing ?? this.refreshSubject(subjectAid, subject, attemptId, attemptedAt);
|
|
@@ -339,7 +328,6 @@ export class OwnerResolver {
|
|
|
339
328
|
}
|
|
340
329
|
async refreshSubject(subjectAid, subject, attemptId, attemptedAt) {
|
|
341
330
|
const client = subject.client;
|
|
342
|
-
subject.lastRefreshAttemptAt = attemptedAt;
|
|
343
331
|
if (!client || !subject.view.connected) {
|
|
344
332
|
const reason = 'Subject AID has no connected SDK client';
|
|
345
333
|
this.handleRefreshFailure(subjectAid, subject, { code: 'CLIENT_DISCONNECTED', message: reason }, attemptedAt, attemptId);
|
|
@@ -551,10 +539,17 @@ export class OwnerResolver {
|
|
|
551
539
|
}
|
|
552
540
|
async status(subjectAid) {
|
|
553
541
|
const subject = this.subject(subjectAid);
|
|
542
|
+
// Status display reuses the resolve snapshot; consensus verification is
|
|
543
|
+
// reserved for operations that actually depend on Owner permission.
|
|
544
|
+
if (subject.client && subject.view.connected)
|
|
545
|
+
return this.refresh(subjectAid);
|
|
546
|
+
// A fresh snapshot survives transport loss; serve it instead of loading a
|
|
547
|
+
// short-lived client. Only a stale unattached subject needs a live check.
|
|
548
|
+
if (this.isCacheFresh(subject, this.options.lifetimeMs ?? OWNERSHIP_CACHE_MAX_AGE_MS)) {
|
|
549
|
+
return this.snapshot(subjectAid);
|
|
550
|
+
}
|
|
554
551
|
const generation = subject.generation;
|
|
555
|
-
return this.withSubjectClient(subjectAid, async (client
|
|
556
|
-
if (attached)
|
|
557
|
-
return this.refresh(subjectAid, { force: true });
|
|
552
|
+
return this.withSubjectClient(subjectAid, async (client) => {
|
|
558
553
|
const consensus = await client.checkOwnershipConsensus(subjectAid);
|
|
559
554
|
if (subject.generation !== generation) {
|
|
560
555
|
throw new OwnershipError('CLIENT_REPLACED', 'Subject state changed during status query; retry');
|
|
@@ -563,6 +558,13 @@ export class OwnerResolver {
|
|
|
563
558
|
return this.snapshot(subjectAid);
|
|
564
559
|
});
|
|
565
560
|
}
|
|
561
|
+
isCacheFresh(subject, maxAgeMs) {
|
|
562
|
+
const { checkedAt, validUntil, consensusStatus } = subject.view;
|
|
563
|
+
const now = this.now();
|
|
564
|
+
return consensusStatus !== 'unavailable' && consensusStatus !== 'not_applicable'
|
|
565
|
+
&& checkedAt !== undefined && checkedAt <= now && (validUntil ?? 0) > now
|
|
566
|
+
&& now - checkedAt < maxAgeMs;
|
|
567
|
+
}
|
|
566
568
|
async withSubjectClient(subjectAid, operation) {
|
|
567
569
|
const subject = this.subject(subjectAid);
|
|
568
570
|
if (subject.client && subject.view.connected)
|
|
@@ -675,11 +677,11 @@ export class OwnerResolver {
|
|
|
675
677
|
return undefined;
|
|
676
678
|
ownerClient = await sdkStore.loadClient(store, ownerAid);
|
|
677
679
|
subClient = await sdkStore.loadClient(store, subjectAid);
|
|
678
|
-
if (typeof ownerClient.
|
|
680
|
+
if (typeof ownerClient.bindSubaid !== 'function'
|
|
679
681
|
|| ownerClient.getType() !== 'agent' || subClient.getType() !== 'agent')
|
|
680
682
|
return undefined;
|
|
681
683
|
invoked = true;
|
|
682
|
-
const task = this.task(await ownerClient.
|
|
684
|
+
const task = this.task(await ownerClient.bindSubaid(subjectAid));
|
|
683
685
|
if (!task || task.operation !== 'bind' || task.sub_aid !== subjectAid || task.owner_aid !== ownerAid
|
|
684
686
|
|| task.status !== 'completed') {
|
|
685
687
|
throw Object.assign(new OwnershipError(task?.code ?? 'LOCAL_BIND_FAILED', task?.reason ?? 'Local binding did not complete'), { retryable: task?.retryable });
|
|
@@ -799,12 +801,12 @@ export class OwnerResolver {
|
|
|
799
801
|
}
|
|
800
802
|
}
|
|
801
803
|
}
|
|
802
|
-
schedule(subjectAid, subject
|
|
804
|
+
schedule(subjectAid, subject) {
|
|
803
805
|
if (subject.timer || !subject.client || !subject.view.connected)
|
|
804
806
|
return;
|
|
805
807
|
subject.timer = setTimeout(() => {
|
|
806
808
|
subject.timer = undefined;
|
|
807
|
-
void this.refresh(subjectAid, { force: true, allowTransient }).catch(error => {
|
|
809
|
+
void this.refresh(subjectAid, { force: true, allowTransient: true }).catch(error => {
|
|
808
810
|
logger.warn(`[ownership] Event refresh failed for ${subjectAid}: ${error instanceof Error ? error.message : String(error)}`);
|
|
809
811
|
});
|
|
810
812
|
}, 0);
|