evolcore 0.0.43-test.6 → 0.0.43-test.8
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 +95 -0
- package/bin/ecmsg.js +188 -58
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/claude-runner.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +277 -49
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +7 -3
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +11 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +109 -0
- package/dist/cli/index.js +60 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +160 -83
- package/dist/cli/services-command.js +137 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +103 -13
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +8 -8
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +45 -15
- package/dist/config-store.js +2 -1
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +106 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +29 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +20 -12
- package/dist/core/command/agent-control.js +12 -2
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +80 -17
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +468 -0
- package/dist/core/command/menu-catalog.js +15 -0
- package/dist/core/command/menu-handler.js +216 -90
- package/dist/core/command/menu-protocol.js +71 -13
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +22 -5
- package/dist/core/daemon-lifecycle.js +323 -191
- package/dist/core/handoff/runtime.js +45 -13
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +50 -7
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +252 -17
- package/dist/core/message/im-renderer.js +116 -85
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-queue.js +66 -15
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +29 -5
- package/dist/core/message/response-engine.js +194 -61
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +50 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +51 -17
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +67 -28
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/core/thread/thread-service.js +52 -3
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/eck/message-renderer.js +2 -0
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +124 -0
- package/dist/event-center/bus-gate.js +154 -0
- package/dist/event-center/bus-host.js +307 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +127 -0
- package/dist/event-center/daemon.js +44 -0
- package/dist/event-center/directory-source.js +55 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +73 -0
- package/dist/event-center/ipc-operation.js +423 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +207 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +463 -0
- package/dist/event-center/runtime.js +837 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +51 -0
- package/dist/event-center/validation.js +435 -0
- package/dist/index.js +424 -135
- package/dist/ipc.js +106 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/engines/v1/proactive-flow.js +4 -2
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +550 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +215 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +98 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +170 -24
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +9 -15
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -1
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +227 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +5 -3
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +28 -1
- package/kits/docs/evolcore/msg.md +21 -9
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +294 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +1 -0
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-group/SKILL.md +5 -8
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +1 -5
- package/kits/templates/system-fragments/thread.md +13 -10
- package/package.json +5 -6
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -15,7 +15,6 @@ import { logger } from '../../utils/logger.js';
|
|
|
15
15
|
import { resolvePeerRoleDetail, roleToSessionIdentity } from '../../config/peer-role-resolver.js';
|
|
16
16
|
import { ThreadService } from '../thread/thread-service.js';
|
|
17
17
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
18
|
-
import { resolveAgentLifecycle } from '../../config/lifecycle.js';
|
|
19
18
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
20
19
|
import { sameGroupAid } from '../../aun/group/index.js';
|
|
21
20
|
import crypto from 'crypto';
|
|
@@ -57,9 +56,10 @@ import { constrainRuntimePermissionMode, resolveRuntimePermissionMode, validateR
|
|
|
57
56
|
import { parsePeerKey } from '../relation/peer-identity.js';
|
|
58
57
|
import { isQuickCommand } from './slash-gate.js';
|
|
59
58
|
import { handleSlashCommand } from './slash-handler.js';
|
|
60
|
-
import {
|
|
59
|
+
import { resolveChatMode } from '../message/peer-mode.js';
|
|
61
60
|
import { execMenuAction as menuExecMenuAction, execMenuForEcweb as menuExecMenuForEcweb, execMenuForControl as menuExecMenuForControl, execMenuQuery as menuExecMenuQuery, execMenuUpdate as menuExecMenuUpdate, getMenuItems as menuGetMenuItems, getSubMenuItems as menuGetSubMenuItems, buildTopicForkSourcePayload, } from './menu-handler.js';
|
|
62
61
|
import { getMenuCatalog, execMenuValueBatch, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
62
|
+
import { execMenuQueryBatch } from './menu-query-batch.js';
|
|
63
63
|
import { resolveCurrentSessionLoopTarget, sessionLoopError } from '../session/session-idle-monitor.js';
|
|
64
64
|
export { isProcessLevelOwner } from './menu-handler.js';
|
|
65
65
|
const CLI_EXEC_TIMEOUT_MS = 15_000;
|
|
@@ -106,6 +106,7 @@ export class CommandHandler {
|
|
|
106
106
|
legacySingleRunnerMode;
|
|
107
107
|
primaryRunnerKey;
|
|
108
108
|
agentRegistry;
|
|
109
|
+
teamWorkspaceManagementService;
|
|
109
110
|
memoryConsolidationLauncher;
|
|
110
111
|
/** /skill refresh 的 daemon 侧入口:重建指定 agent 的技能索引 */
|
|
111
112
|
skillIndexRefresher;
|
|
@@ -234,8 +235,38 @@ export class CommandHandler {
|
|
|
234
235
|
logger.error(`[RunnerLookup] unavailable channel=${channel ?? '<none>'} baseagent=${requestedBaseagent || '<missing>'} keys=${[...this.agentMap.keys()].join(',')}`);
|
|
235
236
|
throw new BaseagentRunnerUnavailableError('<unknown>', requestedBaseagent || '<missing>', []);
|
|
236
237
|
}
|
|
238
|
+
runnerReadiness;
|
|
239
|
+
configuredBaseagents;
|
|
240
|
+
setRunnerReadiness(ensure, available) {
|
|
241
|
+
this.runnerReadiness = ensure;
|
|
242
|
+
this.configuredBaseagents = available;
|
|
243
|
+
}
|
|
244
|
+
/** Commands that use backend state load it; activity probes keep using getAgent. */
|
|
245
|
+
async ensureAgent(channel, baseagent, selfAid) {
|
|
246
|
+
const owner = selfAid ? this.agentRegistry?.get(selfAid) : channel ? this.agentRegistry?.resolveByChannel(channel) : undefined;
|
|
247
|
+
if (owner && baseagent && this.runnerReadiness) {
|
|
248
|
+
await this.runnerReadiness(owner.aid, baseagent);
|
|
249
|
+
const runner = this.agentMap.get(`${owner.aid}::${baseagent}`);
|
|
250
|
+
if (runner)
|
|
251
|
+
return runner;
|
|
252
|
+
}
|
|
253
|
+
return this.getAgent(channel, baseagent);
|
|
254
|
+
}
|
|
255
|
+
getLoadedAgent(channel, baseagent) {
|
|
256
|
+
const owner = this.agentRegistry?.resolveByChannel(channel);
|
|
257
|
+
if (owner && this.configuredBaseagents) {
|
|
258
|
+
const runner = this.agentMap.get(`${owner.aid}::${baseagent}`);
|
|
259
|
+
if (runner)
|
|
260
|
+
return runner;
|
|
261
|
+
const available = this.configuredBaseagents(owner.aid);
|
|
262
|
+
if (available.includes(baseagent))
|
|
263
|
+
return undefined;
|
|
264
|
+
throw new BaseagentRunnerUnavailableError(owner.aid, baseagent, available);
|
|
265
|
+
}
|
|
266
|
+
return this.getAgent(channel, baseagent);
|
|
267
|
+
}
|
|
237
268
|
getAvailableBaseagentsForOwner(evolName) {
|
|
238
|
-
return loadedBaseagentIds(this.agentMap.keys(), evolName);
|
|
269
|
+
return this.configuredBaseagents?.(evolName) ?? loadedBaseagentIds(this.agentMap.keys(), evolName);
|
|
239
270
|
}
|
|
240
271
|
/** Return the stable temporary root for a managed session, if available. */
|
|
241
272
|
getManagedSessionTempDir(session) {
|
|
@@ -255,10 +286,12 @@ export class CommandHandler {
|
|
|
255
286
|
getAvailableBaseagents(channel) {
|
|
256
287
|
const owner = this.agentRegistry?.resolveByChannel(channel);
|
|
257
288
|
if (!owner) {
|
|
258
|
-
return
|
|
289
|
+
return this.configuredBaseagents && this.agentRegistry
|
|
290
|
+
? [...new Set(this.agentRegistry.list().flatMap(agent => this.configuredBaseagents(agent.aid)))]
|
|
291
|
+
: loadedBaseagentIds(this.agentMap.keys());
|
|
259
292
|
}
|
|
260
293
|
const evolName = owner.name || '<unknown>';
|
|
261
|
-
return
|
|
294
|
+
return this.getAvailableBaseagentsForOwner(evolName);
|
|
262
295
|
}
|
|
263
296
|
/** Extract the baseagent component from `primaryRunnerKey` (e.g. `aid::claude` → `claude`). */
|
|
264
297
|
parseDefaultBaseagent() {
|
|
@@ -285,6 +318,14 @@ export class CommandHandler {
|
|
|
285
318
|
setAgentRegistry(registry) {
|
|
286
319
|
this.agentRegistry = registry;
|
|
287
320
|
}
|
|
321
|
+
setTeamWorkspaceManagementService(service) {
|
|
322
|
+
this.teamWorkspaceManagementService = service;
|
|
323
|
+
}
|
|
324
|
+
/** 事件中心(menu events)。字段名避开既有的进程内 `eventBus`。 */
|
|
325
|
+
eventCenter;
|
|
326
|
+
setEventCenter(registry) {
|
|
327
|
+
this.eventCenter = registry;
|
|
328
|
+
}
|
|
288
329
|
/** Inject the Core-owned agent application facade after runtime hooks exist. */
|
|
289
330
|
setAgentApplicationService(service) {
|
|
290
331
|
this.agentApplicationService = service;
|
|
@@ -1105,6 +1146,12 @@ export class CommandHandler {
|
|
|
1105
1146
|
execQuery: async (cmd, resolvedChannelId, queryArgs, context) => this.execMenuQuery(cmd, channel, resolvedChannelId, context.subject.actorId, queryArgs, context.subject.chatType, context.subject.fromControlChannel, context.subject.identity, context.subject, channelScope === 'control' ? 'control' : 'menu', resolvedChannelId === channelId ? transportReplyContext : undefined),
|
|
1106
1147
|
});
|
|
1107
1148
|
}
|
|
1149
|
+
async execMenuQueryBatch(channel, channelId, subject, args, channelScope = 'agent', transportReplyContext) {
|
|
1150
|
+
return execMenuQueryBatch({
|
|
1151
|
+
subject, channelType: this.resolveChannelType(channel), channelScope, channelId, args,
|
|
1152
|
+
execQuery: (cmd, resolvedChannelId, queryArgs, querySubject) => this.execMenuQuery(cmd, channel, resolvedChannelId, querySubject.actorId, queryArgs, querySubject.chatType, querySubject.fromControlChannel, querySubject.identity, querySubject, channelScope === 'control' ? 'control' : 'menu', resolvedChannelId === channelId ? transportReplyContext : undefined),
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1108
1155
|
/** 动态子菜单:根据 cmd 路径返回选项列表(供 menu.query + cmd 使用) */
|
|
1109
1156
|
async getSubMenuItems(cmd, channel, channelId, userId, args, overrideIdentity, explicitChatType, fromControlChannel = false, authSubject, source = 'menu', transportReplyContext) {
|
|
1110
1157
|
return await menuGetSubMenuItems.call(this, cmd, channel, channelId, userId, args, overrideIdentity, explicitChatType, fromControlChannel, authSubject, source, transportReplyContext);
|
|
@@ -1832,10 +1879,7 @@ export class CommandHandler {
|
|
|
1832
1879
|
if (meta?.replyContext?.replyInThread)
|
|
1833
1880
|
ctx.replyInThread = meta.replyContext.replyInThread;
|
|
1834
1881
|
const taskId = this.sessionManager.getActiveTaskId(session.id);
|
|
1835
|
-
const
|
|
1836
|
-
? meta.turnState.active.recoveryContext?.chatmode
|
|
1837
|
-
: undefined;
|
|
1838
|
-
const chatmode = isChatMode(taskChatmode) ? taskChatmode : this.resolveEffectiveChatmodeForSession(session);
|
|
1882
|
+
const chatmode = this.resolveEffectiveChatmodeForSession(session);
|
|
1839
1883
|
const encrypted = this.sessionManager.getSessionEncrypt(session.id);
|
|
1840
1884
|
// 诊断日志:记录 task_id 解析结果
|
|
1841
1885
|
logger.info(`[CommandHandler] buildCtlReplyContext: sessionId=${session.id} taskId=${taskId ?? 'none'} chatmode=${chatmode} threadId=${ctx.threadId ?? 'none'} replyTo=${ctx.replyToMessageId ?? 'none'} inThread=${ctx.replyInThread ?? false}`);
|
|
@@ -1866,8 +1910,6 @@ export class CommandHandler {
|
|
|
1866
1910
|
chatType: session.chatType,
|
|
1867
1911
|
peerType,
|
|
1868
1912
|
channelType,
|
|
1869
|
-
lifecycle: resolveAgentLifecycle(this.getOwningAgent(session.channel)?.config ?? {}),
|
|
1870
|
-
sessionType: session.sessionType ?? session.metadata?.sessionType ?? 'main',
|
|
1871
1913
|
});
|
|
1872
1914
|
}
|
|
1873
1915
|
catch {
|
|
@@ -3527,6 +3569,25 @@ export class CommandHandler {
|
|
|
3527
3569
|
return { ok: false, error: `❌ --before 不是有效时间(支持 ${TIME_ARG_FORMATS})` };
|
|
3528
3570
|
if (after !== undefined && before !== undefined && after >= before)
|
|
3529
3571
|
return { ok: false, error: '❌ --after 必须早于 --before' };
|
|
3572
|
+
// 跨会话查看:跨话题自派落点是别的话题会话,队列不在当前会话里,没有这个
|
|
3573
|
+
// 选择器就只能靠 daemon 日志反推。只读,不允许借它改动别的会话。
|
|
3574
|
+
const requestedSessionId = this.extractArg(args, '--session');
|
|
3575
|
+
if (requestedSessionId && (args.includes('--clear') || args.includes('--cancel') || args.includes('--interrupt'))) {
|
|
3576
|
+
return { ok: false, error: '❌ --session 只用于查看,不能跨会话清空/取消/打断' };
|
|
3577
|
+
}
|
|
3578
|
+
let targetSessionId = sessionId;
|
|
3579
|
+
if (requestedSessionId && requestedSessionId !== sessionId) {
|
|
3580
|
+
const [current, target] = await Promise.all([
|
|
3581
|
+
this.sessionManager.getSessionById(sessionId),
|
|
3582
|
+
this.sessionManager.getSessionById(requestedSessionId),
|
|
3583
|
+
]);
|
|
3584
|
+
if (!target)
|
|
3585
|
+
return { ok: false, error: `❌ 找不到会话 ${requestedSessionId}` };
|
|
3586
|
+
if (!current || target.selfAID !== current.selfAID) {
|
|
3587
|
+
return { ok: false, error: '❌ --session 只能查看本 Agent 的会话' };
|
|
3588
|
+
}
|
|
3589
|
+
targetSessionId = requestedSessionId;
|
|
3590
|
+
}
|
|
3530
3591
|
// 操作分支
|
|
3531
3592
|
if (args.includes('--clear')) {
|
|
3532
3593
|
const count = this.messageQueue.clearBySession(sessionId);
|
|
@@ -3548,11 +3609,12 @@ export class CommandHandler {
|
|
|
3548
3609
|
: { ok: false, error: `❌ 当前无处理中任务` };
|
|
3549
3610
|
}
|
|
3550
3611
|
// 查询
|
|
3551
|
-
const items = this.messageQueue.getQueueItemsBySession(
|
|
3612
|
+
const items = this.messageQueue.getQueueItemsBySession(targetSessionId, { after, before });
|
|
3613
|
+
const title = targetSessionId === sessionId ? undefined : `会话 ${targetSessionId} 队列`;
|
|
3552
3614
|
if (formatJson) {
|
|
3553
|
-
return { ok: true, result: JSON.stringify({ items }, null, 2) };
|
|
3615
|
+
return { ok: true, result: JSON.stringify({ sessionId: targetSessionId, items }, null, 2) };
|
|
3554
3616
|
}
|
|
3555
|
-
return { ok: true, result: renderQueueItemsCtl(items, showId, full) };
|
|
3617
|
+
return { ok: true, result: renderQueueItemsCtl(items, showId, full, title) };
|
|
3556
3618
|
}
|
|
3557
3619
|
}
|
|
3558
3620
|
function parseQueueTimeArg(value) {
|
|
@@ -3561,11 +3623,12 @@ function parseQueueTimeArg(value) {
|
|
|
3561
3623
|
/**
|
|
3562
3624
|
* ctl 专用渲染:不显示 session 标识列(因为只有一个 session)
|
|
3563
3625
|
*/
|
|
3564
|
-
function renderQueueItemsCtl(items, showId, full) {
|
|
3626
|
+
function renderQueueItemsCtl(items, showId, full, title) {
|
|
3627
|
+
const heading = title ?? '当前会话队列';
|
|
3565
3628
|
if (items.length === 0) {
|
|
3566
|
-
return
|
|
3629
|
+
return `${heading} (0 条待处理)\n\n(无待处理消息)`;
|
|
3567
3630
|
}
|
|
3568
|
-
const lines = [
|
|
3631
|
+
const lines = [`${heading} (${items.length} 条待处理)`, ''];
|
|
3569
3632
|
// 计算列宽
|
|
3570
3633
|
const maxIdLen = showId ? Math.max(...items.map(i => i.messageId?.length ?? 0)) : 0;
|
|
3571
3634
|
const maxNameLen = Math.max(...items.map(i => (i.peerName ? `[${i.peerName}]`.length : 0)));
|
|
@@ -5,8 +5,8 @@ import { isValidAid } from '../../aun/aid/validation.js';
|
|
|
5
5
|
import { isStaticAgentOwner } from '../../config/peer-role-resolver.js';
|
|
6
6
|
import { agentDir, agentRelationSharedDir } from '../../paths.js';
|
|
7
7
|
import { formatPeerKey, readAunPeerKind } from '../relation/peer-identity.js';
|
|
8
|
-
import { DataRootError,
|
|
9
|
-
export { DataRootError } from './
|
|
8
|
+
import { DataRootError, teamWorkspaceStore } from './team-workspace-store.js';
|
|
9
|
+
export { DataRootError } from './team-workspace-store.js';
|
|
10
10
|
const DEFAULT_ROOT_TTL_MS = 10 * 60 * 1000;
|
|
11
11
|
const TOKEN_PREFIX = 'dr1';
|
|
12
12
|
function base64Url(value) {
|
|
@@ -31,7 +31,7 @@ export class DataRootResolver {
|
|
|
31
31
|
isOwner;
|
|
32
32
|
resolveAgentPath;
|
|
33
33
|
resolveRelationSharedPath;
|
|
34
|
-
|
|
34
|
+
teamStore;
|
|
35
35
|
constructor(options = {}) {
|
|
36
36
|
this.secret = options.secret ?? crypto.randomBytes(32);
|
|
37
37
|
if (this.secret.length < 32)
|
|
@@ -41,7 +41,7 @@ export class DataRootResolver {
|
|
|
41
41
|
this.isOwner = options.isOwner ?? isStaticAgentOwner;
|
|
42
42
|
this.resolveAgentPath = options.resolveAgentPath ?? agentDir;
|
|
43
43
|
this.resolveRelationSharedPath = options.resolveRelationSharedPath ?? agentRelationSharedDir;
|
|
44
|
-
this.
|
|
44
|
+
this.teamStore = options.teamStore ?? teamWorkspaceStore;
|
|
45
45
|
}
|
|
46
46
|
issueAgentRoot(subject) {
|
|
47
47
|
const targetAid = this.targetAid(subject);
|
|
@@ -74,18 +74,18 @@ export class DataRootResolver {
|
|
|
74
74
|
const rootPath = this.canonicalRoot(this.resolveRelationSharedPath(targetAid, peerKey), agentRoot);
|
|
75
75
|
return this.issueDescriptor({ scope: 'relation', targetAid, principalId, peerAid, peerKey }, rootPath);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
issueTeamWorkspaceRoot(subject) {
|
|
78
78
|
const targetAid = this.targetAid(subject);
|
|
79
79
|
this.assertPrivateAun(subject);
|
|
80
80
|
const principalId = authenticatedPrincipal(subject);
|
|
81
81
|
if (subject.role !== 'owner' || !this.isOwner(targetAid, principalId)) {
|
|
82
|
-
throw new DataRootError('ROOT_FORBIDDEN', '
|
|
82
|
+
throw new DataRootError('ROOT_FORBIDDEN', 'Team workspace root requires Agent owner permission');
|
|
83
83
|
}
|
|
84
|
-
const state = this.
|
|
84
|
+
const state = this.teamStore.require(targetAid);
|
|
85
85
|
if (state.ownerAid !== principalId) {
|
|
86
|
-
throw new DataRootError('ROOT_FORBIDDEN', '
|
|
86
|
+
throw new DataRootError('ROOT_FORBIDDEN', 'Team workspace is bound to another owner');
|
|
87
87
|
}
|
|
88
|
-
return this.issueDescriptor({ scope: '
|
|
88
|
+
return this.issueDescriptor({ scope: 'team', targetAid, principalId, workspaceId: state.workspaceId }, this.teamStore.root(state));
|
|
89
89
|
}
|
|
90
90
|
resolveRoot(rootId, subject) {
|
|
91
91
|
const claims = this.verifyToken(rootId);
|
|
@@ -120,17 +120,17 @@ export class DataRootResolver {
|
|
|
120
120
|
else {
|
|
121
121
|
this.assertPrivateAun(subject);
|
|
122
122
|
if (!claims.workspaceId)
|
|
123
|
-
throw new DataRootError('ROOT_SCOPE_MISMATCH', '
|
|
123
|
+
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'Team workspace root claims are invalid');
|
|
124
124
|
if (subject.role !== 'owner' || !this.isOwner(targetAid, principalId)) {
|
|
125
|
-
throw new DataRootError('ROOT_FORBIDDEN', '
|
|
125
|
+
throw new DataRootError('ROOT_FORBIDDEN', 'Team workspace root requires Agent owner permission');
|
|
126
126
|
}
|
|
127
|
-
workspaceState = this.
|
|
127
|
+
workspaceState = this.teamStore.require(targetAid);
|
|
128
128
|
if (workspaceState.ownerAid !== principalId || workspaceState.workspaceId !== claims.workspaceId) {
|
|
129
|
-
throw new DataRootError('ROOT_SCOPE_MISMATCH', '
|
|
129
|
+
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'Team workspace binding changed; request a new root');
|
|
130
130
|
}
|
|
131
|
-
rootPath = this.
|
|
131
|
+
rootPath = this.teamStore.root(workspaceState);
|
|
132
132
|
}
|
|
133
|
-
const revision = this.
|
|
133
|
+
const revision = this.descriptorRevision(claims.scope, targetAid, rootPath);
|
|
134
134
|
if (revision !== claims.revision) {
|
|
135
135
|
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'Root identity changed; request a new root');
|
|
136
136
|
}
|
|
@@ -148,11 +148,11 @@ export class DataRootResolver {
|
|
|
148
148
|
resolvePath(rootId, subject, input, expectType) {
|
|
149
149
|
const root = this.resolveRoot(rootId, subject);
|
|
150
150
|
const raw = String(input ?? '').trim();
|
|
151
|
-
if (root.scope === '
|
|
152
|
-
const state = this.
|
|
151
|
+
if (root.scope === 'team') {
|
|
152
|
+
const state = this.teamStore.require(root.targetAid);
|
|
153
153
|
if (state.workspaceId !== root.workspaceId)
|
|
154
|
-
throw new DataRootError('ROOT_SCOPE_MISMATCH', '
|
|
155
|
-
const resolved = this.
|
|
154
|
+
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'Team workspace binding changed; request a new root');
|
|
155
|
+
const resolved = this.teamStore.resolvePath(state, raw);
|
|
156
156
|
if (expectType === 'file' && !resolved.stat.isFile()) {
|
|
157
157
|
throw new DataRootError('NOT_SUPPORTED', 'Path is not a regular file');
|
|
158
158
|
}
|
|
@@ -201,7 +201,7 @@ export class DataRootResolver {
|
|
|
201
201
|
const claims = {
|
|
202
202
|
v: 1,
|
|
203
203
|
...base,
|
|
204
|
-
revision: this.
|
|
204
|
+
revision: this.descriptorRevision(base.scope, base.targetAid, rootPath),
|
|
205
205
|
issuedAt,
|
|
206
206
|
expiresAt: issuedAt + this.ttlMs,
|
|
207
207
|
nonce: crypto.randomBytes(12).toString('base64url'),
|
|
@@ -217,7 +217,7 @@ export class DataRootResolver {
|
|
|
217
217
|
? '$AGENTS_DIR/<targetAid>'
|
|
218
218
|
: claims.scope === 'relation'
|
|
219
219
|
? '$AGENTS_DIR/<targetAid>/relations/<peerKey>/shared'
|
|
220
|
-
: '$
|
|
220
|
+
: '$AGENTS_DIR/<targetAid>/workspace',
|
|
221
221
|
revision: `sha256:${claims.revision}`,
|
|
222
222
|
expiresAt: claims.expiresAt,
|
|
223
223
|
readOnly: true,
|
|
@@ -256,11 +256,11 @@ export class DataRootResolver {
|
|
|
256
256
|
throw new DataRootError('INVALID_ROOT_ID', 'Invalid data rootId payload');
|
|
257
257
|
}
|
|
258
258
|
if (claims.v !== 1
|
|
259
|
-
|| (claims.scope !== 'agent' && claims.scope !== 'relation' && claims.scope !== '
|
|
259
|
+
|| (claims.scope !== 'agent' && claims.scope !== 'relation' && claims.scope !== 'team')
|
|
260
260
|
|| typeof claims.targetAid !== 'string'
|
|
261
261
|
|| typeof claims.principalId !== 'string'
|
|
262
262
|
|| typeof claims.revision !== 'string'
|
|
263
|
-
|| (claims.scope === '
|
|
263
|
+
|| (claims.scope === 'team' && typeof claims.workspaceId !== 'string')
|
|
264
264
|
|| !Number.isFinite(claims.expiresAt)) {
|
|
265
265
|
throw new DataRootError('INVALID_ROOT_ID', 'Invalid data rootId claims');
|
|
266
266
|
}
|
|
@@ -292,6 +292,15 @@ export class DataRootResolver {
|
|
|
292
292
|
.update(JSON.stringify({ rootPath, dev: stat.dev, ino: stat.ino, birthtimeMs: stat.birthtimeMs }))
|
|
293
293
|
.digest('hex');
|
|
294
294
|
}
|
|
295
|
+
descriptorRevision(scope, targetAid, rootPath) {
|
|
296
|
+
const workspaceRevision = this.rootRevision(rootPath);
|
|
297
|
+
if (scope !== 'team')
|
|
298
|
+
return workspaceRevision;
|
|
299
|
+
const outputRoot = this.teamStore.outputRoot(this.teamStore.require(targetAid));
|
|
300
|
+
if (!outputRoot)
|
|
301
|
+
return workspaceRevision;
|
|
302
|
+
return crypto.createHash('sha256').update(`${workspaceRevision}:${this.rootRevision(outputRoot)}`).digest('hex');
|
|
303
|
+
}
|
|
295
304
|
targetAid(subject) {
|
|
296
305
|
const targetAid = String(subject.selfAid ?? '').trim();
|
|
297
306
|
if (!isValidAid(targetAid))
|