evolcore 0.0.40 → 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 +45 -1
- package/bin/codex-managed-hook.mjs +11 -0
- package/bin/ec-safe-output.js +11 -1
- package/dist/agents/claude-runner.js +21 -106
- package/dist/agents/codex-runner.js +451 -231
- package/dist/agents/ecagent-runner.js +30 -11
- package/dist/agents/gemini-runner.js +26 -6
- package/dist/agents/runner-types.js +11 -3
- package/dist/aun/ability-device-routing.js +26 -0
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/group/identity.js +8 -0
- package/dist/aun/msg/managed-operation.js +4 -4
- package/dist/aun/msg/p2p.js +27 -7
- package/dist/aun/storage/download.js +30 -0
- package/dist/aun/storage/index.js +14 -6
- package/dist/channels/aun.js +33 -4
- package/dist/channels/daemon.js +24 -4
- package/dist/cli/agent-command.js +2 -0
- package/dist/cli/agent-create.js +98 -19
- package/dist/cli/agent.js +10 -3
- package/dist/cli/aun-commands.js +82 -22
- package/dist/cli/daemon-commands.js +19 -10
- package/dist/cli/index.js +1 -1
- package/dist/cli/restart-monitor.js +17 -0
- package/dist/cli/session-command.js +128 -13
- package/dist/cli/stats.js +60 -4
- package/dist/cli/trigger-command.js +2 -2
- package/dist/config/access-policy.js +2 -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/core/agent-application-service.js +11 -1
- package/dist/core/agent-ipc-registration.js +4 -0
- package/dist/core/auth/agent-delegation.js +80 -5
- package/dist/core/auth/authorization-audit.js +20 -3
- package/dist/core/auth/operation-catalog.js +8 -0
- package/dist/core/command/agent-control.js +91 -12
- package/dist/core/command/command-handler.js +57 -46
- package/dist/core/command/connect-menu.js +23 -2
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +38 -101
- package/dist/core/command/menu-protocol.js +9 -2
- package/dist/core/command/role-menu.js +7 -6
- package/dist/core/command/slash-gate.js +13 -10
- package/dist/core/command/slash-handler.js +34 -98
- package/dist/core/event-catalog.js +15 -0
- package/dist/core/ipc-registration.js +18 -1
- package/dist/core/memory/consolidation-trigger.js +1 -1
- package/dist/core/message/aun-ipc-sender.js +26 -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 +40 -6
- package/dist/core/message/message-log.js +55 -0
- package/dist/core/message/message-queue.js +5 -5
- package/dist/core/message/response-engine.js +310 -136
- package/dist/core/model/model-catalog.js +7 -6
- package/dist/core/ownership/owner-resolver.js +2 -2
- package/dist/core/permission/ec-command-parser.js +110 -5
- package/dist/core/permission/tool-policy.js +28 -7
- package/dist/core/session/session-capsule.js +197 -0
- package/dist/core/session/session-manager.js +148 -14
- package/dist/core/session/session-mapper.js +2 -0
- package/dist/index.js +3 -3
- package/dist/ipc.js +22 -8
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +15 -0
- package/dist/stats/index.js +2 -2
- package/dist/stats/price-resolver.js +304 -5
- package/dist/stats/query.js +82 -3
- package/dist/stats/writer.js +38 -5
- package/dist/trigger/feedback.js +18 -7
- package/dist/trigger/manager.js +20 -3
- package/dist/trigger/parser.js +6 -3
- package/dist/trigger/patch.js +1 -1
- package/dist/trigger/system-definitions.js +43 -7
- package/dist/trigger/validation.js +13 -5
- package/dist/utils/error-utils.js +14 -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/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/ABILITY_CALLING.md +20 -2
- package/kits/docs/evolcore/INDEX.md +2 -1
- package/kits/docs/evolcore/agent-create.md +3 -2
- package/kits/docs/evolcore/agent.md +1 -1
- package/kits/docs/evolcore/config.md +1 -1
- package/kits/docs/evolcore/event.md +1 -0
- package/kits/docs/evolcore/fs.md +5 -0
- package/kits/docs/evolcore/menu-protocol.md +32 -0
- package/kits/docs/evolcore/msg.md +17 -1
- package/kits/docs/evolcore/session.md +14 -0
- package/kits/schemas/agent-config.schema.13.json +15 -0
- package/kits/skills/aid-ability/SKILL.md +35 -6
- package/kits/templates/session-capsule/recovery.md +5 -0
- package/kits/templates/session-capsule/renew.md +5 -0
- package/kits/templates/system-fragments/bootstrap.md +6 -6
- package/kits/templates/system-fragments/channel.md +1 -1
- package/package.json +3 -3
- package/dist/stats/billing.js +0 -215
|
@@ -398,6 +398,10 @@ export class IMRenderer {
|
|
|
398
398
|
durationMs: opts.durationMs,
|
|
399
399
|
});
|
|
400
400
|
}
|
|
401
|
+
/** Durable system notices use the same task route and serialized send queue. */
|
|
402
|
+
async sendSystemNotice(text, subtype) {
|
|
403
|
+
await this.sendPayload({ kind: 'system.notice', text, subtype });
|
|
404
|
+
}
|
|
401
405
|
/** 发送不进入 activity/thought 历史、也不代表执行活跃的任务级 notice。 */
|
|
402
406
|
async sendStatusNotice(message, severity = 'info', subtype, details) {
|
|
403
407
|
const payload = {
|
|
@@ -128,16 +128,20 @@ export function evaluateOrdinaryInboundAdmission(context) {
|
|
|
128
128
|
const policy = context.policy;
|
|
129
129
|
if (!policy)
|
|
130
130
|
return { allow: false, reason: 'invalid_access_policy', context };
|
|
131
|
+
if (context.isOwner)
|
|
132
|
+
return { allow: true, reason: 'owner', context };
|
|
133
|
+
if (context.primaryId && policy.allowedAids?.includes(context.primaryId)) {
|
|
134
|
+
return { allow: true, reason: 'allowed_aid', context };
|
|
135
|
+
}
|
|
136
|
+
if (policy.allowExternalContacts === false) {
|
|
137
|
+
return { allow: false, reason: 'external_contacts_disabled', context };
|
|
138
|
+
}
|
|
131
139
|
if (context.chatType === 'group') {
|
|
132
|
-
if (context.isOwner)
|
|
133
|
-
return { allow: true, reason: 'owner', context };
|
|
134
140
|
if (policy.policyMode === 'open' || policy.policyMode === 'contacts') {
|
|
135
141
|
return { allow: true, reason: 'group_channel_allowed', context };
|
|
136
142
|
}
|
|
137
143
|
return { allow: false, reason: 'owners', context };
|
|
138
144
|
}
|
|
139
|
-
if (context.isOwner)
|
|
140
|
-
return { allow: true, reason: 'owner', context };
|
|
141
145
|
if (policy.policyMode === 'open')
|
|
142
146
|
return { allow: true, reason: 'open', context };
|
|
143
147
|
if (policy.policyMode === 'owners')
|
|
@@ -40,6 +40,7 @@ import { renderActionAsText } from '../interaction-router.js';
|
|
|
40
40
|
import { planApprovalRoute } from '../permission/approval-gateway.js';
|
|
41
41
|
import { guardGroupSlashCommand, parseFullAccessCommand } from '../command/slash-gate.js';
|
|
42
42
|
import { createAgentPolicyAuthorization, createSessionFullAccessAuthorization, hasSessionFullAccessOverride } from '../role/runtime-policy.js';
|
|
43
|
+
import { auditFullAccessEvent } from '../auth/authorization-audit.js';
|
|
43
44
|
import { DIAGNOSTIC_AGENT_AID, DiagnosticSessionRouter, parseDiagnosticEvent, isDiagnosticSessionActive } from '../command/diag-service.js';
|
|
44
45
|
import { consumeAdmissionReplyBudget, clearAdmissionReplyBudgets, evaluateInboundAdmissionPreflight, evaluateOrdinaryInboundAdmission, } from './message-admission.js';
|
|
45
46
|
const CONTACT_REJECTION_NOTICE = '[rejection] Not accepting messages from you.';
|
|
@@ -706,6 +707,9 @@ export class MessageBridge {
|
|
|
706
707
|
await sendReply(msg.channelId, payload.text, msg.replyContext);
|
|
707
708
|
}
|
|
708
709
|
admissionDeniedNotice(context, channelType) {
|
|
710
|
+
if (context.policy?.allowExternalContacts === false) {
|
|
711
|
+
return '当前 Agent 不接受外部联系消息,请由 Owner 将你的 AID 加入允许名单。';
|
|
712
|
+
}
|
|
709
713
|
if (context.contactStatus === 'pending') {
|
|
710
714
|
return '联系人申请审核中;可再次发送 /request 更新说明。';
|
|
711
715
|
}
|
|
@@ -1186,9 +1190,9 @@ export class MessageBridge {
|
|
|
1186
1190
|
return;
|
|
1187
1191
|
}
|
|
1188
1192
|
}
|
|
1189
|
-
// /fa
|
|
1190
|
-
//
|
|
1191
|
-
//
|
|
1193
|
+
// /fa on/off controls the current session; other non-empty arguments
|
|
1194
|
+
// request one fullaccess run. Only this trusted inbound path can create
|
|
1195
|
+
// the per-call authorization carried into ResponseEngine.
|
|
1192
1196
|
const fullAccessCommand = parseFullAccessCommand(content);
|
|
1193
1197
|
if (fullAccessCommand.matched) {
|
|
1194
1198
|
const groupGuard = guardGroupSlashCommand(content, chatType);
|
|
@@ -1200,9 +1204,39 @@ export class MessageBridge {
|
|
|
1200
1204
|
await sendReply(msg.channelId, '❌ /fa 只能由用户直接发送', msg.replyContext);
|
|
1201
1205
|
return;
|
|
1202
1206
|
}
|
|
1203
|
-
if (fullAccessCommand.action === '
|
|
1204
|
-
|
|
1205
|
-
|
|
1207
|
+
if (fullAccessCommand.action === 'prompt') {
|
|
1208
|
+
if (!authSubject.isDaemonOwner || !authSubject.principalId) {
|
|
1209
|
+
auditFullAccessEvent({
|
|
1210
|
+
event: 'fullaccess.command.rejected',
|
|
1211
|
+
source: 'fullaccess-command',
|
|
1212
|
+
decision: 'deny',
|
|
1213
|
+
actorId: authSubject.principalId ?? authSubject.actorId,
|
|
1214
|
+
processRole: authSubject.processRole,
|
|
1215
|
+
messageId: msg.messageId,
|
|
1216
|
+
reason: '仅可信 daemon-owner 可以使用 fullaccess',
|
|
1217
|
+
});
|
|
1218
|
+
await sendReply(msg.channelId, '❌ 仅可信 daemon-owner 可以使用 fullaccess', msg.replyContext);
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
if (!msg.messageLogContent)
|
|
1222
|
+
msg.messageLogContent = content;
|
|
1223
|
+
content = fullAccessCommand.prompt;
|
|
1224
|
+
executionPermissionOverride = {
|
|
1225
|
+
permissionMode: 'fullaccess',
|
|
1226
|
+
processRole: 'fullaccess-run',
|
|
1227
|
+
dataScope: 'daemon',
|
|
1228
|
+
source: 'fullaccess-command',
|
|
1229
|
+
authorizedBy: authSubject.principalId,
|
|
1230
|
+
};
|
|
1231
|
+
logger.warn(`[MessageBridge] fullaccess command accepted: channel=${channelName} `
|
|
1232
|
+
+ `actor=${authSubject.principalId} message=${msg.messageId ?? '<none>'}`);
|
|
1233
|
+
auditFullAccessEvent({
|
|
1234
|
+
event: 'fullaccess.command.accepted',
|
|
1235
|
+
source: 'fullaccess-command',
|
|
1236
|
+
actorId: authSubject.principalId,
|
|
1237
|
+
processRole: authSubject.processRole,
|
|
1238
|
+
messageId: msg.messageId,
|
|
1239
|
+
});
|
|
1206
1240
|
}
|
|
1207
1241
|
}
|
|
1208
1242
|
// 0. 仅阻止协议遥测进入 session / model / messages.jsonl;协议本身已在
|
|
@@ -341,6 +341,59 @@ export function appendMessageLogStrict(chatDir, entry, durable = false) {
|
|
|
341
341
|
rememberMessageId(chatDir, entry.msgId);
|
|
342
342
|
notifyInbound(chatDir, entry);
|
|
343
343
|
}
|
|
344
|
+
/** Attach a capsule reference to the first admitted message of a renewed backend. */
|
|
345
|
+
export function associateMessageCapsule(chatDir, sessionId, capsuleId, messageId, timestamp) {
|
|
346
|
+
if (!capsuleId || (!messageId && timestamp === undefined))
|
|
347
|
+
return false;
|
|
348
|
+
const file = messageLogPath(chatDir);
|
|
349
|
+
if (!fs.existsSync(file))
|
|
350
|
+
return false;
|
|
351
|
+
try {
|
|
352
|
+
const lines = fs.readFileSync(file, 'utf8').split('\n');
|
|
353
|
+
let changed = false;
|
|
354
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
355
|
+
if (!lines[index]?.trim())
|
|
356
|
+
continue;
|
|
357
|
+
let entry;
|
|
358
|
+
try {
|
|
359
|
+
entry = JSON.parse(lines[index]);
|
|
360
|
+
}
|
|
361
|
+
catch {
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (entry.sessionId !== sessionId || entry.dir !== 'in' || isTransientProtocolMessage(entry)
|
|
365
|
+
|| entry.msgType === 'command' || entry.content?.trim().startsWith('/renew'))
|
|
366
|
+
continue;
|
|
367
|
+
if (messageId && entry.msgId !== messageId)
|
|
368
|
+
continue;
|
|
369
|
+
if (!messageId && entry.ts !== timestamp)
|
|
370
|
+
continue;
|
|
371
|
+
if (entry.capsuleId)
|
|
372
|
+
return entry.capsuleId === capsuleId;
|
|
373
|
+
entry.capsuleId = capsuleId;
|
|
374
|
+
lines[index] = JSON.stringify(entry);
|
|
375
|
+
changed = true;
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
if (!changed)
|
|
379
|
+
return false;
|
|
380
|
+
const temp = `${file}.capsule.tmp`;
|
|
381
|
+
const descriptor = fs.openSync(temp, 'w', 0o600);
|
|
382
|
+
try {
|
|
383
|
+
fs.writeFileSync(descriptor, lines.join('\n'));
|
|
384
|
+
fs.fsyncSync(descriptor);
|
|
385
|
+
}
|
|
386
|
+
finally {
|
|
387
|
+
fs.closeSync(descriptor);
|
|
388
|
+
}
|
|
389
|
+
fs.renameSync(temp, file);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
logger.warn(`[MessageLog] Failed to associate capsule ${capsuleId}: ${error instanceof Error ? error.message : String(error)}`);
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
344
397
|
export function buildInboundEntry(opts) {
|
|
345
398
|
const ts = opts.timestamp || Date.now();
|
|
346
399
|
const isCommandCapable = !opts.msgType || opts.msgType === 'text' || opts.msgType === 'quote' || opts.msgType === 'action_card_reply';
|
|
@@ -351,6 +404,7 @@ export function buildInboundEntry(opts) {
|
|
|
351
404
|
...(opts.gatewaySeq !== undefined ? { gatewaySeq: opts.gatewaySeq } : {}),
|
|
352
405
|
time: formatTimestampMs(ts),
|
|
353
406
|
sessionId: opts.sessionId,
|
|
407
|
+
capsuleId: opts.capsuleId,
|
|
354
408
|
threadId: opts.threadId ?? null,
|
|
355
409
|
dir: 'in',
|
|
356
410
|
from: opts.from,
|
|
@@ -384,6 +438,7 @@ export function buildOutboundEntry(opts) {
|
|
|
384
438
|
ts,
|
|
385
439
|
time: formatTimestampMs(ts),
|
|
386
440
|
sessionId: opts.sessionId,
|
|
441
|
+
capsuleId: opts.capsuleId,
|
|
387
442
|
threadId: opts.threadId ?? null,
|
|
388
443
|
dir: 'out',
|
|
389
444
|
from: opts.from,
|
|
@@ -78,11 +78,11 @@ export class MessageQueue {
|
|
|
78
78
|
this.activeTerminalReasons.set(queueKey, reason);
|
|
79
79
|
let interruption;
|
|
80
80
|
try {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
const active = this.activeStates.get(queueKey);
|
|
82
|
+
const target = active?.taskId && Number.isSafeInteger(active.generation)
|
|
83
|
+
? { taskId: active.taskId, generation: active.generation }
|
|
84
|
+
: undefined;
|
|
85
|
+
interruption = Promise.resolve(this.interruptCallback(sessionKey, baseagent, evolagentName, reason, timeout, strict, target));
|
|
86
86
|
}
|
|
87
87
|
catch (error) {
|
|
88
88
|
interruption = Promise.reject(error);
|