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
|
@@ -4,7 +4,7 @@ function normalizeOwnerValue(value) {
|
|
|
4
4
|
const owner = value.trim();
|
|
5
5
|
return owner || undefined;
|
|
6
6
|
}
|
|
7
|
-
/** Resolve the
|
|
7
|
+
/** Resolve the configured binding target, preferring the new scalar field. */
|
|
8
8
|
export function firstConfiguredOwner(value) {
|
|
9
9
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
10
10
|
return undefined;
|
|
@@ -21,7 +21,7 @@ export function firstConfiguredOwner(value) {
|
|
|
21
21
|
}
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
/** Runtime compatibility projection for
|
|
24
|
+
/** Runtime compatibility projection for binding-target input; this is not an authorization list. */
|
|
25
25
|
export function configuredOwnerList(value) {
|
|
26
26
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
27
27
|
return [];
|
|
@@ -2,7 +2,7 @@ import crypto from 'crypto';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { agentConfig, agentContactConfig, agentRelationsDir } from '../paths.js';
|
|
5
|
-
import { formatPeerKey, parsePeerKey } from '../core/relation/peer-identity.js';
|
|
5
|
+
import { formatPeerKey, parsePeerKey, readAunPeerKind } from '../core/relation/peer-identity.js';
|
|
6
6
|
import { hasTrustedPrincipal } from '../core/auth/authenticated-actor.js';
|
|
7
7
|
import { ConfigTarget, read } from './config-manager.js';
|
|
8
8
|
import { isManagementRole } from './builtin-roles.js';
|
|
@@ -12,18 +12,18 @@ import { resolvePrincipal } from './contact-book.js';
|
|
|
12
12
|
import { configuredOwnerList } from './owner-config.js';
|
|
13
13
|
import { tryParseChannelKey } from '../core/channel-loader.js';
|
|
14
14
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
15
|
-
import { isExplicitGroupId } from '../aun/group/index.js';
|
|
16
15
|
import { getOwners, ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
17
16
|
export function isAuthenticated(userId) {
|
|
18
17
|
return isValidAid(String(userId || '').trim());
|
|
19
18
|
}
|
|
19
|
+
/** Return the protocol Owner, or the legacy configured Owner only before any protocol relation exists. */
|
|
20
20
|
export function listStaticAgentOwners(aid, opts = {}) {
|
|
21
21
|
try {
|
|
22
22
|
const config = read(ConfigTarget.Agent, { self: aid }, { cache: opts.fresh !== true });
|
|
23
23
|
ownerResolver.setAgentConfiguredOwners(aid, configuredOwnerList(config));
|
|
24
24
|
}
|
|
25
25
|
catch { }
|
|
26
|
-
return
|
|
26
|
+
return ownerResolver.owners(aid);
|
|
27
27
|
}
|
|
28
28
|
/** Direct AUN relations with role=admin are the addressable Agent admin set. */
|
|
29
29
|
export function listStaticAgentAdmins(aid, opts = {}) {
|
|
@@ -46,8 +46,7 @@ export function listStaticAgentAdmins(aid, opts = {}) {
|
|
|
46
46
|
if (parsed.channelType !== 'aun' || !isValidAid(parsed.channelId))
|
|
47
47
|
continue;
|
|
48
48
|
const config = read(ConfigTarget.Relation, { self: aid, peerKey: entry.name }, { cache: opts.fresh !== true });
|
|
49
|
-
if (config
|
|
50
|
-
|| (!config?.targetKind && isExplicitGroupId(parsed.channelId)))
|
|
49
|
+
if (readAunPeerKind(aid, parsed.channelId, { relation: config }).kind !== 'private')
|
|
51
50
|
continue;
|
|
52
51
|
if (config?.role === 'admin')
|
|
53
52
|
admins.add(parsed.channelId);
|
|
@@ -78,9 +77,7 @@ export function isStaticAgentAdmin(aid, actorId) {
|
|
|
78
77
|
if (!aid || !isValidAid(actorId))
|
|
79
78
|
return false;
|
|
80
79
|
const config = read(ConfigTarget.Relation, { self: aid, peerKey: formatPeerKey('aun', actorId) }, { cache: true });
|
|
81
|
-
|
|
82
|
-
return false;
|
|
83
|
-
return config?.role === 'admin';
|
|
80
|
+
return readAunPeerKind(aid, actorId, { relation: config }).kind === 'private' && config?.role === 'admin';
|
|
84
81
|
}
|
|
85
82
|
export function addStaticAgentOwner(aid, ownerAid) {
|
|
86
83
|
throw new Error('Owner is protocol-managed; use ec aid bind');
|
|
@@ -186,6 +183,9 @@ function selectHighestRank(candidates, selfAid) {
|
|
|
186
183
|
return winner;
|
|
187
184
|
}
|
|
188
185
|
function resolveActorDirectRole(selfAid, actor, channelType, actorId) {
|
|
186
|
+
if (hasTrustedPrincipal(actor) && channelType !== 'aun'
|
|
187
|
+
&& readAunPeerKind(selfAid, actor.principalId).kind !== 'private')
|
|
188
|
+
return null;
|
|
189
189
|
const role = hasTrustedPrincipal(actor)
|
|
190
190
|
? readDirectRelationRole(selfAid, 'aun', actor.principalId, 'private')
|
|
191
191
|
: actor.principalStatus === 'unmapped'
|
|
@@ -216,11 +216,14 @@ function readDirectRelationRole(selfAid, channelType, channelId, expectedTargetK
|
|
|
216
216
|
return undefined;
|
|
217
217
|
const peerKey = formatPeerKey(channelType, channelId);
|
|
218
218
|
const config = read(ConfigTarget.Relation, { self: selfAid, peerKey }, { cache: true });
|
|
219
|
-
if (expectedTargetKind &&
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
if (expectedTargetKind && channelType === 'aun') {
|
|
220
|
+
const kind = readAunPeerKind(selfAid, channelId, { routeKind: expectedTargetKind, relation: config });
|
|
221
|
+
if (kind.kind !== expectedTargetKind)
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
else if (expectedTargetKind && config?.targetKind && config.targetKind !== expectedTargetKind) {
|
|
223
225
|
return undefined;
|
|
226
|
+
}
|
|
224
227
|
return config?.role;
|
|
225
228
|
}
|
|
226
229
|
function normalizeRelationRole(value, selfAid) {
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { TextDecoder } from 'node:util';
|
|
4
|
+
import { auditCommandAuthorization } from '../core/auth/authorization-audit.js';
|
|
5
|
+
import { createProvider, parseProviderImport, readProvidersSnapshot, updateProvider } from './providers-management.js';
|
|
6
|
+
export const PROVIDER_INPUT_LIMIT = 1024 * 1024;
|
|
7
|
+
export function providerArgumentError(message) {
|
|
8
|
+
throw Object.assign(new Error(message), { code: 'INVALID_ARGUMENT' });
|
|
9
|
+
}
|
|
10
|
+
export function assertProviderId(value) {
|
|
11
|
+
if (typeof value !== 'string' || !/^[A-Za-z0-9_-]+$/u.test(value)
|
|
12
|
+
|| ['__proto__', 'constructor', 'prototype'].includes(value)) {
|
|
13
|
+
providerArgumentError('A valid Provider ID is required');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function parseProviderCommand(argv) {
|
|
17
|
+
if (!Array.isArray(argv) || argv.some(value => typeof value !== 'string') || argv[0] !== 'provider') {
|
|
18
|
+
providerArgumentError('provider.op requires Provider argv');
|
|
19
|
+
}
|
|
20
|
+
const operation = argv[1];
|
|
21
|
+
if (!['list', 'show', 'create', 'import', 'update', 'delete'].includes(operation)) {
|
|
22
|
+
providerArgumentError('Unsupported Provider command');
|
|
23
|
+
}
|
|
24
|
+
const options = new Map();
|
|
25
|
+
const positional = [];
|
|
26
|
+
for (let index = 2; index < argv.length; index++) {
|
|
27
|
+
const token = argv[index];
|
|
28
|
+
if (!token.startsWith('-')) {
|
|
29
|
+
positional.push(token);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const separator = token.indexOf('=');
|
|
33
|
+
const name = separator < 0 ? token : token.slice(0, separator);
|
|
34
|
+
if (!['--file', '--format'].includes(name) || options.has(name))
|
|
35
|
+
providerArgumentError('Unknown or duplicate Provider option');
|
|
36
|
+
const value = separator < 0 ? argv[++index] : token.slice(separator + 1);
|
|
37
|
+
if (typeof value !== 'string' || !value || value.startsWith('--'))
|
|
38
|
+
providerArgumentError('Provider option requires a value');
|
|
39
|
+
options.set(name, value);
|
|
40
|
+
}
|
|
41
|
+
if (options.has('--format') && options.get('--format') !== 'json')
|
|
42
|
+
providerArgumentError('Only --format json is supported');
|
|
43
|
+
const needsId = ['show', 'update', 'delete'].includes(operation);
|
|
44
|
+
const needsFile = ['create', 'import', 'update'].includes(operation);
|
|
45
|
+
if (positional.length !== (needsId ? 1 : 0))
|
|
46
|
+
providerArgumentError('Unexpected or missing Provider ID');
|
|
47
|
+
if (needsId)
|
|
48
|
+
assertProviderId(positional[0]);
|
|
49
|
+
if (needsFile !== options.has('--file'))
|
|
50
|
+
providerArgumentError(needsFile ? '--file is required' : '--file is not supported by this command');
|
|
51
|
+
return { operation, providerId: positional[0], file: options.get('--file'), json: options.has('--format') };
|
|
52
|
+
}
|
|
53
|
+
export function parseProviderObject(text) {
|
|
54
|
+
if (typeof text !== 'string' || Buffer.byteLength(text, 'utf8') > PROVIDER_INPUT_LIMIT) {
|
|
55
|
+
providerArgumentError('Provider JSON must be UTF-8 text under 1 MiB');
|
|
56
|
+
}
|
|
57
|
+
let value;
|
|
58
|
+
try {
|
|
59
|
+
value = JSON.parse(text.replace(/^\uFEFF/u, ''));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
providerArgumentError('Provider configuration must be valid JSON');
|
|
63
|
+
}
|
|
64
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || !Object.hasOwn(value, 'common')) {
|
|
65
|
+
providerArgumentError('Expected one complete Provider object');
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
}
|
|
69
|
+
export function providerFailure(error) {
|
|
70
|
+
const failure = error;
|
|
71
|
+
if (failure?.code === 'NOT_FOUND')
|
|
72
|
+
return { ok: false, code: 'NOT_FOUND', error: 'Provider not found' };
|
|
73
|
+
if (failure?.code === 'CONFLICT' || failure?.statusCode === 409) {
|
|
74
|
+
return { ok: false, code: 'CONFLICT', error: 'Provider configuration changed or is still referenced', data: failure.data };
|
|
75
|
+
}
|
|
76
|
+
if (failure?.code === 'LOCK_TIMEOUT')
|
|
77
|
+
return { ok: false, code: 'CONFLICT', error: 'Provider configuration is busy' };
|
|
78
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: 'Invalid Provider configuration or arguments; expected one valid Provider under 1 MiB' };
|
|
79
|
+
}
|
|
80
|
+
function readProviderInput(file) {
|
|
81
|
+
if (!path.isAbsolute(file))
|
|
82
|
+
providerArgumentError('Provider input path must be absolute');
|
|
83
|
+
const descriptor = fs.openSync(file, 'r');
|
|
84
|
+
try {
|
|
85
|
+
const stat = fs.fstatSync(descriptor);
|
|
86
|
+
if (!stat.isFile() || stat.size > PROVIDER_INPUT_LIMIT)
|
|
87
|
+
providerArgumentError('Provider input must be a file under 1 MiB');
|
|
88
|
+
const buffer = Buffer.alloc(PROVIDER_INPUT_LIMIT + 1);
|
|
89
|
+
let length = 0;
|
|
90
|
+
while (length < buffer.length) {
|
|
91
|
+
const read = fs.readSync(descriptor, buffer, length, buffer.length - length, null);
|
|
92
|
+
if (!read)
|
|
93
|
+
break;
|
|
94
|
+
length += read;
|
|
95
|
+
}
|
|
96
|
+
if (length > PROVIDER_INPUT_LIMIT)
|
|
97
|
+
providerArgumentError('Provider input exceeds 1 MiB');
|
|
98
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(buffer.subarray(0, length));
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
fs.closeSync(descriptor);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export async function executeProviderOperation(command) {
|
|
105
|
+
try {
|
|
106
|
+
const parsed = parseProviderCommand(command.argv);
|
|
107
|
+
auditCommandAuthorization({ ts: Date.now(), source: 'control', operation: 'provider.' + parsed.operation,
|
|
108
|
+
scope: 'process', dangerous: parsed.operation !== 'list' && parsed.operation !== 'show',
|
|
109
|
+
actorId: 'local-control', role: 'daemon-owner', processRole: 'daemon-owner', dataScope: 'daemon',
|
|
110
|
+
isDaemonOwner: true, fromControlChannel: true, decision: 'allow', executed: false,
|
|
111
|
+
argsSummary: parsed.providerId ? { providerId: parsed.providerId } : {}, matchedRule: 'local-control-token' });
|
|
112
|
+
const text = parsed.file ? readProviderInput(parsed.file) : undefined;
|
|
113
|
+
const snapshot = readProvidersSnapshot();
|
|
114
|
+
if (parsed.operation === 'list')
|
|
115
|
+
return { ok: true, data: snapshot };
|
|
116
|
+
if (parsed.operation === 'show') {
|
|
117
|
+
const provider = snapshot.providers[parsed.providerId];
|
|
118
|
+
if (!provider)
|
|
119
|
+
throw Object.assign(new Error('Provider not found'), { code: 'NOT_FOUND' });
|
|
120
|
+
return { ok: true, data: { providerId: parsed.providerId, provider, revision: snapshot.revision } };
|
|
121
|
+
}
|
|
122
|
+
const value = parsed.operation === 'import' ? parseProviderImport(text)
|
|
123
|
+
: text === undefined ? undefined : parseProviderObject(text);
|
|
124
|
+
const data = parsed.operation === 'create' || parsed.operation === 'import'
|
|
125
|
+
? await createProvider({ revision: snapshot.revision, value })
|
|
126
|
+
: await updateProvider({ providerId: parsed.providerId, revision: snapshot.revision, value, remove: parsed.operation === 'delete' });
|
|
127
|
+
return { ok: true, data };
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
return providerFailure(error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { assertProviderId, parseProviderObject, PROVIDER_INPUT_LIMIT, providerArgumentError } from './provider-ipc-service.js';
|
|
2
|
+
export function validateProviderMenuRequest(request) {
|
|
3
|
+
try {
|
|
4
|
+
if ((request.name !== undefined && request.name !== 'provider')
|
|
5
|
+
|| (request.cmd !== undefined && request.cmd !== '/provider')
|
|
6
|
+
|| Object.keys(request).some(key => !['type', 'id', 'name', 'cmd', 'args', 'value', 'action'].includes(key))) {
|
|
7
|
+
providerArgumentError('Provider requests do not accept Agent addressing or extra fields');
|
|
8
|
+
}
|
|
9
|
+
const args = request.args;
|
|
10
|
+
if (!args || typeof args !== 'object' || Array.isArray(args) || args.scope !== 'process') {
|
|
11
|
+
providerArgumentError('Provider requests require args.scope="process"');
|
|
12
|
+
}
|
|
13
|
+
if (args.context !== undefined) {
|
|
14
|
+
const context = args.context;
|
|
15
|
+
if (!context || typeof context !== 'object' || Array.isArray(context)
|
|
16
|
+
|| context.kind !== 'process' || Object.keys(context).length !== 1) {
|
|
17
|
+
providerArgumentError('Provider requests only accept process context');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
let fields;
|
|
21
|
+
if (request.type === 'menu.query' && args.view === 'list')
|
|
22
|
+
fields = ['view'];
|
|
23
|
+
else if (request.type === 'menu.query' && args.view === 'detail')
|
|
24
|
+
fields = ['view', 'providerId'];
|
|
25
|
+
else if (request.type === 'menu.update' && args.resource === 'provider')
|
|
26
|
+
fields = ['resource', 'providerId', 'expectedRevision'];
|
|
27
|
+
else if (request.type === 'menu.action' && request.action === 'create')
|
|
28
|
+
fields = ['expectedRevision', 'provider'];
|
|
29
|
+
else if (request.type === 'menu.action' && request.action === 'import')
|
|
30
|
+
fields = ['expectedRevision', 'text'];
|
|
31
|
+
else if (request.type === 'menu.action' && request.action === 'delete')
|
|
32
|
+
fields = ['expectedRevision', 'providerId'];
|
|
33
|
+
else
|
|
34
|
+
return { code: 'NOT_SUPPORTED', message: 'Unsupported Provider Menu method, view, resource or action' };
|
|
35
|
+
if (Object.keys(args).some(key => !['scope', 'context', ...fields].includes(key)))
|
|
36
|
+
providerArgumentError('Unknown Provider argument');
|
|
37
|
+
if (fields.includes('providerId'))
|
|
38
|
+
assertProviderId(args.providerId);
|
|
39
|
+
if (fields.includes('expectedRevision') && (typeof args.expectedRevision !== 'string' || !/^[a-f0-9]{64}$/u.test(args.expectedRevision))) {
|
|
40
|
+
providerArgumentError('A valid args.expectedRevision is required');
|
|
41
|
+
}
|
|
42
|
+
if (request.type !== 'menu.action' && request.action !== undefined)
|
|
43
|
+
providerArgumentError('Unexpected Provider action');
|
|
44
|
+
if (request.type !== 'menu.update' && request.value !== undefined)
|
|
45
|
+
providerArgumentError('Unexpected Provider value');
|
|
46
|
+
if (request.type === 'menu.update')
|
|
47
|
+
parseProviderObject(request.value);
|
|
48
|
+
if (request.action === 'create')
|
|
49
|
+
parseProviderObject(JSON.stringify(args.provider));
|
|
50
|
+
if (request.action === 'import' && (typeof args.text !== 'string' || !args.text.trim()
|
|
51
|
+
|| Buffer.byteLength(args.text, 'utf8') > PROVIDER_INPUT_LIMIT))
|
|
52
|
+
providerArgumentError('Import requires JSON text under 1 MiB');
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return { code: 'INVALID_ARGUMENT', message: 'Invalid Provider request; use process scope, valid identifiers, revision and JSON under 1 MiB' };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -324,10 +324,9 @@ export function assertProviderSelectionWrite(next, previous, inherited, resolveM
|
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
326
|
const changed = !isDeepStrictEqual(block.provider, before.provider)
|
|
327
|
-
|| !isDeepStrictEqual(block.providerServiceType, before.providerServiceType)
|
|
328
327
|
|| !isDeepStrictEqual(block.model, before.model) || !isDeepStrictEqual(block.fallback, before.fallback);
|
|
329
328
|
if (changed) {
|
|
330
|
-
const serviceType =
|
|
329
|
+
const serviceType = providerServiceTypeForBaseagent(baseagent);
|
|
331
330
|
if (selection.provider !== undefined) {
|
|
332
331
|
const modelOverrides = resolveModelOverrides(selection.provider, serviceType);
|
|
333
332
|
if (selection.model && modelOverrides[selection.model]?.enabled === false) {
|
|
@@ -363,11 +362,17 @@ export function assertProviderSelectionWrite(next, previous, inherited, resolveM
|
|
|
363
362
|
const effective = { ...inherited.Services?.[serviceType], ...selection };
|
|
364
363
|
if (!Object.keys(effective).length)
|
|
365
364
|
continue;
|
|
366
|
-
const providerId =
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
365
|
+
const providerId = effective.provider === undefined
|
|
366
|
+
? undefined
|
|
367
|
+
: nonEmpty(effective.provider, `Services.${serviceType}.provider`);
|
|
368
|
+
const model = effective.model === undefined
|
|
369
|
+
? undefined
|
|
370
|
+
: nonEmpty(effective.model, `Services.${serviceType}.model`);
|
|
371
|
+
const modelOverrides = providerId
|
|
372
|
+
? resolveModelOverrides(providerId, providerServiceTypeForPurpose(serviceType))
|
|
373
|
+
: undefined;
|
|
374
|
+
if (model && modelOverrides?.[model]?.enabled === false) {
|
|
375
|
+
throw new Error(`Model ${model} is disabled for provider ${providerId}`);
|
|
371
376
|
}
|
|
372
377
|
for (const candidate of Array.isArray(effective.fallback) ? effective.fallback : []) {
|
|
373
378
|
const providerId = candidate?.provider ?? effective.provider;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_ECAGENT_BASE_URL, resolveAnthropicConfig, resolveEcagentConfig, resolveGoogleConfig, resolveOpenaiConfig, } from '../agents/baseagent.js';
|
|
2
2
|
import { ConfigTarget, read } from './config-manager.js';
|
|
3
|
-
import {
|
|
4
|
-
import { providerNameFromBaseUrlIfStatic, providerServiceTypeForBaseagent, resolveProviderServiceForBaseagent, validateProvidersFile } from './providers-config.js';
|
|
3
|
+
import { providerNameFromBaseUrlIfStatic, providerServiceTypeForBaseagent, validateProvidersFile } from './providers-config.js';
|
|
5
4
|
const IMPORTABLE_BASEAGENTS = ['claude', 'codex', 'gemini', 'ecagent'];
|
|
6
5
|
function resolveConnection(baseagent, config, projectPath) {
|
|
7
6
|
if (baseagent === 'claude')
|
|
@@ -18,28 +17,11 @@ function resolveConnection(baseagent, config, projectPath) {
|
|
|
18
17
|
export function providerFromBaseagent(baseagent) {
|
|
19
18
|
if (!IMPORTABLE_BASEAGENTS.includes(baseagent))
|
|
20
19
|
throw new Error('Invalid baseagent');
|
|
21
|
-
const source = read(ConfigTarget.Defaults, undefined, { cache: false, expand: true });
|
|
22
20
|
const selected = baseagent;
|
|
23
|
-
const
|
|
24
|
-
if (block?.provider !== undefined) {
|
|
25
|
-
const providers = readProvidersFile().providers;
|
|
26
|
-
const provider = Object.hasOwn(providers, block.provider) ? providers[block.provider] : undefined;
|
|
27
|
-
if (!provider)
|
|
28
|
-
throw new Error('Source baseagent references a missing Provider');
|
|
29
|
-
const resolved = resolveProviderServiceForBaseagent(block.provider, selected, block.providerServiceType, { providers });
|
|
30
|
-
const serviceType = resolved.serviceType;
|
|
31
|
-
const service = provider.services?.[serviceType];
|
|
32
|
-
if (!service)
|
|
33
|
-
throw new Error('Source Provider does not support the selected baseagent');
|
|
34
|
-
if (!provider.common.apiKey?.trim())
|
|
35
|
-
throw new Error('Source baseagent has no API key / token');
|
|
36
|
-
return structuredClone({ name: provider.name || providerNameFromBaseUrlIfStatic(provider.common.baseUrl), common: provider.common, services: { [serviceType]: service } });
|
|
37
|
-
}
|
|
21
|
+
const source = read(ConfigTarget.Defaults, undefined, { cache: false });
|
|
38
22
|
const serviceType = providerServiceTypeForBaseagent(selected);
|
|
39
|
-
const config = { agents:
|
|
23
|
+
const config = { agents: {} };
|
|
40
24
|
const connection = resolveConnection(selected, config, source?.projects?.defaultPath);
|
|
41
|
-
if (connection.useVertex)
|
|
42
|
-
throw new Error('Vertex AI settings cannot be imported as a Gemini API-key Provider');
|
|
43
25
|
if (!connection.apiKey?.trim() || /your-|placeholder|<redacted>/u.test(connection.apiKey))
|
|
44
26
|
throw new Error('Source baseagent has no valid API key / token');
|
|
45
27
|
const defaultBaseUrls = {
|
|
@@ -1,10 +1,78 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path, { posix } from 'node:path';
|
|
3
4
|
import { resolvePaths } from '../paths.js';
|
|
4
5
|
import { ConfigTarget, mutateConfig } from './config-manager.js';
|
|
6
|
+
import { atomicReadJson } from '../utils/atomic-write.js';
|
|
5
7
|
import { readProvidersFile, validateProvidersFile } from './providers.js';
|
|
6
8
|
import { providerEnvironmentVariable, providerNameFromBaseUrlIfStatic, resolveProviderService, resolveProviderServiceForBaseagent } from './providers-config.js';
|
|
7
9
|
export const PROVIDER_SECRET_MASK = '<redacted>';
|
|
10
|
+
function providerReferences(providerId, providerFile) {
|
|
11
|
+
const root = path.dirname(path.resolve(providerFile));
|
|
12
|
+
const agentsDir = path.join(root, 'agents');
|
|
13
|
+
const candidates = [path.join(agentsDir, 'defaults.json')];
|
|
14
|
+
const directories = (directory) => {
|
|
15
|
+
try {
|
|
16
|
+
return fs.readdirSync(directory, { withFileTypes: true }).filter(entry => entry.isDirectory() || entry.isSymbolicLink());
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
if (error.code === 'ENOENT')
|
|
20
|
+
return [];
|
|
21
|
+
throw Object.assign(new Error('Cannot verify Provider reference directories'), {
|
|
22
|
+
code: 'CONFLICT', statusCode: 409,
|
|
23
|
+
data: { kind: 'reference_check_failed', file: path.relative(root, directory).replace(/\\/g, '/') },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
for (const agent of directories(agentsDir)) {
|
|
28
|
+
candidates.push(path.join(agentsDir, agent.name, 'config.json'));
|
|
29
|
+
for (const relation of directories(path.join(agentsDir, agent.name, 'relations'))) {
|
|
30
|
+
candidates.push(path.join(agentsDir, agent.name, 'relations', relation.name, 'config.json'));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const references = [];
|
|
34
|
+
const visit = (value, fieldPath, file) => {
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
value.forEach((item, index) => visit(item, fieldPath + '[' + index + ']', file));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!value || typeof value !== 'object')
|
|
40
|
+
return;
|
|
41
|
+
for (const [key, child] of Object.entries(value)) {
|
|
42
|
+
const childPath = fieldPath + '.' + key;
|
|
43
|
+
if (key === 'provider' && child === providerId)
|
|
44
|
+
references.push({ file, path: childPath });
|
|
45
|
+
visit(child, childPath, file);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
for (const file of candidates) {
|
|
49
|
+
try {
|
|
50
|
+
const value = atomicReadJson(file);
|
|
51
|
+
if (value === null && !fs.existsSync(file))
|
|
52
|
+
continue;
|
|
53
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
54
|
+
throw new Error();
|
|
55
|
+
for (const field of ['baseagents', 'agents', 'Services', 'decision_model']) {
|
|
56
|
+
visit(value[field], field, path.relative(root, file).replace(/\\/g, '/'));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw Object.assign(new Error('Cannot verify Provider references; repair the configuration before deleting'), {
|
|
61
|
+
code: 'CONFLICT', statusCode: 409,
|
|
62
|
+
data: { kind: 'reference_check_failed', file: path.relative(root, file).replace(/\\/g, '/') },
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return references;
|
|
67
|
+
}
|
|
68
|
+
function assertProviderUnreferenced(providerId, file) {
|
|
69
|
+
const references = providerReferences(providerId, file);
|
|
70
|
+
if (references.length) {
|
|
71
|
+
throw Object.assign(new Error('Provider is still referenced'), {
|
|
72
|
+
code: 'CONFLICT', statusCode: 409, data: { kind: 'provider_referenced', providerId, references },
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
8
76
|
function revisionValue(value) {
|
|
9
77
|
if (Array.isArray(value))
|
|
10
78
|
return value.map(revisionValue);
|
|
@@ -85,9 +153,13 @@ export async function updateProvider(input, file = resolvePaths().providersConfi
|
|
|
85
153
|
const result = mutateConfig(ConfigTarget.Providers, { providerFile: file }, config => {
|
|
86
154
|
const current = config;
|
|
87
155
|
if (providersRevision(current) !== input.revision) {
|
|
88
|
-
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { statusCode: 409 });
|
|
156
|
+
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { code: 'CONFLICT', statusCode: 409, data: { kind: 'revision_conflict' } });
|
|
157
|
+
}
|
|
158
|
+
if (!Object.hasOwn(current.providers, input.providerId)) {
|
|
159
|
+
throw Object.assign(new Error(`Provider not found: ${input.providerId}`), { code: 'NOT_FOUND', statusCode: 404 });
|
|
89
160
|
}
|
|
90
161
|
if (input.remove) {
|
|
162
|
+
assertProviderUnreferenced(input.providerId, file);
|
|
91
163
|
current.nextId = nextProviderSequence(current);
|
|
92
164
|
delete current.providers[input.providerId];
|
|
93
165
|
}
|
|
@@ -178,7 +250,7 @@ export async function createProvider(input, file = resolvePaths().providersConfi
|
|
|
178
250
|
const result = mutateConfig(ConfigTarget.Providers, { providerFile: file }, config => {
|
|
179
251
|
const current = config;
|
|
180
252
|
if (providersRevision(current) !== input.revision) {
|
|
181
|
-
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { statusCode: 409 });
|
|
253
|
+
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { code: 'CONFLICT', statusCode: 409, data: { kind: 'revision_conflict' } });
|
|
182
254
|
}
|
|
183
255
|
const sequence = nextProviderSequence(current);
|
|
184
256
|
const providerId = `provider-${sequence}`;
|
|
@@ -270,7 +342,7 @@ export async function saveProviderChanges(input, file = resolvePaths().providers
|
|
|
270
342
|
const result = mutateConfig(ConfigTarget.Providers, { providerFile: file }, config => {
|
|
271
343
|
const current = config;
|
|
272
344
|
if (providersRevision(current) !== input.revision) {
|
|
273
|
-
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { statusCode: 409 });
|
|
345
|
+
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { code: 'CONFLICT', statusCode: 409, data: { kind: 'revision_conflict' } });
|
|
274
346
|
}
|
|
275
347
|
const providerIds = {};
|
|
276
348
|
const originalIds = new Set(Object.keys(current.providers));
|
|
@@ -281,6 +353,7 @@ export async function saveProviderChanges(input, file = resolvePaths().providers
|
|
|
281
353
|
throw new Error(change.create ? 'Provider already exists' : 'Provider not found');
|
|
282
354
|
}
|
|
283
355
|
if (change.remove) {
|
|
356
|
+
assertProviderUnreferenced(change.providerId, file);
|
|
284
357
|
delete current.providers[change.providerId];
|
|
285
358
|
continue;
|
|
286
359
|
}
|
|
@@ -307,7 +380,7 @@ export async function importOrMergeBaseagentProvider(input, file = resolvePaths(
|
|
|
307
380
|
const result = mutateConfig(ConfigTarget.Providers, { providerFile: file }, config => {
|
|
308
381
|
const current = config;
|
|
309
382
|
if (providersRevision(current) !== input.revision) {
|
|
310
|
-
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { statusCode: 409 });
|
|
383
|
+
throw Object.assign(new Error('Providers changed after loading; reload before saving'), { code: 'CONFLICT', statusCode: 409, data: { kind: 'revision_conflict' } });
|
|
311
384
|
}
|
|
312
385
|
const importedHost = providerHostname(imported.common.baseUrl);
|
|
313
386
|
const match = importedHost
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeCliArgv } from '../cli/cli-argv.js';
|
|
2
2
|
import { parseConfigSelector } from '../cli/config-selector.js';
|
|
3
3
|
import { parseConfigFieldValue, resolveConfigFieldRule, } from './config-field-policy.js';
|
|
4
|
+
import { isAgentOnlyBaseagentField } from './config-field-policy.js';
|
|
4
5
|
import { ConfigError, routeFieldPath } from './config-manager.js';
|
|
5
6
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
6
7
|
const SELECTOR_OPTIONS = {
|
|
@@ -93,6 +94,9 @@ function resolveFieldCommand(argv, subcommand, options = {}) {
|
|
|
93
94
|
if (field === 'sessionLoop' || field.startsWith('sessionLoop.')) {
|
|
94
95
|
return { ok: false, code: 'SESSION_LOOP_MANAGED', reason: 'sessionLoop is managed through the dedicated /loop or session Menu entry' };
|
|
95
96
|
}
|
|
97
|
+
if (field === 'sessionFullAccess' || field.startsWith('sessionFullAccess.')) {
|
|
98
|
+
return { ok: false, code: 'SESSION_FULLACCESS_MANAGED', reason: 'sessionFullAccess is managed through the dedicated /fa or session Menu entry' };
|
|
99
|
+
}
|
|
96
100
|
if (field === 'permissionMode') {
|
|
97
101
|
return {
|
|
98
102
|
ok: false,
|
|
@@ -129,6 +133,9 @@ function resolveFieldCommand(argv, subcommand, options = {}) {
|
|
|
129
133
|
};
|
|
130
134
|
}
|
|
131
135
|
const fieldRule = resolveConfigFieldRule(field, selector.scope);
|
|
136
|
+
if (selector.scope === 'relation' && subcommand !== 'get' && isAgentOnlyBaseagentField(field)) {
|
|
137
|
+
return { ok: false, code: 'SCOPE_MISMATCH', reason: `${field} 只支持 Agent scope,请移除 --peer 后操作` };
|
|
138
|
+
}
|
|
132
139
|
if (subcommand !== 'get' && fieldRule.class === 'safe-readonly-object') {
|
|
133
140
|
return {
|
|
134
141
|
ok: false,
|
|
@@ -145,7 +152,10 @@ function resolveFieldCommand(argv, subcommand, options = {}) {
|
|
|
145
152
|
? subcommand === 'get' ? 'config.read' : 'config.write'
|
|
146
153
|
: `config.${subcommand}`;
|
|
147
154
|
let route;
|
|
148
|
-
const
|
|
155
|
+
const relationAgentRead = subcommand === 'get'
|
|
156
|
+
&& selector.scope === 'relation'
|
|
157
|
+
&& isAgentOnlyBaseagentField(field);
|
|
158
|
+
const routeRequired = subcommand !== 'get' || (!isManagementOperation && !relationAgentRead);
|
|
149
159
|
try {
|
|
150
160
|
route = routeFieldPath(field, selector.scope);
|
|
151
161
|
}
|