evolcore 0.0.43-test.5 → 0.0.43-test.7
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 +95 -0
- package/bin/ecmsg.js +281 -81
- package/dist/agents/baseagent-availability.js +20 -5
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +19 -4
- package/dist/agents/codex/app-server-client.js +36 -3
- package/dist/agents/codex-runner.js +75 -8
- package/dist/aun/group/invite-service.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/aun/service-proxy.js +18 -6
- package/dist/channels/aun.js +306 -30
- package/dist/cli/agent-create.js +18 -8
- package/dist/cli/aun-commands.js +9 -1
- package/dist/cli/daemon-commands.js +34 -65
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +38 -3
- package/dist/cli/events-command.js +73 -0
- package/dist/cli/index.js +31 -14
- package/dist/cli/init.js +75 -0
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/provider-command.js +1 -1
- package/dist/cli/restart-monitor.js +67 -50
- package/dist/cli/services-command.js +111 -0
- package/dist/cli/task-context.js +38 -1
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +6 -2
- package/dist/cli/watch-logs.js +6 -4
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +6 -4
- package/dist/config/builtin-roles.js +2 -2
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +1 -8
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/provider-identity-migration.js +92 -17
- package/dist/config/provider-local-sync.js +2 -0
- package/dist/config/providers-config.js +13 -0
- package/dist/config/providers-management.js +100 -10
- package/dist/config/role-service.js +8 -8
- package/dist/config/role-store.js +22 -22
- package/dist/config/schema-migration.js +86 -88
- package/dist/config/snapshot.js +70 -41
- package/dist/config-store.js +2 -1
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +146 -15
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-catalog.js +20 -0
- package/dist/core/baseagent-loader.js +75 -42
- package/dist/core/channel-loader.js +45 -13
- package/dist/core/channel-runtime.js +116 -45
- package/dist/core/command/agent-control.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +58 -16
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +338 -0
- package/dist/core/command/menu-catalog.js +8 -0
- package/dist/core/command/menu-handler.js +206 -87
- package/dist/core/command/menu-protocol.js +142 -22
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/role-menu.js +27 -15
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +45 -15
- package/dist/core/daemon-lifecycle.js +478 -75
- package/dist/core/handoff/dispatcher.js +9 -3
- package/dist/core/handoff/runtime.js +130 -42
- package/dist/core/handoff/store.js +190 -2
- package/dist/core/handoff/types.js +5 -0
- package/dist/core/initialization/service.js +4 -4
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +51 -11
- package/dist/core/lifecycle-notice.js +10 -4
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +149 -19
- package/dist/core/message/im-renderer.js +28 -84
- package/dist/core/message/message-bridge.js +57 -4
- package/dist/core/message/message-queue.js +46 -4
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +4 -10
- package/dist/core/message/response-engine.js +163 -52
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +55 -7
- package/dist/core/ownership/owner-resolver.js +8 -0
- package/dist/core/permission/ec-command-parser.js +14 -3
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/session/adapters/claude-session-file-adapter.js +24 -0
- package/dist/core/session/adapters/codex-session-file-adapter.js +80 -0
- package/dist/core/session/adapters/ecagent-session-file-adapter.js +22 -0
- package/dist/core/session/adapters/gemini-session-file-adapter.js +39 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +163 -3
- package/dist/core/session/session-idle-monitor.js +9 -1
- package/dist/core/session/session-manager.js +36 -2
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/directory/owner-directory-admission.js +42 -30
- package/dist/directory/owner-directory-cache.js +143 -126
- package/dist/directory/owner-directory-query-operation.js +9 -8
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +14 -8
- package/dist/ecweb/runtime/supervisor.js +62 -30
- package/dist/event-center/admission-materializer.js +114 -0
- package/dist/event-center/bus-gate.js +136 -0
- package/dist/event-center/bus-host.js +290 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +100 -0
- package/dist/event-center/client-factory.js +50 -0
- package/dist/event-center/daemon.js +45 -0
- package/dist/event-center/directory-source.js +53 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +63 -0
- package/dist/event-center/ipc-operation.js +308 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +202 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +238 -0
- package/dist/event-center/runtime.js +641 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +35 -0
- package/dist/event-center/validation.js +413 -0
- package/dist/index.js +751 -268
- package/dist/ipc.js +66 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +43 -18
- package/dist/proxy/service-supervisor.js +78 -35
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +458 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +204 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +95 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +21 -1
- package/dist/trigger/audit.js +19 -4
- package/dist/trigger/authorization.js +14 -5
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/history.js +176 -7
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/manager.js +1 -3
- package/dist/trigger/scheduler.js +78 -5
- package/dist/trigger/script-sandbox.js +118 -22
- package/dist/utils/cross-platform.js +175 -13
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/host-info.js +11 -8
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +48 -0
- package/dist/utils/process-introspect.js +109 -10
- package/dist/utils/startup-trace.js +222 -44
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +10 -17
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +5 -2
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/ctl.md +2 -1
- package/kits/docs/evolcore/event-center.md +207 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +3 -2
- package/kits/docs/evolcore/group.md +2 -2
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-exec-schema-commands.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +21 -0
- package/kits/docs/evolcore/msg.md +27 -8
- package/kits/docs/evolcore/provider.md +23 -3
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +277 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/eck_manifest.json +45 -7
- package/kits/eck_message_manifest.json +3 -3
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +5 -6
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/daemon.schema.1.json +5 -0
- package/kits/schemas/daemon.schema.2.json +5 -0
- package/kits/schemas/daemon.schema.3.json +2 -1
- package/kits/schemas/daemon.schema.4.json +2 -1
- package/kits/schemas/daemon.schema.5.json +2 -1
- package/kits/schemas/daemon.schema.6.json +1 -1
- package/kits/schemas/daemon.schema.7.json +1 -1
- package/kits/schemas/daemon.schema.8.json +2 -1
- package/kits/schemas/daemon.schema.9.json +2 -1
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/schemas/role-registry.schema.1.json +2 -2
- package/kits/schemas/single-session.schema.1.json +1 -1
- package/kits/schemas/single-session.schema.2.json +1 -1
- package/kits/schemas/single-session.schema.3.json +1 -1
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-group/SKILL.md +8 -5
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +9 -7
- package/kits/templates/system-fragments/reply.md +2 -6
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/templates/system-fragments/thread.md +11 -9
- package/package.json +5 -6
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
package/dist/cli/init.js
CHANGED
|
@@ -100,6 +100,72 @@ function buildDefaults(chosen, available, projectsDefaultPath) {
|
|
|
100
100
|
function writeDefaults(chosen, available, projectsDefaultPath) {
|
|
101
101
|
saveDefaultsSafe(buildDefaults(chosen, available, projectsDefaultPath));
|
|
102
102
|
}
|
|
103
|
+
export async function importProvidersForCliInit(available, options = {}) {
|
|
104
|
+
const { providerFromBaseagent } = await import('../config/providers-import.js');
|
|
105
|
+
const { importOrMergeBaseagentProvider, readProvidersSnapshot } = await import('../config/providers-management.js');
|
|
106
|
+
const { readProvidersFile } = await import('../config/providers.js');
|
|
107
|
+
const { resolveProviderId, resolveProviderServiceForBaseagent } = await import('../config/providers-config.js');
|
|
108
|
+
const { ConfigTarget, mutateConfig } = await import('../config/config-manager.js');
|
|
109
|
+
const imported = [];
|
|
110
|
+
const warnings = [];
|
|
111
|
+
for (const baseagent of available) {
|
|
112
|
+
let value;
|
|
113
|
+
try {
|
|
114
|
+
value = (options.source ?? providerFromBaseagent)(baseagent);
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
warnings.push({ baseagent, code: 'LOCAL_PROVIDER_SOURCE_UNAVAILABLE' });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
const result = await importOrMergeBaseagentProvider({ revision: readProvidersSnapshot().revision, value });
|
|
122
|
+
imported.push({ baseagent, providerId: result.providerId, merged: result.merged });
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
const code = error.code;
|
|
126
|
+
warnings.push({ baseagent, code: ['PROVIDER_CONFLICT', 'PROVIDER_ID_COLLISION', 'CONFLICT'].includes(code ?? '') ? code : 'PROVIDER_IMPORT_FAILED' });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const snapshot = readProvidersSnapshot();
|
|
130
|
+
const registry = readProvidersFile();
|
|
131
|
+
mutateConfig(ConfigTarget.Defaults, undefined, defaults => {
|
|
132
|
+
if (readProvidersSnapshot().revision !== snapshot.revision)
|
|
133
|
+
throw new Error('Providers changed during CLI initialization; retry');
|
|
134
|
+
defaults.baseagents ??= {};
|
|
135
|
+
for (const baseagent of available) {
|
|
136
|
+
const selection = defaults.baseagents[baseagent] ??= {};
|
|
137
|
+
const usable = (providerId) => {
|
|
138
|
+
try {
|
|
139
|
+
return !!resolveProviderServiceForBaseagent(providerId, baseagent, undefined, registry).apiKey?.trim();
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const providerId = selection.provider && usable(selection.provider) ? resolveProviderId(selection.provider, registry)
|
|
146
|
+
: imported.find(item => item.baseagent === baseagent)?.providerId ?? Object.keys(registry.providers).find(usable);
|
|
147
|
+
if (providerId && usable(providerId))
|
|
148
|
+
selection.provider = providerId;
|
|
149
|
+
else
|
|
150
|
+
warnings.push({ baseagent, code: 'PROVIDER_REQUIRED' });
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
if (!options.quiet) {
|
|
154
|
+
for (const item of imported)
|
|
155
|
+
console.log(`✓ Provider ${item.merged ? '已合并' : '已导入'}: ${item.baseagent} → ${item.providerId}`);
|
|
156
|
+
const messages = {
|
|
157
|
+
LOCAL_PROVIDER_SOURCE_UNAVAILABLE: '未找到可导入的本机连接或有效凭据',
|
|
158
|
+
PROVIDER_REQUIRED: '最终仍缺少可用 Provider',
|
|
159
|
+
PROVIDER_CONFLICT: 'Provider 域名配置冲突,未覆盖原配置',
|
|
160
|
+
PROVIDER_ID_COLLISION: 'Provider ID 冲突,未覆盖原配置',
|
|
161
|
+
CONFLICT: '配置已变更,请重试导入',
|
|
162
|
+
PROVIDER_IMPORT_FAILED: 'Provider 导入失败,未返回凭据详情',
|
|
163
|
+
};
|
|
164
|
+
for (const item of warnings)
|
|
165
|
+
console.warn(`⚠ ${item.baseagent}: ${messages[item.code]}(${item.code});可使用 ec provider import 或 ECWEB 检查并补齐。`);
|
|
166
|
+
}
|
|
167
|
+
return { imported, warnings };
|
|
168
|
+
}
|
|
103
169
|
function hasCompletedInitConfig() {
|
|
104
170
|
const p = resolvePaths();
|
|
105
171
|
const daemon = loadDaemonConfig();
|
|
@@ -442,6 +508,7 @@ export async function cmdInit(options) {
|
|
|
442
508
|
await runInteractive();
|
|
443
509
|
}
|
|
444
510
|
// ── 共享 tail(单一出口):提示创建 agent + 生成控制 AID ──
|
|
511
|
+
await importProvidersForCliInit(available);
|
|
445
512
|
return initTail({
|
|
446
513
|
nonInteractive: options?.nonInteractive,
|
|
447
514
|
autoStart: options?.autoStart,
|
|
@@ -854,6 +921,13 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
854
921
|
catch (e) {
|
|
855
922
|
fail('IO_ERROR', `failed to write defaults.json: ${e?.message || e}`, EXIT_RUNTIME, format);
|
|
856
923
|
}
|
|
924
|
+
let providers;
|
|
925
|
+
try {
|
|
926
|
+
providers = await importProvidersForCliInit(available, { quiet: format === 'json', source: dependencies.providerSource });
|
|
927
|
+
}
|
|
928
|
+
catch {
|
|
929
|
+
fail('PROVIDER_SETUP_FAILED', 'Provider 扫描或默认选择保存失败,请检查配置后重试;未返回凭据详情', EXIT_RUNTIME, format);
|
|
930
|
+
}
|
|
857
931
|
// ── 8. 控制 AID:缺失则生成 ──
|
|
858
932
|
let controlAid = existingCfg.aid;
|
|
859
933
|
if (!controlAid) {
|
|
@@ -927,6 +1001,7 @@ export async function cmdInitNonInteractive(opts, dependencies = {}) {
|
|
|
927
1001
|
ownerAid,
|
|
928
1002
|
ecwebEnabled: opts.ecweb === true || ecwebService(existingCfg.services)?.enabled === true,
|
|
929
1003
|
baseagent: chosenBaseagent,
|
|
1004
|
+
providers,
|
|
930
1005
|
projectsDefaultPath: projectsDefaultPath ?? null,
|
|
931
1006
|
defaultsPath: p.defaultsConfig,
|
|
932
1007
|
daemonConfigPath: p.daemonConfig,
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ec invoke` —— 统一模型调用入口。
|
|
3
|
+
*
|
|
4
|
+
* 设计见 `docs/model-intent/invoke-design.md`。
|
|
5
|
+
*
|
|
6
|
+
* 它不经过任何 baseagent:直接读 `providers.json` 的端点打过去。
|
|
7
|
+
* 所以在 Claude Code 会话里可以调 Codex 端点,也可以调生图/生视频端点——
|
|
8
|
+
* 只要端点在 providers.json 里登记过。
|
|
9
|
+
*/
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { resolvePaths } from '../paths.js';
|
|
13
|
+
import { readDelegationCredential, hashCurrentDelegatedCommand } from '../core/auth/agent-delegation.js';
|
|
14
|
+
import { daemonUnavailableMessage, queryDaemon, wantsHelp } from './help.js';
|
|
15
|
+
import { parseInvokeArgv } from '../config/invoke-ipc-service.js';
|
|
16
|
+
const HELP = `用法: ec invoke --provider <id> --service <type> (--input <json>|--input-file <path>) [选项]
|
|
17
|
+
|
|
18
|
+
统一模型调用入口:按 providers.json 的 style 路由到内置执行器。
|
|
19
|
+
|
|
20
|
+
必填:
|
|
21
|
+
--provider <id> Provider ID(支持别名)
|
|
22
|
+
--service <type> providers.json 的 service 类型,如 text / image / decision
|
|
23
|
+
--input <json> | --input-file <path> 端点特定入参(JSON)
|
|
24
|
+
|
|
25
|
+
可选:
|
|
26
|
+
--model <id> 缺省取该 service 下第一个已启用模型
|
|
27
|
+
--out <path> 产物落盘路径(图片/音频/视频)
|
|
28
|
+
--timeout <duration> 单次尝试超时,缺省 60s;支持 30s / 2m / 60000
|
|
29
|
+
--retries <n> 传输层重试次数,缺省 3,上限 10;0 = 只打一次
|
|
30
|
+
仅 5xx/超时/连接失败重试,4xx 不重试
|
|
31
|
+
--dry-run 只解析与路由,不触网
|
|
32
|
+
--format json|text 缺省 json
|
|
33
|
+
|
|
34
|
+
示例:
|
|
35
|
+
ec invoke --provider provider-1 --service text --model sonnet \\
|
|
36
|
+
--input '{"input":"你好"}'
|
|
37
|
+
ec invoke --provider provider-2 --service image --model dall-e-3 \\
|
|
38
|
+
--input '{"prompt":"一只猫"}' --out ./cat.png
|
|
39
|
+
|
|
40
|
+
路由表(内置):
|
|
41
|
+
claude / anthropic → /v1/messages
|
|
42
|
+
codex / openai-responses→ /v1/responses
|
|
43
|
+
openai-compatible → /v1/chat/completions
|
|
44
|
+
gemini → /v1beta/models/{model}:generateContent
|
|
45
|
+
systemone → POST {baseUrl}
|
|
46
|
+
openai-images → /v1/images/generations (service: image)
|
|
47
|
+
openai-audio → /v1/audio/speech (service: speech)
|
|
48
|
+
openai-audio → /v1/audio/transcriptions (service: transcribe)
|
|
49
|
+
openai-embeddings → /v1/embeddings (service: embedding)
|
|
50
|
+
|
|
51
|
+
本命令不修改 providers.json;产物路径由调用方指定。`;
|
|
52
|
+
function parseDuration(raw) {
|
|
53
|
+
const match = /^(\d+)\s*(ms|s|m|h)?$/u.exec(raw.trim());
|
|
54
|
+
if (!match)
|
|
55
|
+
throw Object.assign(new Error(`--timeout 格式无效: ${raw}`), { code: 'INVALID_ARGUMENT' });
|
|
56
|
+
const value = Number(match[1]);
|
|
57
|
+
const unit = match[2] ?? 'ms';
|
|
58
|
+
const factor = unit === 'h' ? 3_600_000 : unit === 'm' ? 60_000 : unit === 's' ? 1_000 : 1;
|
|
59
|
+
return value * factor;
|
|
60
|
+
}
|
|
61
|
+
/** 把 `--timeout <duration>` 统一改写为 `--timeout-ms <n>`。 */
|
|
62
|
+
function normalizeTimeoutArgs(args) {
|
|
63
|
+
const out = [];
|
|
64
|
+
for (let index = 0; index < args.length; index++) {
|
|
65
|
+
const token = args[index];
|
|
66
|
+
if (token === '--timeout') {
|
|
67
|
+
const value = args[index + 1];
|
|
68
|
+
if (value === undefined)
|
|
69
|
+
throw Object.assign(new Error('--timeout requires a value'), { code: 'INVALID_ARGUMENT' });
|
|
70
|
+
out.push('--timeout-ms', String(parseDuration(value)));
|
|
71
|
+
index++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (token.startsWith('--timeout=')) {
|
|
75
|
+
out.push('--timeout-ms', String(parseDuration(token.slice('--timeout='.length))));
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
out.push(token);
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function isSuccess(response) {
|
|
83
|
+
// 只有明确的 ok:true 才算成功;daemon 旧版本或异常响应只带 error 时按失败处理。
|
|
84
|
+
return response.ok === true;
|
|
85
|
+
}
|
|
86
|
+
function renderText(response) {
|
|
87
|
+
if (!isSuccess(response)) {
|
|
88
|
+
const code = response.code ?? 'INVOKE_FAILED';
|
|
89
|
+
const message = response.error ?? 'invoke failed';
|
|
90
|
+
return `❌ ${message} (${code})` + (response.data?.hint ? `\n 提示: ${response.data.hint}` : '');
|
|
91
|
+
}
|
|
92
|
+
const lines = [
|
|
93
|
+
`✓ 调用成功`,
|
|
94
|
+
` provider: ${response.provider}`,
|
|
95
|
+
` service : ${response.service}`,
|
|
96
|
+
` model : ${response.model}`,
|
|
97
|
+
` style : ${response.style}`,
|
|
98
|
+
` executor: ${response.executor}`,
|
|
99
|
+
` latency : ${response.result?.latencyMs ?? 0}ms`,
|
|
100
|
+
];
|
|
101
|
+
if (response.result?.artifacts?.length) {
|
|
102
|
+
lines.push(' 产物:');
|
|
103
|
+
for (const artifact of response.result.artifacts) {
|
|
104
|
+
lines.push(` ${artifact.kind}${artifact.path ? ` ${artifact.path}` : ''}${artifact.url ? ` ${artifact.url}` : ''}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return lines.join('\n');
|
|
108
|
+
}
|
|
109
|
+
export async function cmdInvoke(args) {
|
|
110
|
+
if (!args.length || wantsHelp(args)) {
|
|
111
|
+
console.log(HELP);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const json = args.some((value, index) => value === '--format=json' || (value === '--format' && args[index + 1] === 'json'));
|
|
115
|
+
const emit = (payload) => {
|
|
116
|
+
if (json)
|
|
117
|
+
console.log(JSON.stringify(payload, null, 2));
|
|
118
|
+
else if (!isSuccess(payload))
|
|
119
|
+
console.error(renderText(payload));
|
|
120
|
+
else
|
|
121
|
+
console.log(renderText(payload));
|
|
122
|
+
};
|
|
123
|
+
let parsed;
|
|
124
|
+
try {
|
|
125
|
+
// 本地把 `--timeout <duration>` 换算成毫秒,再交给统一的 argv 解析。
|
|
126
|
+
const normalized = normalizeTimeoutArgs(args);
|
|
127
|
+
parsed = parseInvokeArgv(['invoke', ...normalized]);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
emit({ ok: false, code: error.code ?? 'INVALID_ARGUMENT', error: error.message });
|
|
131
|
+
process.exitCode = 1;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// 本地解析出的 input:路径相对 cwd 解析(daemon 无法知道调用方 cwd)。
|
|
135
|
+
const inputText = parsed.inputFile
|
|
136
|
+
? fs.readFileSync(path.resolve(parsed.inputFile), 'utf8')
|
|
137
|
+
: parsed.input;
|
|
138
|
+
if (Buffer.byteLength(inputText, 'utf8') > 1024 * 1024) {
|
|
139
|
+
emit({ ok: false, code: 'INVALID_ARGUMENT', error: 'invoke input must be under 1 MiB' });
|
|
140
|
+
process.exitCode = 1;
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const timeoutMs = parsed.timeoutMs;
|
|
144
|
+
const retries = parsed.retries === undefined ? undefined : Number(parsed.retries);
|
|
145
|
+
const sessionId = process.env.EVOLCORE_SESSION_ID;
|
|
146
|
+
const delegationToken = readDelegationCredential();
|
|
147
|
+
// 托管与非托管都走 daemon:密钥解析($VAR)与 providers.json 的合理归属都在 daemon。
|
|
148
|
+
const argv = [
|
|
149
|
+
'invoke',
|
|
150
|
+
'--provider', parsed.providerId,
|
|
151
|
+
'--service', parsed.serviceType,
|
|
152
|
+
...(parsed.model ? ['--model', parsed.model] : []),
|
|
153
|
+
...(parsed.out ? ['--out', path.resolve(parsed.out)] : []),
|
|
154
|
+
...(timeoutMs !== undefined ? ['--timeout-ms', String(timeoutMs)] : []),
|
|
155
|
+
...(retries !== undefined ? ['--retries', String(retries)] : []),
|
|
156
|
+
...(parsed.dryRun ? ['--dry-run'] : []),
|
|
157
|
+
];
|
|
158
|
+
try {
|
|
159
|
+
let controlToken;
|
|
160
|
+
if (!sessionId && !delegationToken) {
|
|
161
|
+
try {
|
|
162
|
+
controlToken = fs.readFileSync(resolvePaths().controlToken, 'utf8').trim();
|
|
163
|
+
}
|
|
164
|
+
catch { }
|
|
165
|
+
}
|
|
166
|
+
const { response, transportError } = await queryDaemon(resolvePaths().socket, {
|
|
167
|
+
type: 'invoke.op', argv, input: inputText,
|
|
168
|
+
...(sessionId || delegationToken
|
|
169
|
+
? { sessionId, delegationToken, delegationCommandHash: hashCurrentDelegatedCommand() }
|
|
170
|
+
: { controlToken }),
|
|
171
|
+
}, (timeoutMs ?? 60_000) + 30_000);
|
|
172
|
+
if (!response)
|
|
173
|
+
throw Object.assign(new Error(daemonUnavailableMessage(transportError, '无法连接 EvolCore daemon')), { code: 'DAEMON_UNAVAILABLE' });
|
|
174
|
+
emit(response);
|
|
175
|
+
if (!isSuccess(response))
|
|
176
|
+
process.exitCode = 1;
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
emit({ ok: false, code: error.code ?? 'INVOKE_FAILED', error: error.message });
|
|
180
|
+
process.exitCode = 1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -20,9 +20,11 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
20
20
|
'memory',
|
|
21
21
|
'model',
|
|
22
22
|
'msg',
|
|
23
|
-
'
|
|
23
|
+
'team',
|
|
24
24
|
'proxy',
|
|
25
25
|
'provider',
|
|
26
|
+
// `invoke` 调用已登记的端点,不改配置;具体授权由 invoke.op 的委托校验完成。
|
|
27
|
+
'invoke',
|
|
26
28
|
'ability',
|
|
27
29
|
'queue',
|
|
28
30
|
'response',
|
|
@@ -39,6 +41,9 @@ const MANAGED_TASK_COMMANDS = new Set([
|
|
|
39
41
|
// ec-skill 技能的 SKILL.md 明确指导 agent 调用它。脚本只读写
|
|
40
42
|
// `thread` 提供话题链操作,通过 thread.op IPC 鉴权
|
|
41
43
|
'thread',
|
|
44
|
+
// `events` 事件中心运维(白名单自动维护脚本用它加白名单),通过 events.op IPC
|
|
45
|
+
// 且要求本地 control token,daemon 侧鉴权。
|
|
46
|
+
'events',
|
|
42
47
|
// $EVOLCORE_HOME/skills/ 与 kits/skills/ 下的技能文件,不触碰进程生命周期。
|
|
43
48
|
// 本白名单只负责让它进到脚本;具体某一级的读写权限由 skill.mjs 的
|
|
44
49
|
// assertPermission() 按会话上下文判定(群聊一律拒,Agent 级要 owner,
|
|
@@ -26,7 +26,7 @@ function providerText(command, data) {
|
|
|
26
26
|
}
|
|
27
27
|
lines.push(`全局默认基座:${label(data.activeBaseagent)}`);
|
|
28
28
|
lines.push(data.selection ? `本次默认选择:${label(data.selection.provider)} / ${label(data.selection.model)}` : '本次默认选择:未重新选择');
|
|
29
|
-
lines.push(`待处理:${data.pending?.length ? data.pending.map(label).join('、') : '无'}`, `告警:${data.warnings?.length ? data.warnings.map(label).join('、') : '无'}`,
|
|
29
|
+
lines.push(`待处理:${data.pending?.length ? data.pending.map(label).join('、') : '无'}`, `告警:${data.warnings?.length ? data.warnings.map(label).join('、') : '无'}`, `备份版本:${data.backup ? label(data.backup) : data.warnings?.includes('CONFIG_SNAPSHOTS_DISABLED') ? '无(配置快照已关闭)' : '无(未产生变更)'}`);
|
|
30
30
|
}
|
|
31
31
|
else if (command.operation === 'list') {
|
|
32
32
|
const entries = Object.entries(data.providers ?? {});
|