evolcore 0.0.8 → 0.0.10
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 +31 -0
- package/README.md +37 -3
- package/dist/agents/baseagent.js +111 -19
- package/dist/agents/claude-runner.js +30 -2
- package/dist/agents/codex-app-server-client.js +31 -0
- package/dist/agents/codex-runner.js +3 -0
- package/dist/aun/msg/group.js +9 -9
- package/dist/aun/msg/p2p.js +11 -6
- package/dist/aun/msg/upload.js +43 -29
- package/dist/aun/outbox.js +48 -5
- package/dist/channels/aun.js +199 -50
- package/dist/cli/aun-commands.js +10 -7
- package/dist/cli/daemon-commands.js +19 -4
- package/dist/cli/index.js +11 -1
- package/dist/cli/init.js +103 -4
- package/dist/cli/model.js +5 -5
- package/dist/config/builtin-role-templates.js +4 -3
- package/dist/config/config-field-policy.js +6 -2
- package/dist/config/config-manager.js +48 -11
- package/dist/config/contact-book-store.js +1 -1
- package/dist/config/role-schema.js +18 -3
- package/dist/config/role-service.js +3 -3
- package/dist/config/role-store.js +4 -3
- package/dist/config-store.js +4 -0
- package/dist/core/auth/operation-authorizer.js +3 -1
- package/dist/core/bootstrap-service.js +0 -12
- package/dist/core/channel-loader.js +5 -1
- package/dist/core/command/command-handler.js +1 -1
- package/dist/core/command/evol-menu-version-gate.js +3 -2
- package/dist/core/command/menu-handler.js +33 -22
- package/dist/core/command/menu-protocol.js +7 -4
- package/dist/core/command/slash-handler.js +4 -4
- package/dist/core/data-migration.js +79 -27
- package/dist/core/inference/text-inference.js +18 -5
- package/dist/core/message/message-bridge.js +17 -6
- package/dist/core/message/response-engine.js +22 -3
- package/dist/core/model/config-scope.js +3 -3
- package/dist/core/permission/tool-policy.js +18 -0
- package/dist/index.js +43 -26
- package/dist/ipc.js +1 -1
- package/dist/product.js +1 -0
- package/dist/utils/autostart.js +27 -0
- package/dist/utils/ecweb-utils.js +15 -2
- package/dist/utils/macos-autostart.js +179 -0
- package/dist/utils/windows-autostart.js +130 -0
- package/ecagent/dist/agent-loop.d.ts +1 -1
- package/ecagent/dist/agent-loop.js +1 -1
- package/ecagent/dist/agent.d.ts +1 -1
- package/ecagent/dist/agent.js +1 -1
- package/ecagent/dist/harness/agent-harness.d.ts +1 -1
- package/ecagent/dist/harness/compaction/branch-summarization.d.ts +1 -1
- package/ecagent/dist/harness/compaction/compaction.d.ts +1 -1
- package/ecagent/dist/harness/compaction/utils.d.ts +1 -1
- package/ecagent/dist/harness/messages.d.ts +1 -1
- package/ecagent/dist/harness/session/session.d.ts +1 -1
- package/ecagent/dist/harness/types.d.ts +1 -1
- package/ecagent/dist/proxy.d.ts +1 -1
- package/ecagent/dist/proxy.js +1 -1
- package/ecagent/dist/types.d.ts +1 -1
- package/kits/migrations/migrate-role-config-v5.mjs +27 -2
- package/kits/schemas/agent-config.schema.10.json +19 -1
- package/kits/schemas/daemon.schema.4.json +4 -0
- package/kits/schemas/defaults.schema.4.json +15 -1
- package/kits/schemas/relation-config.schema.8.json +22 -1
- package/kits/schemas/role-config.schema.1.json +2 -2
- package/package.json +2 -4
- package/ecagent/dist/agent-loop.d.ts.map +0 -1
- package/ecagent/dist/agent-loop.js.map +0 -1
- package/ecagent/dist/agent.d.ts.map +0 -1
- package/ecagent/dist/agent.js.map +0 -1
- package/ecagent/dist/harness/agent-harness.d.ts.map +0 -1
- package/ecagent/dist/harness/agent-harness.js.map +0 -1
- package/ecagent/dist/harness/compaction/branch-summarization.d.ts.map +0 -1
- package/ecagent/dist/harness/compaction/branch-summarization.js.map +0 -1
- package/ecagent/dist/harness/compaction/compaction.d.ts.map +0 -1
- package/ecagent/dist/harness/compaction/compaction.js.map +0 -1
- package/ecagent/dist/harness/compaction/utils.d.ts.map +0 -1
- package/ecagent/dist/harness/compaction/utils.js.map +0 -1
- package/ecagent/dist/harness/env/nodejs.d.ts.map +0 -1
- package/ecagent/dist/harness/env/nodejs.js.map +0 -1
- package/ecagent/dist/harness/messages.d.ts.map +0 -1
- package/ecagent/dist/harness/messages.js.map +0 -1
- package/ecagent/dist/harness/prompt-templates.d.ts.map +0 -1
- package/ecagent/dist/harness/prompt-templates.js.map +0 -1
- package/ecagent/dist/harness/session/jsonl-repo.d.ts.map +0 -1
- package/ecagent/dist/harness/session/jsonl-repo.js.map +0 -1
- package/ecagent/dist/harness/session/jsonl-storage.d.ts.map +0 -1
- package/ecagent/dist/harness/session/jsonl-storage.js.map +0 -1
- package/ecagent/dist/harness/session/memory-repo.d.ts.map +0 -1
- package/ecagent/dist/harness/session/memory-repo.js.map +0 -1
- package/ecagent/dist/harness/session/memory-storage.d.ts.map +0 -1
- package/ecagent/dist/harness/session/memory-storage.js.map +0 -1
- package/ecagent/dist/harness/session/repo-utils.d.ts.map +0 -1
- package/ecagent/dist/harness/session/repo-utils.js.map +0 -1
- package/ecagent/dist/harness/session/session.d.ts.map +0 -1
- package/ecagent/dist/harness/session/session.js.map +0 -1
- package/ecagent/dist/harness/session/uuid.d.ts.map +0 -1
- package/ecagent/dist/harness/session/uuid.js.map +0 -1
- package/ecagent/dist/harness/skills.d.ts.map +0 -1
- package/ecagent/dist/harness/skills.js.map +0 -1
- package/ecagent/dist/harness/system-prompt.d.ts.map +0 -1
- package/ecagent/dist/harness/system-prompt.js.map +0 -1
- package/ecagent/dist/harness/types.d.ts.map +0 -1
- package/ecagent/dist/harness/types.js.map +0 -1
- package/ecagent/dist/harness/utils/shell-output.d.ts.map +0 -1
- package/ecagent/dist/harness/utils/shell-output.js.map +0 -1
- package/ecagent/dist/harness/utils/truncate.d.ts.map +0 -1
- package/ecagent/dist/harness/utils/truncate.js.map +0 -1
- package/ecagent/dist/index.d.ts.map +0 -1
- package/ecagent/dist/index.js.map +0 -1
- package/ecagent/dist/node.d.ts.map +0 -1
- package/ecagent/dist/node.js.map +0 -1
- package/ecagent/dist/proxy.d.ts.map +0 -1
- package/ecagent/dist/proxy.js.map +0 -1
- package/ecagent/dist/runtime/api/lazy.d.ts.map +0 -1
- package/ecagent/dist/runtime/api/lazy.js.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.d.ts.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.js.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.lazy.d.ts.map +0 -1
- package/ecagent/dist/runtime/api/pi-messages.lazy.js.map +0 -1
- package/ecagent/dist/runtime/auth/context.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/context.js.map +0 -1
- package/ecagent/dist/runtime/auth/credential-store.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/credential-store.js.map +0 -1
- package/ecagent/dist/runtime/auth/helpers.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/helpers.js.map +0 -1
- package/ecagent/dist/runtime/auth/resolve.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/resolve.js.map +0 -1
- package/ecagent/dist/runtime/auth/types.d.ts.map +0 -1
- package/ecagent/dist/runtime/auth/types.js.map +0 -1
- package/ecagent/dist/runtime/compat.d.ts.map +0 -1
- package/ecagent/dist/runtime/compat.js.map +0 -1
- package/ecagent/dist/runtime/index.d.ts.map +0 -1
- package/ecagent/dist/runtime/index.js.map +0 -1
- package/ecagent/dist/runtime/models.d.ts.map +0 -1
- package/ecagent/dist/runtime/models.js.map +0 -1
- package/ecagent/dist/runtime/oauth.d.ts.map +0 -1
- package/ecagent/dist/runtime/oauth.js.map +0 -1
- package/ecagent/dist/runtime/providers/faux.d.ts.map +0 -1
- package/ecagent/dist/runtime/providers/faux.js.map +0 -1
- package/ecagent/dist/runtime/types.d.ts.map +0 -1
- package/ecagent/dist/runtime/types.js.map +0 -1
- package/ecagent/dist/runtime/utils/diagnostics.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/diagnostics.js.map +0 -1
- package/ecagent/dist/runtime/utils/event-stream.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/event-stream.js.map +0 -1
- package/ecagent/dist/runtime/utils/headers.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/headers.js.map +0 -1
- package/ecagent/dist/runtime/utils/json-parse.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/json-parse.js.map +0 -1
- package/ecagent/dist/runtime/utils/oauth/types.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/oauth/types.js.map +0 -1
- package/ecagent/dist/runtime/utils/overflow.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/overflow.js.map +0 -1
- package/ecagent/dist/runtime/utils/provider-env.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/provider-env.js.map +0 -1
- package/ecagent/dist/runtime/utils/retry.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/retry.js.map +0 -1
- package/ecagent/dist/runtime/utils/typebox-helpers.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/typebox-helpers.js.map +0 -1
- package/ecagent/dist/runtime/utils/validation.d.ts.map +0 -1
- package/ecagent/dist/runtime/utils/validation.js.map +0 -1
- package/ecagent/dist/types.d.ts.map +0 -1
- package/ecagent/dist/types.js.map +0 -1
- package/ecagent/package.json +0 -93
- package/ecagent/src/agent-loop.ts +0 -792
- package/ecagent/src/agent.ts +0 -575
- package/ecagent/src/harness/agent-harness.ts +0 -1029
- package/ecagent/src/harness/compaction/branch-summarization.ts +0 -261
- package/ecagent/src/harness/compaction/compaction.ts +0 -753
- package/ecagent/src/harness/compaction/utils.ts +0 -144
- package/ecagent/src/harness/env/nodejs.ts +0 -569
- package/ecagent/src/harness/messages.ts +0 -164
- package/ecagent/src/harness/prompt-templates.ts +0 -267
- package/ecagent/src/harness/session/jsonl-repo.ts +0 -179
- package/ecagent/src/harness/session/jsonl-storage.ts +0 -314
- package/ecagent/src/harness/session/memory-repo.ts +0 -50
- package/ecagent/src/harness/session/memory-storage.ts +0 -133
- package/ecagent/src/harness/session/repo-utils.ts +0 -51
- package/ecagent/src/harness/session/session.ts +0 -338
- package/ecagent/src/harness/session/uuid.ts +0 -54
- package/ecagent/src/harness/skills.ts +0 -375
- package/ecagent/src/harness/system-prompt.ts +0 -34
- package/ecagent/src/harness/types.ts +0 -838
- package/ecagent/src/harness/utils/shell-output.ts +0 -135
- package/ecagent/src/harness/utils/truncate.ts +0 -344
- package/ecagent/src/index.ts +0 -46
- package/ecagent/src/node.ts +0 -2
- package/ecagent/src/proxy.ts +0 -367
- package/ecagent/src/runtime/api/lazy.ts +0 -70
- package/ecagent/src/runtime/api/pi-messages.lazy.ts +0 -4
- package/ecagent/src/runtime/api/pi-messages.ts +0 -436
- package/ecagent/src/runtime/auth/context.ts +0 -45
- package/ecagent/src/runtime/auth/credential-store.ts +0 -47
- package/ecagent/src/runtime/auth/helpers.ts +0 -46
- package/ecagent/src/runtime/auth/resolve.ts +0 -141
- package/ecagent/src/runtime/auth/types.ts +0 -182
- package/ecagent/src/runtime/compat.ts +0 -158
- package/ecagent/src/runtime/index.ts +0 -31
- package/ecagent/src/runtime/models.ts +0 -452
- package/ecagent/src/runtime/oauth.ts +0 -1
- package/ecagent/src/runtime/providers/faux.ts +0 -538
- package/ecagent/src/runtime/types.ts +0 -718
- package/ecagent/src/runtime/utils/diagnostics.ts +0 -45
- package/ecagent/src/runtime/utils/event-stream.ts +0 -88
- package/ecagent/src/runtime/utils/headers.ts +0 -18
- package/ecagent/src/runtime/utils/json-parse.ts +0 -124
- package/ecagent/src/runtime/utils/oauth/types.ts +0 -79
- package/ecagent/src/runtime/utils/overflow.ts +0 -165
- package/ecagent/src/runtime/utils/provider-env.ts +0 -52
- package/ecagent/src/runtime/utils/retry.ts +0 -101
- package/ecagent/src/runtime/utils/typebox-helpers.ts +0 -24
- package/ecagent/src/runtime/utils/validation.ts +0 -310
- package/ecagent/src/types.ts +0 -430
- package/ecagent/tsconfig.build.json +0 -32
|
@@ -169,6 +169,17 @@ function isOwnerOrAdminRole(role) {
|
|
|
169
169
|
function hasNodeProcessTarget(command) {
|
|
170
170
|
return /\bnode(?:js|\.exe)?\b/i.test(command);
|
|
171
171
|
}
|
|
172
|
+
// 包发布命令:npm/pnpm/yarn/bun publish。
|
|
173
|
+
// 排除 --dry-run(不产生实际发布),保留 --provenance 等真实发布参数。
|
|
174
|
+
function isPackagePublishCommand(parsed) {
|
|
175
|
+
const runners = ['npm', 'pnpm', 'yarn', 'bun', 'npx'];
|
|
176
|
+
if (!runners.includes(parsed.executable))
|
|
177
|
+
return false;
|
|
178
|
+
const words = parsed.args.filter(arg => !arg.startsWith('-')).map(arg => arg.toLowerCase());
|
|
179
|
+
if (words[0] !== 'publish')
|
|
180
|
+
return false;
|
|
181
|
+
return !parsed.args.some(arg => arg === '--dry-run' || arg.startsWith('--dry-run='));
|
|
182
|
+
}
|
|
172
183
|
function classifyHostProcessArgv(argv) {
|
|
173
184
|
const executable = commandName(argv[0]);
|
|
174
185
|
if (['ps', 'pgrep', 'pidof'].includes(executable)) {
|
|
@@ -279,6 +290,13 @@ function classifyStructuredCommand(command, depth = 0) {
|
|
|
279
290
|
matches.push({ kind: 'git-push', reason: 'Git push 会修改远端仓库', approvalScope: 'request' });
|
|
280
291
|
}
|
|
281
292
|
}
|
|
293
|
+
if (isPackagePublishCommand(parsed)) {
|
|
294
|
+
matches.push({
|
|
295
|
+
kind: 'package-publish',
|
|
296
|
+
reason: '发布软件包到公共 registry,发布后无法替换同版本',
|
|
297
|
+
approvalScope: 'all',
|
|
298
|
+
});
|
|
299
|
+
}
|
|
282
300
|
if (['kill', 'pkill', 'killall'].includes(parsed.executable) && hasNodeProcessTarget(parsed.raw)) {
|
|
283
301
|
matches.push({ kind: 'process-kill', reason: '终止 Node.js 运行时进程', approvalScope: 'request' });
|
|
284
302
|
}
|
package/dist/index.js
CHANGED
|
@@ -69,7 +69,7 @@ import { EvolAgentRegistry } from './core/evolagent-registry.js';
|
|
|
69
69
|
import { buildReloadHooks } from './core/channel-loader.js';
|
|
70
70
|
import { IpcServer } from './ipc.js';
|
|
71
71
|
import { logger, setLogLevel } from './utils/logger.js';
|
|
72
|
-
import { fetchEcwebPairCode } from './utils/ecweb-utils.js';
|
|
72
|
+
import { ecwebVersionRequirementError, fetchEcwebPairCode } from './utils/ecweb-utils.js';
|
|
73
73
|
import { writeMain, removeAll, isMainWinner, scanInstances } from './utils/instance-registry.js';
|
|
74
74
|
import { detectDuplicates } from './core/evolagent-registry.js';
|
|
75
75
|
import { loadKitManifest, cleanEckDebug, invalidateKitCache } from './eck/kit-renderer.js';
|
|
@@ -369,6 +369,7 @@ async function runBindBootstrapDaemon(daemonCfg) {
|
|
|
369
369
|
channelName: 'control',
|
|
370
370
|
pureIdentity: true,
|
|
371
371
|
gatewayUrl: daemonCfg.aun?.gatewayUrl,
|
|
372
|
+
defaultEncrypt: daemonCfg.aun?.defaultEncrypt,
|
|
372
373
|
aunTrace: daemonCfg.debug?.aunTrace,
|
|
373
374
|
aunSdkLog: daemonCfg.debug?.aunSdkLog,
|
|
374
375
|
});
|
|
@@ -951,7 +952,7 @@ async function main() {
|
|
|
951
952
|
messageCache.cleanupExpired();
|
|
952
953
|
}, 60 * 60 * 1000);
|
|
953
954
|
// 渠道插件系统
|
|
954
|
-
const channelLoader = new ChannelLoader(daemonCfg.debug);
|
|
955
|
+
const channelLoader = new ChannelLoader(daemonCfg.debug, daemonCfg.aun?.defaultEncrypt);
|
|
955
956
|
channelLoader.register(new FeishuChannelPlugin());
|
|
956
957
|
channelLoader.register(new WechatChannelPlugin());
|
|
957
958
|
channelLoader.register(new AUNChannelPlugin());
|
|
@@ -1226,7 +1227,7 @@ async function main() {
|
|
|
1226
1227
|
const effortDecision = validateRuntimeStringFieldOverride({
|
|
1227
1228
|
selfAid: definition.agentAid,
|
|
1228
1229
|
role: actor.role,
|
|
1229
|
-
field: `baseagents.${baseagent}
|
|
1230
|
+
field: `baseagents.${baseagent}.effort`,
|
|
1230
1231
|
value: definition.execution.effort,
|
|
1231
1232
|
});
|
|
1232
1233
|
if (!effortDecision.ok)
|
|
@@ -1454,7 +1455,7 @@ async function main() {
|
|
|
1454
1455
|
originSessionId: originSession.id,
|
|
1455
1456
|
originMessageId: input.runId,
|
|
1456
1457
|
payload,
|
|
1457
|
-
encrypt:
|
|
1458
|
+
encrypt: typeof channel.getDefaultEncrypt === 'function' ? channel.getDefaultEncrypt() : true,
|
|
1458
1459
|
thread: target.session === 'thread' ? target.threadId : undefined,
|
|
1459
1460
|
targetChatType,
|
|
1460
1461
|
explicitReturnPolicy: 'none',
|
|
@@ -2016,6 +2017,7 @@ async function main() {
|
|
|
2016
2017
|
channelName: 'control',
|
|
2017
2018
|
pureIdentity: true,
|
|
2018
2019
|
gatewayUrl: daemonCfg.aun?.gatewayUrl,
|
|
2020
|
+
defaultEncrypt: daemonCfg.aun?.defaultEncrypt,
|
|
2019
2021
|
aunTrace: daemonCfg.debug?.aunTrace,
|
|
2020
2022
|
aunSdkLog: daemonCfg.debug?.aunSdkLog,
|
|
2021
2023
|
});
|
|
@@ -2034,26 +2036,38 @@ async function main() {
|
|
|
2034
2036
|
const ecwebPath = path.join(resolvePaths().root, 'ecweb');
|
|
2035
2037
|
const ecwebEntry = path.join(ecwebPath, 'dist', 'index.js');
|
|
2036
2038
|
if (fs.existsSync(ecwebEntry)) {
|
|
2039
|
+
let ecwebVersion;
|
|
2037
2040
|
try {
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2040
|
-
detached: true,
|
|
2041
|
-
stdio: 'ignore',
|
|
2042
|
-
env: { ...process.env, EVOLCORE_HOME: resolvePaths().root }
|
|
2043
|
-
});
|
|
2044
|
-
ecwebProc.unref();
|
|
2045
|
-
logger.info(`✓ ECWeb 已启动 (PID: ${ecwebProc.pid})`);
|
|
2046
|
-
onShutdown(() => {
|
|
2047
|
-
try {
|
|
2048
|
-
if (ecwebProc.pid)
|
|
2049
|
-
platform.killProcess(ecwebProc.pid, true);
|
|
2050
|
-
logger.info(`✓ ECWeb 已停止`);
|
|
2051
|
-
}
|
|
2052
|
-
catch { }
|
|
2053
|
-
});
|
|
2041
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(ecwebPath, 'package.json'), 'utf-8'));
|
|
2042
|
+
ecwebVersion = pkg.version;
|
|
2054
2043
|
}
|
|
2055
|
-
catch
|
|
2056
|
-
|
|
2044
|
+
catch { }
|
|
2045
|
+
const versionError = ecwebVersionRequirementError(ecwebVersion);
|
|
2046
|
+
if (versionError) {
|
|
2047
|
+
logger.error(`ECWeb 未启动: ${versionError}`);
|
|
2048
|
+
}
|
|
2049
|
+
else {
|
|
2050
|
+
try {
|
|
2051
|
+
const ecwebProc = spawn('node', [ecwebEntry], {
|
|
2052
|
+
cwd: ecwebPath,
|
|
2053
|
+
detached: true,
|
|
2054
|
+
stdio: 'ignore',
|
|
2055
|
+
env: { ...process.env, EVOLCORE_HOME: resolvePaths().root }
|
|
2056
|
+
});
|
|
2057
|
+
ecwebProc.unref();
|
|
2058
|
+
logger.info(`✓ ECWeb 已启动 (PID: ${ecwebProc.pid})`);
|
|
2059
|
+
onShutdown(() => {
|
|
2060
|
+
try {
|
|
2061
|
+
if (ecwebProc.pid)
|
|
2062
|
+
platform.killProcess(ecwebProc.pid, true);
|
|
2063
|
+
logger.info(`✓ ECWeb 已停止`);
|
|
2064
|
+
}
|
|
2065
|
+
catch { }
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
catch (e) {
|
|
2069
|
+
logger.warn(`ECWeb 启动失败: ${e?.message || e}`);
|
|
2070
|
+
}
|
|
2057
2071
|
}
|
|
2058
2072
|
}
|
|
2059
2073
|
else {
|
|
@@ -2090,7 +2104,7 @@ async function main() {
|
|
|
2090
2104
|
const isRoleMenu = menuControl.isMenu
|
|
2091
2105
|
&& (menuControl.name === 'role' || menuControl.request.cmd === '/role');
|
|
2092
2106
|
const menuResponseContext = () => ({
|
|
2093
|
-
metadata: evolMenuResponseTransportMetadata(
|
|
2107
|
+
metadata: evolMenuResponseTransportMetadata(),
|
|
2094
2108
|
});
|
|
2095
2109
|
if (menuControl.isMenu && !hasValidMenuId(menuControl)) {
|
|
2096
2110
|
logger.warn(`[ControlMenu] dropped malformed request without id type=${menuControl.type}`);
|
|
@@ -2479,6 +2493,9 @@ async function main() {
|
|
|
2479
2493
|
if ((params.scope === 'group') !== targetIsGroup) {
|
|
2480
2494
|
return { ok: false, error: 'AUN target does not match the delegated send scope', code: 'UNSUPPORTED_TARGET' };
|
|
2481
2495
|
}
|
|
2496
|
+
const encrypt = typeof params.encrypt === 'boolean'
|
|
2497
|
+
? params.encrypt
|
|
2498
|
+
: (typeof ch.getDefaultEncrypt === 'function' ? ch.getDefaultEncrypt() : true);
|
|
2482
2499
|
let payload = params.payload;
|
|
2483
2500
|
if (params.file) {
|
|
2484
2501
|
if (isHClassPath(params.file.filePath)) {
|
|
@@ -2520,7 +2537,7 @@ async function main() {
|
|
|
2520
2537
|
originSessionId: params.originSessionId,
|
|
2521
2538
|
originMessageId: params.originMessageId,
|
|
2522
2539
|
payload,
|
|
2523
|
-
encrypt
|
|
2540
|
+
encrypt,
|
|
2524
2541
|
thread: params.thread,
|
|
2525
2542
|
targetChatType: params.scope === 'group' ? 'group' : 'private',
|
|
2526
2543
|
explicitReturnPolicy: params.returnPolicy,
|
|
@@ -2567,7 +2584,7 @@ async function main() {
|
|
|
2567
2584
|
groupId: params.to,
|
|
2568
2585
|
payload,
|
|
2569
2586
|
mentions: params.mentions,
|
|
2570
|
-
encrypt
|
|
2587
|
+
encrypt,
|
|
2571
2588
|
log: params.log ? { ...params.log, sessionId: targetSessionId ?? params.log.sessionId } : undefined,
|
|
2572
2589
|
});
|
|
2573
2590
|
}
|
|
@@ -2577,7 +2594,7 @@ async function main() {
|
|
|
2577
2594
|
return await ch.sendDaemonMsg({
|
|
2578
2595
|
to: params.to,
|
|
2579
2596
|
payload,
|
|
2580
|
-
encrypt
|
|
2597
|
+
encrypt,
|
|
2581
2598
|
causation: runtimeCausation,
|
|
2582
2599
|
log: params.log ? { ...params.log, sessionId: targetSessionId ?? params.log.sessionId } : undefined,
|
|
2583
2600
|
});
|
package/dist/ipc.js
CHANGED
|
@@ -519,7 +519,7 @@ export class IpcServer {
|
|
|
519
519
|
mentions: Array.isArray(cmd.mentions)
|
|
520
520
|
? cmd.mentions.filter((entry) => !!entry && typeof entry === 'object' && !Array.isArray(entry))
|
|
521
521
|
: undefined,
|
|
522
|
-
encrypt: cmd.encrypt ===
|
|
522
|
+
encrypt: typeof cmd.encrypt === 'boolean' ? cmd.encrypt : undefined,
|
|
523
523
|
thread: typeof cmd.thread === 'string' ? cmd.thread : undefined,
|
|
524
524
|
returnPolicy: cmd.returnPolicy === 'required' || cmd.returnPolicy === 'none' ? cmd.returnPolicy : undefined,
|
|
525
525
|
originSessionId: typeof cmd.originSessionId === 'string' ? cmd.originSessionId : undefined,
|
package/dist/product.js
CHANGED
|
@@ -10,6 +10,7 @@ export const MAIN_CLI_BIN = 'ec';
|
|
|
10
10
|
export const WEB_PACKAGE_NAME = 'ec-web';
|
|
11
11
|
export const WEB_CLI_BIN = 'ec-web';
|
|
12
12
|
export const WEB_PACKAGE_LATEST = `${WEB_PACKAGE_NAME}@latest`;
|
|
13
|
+
export const MIN_ECWEB_VERSION = '0.0.8';
|
|
13
14
|
export const DAEMON_CONFIG_FILENAME = 'daemon.json';
|
|
14
15
|
export const DAEMON_SCHEMA_NAME = 'daemon';
|
|
15
16
|
export const RUNTIME_HOME_ENV = 'EVOLCORE_HOME';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { configureMacosAutostart, macosAutostartInstalled } from './macos-autostart.js';
|
|
2
|
+
import { configureWindowsAutostart, windowsAutostartInstalled } from './windows-autostart.js';
|
|
3
|
+
export function autostartInstalled() {
|
|
4
|
+
if (process.platform === 'win32')
|
|
5
|
+
return windowsAutostartInstalled();
|
|
6
|
+
if (process.platform === 'darwin')
|
|
7
|
+
return macosAutostartInstalled();
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
export function configureAutostart(enabled, runtimeRoot) {
|
|
11
|
+
if (process.platform === 'win32')
|
|
12
|
+
return configureWindowsAutostart(enabled, runtimeRoot);
|
|
13
|
+
if (process.platform === 'darwin')
|
|
14
|
+
return configureMacosAutostart(enabled, runtimeRoot);
|
|
15
|
+
return {
|
|
16
|
+
ok: !enabled,
|
|
17
|
+
enabled: false,
|
|
18
|
+
...(!enabled ? {} : { error: '登录自启仅支持 Windows 和 macOS 主机' }),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export function autostartPlatformLabel() {
|
|
22
|
+
if (process.platform === 'win32')
|
|
23
|
+
return 'Windows';
|
|
24
|
+
if (process.platform === 'darwin')
|
|
25
|
+
return 'macOS';
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { resolveGlobalPkg } from './npm-ops.js';
|
|
3
|
+
import { compareVersions, resolveGlobalPkg } from './npm-ops.js';
|
|
4
4
|
import { isWindows as platformIsWindows, resolveCommandPath } from './cross-platform.js';
|
|
5
|
-
import { WEB_CLI_BIN, WEB_PACKAGE_NAME } from '../product.js';
|
|
5
|
+
import { MIN_ECWEB_VERSION, WEB_CLI_BIN, WEB_PACKAGE_NAME } from '../product.js';
|
|
6
|
+
/** EC Web owns the session-log reader, so older builds cannot safely serve a newer daemon. */
|
|
7
|
+
export function isEcwebVersionSupported(version) {
|
|
8
|
+
const normalized = version?.trim();
|
|
9
|
+
if (!normalized || !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(normalized))
|
|
10
|
+
return false;
|
|
11
|
+
return compareVersions(normalized, MIN_ECWEB_VERSION) >= 0;
|
|
12
|
+
}
|
|
13
|
+
export function ecwebVersionRequirementError(version) {
|
|
14
|
+
if (isEcwebVersionSupported(version))
|
|
15
|
+
return null;
|
|
16
|
+
const detected = version?.trim() || 'unknown';
|
|
17
|
+
return `EC Web ${detected} 低于最低要求 ${MIN_ECWEB_VERSION},拒绝启动。请运行: npm install -g ${WEB_PACKAGE_NAME}@latest`;
|
|
18
|
+
}
|
|
6
19
|
function readEcwebPackageEntry(pkgJsonPath) {
|
|
7
20
|
try {
|
|
8
21
|
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'));
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { spawnSync } from 'child_process';
|
|
5
|
+
import { getPackageRoot } from '../paths.js';
|
|
6
|
+
export const MACOS_AUTOSTART_LABEL = 'cn.evolai.evolcore';
|
|
7
|
+
function isMacos() {
|
|
8
|
+
return process.platform === 'darwin';
|
|
9
|
+
}
|
|
10
|
+
function plistPath() {
|
|
11
|
+
return path.join(os.homedir(), 'Library', 'LaunchAgents', `${MACOS_AUTOSTART_LABEL}.plist`);
|
|
12
|
+
}
|
|
13
|
+
function launchctl(args) {
|
|
14
|
+
return spawnSync('/bin/launchctl', args, {
|
|
15
|
+
encoding: 'utf8',
|
|
16
|
+
timeout: 15_000,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function commandError(result, fallback) {
|
|
20
|
+
return String(result.error?.message || result.stderr || result.stdout || fallback).trim();
|
|
21
|
+
}
|
|
22
|
+
function guiDomain() {
|
|
23
|
+
const uid = process.getuid?.();
|
|
24
|
+
return uid === undefined ? undefined : `gui/${uid}`;
|
|
25
|
+
}
|
|
26
|
+
function xmlLiteral(value) {
|
|
27
|
+
return value
|
|
28
|
+
.replace(/&/g, '&')
|
|
29
|
+
.replace(/</g, '<')
|
|
30
|
+
.replace(/>/g, '>')
|
|
31
|
+
.replace(/"/g, '"')
|
|
32
|
+
.replace(/'/g, ''');
|
|
33
|
+
}
|
|
34
|
+
function createPlist(runtimeRoot) {
|
|
35
|
+
const absoluteRoot = path.resolve(runtimeRoot);
|
|
36
|
+
const cliEntry = path.join(getPackageRoot(), 'dist', 'cli', 'index.js');
|
|
37
|
+
if (!fs.existsSync(cliEntry)) {
|
|
38
|
+
throw new Error(`找不到 EvolCore CLI 入口: ${cliEntry}`);
|
|
39
|
+
}
|
|
40
|
+
const environment = [
|
|
41
|
+
['EVOLCORE_HOME', absoluteRoot],
|
|
42
|
+
['HOME', os.homedir()],
|
|
43
|
+
['PATH', Array.from(new Set([
|
|
44
|
+
path.dirname(process.execPath),
|
|
45
|
+
...(process.env.PATH ?? '').split(path.delimiter).filter(Boolean),
|
|
46
|
+
])).join(path.delimiter)],
|
|
47
|
+
];
|
|
48
|
+
const environmentXml = environment
|
|
49
|
+
.map(([key, value]) => ` <key>${xmlLiteral(key)}</key>\n <string>${xmlLiteral(value)}</string>`)
|
|
50
|
+
.join('\n');
|
|
51
|
+
const args = [process.execPath, '--no-warnings=ExperimentalWarning', cliEntry, 'start']
|
|
52
|
+
.map(value => ` <string>${xmlLiteral(value)}</string>`)
|
|
53
|
+
.join('\n');
|
|
54
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
55
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
56
|
+
<plist version="1.0">
|
|
57
|
+
<dict>
|
|
58
|
+
<key>Label</key>
|
|
59
|
+
<string>${xmlLiteral(MACOS_AUTOSTART_LABEL)}</string>
|
|
60
|
+
<key>ProgramArguments</key>
|
|
61
|
+
<array>
|
|
62
|
+
${args}
|
|
63
|
+
</array>
|
|
64
|
+
<key>EnvironmentVariables</key>
|
|
65
|
+
<dict>
|
|
66
|
+
${environmentXml}
|
|
67
|
+
</dict>
|
|
68
|
+
<key>RunAtLoad</key>
|
|
69
|
+
<true/>
|
|
70
|
+
<key>StandardOutPath</key>
|
|
71
|
+
<string>${xmlLiteral(path.join(absoluteRoot, 'logs', 'autostart.stdout.log'))}</string>
|
|
72
|
+
<key>StandardErrorPath</key>
|
|
73
|
+
<string>${xmlLiteral(path.join(absoluteRoot, 'logs', 'autostart.stderr.log'))}</string>
|
|
74
|
+
</dict>
|
|
75
|
+
</plist>
|
|
76
|
+
`;
|
|
77
|
+
}
|
|
78
|
+
function restorePlist(file, previous) {
|
|
79
|
+
try {
|
|
80
|
+
if (previous === undefined)
|
|
81
|
+
fs.rmSync(file, { force: true });
|
|
82
|
+
else
|
|
83
|
+
fs.writeFileSync(file, previous, { encoding: 'utf8', mode: 0o600 });
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
return error instanceof Error ? error.message : String(error);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function macosAutostartInstalled() {
|
|
91
|
+
if (!isMacos())
|
|
92
|
+
return false;
|
|
93
|
+
const domain = guiDomain();
|
|
94
|
+
if (!domain)
|
|
95
|
+
return false;
|
|
96
|
+
const result = launchctl(['print', `${domain}/${MACOS_AUTOSTART_LABEL}`]);
|
|
97
|
+
return result.status === 0;
|
|
98
|
+
}
|
|
99
|
+
export function configureMacosAutostart(enabled, runtimeRoot) {
|
|
100
|
+
if (!isMacos()) {
|
|
101
|
+
return {
|
|
102
|
+
ok: !enabled,
|
|
103
|
+
enabled: false,
|
|
104
|
+
...(!enabled ? {} : { error: 'macOS 登录自启仅支持 macOS 主机' }),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const domain = guiDomain();
|
|
108
|
+
if (!domain) {
|
|
109
|
+
return { ok: false, enabled: false, error: '无法确定当前 macOS 用户 UID' };
|
|
110
|
+
}
|
|
111
|
+
const file = plistPath();
|
|
112
|
+
if (!enabled) {
|
|
113
|
+
const result = launchctl(['bootout', `${domain}/${MACOS_AUTOSTART_LABEL}`]);
|
|
114
|
+
if (result.status !== 0 && macosAutostartInstalled()) {
|
|
115
|
+
return {
|
|
116
|
+
ok: false,
|
|
117
|
+
enabled: true,
|
|
118
|
+
error: commandError(result, '删除 macOS 登录自启失败'),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
fs.rmSync(file, { force: true });
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
// Keep the previous state coherent: a LaunchAgents plist that cannot be
|
|
126
|
+
// removed would otherwise silently re-enable the job at the next login.
|
|
127
|
+
const restored = launchctl(['bootstrap', domain, file]);
|
|
128
|
+
return {
|
|
129
|
+
ok: false,
|
|
130
|
+
enabled: restored.status === 0 || macosAutostartInstalled(),
|
|
131
|
+
error: `删除 macOS 登录自启配置失败: ${error instanceof Error ? error.message : String(error)}`,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return { ok: true, enabled: false };
|
|
135
|
+
}
|
|
136
|
+
let previousPlist;
|
|
137
|
+
let previouslyInstalled = false;
|
|
138
|
+
try {
|
|
139
|
+
const absoluteRoot = path.resolve(runtimeRoot);
|
|
140
|
+
if (fs.existsSync(file)) {
|
|
141
|
+
previousPlist = fs.readFileSync(file, 'utf8');
|
|
142
|
+
previouslyInstalled = macosAutostartInstalled();
|
|
143
|
+
}
|
|
144
|
+
fs.mkdirSync(path.join(absoluteRoot, 'logs'), { recursive: true });
|
|
145
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
146
|
+
fs.writeFileSync(file, createPlist(absoluteRoot), { encoding: 'utf8', mode: 0o600 });
|
|
147
|
+
// Re-bootstrap so repeated `ec init --auto-start` updates the command and paths.
|
|
148
|
+
launchctl(['bootout', `${domain}/${MACOS_AUTOSTART_LABEL}`]);
|
|
149
|
+
const result = launchctl(['bootstrap', domain, file]);
|
|
150
|
+
if (result.status !== 0) {
|
|
151
|
+
const restoreError = restorePlist(file, previousPlist);
|
|
152
|
+
let restored = false;
|
|
153
|
+
if (!restoreError && previouslyInstalled && previousPlist !== undefined) {
|
|
154
|
+
const restoreResult = launchctl(['bootstrap', domain, file]);
|
|
155
|
+
restored = restoreResult.status === 0 || macosAutostartInstalled();
|
|
156
|
+
}
|
|
157
|
+
else if (!previouslyInstalled) {
|
|
158
|
+
// A failed bootstrap may still have partially loaded the job.
|
|
159
|
+
launchctl(['bootout', `${domain}/${MACOS_AUTOSTART_LABEL}`]);
|
|
160
|
+
}
|
|
161
|
+
const rollbackSuffix = restoreError ? `; 恢复原配置失败: ${restoreError}` : '';
|
|
162
|
+
return {
|
|
163
|
+
ok: false,
|
|
164
|
+
enabled: restored,
|
|
165
|
+
error: `${commandError(result, '创建 macOS 登录自启失败')}${rollbackSuffix}`,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return { ok: true, enabled: true };
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const restoreError = restorePlist(file, previousPlist);
|
|
172
|
+
const rollbackSuffix = restoreError ? `; 恢复原配置失败: ${restoreError}` : '';
|
|
173
|
+
return {
|
|
174
|
+
ok: false,
|
|
175
|
+
enabled: previouslyInstalled,
|
|
176
|
+
error: `${error instanceof Error ? error.message : String(error)}${rollbackSuffix}`,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { spawnSync } from 'child_process';
|
|
4
|
+
import { getPackageRoot } from '../paths.js';
|
|
5
|
+
export const WINDOWS_AUTOSTART_TASK_NAME = 'EvolCore';
|
|
6
|
+
function isWindows() {
|
|
7
|
+
return process.platform === 'win32';
|
|
8
|
+
}
|
|
9
|
+
function runSchtasks(args) {
|
|
10
|
+
return spawnSync('schtasks.exe', args, {
|
|
11
|
+
encoding: 'utf8',
|
|
12
|
+
windowsHide: true,
|
|
13
|
+
timeout: 15_000,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function commandError(result, fallback) {
|
|
17
|
+
return String(result.error?.message || result.stderr || result.stdout || fallback).trim();
|
|
18
|
+
}
|
|
19
|
+
function powershellLiteral(value) {
|
|
20
|
+
return `'${value.replace(/'/g, "''")}'`;
|
|
21
|
+
}
|
|
22
|
+
function windowsCommandLiteral(value) {
|
|
23
|
+
return `"${value}"`;
|
|
24
|
+
}
|
|
25
|
+
function wrapperPath(runtimeRoot) {
|
|
26
|
+
return path.join(runtimeRoot, 'data', 'evolcore-autostart.ps1');
|
|
27
|
+
}
|
|
28
|
+
export function windowsAutostartInstalled() {
|
|
29
|
+
if (!isWindows())
|
|
30
|
+
return false;
|
|
31
|
+
const result = runSchtasks(['/Query', '/TN', WINDOWS_AUTOSTART_TASK_NAME]);
|
|
32
|
+
return result.status === 0;
|
|
33
|
+
}
|
|
34
|
+
function createWrapper(runtimeRoot) {
|
|
35
|
+
const scriptPath = wrapperPath(runtimeRoot);
|
|
36
|
+
const cliEntry = path.join(getPackageRoot(), 'dist', 'cli', 'index.js');
|
|
37
|
+
if (!fs.existsSync(cliEntry)) {
|
|
38
|
+
throw new Error(`找不到 EvolCore CLI 入口: ${cliEntry}`);
|
|
39
|
+
}
|
|
40
|
+
const pathValue = process.env.PATH ?? '';
|
|
41
|
+
const script = [
|
|
42
|
+
`$env:EVOLCORE_HOME = ${powershellLiteral(runtimeRoot)}`,
|
|
43
|
+
`$env:Path = ${powershellLiteral(pathValue)}`,
|
|
44
|
+
`& ${powershellLiteral(process.execPath)} --no-warnings=ExperimentalWarning ${powershellLiteral(cliEntry)} start`,
|
|
45
|
+
'exit $LASTEXITCODE',
|
|
46
|
+
'',
|
|
47
|
+
].join('\r\n');
|
|
48
|
+
fs.mkdirSync(path.dirname(scriptPath), { recursive: true });
|
|
49
|
+
fs.writeFileSync(scriptPath, script, 'utf8');
|
|
50
|
+
return scriptPath;
|
|
51
|
+
}
|
|
52
|
+
function restoreWrapper(file, previous) {
|
|
53
|
+
try {
|
|
54
|
+
if (previous === undefined)
|
|
55
|
+
fs.rmSync(file, { force: true });
|
|
56
|
+
else
|
|
57
|
+
fs.writeFileSync(file, previous, 'utf8');
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return error instanceof Error ? error.message : String(error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function configureWindowsAutostart(enabled, runtimeRoot) {
|
|
65
|
+
if (!isWindows()) {
|
|
66
|
+
return {
|
|
67
|
+
ok: !enabled,
|
|
68
|
+
enabled: false,
|
|
69
|
+
...(!enabled ? {} : { error: 'Windows 开机自启仅支持 Windows 主机' }),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const absoluteRoot = path.resolve(runtimeRoot);
|
|
73
|
+
const scriptPath = wrapperPath(absoluteRoot);
|
|
74
|
+
if (!enabled) {
|
|
75
|
+
const result = runSchtasks(['/Delete', '/TN', WINDOWS_AUTOSTART_TASK_NAME, '/F']);
|
|
76
|
+
if (result.status !== 0 && windowsAutostartInstalled()) {
|
|
77
|
+
return {
|
|
78
|
+
ok: false,
|
|
79
|
+
enabled: true,
|
|
80
|
+
error: commandError(result, '删除 Windows 开机自启任务失败'),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
fs.rmSync(scriptPath, { force: true });
|
|
85
|
+
}
|
|
86
|
+
catch { }
|
|
87
|
+
return { ok: true, enabled: false };
|
|
88
|
+
}
|
|
89
|
+
let previousWrapper;
|
|
90
|
+
let previouslyInstalled = false;
|
|
91
|
+
try {
|
|
92
|
+
if (fs.existsSync(scriptPath))
|
|
93
|
+
previousWrapper = fs.readFileSync(scriptPath, 'utf8');
|
|
94
|
+
previouslyInstalled = windowsAutostartInstalled();
|
|
95
|
+
const taskScript = createWrapper(absoluteRoot);
|
|
96
|
+
const systemRoot = process.env.SystemRoot || 'C:\\Windows';
|
|
97
|
+
const powershell = path.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
98
|
+
const taskCommand = `${windowsCommandLiteral(powershell)} -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ${windowsCommandLiteral(taskScript)}`;
|
|
99
|
+
// Omitting /RU keeps the task attached to the user creating it and avoids a password prompt.
|
|
100
|
+
const args = [
|
|
101
|
+
'/Create',
|
|
102
|
+
'/TN', WINDOWS_AUTOSTART_TASK_NAME,
|
|
103
|
+
'/SC', 'ONLOGON',
|
|
104
|
+
'/TR', taskCommand,
|
|
105
|
+
'/RL', 'LIMITED',
|
|
106
|
+
'/F',
|
|
107
|
+
];
|
|
108
|
+
const result = runSchtasks(args);
|
|
109
|
+
if (result.status !== 0) {
|
|
110
|
+
const restoreError = restoreWrapper(scriptPath, previousWrapper);
|
|
111
|
+
const stillInstalled = windowsAutostartInstalled();
|
|
112
|
+
const rollbackSuffix = restoreError ? `; 恢复原启动脚本失败: ${restoreError}` : '';
|
|
113
|
+
return {
|
|
114
|
+
ok: false,
|
|
115
|
+
enabled: stillInstalled,
|
|
116
|
+
error: `${commandError(result, '创建 Windows 开机自启任务失败')}${rollbackSuffix}`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return { ok: true, enabled: true };
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
const restoreError = restoreWrapper(scriptPath, previousWrapper);
|
|
123
|
+
const rollbackSuffix = restoreError ? `; 恢复原启动脚本失败: ${restoreError}` : '';
|
|
124
|
+
return {
|
|
125
|
+
ok: false,
|
|
126
|
+
enabled: previouslyInstalled,
|
|
127
|
+
error: `${error instanceof Error ? error.message : String(error)}${rollbackSuffix}`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Agent loop that works with AgentMessage throughout.
|
|
3
3
|
* Transforms to Message[] only at the LLM call boundary.
|
|
4
4
|
*/
|
|
5
|
-
import { EventStream } from "
|
|
5
|
+
import { EventStream } from "./runtime/compat.ts";
|
|
6
6
|
import type { AgentContext, AgentEvent, AgentLoopConfig, AgentMessage, StreamFn } from "./types.ts";
|
|
7
7
|
export type AgentEventSink = (event: AgentEvent) => Promise<void> | void;
|
|
8
8
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Agent loop that works with AgentMessage throughout.
|
|
3
3
|
* Transforms to Message[] only at the LLM call boundary.
|
|
4
4
|
*/
|
|
5
|
-
import { EventStream, streamSimple, validateToolArguments, } from "
|
|
5
|
+
import { EventStream, streamSimple, validateToolArguments, } from "./runtime/compat.js";
|
|
6
6
|
/**
|
|
7
7
|
* Start an agent loop with a new prompt message.
|
|
8
8
|
* The prompt is added to the context and events are emitted for it.
|
package/ecagent/dist/agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ImageContent, type Message, type SimpleStreamOptions, type ThinkingBudgets, type Transport } from "
|
|
1
|
+
import { type ImageContent, type Message, type SimpleStreamOptions, type ThinkingBudgets, type Transport } from "./runtime/compat.ts";
|
|
2
2
|
import type { AfterToolCallContext, AfterToolCallResult, AgentEvent, AgentLoopTurnUpdate, AgentMessage, AgentState, BeforeToolCallContext, BeforeToolCallResult, PrepareNextTurnContext, QueueMode, StreamFn, ToolExecutionMode } from "./types.ts";
|
|
3
3
|
export type { QueueMode } from "./types.ts";
|
|
4
4
|
/** Options for constructing an {@link Agent}. */
|
package/ecagent/dist/agent.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { streamSimple, } from "
|
|
1
|
+
import { streamSimple, } from "./runtime/compat.js";
|
|
2
2
|
import { runAgentLoop, runAgentLoopContinue } from "./agent-loop.js";
|
|
3
3
|
function defaultConvertToLlm(messages) {
|
|
4
4
|
return messages.filter((message) => message.role === "user" || message.role === "assistant" || message.role === "toolResult");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssistantMessage, ImageContent, Model, Models } from "
|
|
1
|
+
import type { AssistantMessage, ImageContent, Model, Models } from "../runtime/index.ts";
|
|
2
2
|
import type { AgentMessage, AgentTool, QueueMode, ThinkingLevel } from "../types.ts";
|
|
3
3
|
import type { AbortResult, AgentHarnessEvent, AgentHarnessEventResultMap, AgentHarnessOptions, AgentHarnessOwnEvent, AgentHarnessResources, AgentHarnessStreamOptions, ExecutionEnv, NavigateTreeResult, PromptTemplate, Skill } from "./types.ts";
|
|
4
4
|
export declare class AgentHarness<TSkill extends Skill = Skill, TPromptTemplate extends PromptTemplate = PromptTemplate, TTool extends AgentTool = AgentTool> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Model, Models } from "
|
|
1
|
+
import type { Model, Models } from "../../runtime/index.ts";
|
|
2
2
|
import type { AgentMessage } from "../../types.ts";
|
|
3
3
|
import type { BranchSummaryResult, Session, SessionTreeEntry } from "../types.ts";
|
|
4
4
|
import { BranchSummaryError, type Result } from "../types.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Model, Models, Usage } from "
|
|
1
|
+
import type { Model, Models, Usage } from "../../runtime/index.ts";
|
|
2
2
|
import type { AgentMessage, ThinkingLevel } from "../../types.ts";
|
|
3
3
|
import { CompactionError, type Result, type SessionTreeEntry } from "../types.ts";
|
|
4
4
|
import { type FileOperations } from "./utils.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ImageContent, Message, TextContent } from "
|
|
1
|
+
import type { ImageContent, Message, TextContent } from "../runtime/index.ts";
|
|
2
2
|
import type { AgentMessage } from "../types.ts";
|
|
3
3
|
export declare const COMPACTION_SUMMARY_PREFIX = "The conversation history before this point was compacted into the following summary:\n\n<summary>\n";
|
|
4
4
|
export declare const COMPACTION_SUMMARY_SUFFIX = "\n</summary>";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ImageContent, TextContent } from "
|
|
1
|
+
import type { ImageContent, TextContent } from "../../runtime/index.ts";
|
|
2
2
|
import type { AgentMessage } from "../../types.ts";
|
|
3
3
|
import type { CustomEntry, SessionContext, SessionMetadata, SessionStorage, SessionTreeEntry } from "../types.ts";
|
|
4
4
|
export type ContextEntryTransform = (entries: readonly SessionTreeEntry[]) => readonly SessionTreeEntry[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ImageContent, Model, Models, SimpleStreamOptions, TextContent, Transport } from "
|
|
1
|
+
import type { ImageContent, Model, Models, SimpleStreamOptions, TextContent, Transport } from "../runtime/index.ts";
|
|
2
2
|
import type { AgentEvent, AgentMessage, AgentTool, QueueMode, ThinkingLevel } from "../index.ts";
|
|
3
3
|
import type { Session } from "./session/session.ts";
|
|
4
4
|
/** Result of a fallible operation. Expected failures are returned as `ok: false` instead of thrown. */
|