evolcore 0.0.47 → 0.0.49
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 +90 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +143 -40
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +36 -17
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/msg/p2p.js +2 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +722 -295
- package/dist/channels/daemon.js +9 -25
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +44 -43
- package/dist/cli/directory.js +13 -2
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +9 -9
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/managed-command-guard.js +2 -0
- package/dist/cli/model.js +20 -5
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/quota.js +89 -0
- package/dist/cli/role.js +62 -17
- package/dist/cli/services-command.js +1 -0
- package/dist/cli/stats.js +3 -3
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-field-policy.js +71 -1
- package/dist/config/config-manager.js +13 -7
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +67 -12
- package/dist/config/providers-management.js +477 -51
- package/dist/config/resolved-config-op.js +3 -2
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +36 -26
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +37 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/cli-intent-parser.js +13 -0
- package/dist/core/command/command-handler.js +126 -87
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +67 -150
- package/dist/core/command/menu-protocol.js +31 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +8 -1
- package/dist/core/daemon-control.js +64 -8
- package/dist/core/daemon-lifecycle.js +16 -2
- package/dist/core/evolagent-registry.js +20 -3
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +3 -1
- package/dist/core/message/aun-ipc-sender.js +279 -107
- 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 +41 -2
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +140 -370
- package/dist/core/message/message-log.js +29 -0
- package/dist/core/message/message-queue.js +119 -15
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +580 -134
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- 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 +328 -50
- package/dist/core/pack-auth.js +3 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +106 -19
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/permission/services-path-acl.js +451 -0
- package/dist/core/permission/tool-policy.js +5 -1
- package/dist/core/relation/peer-identity.js +36 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-recovery-service.js +13 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/core/thread/topic-id.js +15 -0
- package/dist/directory/owner-directory-admission.js +12 -9
- package/dist/directory/owner-directory-cache.js +64 -28
- package/dist/directory/owner-directory-markdown.js +14 -2
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +112 -29
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +36 -6
- 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 +29 -3
- package/dist/event-center/runtime.js +106 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +96 -59
- package/dist/ipc.js +38 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +63 -0
- package/dist/outputs/protocol.js +103 -0
- package/dist/outputs/service.js +266 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +114 -5
- package/dist/services/ipc-operation.js +88 -15
- package/dist/services/pack-manager.js +13 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +2 -2
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +304 -23
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/quota-query.js +95 -0
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +21 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/host-info.js +100 -1
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +4 -2
- package/kits/docs/evolcore/aid.md +25 -0
- package/kits/docs/evolcore/config.md +16 -1
- package/kits/docs/evolcore/directory.md +30 -12
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/msg.md +9 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +124 -4
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +83 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/stats.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +12 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/agent-config.schema.20.json +24 -0
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +8 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/agent-output-cards/SKILL.md +57 -0
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +270 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +4 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +7 -5
- package/kits/templates/system-fragments/venue.md +11 -0
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +50 -11
- package/scripts/agent-template/shared/common.mjs +11 -6
- package/scripts/agent-template/shared/team-schema.json +6 -4
- package/scripts/agent-template/shared/template-contract.mjs +62 -11
- package/scripts/agent-template/shared/template-package.mjs +189 -21
- package/scripts/agent-template/shared/template-runtime.mjs +54 -6
- package/scripts/agent-template/shared/template.mjs +2 -2
- package/scripts/agent-template/team-pack.mjs +52 -14
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
|
@@ -34,7 +34,7 @@ export function isAgentOnlyModelField(fieldPath) {
|
|
|
34
34
|
return parts.length === 3
|
|
35
35
|
&& parts[0] === 'baseagents'
|
|
36
36
|
&& SUPPORTED_BASEAGENTS.has(parts[1])
|
|
37
|
-
&& (parts[2] === 'model' || parts[2] === 'effort' || parts[2] === 'reasoning');
|
|
37
|
+
&& (parts[2] === 'model' || parts[2] === 'effort' || parts[2] === 'reasoning' || parts[2] === 'fallback');
|
|
38
38
|
}
|
|
39
39
|
/** Baseagent selection is Agent-owned as well. */
|
|
40
40
|
export function isAgentOnlyBaseagentField(fieldPath) {
|
|
@@ -96,6 +96,15 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
96
96
|
const top = parts[0];
|
|
97
97
|
if (SENSITIVE_TOP_FIELDS.has(top))
|
|
98
98
|
return { class: 'sensitive' };
|
|
99
|
+
if (field === 'version')
|
|
100
|
+
return scalar(field, 'member-version', 'owner-only');
|
|
101
|
+
if (top === 'update') {
|
|
102
|
+
if (field === 'update')
|
|
103
|
+
return { ...readonlyObject('update'), access: 'owner-only' };
|
|
104
|
+
if (field === 'update.publisher')
|
|
105
|
+
return scalar('update', 'aid', 'owner-only');
|
|
106
|
+
return field === 'update.mode' ? scalar('update', 'update-mode', 'owner-only') : { class: 'unknown' };
|
|
107
|
+
}
|
|
99
108
|
if (top === 'Services') {
|
|
100
109
|
return parts.length === 3 && /^[A-Za-z0-9_-]+$/u.test(parts[1]) && ['provider', 'model', 'effort'].includes(parts[2])
|
|
101
110
|
? scalar(field, parts[2] === 'effort' ? 'effort' : 'string', 'owner-only')
|
|
@@ -115,6 +124,9 @@ export function resolveConfigFieldRule(fieldPath, scope) {
|
|
|
115
124
|
return scalar(permissionKey, 'string');
|
|
116
125
|
if ((leaf === 'effort' || leaf === 'reasoning') && parts.length === 3)
|
|
117
126
|
return scalar(permissionKey, 'effort');
|
|
127
|
+
// 降级链是模型选择的一部分:Agent 级可写,但每项都要能换供应商,故 owner-only。
|
|
128
|
+
if (leaf === 'fallback' && parts.length === 3)
|
|
129
|
+
return scalar(permissionKey, 'fallback-chain', 'owner-only');
|
|
118
130
|
if (baseagent === 'claude' && (leaf === 'agentProgressSummaries' || leaf === 'excludeDynamicSections') && parts.length === 3) {
|
|
119
131
|
return scalar(permissionKey, 'boolean');
|
|
120
132
|
}
|
|
@@ -281,6 +293,50 @@ export function relationFieldWriteOperation(fieldPath) {
|
|
|
281
293
|
return 'mentionmode.update';
|
|
282
294
|
return undefined;
|
|
283
295
|
}
|
|
296
|
+
const MAX_FALLBACK_ITEMS = 3;
|
|
297
|
+
const PROVIDER_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
298
|
+
/**
|
|
299
|
+
* 降级链的值是 JSON 数组,每项必须同时给出 provider / model / effort:
|
|
300
|
+
* 降级可能换用不同供应商的不同模型,缺任何一项都无法构造请求。
|
|
301
|
+
*/
|
|
302
|
+
function parseFallbackChainValue(fieldPath, raw) {
|
|
303
|
+
let parsed;
|
|
304
|
+
try {
|
|
305
|
+
parsed = JSON.parse(raw);
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return { ok: false, reason: `Config field ${fieldPath} requires a JSON array of {provider, model, effort}` };
|
|
309
|
+
}
|
|
310
|
+
if (!Array.isArray(parsed)) {
|
|
311
|
+
return { ok: false, reason: `Config field ${fieldPath} requires a JSON array of {provider, model, effort}` };
|
|
312
|
+
}
|
|
313
|
+
if (parsed.length > MAX_FALLBACK_ITEMS) {
|
|
314
|
+
return { ok: false, reason: `Config field ${fieldPath} accepts at most ${MAX_FALLBACK_ITEMS} fallback entries` };
|
|
315
|
+
}
|
|
316
|
+
const entries = [];
|
|
317
|
+
for (const [index, item] of parsed.entries()) {
|
|
318
|
+
if (!item || typeof item !== 'object' || Array.isArray(item)) {
|
|
319
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} must be an object` };
|
|
320
|
+
}
|
|
321
|
+
const extra = Object.keys(item)
|
|
322
|
+
.filter(key => !['provider', 'model', 'effort'].includes(key));
|
|
323
|
+
if (extra.length) {
|
|
324
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} has unsupported keys: ${extra.join(', ')}` };
|
|
325
|
+
}
|
|
326
|
+
const { provider, model, effort } = item;
|
|
327
|
+
if (typeof provider !== 'string' || !PROVIDER_ID_PATTERN.test(provider)) {
|
|
328
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} needs a provider id` };
|
|
329
|
+
}
|
|
330
|
+
if (typeof model !== 'string' || !model.trim()) {
|
|
331
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} needs a non-empty model` };
|
|
332
|
+
}
|
|
333
|
+
if (typeof effort !== 'string' || !EFFORTS.has(effort)) {
|
|
334
|
+
return { ok: false, reason: `Config field ${fieldPath} entry ${index} needs an effort of ${[...EFFORTS].join(', ')}` };
|
|
335
|
+
}
|
|
336
|
+
entries.push({ provider, model: model.trim(), effort });
|
|
337
|
+
}
|
|
338
|
+
return { ok: true, value: entries };
|
|
339
|
+
}
|
|
284
340
|
export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
285
341
|
const rule = resolveConfigFieldRule(fieldPath);
|
|
286
342
|
if (rule.class !== 'safe-scalar' || !rule.valueKind) {
|
|
@@ -290,6 +346,18 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
290
346
|
return { ok: false, reason: `Config field ${fieldPath} requires a string CLI value` };
|
|
291
347
|
const raw = rawValue.trim();
|
|
292
348
|
switch (rule.valueKind) {
|
|
349
|
+
case 'member-version':
|
|
350
|
+
return /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(rawValue)
|
|
351
|
+
? { ok: true, value: rawValue }
|
|
352
|
+
: { ok: false, reason: `Config field ${fieldPath} must be an explicit x.y.z version` };
|
|
353
|
+
case 'aid':
|
|
354
|
+
return isValidAid(rawValue)
|
|
355
|
+
? { ok: true, value: rawValue }
|
|
356
|
+
: { ok: false, reason: `Config field ${fieldPath} must be a valid AID` };
|
|
357
|
+
case 'update-mode':
|
|
358
|
+
return ['auto', 'manual', 'disabled'].includes(rawValue)
|
|
359
|
+
? { ok: true, value: rawValue }
|
|
360
|
+
: { ok: false, reason: `Config field ${fieldPath} must be auto, manual, or disabled` };
|
|
293
361
|
case 'string':
|
|
294
362
|
return raw ? { ok: true, value: raw } : { ok: false, reason: `Config field ${fieldPath} cannot be empty` };
|
|
295
363
|
case 'baseagent':
|
|
@@ -330,6 +398,8 @@ export function parseConfigFieldValue(fieldPath, rawValue) {
|
|
|
330
398
|
return EFFORTS.has(raw)
|
|
331
399
|
? { ok: true, value: raw }
|
|
332
400
|
: { ok: false, reason: `Config field ${fieldPath} must be one of ${[...EFFORTS].join(', ')}; use unset for auto` };
|
|
401
|
+
case 'fallback-chain':
|
|
402
|
+
return parseFallbackChainValue(fieldPath, raw);
|
|
333
403
|
case 'chatmode':
|
|
334
404
|
if (fieldPath.trim() === 'chatmode.group') {
|
|
335
405
|
return raw === 'proactive'
|
|
@@ -29,7 +29,7 @@ import { isAgentOnlyBaseagentField, isBehaviorConfigFieldPath } from './config-f
|
|
|
29
29
|
import { clearRoleStoreCache, isRoleName } from './role-store.js';
|
|
30
30
|
import { writeRoleDefinition, writeRoleRegistry } from './role-service.js';
|
|
31
31
|
import { normalizeRoleEffortCompat, normalizeRoleGroupChatmodeCompat } from './role-schema.js';
|
|
32
|
-
import { mutatePeerBookTransactionSync, resolvePeerAidKind } from './peer-book-store.js';
|
|
32
|
+
import { commitAgentConfigTransactionSync, mutatePeerBookTransactionSync, resolvePeerAidKind } from './peer-book-store.js';
|
|
33
33
|
import { DAEMON_SCHEMA_NAME } from '../product.js';
|
|
34
34
|
import { normalizeDaemonServices } from './daemon-services.js';
|
|
35
35
|
import { assertProviderSelectionWrite, resolveProviderModelSettings, validateProvidersFile } from './providers-config.js';
|
|
@@ -1032,11 +1032,7 @@ export function write(target, value, sel, opts = {}) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
const before = readTextOrNull(file);
|
|
1034
1034
|
const after = `${JSON.stringify(normalized, null, 2)}\n`;
|
|
1035
|
-
|
|
1036
|
-
selfAid: syncAid,
|
|
1037
|
-
actor: target === ConfigTarget.Agent ? 'agent-management-role-sync' : 'relation-management-role-sync',
|
|
1038
|
-
mutation: { type: 'sync-management-roles' },
|
|
1039
|
-
}, [{ file, before, after }]);
|
|
1035
|
+
commitAgentConfigTransactionSync(syncAid, [{ file, before, after }]);
|
|
1040
1036
|
if (target === ConfigTarget.Agent) {
|
|
1041
1037
|
ownerResolver.setAgentConfiguredOwners(syncAid, configuredOwnerList(normalized));
|
|
1042
1038
|
}
|
|
@@ -1303,6 +1299,12 @@ function validateProcessOnlyFields(target, value) {
|
|
|
1303
1299
|
if (target === ConfigTarget.Process || !value || typeof value !== 'object')
|
|
1304
1300
|
return [];
|
|
1305
1301
|
const errors = [];
|
|
1302
|
+
if (target === ConfigTarget.Defaults || target === ConfigTarget.Relation) {
|
|
1303
|
+
for (const field of ['version', 'update'])
|
|
1304
|
+
if (Object.prototype.hasOwnProperty.call(value, field)) {
|
|
1305
|
+
errors.push(`/${field} is only allowed in Agent config`);
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1306
1308
|
if (Object.prototype.hasOwnProperty.call(value, 'debug')) {
|
|
1307
1309
|
errors.push('/debug is only allowed in process config');
|
|
1308
1310
|
}
|
|
@@ -1596,13 +1598,15 @@ function stripStaticOwnerField(config) {
|
|
|
1596
1598
|
if (!config)
|
|
1597
1599
|
return config;
|
|
1598
1600
|
if (!Object.prototype.hasOwnProperty.call(config, 'owner')
|
|
1601
|
+
&& !Object.prototype.hasOwnProperty.call(config, 'version')
|
|
1602
|
+
&& !Object.prototype.hasOwnProperty.call(config, 'update')
|
|
1599
1603
|
&& !Object.prototype.hasOwnProperty.call(config, 'owners')
|
|
1600
1604
|
&& !Object.prototype.hasOwnProperty.call(config, 'admins')
|
|
1601
1605
|
&& !Object.prototype.hasOwnProperty.call(config, 'access')
|
|
1602
1606
|
&& !Object.prototype.hasOwnProperty.call(config, 'groupSlashRequireMentions')
|
|
1603
1607
|
&& !Object.prototype.hasOwnProperty.call(config, 'fullaccess'))
|
|
1604
1608
|
return config;
|
|
1605
|
-
const { owner: _owner, owners: _owners, admins: _admins, access: _access, groupSlashRequireMentions: _groupSlashRequireMentions, fullaccess: _fullaccess, ...rest } = config;
|
|
1609
|
+
const { owner: _owner, version: _memberVersion, update: _update, owners: _owners, admins: _admins, access: _access, groupSlashRequireMentions: _groupSlashRequireMentions, fullaccess: _fullaccess, ...rest } = config;
|
|
1606
1610
|
return rest;
|
|
1607
1611
|
}
|
|
1608
1612
|
function stripDefaultsLegacyModelFields(config) {
|
|
@@ -1656,6 +1660,8 @@ export function resolveEffective(sel, opts = {}) {
|
|
|
1656
1660
|
const effective = {
|
|
1657
1661
|
$schema_version: config.$schema_version ?? currentVersion('agent-config'),
|
|
1658
1662
|
aid: config.aid ?? sel.self ?? '',
|
|
1663
|
+
...(config.version !== undefined ? { version: config.version } : {}),
|
|
1664
|
+
...(config.update !== undefined ? { update: config.update } : {}),
|
|
1659
1665
|
enabled: config.enabled,
|
|
1660
1666
|
lifecycle: config.lifecycle,
|
|
1661
1667
|
initialized: config.initialized,
|
|
@@ -13,6 +13,7 @@ export function serviceRuntimeMode(service) {
|
|
|
13
13
|
return service.runtime?.mode ?? (service.name === 'ecweb' ? 'managed' : 'external');
|
|
14
14
|
}
|
|
15
15
|
export const DEFAULT_ECWEB_PORT = 42705;
|
|
16
|
+
export const DEFAULT_ECWEB_PROXY_VISIBILITY = 'public';
|
|
16
17
|
function isRecord(value) {
|
|
17
18
|
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
18
19
|
}
|
|
@@ -109,7 +110,7 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
109
110
|
};
|
|
110
111
|
services.push({ name, enabled: true, proxy });
|
|
111
112
|
}
|
|
112
|
-
if (legacyEcweb || legacyEcwebProxy) {
|
|
113
|
+
if (legacyEcweb || legacyEcwebProxy || legacyProxy?.enabled === false) {
|
|
113
114
|
const service = ecwebIndex >= 0
|
|
114
115
|
? services[ecwebIndex]
|
|
115
116
|
: {
|
|
@@ -117,7 +118,7 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
117
118
|
// The old ECWeb lifecycle switch and Service Proxy switch were
|
|
118
119
|
// independent. Preserve that distinction during migration: a
|
|
119
120
|
// proxy-only config must not start managing the local process.
|
|
120
|
-
enabled: legacyEcweb?.enabled === true,
|
|
121
|
+
enabled: legacyEcweb?.enabled === true || (!legacyEcweb && !legacyEcwebProxy),
|
|
121
122
|
};
|
|
122
123
|
if (legacyEcweb) {
|
|
123
124
|
if (service.enabled === undefined && typeof legacyEcweb.enabled === 'boolean')
|
|
@@ -129,6 +130,8 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
129
130
|
throw new Error('daemon.json.services[ecweb].proxy must be an object before legacy proxy settings can be migrated');
|
|
130
131
|
}
|
|
131
132
|
const proxy = { ...(service.proxy ?? {}) };
|
|
133
|
+
if (proxy.enabled === undefined && legacyProxy?.enabled === false)
|
|
134
|
+
proxy.enabled = false;
|
|
132
135
|
if (legacyEcwebProxy) {
|
|
133
136
|
if (proxy.enabled === undefined) {
|
|
134
137
|
proxy.enabled = legacyProxy?.enabled === true && legacyEcwebProxy.enabled !== false;
|
|
@@ -151,6 +154,7 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
151
154
|
if (proxy.metadata === undefined && isRecord(legacyEcwebProxy.metadata)) {
|
|
152
155
|
proxy.metadata = { ...legacyEcwebProxy.metadata };
|
|
153
156
|
}
|
|
157
|
+
// Preserve the former implicit policy when migrating existing services.
|
|
154
158
|
if (proxy.enabled === true && proxy.visibility === undefined)
|
|
155
159
|
proxy.visibility = 'private';
|
|
156
160
|
}
|
|
@@ -171,8 +175,28 @@ export function normalizeDaemonServices(raw, warn) {
|
|
|
171
175
|
export function findService(services, name) {
|
|
172
176
|
return (services ?? []).find((service) => service.name === name);
|
|
173
177
|
}
|
|
178
|
+
/** Runtime defaults only: reading these values never persists them. */
|
|
174
179
|
export function ecwebService(services) {
|
|
175
|
-
|
|
180
|
+
const service = findService(services, 'ecweb');
|
|
181
|
+
return {
|
|
182
|
+
...service,
|
|
183
|
+
name: 'ecweb',
|
|
184
|
+
enabled: service?.enabled ?? true,
|
|
185
|
+
port: service?.port ?? DEFAULT_ECWEB_PORT,
|
|
186
|
+
proxy: {
|
|
187
|
+
enabled: true,
|
|
188
|
+
source: 'instance',
|
|
189
|
+
serviceType: 'http',
|
|
190
|
+
visibility: DEFAULT_ECWEB_PROXY_VISIBILITY,
|
|
191
|
+
...service?.proxy,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
export function resolveDaemonServices(services) {
|
|
196
|
+
const ecweb = ecwebService(services);
|
|
197
|
+
return findService(services, 'ecweb')
|
|
198
|
+
? services.map(service => service.name === 'ecweb' ? ecweb : service)
|
|
199
|
+
: [ecweb, ...(services ?? [])];
|
|
176
200
|
}
|
|
177
201
|
export function upsertService(services, patch) {
|
|
178
202
|
const current = services ?? [];
|
|
@@ -196,3 +220,6 @@ export function setEcwebEnabled(services, enabled, port = ecwebService(services)
|
|
|
196
220
|
port,
|
|
197
221
|
});
|
|
198
222
|
}
|
|
223
|
+
export function prepareEcwebInitialization(services) {
|
|
224
|
+
return resolveDaemonServices(services);
|
|
225
|
+
}
|
|
@@ -17,7 +17,7 @@ import { resolvePaths } from '../paths.js';
|
|
|
17
17
|
import { saveAgent } from '../config-store.js';
|
|
18
18
|
import { buildModelRequestHeaders } from '../agents/request-identity.js';
|
|
19
19
|
import { appendV1RequestPath } from '../agents/request-identity.js';
|
|
20
|
-
import { resolvePriceRow } from '../stats/
|
|
20
|
+
import { resolvePriceRow } from '../stats/model-resolver.js';
|
|
21
21
|
import { ipcQuery } from '../ipc.js';
|
|
22
22
|
import { logger } from '../utils/logger.js';
|
|
23
23
|
import { resolveProviderServiceForBaseagent } from './providers.js';
|
|
@@ -423,7 +423,7 @@ export function gatewaySetPrice(args) {
|
|
|
423
423
|
try {
|
|
424
424
|
const dir = path.join(resolvePaths().root, 'data', 'stats');
|
|
425
425
|
fs.mkdirSync(dir, { recursive: true });
|
|
426
|
-
// 写入网关价格覆盖层(
|
|
426
|
+
// 写入网关价格覆盖层(model-resolver 的「优先级1 用户手动设置网关价」读此文件)。
|
|
427
427
|
// 注意:必须是 model-prices-gateway.jsonl,不是 model-prices.jsonl(后者是官方价表)。
|
|
428
428
|
const file = path.join(dir, 'model-prices-gateway.jsonl');
|
|
429
429
|
const mode = 0o600; // owner-only read/write for security
|
|
@@ -63,16 +63,18 @@ export function parseInvokeArgv(argv) {
|
|
|
63
63
|
const retriesRaw = options.get('--retries');
|
|
64
64
|
if (retriesRaw !== undefined && !/^\d+$/u.test(retriesRaw))
|
|
65
65
|
argumentError('--retries must be a non-negative integer');
|
|
66
|
-
//
|
|
66
|
+
// Preserve managed argv for authorization; parse duration syntax only after it is bound.
|
|
67
67
|
const timeoutRaw = options.get('--timeout-ms') ?? options.get('--timeout');
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const timeout = timeoutRaw === undefined ? undefined : /^(\d+)\s*(ms|s|m|h)?$/u.exec(timeoutRaw);
|
|
69
|
+
if (timeoutRaw !== undefined && !timeout)
|
|
70
|
+
argumentError('timeout must be a positive duration');
|
|
71
|
+
const timeoutMs = timeout ? Number(timeout[1]) * ({ ms: 1, s: 1000, m: 60_000, h: 3_600_000 }[timeout[2] || 'ms'] ?? 1) : undefined;
|
|
70
72
|
return {
|
|
71
73
|
providerId,
|
|
72
74
|
serviceType,
|
|
73
75
|
model: options.get('--model'),
|
|
74
76
|
out: options.get('--out'),
|
|
75
|
-
timeoutMs
|
|
77
|
+
timeoutMs,
|
|
76
78
|
retries: retriesRaw === undefined ? undefined : Number(retriesRaw),
|
|
77
79
|
dryRun: flags.has('--dry-run'),
|
|
78
80
|
input: hasInput ? options.get('--input') : undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomInt } from 'crypto';
|
|
2
2
|
import { isValidAid } from '../aun/aid/validation.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isPeerBindingEligible } from './peer-book.js';
|
|
4
4
|
import { formatContactAlias, normalizeContactChannelKey } from './peer-alias.js';
|
|
5
5
|
import { mutatePeerBookSync } from './peer-book-store.js';
|
|
6
6
|
export const CONTACT_BIND_CODE_TTL_MS = 10 * 60 * 1000;
|
|
@@ -34,9 +34,8 @@ export class ContactBindCodeRegistry {
|
|
|
34
34
|
return { ok: false, error: `invalid channelName: ${req.channelName}` };
|
|
35
35
|
if (!isValidAid(primaryId))
|
|
36
36
|
return { ok: false, error: `invalid primaryId: ${req.primaryId}` };
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return { ok: false, error: `only an active contact or Agent owner can bind an identity: ${primaryId}` };
|
|
37
|
+
if (!isPeerBindingEligible(selfAid, primaryId)) {
|
|
38
|
+
return { ok: false, error: `only an admitted principal can bind an identity: ${primaryId}` };
|
|
40
39
|
}
|
|
41
40
|
if (requestedCode && !/^\d{6}$/.test(requestedCode))
|
|
42
41
|
return { ok: false, error: 'binding code must be 6 digits' };
|