evolcore 0.0.39 → 0.0.41-test.0
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 +93 -0
- package/README.md +31 -20
- package/bin/codex-managed-hook.mjs +11 -0
- package/bin/ec-safe-output.js +25 -3
- package/dist/agents/baseagent-availability.js +1 -0
- package/dist/agents/claude-runner.js +53 -152
- package/dist/agents/codex-runner.js +485 -241
- package/dist/agents/ecagent-runner.js +48 -18
- package/dist/agents/gemini-runner.js +27 -8
- package/dist/agents/runner-types.js +39 -9
- package/dist/aun/ability-device-routing.js +26 -0
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +23 -98
- package/dist/aun/aid/ownership-operation.js +1 -3
- package/dist/aun/group/identity.js +8 -0
- package/dist/aun/group/invite-service.js +6 -0
- package/dist/aun/msg/managed-operation.js +4 -4
- package/dist/aun/msg/p2p.js +28 -12
- package/dist/aun/storage/download.js +30 -0
- package/dist/aun/storage/index.js +14 -6
- package/dist/channels/aun.js +99 -52
- package/dist/channels/daemon.js +24 -4
- package/dist/channels/dingtalk.js +8 -2
- package/dist/channels/feishu.js +6 -1
- package/dist/channels/wecom.js +7 -3
- package/dist/cli/agent-command.js +2 -0
- package/dist/cli/agent-create.js +121 -23
- package/dist/cli/agent.js +10 -3
- package/dist/cli/aid-bind-command.js +4 -1
- package/dist/cli/aun-commands.js +82 -22
- package/dist/cli/daemon-commands.js +260 -26
- package/dist/cli/index.js +25 -13
- package/dist/cli/memory-command.js +33 -14
- package/dist/cli/restart-monitor.js +52 -13
- package/dist/cli/session-command.js +128 -13
- package/dist/cli/stats.js +60 -4
- package/dist/cli/task-context.js +1 -0
- package/dist/cli/trigger-command.js +2 -2
- package/dist/config/access-policy.js +2 -0
- package/dist/config/config-field-policy.js +1 -0
- package/dist/config/config-operation-service.js +17 -6
- package/dist/config/gateway-config.js +1 -1
- package/dist/config/peer-role-resolver.js +10 -8
- package/dist/contracts/ecweb-service-protocol.js +44 -0
- package/dist/core/agent-application-service.js +11 -1
- package/dist/core/agent-ipc-registration.js +4 -0
- package/dist/core/agent-runtime.js +6 -0
- package/dist/core/auth/agent-delegation.js +87 -9
- package/dist/core/auth/auth-gateway.js +3 -1
- package/dist/core/auth/authorization-audit.js +25 -4
- package/dist/core/auth/debug-context.js +5 -1
- package/dist/core/auth/operation-catalog.js +24 -0
- package/dist/core/command/agent-control.js +91 -12
- package/dist/core/command/command-handler.js +64 -47
- package/dist/core/command/connect-menu.js +23 -2
- package/dist/core/command/menu-catalog.js +49 -12
- package/dist/core/command/menu-handler.js +110 -105
- package/dist/core/command/menu-protocol.js +29 -3
- package/dist/core/command/role-menu.js +7 -6
- package/dist/core/command/slash-gate.js +22 -5
- package/dist/core/command/slash-handler.js +121 -102
- package/dist/core/event-catalog.js +17 -0
- package/dist/core/interaction-router.js +2 -1
- package/dist/core/ipc-registration.js +44 -8
- package/dist/core/memory/batch-meta.js +2 -0
- package/dist/core/memory/consolidation-context.js +42 -51
- package/dist/core/memory/consolidation-ops-records.js +39 -7
- package/dist/core/memory/consolidation-trigger.js +72 -65
- package/dist/core/memory/consolidation.js +226 -20
- package/dist/core/memory/memory-writer.js +160 -34
- package/dist/core/memory/relation-idle-monitor.js +287 -0
- package/dist/core/memory/relation-sweep.js +206 -0
- package/dist/core/message/aun-ipc-sender.js +31 -5
- package/dist/core/message/aun-request-registry.js +97 -3
- package/dist/core/message/im-renderer.js +4 -0
- package/dist/core/message/message-admission.js +8 -4
- package/dist/core/message/message-bridge.js +96 -53
- package/dist/core/message/message-log.js +72 -0
- package/dist/core/message/message-queue.js +11 -5
- package/dist/core/message/outbound.js +70 -0
- package/dist/core/message/peer-mode.js +7 -2
- package/dist/core/message/response-engine.js +633 -191
- package/dist/core/model/model-catalog.js +7 -6
- package/dist/core/ownership/owner-resolver.js +384 -178
- package/dist/core/permission/ec-command-parser.js +129 -8
- package/dist/core/permission/tool-policy.js +35 -14
- package/dist/core/role/runtime-policy.js +64 -0
- package/dist/core/session/session-capsule.js +197 -0
- package/dist/core/session/session-manager.js +172 -18
- package/dist/core/session/session-mapper.js +2 -0
- package/dist/core/system-session/memory.js +3 -18
- package/dist/ecweb/basic-settings-service.js +709 -0
- package/dist/ecweb/providers-service.js +172 -0
- package/dist/index.js +95 -7
- package/dist/ipc.js +100 -19
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +48 -0
- package/dist/stats/index.js +3 -3
- package/dist/stats/price-resolver.js +304 -5
- package/dist/stats/query.js +328 -3
- package/dist/stats/writer.js +79 -6
- package/dist/trigger/application-service.js +12 -0
- package/dist/trigger/authorization.js +2 -2
- package/dist/trigger/feedback.js +18 -7
- package/dist/trigger/history.js +36 -0
- package/dist/trigger/manager.js +20 -3
- package/dist/trigger/parser.js +6 -3
- package/dist/trigger/patch.js +1 -1
- package/dist/trigger/scheduler.js +3 -0
- package/dist/trigger/system-definitions.js +43 -7
- package/dist/trigger/validation.js +13 -5
- package/dist/utils/ecweb-supervisor.js +31 -10
- package/dist/utils/error-utils.js +22 -4
- package/dist/utils/evolcore-version.js +3 -2
- package/dist/utils/host-info.js +52 -0
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +1 -1
- package/dist/utils/upgrade-jobs.js +45 -5
- package/ecagent/dist/harness/agent-harness.js +4 -1
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/ABILITY_CALLING.md +20 -2
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +3 -2
- package/kits/docs/evolcore/agent.md +1 -1
- package/kits/docs/evolcore/aid.md +29 -12
- package/kits/docs/evolcore/config.md +9 -7
- package/kits/docs/evolcore/event.md +1 -0
- package/kits/docs/evolcore/fs.md +5 -0
- package/kits/docs/evolcore/memory-architecture.md +3 -4
- package/kits/docs/evolcore/memory-consolidation.md +28 -7
- package/kits/docs/evolcore/memory-tags.md +1 -1
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-client.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +38 -0
- package/kits/docs/evolcore/msg.md +18 -2
- package/kits/docs/evolcore/session.md +14 -0
- package/kits/eck_manifest.json +3 -3
- package/kits/rules/04-relation.md +3 -2
- package/kits/schemas/agent-config.schema.13.json +20 -1
- package/kits/skills/aid-ability/SKILL.md +35 -6
- package/kits/templates/memory-consolidation/generalize.md +32 -4
- package/kits/templates/memory-consolidation/notes.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +10 -2
- package/kits/templates/session-capsule/recovery.md +5 -0
- package/kits/templates/session-capsule/renew.md +5 -0
- package/kits/templates/system-fragments/baseagent.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +6 -6
- package/kits/templates/system-fragments/channel.md +1 -1
- package/kits/templates/system-fragments/memory.md +12 -3
- package/kits/templates/system-fragments/session.md +1 -1
- package/kits/{rules/07-memory-and-thread.md → templates/system-fragments/thread.md} +17 -80
- package/package.json +3 -3
- package/dist/stats/billing.js +0 -215
|
@@ -19,8 +19,8 @@ import { auditToolPreflightDenial } from '../core/auth/authorization-audit.js';
|
|
|
19
19
|
import { resolveEcagentConfig } from './baseagent.js';
|
|
20
20
|
import { resolveProviderServiceForBaseagent } from '../config/providers.js';
|
|
21
21
|
import { buildModelRequestHeaders } from './request-identity.js';
|
|
22
|
+
import { getGatewayPricing as getSharedGatewayPricing, resolveModelSpec } from '../stats/price-resolver.js';
|
|
22
23
|
import { appendRequestPath } from './request-identity.js';
|
|
23
|
-
import { resolveModelSpec } from '../stats/billing.js';
|
|
24
24
|
import { getManagedTaskTempDir } from '../cli/task-context.js';
|
|
25
25
|
import { unsettledInterruptError, withInterruptDeadline, hasTrustedFullAccessContext } from './runner-types.js';
|
|
26
26
|
const PROVIDER_ID = 'evolcore-gateway';
|
|
@@ -136,24 +136,27 @@ function openAiMessages(context) {
|
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
138
|
if (message.role === 'assistant') {
|
|
139
|
-
const
|
|
139
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
140
|
+
const text = content
|
|
140
141
|
.filter((block) => block.type === 'text')
|
|
141
142
|
.map(block => block.text)
|
|
142
143
|
.join('');
|
|
143
|
-
const thinking =
|
|
144
|
+
const thinking = content
|
|
144
145
|
.filter((block) => block.type === 'thinking')
|
|
145
146
|
.map((block) => block.thinking)
|
|
146
147
|
.join('');
|
|
147
|
-
const toolCalls =
|
|
148
|
+
const toolCalls = content
|
|
148
149
|
.filter((block) => block.type === 'toolCall')
|
|
149
150
|
.map((block) => ({
|
|
150
151
|
id: block.id,
|
|
151
152
|
type: 'function',
|
|
152
153
|
function: { name: block.name, arguments: JSON.stringify(block.arguments ?? {}) },
|
|
153
154
|
}));
|
|
155
|
+
if (!text && !thinking && toolCalls.length === 0)
|
|
156
|
+
continue;
|
|
154
157
|
messages.push({
|
|
155
158
|
role: 'assistant',
|
|
156
|
-
content: text ||
|
|
159
|
+
content: text || [],
|
|
157
160
|
...(thinking ? { reasoning_content: thinking } : {}),
|
|
158
161
|
...(toolCalls.length > 0 ? { tool_calls: toolCalls } : {}),
|
|
159
162
|
});
|
|
@@ -792,6 +795,12 @@ export class EcagentRunner {
|
|
|
792
795
|
setSendPrompt(fn) { this.sendPromptFn = fn; }
|
|
793
796
|
setPermissionContext(sessionId, context) { this.permissionContexts.set(sessionId, context); }
|
|
794
797
|
setCompactStartCallback(callback) { this.onCompactStart = callback; }
|
|
798
|
+
/** 返回当前网关 /v1/models 的价格缓存(1h TTL,stale-while-revalidate)。
|
|
799
|
+
* 缺失/过期时异步触发刷新,本轮先返回旧值或 undefined(回退本地价表)。 */
|
|
800
|
+
getGatewayPricing() {
|
|
801
|
+
const conn = this.currentProviderConfig();
|
|
802
|
+
return getSharedGatewayPricing(conn.baseUrl, conn.apiKey, conn.headers);
|
|
803
|
+
}
|
|
795
804
|
currentProviderConfig(providerOverride) {
|
|
796
805
|
const providerId = providerOverride ?? this.config.providerId;
|
|
797
806
|
if (!providerId)
|
|
@@ -922,7 +931,13 @@ export class EcagentRunner {
|
|
|
922
931
|
const connection = this.currentProviderConfig(request.modelOverride?.provider);
|
|
923
932
|
await fs.promises.mkdir(request.projectPath, { recursive: true });
|
|
924
933
|
const previousRuntime = this.runtimes.get(request.sessionId);
|
|
925
|
-
const runtime = await this.getOrCreateRuntime(request.sessionId, request.projectPath, request.initialAgentSessionId, request.modelOverride)
|
|
934
|
+
const runtime = await this.getOrCreateRuntime(request.sessionId, request.projectPath, request.initialAgentSessionId, request.modelOverride, async (oldId) => {
|
|
935
|
+
if (!request.modelOverride?.capsule)
|
|
936
|
+
return;
|
|
937
|
+
const recovered = await request.modelOverride.capsule.recover(oldId, request.prompt, request.systemPromptAppend);
|
|
938
|
+
request.prompt = recovered.prompt;
|
|
939
|
+
request.systemPromptAppend = recovered.systemPrompt;
|
|
940
|
+
});
|
|
926
941
|
if (lifecycle.cancelled)
|
|
927
942
|
throw new Error('ecagent run interrupted');
|
|
928
943
|
if (previousRuntime !== runtime) {
|
|
@@ -986,13 +1001,20 @@ export class EcagentRunner {
|
|
|
986
1001
|
const decision = await this.authorizeTool(request.sessionId, request.projectPath, permissionMode, event.toolName, event.input, stats.numTurns + 1);
|
|
987
1002
|
return lifecycle.cancelled || signal?.aborted ? { block: true, reason: '工具调用已取消' } : decision;
|
|
988
1003
|
});
|
|
989
|
-
|
|
1004
|
+
let inputAccepted = false;
|
|
1005
|
+
const unsubscribe = harness.subscribe(event => {
|
|
1006
|
+
// The harness persists a user message before publishing message_end.
|
|
1007
|
+
// Failures in createTurnState/before_agent_start must leave context pending.
|
|
1008
|
+
if (!inputAccepted && event.type === 'message_end' && event.message.role === 'user') {
|
|
1009
|
+
inputAccepted = true;
|
|
1010
|
+
if (request.modelOverride?.turn?.inputId) {
|
|
1011
|
+
queue.push({ type: 'input_accepted', inputId: request.modelOverride.turn.inputId });
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
this.mapHarnessEvent(queue, event, stats, model, effort);
|
|
1015
|
+
});
|
|
990
1016
|
queue.push({ type: 'state_changed', state: 'running' });
|
|
991
1017
|
queue.push({ type: 'status', subtype: 'started', message: `ecagent is using ${modelId}` });
|
|
992
|
-
// Ecagent 输入在 harness.prompt 调用时提交,在此前报告
|
|
993
|
-
if (request.modelOverride?.turn?.inputId) {
|
|
994
|
-
queue.push({ type: 'input_accepted', inputId: request.modelOverride.turn.inputId });
|
|
995
|
-
}
|
|
996
1018
|
const ecImages = request.images?.map(image => ({
|
|
997
1019
|
type: 'image', data: image.data, mimeType: image.mimeType || 'image/png',
|
|
998
1020
|
}));
|
|
@@ -1068,7 +1090,7 @@ export class EcagentRunner {
|
|
|
1068
1090
|
queue.end();
|
|
1069
1091
|
}
|
|
1070
1092
|
}
|
|
1071
|
-
async getOrCreateRuntime(sessionId, projectPath, requestedId, modelOverride) {
|
|
1093
|
+
async getOrCreateRuntime(sessionId, projectPath, requestedId, modelOverride, recover) {
|
|
1072
1094
|
const current = this.runtimes.get(sessionId);
|
|
1073
1095
|
const topicBinding = modelOverride?.backend?.kind === 'topic';
|
|
1074
1096
|
const requestedTopicAgentSessionId = topicBinding
|
|
@@ -1083,6 +1105,7 @@ export class EcagentRunner {
|
|
|
1083
1105
|
}
|
|
1084
1106
|
if (current && !recoverySessionId
|
|
1085
1107
|
&& current.projectPath === projectPath
|
|
1108
|
+
&& !!this.resolveSessionFile(current.agentSessionId, projectPath)
|
|
1086
1109
|
&& (!targetId || current.agentSessionId === targetId)
|
|
1087
1110
|
&& (!topicBinding || (!!targetId && current.agentSessionId === targetId)))
|
|
1088
1111
|
return current;
|
|
@@ -1101,6 +1124,7 @@ export class EcagentRunner {
|
|
|
1101
1124
|
throw error;
|
|
1102
1125
|
}
|
|
1103
1126
|
logger.warn(`[EcagentRunner] backing session ${targetId} was not found; creating a new session`);
|
|
1127
|
+
await recover?.(targetId);
|
|
1104
1128
|
session = await repo.create({ cwd: projectPath });
|
|
1105
1129
|
}
|
|
1106
1130
|
else
|
|
@@ -1110,9 +1134,7 @@ export class EcagentRunner {
|
|
|
1110
1134
|
// Topic UNBOUND is an explicit backend boundary. Let ecagent allocate a
|
|
1111
1135
|
// fresh provider ID; reusing the EvolCore Session ID would make every
|
|
1112
1136
|
// /renew cycle reopen the same provider session under a new filename.
|
|
1113
|
-
session =
|
|
1114
|
-
? await repo.create({ cwd: projectPath })
|
|
1115
|
-
: await repo.create({ cwd: projectPath, id: sessionId });
|
|
1137
|
+
session = await repo.create({ cwd: projectPath });
|
|
1116
1138
|
}
|
|
1117
1139
|
const metadata = await session.getMetadata();
|
|
1118
1140
|
if (recoverySessionId && metadata.id !== recoverySessionId) {
|
|
@@ -1383,15 +1405,23 @@ export class EcagentRunner {
|
|
|
1383
1405
|
harness?.abort(),
|
|
1384
1406
|
...runs.map(run => run.done),
|
|
1385
1407
|
]), 'ecagent');
|
|
1408
|
+
for (const run of runs) {
|
|
1409
|
+
if (run.cancelled)
|
|
1410
|
+
run.interruptError = undefined;
|
|
1411
|
+
}
|
|
1386
1412
|
}
|
|
1387
1413
|
catch (error) {
|
|
1414
|
+
for (const run of runs) {
|
|
1415
|
+
if (run.cancelled && run.interruptError === undefined)
|
|
1416
|
+
run.interruptError = error;
|
|
1417
|
+
}
|
|
1388
1418
|
logger.warn(`[EcagentRunner] Interrupted execution still requires quiescence: session=${sessionKey} error=${String(error)}`);
|
|
1389
1419
|
}
|
|
1390
1420
|
}
|
|
1391
1421
|
assertInterruptSettled(sessionId) {
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1422
|
+
const unsettled = [...(this.sessionRuns.get(sessionId) ?? [])].find(run => run.cancelled);
|
|
1423
|
+
if (unsettled)
|
|
1424
|
+
throw unsettledInterruptError('ecagent', unsettled.interruptError);
|
|
1395
1425
|
}
|
|
1396
1426
|
injectUserMessage(sessionId, text) {
|
|
1397
1427
|
const harness = this.runtimes.get(sessionId)?.harness;
|
|
@@ -26,6 +26,7 @@ import { GeminiSessionFileAdapter } from '../core/session/adapters/gemini-sessio
|
|
|
26
26
|
import { logger } from '../utils/logger.js';
|
|
27
27
|
import { normalizeExecutionPermissionMode, normalizePermissionMode } from '../core/permission/mode.js';
|
|
28
28
|
import { resolveRoot } from '../paths.js';
|
|
29
|
+
import { getGatewayPricing as getSharedGatewayPricing } from '../stats/price-resolver.js';
|
|
29
30
|
import { workspaceContainsHClassPaths } from '../core/permission/protected-paths.js';
|
|
30
31
|
import { buildBubblewrapCommand } from '../core/permission/sandbox-runtime.js';
|
|
31
32
|
import { getManagedTaskTempDir } from '../cli/task-context.js';
|
|
@@ -337,6 +338,12 @@ export class GeminiRunner {
|
|
|
337
338
|
// ── ModelSwitcher ──
|
|
338
339
|
setModel(model) { this.model = stripContextWindowSuffix(model); }
|
|
339
340
|
getModel() { return this.model; }
|
|
341
|
+
/** 返回当前网关 /v1/models 的价格缓存(1h TTL,stale-while-revalidate)。
|
|
342
|
+
* 缺失/过期时异步触发刷新,本轮先返回旧值或 undefined(回退本地价表)。 */
|
|
343
|
+
getGatewayPricing() {
|
|
344
|
+
const conn = this.currentProviderConfig();
|
|
345
|
+
return getSharedGatewayPricing(conn.baseUrl, conn.apiKey, conn.headers);
|
|
346
|
+
}
|
|
340
347
|
getModelCatalog() {
|
|
341
348
|
return getRunnerCatalog('gemini', this.agentAid, this.currentProviderConfig());
|
|
342
349
|
}
|
|
@@ -413,6 +420,18 @@ export class GeminiRunner {
|
|
|
413
420
|
let geminiSessionId = topicBinding
|
|
414
421
|
? (topicAgentSessionId || undefined)
|
|
415
422
|
: initialAgentSessionId || cachedSessionId;
|
|
423
|
+
if (!topicBinding && !initialAgentSessionId && typeof sessionManager?.getSessionById === 'function') {
|
|
424
|
+
const latest = await sessionManager.getSessionById(sessionId);
|
|
425
|
+
geminiSessionId = latest?.agentSessionId || undefined;
|
|
426
|
+
}
|
|
427
|
+
if (!topicBinding && geminiSessionId && modelOverride?.capsule
|
|
428
|
+
&& !this.resolveSessionFile(geminiSessionId, projectPath)) {
|
|
429
|
+
const recovered = await modelOverride.capsule.recover(geminiSessionId, prompt, systemPromptAppend);
|
|
430
|
+
prompt = recovered.prompt;
|
|
431
|
+
systemPromptAppend = recovered.systemPrompt;
|
|
432
|
+
this.activeSessions.delete(sessionId);
|
|
433
|
+
geminiSessionId = undefined;
|
|
434
|
+
}
|
|
416
435
|
// per-call 权限模式/模型:优先 override,缺省回落实例级(多会话并发互不污染)
|
|
417
436
|
const requestedPermissionMode = modelOverride?.permissionMode || this.currentMode;
|
|
418
437
|
const executionPermissionMode = normalizeExecutionPermissionMode(requestedPermissionMode);
|
|
@@ -539,10 +558,7 @@ export class GeminiRunner {
|
|
|
539
558
|
const pendingToolNames = new Map(); // toolId → toolName
|
|
540
559
|
const recordedDeniedToolIds = new Set();
|
|
541
560
|
const startTime = Date.now();
|
|
542
|
-
|
|
543
|
-
if (turn?.inputId) {
|
|
544
|
-
yield { type: 'input_accepted', inputId: turn.inputId };
|
|
545
|
-
}
|
|
561
|
+
let inputAccepted = false;
|
|
546
562
|
const rl = createInterface({ input: child.stdout });
|
|
547
563
|
// Build async queue from readline
|
|
548
564
|
const queue = [];
|
|
@@ -631,9 +647,13 @@ export class GeminiRunner {
|
|
|
631
647
|
break;
|
|
632
648
|
}
|
|
633
649
|
case 'message': {
|
|
634
|
-
|
|
635
|
-
|
|
650
|
+
if (event.role === 'user') {
|
|
651
|
+
if (!inputAccepted && turn?.inputId) {
|
|
652
|
+
inputAccepted = true;
|
|
653
|
+
yield { type: 'input_accepted', inputId: turn.inputId };
|
|
654
|
+
}
|
|
636
655
|
break;
|
|
656
|
+
}
|
|
637
657
|
// Assistant message (delta=true → streaming)
|
|
638
658
|
// Accumulate into textBuffer; will flush on boundary event
|
|
639
659
|
if (event.role === 'assistant' && event.content) {
|
|
@@ -760,8 +780,7 @@ export class GeminiRunner {
|
|
|
760
780
|
if (context?.approvalInteractionPolicy !== 'deny')
|
|
761
781
|
return;
|
|
762
782
|
if (isGeminiUnattendedInteraction(toolName)) {
|
|
763
|
-
|
|
764
|
-
return;
|
|
783
|
+
throw new Error('无人值守任务不能自动回答用户问题');
|
|
765
784
|
}
|
|
766
785
|
const lifecycleRequestId = requestId ?? `gemini-approval-${crypto.randomUUID()}`;
|
|
767
786
|
const auditSummary = `${toolName} runtime authorization denied by Gemini headless policy`;
|
|
@@ -34,7 +34,23 @@ export function parseAsyncUserQuestions(value) {
|
|
|
34
34
|
|| question.options.length > 20 || question.options.some((option) => typeof option !== 'string' || !option.trim() || option.length > 4_096))) {
|
|
35
35
|
throw new Error('Invalid asynchronous question options');
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
if (question.blocking != null && typeof question.blocking !== 'boolean') {
|
|
38
|
+
throw new Error('Invalid asynchronous question blocking flag');
|
|
39
|
+
}
|
|
40
|
+
if (question.recommendedOption != null
|
|
41
|
+
&& (typeof question.recommendedOption !== 'string' || !question.recommendedOption.trim())) {
|
|
42
|
+
throw new Error('Invalid asynchronous question recommended option');
|
|
43
|
+
}
|
|
44
|
+
if (question.recommendedOption != null && question.options
|
|
45
|
+
&& !question.options.includes(question.recommendedOption)) {
|
|
46
|
+
throw new Error('Asynchronous question recommended option is not in options');
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
title: question.title,
|
|
50
|
+
...(question.options ? { options: [...question.options] } : {}),
|
|
51
|
+
blocking: question.blocking !== false,
|
|
52
|
+
...(question.recommendedOption ? { recommendedOption: question.recommendedOption } : {}),
|
|
53
|
+
};
|
|
38
54
|
});
|
|
39
55
|
}
|
|
40
56
|
export function hasTrustedFullAccessContext(context) {
|
|
@@ -44,10 +60,13 @@ export function hasTrustedFullAccessContext(context) {
|
|
|
44
60
|
|| authorization.processRole !== 'fullaccess-run'
|
|
45
61
|
|| authorization.dataScope !== 'daemon')
|
|
46
62
|
return false;
|
|
47
|
-
if (authorization.source === 'fullaccess-command' || authorization.source === 'agent-policy') {
|
|
63
|
+
if (authorization.source === 'fullaccess-command' || authorization.source === 'agent-policy' || authorization.source === 'session-policy') {
|
|
48
64
|
return typeof authorization.authorizedBy === 'string' && authorization.authorizedBy.length > 0
|
|
49
|
-
&& (authorization.source
|
|
50
|
-
|| (typeof authorization.agentAid === 'string'
|
|
65
|
+
&& (authorization.source === 'fullaccess-command'
|
|
66
|
+
|| (typeof authorization.agentAid === 'string'
|
|
67
|
+
&& authorization.agentAid.length > 0
|
|
68
|
+
&& (authorization.source !== 'session-policy'
|
|
69
|
+
|| (typeof authorization.sessionId === 'string' && authorization.sessionId.length > 0))));
|
|
51
70
|
}
|
|
52
71
|
return authorization.source === 'trigger'
|
|
53
72
|
&& typeof authorization.authorizedBy === 'string' && authorization.authorizedBy.length > 0
|
|
@@ -75,10 +94,13 @@ export async function withInterruptDeadline(operation, label, timeoutMs = 5_000)
|
|
|
75
94
|
clearTimeout(timer);
|
|
76
95
|
}
|
|
77
96
|
}
|
|
78
|
-
export function unsettledInterruptError(runner) {
|
|
79
|
-
|
|
97
|
+
export function unsettledInterruptError(runner, cause) {
|
|
98
|
+
const error = Object.assign(new Error(`${runner} 的上一次执行尚未确认停止,本次任务未启动;旧执行结束后可在原会话继续。`), {
|
|
80
99
|
code: 'RUNNER_INTERRUPT_UNCONFIRMED',
|
|
81
100
|
});
|
|
101
|
+
if (cause !== undefined)
|
|
102
|
+
error.cause = cause;
|
|
103
|
+
return error;
|
|
82
104
|
}
|
|
83
105
|
// ── 类型守卫 ──
|
|
84
106
|
export function hasModelSwitcher(agent) {
|
|
@@ -97,20 +119,28 @@ export function hasClearSession(agent) {
|
|
|
97
119
|
export function numericToken(value) {
|
|
98
120
|
return typeof value === 'number' && Number.isFinite(value) ? value : 0;
|
|
99
121
|
}
|
|
100
|
-
export function contextTokensForUsage(usage,
|
|
122
|
+
export function contextTokensForUsage(usage, model) {
|
|
101
123
|
if (!usage)
|
|
102
124
|
return 0;
|
|
103
|
-
|
|
125
|
+
// GPT keeps its reported input count; other models report cache separately.
|
|
126
|
+
if (isGptContextUsageModel(model))
|
|
104
127
|
return numericToken(usage.input_tokens);
|
|
105
128
|
return numericToken(usage.input_tokens)
|
|
129
|
+
+ numericToken(usage.output_tokens)
|
|
106
130
|
+ numericToken(usage.cache_creation_input_tokens)
|
|
107
131
|
+ numericToken(usage.cache_read_input_tokens);
|
|
108
132
|
}
|
|
109
133
|
export function usageForContext(usage) {
|
|
110
134
|
const iterations = Array.isArray(usage?.iterations) ? usage.iterations : undefined;
|
|
111
|
-
const lastIteration = iterations?.slice().reverse().find(it => contextTokensForUsage(it
|
|
135
|
+
const lastIteration = iterations?.slice().reverse().find(it => contextTokensForUsage(it) > 0);
|
|
112
136
|
return lastIteration ?? usage;
|
|
113
137
|
}
|
|
138
|
+
export function isGptContextUsageModel(model) {
|
|
139
|
+
if (!model)
|
|
140
|
+
return false;
|
|
141
|
+
const modelId = stripContextWindowSuffix(model).trim().split(/[/:]/).at(-1) ?? '';
|
|
142
|
+
return /^(?:gpt|chatgpt|o[134])(?:[-.]|$)/i.test(modelId);
|
|
143
|
+
}
|
|
114
144
|
/** Models whose base ID uses a 1M context window when sent to the SDK with [1m]. */
|
|
115
145
|
export const ONE_M_CONTEXT_MODEL_PREFIXES = ['claude-opus-5', 'claude-opus-4-8', 'claude-sonnet-4-6'];
|
|
116
146
|
const ONE_M_CONTEXT_MODEL_ALIASES = ['opus', 'sonnet'];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Only this read-only query collects responses from every online device. */
|
|
2
|
+
export function isAidWideDeviceStatusQuery(payload) {
|
|
3
|
+
const params = payload?.params;
|
|
4
|
+
return payload?.type === 'ability' && payload.role === 'call'
|
|
5
|
+
&& payload.ability_path === 'device/status'
|
|
6
|
+
&& !!params && typeof params === 'object' && !Array.isArray(params)
|
|
7
|
+
&& params.action === 'read';
|
|
8
|
+
}
|
|
9
|
+
/** Device routing belongs to message.send, never to the Ability payload. */
|
|
10
|
+
export function resolveAunSendDevice(deviceId, scope, payload) {
|
|
11
|
+
if (deviceId !== undefined && (scope !== 'msg' || typeof deviceId !== 'string'
|
|
12
|
+
|| !deviceId || deviceId.length > 256 || /[\s\x00-\x1f\x7f]/.test(deviceId))) {
|
|
13
|
+
throw Object.assign(new Error('--device-id requires a nonempty private target device ID'), { code: 'INVALID_DEVICE_ID' });
|
|
14
|
+
}
|
|
15
|
+
if (isAidWideDeviceStatusQuery(payload)) {
|
|
16
|
+
if (scope !== 'msg' || deviceId !== undefined) {
|
|
17
|
+
throw Object.assign(new Error('device/status queries the AID online devices; omit --device-id and use a private AID target'), { code: 'ABILITY_DEVICE_NOT_ALLOWED' });
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
if (payload?.type === 'ability' && payload.role === 'call'
|
|
22
|
+
&& payload.ability_path !== 'protocol/discover' && !deviceId) {
|
|
23
|
+
throw Object.assign(new Error('Select a device from the Provider ability index and pass --device-id; business Ability calls cannot broadcast to every device'), { code: 'ABILITY_DEVICE_REQUIRED' });
|
|
24
|
+
}
|
|
25
|
+
return deviceId;
|
|
26
|
+
}
|
package/dist/aun/aid/client.js
CHANGED
|
@@ -39,7 +39,7 @@ export function suppressSdkLogs() {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
// ==================== SDK package ====================
|
|
42
|
-
export const MIN_AUN_CORE_SDK = [0, 5,
|
|
42
|
+
export const MIN_AUN_CORE_SDK = [0, 5, 26];
|
|
43
43
|
export const AUN_CORE_SDK_PKG = '@agentunion/fastaun';
|
|
44
44
|
function compareVersion(a, min) {
|
|
45
45
|
const parts = a.split('.').map(n => parseInt(n, 10));
|
|
@@ -8,7 +8,6 @@ import { getAidStore, loadClient, SLOT } from './store.js';
|
|
|
8
8
|
import { LocalTokenStore, validateAgentMdDocument, verifyAgentMdUpload, } from '@agentunion/fastaun';
|
|
9
9
|
import { AUN_KEYSTORE_ENCRYPTION_SEED } from './encryption-seed-policy.js';
|
|
10
10
|
import { isValidAid } from './validation.js';
|
|
11
|
-
import { OwnerResolver } from '../../core/ownership/owner-resolver.js';
|
|
12
11
|
import { agentMdPath, resolvePaths } from '../../paths.js';
|
|
13
12
|
import { PeerIdentityCache } from '../../core/relation/peer-identity.js';
|
|
14
13
|
import { agentmdPut, buildInitialAgentMd, invalidateAgentDisplayName, stripAgentMdSignature } from './agentmd.js';
|
|
@@ -331,7 +330,6 @@ export async function submitControlAidRegistration(aid, owner, options = {}) {
|
|
|
331
330
|
let connecting = false;
|
|
332
331
|
let sentOperationIds = new Set();
|
|
333
332
|
let invitationObserver;
|
|
334
|
-
const resolver = new OwnerResolver();
|
|
335
333
|
async function bounded(operation, timeoutMs = deadline - Date.now()) {
|
|
336
334
|
let timer;
|
|
337
335
|
try {
|
|
@@ -346,27 +344,6 @@ export async function submitControlAidRegistration(aid, owner, options = {}) {
|
|
|
346
344
|
clearTimeout(timer);
|
|
347
345
|
}
|
|
348
346
|
}
|
|
349
|
-
function readTask() {
|
|
350
|
-
const raw = records.loadOwnershipTask(aid, operationId)?.task;
|
|
351
|
-
if (!raw)
|
|
352
|
-
return;
|
|
353
|
-
if (raw.operation_id !== operationId || raw.operation !== 'bind' || raw.sub_aid !== aid
|
|
354
|
-
|| raw.owner_aid !== ownerAid || raw.initiator_aid !== aid || raw.new_owner_aid !== undefined
|
|
355
|
-
|| !['pending', 'completed', 'rejected', 'stopped', 'error'].includes(String(raw.status))
|
|
356
|
-
|| typeof raw.step !== 'string' || !Number.isSafeInteger(raw.base_relation_version)
|
|
357
|
-
|| raw.target_relation_version !== Number(raw.base_relation_version) + 1) {
|
|
358
|
-
throw Object.assign(new Error('SDK registration task does not match its original intent'), { code: 'TASK_MISMATCH' });
|
|
359
|
-
}
|
|
360
|
-
task = {
|
|
361
|
-
operation_id: operationId, operation: 'bind', sub_aid: aid, owner_aid: ownerAid,
|
|
362
|
-
base_relation_version: raw.base_relation_version,
|
|
363
|
-
target_relation_version: raw.target_relation_version,
|
|
364
|
-
status: raw.status, step: raw.step,
|
|
365
|
-
...(typeof raw.code === 'string' ? { code: raw.code } : {}),
|
|
366
|
-
...(typeof raw.reason === 'string' ? { reason: raw.reason } : {}),
|
|
367
|
-
...(typeof raw.retryable === 'boolean' ? { retryable: raw.retryable } : {}),
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
347
|
function result(status, error) {
|
|
371
348
|
return { status, ...(operationId ? { operationId } : {}), ...(task ? { task } : {}), ...(error ? { error } : {}) };
|
|
372
349
|
}
|
|
@@ -374,10 +351,8 @@ export async function submitControlAidRegistration(aid, owner, options = {}) {
|
|
|
374
351
|
records = new LocalTokenStore(resolvePaths().root, { encryptionSeed: AUN_KEYSTORE_ENCRYPTION_SEED });
|
|
375
352
|
const intent = records.loadMetadata(aid)?.registration_intent;
|
|
376
353
|
const registrationIntentOwner = typeof intent?.owner === 'string' ? intent.owner.toLowerCase() : undefined;
|
|
377
|
-
// Preserve an existing SDK registration task and let the same SDK client
|
|
378
|
-
// resume it during connect before OwnerResolver checks/binds the subject.
|
|
379
354
|
if (intent && Object.prototype.hasOwnProperty.call(intent, 'owner')) {
|
|
380
|
-
if (!registrationIntentOwner) {
|
|
355
|
+
if (!registrationIntentOwner || !isValidAid(registrationIntentOwner)) {
|
|
381
356
|
return result('unknown', {
|
|
382
357
|
code: 'REGISTRATION_INTENT_PRESENT',
|
|
383
358
|
message: 'Control AID has an invalid SDK registration Owner intent',
|
|
@@ -386,93 +361,44 @@ export async function submitControlAidRegistration(aid, owner, options = {}) {
|
|
|
386
361
|
if (registrationIntentOwner !== ownerAid) {
|
|
387
362
|
return result('failed', { code: 'OWNER_INTENT_CONFLICT', message: 'Control AID was registered for a different Owner' });
|
|
388
363
|
}
|
|
389
|
-
if (typeof intent.operation_id === 'string' && REGISTRATION_OPERATION_ID.test(intent.operation_id)) {
|
|
390
|
-
operationId = intent.operation_id;
|
|
391
|
-
readTask();
|
|
392
|
-
}
|
|
393
|
-
if (!operationId) {
|
|
394
|
-
return result('unknown', {
|
|
395
|
-
code: 'REGISTRATION_INTENT_PRESENT',
|
|
396
|
-
message: 'Control AID has an SDK registration intent without a valid operation ID',
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
364
|
}
|
|
400
365
|
if (options.agentMdError) {
|
|
401
366
|
return result('failed', { code: 'CONTROL_AGENTMD_NOT_READY', message: options.agentMdError });
|
|
402
367
|
}
|
|
403
|
-
store = await bounded(getAidStore({ slotId:
|
|
404
|
-
const ownershipTasks = records.listOwnershipTasks(aid).map(snapshot => snapshot.task);
|
|
405
|
-
const conflictingTask = ownershipTasks.find(candidate => candidate.sub_aid === aid
|
|
406
|
-
&& (candidate.status === 'pending' || candidate.status === 'error' && candidate.retryable === true)
|
|
407
|
-
&& !(candidate.operation === 'bind' && candidate.owner_aid === ownerAid
|
|
408
|
-
&& candidate.initiator_aid === aid && candidate.new_owner_aid === undefined));
|
|
409
|
-
if (conflictingTask) {
|
|
410
|
-
return result('failed', { code: 'BIND_CONFLICT', message: 'A different active ownership task must be resolved first' });
|
|
411
|
-
}
|
|
368
|
+
store = await bounded(getAidStore({ slotId: `ownership-${crypto.randomUUID()}` }));
|
|
412
369
|
client = await bounded(loadClient(store, aid));
|
|
413
370
|
connecting = true;
|
|
414
371
|
sentOperationIds = new Set();
|
|
415
372
|
invitationObserver = observeInvitationSend(client, ownerAid, sentOperationIds);
|
|
416
373
|
await bounded(client.connect({
|
|
417
|
-
connection_kind: '
|
|
374
|
+
connection_kind: 'short', short_ttl_ms: 30_000, auto_reconnect: false, background_sync: false,
|
|
418
375
|
connect_timeout: 10, call_timeout: 10,
|
|
419
376
|
}));
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
377
|
+
task = await bounded(client.bindOwneraid(ownerAid));
|
|
378
|
+
if (task.operation !== 'bind' || task.sub_aid !== aid || task.owner_aid !== ownerAid
|
|
379
|
+
|| task.new_owner_aid !== undefined || !REGISTRATION_OPERATION_ID.test(task.operation_id)
|
|
380
|
+
|| !Number.isSafeInteger(task.base_relation_version)
|
|
381
|
+
|| task.target_relation_version !== task.base_relation_version + 1) {
|
|
382
|
+
throw Object.assign(new Error('SDK returned a binding result for a different subject or Owner'), { code: 'TASK_MISMATCH' });
|
|
383
|
+
}
|
|
384
|
+
operationId = task.operation_id;
|
|
385
|
+
if (task.status === 'completed') {
|
|
386
|
+
let consensus;
|
|
387
|
+
try {
|
|
388
|
+
consensus = await bounded(client.checkOwnershipConsensus(aid));
|
|
425
389
|
}
|
|
426
|
-
|
|
390
|
+
catch (error) {
|
|
427
391
|
return result('unknown', {
|
|
428
|
-
code: '
|
|
429
|
-
message:
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
if (task?.status === 'completed') {
|
|
433
|
-
const consensus = await bounded(client.checkOwnershipConsensus(aid));
|
|
434
|
-
if (consensus.status === 'consensus' && consensus.sub_aid === aid && consensus.owner_aid === ownerAid) {
|
|
435
|
-
return result('already_bound');
|
|
436
|
-
}
|
|
437
|
-
return result('failed', {
|
|
438
|
-
code: 'CONSENSUS_REQUIRED',
|
|
439
|
-
message: 'A completed binding task has no current verified Owner consensus',
|
|
392
|
+
code: 'BIND_SUBMIT_UNKNOWN',
|
|
393
|
+
message: error instanceof Error ? error.message : String(error),
|
|
440
394
|
});
|
|
441
395
|
}
|
|
442
|
-
if (task && (['rejected', 'stopped', 'error'].includes(task.status) || task.code)) {
|
|
443
|
-
return result('failed', { code: task.code ?? 'BIND_SUBMIT_FAILED', message: task.reason ?? `Binding task ${task.status}` });
|
|
444
|
-
}
|
|
445
|
-
if (sentOperationIds.has(operationId))
|
|
446
|
-
return result('submitted');
|
|
447
|
-
return result('unknown', {
|
|
448
|
-
code: 'BIND_SUBMIT_UNKNOWN',
|
|
449
|
-
message: 'SDK is recovering the original registration task; no matching message.send acknowledgement was observed',
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
// Reuse the same service as agent-create, including its fresh consensus
|
|
453
|
-
// check, explicit SDK bind call, and persistent task projection.
|
|
454
|
-
resolver.attachClient(aid, client, true);
|
|
455
|
-
const view = await bounded(resolver.bind(aid, ownerAid));
|
|
456
|
-
if (view.consensusStatus === 'consensus' && view.ownerAid === ownerAid) {
|
|
457
|
-
return result('already_bound');
|
|
458
|
-
}
|
|
459
|
-
const returnedTask = view.task;
|
|
460
|
-
if (!returnedTask || returnedTask.operation !== 'bind' || returnedTask.sub_aid !== aid
|
|
461
|
-
|| returnedTask.owner_aid !== ownerAid || returnedTask.new_owner_aid !== undefined
|
|
462
|
-
|| typeof returnedTask.operation_id !== 'string' || !REGISTRATION_OPERATION_ID.test(returnedTask.operation_id)) {
|
|
463
|
-
throw Object.assign(new Error('SDK returned a binding task for a different subject or Owner'), { code: 'TASK_MISMATCH' });
|
|
464
|
-
}
|
|
465
|
-
operationId = returnedTask.operation_id;
|
|
466
|
-
readTask();
|
|
467
|
-
if (!task) {
|
|
468
|
-
throw Object.assign(new Error('SDK binding task was not persisted'), { code: 'BIND_TASK_NOT_PERSISTED' });
|
|
469
|
-
}
|
|
470
|
-
if (task.status === 'completed') {
|
|
471
|
-
const consensus = await bounded(client.checkOwnershipConsensus(aid));
|
|
472
396
|
if (consensus.status === 'consensus' && consensus.sub_aid === aid && consensus.owner_aid === ownerAid) {
|
|
473
397
|
return result('already_bound');
|
|
474
398
|
}
|
|
475
|
-
|
|
399
|
+
if (sentOperationIds.has(operationId))
|
|
400
|
+
return result('submitted');
|
|
401
|
+
return result('unknown', { code: 'BIND_SUBMIT_UNKNOWN', message: 'SDK completed the local bind without a message.send acknowledgement' });
|
|
476
402
|
}
|
|
477
403
|
if (['rejected', 'stopped', 'error'].includes(task.status)) {
|
|
478
404
|
return result('failed', { code: task.code ?? 'BIND_SUBMIT_FAILED', message: task.reason ?? `Binding task ${task.status}` });
|
|
@@ -489,15 +415,14 @@ export async function submitControlAidRegistration(aid, owner, options = {}) {
|
|
|
489
415
|
const details = error;
|
|
490
416
|
const code = typeof details.stringCode === 'string' ? details.stringCode
|
|
491
417
|
: typeof details.code === 'string' ? details.code : undefined;
|
|
492
|
-
|
|
493
|
-
|
|
418
|
+
operationId ??= sentOperationIds.values().next().value;
|
|
419
|
+
const uncertain = connecting && (code === 'BIND_SUBMIT_TIMEOUT' || !code || !!operationId);
|
|
494
420
|
return result(uncertain ? 'unknown' : 'failed', {
|
|
495
421
|
code: uncertain ? 'BIND_SUBMIT_UNKNOWN' : code ?? 'BIND_SUBMIT_FAILED',
|
|
496
422
|
message: details.message ?? String(error),
|
|
497
423
|
});
|
|
498
424
|
}
|
|
499
425
|
finally {
|
|
500
|
-
resolver.stop();
|
|
501
426
|
invitationObserver?.restore();
|
|
502
427
|
if (client) {
|
|
503
428
|
try {
|
|
@@ -58,15 +58,13 @@ export async function executeOwnershipCommand(command, defaultSubjectAid) {
|
|
|
58
58
|
if (!subjectAid)
|
|
59
59
|
throw new OwnershipError('SUBJECT_REQUIRED', 'No local subject AID is available');
|
|
60
60
|
if (command.action === 'status') {
|
|
61
|
-
ownerResolver.
|
|
62
|
-
return ownerResolver.refresh(subjectAid);
|
|
61
|
+
return ownerResolver.status(subjectAid);
|
|
63
62
|
}
|
|
64
63
|
if (command.action === 'accept' || command.action === 'reject') {
|
|
65
64
|
return ownerResolver.decide(subjectAid, command.operationId, command.action, command.action === 'reject' ? command.reason : undefined);
|
|
66
65
|
}
|
|
67
66
|
logger.info(`[ownership] bind requested subject=${subjectAid} owner=${command.ownerAid}`);
|
|
68
67
|
try {
|
|
69
|
-
ownerResolver.assertLocalSubject(subjectAid);
|
|
70
68
|
const result = await ownerResolver.bind(subjectAid, command.ownerAid);
|
|
71
69
|
const task = result.task;
|
|
72
70
|
const log = task && ['rejected', 'stopped', 'error'].includes(task.status) ? logger.warn : logger.info;
|
|
@@ -41,3 +41,11 @@ export function isExplicitGroupId(value) {
|
|
|
41
41
|
|| /^grp_[a-z0-9_-]+$/i.test(id)
|
|
42
42
|
|| /^g-[a-z0-9_-]+(?:[.@][a-z0-9.-]+)?$/i.test(id);
|
|
43
43
|
}
|
|
44
|
+
/** Legacy named-group hint for generic relation data without authoritative type metadata. */
|
|
45
|
+
export function isLegacyNamedGroupIdHint(value) {
|
|
46
|
+
const id = value.trim();
|
|
47
|
+
if (!id)
|
|
48
|
+
return false;
|
|
49
|
+
return /^grp_[a-z0-9_-]+$/i.test(id)
|
|
50
|
+
|| /^g-[a-z0-9_-]+(?:[.@][a-z0-9.-]+)?$/i.test(id);
|
|
51
|
+
}
|
|
@@ -372,6 +372,12 @@ export class GroupInviteReviewService {
|
|
|
372
372
|
if (!runtime)
|
|
373
373
|
return Promise.reject(new Error('邀请审核服务未就绪'));
|
|
374
374
|
const task = this.serial(selfAid, async () => {
|
|
375
|
+
if (!this.active(runtime)) {
|
|
376
|
+
runtime.ready = false;
|
|
377
|
+
runtime.failures = 0;
|
|
378
|
+
runtime.nextSync = Date.now() + 15 * 60_000;
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
375
381
|
try {
|
|
376
382
|
await this.sync(runtime);
|
|
377
383
|
runtime.failures = 0;
|
|
@@ -825,7 +825,7 @@ function parseRemote(value, allowEmpty) {
|
|
|
825
825
|
return failFs('INVALID_ARGUMENT', 'missing remote storage path');
|
|
826
826
|
const separator = value.indexOf(':');
|
|
827
827
|
if (separator <= 0)
|
|
828
|
-
return failFs('INVALID_PATH', 'remote path must use <
|
|
828
|
+
return failFs('INVALID_PATH', 'remote path must use <AID>:<absolute-path>');
|
|
829
829
|
let targetAid;
|
|
830
830
|
const remotePath = value.slice(separator + 1);
|
|
831
831
|
const rawId = value.slice(0, separator).trim();
|
|
@@ -834,7 +834,7 @@ function parseRemote(value, allowEmpty) {
|
|
|
834
834
|
}
|
|
835
835
|
catch (error) {
|
|
836
836
|
if (!isValidAid(rawId))
|
|
837
|
-
return failFs('
|
|
837
|
+
return failFs('INVALID_AID', `invalid AID: ${error.message}`);
|
|
838
838
|
targetAid = rawId;
|
|
839
839
|
}
|
|
840
840
|
if (remotePath === '' && allowEmpty)
|
|
@@ -960,7 +960,7 @@ export function resolveManagedFsOperation(argv) {
|
|
|
960
960
|
if (source && !('targetAid' in source))
|
|
961
961
|
return source;
|
|
962
962
|
if (source && source.targetAid !== destination.targetAid)
|
|
963
|
-
return failFs('
|
|
963
|
+
return failFs('INVALID_ARGUMENT', 'managed cp cannot cross targets');
|
|
964
964
|
const kind = source ? 'copy' : 'upload';
|
|
965
965
|
return { ok: true, command: {
|
|
966
966
|
kind, operationId: `ec.fs.${kind}`, canonicalArgv: ['fs', 'cp', positionals[0], positionals[1], ...(actorAid ? ['--as', actorAid] : [])],
|
|
@@ -976,7 +976,7 @@ export function resolveManagedFsOperation(argv) {
|
|
|
976
976
|
if (!('targetAid' in destination))
|
|
977
977
|
return destination;
|
|
978
978
|
if (source.targetAid !== destination.targetAid)
|
|
979
|
-
return failFs('
|
|
979
|
+
return failFs('INVALID_ARGUMENT', 'managed mv cannot cross targets');
|
|
980
980
|
return { ok: true, command: {
|
|
981
981
|
kind: 'move', operationId: 'ec.fs.move', canonicalArgv: ['fs', 'mv', positionals[0], positionals[1], ...(actorAid ? ['--as', actorAid] : [])],
|
|
982
982
|
actorAid, targetAid: destination.targetAid, remotePath: destination.remotePath, destinationPath: destination.remotePath,
|