evolcore 0.0.41-test.0 → 0.0.41-test.2
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 +62 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -49
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +146 -71
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -21
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/menu/client.js +27 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +8 -8
- package/dist/aun/service-proxy.js +53 -12
- package/dist/channels/aun.js +633 -32
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +48 -36
- package/dist/cli/daemon-commands.js +679 -697
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +72 -5
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +17 -1
- package/dist/cli/model.js +40 -40
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/role.js +85 -0
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/access-policy.js +7 -2
- package/dist/config/boot-log.js +39 -1
- package/dist/config/config-field-policy.js +17 -39
- package/dist/config/config-manager.js +183 -44
- package/dist/config/config-operation-service.js +5 -19
- 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 +88 -594
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +15 -12
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +11 -1
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +1000 -25
- package/dist/config-store.js +89 -4
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +4 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +194 -24
- package/dist/core/auth/agent-delegation.js +6 -3
- package/dist/core/auth/auth-gateway.js +67 -2
- package/dist/core/auth/authorization-audit.js +58 -11
- package/dist/core/auth/delegation-authorization.js +5 -2
- package/dist/core/auth/operation-authorizer.js +43 -6
- package/dist/core/auth/operation-catalog.js +45 -7
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +260 -21
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +8 -3
- package/dist/core/command/command-handler.js +112 -154
- package/dist/core/command/connect-menu.js +11 -3
- 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 +10 -6
- package/dist/core/command/menu-handler.js +106 -73
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +125 -255
- package/dist/core/daemon-control.js +26 -27
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +7 -5
- package/dist/core/evolagent.js +10 -8
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +40 -24
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +96 -1
- package/dist/core/memory/consolidation-trigger.js +208 -191
- package/dist/core/memory/consolidation.js +333 -35
- 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 +55 -45
- package/dist/core/message/aun-ipc-sender.js +81 -69
- package/dist/core/message/im-renderer.js +25 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +66 -21
- package/dist/core/message/response-engine.js +108 -35
- package/dist/core/model/catalog-service.js +5 -3
- package/dist/core/model/config-scope.js +29 -71
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +30 -41
- 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 +772 -158
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +62 -6
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +21 -46
- 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 +1 -1
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +20 -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 +43 -8
- 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/init-menu.js +32 -0
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +93 -19
- package/dist/ipc.js +247 -29
- package/dist/paths.js +7 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +484 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +26 -2
- package/dist/utils/logger.js +92 -6
- package/dist/utils/package-version-info.js +4 -2
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +28 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -0
- package/kits/docs/evolcore/group.md +1 -1
- 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 +4 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +4 -7
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +8 -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 +277 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- 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/skills/thread-ops/SKILL.md +5 -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/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/memory.md +4 -4
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +7 -3
- package/dist/core/message/create-status.js +0 -96
|
@@ -1,22 +1,21 @@
|
|
|
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
|
*/
|
|
18
17
|
import { formatPeerKey, parsePeerKey } from '../relation/peer-identity.js';
|
|
19
|
-
import { ConfigTarget, read, write, ensureFile, } from '../../config/config-manager.js';
|
|
18
|
+
import { ConfigTarget, read, write, ensureFile, resolveEffective, } from '../../config/config-manager.js';
|
|
20
19
|
import { resolveRuntimePermissionMode } from '../role/runtime-policy.js';
|
|
21
20
|
export class ModelScopeError extends Error {
|
|
22
21
|
code;
|
|
@@ -70,72 +69,40 @@ export function determineScope(sel) {
|
|
|
70
69
|
return 'global';
|
|
71
70
|
}
|
|
72
71
|
// ── baseagent 解析 ───────────────────────────────────────────────────────
|
|
73
|
-
/**
|
|
72
|
+
/** Read the Agent's active backend, including an inherited defaults selection. */
|
|
74
73
|
export function activeBaseagent(self) {
|
|
75
74
|
try {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return b.active_baseagent;
|
|
80
|
-
}
|
|
75
|
+
const b = resolveEffective({ self }, { cache: true });
|
|
76
|
+
if (b?.active_baseagent)
|
|
77
|
+
return b.active_baseagent;
|
|
81
78
|
}
|
|
82
79
|
catch { /* fall through */ }
|
|
83
80
|
return 'claude';
|
|
84
81
|
}
|
|
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];
|
|
82
|
+
// ── 写:Agent 级 ──────────────────────────────────────────────────────
|
|
83
|
+
/** 写入 Agent 级 baseagents.<ba>.{model,effort}。patch 中 undefined 不动;显式 null 删除字段。 */
|
|
84
|
+
export function writeAgentModelConfig(self, ba, patch) {
|
|
85
|
+
if (!self)
|
|
86
|
+
throw new ModelScopeError('AGENT_NOT_FOUND', '模型参数只能在 Agent 级设置,需要 --self');
|
|
87
|
+
const target = ConfigTarget.Agent;
|
|
88
|
+
const cur = read(target, { self }) || {};
|
|
89
|
+
const baseagents = (cur.baseagents || {});
|
|
90
|
+
const block = { ...(baseagents[ba] || {}) };
|
|
124
91
|
if (patch.model === null)
|
|
125
|
-
delete
|
|
92
|
+
delete block.model;
|
|
126
93
|
else if (patch.model !== undefined)
|
|
127
|
-
|
|
94
|
+
block.model = patch.model;
|
|
128
95
|
if (patch.effort === null)
|
|
129
|
-
delete
|
|
96
|
+
delete block.effort;
|
|
130
97
|
else if (patch.effort !== undefined)
|
|
131
|
-
|
|
98
|
+
block.effort = patch.effort;
|
|
99
|
+
cur.baseagents = { ...baseagents, [ba]: block };
|
|
100
|
+
ensureFile(target, { self });
|
|
101
|
+
write(target, cur, { self });
|
|
132
102
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (scope === 'global')
|
|
137
|
-
return;
|
|
138
|
-
writeScope(scope, sel, ba, { model: null, effort: null });
|
|
103
|
+
/** 清除 Agent 级 model+effort。清除后该 Agent 没有模型可用,直到重新设置。 */
|
|
104
|
+
export function clearAgentModelConfig(self, ba) {
|
|
105
|
+
writeAgentModelConfig(self, ba, { model: null, effort: null });
|
|
139
106
|
}
|
|
140
107
|
// ── permissionMode 解析 ────────────────────────────────────────────────────
|
|
141
108
|
const FALLBACK_PERMISSION_MODE = 'readonly';
|
|
@@ -151,12 +118,3 @@ export function resolvePermissionMode(sel) {
|
|
|
151
118
|
return FALLBACK_PERMISSION_MODE;
|
|
152
119
|
}
|
|
153
120
|
}
|
|
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';
|
|
@@ -124,48 +123,38 @@ export function previewProviderCatalog(provider, requestedBaseagent) {
|
|
|
124
123
|
}
|
|
125
124
|
export function resolveCatalogContext(self, ba) {
|
|
126
125
|
const baseagent = ba || activeBaseagent(self);
|
|
127
|
-
const context = { scope: self || '<
|
|
128
|
-
const config = self ? resolveEffective({ self }, { cache: true
|
|
129
|
-
const block = (config
|
|
126
|
+
const context = { scope: self || '<none>', baseagent };
|
|
127
|
+
const config = self ? resolveEffective({ self }, { cache: true }) : loadDefaults();
|
|
128
|
+
const block = (config?.baseagents ?? {});
|
|
130
129
|
const selected = block[baseagent];
|
|
131
|
-
if (providerIsConfigured(selected)) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
queryParams: provider.queryParams,
|
|
143
|
-
modelOverrides: provider.modelOverrides,
|
|
144
|
-
});
|
|
145
|
-
return context;
|
|
146
|
-
}
|
|
147
|
-
try {
|
|
148
|
-
const cfg = { agents: block };
|
|
149
|
-
const resolved = baseagent === 'codex' ? resolveOpenaiConfig(cfg, block.codex)
|
|
150
|
-
: baseagent === 'claude' ? resolveAnthropicConfig(cfg, block.claude)
|
|
151
|
-
: baseagent === 'ecagent' ? resolveEcagentConfig(cfg, block.ecagent) : undefined;
|
|
152
|
-
if (resolved) {
|
|
153
|
-
Object.assign(context, { baseUrl: resolved.baseUrl, apiKey: resolved.apiKey, authType: 'authType' in resolved ? resolved.authType : undefined, queryParams: resolved.queryParams,
|
|
154
|
-
provider: 'provider' in resolved ? resolved.provider : undefined,
|
|
155
|
-
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
|
+
}
|
|
156
141
|
}
|
|
142
|
+
// 模型选择只在 Agent 级且必须指向 provider;没有 provider 就没有目录可查。
|
|
143
|
+
return { ...context, configUnavailable: true };
|
|
157
144
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
});
|
|
169
158
|
return context;
|
|
170
159
|
}
|
|
171
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
|
}
|