evolcore 0.0.48 → 0.0.50
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 +97 -0
- package/bin/ecmsg.js +9 -4
- package/dist/ability/caller/authorization.js +21 -0
- package/dist/ability/caller/command.js +164 -0
- package/dist/ability/caller/contract.js +102 -0
- package/dist/ability/caller/daemon.js +158 -0
- package/dist/ability/caller/service.js +380 -0
- package/dist/ability/command-contract.js +5 -0
- package/dist/ability/daemon.js +5 -1
- package/dist/ability/interop-v1.js +10 -3
- package/dist/ability/management.js +1 -0
- package/dist/agent-template/jobs.js +173 -1
- package/dist/agent-template/runtime.js +285 -8
- package/dist/agent-template/service.js +1159 -40
- package/dist/agent-template/types.js +2 -1
- package/dist/agents/baseagent-availability.js +27 -3
- package/dist/agents/baseagent-capability-adapter.js +102 -0
- package/dist/agents/baseagent-plugin-descriptor.js +274 -0
- package/dist/agents/baseagent-plugin-loader.js +145 -0
- package/dist/agents/baseagent.js +68 -2
- package/dist/agents/claude-gateway/agent-registration.js +389 -0
- package/dist/agents/claude-gateway/binding.js +96 -0
- package/dist/agents/claude-gateway/inbox.js +138 -0
- package/dist/agents/claude-gateway/index.js +125 -0
- package/dist/agents/claude-gateway/listing.js +330 -0
- package/dist/agents/claude-gateway/router.js +328 -0
- package/dist/agents/claude-gateway/sessions.js +128 -0
- package/dist/agents/claude-gateway/terminal.js +250 -0
- package/dist/agents/claude-gateway/transcript.js +272 -0
- package/dist/agents/claude-gateway/types.js +14 -0
- package/dist/agents/claude-runner.js +6 -10
- package/dist/agents/codex-runner.js +9 -2
- package/dist/agents/{gemini-runner.js → gemini/gemini-runner.js} +17 -17
- package/dist/{core/session/adapters → agents/gemini}/gemini-session-file-adapter.js +2 -2
- package/dist/agents/gemini/index.js +51 -0
- package/dist/aun/aid/control-aid.js +52 -32
- package/dist/aun/group/invite-service.js +6 -36
- package/dist/aun/group/operations.js +6 -0
- package/dist/aun/msg/mention-schema.js +1 -1
- package/dist/aun/msg/p2p.js +31 -2
- package/dist/aun/msg/upload.js +126 -3
- package/dist/build-identity.json +1 -1
- package/dist/channels/aun.js +1175 -457
- package/dist/cli/ability-command.js +42 -0
- package/dist/cli/agent-command.js +20 -1
- package/dist/cli/agent-create.js +78 -18
- package/dist/cli/agent-template.js +5 -3
- package/dist/cli/agent.js +91 -0
- package/dist/cli/aun-commands.js +92 -34
- package/dist/cli/bench.js +5 -2
- package/dist/cli/config.js +22 -6
- package/dist/cli/daemon-commands.js +245 -101
- package/dist/cli/directory.js +6 -1
- package/dist/cli/ecmsg-gateway.js +11 -9
- package/dist/cli/index.js +30 -5
- package/dist/cli/init.js +39 -63
- package/dist/cli/managed-command-guard.js +3 -0
- package/dist/cli/menu-client.js +32 -7
- package/dist/cli/model.js +20 -5
- package/dist/cli/pay-command.js +30 -0
- package/dist/cli/provider-command.js +6 -2
- package/dist/cli/quota.js +89 -0
- package/dist/cli/restart-monitor.js +2 -2
- package/dist/cli/role.js +1 -0
- package/dist/cli/services-command.js +12 -9
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +78 -12
- package/dist/config/access-policy.js +16 -3
- package/dist/config/config-field-policy.js +88 -9
- package/dist/config/config-manager.js +97 -47
- package/dist/config/config-operation-service.js +22 -1
- package/dist/config/gateway-config.js +9 -8
- package/dist/config/owner-config.js +0 -16
- package/dist/config/peer-role-resolver.js +1 -7
- package/dist/config/providers-config.js +107 -20
- package/dist/config/providers-management.js +45 -21
- package/dist/config/resolved-config-op.js +4 -44
- package/dist/config/schema-migration.js +78 -5
- package/dist/config/schema-registry.js +52 -7
- package/dist/config-store.js +1309 -17
- package/dist/core/agent-application-service.js +220 -1
- package/dist/core/agent-ipc-registration.js +19 -2
- package/dist/core/agent-reload-coordinator.js +5 -0
- package/dist/core/agent-runtime.js +198 -54
- package/dist/core/auth/agent-delegation.js +14 -0
- package/dist/core/auth/delegation-authorization.js +33 -26
- package/dist/core/auth/operation-authorizer.js +16 -1
- package/dist/core/auth/operation-catalog.js +59 -7
- package/dist/core/baseagent-loader.js +30 -3
- package/dist/core/capability/capability-manager.js +16 -7
- package/dist/core/channel-runtime.js +4 -2
- package/dist/core/command/agent-control.js +20 -2
- package/dist/core/command/agent-template-menu.js +4 -3
- package/dist/core/command/cli-intent-parser.js +28 -0
- package/dist/core/command/command-handler.js +45 -2
- package/dist/core/command/menu-catalog.js +20 -4
- package/dist/core/command/menu-file-path.js +70 -0
- package/dist/core/command/menu-handler.js +97 -73
- package/dist/core/command/menu-protocol.js +29 -0
- package/dist/core/command/menu-query-batch.js +2 -2
- package/dist/core/command/private-mention-menu.js +71 -0
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/slash-handler.js +17 -26
- package/dist/core/command/team-workspace-bootstrap.js +2 -1
- package/dist/core/command/topic-slash.js +7 -1
- package/dist/core/daemon-bootstrap.js +0 -4
- package/dist/core/daemon-control.js +58 -1
- package/dist/core/daemon-lifecycle.js +29 -7
- package/dist/core/evolagent-registry.js +18 -9
- package/dist/core/handoff/runtime.js +1 -1
- package/dist/core/host-snapshot.js +8 -3
- package/dist/core/initialization/service.js +3 -0
- package/dist/core/interaction-router.js +130 -0
- package/dist/core/ipc-registration.js +5 -0
- package/dist/core/memory/consolidation-context.js +2 -1
- package/dist/core/memory/consolidation.js +35 -64
- package/dist/core/message/aun-ipc-sender.js +213 -74
- package/dist/core/message/aun-request-registry.js +31 -0
- package/dist/core/message/contact-admission.js +91 -6
- package/dist/core/message/contact-pending-inbound.js +113 -0
- package/dist/core/message/contact-thread-approval.js +212 -0
- package/dist/core/message/im-renderer.js +40 -1
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +197 -45
- package/dist/core/message/message-log.js +32 -0
- package/dist/core/message/message-queue.js +102 -18
- package/dist/core/message/peer-mode.js +15 -4
- package/dist/core/message/response-engine.js +174 -26
- package/dist/core/message/send-options.js +37 -3
- package/dist/core/message/send-routing.js +11 -7
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-catalog.js +5 -5
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- package/dist/core/ownership/owner-resolver.js +12 -86
- package/dist/core/pack-auth.js +7 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +288 -77
- package/dist/core/permission/protected-paths.js +64 -9
- package/dist/core/permission/services-path-acl.js +458 -0
- package/dist/core/permission/tool-policy.js +26 -10
- package/dist/core/relation/peer-identity.js +13 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +6 -2
- package/dist/core/session/adapters/codex-session-file-adapter.js +4 -0
- package/dist/core/session/session-manager.js +47 -10
- package/dist/core/session/session-mapper.js +16 -0
- package/dist/core/skill/index-generator.js +2 -3
- package/dist/core/skill/switch-resolver.js +3 -0
- package/dist/core/task/task-recovery-service.js +1 -0
- package/dist/core/thread/command-parser.js +4 -1
- package/dist/core/thread/ipc-operation.js +4 -2
- package/dist/core/thread/thread-operation.js +25 -10
- package/dist/core/thread/thread-service.js +294 -55
- package/dist/core/thread/topic-id.js +67 -2
- package/dist/core/thread/types.js +15 -1
- package/dist/directory/owner-directory-admission.js +11 -8
- package/dist/directory/owner-directory-cache.js +19 -0
- package/dist/directory/owner-directory-markdown.js +1 -1
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +3 -2
- package/dist/eck/message-renderer.js +28 -5
- package/dist/ecweb/basic-settings-service.js +5 -9
- package/dist/ecweb/providers-service.js +4 -2
- package/dist/ecweb/runtime/supervisor.js +36 -8
- package/dist/event-center/center-config.js +9 -5
- package/dist/event-center/dispatcher.js +10 -1
- package/dist/event-center/ipc-operation.js +19 -0
- package/dist/event-center/registry.js +20 -5
- package/dist/event-center/runtime.js +10 -7
- package/dist/index.js +120 -41
- package/dist/ipc.js +83 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +3 -2
- package/dist/outputs/protocol.js +1 -0
- package/dist/outputs/service.js +2 -15
- package/dist/paths.js +48 -1
- package/dist/pay/command.js +38 -0
- package/dist/pay/protocol.js +136 -0
- package/dist/pay/runtime.js +188 -0
- package/dist/pay/service.js +384 -0
- package/dist/pay/store.js +81 -0
- package/dist/response-system/engines/v1/proactive-flow.js +29 -2
- package/dist/services/dispatcher.js +23 -5
- package/dist/services/host/main.js +388 -0
- package/dist/services/host/protocol.js +118 -0
- package/dist/services/host/resident.js +310 -0
- package/dist/services/host-client.js +386 -0
- package/dist/services/host-deploy.js +180 -0
- package/dist/services/host-launch.js +117 -0
- package/dist/services/host-recycle.js +203 -0
- package/dist/services/host-runtime.js +802 -0
- package/dist/services/idempotency.js +44 -86
- package/dist/services/index-generator.js +4 -3
- package/dist/services/index.js +204 -22
- package/dist/services/ipc-operation.js +288 -44
- package/dist/services/pack-manager.js +1 -0
- package/dist/services/script-runner.js +515 -83
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +109 -4
- package/dist/stats/budget.js +1 -1
- package/dist/stats/model-resolver.js +2 -2
- package/dist/stats/quota-query.js +95 -0
- package/dist/trigger/application-service.js +6 -4
- package/dist/trigger/local-files.js +19 -9
- package/dist/trigger/scheduler.js +22 -12
- package/dist/trigger/script-sandbox.js +51 -8
- package/dist/utils/aid-bind.js +3 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/evolcore-version.js +2 -2
- package/dist/utils/host-info.js +173 -1
- package/dist/utils/logger.js +2 -2
- package/dist/utils/media-cache.js +190 -43
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/restart-safety.js +14 -1
- package/dist/utils/system-memory.js +113 -25
- package/dist/utils/systemd-lifecycle.js +154 -0
- package/dist/utils/windows-shell-trust.js +7 -3
- package/dist/workbench/service.js +1 -1
- package/kits/docs/INDEX.md +3 -2
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +1 -0
- package/kits/docs/channels/aun.md +1 -1
- package/kits/docs/evolcore/INDEX.md +9 -6
- package/kits/docs/evolcore/agent.md +36 -1
- package/kits/docs/evolcore/aid.md +45 -3
- package/kits/docs/evolcore/config.md +5 -2
- package/kits/docs/evolcore/directory.md +8 -9
- package/kits/docs/evolcore/group.md +2 -1
- package/kits/docs/evolcore/memory-tags.md +2 -0
- package/kits/docs/evolcore/menu-client.md +3 -3
- package/kits/docs/evolcore/menu-protocol.md +7 -0
- package/kits/docs/evolcore/model.md +3 -0
- package/kits/docs/evolcore/msg.md +77 -10
- package/kits/docs/evolcore/pay.md +34 -0
- package/kits/docs/evolcore/provider.md +22 -1
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +3 -0
- package/kits/docs/evolcore/services.md +46 -18
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/thread-chain.md +2 -0
- package/kits/docs/evolcore/tool-authorization.md +10 -0
- package/kits/docs/evolcore/trigger.md +2 -0
- package/kits/rules/01-overview.md +11 -32
- package/kits/rules/02-navigation.md +7 -0
- package/kits/rules/06-channel.md +3 -3
- package/kits/schemas/_meta.json +38 -5
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/schemas/agent-config.schema.21.json +974 -0
- package/kits/schemas/agent-config.schema.22.json +977 -0
- package/kits/schemas/agent-config.schema.23.json +958 -0
- package/kits/schemas/daemon.schema.10.json +373 -0
- package/kits/schemas/daemon.schema.9.json +12 -0
- package/kits/schemas/defaults.schema.7.json +472 -0
- package/kits/schemas/providers.schema.3.json +18 -2
- package/kits/schemas/relation-config.schema.13.json +289 -0
- package/kits/skills/.switches.json +17 -1
- package/kits/skills/ability/SKILL.md +229 -34
- package/kits/skills/ability/STRUCTURE.md +333 -0
- package/kits/skills/ability/references/cli.md +208 -0
- package/kits/skills/ability/references/development.md +107 -37
- package/kits/skills/ability/references/management.md +106 -46
- package/kits/skills/ability/references/runtime-protocol.md +65 -63
- package/kits/skills/agent-output-cards/SKILL.md +64 -0
- package/kits/skills/ec-group/SKILL.md +8 -6
- package/kits/skills/ec-group/TASK.md +186 -0
- package/kits/skills/ec-group/WORKLOG.md +180 -0
- package/kits/skills/ec-group-collaboration/SKILL.md +3 -3
- package/kits/skills/ec-pay/SKILL.md +101 -0
- package/kits/skills/ec-pay/references/pay-cli.md +110 -0
- package/kits/skills/ec-provider/SKILL.md +58 -9
- package/kits/skills/{ec-service-proxy → ec-proxy}/SKILL.md +8 -5
- package/kits/skills/ec-service-call/SKILL.md +135 -0
- package/kits/skills/ec-service-pack/SKILL.md +277 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/templates/memory-consolidation/notes.md +2 -2
- package/kits/templates/memory-consolidation/workflow.md +46 -0
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/channel.md +13 -4
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/reply.md +1 -0
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +27 -128
- package/kits/templates/system-fragments/venue.md +27 -0
- package/package.json +4 -5
- package/scripts/agent-template/inspect.mjs +79 -29
- package/scripts/agent-template/overlay.mjs +20 -2
- package/scripts/agent-template/shared/common.mjs +24 -6
- package/scripts/agent-template/shared/team-schema.json +23 -5
- package/scripts/agent-template/shared/template-contract.mjs +107 -17
- package/scripts/agent-template/shared/template-package.mjs +254 -29
- package/scripts/agent-template/shared/template-runtime.mjs +145 -2
- package/scripts/agent-template/shared/template.mjs +67 -9
- package/scripts/agent-template/team-pack.mjs +132 -41
- package/scripts/agent-template/team-preview.mjs +249 -5
- package/kits/docs/aun/ABILITY_CALLING.md +0 -280
- package/kits/docs/evolcore/ability.md +0 -185
- package/kits/skills/ability/references/calling.md +0 -56
- package/kits/skills/ability/references/contract-checklist.md +0 -37
- package/kits/skills/ability/references/recovery.md +0 -27
- /package/dist/{core/capability/providers → agents/gemini}/gemini-capability-provider.js +0 -0
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* 详见 docs/config/
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
17
|
+
import { normalizePeerKey } from '../relation/peer-identity.js';
|
|
18
18
|
import { ConfigTarget, read, write, ensureFile, resolveEffective, } from '../../config/config-manager.js';
|
|
19
19
|
import { resolveRuntimePermissionMode } from '../role/runtime-policy.js';
|
|
20
20
|
export class ModelScopeError extends Error {
|
|
@@ -35,20 +35,12 @@ export function normalizePeer(input) {
|
|
|
35
35
|
const raw = (input || '').trim();
|
|
36
36
|
if (!raw)
|
|
37
37
|
throw new ModelScopeError('INVALID_PEER', '--peer 不能为空');
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
throw new ModelScopeError('INVALID_PEER', `无法解析 --peer: ${raw}`);
|
|
45
|
-
}
|
|
46
|
-
if (!parsed.channelType || !parsed.channelId) {
|
|
47
|
-
throw new ModelScopeError('INVALID_PEER', `无法解析 --peer: ${raw}`);
|
|
48
|
-
}
|
|
49
|
-
return formatPeerKey(parsed.channelType, parsed.channelId);
|
|
38
|
+
try {
|
|
39
|
+
return normalizePeerKey(raw);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw new ModelScopeError('INVALID_PEER', `无法解析 --peer: ${raw}`);
|
|
50
43
|
}
|
|
51
|
-
return formatPeerKey('aun', raw);
|
|
52
44
|
}
|
|
53
45
|
// ── 作用域判定(CLI 写入目标)─────────────────────────────────────────────
|
|
54
46
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
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 { clearRuntimeBaseagentModelDefaults } from '../../agents/baseagent.js';
|
|
6
|
+
import { listSupportedBaseagents, clearRuntimeBaseagentModelDefaults } from '../../agents/baseagent.js';
|
|
7
7
|
import { buildModelRequestHeaders } from '../../agents/request-identity.js';
|
|
8
8
|
import { activeBaseagent } from './config-scope.js';
|
|
9
9
|
import { resolveEffective } from '../../config/config-manager.js';
|
|
@@ -80,10 +80,10 @@ const service = new ModelCatalogService({
|
|
|
80
80
|
legacyAliasFile: () => resolvePaths().claudeModelCache,
|
|
81
81
|
native: async (context) => (await import('../../agents/codex/catalog.js')).codexNativeCatalog(context),
|
|
82
82
|
});
|
|
83
|
-
const
|
|
83
|
+
const hostBaseagents = () => listSupportedBaseagents();
|
|
84
84
|
function resolveProviderCatalogBaseagent(serviceType, requested) {
|
|
85
85
|
const baseagent = requested ?? (['claude', 'codex', 'gemini'].includes(serviceType) ? serviceType : '');
|
|
86
|
-
if (baseagent && (!
|
|
86
|
+
if (baseagent && (!hostBaseagents().includes(baseagent)
|
|
87
87
|
|| !providerServiceTypesForBaseagent(baseagent).includes(serviceType))) {
|
|
88
88
|
throw new Error(`Baseagent ${baseagent} is incompatible with provider service ${serviceType}`);
|
|
89
89
|
}
|
|
@@ -170,8 +170,8 @@ export function resolveCatalogContext(self, ba) {
|
|
|
170
170
|
}
|
|
171
171
|
/** Query the catalog for a host-level default connection, without Agent scope. */
|
|
172
172
|
export async function getBaseagentCatalog(baseagent, options = {}) {
|
|
173
|
-
if (!
|
|
174
|
-
throw Object.assign(new Error(`Invalid baseagent: ${baseagent}. Valid: ${
|
|
173
|
+
if (!hostBaseagents().includes(baseagent)) {
|
|
174
|
+
throw Object.assign(new Error(`Invalid baseagent: ${baseagent}. Valid: ${hostBaseagents().join(', ')}`), { code: 'INVALID_ARGUMENT' });
|
|
175
175
|
}
|
|
176
176
|
const normalized = baseagent;
|
|
177
177
|
const snapshot = await getCatalog(undefined, normalized, options.refresh === true);
|
|
@@ -4,6 +4,7 @@ import { appendV1RequestPath } from '../../agents/request-identity.js';
|
|
|
4
4
|
import { resolveEffective, resolveEffectiveFieldWithSource } from '../../config/config-manager.js';
|
|
5
5
|
import { constrainResolvedModelForRole } from './model-permission.js';
|
|
6
6
|
import { getCatalog } from './model-catalog.js';
|
|
7
|
+
import { eligibleFallbackModels } from './model-fallback.js';
|
|
7
8
|
async function fetchWithTimeout(url, opts, timeoutMs) {
|
|
8
9
|
const controller = new AbortController();
|
|
9
10
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -172,6 +173,24 @@ export async function runModelCheck(input) {
|
|
|
172
173
|
log(configuredModel
|
|
173
174
|
? { label: '配置模型', ok: true, detail: `${configuredModel}(来源: ${configuredModelSource ?? '未知'})` }
|
|
174
175
|
: { label: '配置模型', ok: false, detail: '无法解析当前基座的模型' });
|
|
176
|
+
// 降级链的候选会被静默过滤(不在目录、effort 不支持、重复等),这里把过滤结果显式报出来。
|
|
177
|
+
const fallbackResolution = await eligibleFallbackModels({
|
|
178
|
+
selfAid: input.self,
|
|
179
|
+
baseagent: input.baseagent,
|
|
180
|
+
currentModel: configuredModel,
|
|
181
|
+
currentProvider: resolveEffective(selector, { cache: true }).baseagents?.[input.baseagent]?.provider,
|
|
182
|
+
isAllowed: () => true,
|
|
183
|
+
});
|
|
184
|
+
if (fallbackResolution.candidates.length || fallbackResolution.rejected.length) {
|
|
185
|
+
const admitted = fallbackResolution.candidates.length;
|
|
186
|
+
const dropped = fallbackResolution.rejected
|
|
187
|
+
.map(item => `${item.model ?? '<invalid>'}:${item.reason}`);
|
|
188
|
+
log({
|
|
189
|
+
label: '降级链',
|
|
190
|
+
ok: fallbackResolution.rejected.length === 0,
|
|
191
|
+
detail: `${admitted} 条生效${dropped.length ? `,丢弃 ${dropped.length} 条(${dropped.join('、')})` : ''}`,
|
|
192
|
+
});
|
|
193
|
+
}
|
|
175
194
|
const probeResults = [];
|
|
176
195
|
if (baseUrl) {
|
|
177
196
|
const aliases = new Map();
|
|
@@ -104,12 +104,23 @@ async function eligibleCandidates(input) {
|
|
|
104
104
|
const efforts = input.serviceType === 'text'
|
|
105
105
|
? catalog.models.find(entry => entry.id === resolvedModel)?.reasoningLevels ?? []
|
|
106
106
|
: catalogEfforts(catalog, resolvedModel, input.serviceType);
|
|
107
|
-
|
|
107
|
+
// 目录未声明任何推理强度(supports_effort=false 的模型):effort 无从校验,
|
|
108
|
+
// 保留候选并丢弃该字段,降级时走模型默认强度,而不是整条丢掉这条兜底。
|
|
109
|
+
const hasDeclaredEfforts = efforts.length > 0;
|
|
110
|
+
if (hasDeclaredEfforts && candidate.effort && !efforts.includes(candidate.effort)) {
|
|
108
111
|
rejected.push({ model: candidate.model, reason: 'unsupported_effort' });
|
|
109
112
|
continue;
|
|
110
113
|
}
|
|
111
114
|
seen.add(key);
|
|
112
|
-
|
|
115
|
+
const admitted = {
|
|
116
|
+
...candidate,
|
|
117
|
+
...(provider ? { provider } : {}),
|
|
118
|
+
model: resolvedModel,
|
|
119
|
+
};
|
|
120
|
+
// 未声明强度的模型上,显式保留 effort 会被当成"该模型确实支持这个强度"。
|
|
121
|
+
if (!hasDeclaredEfforts)
|
|
122
|
+
delete admitted.effort;
|
|
123
|
+
candidates.push(admitted);
|
|
113
124
|
}
|
|
114
125
|
return { candidates, rejected };
|
|
115
126
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { createHash, randomUUID } from 'crypto';
|
|
4
|
-
import { agentMdPath, agentOwnerBindingRejectionPath, ownershipCachePath
|
|
4
|
+
import { agentMdPath, agentOwnerBindingRejectionPath, ownershipCachePath } from '../../paths.js';
|
|
5
5
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
6
|
-
import { atomicReadJson } from '../../utils/atomic-write.js';
|
|
7
|
-
import { configuredOwnerList as readConfiguredOwnerList } from '../../config/owner-config.js';
|
|
8
6
|
import { logger, logOwnershipEvent, ownershipErrorCode } from '../../utils/logger.js';
|
|
9
7
|
import { hasTrustedPrincipal } from '../auth/authenticated-actor.js';
|
|
10
8
|
import { registerContent, verifyFile } from '../file-integrity/store.js';
|
|
@@ -65,9 +63,6 @@ export class OwnerResolver {
|
|
|
65
63
|
subjects = new Map();
|
|
66
64
|
authorizationChecks = new Map();
|
|
67
65
|
daemonAid;
|
|
68
|
-
/** Compatibility binding targets loaded from config; never an Owner authorization source. */
|
|
69
|
-
configuredOwners = new Map();
|
|
70
|
-
configuredOwnerFileRevision = new Map();
|
|
71
66
|
listeners = new Set();
|
|
72
67
|
updateListeners = new Set();
|
|
73
68
|
cacheFile;
|
|
@@ -196,6 +191,9 @@ export class OwnerResolver {
|
|
|
196
191
|
}
|
|
197
192
|
subject.view = { ...JSON.parse(JSON.stringify(cached)), connected: subject.view.connected };
|
|
198
193
|
this.rememberVerifiedRelation(subject);
|
|
194
|
+
// Restoring a restart snapshot changes readiness just like a network result.
|
|
195
|
+
// Cache hits must wake observers even when no consensus query runs.
|
|
196
|
+
this.notifyUpdate(subjectAid);
|
|
199
197
|
}
|
|
200
198
|
persistCache(subject, invalidate = false) {
|
|
201
199
|
// The daemon is the sole production writer. Short-lived CLI processes may read, never replace its snapshot.
|
|
@@ -250,47 +248,12 @@ export class OwnerResolver {
|
|
|
250
248
|
logger.warn(`[ownership] Cache write failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
251
249
|
}
|
|
252
250
|
}
|
|
253
|
-
setConfiguredOwners(subjectAid, owners) {
|
|
254
|
-
this.assertAid(subjectAid);
|
|
255
|
-
const normalized = [...new Set(owners
|
|
256
|
-
.map(owner => String(owner || '').trim())
|
|
257
|
-
.filter(owner => isValidAid(owner) && owner !== subjectAid))];
|
|
258
|
-
const previous = this.configuredOwners.get(subjectAid) ?? [];
|
|
259
|
-
if (JSON.stringify(previous) === JSON.stringify(normalized))
|
|
260
|
-
return;
|
|
261
|
-
if (normalized.length > 0)
|
|
262
|
-
this.configuredOwners.set(subjectAid, normalized);
|
|
263
|
-
else
|
|
264
|
-
this.configuredOwners.delete(subjectAid);
|
|
265
|
-
const subject = this.subjects.get(subjectAid);
|
|
266
|
-
// Retiring compatibility targets must not invalidate the freshly verified protocol Owner.
|
|
267
|
-
const removesConfirmedTargets = normalized.length === 0 && subject?.view.consensusStatus === 'consensus'
|
|
268
|
-
&& this.isCacheFresh(subject, OWNERSHIP_AUTHORIZATION_MAX_AGE_MS);
|
|
269
|
-
if (subject && !removesConfirmedTargets) {
|
|
270
|
-
this.invalidate(subject, 'Configured Owners changed; fresh consensus is required', true);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
setAgentConfiguredOwners(subjectAid, owners) {
|
|
274
|
-
this.assertAid(subjectAid);
|
|
275
|
-
if (subjectAid === this.daemonAid)
|
|
276
|
-
return;
|
|
277
|
-
this.setConfiguredOwners(subjectAid, owners);
|
|
278
|
-
}
|
|
279
|
-
configuredOwnerList(subjectAid) {
|
|
280
|
-
if (!subjectAid)
|
|
281
|
-
return [];
|
|
282
|
-
this.refreshConfiguredOwnersFromDisk(subjectAid);
|
|
283
|
-
return [...(this.configuredOwners.get(subjectAid) ?? [])];
|
|
284
|
-
}
|
|
285
251
|
isOwner(subjectAid, ownerAid) {
|
|
286
252
|
if (!subjectAid || !ownerAid)
|
|
287
253
|
return false;
|
|
288
254
|
if (subjectAid === ownerAid && this.owner(subjectAid) === subjectAid)
|
|
289
255
|
return true;
|
|
290
|
-
|
|
291
|
-
return true;
|
|
292
|
-
return !this.hasObservedProtocolConsensus(subjectAid)
|
|
293
|
-
&& this.configuredOwnerList(subjectAid).includes(ownerAid);
|
|
256
|
+
return this.protocolOwners(subjectAid).includes(ownerAid);
|
|
294
257
|
}
|
|
295
258
|
assertLocalSubject(subjectAid) {
|
|
296
259
|
this.assertAid(subjectAid);
|
|
@@ -477,7 +440,11 @@ export class OwnerResolver {
|
|
|
477
440
|
const protocol = this.protocolOwners(subjectAid);
|
|
478
441
|
if (protocol.length > 0 || this.hasObservedProtocolConsensus(subjectAid))
|
|
479
442
|
return protocol;
|
|
480
|
-
|
|
443
|
+
// Ownership is granted by the ownership protocol only. A configured value
|
|
444
|
+
// is a binding target and never an authorization source — not for Agents,
|
|
445
|
+
// and not for the daemon's own control identity. Until consensus exists the
|
|
446
|
+
// daemon has no Owner and its control surface stays closed.
|
|
447
|
+
return [];
|
|
481
448
|
}
|
|
482
449
|
protocolOwners(subjectAid) {
|
|
483
450
|
const owner = this.owner(subjectAid);
|
|
@@ -496,6 +463,7 @@ export class OwnerResolver {
|
|
|
496
463
|
primaryOwner(subjectAid) {
|
|
497
464
|
return this.owners(subjectAid)[0];
|
|
498
465
|
}
|
|
466
|
+
/** Owners already established by protocol evidence. Configured values never qualify. */
|
|
499
467
|
knownOwners(subjectAid) {
|
|
500
468
|
if (!subjectAid)
|
|
501
469
|
return [];
|
|
@@ -505,9 +473,7 @@ export class OwnerResolver {
|
|
|
505
473
|
const relation = this.subjects.get(subjectAid)?.view.relation;
|
|
506
474
|
if (relation?.consensusStatus === 'consensus' && relation.ownerAid)
|
|
507
475
|
return [relation.ownerAid];
|
|
508
|
-
|
|
509
|
-
return [];
|
|
510
|
-
return this.configuredOwnerList(subjectAid);
|
|
476
|
+
return [];
|
|
511
477
|
}
|
|
512
478
|
knownOwner(subjectAid) {
|
|
513
479
|
return this.knownOwners(subjectAid)[0];
|
|
@@ -515,16 +481,12 @@ export class OwnerResolver {
|
|
|
515
481
|
daemonOwners() {
|
|
516
482
|
return this.owners(this.daemonAid);
|
|
517
483
|
}
|
|
518
|
-
configuredRevision(subjectAid) {
|
|
519
|
-
return JSON.stringify(this.configuredOwnerList(subjectAid));
|
|
520
|
-
}
|
|
521
484
|
revision(subjectAid) {
|
|
522
485
|
const view = this.subjects.get(subjectAid)?.view;
|
|
523
486
|
return JSON.stringify([
|
|
524
487
|
view?.revision ?? 0,
|
|
525
488
|
this.owner(subjectAid),
|
|
526
489
|
view?.consensusStatus ?? 'unavailable',
|
|
527
|
-
this.configuredOwnerList(subjectAid),
|
|
528
490
|
]);
|
|
529
491
|
}
|
|
530
492
|
snapshot(subjectAid) {
|
|
@@ -545,7 +507,6 @@ export class OwnerResolver {
|
|
|
545
507
|
async refresh(subjectAid, options = {}) {
|
|
546
508
|
const subject = this.subject(subjectAid);
|
|
547
509
|
this.restoreCache(subjectAid, subject);
|
|
548
|
-
this.refreshConfiguredOwnersFromDisk(subjectAid);
|
|
549
510
|
const inFlight = subject.refreshing?.epoch === subject.epoch ? subject.refreshing : undefined;
|
|
550
511
|
const refreshing = inFlight?.promise;
|
|
551
512
|
const initialEpoch = subject.epoch;
|
|
@@ -567,14 +528,12 @@ export class OwnerResolver {
|
|
|
567
528
|
.filter(frame => !/\/core\/ownership\/owner-resolver\.[cm]?[jt]s:/.test(frame))
|
|
568
529
|
.map(frame => frame.match(/\/((?:src|dist)\/[a-zA-Z0-9_./-]+\.[cm]?[jt]s:\d+:\d+)/)?.[1])
|
|
569
530
|
.find(frame => !!frame);
|
|
570
|
-
const configuredOwners = this.configuredOwnerList(subjectAid);
|
|
571
531
|
const diagnostic = inFlight?.diagnostic ?? {
|
|
572
532
|
startedAt: performance.now(), source: options.source ?? 'direct', caller,
|
|
573
533
|
attemptId, processId: process.pid, connected: subject.view.connected,
|
|
574
534
|
sdkReady: subject.client?.isReady === true,
|
|
575
535
|
force: !!options.force, maxAgeMs, timeoutMs: this.options.timeoutMs ?? 8_000,
|
|
576
536
|
firstObservation: !subject.view.consensus, previousConsensusStatus: subject.view.consensusStatus,
|
|
577
|
-
configuredOwnerAid: configuredOwners[0], configuredOwnerCount: configuredOwners.length,
|
|
578
537
|
};
|
|
579
538
|
const promise = refreshing ?? this.refreshSubject(subjectAid, subject, attemptId, attemptedAt, diagnostic, options);
|
|
580
539
|
subject.refreshing = { epoch: subject.epoch, attemptId, attemptedAt, diagnostic, promise };
|
|
@@ -1207,8 +1166,6 @@ export class OwnerResolver {
|
|
|
1207
1166
|
for (const subjectAid of this.subjects.keys())
|
|
1208
1167
|
this.detachClient(subjectAid);
|
|
1209
1168
|
this.subjects.clear();
|
|
1210
|
-
this.configuredOwners.clear();
|
|
1211
|
-
this.configuredOwnerFileRevision.clear();
|
|
1212
1169
|
this.authorizationChecks.clear();
|
|
1213
1170
|
this.cacheEntries.clear();
|
|
1214
1171
|
this.cacheFile = undefined;
|
|
@@ -1758,8 +1715,6 @@ export class OwnerResolver {
|
|
|
1758
1715
|
const rootScope = this.options.cachePath?.() ?? ownershipCachePath();
|
|
1759
1716
|
if (this.rootScope && this.rootScope !== rootScope) {
|
|
1760
1717
|
this.subjects.clear();
|
|
1761
|
-
this.configuredOwners.clear();
|
|
1762
|
-
this.configuredOwnerFileRevision.clear();
|
|
1763
1718
|
this.authorizationChecks.clear();
|
|
1764
1719
|
}
|
|
1765
1720
|
this.rootScope = rootScope;
|
|
@@ -1838,34 +1793,6 @@ export class OwnerResolver {
|
|
|
1838
1793
|
now() {
|
|
1839
1794
|
return this.options.now?.() ?? Date.now();
|
|
1840
1795
|
}
|
|
1841
|
-
refreshConfiguredOwnersFromDisk(subjectAid) {
|
|
1842
|
-
const file = subjectAid === this.daemonAid
|
|
1843
|
-
? resolvePaths().daemonConfig
|
|
1844
|
-
: path.join(resolvePaths().agentsDir, subjectAid, 'config.json');
|
|
1845
|
-
let revision = 'missing';
|
|
1846
|
-
try {
|
|
1847
|
-
const stat = fs.statSync(file);
|
|
1848
|
-
revision = `${stat.size}:${stat.mtimeMs}`;
|
|
1849
|
-
}
|
|
1850
|
-
catch { }
|
|
1851
|
-
if (this.configuredOwnerFileRevision.get(subjectAid) === revision)
|
|
1852
|
-
return;
|
|
1853
|
-
const hadFileRevision = this.configuredOwnerFileRevision.has(subjectAid);
|
|
1854
|
-
this.configuredOwnerFileRevision.set(subjectAid, revision);
|
|
1855
|
-
if (revision === 'missing') {
|
|
1856
|
-
if (hadFileRevision)
|
|
1857
|
-
this.setConfiguredOwners(subjectAid, []);
|
|
1858
|
-
return;
|
|
1859
|
-
}
|
|
1860
|
-
try {
|
|
1861
|
-
const raw = atomicReadJson(file);
|
|
1862
|
-
this.setConfiguredOwners(subjectAid, readConfiguredOwnerList(raw));
|
|
1863
|
-
}
|
|
1864
|
-
catch {
|
|
1865
|
-
// The regular config loader reports malformed files; keep this optional
|
|
1866
|
-
// compatibility read fail-closed without interrupting ownership checks.
|
|
1867
|
-
}
|
|
1868
|
-
}
|
|
1869
1796
|
assertAid(aid) {
|
|
1870
1797
|
if (!isValidAid(aid) || aid.trim() !== aid)
|
|
1871
1798
|
throw new OwnershipError('INVALID_AID', `Invalid AID: ${aid}`);
|
|
@@ -1988,7 +1915,6 @@ export const getProtocolOwner = (subjectAid) => ownerResolver.owner(subjectAid);
|
|
|
1988
1915
|
export const getPrimaryOwner = (subjectAid) => ownerResolver.primaryOwner(subjectAid);
|
|
1989
1916
|
export const getProtocolOwners = (subjectAid) => ownerResolver.protocolOwners(subjectAid);
|
|
1990
1917
|
export const getOwners = (subjectAid) => ownerResolver.owners(subjectAid);
|
|
1991
|
-
export const getConfiguredOwners = (subjectAid) => ownerResolver.configuredOwnerList(subjectAid);
|
|
1992
1918
|
export const getDaemonOwners = () => ownerResolver.daemonOwners();
|
|
1993
1919
|
export function resolveContextOwner(selfAid, directoryOwnerAid) {
|
|
1994
1920
|
const ownerAid = selfAid ? getProtocolOwner(selfAid) : undefined;
|
package/dist/core/pack-auth.js
CHANGED
|
@@ -209,11 +209,18 @@ const PACK_OPERATIONS = {
|
|
|
209
209
|
// AID 级总闸:整机是否对外提供本 AID 的服务。
|
|
210
210
|
enable: 'switch',
|
|
211
211
|
disable: 'switch',
|
|
212
|
+
// 宿主模式总闸。与 enable/disable 同档:它虽然不改"接不接活",但决定脚本以
|
|
213
|
+
// 什么隔离形态执行(常驻进程跨调用共享内存),属于整机执行面决策,不是包级配置。
|
|
214
|
+
'host:enable': 'switch',
|
|
215
|
+
'host:disable': 'switch',
|
|
212
216
|
'pack:list': 'view',
|
|
213
217
|
'pack:add': 'manage',
|
|
214
218
|
'pack:remove': 'manage',
|
|
215
219
|
'pack:enable': 'manage',
|
|
216
220
|
'pack:disable': 'manage',
|
|
221
|
+
// ACL 加固:只改 services 树的 DACL,不碰内容,但属于改防护配置——
|
|
222
|
+
// 与 pack 同档,避免 member 自己去收/放权限。
|
|
223
|
+
'repair-acl': 'manage',
|
|
217
224
|
},
|
|
218
225
|
};
|
|
219
226
|
/** `pack` 需要带上子动作(list/add/remove/enable/disable),其余命令名本身就是操作键。 */
|
|
@@ -13,7 +13,7 @@ import fs from 'node:fs';
|
|
|
13
13
|
import path from 'node:path';
|
|
14
14
|
import { atomicWriteJson } from '../utils/atomic-write.js';
|
|
15
15
|
/** 包安装期间的运行时产物:不该被拷进新包,也不该被 `pack add` 覆盖。 */
|
|
16
|
-
const PACK_RUNTIME_ENTRIES = new Set(['ledger.jsonl', '.idempotency.jsonl', 'logs', '.state.json', '.index.md']);
|
|
16
|
+
export const PACK_RUNTIME_ENTRIES = new Set(['ledger.jsonl', '.idempotency.jsonl', 'logs', '.state.json', '.index.md']);
|
|
17
17
|
/** 包名:英文短横线/下划线,防止 `..` 或路径分隔符把写入引出目标根。 */
|
|
18
18
|
const PACK_NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
19
19
|
function assertPackName(name) {
|