evolcore 0.0.26 → 0.0.28
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 +36 -0
- package/bin/codex-managed-acl.ps1 +43 -0
- package/dist/agents/baseagent-availability.js +68 -0
- package/dist/agents/baseagent.js +10 -5
- package/dist/agents/claude-runner.js +123 -22
- package/dist/agents/codex/app-server-client.js +70 -26
- package/dist/agents/codex/catalog.js +7 -1
- package/dist/agents/codex-runner.js +363 -421
- package/dist/agents/ecagent-runner.js +170 -25
- package/dist/agents/gemini-runner.js +6 -0
- package/dist/agents/runner-types.js +50 -2
- package/dist/aun/aid/agentmd.js +73 -31
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +180 -1
- package/dist/aun/aid/identity.js +3 -3
- package/dist/aun/group/history.js +303 -0
- package/dist/aun/group/identity.js +43 -0
- package/dist/aun/group/index.js +5 -0
- package/dist/aun/{msg/group.js → group/operations.js} +161 -38
- package/dist/aun/{menu-client.js → menu/client.js} +13 -7
- package/dist/aun/menu/index.js +2 -0
- package/dist/aun/menu/transport.js +49 -0
- package/dist/aun/msg/index.js +2 -1
- package/dist/aun/msg/managed-operation.js +84 -18
- package/dist/aun/msg/mention-schema.js +51 -0
- package/dist/aun/msg/p2p.js +13 -8
- package/dist/aun/msg/upload.js +43 -88
- package/dist/aun/outbox.js +29 -7
- package/dist/aun/rpc/client.js +1 -0
- package/dist/aun/storage/client.js +39 -50
- package/dist/channels/aun.js +544 -239
- package/dist/channels/daemon.js +10 -6
- package/dist/cli/agent-command.js +108 -6
- package/dist/cli/agent-create.js +515 -2
- package/dist/cli/agent.js +109 -8
- package/dist/cli/aun-commands.js +191 -42
- package/dist/cli/config.js +8 -5
- package/dist/cli/contact.js +2 -2
- package/dist/cli/ctl-command.js +2 -2
- package/dist/cli/daemon-commands.js +111 -162
- package/dist/cli/diag.js +3 -3
- package/dist/cli/fs-command.js +3 -3
- package/dist/cli/handoff-command.js +6 -6
- package/dist/cli/index.js +8 -2
- package/dist/cli/init.js +34 -1
- package/dist/cli/managed-command-guard.js +2 -1
- package/dist/cli/menu-client.js +13 -5
- package/dist/cli/model.js +3 -3
- package/dist/cli/queue-command.js +2 -2
- package/dist/cli/response.js +2 -2
- package/dist/cli/restart-monitor.js +81 -19
- package/dist/cli/task-command.js +59 -0
- package/dist/cli/task-context.js +97 -49
- package/dist/cli/trigger-command.js +20 -10
- package/dist/config/builtin-roles.js +10 -0
- package/dist/config/config-field-policy.js +11 -0
- package/dist/config/config-manager.js +32 -4
- package/dist/config/config-operation-service.js +20 -5
- package/dist/config/contact-book-store.js +1 -1
- package/dist/config/contact-book.js +1 -1
- package/dist/config/contact-operation-service.js +1 -1
- package/dist/config/peer-role-resolver.js +1 -1
- package/dist/config/resolved-config-op.js +3 -0
- package/dist/config-store.js +1 -1
- package/dist/core/agent-application-service.js +5 -0
- package/dist/core/audit/event-key.js +17 -2
- package/dist/core/audit/log-integrity.js +34 -8
- package/dist/core/auth/agent-delegation.js +48 -14
- package/dist/core/auth/auth-gateway.js +2 -0
- package/dist/core/auth/authorization-audit.js +34 -38
- package/dist/core/auth/operation-authorizer.js +67 -5
- package/dist/core/auth/operation-catalog.js +110 -0
- package/dist/core/auth/remote-access-store.js +115 -9
- package/dist/core/bootstrap-messages.js +66 -7
- package/dist/core/bootstrap-service.js +110 -19
- package/dist/core/command/agent-control.js +88 -7
- package/dist/core/command/agent-storage-menu.js +443 -0
- package/dist/core/command/cli-intent-parser.js +19 -0
- package/dist/core/command/command-handler.js +105 -40
- package/dist/core/command/data-root-resolver.js +273 -0
- package/dist/core/command/diag-service.js +292 -27
- package/dist/core/command/group-menu.js +7 -2
- package/dist/core/command/menu-catalog.js +34 -4
- package/dist/core/command/menu-handler.js +364 -96
- package/dist/core/command/menu-protocol.js +43 -6
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-handler.js +61 -37
- package/dist/core/event-catalog.js +4 -0
- package/dist/core/evolagent-registry.js +28 -2
- package/dist/core/group/invite-service.js +924 -0
- package/dist/core/interaction-router.js +22 -8
- package/dist/core/message/im-renderer.js +94 -16
- package/dist/core/message/message-bridge.js +140 -13
- package/dist/core/message/message-log.js +5 -3
- package/dist/core/message/message-queue.js +73 -41
- package/dist/core/message/response-engine.js +729 -118
- package/dist/core/permission/approval-gateway.js +36 -3
- package/dist/core/permission/ec-command-parser.js +76 -36
- package/dist/core/permission/protected-paths.js +134 -16
- package/dist/core/permission/sandbox-runtime.js +72 -3
- package/dist/core/permission/tool-error-code.js +15 -0
- package/dist/core/permission/tool-policy.js +8 -8
- package/dist/core/relation/peer-identity.js +57 -6
- package/dist/core/relation/shared-data.js +106 -0
- package/dist/core/role/runtime-policy.js +64 -0
- package/dist/core/runtime-lock.js +10 -26
- package/dist/core/session/runner-task-history.js +170 -0
- package/dist/core/session/session-manager.js +38 -6
- package/dist/core/session/session-mapper.js +41 -0
- package/dist/core/session/session-turn-coordinator.js +37 -7
- package/dist/core/session/session-turns.js +48 -7
- package/dist/core/task/task-recovery-service.js +176 -0
- package/dist/core/task/task-resume-operation.js +32 -0
- package/dist/eck/group-rules-sync.js +5 -3
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/index.js +322 -207
- package/dist/ipc.js +141 -15
- package/dist/paths.js +17 -4
- package/dist/product.js +3 -0
- package/dist/trigger/event-source.js +19 -0
- package/dist/trigger/feedback.js +233 -40
- package/dist/trigger/parser.js +55 -5
- package/dist/trigger/patch.js +9 -0
- package/dist/trigger/scheduler.js +30 -4
- package/dist/trigger/validation.js +20 -3
- package/dist/utils/atomic-write.js +98 -0
- package/dist/utils/cross-platform.js +87 -16
- package/dist/utils/ecweb-utils.js +1 -0
- package/dist/utils/error-utils.js +40 -2
- package/dist/utils/logger.js +23 -13
- package/dist/utils/npm-ops.js +119 -4
- package/dist/utils/package-version-info.js +244 -0
- package/dist/utils/tool-summary.js +59 -3
- package/dist/utils/welcome.js +174 -1
- package/dist/utils/windows-shell-trust.js +37 -0
- package/ecagent/dist/harness/agent-harness.js +3 -0
- package/ecagent/dist/harness/session/jsonl-storage.js +21 -2
- package/kits/docs/INDEX.md +0 -6
- package/kits/docs/channels/aun.md +23 -2
- package/kits/docs/channels/feishu.md +1 -1
- package/kits/docs/context-assembly.md +29 -17
- package/kits/docs/evolcore/INDEX.md +8 -3
- package/kits/docs/evolcore/agent-create.md +39 -7
- package/kits/docs/evolcore/agent.md +33 -1
- package/kits/docs/evolcore/aid.md +9 -1
- package/kits/docs/evolcore/config.md +40 -1
- package/kits/docs/evolcore/group-collaboration.md +1 -1
- package/kits/docs/evolcore/group.md +117 -2
- package/kits/docs/evolcore/menu-client.md +16 -0
- package/kits/docs/evolcore/msg.md +3 -0
- package/kits/docs/evolcore/storage.md +3 -0
- package/kits/docs/evolcore/task.md +14 -0
- package/kits/docs/evolcore/trigger.md +51 -3
- package/kits/docs/venues/group.md +5 -0
- package/kits/eck_manifest.json +27 -0
- package/kits/rules/01-overview.md +11 -7
- package/kits/rules/04-relation.md +2 -1
- package/kits/rules/05-venue.md +1 -1
- package/kits/rules/06-channel.md +6 -4
- package/kits/schemas/agent-config.schema.12.json +25 -1
- package/kits/schemas/daemon.schema.6.json +2 -2
- package/kits/schemas/defaults.schema.5.json +1 -1
- package/kits/schemas/relation-config.schema.1.json +1 -1
- package/kits/schemas/relation-config.schema.5.json +1 -1
- package/kits/schemas/role-config.schema.1.json +14 -0
- package/kits/templates/roles/member.json +5 -0
- package/kits/templates/roles/visitor.json +5 -0
- package/kits/templates/system-fragments/baseagent.md +1 -1
- package/kits/templates/system-fragments/bootstrap.md +26 -9
- package/kits/templates/system-fragments/channel.md +8 -44
- package/kits/templates/system-fragments/commands.md +10 -2
- package/kits/templates/system-fragments/group-unread-history.md +7 -0
- package/kits/templates/system-fragments/reply.md +56 -0
- package/package.json +7 -3
- package/dist/aun/group-identity.js +0 -9
- /package/dist/aun/{group-fs-download.js → group/fs-download.js} +0 -0
- /package/dist/aun/{msg/group-index.js → group/index-rpc.js} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import crypto from 'node:crypto';
|
|
4
|
-
import { createShortConnection } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
4
|
+
import { createShortConnection } from '../rpc/client.js';
|
|
5
|
+
import { MENU_MESSAGE_TTL_SECONDS } from './transport.js';
|
|
6
|
+
import { SLOT } from '../aid/store.js';
|
|
7
|
+
import { isValidAid } from '../aid/validation.js';
|
|
8
|
+
import { resolveRoot } from '../../paths.js';
|
|
9
|
+
import { readInstalledEvolcoreVersion } from '../../utils/evolcore-version.js';
|
|
10
|
+
import { buildMenuClientProtectedHeaders, parseMenuResponse, validateMenuRequest, } from '../../core/command/menu-protocol.js';
|
|
10
11
|
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
11
12
|
const MAX_TIMEOUT_MS = 120_000;
|
|
12
13
|
const POLL_INTERVAL_MS = 200;
|
|
@@ -66,11 +67,15 @@ export class ManagedMenuClient {
|
|
|
66
67
|
let timer;
|
|
67
68
|
try {
|
|
68
69
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
70
|
+
options.beforeSend?.();
|
|
69
71
|
const response = new Promise((resolve, reject) => {
|
|
70
72
|
this.pending.set(key, { resolve, reject });
|
|
71
73
|
timer = setTimeout(() => reject(new MenuClientError('TIMEOUT', 'Remote Menu response timed out')), timeout);
|
|
72
74
|
});
|
|
73
|
-
const sent = this.send({
|
|
75
|
+
const sent = this.send({
|
|
76
|
+
to: options.targetAid, payload: request, encrypt: true,
|
|
77
|
+
ttl: MENU_MESSAGE_TTL_SECONDS, protected_headers: headers,
|
|
78
|
+
})
|
|
74
79
|
.then(result => {
|
|
75
80
|
if (!(result?.message_id ?? result?.message?.message_id))
|
|
76
81
|
throw new MenuClientError('SEND_FAILED', 'message.send returned no message_id');
|
|
@@ -294,6 +299,7 @@ async function sendOnce(options, request, timeoutMs) {
|
|
|
294
299
|
to: options.targetAid,
|
|
295
300
|
payload: request,
|
|
296
301
|
encrypt,
|
|
302
|
+
ttl: MENU_MESSAGE_TTL_SECONDS,
|
|
297
303
|
...(encrypt ? { protected_headers: headers } : {}),
|
|
298
304
|
});
|
|
299
305
|
const messageId = sent?.message_id ?? sent?.message?.message_id;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Message Service TTL in seconds; unrelated to Menu execution/client timeouts. */
|
|
2
|
+
export const MENU_MESSAGE_TTL_SECONDS = 60;
|
|
3
|
+
export const MENU_VOLATILE_SDK_VERSION = '0.5.17';
|
|
4
|
+
function parseSdkVersion(value) {
|
|
5
|
+
if (typeof value !== 'string' || !/^\d+\.\d+\.\d+$/.test(value.trim()))
|
|
6
|
+
return undefined;
|
|
7
|
+
const parts = value.trim().split('.').map(Number);
|
|
8
|
+
return parts.every(Number.isSafeInteger) ? parts : undefined;
|
|
9
|
+
}
|
|
10
|
+
/** Volatile cursors and device targeting require the SDK's 0.5.17 contract. */
|
|
11
|
+
export function supportsMenuVolatileTransport(value) {
|
|
12
|
+
const version = parseSdkVersion(value);
|
|
13
|
+
if (!version)
|
|
14
|
+
return false;
|
|
15
|
+
const minimum = parseSdkVersion(MENU_VOLATILE_SDK_VERSION);
|
|
16
|
+
return version[0] > minimum[0]
|
|
17
|
+
|| (version[0] === minimum[0] && (version[1] > minimum[1]
|
|
18
|
+
|| (version[1] === minimum[1] && version[2] >= minimum[2])));
|
|
19
|
+
}
|
|
20
|
+
/** Read only the SDK's public sender_device_id, never a payload/recipient device. */
|
|
21
|
+
export function menuSenderDeviceId(value) {
|
|
22
|
+
if (typeof value !== 'string' || value.length > 256 || /[\u0000-\u001f\u007f]/.test(value))
|
|
23
|
+
return undefined;
|
|
24
|
+
return value.trim() || undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Enforce the Menu wire policy at the final P2P send boundary, including retries. */
|
|
27
|
+
export function menuTransportParams(method, params) {
|
|
28
|
+
if (method !== 'message.send' || typeof params.payload?.type !== 'string'
|
|
29
|
+
|| !params.payload.type.startsWith('menu.'))
|
|
30
|
+
return params;
|
|
31
|
+
if (params.payload.type !== 'menu.response')
|
|
32
|
+
return { ...params, ttl: MENU_MESSAGE_TTL_SECONDS };
|
|
33
|
+
const { to_device_id: target, menu_client_sdk_version: sdkVersion, ...rest } = params;
|
|
34
|
+
delete rest.device_id;
|
|
35
|
+
if (!supportsMenuVolatileTransport(sdkVersion ?? params.protected_headers?.sdk_version)) {
|
|
36
|
+
// Evol App versions backed by fastaun < 0.5.17 do not consume the
|
|
37
|
+
// volatile cursor or understand device-targeted Menu responses.
|
|
38
|
+
return rest;
|
|
39
|
+
}
|
|
40
|
+
if (target === undefined)
|
|
41
|
+
return { ...rest, ttl: MENU_MESSAGE_TTL_SECONDS };
|
|
42
|
+
const deviceId = menuSenderDeviceId(target);
|
|
43
|
+
if (!deviceId) {
|
|
44
|
+
throw Object.assign(new Error('Invalid Menu reply device'), { code: 'INVALID_MENU_REPLY_DEVICE', retryable: false });
|
|
45
|
+
}
|
|
46
|
+
// device_id takes precedence in the SDK; do not let it override the captured
|
|
47
|
+
// request sender. A rejected target is never retried as an AID broadcast.
|
|
48
|
+
return { ...rest, ttl: MENU_MESSAGE_TTL_SECONDS, to_device_id: deviceId };
|
|
49
|
+
}
|
package/dist/aun/msg/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { msgSend, msgPull, msgAck, msgRecall, msgOnline, } from './p2p.js';
|
|
2
2
|
export { msgHistory, MAX_MSG_HISTORY_LIMIT } from './history.js';
|
|
3
|
-
export {
|
|
3
|
+
export { groupHistory, parseGroupHistoryArgs, GroupHistoryError } from '../group/index.js';
|
|
4
|
+
export { groupSend, groupPull, groupAck, groupCreate, groupInfo, groupList, groupUpdate, groupDissolve, groupSuspend, groupResume, groupJoin, groupLeave, groupInvite, groupInvites, groupAcceptInvite, groupRejectInvite, groupRevokeInvite, groupKick, groupMembers, groupOnline, groupSetRole, groupTransferOwner, groupBan, groupUnban, groupBanlist, groupBlock, groupUnblock, groupBlocklist, groupReportStatus, groupMemberStatuses, groupRules, groupUpdateRules, groupRulesFileGet, groupRulesFileSet, groupRulesFilePublish, } from '../group/index.js';
|
|
4
5
|
export { uploadFileAndBuildPayload, inferPayloadType, isValidPayloadType } from './upload.js';
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { TextDecoder } from 'util';
|
|
2
2
|
import { getAidStore, loadClient, SLOT } from '../aid/index.js';
|
|
3
3
|
import { msgHistory } from './history.js';
|
|
4
|
+
import { groupHistory, parseGroupHistoryArgs, GroupHistoryError } from '../group/history.js';
|
|
4
5
|
import { msgOnline } from './p2p.js';
|
|
5
6
|
import { resolveRoot } from '../../paths.js';
|
|
6
|
-
import {
|
|
7
|
+
import { normalizeGroupAid } from '../group/identity.js';
|
|
7
8
|
import { isValidAid } from '../aid/validation.js';
|
|
8
9
|
import { tryParseChannelKey } from '../../core/channel-loader.js';
|
|
9
|
-
import { downloadGroupFsBytes } from '../group
|
|
10
|
-
import { groupBan, groupBanlist, groupCreate, groupDissolve, groupInfo, groupInvite, groupJoin, groupKick, groupLeave, groupList, groupMembers, groupOnline, groupPull, groupAck, groupAcceptInvite, groupInvites, groupRejectInvite, groupRevokeInvite, groupResume, groupRules, groupRulesFileGet, groupRulesFilePublish, groupRulesFileSet, groupSetRole, groupSuspend, groupTransferOwner, groupUnban, groupUpdate, groupUpdateRules, } from '
|
|
10
|
+
import { downloadGroupFsBytes } from '../group/fs-download.js';
|
|
11
|
+
import { groupBan, groupBanlist, groupBlock, groupUnblock, groupBlocklist, groupReportStatus, groupMemberStatuses, groupCreate, groupDissolve, groupInfo, groupInvite, groupJoin, groupKick, groupLeave, groupList, groupMembers, groupOnline, groupPull, groupAck, groupAcceptInvite, groupInvites, groupRejectInvite, groupRevokeInvite, groupResume, groupRules, groupRulesFileGet, groupRulesFilePublish, groupRulesFileSet, groupSetRole, groupSuspend, groupTransferOwner, groupUnban, groupUpdate, groupUpdateRules, } from '../group/operations.js';
|
|
11
12
|
/** Rules uploaded by a managed task are carried as bounded UTF-8 content. */
|
|
12
13
|
export const MAX_MANAGED_GROUP_RULES_BYTES = 4 * 1024;
|
|
13
14
|
const RELATION_GROUP_READ_KINDS = new Set([
|
|
14
15
|
'info',
|
|
15
16
|
'pull',
|
|
17
|
+
'history',
|
|
16
18
|
'members',
|
|
17
19
|
'online',
|
|
20
|
+
'member-statuses',
|
|
18
21
|
'rules.get',
|
|
19
22
|
'rules.get-legacy',
|
|
20
23
|
]);
|
|
@@ -22,6 +25,11 @@ const RELATION_GROUP_READ_KINDS = new Set([
|
|
|
22
25
|
export function isManagedGroupRelationRead(command) {
|
|
23
26
|
return RELATION_GROUP_READ_KINDS.has(command.kind);
|
|
24
27
|
}
|
|
28
|
+
/** Members may change only the current Agent's own reception and reported status. */
|
|
29
|
+
export function isManagedGroupRelationWrite(command) {
|
|
30
|
+
return command.kind === 'report-status'
|
|
31
|
+
|| ((command.kind === 'block' || command.kind === 'unblock') && command.memberAid === command.from);
|
|
32
|
+
}
|
|
25
33
|
export class ManagedGroupOperationError extends Error {
|
|
26
34
|
code;
|
|
27
35
|
constructor(code, message) {
|
|
@@ -33,6 +41,7 @@ export class ManagedGroupOperationError extends Error {
|
|
|
33
41
|
const GROUP_VALUE_FLAGS = new Set([
|
|
34
42
|
'--format', '--after-seq', '--limit', '--visibility', '--description', '--join-mode', '--group-id',
|
|
35
43
|
'--name', '--page', '--size', '--mode', '--question', '--max-pending', '--message', '--answer', '--duration', '--member-type',
|
|
44
|
+
'--reason', '--online-status', '--work-status',
|
|
36
45
|
]);
|
|
37
46
|
function failGroup(code, reason) {
|
|
38
47
|
return { ok: false, code, reason };
|
|
@@ -73,13 +82,16 @@ function requiredAid(value, label) {
|
|
|
73
82
|
return failGroup('INVALID_AID', `invalid ${label}: ${aid}`);
|
|
74
83
|
return aid;
|
|
75
84
|
}
|
|
76
|
-
function requiredGroup(value) {
|
|
85
|
+
function requiredGroup(value, from) {
|
|
77
86
|
const groupId = String(value || '').trim();
|
|
78
87
|
if (!groupId)
|
|
79
88
|
return failGroup('INVALID_ARGUMENT', 'missing group AID');
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
|
|
89
|
+
try {
|
|
90
|
+
return normalizeGroupAid(groupId, from?.slice(from.indexOf('.') + 1));
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return failGroup('INVALID_GROUP', `invalid group AID: ${groupId}: ${error.message}`);
|
|
94
|
+
}
|
|
83
95
|
}
|
|
84
96
|
function numberFlag(flags, name) {
|
|
85
97
|
const raw = flags.get(name);
|
|
@@ -108,7 +120,7 @@ function withFromAndGroup(sub, parsed, operationId, groupRequired = true) {
|
|
|
108
120
|
return from;
|
|
109
121
|
let groupId;
|
|
110
122
|
if (groupRequired) {
|
|
111
|
-
const parsedGroup = requiredGroup(parsed.positionals[1]);
|
|
123
|
+
const parsedGroup = requiredGroup(parsed.positionals[1], from);
|
|
112
124
|
if (typeof parsedGroup !== 'string')
|
|
113
125
|
return parsedGroup;
|
|
114
126
|
groupId = parsedGroup;
|
|
@@ -121,6 +133,15 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
121
133
|
const sub = raw[0];
|
|
122
134
|
if (!sub || sub === 'send')
|
|
123
135
|
return failGroup('NOT_ALLOWED', 'managed group operations do not allow send; use the group send daemon route');
|
|
136
|
+
if (sub === 'history') {
|
|
137
|
+
try {
|
|
138
|
+
const history = parseGroupHistoryArgs(raw);
|
|
139
|
+
return command('history', 'ec.group.history', ['group', ...raw], history.from, { groupId: history.groupId, history });
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return failGroup('INVALID_ARGUMENT', error instanceof Error ? error.message : String(error));
|
|
143
|
+
}
|
|
144
|
+
}
|
|
124
145
|
const parsed = parseFlags(raw.slice(1));
|
|
125
146
|
if (!('positionals' in parsed))
|
|
126
147
|
return parsed;
|
|
@@ -186,9 +207,10 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
186
207
|
return failGroup('INVALID_ARGUMENT', 'invalid --visibility');
|
|
187
208
|
if (joinMode !== undefined && !['open', 'approval', 'invite_only', 'closed'].includes(joinMode))
|
|
188
209
|
return failGroup('INVALID_ARGUMENT', 'invalid --join-mode');
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
|
|
210
|
+
const rawGroupId = values.get('--group-id');
|
|
211
|
+
const groupId = rawGroupId === undefined ? undefined : requiredGroup(rawGroupId, from);
|
|
212
|
+
if (groupId !== undefined && typeof groupId !== 'string')
|
|
213
|
+
return groupId;
|
|
192
214
|
return command(sub, 'ec.group.create', ['group', sub, from, name], from, { name, visibility, description: values.get('--description'), joinMode, groupId });
|
|
193
215
|
}
|
|
194
216
|
const simple = new Map([
|
|
@@ -197,12 +219,16 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
197
219
|
['join', 'ec.group.join'], ['leave', 'ec.group.leave'], ['invite', 'ec.group.invite'], ['kick', 'ec.group.kick'],
|
|
198
220
|
['members', 'ec.group.members'], ['online', 'ec.group.online'], ['role', 'ec.group.role'], ['owner', 'ec.group.owner'],
|
|
199
221
|
['ban', 'ec.group.ban'], ['unban', 'ec.group.unban'],
|
|
222
|
+
['block', 'ec.group.block'], ['unblock', 'ec.group.unblock'], ['blocklist', 'ec.group.blocklist'],
|
|
223
|
+
['report-status', 'ec.group.report-status'], ['member-statuses', 'ec.group.member-statuses'],
|
|
200
224
|
]);
|
|
201
225
|
if (simple.has(sub)) {
|
|
202
226
|
const allowedFlags = {
|
|
203
227
|
pull: ['--after-seq', '--limit'], ack: [], info: [], update: ['--name', '--description'], dissolve: [],
|
|
204
228
|
suspend: [], resume: [], join: ['--message', '--answer'], leave: [], invite: ['--member-type'], kick: [],
|
|
205
229
|
members: ['--page', '--size'], online: [], role: [], owner: [], ban: ['--duration'], unban: [],
|
|
230
|
+
block: ['--reason'], unblock: [], blocklist: [],
|
|
231
|
+
'report-status': ['--online-status', '--work-status'], 'member-statuses': [],
|
|
206
232
|
};
|
|
207
233
|
const flagsError = onlyFlags(values, allowedFlags[sub] ?? []);
|
|
208
234
|
if (flagsError)
|
|
@@ -253,13 +279,25 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
253
279
|
extra.members = members;
|
|
254
280
|
extra.memberType = memberType;
|
|
255
281
|
}
|
|
256
|
-
else if (sub === 'kick' || sub === 'unban') {
|
|
282
|
+
else if (sub === 'kick' || sub === 'unban' || sub === 'block' || sub === 'unblock') {
|
|
257
283
|
if (positionals.length !== 3)
|
|
258
284
|
return failGroup('INVALID_ARGUMENT', `${sub} requires a member AID`);
|
|
259
285
|
const memberAid = requiredAid(positionals[2], 'member AID');
|
|
260
286
|
if (typeof memberAid !== 'string')
|
|
261
287
|
return memberAid;
|
|
262
288
|
extra.memberAid = memberAid;
|
|
289
|
+
if (sub === 'block')
|
|
290
|
+
extra.reason = values.get('--reason');
|
|
291
|
+
}
|
|
292
|
+
else if (sub === 'report-status') {
|
|
293
|
+
if (positionals.length !== 2)
|
|
294
|
+
return failGroup('INVALID_ARGUMENT', 'report-status accepts exactly <from> <group-aid>');
|
|
295
|
+
const onlineStatus = values.get('--online-status');
|
|
296
|
+
const workStatus = values.get('--work-status');
|
|
297
|
+
if (onlineStatus === undefined || workStatus === undefined) {
|
|
298
|
+
return failGroup('INVALID_ARGUMENT', 'report-status requires --online-status and --work-status');
|
|
299
|
+
}
|
|
300
|
+
Object.assign(extra, { onlineStatus, workStatus });
|
|
263
301
|
}
|
|
264
302
|
else if (sub === 'members') {
|
|
265
303
|
if (positionals.length !== 2)
|
|
@@ -305,7 +343,7 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
305
343
|
extra.durationSeconds = durationSeconds;
|
|
306
344
|
extra.list = positionals.length === 2;
|
|
307
345
|
}
|
|
308
|
-
else if (sub === 'info' || sub === 'dissolve' || sub === 'suspend' || sub === 'resume' || sub === 'leave' || sub === 'online') {
|
|
346
|
+
else if (sub === 'info' || sub === 'dissolve' || sub === 'suspend' || sub === 'resume' || sub === 'leave' || sub === 'online' || sub === 'blocklist' || sub === 'member-statuses') {
|
|
309
347
|
if (positionals.length !== 2)
|
|
310
348
|
return failGroup('INVALID_ARGUMENT', `${sub} accepts exactly <from> <group-aid>`);
|
|
311
349
|
}
|
|
@@ -318,7 +356,7 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
318
356
|
const from = requiredAid(positionals[0], 'from AID');
|
|
319
357
|
if (typeof from !== 'string')
|
|
320
358
|
return from;
|
|
321
|
-
const groupId = requiredGroup(positionals[1]);
|
|
359
|
+
const groupId = requiredGroup(positionals[1], from);
|
|
322
360
|
if (typeof groupId !== 'string')
|
|
323
361
|
return groupId;
|
|
324
362
|
const rest = positionals.slice(2);
|
|
@@ -354,7 +392,17 @@ export function resolveManagedGroupOperation(argv) {
|
|
|
354
392
|
return failGroup('NOT_ALLOWED', `unsupported managed group command: ${sub}`);
|
|
355
393
|
}
|
|
356
394
|
/** Execute a parsed command using daemon-owned AUN credentials and root. */
|
|
357
|
-
export async function executeManagedGroupOperation(command, rulesContent) {
|
|
395
|
+
export async function executeManagedGroupOperation(command, rulesContent, historyContext = {}) {
|
|
396
|
+
if (command.kind === 'history') {
|
|
397
|
+
try {
|
|
398
|
+
return groupHistory(command.history, historyContext);
|
|
399
|
+
}
|
|
400
|
+
catch (error) {
|
|
401
|
+
if (error instanceof GroupHistoryError)
|
|
402
|
+
throw new ManagedGroupOperationError(error.code, error.message);
|
|
403
|
+
throw error;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
358
406
|
const opts = { aunPath: resolveRoot() };
|
|
359
407
|
let result;
|
|
360
408
|
switch (command.kind) {
|
|
@@ -427,6 +475,21 @@ export async function executeManagedGroupOperation(command, rulesContent) {
|
|
|
427
475
|
case 'unban':
|
|
428
476
|
result = await groupUnban({ from: command.from, groupId: command.groupId, memberAid: command.memberAid, ...opts });
|
|
429
477
|
break;
|
|
478
|
+
case 'block':
|
|
479
|
+
result = await groupBlock({ from: command.from, groupId: command.groupId, memberAid: command.memberAid, reason: command.reason, ...opts });
|
|
480
|
+
break;
|
|
481
|
+
case 'unblock':
|
|
482
|
+
result = await groupUnblock({ from: command.from, groupId: command.groupId, memberAid: command.memberAid, ...opts });
|
|
483
|
+
break;
|
|
484
|
+
case 'blocklist':
|
|
485
|
+
result = await groupBlocklist({ from: command.from, groupId: command.groupId, ...opts });
|
|
486
|
+
break;
|
|
487
|
+
case 'report-status':
|
|
488
|
+
result = await groupReportStatus({ from: command.from, groupId: command.groupId, onlineStatus: command.onlineStatus, workStatus: command.workStatus, ...opts });
|
|
489
|
+
break;
|
|
490
|
+
case 'member-statuses':
|
|
491
|
+
result = await groupMemberStatuses({ from: command.from, groupId: command.groupId, ...opts });
|
|
492
|
+
break;
|
|
430
493
|
case 'rules.get':
|
|
431
494
|
result = await groupRulesFileGet({ from: command.from, groupId: command.groupId, ...opts });
|
|
432
495
|
break;
|
|
@@ -678,10 +741,13 @@ function parseRemote(value, allowEmpty) {
|
|
|
678
741
|
const separator = value.indexOf(':');
|
|
679
742
|
if (separator <= 0)
|
|
680
743
|
return failFs('INVALID_PATH', 'remote path must use <group-aid>:<absolute-path>');
|
|
681
|
-
|
|
744
|
+
let groupId;
|
|
682
745
|
const remotePath = value.slice(separator + 1);
|
|
683
|
-
|
|
684
|
-
|
|
746
|
+
try {
|
|
747
|
+
groupId = normalizeGroupAid(value.slice(0, separator).trim());
|
|
748
|
+
}
|
|
749
|
+
catch (error) {
|
|
750
|
+
return failFs('INVALID_GROUP', `invalid group AID: ${error.message}`);
|
|
685
751
|
}
|
|
686
752
|
if (remotePath === '' && allowEmpty)
|
|
687
753
|
return { groupId, remotePath: '' };
|
|
@@ -18,3 +18,54 @@ export function normalizeAunMentionEntries(raw) {
|
|
|
18
18
|
}
|
|
19
19
|
return entries;
|
|
20
20
|
}
|
|
21
|
+
/** Reject unsupported attention values before normalizing the outbound payload. */
|
|
22
|
+
export function parseAunAttention(value) {
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return undefined;
|
|
25
|
+
if (value === 'completed' || value === 'failed' || value === 'required' || value === 'interrupted')
|
|
26
|
+
return value;
|
|
27
|
+
throw Object.assign(new Error('attention must be completed, failed, required, or interrupted'), {
|
|
28
|
+
code: 'INVALID_ATTENTION',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Project runner state as a pair, using the structured status as the authority.
|
|
33
|
+
* Action cards always require action. All other business payloads omit both
|
|
34
|
+
* fields, including explicit/custom payloads and entries retried from outbox.
|
|
35
|
+
*/
|
|
36
|
+
export function withAunAttention(payload, fallback) {
|
|
37
|
+
parseAunAttention(payload.attention);
|
|
38
|
+
parseAunAttention(fallback);
|
|
39
|
+
const attention = payload.type === 'action_card'
|
|
40
|
+
? 'required'
|
|
41
|
+
: payload.type === 'task.status' && typeof payload.status === 'string'
|
|
42
|
+
? aunStatusAttention(payload.status)
|
|
43
|
+
: undefined;
|
|
44
|
+
const normalized = { ...payload };
|
|
45
|
+
delete normalized.terminal;
|
|
46
|
+
delete normalized.attention;
|
|
47
|
+
return attention === undefined
|
|
48
|
+
? normalized
|
|
49
|
+
: { ...normalized, terminal: attention !== 'required', attention };
|
|
50
|
+
}
|
|
51
|
+
export function aunStatusAttention(status) {
|
|
52
|
+
switch (status) {
|
|
53
|
+
case 'done':
|
|
54
|
+
case 'completed': return 'completed';
|
|
55
|
+
case 'error':
|
|
56
|
+
case 'timeout': return 'failed';
|
|
57
|
+
case 'interrupted': return 'interrupted';
|
|
58
|
+
case 'requires_action': return 'required';
|
|
59
|
+
default: return undefined;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Business messages and command feedback never inherit runner attention. */
|
|
63
|
+
export function aunOutboundAttention(payload) {
|
|
64
|
+
parseAunAttention(payload.attention);
|
|
65
|
+
switch (payload.kind) {
|
|
66
|
+
case 'interaction': return 'required';
|
|
67
|
+
default: return payload.kind.startsWith('status.')
|
|
68
|
+
? aunStatusAttention(payload.kind.slice(7))
|
|
69
|
+
: undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
package/dist/aun/msg/p2p.js
CHANGED
|
@@ -8,9 +8,9 @@ import { normalizeCodexTextPayload, readBestTaskRuntimeContext, runtimeRefMessag
|
|
|
8
8
|
import { chatDirPath } from '../../core/session/session-fs-store.js';
|
|
9
9
|
import { resolvePaths } from '../../paths.js';
|
|
10
10
|
import { ipcQuery } from '../../ipc.js';
|
|
11
|
-
import {
|
|
11
|
+
import { readDelegationCredential } from '../../core/auth/agent-delegation.js';
|
|
12
12
|
import { loadDaemonConfig } from '../../config-store.js';
|
|
13
|
-
import { normalizeAunMentionEntries } from './mention-schema.js';
|
|
13
|
+
import { normalizeAunMentionEntries, withAunAttention } from './mention-schema.js';
|
|
14
14
|
const DAEMON_SEND_TIMEOUT_GRACE_MS = 10_000;
|
|
15
15
|
const DEFAULT_IDLE_TIMEOUT_MS = 120_000;
|
|
16
16
|
const MAX_TIMER_MS = 2_147_483_647;
|
|
@@ -110,7 +110,7 @@ function msgSendLogMetadata(args, payload, runtimeContext) {
|
|
|
110
110
|
}
|
|
111
111
|
async function tryDaemonMsgSend(args, payload, runtimeContext, file) {
|
|
112
112
|
const delegatedTask = !!process.env.EVOLCORE_SESSION_ID
|
|
113
|
-
|| !!
|
|
113
|
+
|| !!readDelegationCredential();
|
|
114
114
|
if (!runtimeContext) {
|
|
115
115
|
return delegatedTask
|
|
116
116
|
? { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task runtime context is unavailable' }
|
|
@@ -138,9 +138,9 @@ async function tryDaemonMsgSend(args, payload, runtimeContext, file) {
|
|
|
138
138
|
handoffContext: args.handoffContext,
|
|
139
139
|
originSessionId: runtimeContext.sessionId,
|
|
140
140
|
originMessageId: runtimeContext.messageId,
|
|
141
|
-
delegationToken:
|
|
141
|
+
delegationToken: readDelegationCredential(),
|
|
142
142
|
log: msgSendLogMetadata(args, payload, runtimeContext),
|
|
143
|
-
}, daemonTaskSendIpcTimeoutMs(!!file));
|
|
143
|
+
}, daemonTaskSendIpcTimeoutMs(!!file), { throwOnError: true });
|
|
144
144
|
return response ?? {
|
|
145
145
|
ok: false,
|
|
146
146
|
code: 'AUN_DAEMON_UNAVAILABLE',
|
|
@@ -228,7 +228,7 @@ export async function msgSend(args) {
|
|
|
228
228
|
try {
|
|
229
229
|
let payload;
|
|
230
230
|
if (args.body.mode !== 'file') {
|
|
231
|
-
payload = buildSimplePayload(args.body);
|
|
231
|
+
payload = withAunAttention(buildSimplePayload(args.body));
|
|
232
232
|
normalizeCodexTextPayload(payload, runtimeContext);
|
|
233
233
|
if (Object.prototype.hasOwnProperty.call(payload, 'mentions')) {
|
|
234
234
|
payload.mentions = normalizeAunMentionEntries(payload.mentions);
|
|
@@ -272,7 +272,7 @@ export async function msgSend(args) {
|
|
|
272
272
|
const idStore = await getAidStore({ slotId: args.slotId ?? SLOT.cli, aunPath: args.aunPath });
|
|
273
273
|
let peerIdentity;
|
|
274
274
|
try {
|
|
275
|
-
peerIdentity = await PeerIdentityCache.resolve('aun', args.to, selfAgentDir, idStore, false);
|
|
275
|
+
peerIdentity = await PeerIdentityCache.resolve('aun', args.to, selfAgentDir, idStore, false, args.aunPath);
|
|
276
276
|
}
|
|
277
277
|
finally {
|
|
278
278
|
try {
|
|
@@ -297,6 +297,7 @@ export async function msgSend(args) {
|
|
|
297
297
|
payload.mentions = normalizeAunMentionEntries(payload.mentions);
|
|
298
298
|
}
|
|
299
299
|
const encrypt = resolveAunMessageEncrypt(args.encrypt);
|
|
300
|
+
payload = withAunAttention(payload);
|
|
300
301
|
const sendParams = { to: args.to, payload, encrypt };
|
|
301
302
|
const result = await conn.call('message.send', sendParams);
|
|
302
303
|
const messageId = typeof result?.message_id === 'string' && result.message_id.trim()
|
|
@@ -353,11 +354,15 @@ export async function msgPull(args) {
|
|
|
353
354
|
return {
|
|
354
355
|
ok: true,
|
|
355
356
|
messages: result?.messages ?? [],
|
|
356
|
-
count: result?.count ?? 0,
|
|
357
|
+
count: result?.count ?? result?.messages?.length ?? 0,
|
|
357
358
|
latest_seq: result?.latest_seq ?? 0,
|
|
358
359
|
earliest_available_seq: result?.earliest_available_seq ?? null,
|
|
359
360
|
ephemeral_earliest_available_seq: result?.ephemeral_earliest_available_seq ?? null,
|
|
360
361
|
ephemeral_dropped_count: result?.ephemeral_dropped_count ?? 0,
|
|
362
|
+
...(typeof result?.latest_volatile_cursor === 'string' ? { latest_volatile_cursor: result.latest_volatile_cursor } : {}),
|
|
363
|
+
...(typeof result?.volatile_earliest_cursor === 'string' ? { volatile_earliest_cursor: result.volatile_earliest_cursor } : {}),
|
|
364
|
+
...(typeof result?.volatile_dropped_count === 'number' ? { volatile_dropped_count: result.volatile_dropped_count } : {}),
|
|
365
|
+
...(typeof result?.volatile_has_more === 'boolean' ? { volatile_has_more: result.volatile_has_more } : {}),
|
|
361
366
|
};
|
|
362
367
|
}
|
|
363
368
|
catch (e) {
|