evolcore 0.0.42-test.0 → 0.0.43-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 +31 -2
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +4 -2
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
|
+
import { StringDecoder } from 'node:string_decoder';
|
|
4
5
|
import { resolvePaths } from '../../paths.js';
|
|
5
6
|
import { appendJsonlDurable } from '../session/session-fs-store.js';
|
|
6
|
-
import {
|
|
7
|
+
import { isAidWideAbilityQuery } from '../../aun/ability-device-routing.js';
|
|
8
|
+
import { validateAbilityResult } from '../../ability/interop-v1.js';
|
|
7
9
|
export function requestDiagnostics(record) {
|
|
8
10
|
const ignoredReason = record.lastIgnoredResponse?.reason;
|
|
9
11
|
const unresolved = record.state !== 'completed' && record.state !== 'failed';
|
|
@@ -61,6 +63,7 @@ export class AunRequestRegistry {
|
|
|
61
63
|
records = new Map();
|
|
62
64
|
waiters = new Map();
|
|
63
65
|
loaded = new Set();
|
|
66
|
+
appends = new Map();
|
|
64
67
|
key(selfAid, requestId) {
|
|
65
68
|
return `${selfAid}\0${requestId}`;
|
|
66
69
|
}
|
|
@@ -70,20 +73,42 @@ export class AunRequestRegistry {
|
|
|
70
73
|
this.loaded.add(selfAid);
|
|
71
74
|
const file = requestFile(selfAid);
|
|
72
75
|
try {
|
|
73
|
-
const
|
|
74
|
-
for (const line of lines) {
|
|
76
|
+
const visit = (line) => {
|
|
75
77
|
if (!line.trim())
|
|
76
|
-
|
|
78
|
+
return;
|
|
77
79
|
try {
|
|
78
80
|
const event = JSON.parse(line);
|
|
79
|
-
if (event?.event !== 'upsert' || !event.record?.requestId)
|
|
80
|
-
|
|
81
|
+
if (event?.event !== 'upsert' || !event.record?.requestId || event.record.selfAid !== selfAid)
|
|
82
|
+
return;
|
|
81
83
|
const recovered = event.record.state === 'created' || event.record.state === 'sending'
|
|
82
84
|
? { ...event.record, state: 'unknown', updatedAt: Date.now() }
|
|
83
85
|
: event.record;
|
|
84
86
|
this.records.set(this.key(selfAid, recovered.requestId), recovered);
|
|
85
87
|
}
|
|
86
88
|
catch { /* ignore an incomplete/corrupt historical line */ }
|
|
89
|
+
};
|
|
90
|
+
const fd = fs.openSync(file, 'r');
|
|
91
|
+
const decoder = new StringDecoder('utf8');
|
|
92
|
+
const chunk = Buffer.alloc(65536);
|
|
93
|
+
let tail = '';
|
|
94
|
+
try {
|
|
95
|
+
for (;;) {
|
|
96
|
+
const size = fs.readSync(fd, chunk, 0, chunk.length, null);
|
|
97
|
+
if (!size)
|
|
98
|
+
break;
|
|
99
|
+
tail += decoder.write(chunk.subarray(0, size));
|
|
100
|
+
let end;
|
|
101
|
+
while ((end = tail.indexOf('\n')) >= 0) {
|
|
102
|
+
visit(tail.slice(0, end));
|
|
103
|
+
tail = tail.slice(end + 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
tail += decoder.end();
|
|
107
|
+
if (tail.trim())
|
|
108
|
+
visit(tail);
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
fs.closeSync(fd);
|
|
87
112
|
}
|
|
88
113
|
for (const record of this.recordsFor(selfAid)) {
|
|
89
114
|
for (const alias of record.correlationKeys)
|
|
@@ -106,6 +131,38 @@ export class AunRequestRegistry {
|
|
|
106
131
|
this.records.set(this.key(record.selfAid, record.requestId), record);
|
|
107
132
|
for (const alias of record.correlationKeys)
|
|
108
133
|
this.records.set(this.key(record.selfAid, alias), record);
|
|
134
|
+
const count = (this.appends.get(record.selfAid) ?? 0) + 1;
|
|
135
|
+
this.appends.set(record.selfAid, count);
|
|
136
|
+
if (count >= 500) {
|
|
137
|
+
this.appends.set(record.selfAid, 0);
|
|
138
|
+
this.compact(record.selfAid);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Compact duplicate events without expiring operation receipts or aliases. */
|
|
142
|
+
compact(selfAid) {
|
|
143
|
+
this.ensureLoaded(selfAid);
|
|
144
|
+
const tempRoot = process.env.TMPDIR;
|
|
145
|
+
if (!tempRoot || !path.isAbsolute(tempRoot))
|
|
146
|
+
return;
|
|
147
|
+
fs.mkdirSync(tempRoot, { recursive: true });
|
|
148
|
+
const directory = fs.mkdtempSync(path.join(tempRoot, 'aun-request-compact-'));
|
|
149
|
+
const staged = path.join(directory, 'requests.jsonl');
|
|
150
|
+
try {
|
|
151
|
+
const fd = fs.openSync(staged, 'wx', 0o600);
|
|
152
|
+
try {
|
|
153
|
+
for (const record of this.recordsFor(selfAid))
|
|
154
|
+
fs.writeSync(fd, JSON.stringify({ event: 'upsert', record }) + '\n');
|
|
155
|
+
fs.fsyncSync(fd);
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
fs.closeSync(fd);
|
|
159
|
+
}
|
|
160
|
+
fs.renameSync(staged, requestFile(selfAid));
|
|
161
|
+
}
|
|
162
|
+
catch { /* Cross-volume replacement or file contention: retain the complete original log. */ }
|
|
163
|
+
finally {
|
|
164
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
165
|
+
}
|
|
109
166
|
}
|
|
110
167
|
notify(record) {
|
|
111
168
|
if (!['completed', 'failed', 'unknown', 'pending'].includes(record.state))
|
|
@@ -129,6 +186,20 @@ export class AunRequestRegistry {
|
|
|
129
186
|
const correlationKind = requestId || !callId ? 'request_id' : 'call_id';
|
|
130
187
|
const now = Date.now();
|
|
131
188
|
const timeoutMs = normalizeTimeoutMs(params.timeoutMs);
|
|
189
|
+
const discoveryWindow = params.payload.type === 'ability' && params.payload.ability_path === 'protocol/discover'
|
|
190
|
+
? Number(params.payload.params?.window_seconds) : undefined;
|
|
191
|
+
const collectionMs = discoveryWindow && Number.isInteger(discoveryWindow) && discoveryWindow >= 1 && discoveryWindow <= 30 ? discoveryWindow * 1000 : timeoutMs;
|
|
192
|
+
const abilityCorrelation = params.payload.type === 'ability' && params.payload.role === 'call'
|
|
193
|
+
&& !!callId
|
|
194
|
+
&& typeof params.payload.ability_path === 'string'
|
|
195
|
+
&& typeof params.payload.operation_id === 'string'
|
|
196
|
+
? {
|
|
197
|
+
callId,
|
|
198
|
+
abilityPath: params.payload.ability_path,
|
|
199
|
+
...(typeof params.payload.definition_id === 'string' ? { definitionId: params.payload.definition_id } : {}),
|
|
200
|
+
operationId: params.payload.operation_id,
|
|
201
|
+
}
|
|
202
|
+
: undefined;
|
|
132
203
|
const record = {
|
|
133
204
|
selfAid: params.selfAid,
|
|
134
205
|
targetAid: params.targetAid,
|
|
@@ -140,14 +211,10 @@ export class AunRequestRegistry {
|
|
|
140
211
|
state: 'created',
|
|
141
212
|
createdAt: now,
|
|
142
213
|
updatedAt: now,
|
|
143
|
-
deadlineAt: now +
|
|
144
|
-
...(
|
|
214
|
+
deadlineAt: now + collectionMs,
|
|
215
|
+
...(abilityCorrelation ? { responseCorrelation: abilityCorrelation } : {}),
|
|
216
|
+
...(!params.targetDeviceId && isAidWideAbilityQuery(params.payload) ? {
|
|
145
217
|
responseMode: 'all_devices',
|
|
146
|
-
responseCorrelation: {
|
|
147
|
-
abilityPath: params.payload.ability_path,
|
|
148
|
-
definitionId: params.payload.definition_id,
|
|
149
|
-
operationId: params.payload.operation_id,
|
|
150
|
-
},
|
|
151
218
|
responses: [],
|
|
152
219
|
} : {}),
|
|
153
220
|
};
|
|
@@ -225,16 +292,28 @@ export class AunRequestRegistry {
|
|
|
225
292
|
ignoredResponseCount: (record.ignoredResponseCount ?? 0) + 1,
|
|
226
293
|
});
|
|
227
294
|
}
|
|
295
|
+
const expected = record.responseCorrelation;
|
|
296
|
+
if (expected) {
|
|
297
|
+
// Match EvolApp's caller: encrypted private transport is required.
|
|
298
|
+
// Generic requests keep their existing transport semantics.
|
|
299
|
+
if (params.encrypted !== true || params.transport !== 'p2p')
|
|
300
|
+
continue;
|
|
301
|
+
try {
|
|
302
|
+
// EvolApp replay ACKs can omit ability_path; terminal results must
|
|
303
|
+
// echo the call contract. Neither malformed replies nor another
|
|
304
|
+
// message type may consume this request's correlation key.
|
|
305
|
+
validateAbilityResult(payload, { ...expected, callId: expected.callId ?? record.requestId });
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
228
311
|
if (record.responseMode === 'all_devices') {
|
|
229
312
|
// Device identity is authenticated transport metadata, never payload data.
|
|
230
313
|
// Keep each device's terminal result and do not finish on the first one.
|
|
231
314
|
if (!stringValue(params.fromDeviceId) || !record.deadlineAt || Date.now() >= record.deadlineAt)
|
|
232
315
|
continue;
|
|
233
|
-
|
|
234
|
-
if (payload.type !== 'ability' || !['ack', 'result'].includes(String(payload.role))
|
|
235
|
-
|| payload.ability_path !== expected?.abilityPath
|
|
236
|
-
|| payload.definition_id !== expected?.definitionId
|
|
237
|
-
|| payload.operation_id !== expected?.operationId)
|
|
316
|
+
if (!expected)
|
|
238
317
|
continue;
|
|
239
318
|
if (this.isIntermediateResponse(payload)) {
|
|
240
319
|
return this.updateWithoutNotify(params.selfAid, record.requestId, {
|
|
@@ -292,6 +371,8 @@ export class AunRequestRegistry {
|
|
|
292
371
|
const record = this.get(selfAid, requestId);
|
|
293
372
|
if (!record || ['completed', 'failed', 'unknown'].includes(record.state))
|
|
294
373
|
return record;
|
|
374
|
+
if (record.responseMode === 'all_devices' && record.deadlineAt && record.deadlineAt > Date.now())
|
|
375
|
+
return record;
|
|
295
376
|
return this.update(selfAid, requestId, {
|
|
296
377
|
state: record.responseMode === 'all_devices' && record.responses?.length ? 'completed' : 'pending',
|
|
297
378
|
});
|
|
@@ -34,6 +34,7 @@ export class IMRenderer {
|
|
|
34
34
|
loggedBlankTextDiagnostic = false;
|
|
35
35
|
/** 串行发送队列:保证消息按序到达 */
|
|
36
36
|
sendChain = Promise.resolve();
|
|
37
|
+
activityRecordChain = Promise.resolve();
|
|
37
38
|
/** proactive:是否已发过 text 文本(用于去重 complete.result) */
|
|
38
39
|
hasEmittedText = false;
|
|
39
40
|
/** 自增 callId 兜底(runner 没提供时用) */
|
|
@@ -55,6 +56,12 @@ export class IMRenderer {
|
|
|
55
56
|
parentSubtasks = new Map();
|
|
56
57
|
constructor(opts) {
|
|
57
58
|
this.opts = opts;
|
|
59
|
+
const send = opts.send;
|
|
60
|
+
this.opts = { ...opts, send: payload => {
|
|
61
|
+
// Capture the current barrier: later activities must not hold this send.
|
|
62
|
+
const recorded = this.activityRecordChain;
|
|
63
|
+
return recorded.then(() => send(payload));
|
|
64
|
+
} };
|
|
58
65
|
}
|
|
59
66
|
suppressActivityItems() {
|
|
60
67
|
return this.opts.suppressActivityItems ?? this.opts.suppressActivities ?? false;
|
|
@@ -96,9 +103,11 @@ export class IMRenderer {
|
|
|
96
103
|
}
|
|
97
104
|
/** 强制刷新所有 pending 事件 */
|
|
98
105
|
async flush(isFinal, attention) {
|
|
106
|
+
await this.activityRecordChain;
|
|
99
107
|
if (this.opts.envelope.chatmode === 'proactive') {
|
|
100
108
|
// proactive 是 fire-and-forget,无 pending buffer;只需放出仍被扣住的工具结果
|
|
101
109
|
this.releaseHeldToolResults();
|
|
110
|
+
await this.activityRecordChain;
|
|
102
111
|
return;
|
|
103
112
|
}
|
|
104
113
|
return this.flushInternal(isFinal, attention);
|
|
@@ -432,6 +441,7 @@ export class IMRenderer {
|
|
|
432
441
|
decision: 'deny',
|
|
433
442
|
decisionSource: 'policy',
|
|
434
443
|
...(activity.policyCode ? { policyCode: activity.policyCode } : {}),
|
|
444
|
+
...(activity.matchedRule ? { matchedRule: activity.matchedRule } : {}),
|
|
435
445
|
reason: activity.reason,
|
|
436
446
|
executed: false,
|
|
437
447
|
executionState: 'blocked',
|
|
@@ -945,20 +955,15 @@ export class IMRenderer {
|
|
|
945
955
|
}
|
|
946
956
|
this.emitProactiveItem(item);
|
|
947
957
|
}
|
|
948
|
-
/**
|
|
958
|
+
/** Serialize persistence and resource preparation before publishing items. */
|
|
949
959
|
recordActivity(item) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
result.catch(error => {
|
|
954
|
-
logger.warn(`[IMRenderer] task activity record failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
catch (error) {
|
|
960
|
+
this.activityRecordChain = this.activityRecordChain.then(async () => {
|
|
961
|
+
await this.opts.recordActivity?.(item);
|
|
962
|
+
}).catch(error => {
|
|
959
963
|
logger.warn(`[IMRenderer] task activity record failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
960
|
-
}
|
|
964
|
+
});
|
|
961
965
|
}
|
|
966
|
+
/** proactive:单个 ThoughtItem 包成 activity.batch[1] 发出。 */
|
|
962
967
|
emitProactiveItem(item) {
|
|
963
968
|
this.recordActivity(item);
|
|
964
969
|
const evolCommand = item.kind === 'tool_call' ? item.evolCommand : undefined;
|
|
@@ -4,9 +4,10 @@ import { isValidAid } from '../../aun/aid/validation.js';
|
|
|
4
4
|
import { readOwnerDirectoryMembership } from '../../directory/owner-directory-admission.js';
|
|
5
5
|
import { resolveAunPeerKind } from '../relation/peer-identity.js';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* 出站私聊准入:与入站使用同一套判定,保证双向对称。
|
|
8
8
|
*
|
|
9
|
-
* 顺序与入站一致:本地拉黑 → Owner/个人助理 → 黑名单 → 白名单
|
|
9
|
+
* 顺序与入站一致:本地拉黑 → Owner/个人助理 → 黑名单 → 白名单
|
|
10
|
+
* → `allowAllContacts` 总开关 → 名录内部/外部档。
|
|
10
11
|
* 群聊的准入单位是群,出站到群不做发言人判定。
|
|
11
12
|
*/
|
|
12
13
|
export async function evaluateOutboundContactAdmission(input) {
|
|
@@ -44,10 +45,13 @@ export async function evaluateOutboundContactAdmission(input) {
|
|
|
44
45
|
}
|
|
45
46
|
if (policy.allowedAids?.includes(targetAid))
|
|
46
47
|
return { allow: true, status: 'allowed_aid' };
|
|
48
|
+
// 总开关:压过名录三档(含名录不可用)。拉黑与 deniedAids 已在本行之前判定。
|
|
49
|
+
if (policy.allowAllContacts === true)
|
|
50
|
+
return { allow: true, status: 'all_contacts' };
|
|
47
51
|
const membership = readOwnerDirectoryMembership(selfAid, targetAid);
|
|
48
52
|
switch (membership?.category) {
|
|
49
53
|
case 'unavailable':
|
|
50
|
-
return { allow: false, code: 'CONTACT_DIRECTORY_UNAVAILABLE', status: 'unavailable', error: 'Owner
|
|
54
|
+
return { allow: false, code: 'CONTACT_DIRECTORY_UNAVAILABLE', status: 'unavailable', error: 'Owner 名录当前不可用,无法确认目标身份,已拒绝发送;如需无条件联系请开启 allowAllContacts' };
|
|
51
55
|
case 'owner':
|
|
52
56
|
return { allow: true, status: 'owner' };
|
|
53
57
|
case 'assistant':
|
|
@@ -58,17 +62,15 @@ export async function evaluateOutboundContactAdmission(input) {
|
|
|
58
62
|
if (membership.internal) {
|
|
59
63
|
return policy.allowInternalContacts !== false
|
|
60
64
|
? { allow: true, status: 'internal' }
|
|
61
|
-
: { allow: false, code: 'CONTACT_INTERNAL_DISABLED', status: 'disabled', error: '当前 Agent 不接受内部联系,Owner 未开启 allowInternalContacts' };
|
|
65
|
+
: { allow: false, code: 'CONTACT_INTERNAL_DISABLED', status: 'disabled', error: '当前 Agent 不接受内部联系,Owner 未开启 allowInternalContacts 与 allowAllContacts' };
|
|
62
66
|
}
|
|
63
67
|
return policy.allowExternalContacts === true
|
|
64
68
|
? { allow: true, status: 'external' }
|
|
65
|
-
: { allow: false, code: 'CONTACT_EXTERNAL_DISABLED', status: 'disabled', error: '当前 Agent 不接受外部联系,Owner 未开启 allowExternalContacts' };
|
|
69
|
+
: { allow: false, code: 'CONTACT_EXTERNAL_DISABLED', status: 'disabled', error: '当前 Agent 不接受外部联系,Owner 未开启 allowExternalContacts 与 allowAllContacts' };
|
|
66
70
|
}
|
|
67
71
|
case 'not_found':
|
|
68
72
|
default:
|
|
69
|
-
|
|
70
|
-
return { allow: true, status: 'stranger' };
|
|
71
|
-
return { allow: false, code: 'CONTACT_STRANGER_DISABLED', status: 'disabled', error: `目标 ${targetAid} 不在当前 Agent 的 Owner 名录中,Owner 未开启 allowStrangerContacts` };
|
|
73
|
+
return { allow: false, code: 'CONTACT_ALL_CONTACTS_DISABLED', status: 'disabled', error: `目标 ${targetAid} 不在当前 Agent 的 Owner 名录中,Owner 未开启 allowAllContacts` };
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
export function evaluateInboundAdmissionPreflight(input) {
|
|
@@ -146,8 +148,8 @@ export function evaluateInboundAdmissionPreflight(input) {
|
|
|
146
148
|
* - `owner` / `assistant`:恒放行,不受任何开关与名单影响。
|
|
147
149
|
* - 命中条目且属于本 Owner → `allowInternalContacts`。
|
|
148
150
|
* - 命中条目但归属其他 Owner(或缺失归属)→ `allowExternalContacts`。
|
|
149
|
-
* - 未命中 → 返回 undefined,由调用方按 `
|
|
150
|
-
* - 名录不可用 →
|
|
151
|
+
* - 未命中 → 返回 undefined,由调用方按 `allowAllContacts` 决定。
|
|
152
|
+
* - 名录不可用 → 拒绝,不回退放行(`allowAllContacts` 与白名单都在调用方更早处置)。
|
|
151
153
|
*
|
|
152
154
|
* 拒绝发生在业务路由之前,被拒的名录发送者不会收到自动回复。
|
|
153
155
|
*/
|
|
@@ -185,8 +187,9 @@ export function evaluateOwnerDirectoryInboundAdmission(context) {
|
|
|
185
187
|
/**
|
|
186
188
|
* 普通消息准入。出站私聊复用同一套判定,保证出入站对称。
|
|
187
189
|
*
|
|
188
|
-
* 顺序:可信 handoff → Owner/个人助理 → 群聊(准入单位是整个群)→ 黑名单
|
|
189
|
-
* →
|
|
190
|
+
* 顺序:可信 handoff → Owner/个人助理 → 群聊(准入单位是整个群)→ 黑名单
|
|
191
|
+
* → `allowAllContacts` 总开关 → 名录不可用 → 白名单 → 名录三档。
|
|
192
|
+
* 群聊不按发言人判定,因此群内发言人即使落在被关闭的档也放行。
|
|
190
193
|
*/
|
|
191
194
|
export function evaluateOrdinaryInboundAdmission(context) {
|
|
192
195
|
const decision = evaluateOrdinaryAdmission(context);
|
|
@@ -215,23 +218,25 @@ function evaluateOrdinaryAdmission(context) {
|
|
|
215
218
|
&& (directoryDecision.reason === 'owner_directory_owner' || directoryDecision.reason === 'owner_directory_assistant')) {
|
|
216
219
|
return directoryDecision;
|
|
217
220
|
}
|
|
218
|
-
//
|
|
219
|
-
if (directoryDecision && !directoryDecision.allow && directoryDecision.reason === 'owner_directory_unavailable') {
|
|
220
|
-
return directoryDecision;
|
|
221
|
-
}
|
|
221
|
+
// 黑名单在总开关之前:deniedAids 是 Owner 显式指定的拒绝,总开关翻不动它。
|
|
222
222
|
const aid = context.primaryId;
|
|
223
223
|
if (aid && policy.deniedAids?.includes(aid)) {
|
|
224
224
|
return { allow: false, reason: 'denied_aid', context };
|
|
225
225
|
}
|
|
226
|
+
// 总开关:压过名录三档,也压过名录不可用。
|
|
227
|
+
if (policy.allowAllContacts === true) {
|
|
228
|
+
return { allow: true, reason: 'all_contacts_allowed', context };
|
|
229
|
+
}
|
|
230
|
+
// 名录不可用是 fail closed,白名单不能把它翻成放行。
|
|
231
|
+
if (directoryDecision && !directoryDecision.allow && directoryDecision.reason === 'owner_directory_unavailable') {
|
|
232
|
+
return directoryDecision;
|
|
233
|
+
}
|
|
226
234
|
if (aid && policy.allowedAids?.includes(aid)) {
|
|
227
235
|
return { allow: true, reason: 'allowed_aid', context };
|
|
228
236
|
}
|
|
229
237
|
if (directoryDecision)
|
|
230
238
|
return directoryDecision;
|
|
231
|
-
|
|
232
|
-
return { allow: true, reason: 'stranger_contacts_allowed', context };
|
|
233
|
-
}
|
|
234
|
-
return { allow: false, reason: 'stranger_contacts_disabled', context };
|
|
239
|
+
return { allow: false, reason: 'all_contacts_disabled', context };
|
|
235
240
|
}
|
|
236
241
|
const principalReplyBuckets = new Map();
|
|
237
242
|
const channelReplyBuckets = new Map();
|
|
@@ -24,11 +24,6 @@ import { resolveEffective } from '../../config/config-manager.js';
|
|
|
24
24
|
import { createDecisionInferenceProvider } from '../inference/text-inference.js';
|
|
25
25
|
import { AutoMentionGate } from './auto-mention-gate.js';
|
|
26
26
|
import { syncGroupRulesContext } from '../../eck/group-rules-sync.js';
|
|
27
|
-
import { handlePendingDingtalkContactBindMessage, registerPendingDingtalkContactBind } from '../../channels/dingtalk.js';
|
|
28
|
-
import { handlePendingFeishuContactBindMessage, registerPendingFeishuContactBind } from '../../channels/feishu.js';
|
|
29
|
-
import { handlePendingQQBotContactBindMessage, registerPendingQQBotContactBind } from '../../channels/qqbot.js';
|
|
30
|
-
import { handlePendingWecomContactBindMessage, registerPendingWecomContactBind } from '../../channels/wecom.js';
|
|
31
|
-
import { handlePendingWechatContactBindMessage, registerPendingWechatContactBind } from '../../channels/wechat.js';
|
|
32
27
|
import { authorizeAccess, buildAuthSubject } from '../auth/auth-gateway.js';
|
|
33
28
|
import { MenuDiagnosticLimiter, MenuRequestDeduper, hasValidMenuId, menuFailure, menuPayloadFingerprint, menuSuccess, normalizeMenuError, parseMenuControl, validateMenuRequest, evaluateEvolMenuVersionGate, evolMenuResponseTransportMetadata, isAunMenuTokenRequired, menuCommandForName, normalizeMenuResponseTiming, withMenuProcessingTime, logMenuRequestCompleted, logMenuRequestReceived, } from '../command/menu-protocol.js';
|
|
34
29
|
import { resolveExplicitMenuExecutionContext, validateMenuCatalogArgs, validateMenuValueBatchArgs } from '../command/menu-catalog.js';
|
|
@@ -49,14 +44,6 @@ const REJECTABLE_PEER_TYPES = new Set(['ai', 'bot', 'agent', 'service']);
|
|
|
49
44
|
const REJECTION_MAX = 3;
|
|
50
45
|
const REJECTION_WINDOW_MS = 60 * 60 * 1000;
|
|
51
46
|
const rejectionState = new Map();
|
|
52
|
-
const SELF_SERVICE_CONTACT_BIND_TYPES = ['feishu', 'dingtalk', 'wecom', 'qqbot', 'wechat'];
|
|
53
|
-
const SELF_SERVICE_CONTACT_BIND_DISPLAY = {
|
|
54
|
-
feishu: '飞书',
|
|
55
|
-
dingtalk: '钉钉',
|
|
56
|
-
wecom: '企微',
|
|
57
|
-
qqbot: 'QQ',
|
|
58
|
-
wechat: '微信',
|
|
59
|
-
};
|
|
60
47
|
export function shouldBlockInboundContact(input) {
|
|
61
48
|
if (!input.selfAid) {
|
|
62
49
|
return { blocked: false, status: 'unsupported-channel' };
|
|
@@ -202,6 +189,7 @@ export class MessageBridge {
|
|
|
202
189
|
diagnosticRouter;
|
|
203
190
|
aidStatsCollector;
|
|
204
191
|
contactBindRuntimeChecker;
|
|
192
|
+
contactBindRegistry;
|
|
205
193
|
interactionRouter;
|
|
206
194
|
groupInviteReviewService;
|
|
207
195
|
constructor(defaultProjectPath, sessionManager, processor, messageQueue, cmdHandler, eventBus, defaultDebounce, processOwnersProvider) {
|
|
@@ -239,6 +227,9 @@ export class MessageBridge {
|
|
|
239
227
|
setContactBindRuntimeChecker(checker) {
|
|
240
228
|
this.contactBindRuntimeChecker = checker;
|
|
241
229
|
}
|
|
230
|
+
setContactBindRegistry(registry) {
|
|
231
|
+
this.contactBindRegistry = registry;
|
|
232
|
+
}
|
|
242
233
|
setInteractionRouter(router) {
|
|
243
234
|
this.interactionRouter = router;
|
|
244
235
|
}
|
|
@@ -349,10 +340,12 @@ export class MessageBridge {
|
|
|
349
340
|
if (args.length > 2) {
|
|
350
341
|
return { handled: true, status: 'format', reply: this.aunSelfServiceBindUsage() };
|
|
351
342
|
}
|
|
352
|
-
const channelType = args[0]
|
|
353
|
-
|
|
343
|
+
const channelType = args[0]?.toLowerCase() ?? '';
|
|
344
|
+
const provider = this.contactBindRegistry?.get(channelType);
|
|
345
|
+
if (!provider) {
|
|
354
346
|
return { handled: true, status: 'unsupported-channel', reply: this.aunSelfServiceBindUsage() };
|
|
355
347
|
}
|
|
348
|
+
const displayName = provider.displayName;
|
|
356
349
|
const agent = input.owningAgent ?? this.agentRegistry?.get(selfAid);
|
|
357
350
|
if (!agent || agent.aid !== selfAid) {
|
|
358
351
|
return {
|
|
@@ -373,7 +366,7 @@ export class MessageBridge {
|
|
|
373
366
|
return {
|
|
374
367
|
handled: true,
|
|
375
368
|
status: 'unknown-instance',
|
|
376
|
-
reply: `未找到已启用的 ${
|
|
369
|
+
reply: `未找到已启用的 ${displayName} 实例 “${requestedInstance}”。${this.aunSelfServiceBindInstances(channelType, instances)}`,
|
|
377
370
|
};
|
|
378
371
|
}
|
|
379
372
|
}
|
|
@@ -384,14 +377,14 @@ export class MessageBridge {
|
|
|
384
377
|
return {
|
|
385
378
|
handled: true,
|
|
386
379
|
status: 'not-configured',
|
|
387
|
-
reply: `目标 Agent 未启用 ${
|
|
380
|
+
reply: `目标 Agent 未启用 ${displayName} 机器人,无法创建联系人绑定码。`,
|
|
388
381
|
};
|
|
389
382
|
}
|
|
390
383
|
else {
|
|
391
384
|
return {
|
|
392
385
|
handled: true,
|
|
393
386
|
status: 'instance-required',
|
|
394
|
-
reply: `该 Agent 有多个 ${
|
|
387
|
+
reply: `该 Agent 有多个 ${displayName} 实例。${this.aunSelfServiceBindInstances(channelType, instances)}`,
|
|
395
388
|
};
|
|
396
389
|
}
|
|
397
390
|
const channelName = formatChannelKey({ type: channelType, selfAID: selfAid, name: instance.name });
|
|
@@ -402,11 +395,10 @@ export class MessageBridge {
|
|
|
402
395
|
return {
|
|
403
396
|
handled: true,
|
|
404
397
|
status: 'runtime-unavailable',
|
|
405
|
-
reply: `${
|
|
398
|
+
reply: `${displayName}实例当前未连接,未创建联系人绑定码。请等待机器人上线后重试。`,
|
|
406
399
|
};
|
|
407
400
|
}
|
|
408
|
-
const result = this.
|
|
409
|
-
channelType,
|
|
401
|
+
const result = this.contactBindRegistry.registerPending(channelType, {
|
|
410
402
|
selfAid,
|
|
411
403
|
channelName,
|
|
412
404
|
primaryId: actorId,
|
|
@@ -416,26 +408,18 @@ export class MessageBridge {
|
|
|
416
408
|
return {
|
|
417
409
|
handled: true,
|
|
418
410
|
status: 'register-failed',
|
|
419
|
-
reply: `未能创建${
|
|
411
|
+
reply: `未能创建${displayName}身份绑定码:${result.error}。请稍后重试。`,
|
|
420
412
|
};
|
|
421
413
|
}
|
|
422
414
|
return {
|
|
423
415
|
handled: true,
|
|
424
416
|
status: result.replaced ? 'replaced' : 'issued',
|
|
425
|
-
reply: `请在 ${
|
|
417
|
+
reply: `请在 ${displayName} 机器人私聊中发送 /bind ${result.code} 完成联系人绑定。绑定 10 分钟内有效,不会修改 Owner、Admin 或关系角色配置。`,
|
|
426
418
|
};
|
|
427
419
|
}
|
|
428
|
-
registerSelfServiceContactBind(input) {
|
|
429
|
-
switch (input.channelType) {
|
|
430
|
-
case 'feishu': return registerPendingFeishuContactBind(input);
|
|
431
|
-
case 'dingtalk': return registerPendingDingtalkContactBind(input);
|
|
432
|
-
case 'wecom': return registerPendingWecomContactBind(input);
|
|
433
|
-
case 'qqbot': return registerPendingQQBotContactBind(input);
|
|
434
|
-
case 'wechat': return registerPendingWechatContactBind(input);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
420
|
aunSelfServiceBindUsage() {
|
|
438
|
-
|
|
421
|
+
const types = this.contactBindRegistry?.channelTypes() ?? [];
|
|
422
|
+
return `用法:/bind(首个兼容绑定目标发起 ownership 绑定);/bind <渠道> [实例名](联系人绑定)。支持渠道:${types.join('、')}。`;
|
|
439
423
|
}
|
|
440
424
|
aunSelfServiceBindInstances(channelType, instances) {
|
|
441
425
|
const names = instances.map(instance => String(instance.name || '').trim()).filter(Boolean);
|
|
@@ -453,17 +437,7 @@ export class MessageBridge {
|
|
|
453
437
|
actorId: context.actorId,
|
|
454
438
|
content,
|
|
455
439
|
};
|
|
456
|
-
const contactBind = context.channelType
|
|
457
|
-
? handlePendingDingtalkContactBindMessage(bindContext)
|
|
458
|
-
: context.channelType === 'feishu'
|
|
459
|
-
? handlePendingFeishuContactBindMessage(bindContext)
|
|
460
|
-
: context.channelType === 'wecom'
|
|
461
|
-
? handlePendingWecomContactBindMessage(bindContext)
|
|
462
|
-
: context.channelType === 'qqbot'
|
|
463
|
-
? handlePendingQQBotContactBindMessage(bindContext)
|
|
464
|
-
: context.channelType === 'wechat'
|
|
465
|
-
? handlePendingWechatContactBindMessage(bindContext)
|
|
466
|
-
: { handled: false };
|
|
440
|
+
const contactBind = this.contactBindRegistry?.handle(context.channelType, bindContext) ?? { handled: false };
|
|
467
441
|
if (contactBind.handled) {
|
|
468
442
|
logger.info(`[MessageBridge] ${context.channelType} contact bind handled before admission: channel=${context.channelKey} actor=${context.actorId || '<none>'} status=${contactBind.status}`);
|
|
469
443
|
if (contactBind.reply) {
|
|
@@ -699,9 +673,9 @@ export class MessageBridge {
|
|
|
699
673
|
if (reason === 'owner_directory_unavailable')
|
|
700
674
|
return undefined;
|
|
701
675
|
if (channelType === 'aun') {
|
|
702
|
-
return '
|
|
676
|
+
return '当前不接受非联系人消息。可发送 /request <申请说明> 申请成为联系人。';
|
|
703
677
|
}
|
|
704
|
-
return '
|
|
678
|
+
return '当前不接受非联系人消息。联系人申请仅支持 AUN 私聊。';
|
|
705
679
|
}
|
|
706
680
|
async deliverContactReviewCard(selfAid, applicantAid, submission, owningAgent) {
|
|
707
681
|
if (!this.interactionRouter || !submission.requestId || !submission.expiresAt || !submission.submittedAt) {
|
|
@@ -2161,7 +2135,7 @@ export class MessageBridge {
|
|
|
2161
2135
|
if (request.type === 'menu.action' && request.action === 'upgrade' && (request.name === 'system' || request.cmd === '/system') && upgradeData?.jobId) {
|
|
2162
2136
|
const jobId = upgradeData.jobId;
|
|
2163
2137
|
subscribeUpgradeJob(jobId, async (event) => {
|
|
2164
|
-
const permission = await this.cmdHandler.execMenuAction('/system', 'upgrade', { mode: 'status'
|
|
2138
|
+
const permission = await this.cmdHandler.execMenuAction('/system', 'upgrade', { mode: 'status' }, channel, msg.channelId, msg.peerId, undefined, msg.replyContext?.delivery?.chatType, undefined, false, undefined, 'menu', msg.replyContext);
|
|
2165
2139
|
if ('error' in permission)
|
|
2166
2140
|
throw new Error('Upgrade event authorization expired');
|
|
2167
2141
|
await adapter.send(envelope, { kind: 'custom', channelType: channel, payload: event });
|
|
@@ -1681,6 +1681,9 @@ export class MessageQueue {
|
|
|
1681
1681
|
isChannelProcessing(channelName) {
|
|
1682
1682
|
const prefix = `${channelName}-`;
|
|
1683
1683
|
for (const key of this.processing.keys()) {
|
|
1684
|
+
if (this.activeBatches.get(key)?.message.channel === channelName) {
|
|
1685
|
+
return true;
|
|
1686
|
+
}
|
|
1684
1687
|
if (key.startsWith(prefix) || key.startsWith(`${channelName}::`)) {
|
|
1685
1688
|
return true;
|
|
1686
1689
|
}
|
|
@@ -2913,7 +2913,7 @@ export class ResponseEngine {
|
|
|
2913
2913
|
'/model', '/effort', '/agent', '/slist', '/session', '/rename', '/repair', '/fork',
|
|
2914
2914
|
'/stop', '/pause', '/resume', '/clear', '/compact', '/renew', '/del', '/perm', '/file', '/check',
|
|
2915
2915
|
'/s ', '/name ', '/rewind', '/rw', '/rw ', '/activity', '/observable', '/chatmode',
|
|
2916
|
-
'/aid', '/upgrade', '/evolagent', '/pair ', '/memory',
|
|
2916
|
+
'/aid', '/upgrade', '/update', '/evolagent', '/pair ', '/memory',
|
|
2917
2917
|
];
|
|
2918
2918
|
/** 判断消息内容是否为已知命令 */
|
|
2919
2919
|
isKnownCommand(content) {
|
|
@@ -3571,6 +3571,7 @@ export class ResponseEngine {
|
|
|
3571
3571
|
const taskId = `task-${crypto.randomUUID().replace(/-/g, '').slice(0, 10)}`;
|
|
3572
3572
|
let taskActivityStatus = 'running';
|
|
3573
3573
|
const taskActivityStore = runnerSelfAid ? new TaskActivityStore(runnerSelfAid) : undefined;
|
|
3574
|
+
let toolImageReadRoots = [];
|
|
3574
3575
|
if (taskActivityStore) {
|
|
3575
3576
|
try {
|
|
3576
3577
|
const activityChatType = chatType === 'group' ? 'group' : 'private';
|
|
@@ -4246,7 +4247,7 @@ export class ResponseEngine {
|
|
|
4246
4247
|
deferTextUntilBoundary: (message.channelType ?? session.channelType) === 'aun' && session.chatType === 'private',
|
|
4247
4248
|
operationalNoticesAsText: !isProactive && middleOutputMode !== 'none',
|
|
4248
4249
|
fileMarkerPattern: options?.fileMarkerPattern,
|
|
4249
|
-
recordActivity: item => {
|
|
4250
|
+
recordActivity: async (item) => {
|
|
4250
4251
|
if (!taskActivityStore || (turnLease && !this.turnCoordinator.canPublish(turnLease)))
|
|
4251
4252
|
return;
|
|
4252
4253
|
try {
|
|
@@ -4254,7 +4255,7 @@ export class ResponseEngine {
|
|
|
4254
4255
|
const activityChannelId = activityChatType === 'group'
|
|
4255
4256
|
? (message.groupId || session.metadata?.groupId || message.channelId)
|
|
4256
4257
|
: (message.peerId || message.channelId);
|
|
4257
|
-
taskActivityStore.
|
|
4258
|
+
await taskActivityStore.appendWithImage({
|
|
4258
4259
|
taskId,
|
|
4259
4260
|
sessionId: session.id,
|
|
4260
4261
|
channel: message.channelType || session.channelType || message.channel,
|
|
@@ -4263,7 +4264,7 @@ export class ResponseEngine {
|
|
|
4263
4264
|
...(activityChatType === 'group' ? { groupId: activityChannelId } : {}),
|
|
4264
4265
|
...(activityChatType === 'private' ? { peerId: activityChannelId } : {}),
|
|
4265
4266
|
item,
|
|
4266
|
-
});
|
|
4267
|
+
}, { projectPath: absoluteProjectPath, allowedRoots: toolImageReadRoots });
|
|
4267
4268
|
}
|
|
4268
4269
|
catch (error) {
|
|
4269
4270
|
logger.warn(`[ResponseEngine] task activity record failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -4543,6 +4544,7 @@ export class ResponseEngine {
|
|
|
4543
4544
|
permissionMode: effectivePermissionMode,
|
|
4544
4545
|
});
|
|
4545
4546
|
})();
|
|
4547
|
+
toolImageReadRoots = [absoluteProjectPath, ...grantedReadRoots, ...(sessionRuntimeDir ? [sessionRuntimeDir] : [])];
|
|
4546
4548
|
// 设置权限审批的交互上下文(支持交互卡片)
|
|
4547
4549
|
const permissionContext = {
|
|
4548
4550
|
sendPrompt: permissionPromptForOrigin,
|
|
@@ -5160,7 +5162,7 @@ export class ResponseEngine {
|
|
|
5160
5162
|
intent: {
|
|
5161
5163
|
operation, scope: ['owner', 'admin'].includes(historySubject.role) ? 'agent' : 'relation',
|
|
5162
5164
|
source: 'agent-tool',
|
|
5163
|
-
args: { self: selfAid, targetId: historyGroupId, peer: historyGroupId,
|
|
5165
|
+
args: { self: selfAid, targetAgentAid: selfAid, targetId: historyGroupId, peer: historyGroupId,
|
|
5164
5166
|
peerKey: formatPeerKey('aun', historyGroupId) },
|
|
5165
5167
|
},
|
|
5166
5168
|
}).allow;
|
|
@@ -105,7 +105,7 @@ export function parseModelList(json, _url) {
|
|
|
105
105
|
const BUILTIN_IDS = {
|
|
106
106
|
codex: ['gpt-6.1-terra', 'gpt-6.1-sol', 'gpt-6-sol', 'gpt-6-astra', 'gpt-5.6-terra', 'gpt-5.6-sol'],
|
|
107
107
|
claude: ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-5-5', 'claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001', 'claude-fable-5', 'claude-fable-5-1', 'deepseek-v4.1-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'glm-5.3', 'glm-5.3-flash', 'glm-5.3-flashx', 'glm-5.2'],
|
|
108
|
-
ecagent: ['
|
|
108
|
+
ecagent: ['deepseek-v4.1-flash'],
|
|
109
109
|
gemini: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'],
|
|
110
110
|
};
|
|
111
111
|
export function builtinCatalog(baseagent) {
|