evolcore 0.0.41 → 0.0.42
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-hook.mjs +9 -5
- package/dist/agents/baseagent.js +156 -16
- package/dist/agents/claude-runner.js +10 -3
- package/dist/agents/codex/catalog.js +8 -4
- package/dist/agents/codex-runner.js +236 -59
- package/dist/agents/ecagent-runner.js +82 -13
- package/dist/aun/aid/agentmd.js +106 -27
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +65 -13
- package/dist/aun/aid/identity.js +70 -4
- package/dist/aun/aid/index.js +2 -2
- package/dist/aun/service-proxy.js +25 -1
- package/dist/channels/aun.js +242 -209
- package/dist/channels/dingtalk.js +1 -1
- package/dist/channels/feishu.js +1 -1
- package/dist/channels/qqbot.js +1 -1
- package/dist/channels/wechat.js +1 -1
- package/dist/channels/wecom.js +1 -1
- package/dist/cli/agent-command.js +183 -3
- package/dist/cli/agent-create.js +92 -86
- package/dist/cli/agent.js +136 -1
- package/dist/cli/aun-commands.js +137 -35
- package/dist/cli/bench.js +8 -2
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +235 -51
- package/dist/cli/debug-mode.js +1 -1
- package/dist/cli/directory.js +170 -0
- package/dist/cli/index.js +40 -30
- package/dist/cli/init-channel.js +4 -4
- package/dist/cli/init.js +47 -32
- package/dist/cli/managed-command-guard.js +4 -1
- package/dist/cli/model.js +27 -18
- package/dist/cli/pa-workspace-command.js +191 -0
- package/dist/cli/{contact.js → peer.js} +19 -25
- package/dist/cli/restart-monitor.js +11 -4
- package/dist/cli/thread-command.js +47 -18
- package/dist/cli/version.js +18 -18
- package/dist/config/access-policy.js +29 -12
- package/dist/config/boot-log.js +65 -10
- package/dist/config/builtin-roles.js +2 -4
- package/dist/config/config-field-policy.js +3 -0
- package/dist/config/config-manager.js +28 -20
- package/dist/config/{contact-bind-code.js → peer-bind-code.js} +6 -6
- package/dist/config/{contact-book-store.js → peer-book-store.js} +75 -75
- package/dist/config/{contact-book-v2-startup.js → peer-book-v2-startup.js} +2 -2
- package/dist/config/{contact-book.js → peer-book.js} +47 -47
- package/dist/config/peer-operation-service.js +132 -0
- package/dist/config/{contact-request-service.js → peer-request-service.js} +90 -90
- package/dist/config/peer-role-resolver.js +3 -3
- package/dist/config/providers-config.js +17 -8
- package/dist/config/providers.js +1 -1
- package/dist/config/schema-migration.js +336 -39
- package/dist/core/agent-application-service.js +8 -2
- package/dist/core/agent-create-status.js +4 -5
- package/dist/core/agent-ipc-registration.js +5 -4
- package/dist/core/agent-runtime.js +30 -17
- package/dist/core/auth/operation-authorizer.js +0 -24
- package/dist/core/auth/operation-catalog.js +4 -20
- package/dist/core/baseagent-loader.js +27 -3
- package/dist/core/bootstrap-service.js +5 -22
- package/dist/core/capability/capability-manager.js +52 -35
- package/dist/core/channel-loader.js +43 -2
- package/dist/core/channel-runtime.js +2 -2
- package/dist/core/command/agent-control.js +54 -18
- package/dist/core/command/command-handler.js +92 -72
- package/dist/core/command/connect-menu.js +35 -42
- package/dist/core/command/daemon-diagnostics.js +41 -5
- package/dist/core/command/data-root-error.js +10 -0
- package/dist/core/command/data-root-resolver.js +53 -13
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +163 -65
- package/dist/core/command/menu-protocol.js +52 -0
- package/dist/core/command/pa-workspace-calendar.js +223 -0
- package/dist/core/command/pa-workspace-store.js +459 -0
- package/dist/core/command/role-menu.js +2 -2
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +57 -41
- package/dist/core/daemon-lifecycle.js +90 -31
- package/dist/core/evolagent.js +6 -10
- package/dist/core/handoff/runtime.js +11 -4
- package/dist/core/host-snapshot.js +208 -0
- package/dist/core/initialization/service.js +152 -20
- package/dist/core/ipc-registration.js +33 -4
- package/dist/core/memory/batch-meta.js +27 -0
- package/dist/core/memory/consolidation-ops-records.js +44 -1
- package/dist/core/memory/consolidation.js +169 -27
- package/dist/core/message/aun-ipc-sender.js +2 -8
- package/dist/core/message/im-renderer.js +56 -3
- package/dist/core/message/message-admission.js +121 -124
- package/dist/core/message/message-bridge.js +38 -54
- package/dist/core/message/message-queue.js +7 -0
- package/dist/core/message/outbound.js +34 -9
- package/dist/core/message/response-engine.js +154 -73
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +2 -2
- package/dist/core/model/model-catalog.js +5 -4
- package/dist/core/model/model-diagnostics.js +6 -5
- package/dist/core/model/model-fallback.js +3 -6
- package/dist/core/model/model-permission.js +1 -1
- package/dist/core/ownership/owner-resolver.js +9 -9
- package/dist/core/permission/approval-gateway.js +1 -1
- package/dist/core/permission/ec-command-parser.js +2 -2
- package/dist/core/permission/tool-canonical.js +96 -46
- package/dist/core/permission/tool-error-code.js +41 -0
- package/dist/core/permission/tool-policy.js +71 -47
- package/dist/core/role/runtime-policy.js +1 -1
- package/dist/core/session/session-idle-monitor.js +10 -0
- package/dist/core/session/session-manager.js +2 -4
- package/dist/core/session/session-title.js +36 -8
- package/dist/core/system-session/memory.js +2 -7
- package/dist/core/thread/command-parser.js +6 -2
- package/dist/core/thread/ipc-operation.js +51 -36
- package/dist/core/thread/thread-operation.js +29 -61
- package/dist/core/thread/thread-service.js +57 -13
- package/dist/directory/canonical-digest.js +54 -0
- package/dist/directory/owner-directory-admission.js +114 -43
- package/dist/directory/owner-directory-agentmd-sync.js +89 -0
- package/dist/directory/owner-directory-cache.js +847 -459
- package/dist/directory/owner-directory-markdown.js +272 -0
- package/dist/directory/owner-directory-query-operation.js +195 -0
- package/dist/directory/owner-directory-remark-operation.js +147 -0
- package/dist/directory/owner-directory-remarks.js +145 -0
- package/dist/directory/owner-directory-scope.js +55 -0
- package/dist/directory/owner-directory-search.js +148 -0
- package/dist/directory/owner-directory-store.js +227 -0
- package/dist/eck/kit-renderer.js +1 -0
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/message-context-service.js +13 -9
- package/dist/index.js +195 -37
- package/dist/ipc.js +86 -22
- package/dist/paths.js +11 -8
- package/dist/product.js +2 -0
- package/dist/proxy/manager.js +13 -2
- package/dist/proxy/service-supervisor.js +8 -1
- package/dist/trigger/history.js +23 -0
- package/dist/trigger/scheduler.js +3 -0
- package/dist/utils/atomic-write.js +21 -0
- package/dist/utils/cross-platform.js +35 -0
- package/dist/utils/ecweb-supervisor.js +42 -0
- package/dist/utils/error-utils.js +2 -1
- package/dist/utils/evolcore-version.js +19 -0
- package/dist/utils/host-info.js +242 -5
- package/dist/utils/instance-registry.js +28 -6
- package/dist/utils/logger.js +59 -14
- package/dist/utils/machine-info.js +46 -0
- package/dist/utils/process-introspect.js +166 -2
- package/dist/utils/startup-trace.js +245 -0
- package/ecagent/dist/agent-loop.js +27 -13
- package/ecagent/dist/harness/agent-harness.js +3 -3
- package/ecagent/dist/harness/types.d.ts +1 -0
- package/ecagent/dist/types.d.ts +1 -0
- package/kits/docs/INDEX.md +1 -1
- package/kits/docs/aun/AUN/346/266/210/346/201/257/347/261/273/345/236/213/344/270/216/345/261/236/346/200/247.md +72 -0
- package/kits/docs/evolcore/INDEX.md +3 -2
- package/kits/docs/evolcore/agent-create.md +17 -27
- package/kits/docs/evolcore/agent.md +4 -1
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +16 -5
- package/kits/docs/evolcore/ctl.md +9 -0
- package/kits/docs/evolcore/ec-capabilities.md +19 -0
- package/kits/docs/evolcore/memory-consolidation-batches.md +79 -5
- package/kits/docs/evolcore/menu-exec-schema-commands.md +2 -1
- package/kits/docs/evolcore/menu-protocol.md +1 -0
- package/kits/docs/evolcore/model.md +13 -4
- package/kits/docs/evolcore/msg.md +1 -1
- package/kits/docs/evolcore/pa-workspace.md +51 -0
- package/kits/docs/evolcore/peer.md +73 -0
- package/kits/docs/evolcore/thread-chain.md +4 -1
- package/kits/eck_manifest.json +21 -0
- package/kits/rules/06-channel.md +1 -1
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/agent-config.schema.16.json +6 -0
- package/kits/schemas/agent-config.schema.17.json +897 -0
- package/kits/schemas/daemon.schema.9.json +8 -1
- package/kits/skills/ec-agent-create/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +45 -27
- package/kits/skills/ec-service-proxy/SKILL.md +7 -2
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +4 -5
- package/kits/skills/thread-ops/SKILL.md +11 -11
- package/kits/templates/bootstrap-welcome.md +3 -15
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/bootstrap.md +24 -23
- package/kits/templates/system-fragments/commands.md +12 -5
- package/kits/templates/system-fragments/thread.md +18 -3
- package/package.json +6 -4
- package/dist/config/contact-operation-service.js +0 -235
- package/dist/directory/owner-directory-authorization.js +0 -309
- package/kits/docs/evolcore/contact.md +0 -78
- /package/dist/config/{contact-alias.js → peer-alias.js} +0 -0
|
@@ -5,16 +5,9 @@ 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
constructor(code, message, data) {
|
|
12
|
-
super(message);
|
|
13
|
-
this.name = 'DataRootError';
|
|
14
|
-
this.code = code;
|
|
15
|
-
this.data = data;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
8
|
+
import { paWorkspaceStore } from './pa-workspace-store.js';
|
|
9
|
+
import { DataRootError } from './data-root-error.js';
|
|
10
|
+
export { DataRootError } from './data-root-error.js';
|
|
18
11
|
const DEFAULT_ROOT_TTL_MS = 10 * 60 * 1000;
|
|
19
12
|
const TOKEN_PREFIX = 'dr1';
|
|
20
13
|
function base64Url(value) {
|
|
@@ -39,6 +32,7 @@ export class DataRootResolver {
|
|
|
39
32
|
isOwner;
|
|
40
33
|
resolveAgentPath;
|
|
41
34
|
resolveRelationSharedPath;
|
|
35
|
+
paStore;
|
|
42
36
|
constructor(options = {}) {
|
|
43
37
|
this.secret = options.secret ?? crypto.randomBytes(32);
|
|
44
38
|
if (this.secret.length < 32)
|
|
@@ -48,6 +42,7 @@ export class DataRootResolver {
|
|
|
48
42
|
this.isOwner = options.isOwner ?? isStaticAgentOwner;
|
|
49
43
|
this.resolveAgentPath = options.resolveAgentPath ?? agentDir;
|
|
50
44
|
this.resolveRelationSharedPath = options.resolveRelationSharedPath ?? agentRelationSharedDir;
|
|
45
|
+
this.paStore = options.paStore ?? paWorkspaceStore;
|
|
51
46
|
}
|
|
52
47
|
issueAgentRoot(subject) {
|
|
53
48
|
const targetAid = this.targetAid(subject);
|
|
@@ -80,6 +75,19 @@ export class DataRootResolver {
|
|
|
80
75
|
const rootPath = this.canonicalRoot(this.resolveRelationSharedPath(targetAid, peerKey), agentRoot);
|
|
81
76
|
return this.issueDescriptor({ scope: 'relation', targetAid, principalId, peerAid, peerKey }, rootPath);
|
|
82
77
|
}
|
|
78
|
+
issuePaWorkspaceRoot(subject) {
|
|
79
|
+
const targetAid = this.targetAid(subject);
|
|
80
|
+
this.assertPrivateAun(subject);
|
|
81
|
+
const principalId = authenticatedPrincipal(subject);
|
|
82
|
+
if (subject.role !== 'owner' || !this.isOwner(targetAid, principalId)) {
|
|
83
|
+
throw new DataRootError('ROOT_FORBIDDEN', 'PA workspace root requires Agent owner permission');
|
|
84
|
+
}
|
|
85
|
+
const state = this.paStore.require(targetAid);
|
|
86
|
+
if (state.ownerAid !== principalId) {
|
|
87
|
+
throw new DataRootError('ROOT_FORBIDDEN', 'PA workspace is bound to another owner');
|
|
88
|
+
}
|
|
89
|
+
return this.issueDescriptor({ scope: 'pa', targetAid, principalId, workspaceId: state.workspaceId }, this.paStore.root(state));
|
|
90
|
+
}
|
|
83
91
|
resolveRoot(rootId, subject) {
|
|
84
92
|
const claims = this.verifyToken(rootId);
|
|
85
93
|
const targetAid = this.targetAid(subject);
|
|
@@ -91,13 +99,14 @@ export class DataRootResolver {
|
|
|
91
99
|
throw new DataRootError('ROOT_FORBIDDEN', 'Root was issued to another authenticated principal');
|
|
92
100
|
}
|
|
93
101
|
let rootPath;
|
|
102
|
+
let workspaceState;
|
|
94
103
|
if (claims.scope === 'agent') {
|
|
95
104
|
if (subject.role !== 'owner' || !this.isOwner(targetAid, principalId)) {
|
|
96
105
|
throw new DataRootError('ROOT_FORBIDDEN', 'Agent data root requires Agent owner permission');
|
|
97
106
|
}
|
|
98
107
|
rootPath = this.canonicalRoot(this.resolveAgentPath(targetAid), undefined);
|
|
99
108
|
}
|
|
100
|
-
else {
|
|
109
|
+
else if (claims.scope === 'relation') {
|
|
101
110
|
this.assertPrivateAun(subject);
|
|
102
111
|
if (!claims.peerAid || !claims.peerKey || claims.peerKey !== formatPeerKey('aun', claims.peerAid)) {
|
|
103
112
|
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'Relation root claims are invalid');
|
|
@@ -109,6 +118,19 @@ export class DataRootResolver {
|
|
|
109
118
|
const agentRoot = this.canonicalRoot(this.resolveAgentPath(targetAid), undefined);
|
|
110
119
|
rootPath = this.canonicalRoot(this.resolveRelationSharedPath(targetAid, claims.peerKey), agentRoot);
|
|
111
120
|
}
|
|
121
|
+
else {
|
|
122
|
+
this.assertPrivateAun(subject);
|
|
123
|
+
if (!claims.workspaceId)
|
|
124
|
+
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'PA workspace root claims are invalid');
|
|
125
|
+
if (subject.role !== 'owner' || !this.isOwner(targetAid, principalId)) {
|
|
126
|
+
throw new DataRootError('ROOT_FORBIDDEN', 'PA workspace root requires Agent owner permission');
|
|
127
|
+
}
|
|
128
|
+
workspaceState = this.paStore.require(targetAid);
|
|
129
|
+
if (workspaceState.ownerAid !== principalId || workspaceState.workspaceId !== claims.workspaceId) {
|
|
130
|
+
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'PA workspace binding changed; request a new root');
|
|
131
|
+
}
|
|
132
|
+
rootPath = this.paStore.root(workspaceState);
|
|
133
|
+
}
|
|
112
134
|
const revision = this.rootRevision(rootPath);
|
|
113
135
|
if (revision !== claims.revision) {
|
|
114
136
|
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'Root identity changed; request a new root');
|
|
@@ -118,6 +140,7 @@ export class DataRootResolver {
|
|
|
118
140
|
targetAid,
|
|
119
141
|
...(claims.peerAid ? { peerAid: claims.peerAid } : {}),
|
|
120
142
|
...(claims.peerKey ? { peerKey: claims.peerKey } : {}),
|
|
143
|
+
...(claims.workspaceId ? { workspaceId: claims.workspaceId } : {}),
|
|
121
144
|
rootPath,
|
|
122
145
|
revision,
|
|
123
146
|
expiresAt: claims.expiresAt,
|
|
@@ -126,6 +149,19 @@ export class DataRootResolver {
|
|
|
126
149
|
resolvePath(rootId, subject, input, expectType) {
|
|
127
150
|
const root = this.resolveRoot(rootId, subject);
|
|
128
151
|
const raw = String(input ?? '').trim();
|
|
152
|
+
if (root.scope === 'pa') {
|
|
153
|
+
const state = this.paStore.require(root.targetAid);
|
|
154
|
+
if (state.workspaceId !== root.workspaceId)
|
|
155
|
+
throw new DataRootError('ROOT_SCOPE_MISMATCH', 'PA workspace binding changed; request a new root');
|
|
156
|
+
const resolved = this.paStore.resolvePath(state, raw);
|
|
157
|
+
if (expectType === 'file' && !resolved.stat.isFile()) {
|
|
158
|
+
throw new DataRootError('NOT_SUPPORTED', 'Path is not a regular file');
|
|
159
|
+
}
|
|
160
|
+
if (expectType === 'directory' && !resolved.stat.isDirectory()) {
|
|
161
|
+
throw new DataRootError('NOT_A_DIRECTORY', 'Path is not a directory');
|
|
162
|
+
}
|
|
163
|
+
return { ...root, ...resolved };
|
|
164
|
+
}
|
|
129
165
|
if (!raw)
|
|
130
166
|
throw new DataRootError('INVALID_ROOT_PATH', 'A root-relative path is required');
|
|
131
167
|
if (raw.includes('\0'))
|
|
@@ -177,9 +213,12 @@ export class DataRootResolver {
|
|
|
177
213
|
targetAid: claims.targetAid,
|
|
178
214
|
...(claims.peerAid ? { peerAid: claims.peerAid } : {}),
|
|
179
215
|
...(claims.peerKey ? { peerKey: claims.peerKey } : {}),
|
|
216
|
+
...(claims.workspaceId ? { workspaceId: claims.workspaceId } : {}),
|
|
180
217
|
virtualPath: claims.scope === 'agent'
|
|
181
218
|
? '$AGENTS_DIR/<targetAid>'
|
|
182
|
-
: '
|
|
219
|
+
: claims.scope === 'relation'
|
|
220
|
+
? '$AGENTS_DIR/<targetAid>/relations/<peerKey>/shared'
|
|
221
|
+
: '$PA_WORKSPACE/<workspaceId>',
|
|
183
222
|
revision: `sha256:${claims.revision}`,
|
|
184
223
|
expiresAt: claims.expiresAt,
|
|
185
224
|
readOnly: true,
|
|
@@ -218,10 +257,11 @@ export class DataRootResolver {
|
|
|
218
257
|
throw new DataRootError('INVALID_ROOT_ID', 'Invalid data rootId payload');
|
|
219
258
|
}
|
|
220
259
|
if (claims.v !== 1
|
|
221
|
-
|| (claims.scope !== 'agent' && claims.scope !== 'relation')
|
|
260
|
+
|| (claims.scope !== 'agent' && claims.scope !== 'relation' && claims.scope !== 'pa')
|
|
222
261
|
|| typeof claims.targetAid !== 'string'
|
|
223
262
|
|| typeof claims.principalId !== 'string'
|
|
224
263
|
|| typeof claims.revision !== 'string'
|
|
264
|
+
|| (claims.scope === 'pa' && typeof claims.workspaceId !== 'string')
|
|
225
265
|
|| !Number.isFinite(claims.expiresAt)) {
|
|
226
266
|
throw new DataRootError('INVALID_ROOT_ID', 'Invalid data rootId claims');
|
|
227
267
|
}
|
|
@@ -117,6 +117,7 @@ const ENTRIES = [
|
|
|
117
117
|
{ id: 'baseagents.inventory', type: 'list', contexts: ['process'], name: 'baseagents', label: 'Base Agent 清单', section: 'process', order: 9, query: { cmd: '/baseagents', operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
118
118
|
{ id: 'system.status', type: 'list', contexts: ['process'], name: 'system', label: '系统状态', section: 'process', order: 10, query: { cmd: '/system', operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
119
119
|
{ id: 'system.monitor', type: 'list', contexts: ['process'], name: 'system', label: '运行监控快照', section: 'process', order: 11, query: { cmd: '/system', args: { view: 'monitor' }, operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
120
|
+
{ id: 'system.host', type: 'list', contexts: ['process'], name: 'system', label: '主机信息', section: 'process', order: 11.5, query: { cmd: '/system', args: { view: 'host' }, operation: 'system.status', scope: 'process' }, control: 'list' },
|
|
120
121
|
{ id: 'system.logs', type: 'list', contexts: ['process'], name: 'system', label: 'Daemon 日志', section: 'process', order: 12, query: { cmd: '/system', args: { view: 'logs' }, operation: 'system.status', scope: 'process' }, options: { cmd: '/system', args: { option: 'logs' }, operation: 'system.status', scope: 'process', mode: 'dynamic' }, control: 'list' },
|
|
121
122
|
{ id: 'config.rawFile', type: 'list', contexts: ['process'], name: 'config', label: '原始配置文件', section: 'process', order: 13, query: { cmd: '/config', args: { view: 'rawFile' }, operation: 'config.read', scope: 'process' }, options: { cmd: '/config', args: { option: 'rawFile' }, operation: 'config.read', scope: 'process', mode: 'dynamic' }, control: 'list' },
|
|
122
123
|
{ id: 'system.restart', type: 'action', contexts: ['process'], name: 'system', label: '重启服务', section: 'process', order: 20, action: { cmd: '/system', action: 'restart', operation: 'system.restart', scope: 'process' } },
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { memoryHelpEntries } from './memory-slash.js';
|
|
2
2
|
import { executeProviderMenu } from './provider-menu.js';
|
|
3
3
|
import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent-availability.js';
|
|
4
|
+
import { resolveBaseagentModelSelection } from '../../agents/baseagent.js';
|
|
4
5
|
import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
|
|
5
6
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
6
7
|
import { modelMatches, getCatalog, getBaseagentCatalog, resolveCatalogModel, assertCatalogSelectable, CONFIGURABLE_EFFORTS, configurableEfforts } from '../model/model-catalog.js';
|
|
@@ -63,6 +64,8 @@ import { groupMenuAuthorizationArgs, groupMenuIntent, handleGroupMenu, } from '.
|
|
|
63
64
|
import { getMenuCatalog, execMenuValueBatch, resolveExplicitMenuExecutionContext, resolveMenuCatalogContext, validateMenuCatalogArgs, validateMenuValueBatchArgs } from './menu-catalog.js';
|
|
64
65
|
import { probeSessionActivity } from './slash-gate.js';
|
|
65
66
|
import { dataRootFailure, dataRootResolver } from './data-root-resolver.js';
|
|
67
|
+
import { isPaHiddenPath, paWorkspaceStore, readPaWorkspaceNavigation } from './pa-workspace-store.js';
|
|
68
|
+
import { queryPaWorkspaceCalendar } from './pa-workspace-calendar.js';
|
|
66
69
|
import { agentStorageMenuService, isAgentStorageMenuRequest } from './agent-storage-menu.js';
|
|
67
70
|
import { MAX_AUN_ATTACHMENT_SIZE } from '../../aun/msg/upload.js';
|
|
68
71
|
import { normalizeTopicLabel, normalizeTopicStatus, resolveTopicArchiveFilter, } from '../session/session-mapper.js';
|
|
@@ -345,9 +348,24 @@ function listDirectory(realPath, options) {
|
|
|
345
348
|
const code = e?.code === 'EACCES' || e?.code === 'EPERM' ? 'NO_PERMISSION' : 'EXEC_FAILED';
|
|
346
349
|
return { error: `目录读取失败: ${e?.message ?? e}`, code };
|
|
347
350
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
dirents = dirents.filter(d => {
|
|
352
|
+
if (!includeHidden && d.name.startsWith('.'))
|
|
353
|
+
return false;
|
|
354
|
+
if (options.paWorkspace && isPaHiddenPath(path.relative(projectPath, path.join(realPath, d.name)).split(path.sep).join('/')))
|
|
355
|
+
return false;
|
|
356
|
+
if (options.paWorkspace && d.isSymbolicLink()) {
|
|
357
|
+
try {
|
|
358
|
+
const target = fs.realpathSync(path.join(realPath, d.name));
|
|
359
|
+
const relative = path.relative(projectPath, target).split(path.sep).join('/');
|
|
360
|
+
if (!isInProject(target, projectPath) || isPaHiddenPath(relative))
|
|
361
|
+
return false;
|
|
362
|
+
}
|
|
363
|
+
catch {
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return true;
|
|
368
|
+
});
|
|
351
369
|
const entryInfoByName = new Map();
|
|
352
370
|
for (const dirent of dirents) {
|
|
353
371
|
entryInfoByName.set(dirent.name, getDirectoryEntryInfo(realPath, projectPath, role, dirent));
|
|
@@ -772,21 +790,28 @@ function resolveMenuModelTarget(params) {
|
|
|
772
790
|
return { error: '缺少 baseagent 参数', code: 'MISSING_BASEAGENT' };
|
|
773
791
|
return { scope, sel: { self }, role: params.role, baseagent, field: params.field, fieldPath: `baseagents.${baseagent}.${params.field}` };
|
|
774
792
|
}
|
|
775
|
-
/**
|
|
793
|
+
/** Read the effective selection, including local/runner fallback and role policy. */
|
|
776
794
|
function readMenuModel(target, _agent, _agentSessionId) {
|
|
777
795
|
try {
|
|
778
796
|
const fieldPath = menuModelConfigFieldPath(target);
|
|
779
797
|
const resolved = resolveEffectiveFieldWithSource(fieldPath, target.sel, { cache: true });
|
|
798
|
+
const effective = resolveBaseagentModelSelection(target.baseagent, resolveEffective(target.sel, { cache: true }).baseagents?.[target.baseagent]);
|
|
780
799
|
if (target.field === 'model') {
|
|
781
800
|
const decision = constrainResolvedModelForRole({
|
|
782
801
|
selfAid: target.sel.self,
|
|
783
802
|
role: target.role,
|
|
784
803
|
baseagent: target.baseagent,
|
|
785
|
-
model: resolved.value,
|
|
804
|
+
model: effective?.model ?? resolved.value,
|
|
786
805
|
resolveModelId: typeof _agent?.resolveModelId === 'function' ? _agent.resolveModelId.bind(_agent) : undefined,
|
|
787
806
|
});
|
|
788
807
|
if (decision.model) {
|
|
789
|
-
return {
|
|
808
|
+
return {
|
|
809
|
+
value: decision.model,
|
|
810
|
+
source: decision.constrained ? 'role'
|
|
811
|
+
: effective?.modelSource === 'configured' ? toMenuSource(resolved.source)
|
|
812
|
+
: effective?.modelSource === 'cli' ? 'native'
|
|
813
|
+
: effective?.modelSource === 'runner' ? 'runner' : null,
|
|
814
|
+
};
|
|
790
815
|
}
|
|
791
816
|
}
|
|
792
817
|
else {
|
|
@@ -794,12 +819,14 @@ function readMenuModel(target, _agent, _agentSessionId) {
|
|
|
794
819
|
selfAid: target.sel.self,
|
|
795
820
|
role: target.role,
|
|
796
821
|
field: fieldPath,
|
|
797
|
-
configuredValue: resolved.value,
|
|
822
|
+
configuredValue: resolved.value ?? effective?.effort,
|
|
798
823
|
});
|
|
799
824
|
if (decision.effectiveValue) {
|
|
800
825
|
return {
|
|
801
826
|
value: decision.effectiveValue,
|
|
802
|
-
source: decision.decidedBy === 'role' ? 'role'
|
|
827
|
+
source: decision.decidedBy === 'role' ? 'role'
|
|
828
|
+
: effective?.effortSource === 'configured' ? toMenuSource(resolved.source)
|
|
829
|
+
: effective?.effortSource === 'cli' ? 'native' : null,
|
|
803
830
|
};
|
|
804
831
|
}
|
|
805
832
|
}
|
|
@@ -1753,11 +1780,12 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
|
|
|
1753
1780
|
lifecycle: ag.lifecycle ?? null,
|
|
1754
1781
|
baseagent: ag.baseagent ?? null,
|
|
1755
1782
|
projectPath: ag.projectPath ?? null,
|
|
1756
|
-
...(ag.mode === 'one_shot' ? {
|
|
1757
|
-
mode: ag.mode,
|
|
1783
|
+
...(ag.mode === 'one_shot' || ag.initialization?.code === 'INITIALIZE_STATE_INVALID' ? {
|
|
1784
|
+
...(ag.mode === 'one_shot' ? { mode: ag.mode } : {}),
|
|
1758
1785
|
initialization: ag.initialization,
|
|
1759
|
-
createProgress: ag.createProgress,
|
|
1760
|
-
ownership: ag.ownership,
|
|
1786
|
+
...(ag.createProgress ? { createProgress: ag.createProgress } : {}),
|
|
1787
|
+
...(ag.ownership ? { ownership: ag.ownership } : {}),
|
|
1788
|
+
...(ag.usable !== undefined ? { usable: ag.usable } : {}),
|
|
1761
1789
|
} : {}),
|
|
1762
1790
|
}));
|
|
1763
1791
|
}
|
|
@@ -2173,6 +2201,73 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2173
2201
|
return dataRootFailure(error);
|
|
2174
2202
|
}
|
|
2175
2203
|
}
|
|
2204
|
+
if (cmdBase === '/pa-workspace') {
|
|
2205
|
+
const allowed = new Set(['view', 'protocolVersion', 'context', 'from', 'to', 'timezone']);
|
|
2206
|
+
const unknown = Object.keys(args ?? {}).find(key => !allowed.has(key));
|
|
2207
|
+
if (unknown)
|
|
2208
|
+
return { error: `pa-workspace does not accept args.${unknown}`, code: 'INVALID_ARGUMENT' };
|
|
2209
|
+
if (args?.view !== 'navigation' && args?.view !== 'calendar')
|
|
2210
|
+
return { error: 'pa-workspace requires args.view="navigation" or "calendar"', code: 'INVALID_ARGUMENT' };
|
|
2211
|
+
if (args?.protocolVersion !== undefined && args.protocolVersion !== 1) {
|
|
2212
|
+
return { error: 'Unsupported PA workspace protocol version', code: 'SCHEMA_VERSION_UNSUPPORTED' };
|
|
2213
|
+
}
|
|
2214
|
+
if (args.view !== 'calendar' && (args.from !== undefined || args.to !== undefined || args.timezone !== undefined)) {
|
|
2215
|
+
return { error: 'from, to and timezone are only valid for calendar view', code: 'INVALID_ARGUMENT' };
|
|
2216
|
+
}
|
|
2217
|
+
try {
|
|
2218
|
+
const root = dataRootResolver.issuePaWorkspaceRoot(subject);
|
|
2219
|
+
const navigation = readPaWorkspaceNavigation(root.targetAid);
|
|
2220
|
+
if (args.view === 'calendar') {
|
|
2221
|
+
const scheduler = this.getTriggerSchedulerForChannel?.(channel);
|
|
2222
|
+
const isAdmin = isManagementRole(identity.role)
|
|
2223
|
+
|| subject.isDaemonOwner
|
|
2224
|
+
|| subject.processRole === 'daemon-service';
|
|
2225
|
+
const visibleDefinitions = scheduler
|
|
2226
|
+
?.list({ all: true })
|
|
2227
|
+
.filter((definition) => this.canAccessTriggerDefinition(definition, userId ?? '', channel, isAdmin));
|
|
2228
|
+
return {
|
|
2229
|
+
data: {
|
|
2230
|
+
...queryPaWorkspaceCalendar({
|
|
2231
|
+
state: paWorkspaceStore.require(root.targetAid),
|
|
2232
|
+
navigation,
|
|
2233
|
+
scheduler: scheduler && visibleDefinitions
|
|
2234
|
+
? {
|
|
2235
|
+
list: () => visibleDefinitions,
|
|
2236
|
+
listItems: definitions => scheduler.listItems(definitions),
|
|
2237
|
+
recentRuns: (triggerId, limit) => scheduler.recentRuns(triggerId, limit),
|
|
2238
|
+
}
|
|
2239
|
+
: undefined,
|
|
2240
|
+
args,
|
|
2241
|
+
}),
|
|
2242
|
+
workspaceId: navigation.workspaceId,
|
|
2243
|
+
fileRoot: {
|
|
2244
|
+
rootId: root.rootId,
|
|
2245
|
+
expiresAt: root.expiresAt,
|
|
2246
|
+
capabilities: root.capabilities,
|
|
2247
|
+
},
|
|
2248
|
+
},
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
return {
|
|
2252
|
+
data: {
|
|
2253
|
+
protocol: 'evol.pa-workspace',
|
|
2254
|
+
protocolVersion: 1,
|
|
2255
|
+
workspaceId: navigation.workspaceId,
|
|
2256
|
+
navigationRevision: navigation.navigationRevision,
|
|
2257
|
+
title: navigation.title,
|
|
2258
|
+
entries: navigation.entries,
|
|
2259
|
+
fileRoot: {
|
|
2260
|
+
rootId: root.rootId,
|
|
2261
|
+
expiresAt: root.expiresAt,
|
|
2262
|
+
capabilities: root.capabilities,
|
|
2263
|
+
},
|
|
2264
|
+
},
|
|
2265
|
+
};
|
|
2266
|
+
}
|
|
2267
|
+
catch (error) {
|
|
2268
|
+
return dataRootFailure(error);
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2176
2271
|
if (isRequesterRoleQuery) {
|
|
2177
2272
|
if (!subject.allowAccess) {
|
|
2178
2273
|
return { error: `Role ${subject.role} is not allowed to access this agent`, code: 'ROLE_ACCESS_DENIED' };
|
|
@@ -2465,8 +2560,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2465
2560
|
}
|
|
2466
2561
|
const sessionKey = this.getQueueKey(session, channel, channelId);
|
|
2467
2562
|
const sessionAgent = this.getAgent(channel, session.baseagent);
|
|
2468
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent.hasActiveStream(sessionKey)
|
|
2563
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent.hasActiveStream(sessionKey)
|
|
2564
|
+
|| sessionAgent.hasActiveOperation?.(sessionKey) === true;
|
|
2469
2565
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2566
|
+
const executionState = sessionAgent.getExecutionState?.(sessionKey);
|
|
2470
2567
|
const health = await this.sessionManager.getHealthStatus(session.id);
|
|
2471
2568
|
let processingDuration;
|
|
2472
2569
|
if (isProcessing && session.processingState) {
|
|
@@ -2482,7 +2579,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2482
2579
|
const data = {
|
|
2483
2580
|
name: session.name || null,
|
|
2484
2581
|
agentSessionId: session.agentSessionId || null,
|
|
2485
|
-
status: isProcessing ? 'processing' : 'idle',
|
|
2582
|
+
status: executionState === 'interrupting' ? 'interrupting' : isProcessing || queueLength > 0 ? 'processing' : 'idle',
|
|
2486
2583
|
createdAt: session.createdAt,
|
|
2487
2584
|
updatedAt: session.updatedAt,
|
|
2488
2585
|
subtasks: this.sessionManager.getRunnerTaskHistory(session.id).length,
|
|
@@ -2592,8 +2689,10 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2592
2689
|
}
|
|
2593
2690
|
const sessionKey = this.getQueueKey(topic, channel, channelId);
|
|
2594
2691
|
const sessionAgent = this.getAgent(channel, topic.baseagent);
|
|
2595
|
-
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent.hasActiveStream(sessionKey)
|
|
2692
|
+
const isProcessing = this.messageQueue.isProcessing(sessionKey) || sessionAgent.hasActiveStream(sessionKey)
|
|
2693
|
+
|| sessionAgent.hasActiveOperation?.(sessionKey) === true;
|
|
2596
2694
|
const queueLength = this.messageQueue.getQueueLength(sessionKey);
|
|
2695
|
+
const executionState = sessionAgent.getExecutionState?.(sessionKey);
|
|
2597
2696
|
const health = await this.sessionManager.getHealthStatus(topic.id);
|
|
2598
2697
|
let processingDuration;
|
|
2599
2698
|
if (isProcessing && topic.processingState) {
|
|
@@ -2611,7 +2710,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2611
2710
|
label: topic.label || null,
|
|
2612
2711
|
topicStatus: topic.topicStatus ?? 'pending',
|
|
2613
2712
|
agentSessionId: topic.agentSessionId || null,
|
|
2614
|
-
status: isProcessing ? 'processing' : 'idle',
|
|
2713
|
+
status: executionState === 'interrupting' ? 'interrupting' : isProcessing || queueLength > 0 ? 'processing' : 'idle',
|
|
2615
2714
|
createdAt: topic.createdAt,
|
|
2616
2715
|
updatedAt: topic.updatedAt,
|
|
2617
2716
|
subtasks: this.sessionManager.getRunnerTaskHistory(topic.id).length,
|
|
@@ -2830,23 +2929,14 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2830
2929
|
if (cmdBase === '/system') {
|
|
2831
2930
|
const view = args?.view ?? 'status';
|
|
2832
2931
|
if (view === 'version') {
|
|
2833
|
-
const
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
try {
|
|
2842
|
-
const fp = path.join(getPackageRoot(), 'node_modules', '@agentunion', 'fastaun', 'package.json');
|
|
2843
|
-
const fp2 = JSON.parse(fs.readFileSync(fp, 'utf-8'));
|
|
2844
|
-
if (fp2?.version)
|
|
2845
|
-
data.fastaunVersion = fp2.version;
|
|
2846
|
-
}
|
|
2847
|
-
catch { }
|
|
2848
|
-
data.avatarCreateSupported = true;
|
|
2849
|
-
data.agentCreate = agentCreateCapabilities();
|
|
2932
|
+
const { readVersionInfo } = await import('../../utils/machine-info.js');
|
|
2933
|
+
const versions = readVersionInfo();
|
|
2934
|
+
const data = {
|
|
2935
|
+
version: versions.evolcore,
|
|
2936
|
+
fastaunVersion: versions.fastaun,
|
|
2937
|
+
avatarCreateSupported: true,
|
|
2938
|
+
agentCreate: agentCreateCapabilities(),
|
|
2939
|
+
};
|
|
2850
2940
|
return { data };
|
|
2851
2941
|
}
|
|
2852
2942
|
if (view === 'monitor') {
|
|
@@ -2855,6 +2945,12 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2855
2945
|
}
|
|
2856
2946
|
return { data: await this.daemonMonitorProvider() };
|
|
2857
2947
|
}
|
|
2948
|
+
if (view === 'host') {
|
|
2949
|
+
if (typeof this.daemonHostProvider !== 'function') {
|
|
2950
|
+
return { error: 'Daemon host snapshot is unavailable', code: 'DEPENDENCY_UNAVAILABLE' };
|
|
2951
|
+
}
|
|
2952
|
+
return { data: await this.daemonHostProvider() };
|
|
2953
|
+
}
|
|
2858
2954
|
if (view === 'logs') {
|
|
2859
2955
|
try {
|
|
2860
2956
|
return { data: queryDiagnosticLogs(args ?? {}, subject.actorId ?? '') };
|
|
@@ -2865,6 +2961,8 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2865
2961
|
}
|
|
2866
2962
|
if (view !== 'status')
|
|
2867
2963
|
return { error: `Unsupported system view: ${String(view)}`, code: 'NOT_SUPPORTED' };
|
|
2964
|
+
const { readVersionInfo } = await import('../../utils/machine-info.js');
|
|
2965
|
+
const versions = readVersionInfo();
|
|
2868
2966
|
const data = {
|
|
2869
2967
|
aid: loadDaemonConfig().aid ?? null,
|
|
2870
2968
|
pid: process.pid,
|
|
@@ -2873,21 +2971,9 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
|
|
|
2873
2971
|
platform: process.platform,
|
|
2874
2972
|
arch: process.arch,
|
|
2875
2973
|
uptime: Math.floor(process.uptime()),
|
|
2974
|
+
version: versions.evolcore,
|
|
2975
|
+
fastaunVersion: versions.fastaun,
|
|
2876
2976
|
};
|
|
2877
|
-
try {
|
|
2878
|
-
const pkgPath = path.join(getPackageRoot(), 'package.json');
|
|
2879
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
2880
|
-
if (pkg?.version)
|
|
2881
|
-
data.version = pkg.version;
|
|
2882
|
-
}
|
|
2883
|
-
catch { }
|
|
2884
|
-
try {
|
|
2885
|
-
const fp = path.join(getPackageRoot(), 'node_modules', '@agentunion', 'fastaun', 'package.json');
|
|
2886
|
-
const fp2 = JSON.parse(fs.readFileSync(fp, 'utf-8'));
|
|
2887
|
-
if (fp2?.version)
|
|
2888
|
-
data.fastaunVersion = fp2.version;
|
|
2889
|
-
}
|
|
2890
|
-
catch { }
|
|
2891
2977
|
// ecweb 是独立全局包,读其已装版本(与 /upgrade 一致)
|
|
2892
2978
|
const ecwebPkg = resolveGlobalPkg(WEB_PACKAGE_NAME);
|
|
2893
2979
|
if (ecwebPkg?.version)
|
|
@@ -4289,30 +4375,29 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4289
4375
|
return { error: `名称 "${newName}" 已存在`, code: 'CONFLICT' };
|
|
4290
4376
|
}
|
|
4291
4377
|
const oldName = displaySessionTitle(topic.name, sessionTopicThreadId(topic) || '(未命名)');
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
// P1a.5.3: 若为话题会话,同步更新话题索引
|
|
4303
|
-
const renamedTopicThreadId = sessionTopicThreadId(topic);
|
|
4304
|
-
if (renamedTopicThreadId) {
|
|
4378
|
+
// P1a.5.3: 同步话题索引并向对端发 `topic.renamed`。
|
|
4379
|
+
// 主话题同样走这条出口:它不进索引(由会话文件产生),renameThread 只把名字
|
|
4380
|
+
// 落到会话上;通知里的 threadId 由 notifyThreadRename 规范成 `main:<a>:<b>`
|
|
4381
|
+
// 再上线——直接发空串对端会整条丢弃(见 applyInboundTopicRename 的非空校验)。
|
|
4382
|
+
//
|
|
4383
|
+
// 必须**先**跑:renameThread 发现名字已经是目标值会返回 changed=false,
|
|
4384
|
+
// `notifyThreadRename` 据此跳过发送,改名就静默不同步了。它自己会落 session,
|
|
4385
|
+
// 所以下面那段 `renameSession` 只在同步失败时兜底。
|
|
4386
|
+
let renamedByThreadService = false;
|
|
4387
|
+
{
|
|
4305
4388
|
try {
|
|
4306
4389
|
const { ThreadService } = await import('../../core/thread/index.js');
|
|
4307
4390
|
const selfAid = topic.selfAID;
|
|
4308
4391
|
const peer = topic.channelId;
|
|
4309
4392
|
if (selfAid && peer) {
|
|
4310
4393
|
const svc = new ThreadService(this.sessionManager);
|
|
4311
|
-
const
|
|
4394
|
+
const renameThreadId = sessionTopicThreadId(topic) ?? '';
|
|
4395
|
+
const result = await svc.renameThread({ selfAid, peer, threadId: renameThreadId, name: newName });
|
|
4396
|
+
renamedByThreadService = result.changed || result.name === newName;
|
|
4312
4397
|
await notifyThreadRename({
|
|
4313
4398
|
selfAid,
|
|
4314
4399
|
peer,
|
|
4315
|
-
threadId:
|
|
4400
|
+
threadId: renameThreadId,
|
|
4316
4401
|
result,
|
|
4317
4402
|
threadService: svc,
|
|
4318
4403
|
sendSystemMsg: (topic.channelType || channel.split('#', 1)[0]) === 'aun'
|
|
@@ -4322,9 +4407,21 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4322
4407
|
}
|
|
4323
4408
|
}
|
|
4324
4409
|
catch (err) {
|
|
4325
|
-
logger.debug('[MenuHandler] Thread
|
|
4410
|
+
logger.debug('[MenuHandler] Thread rename sync failed:', err);
|
|
4326
4411
|
}
|
|
4327
4412
|
}
|
|
4413
|
+
if (!renamedByThreadService) {
|
|
4414
|
+
const success = await this.sessionManager.renameSession(topic.id, newName);
|
|
4415
|
+
if (!success)
|
|
4416
|
+
return { error: '重命名失败', code: 'EXEC_FAILED' };
|
|
4417
|
+
}
|
|
4418
|
+
if (topic.agentSessionId) {
|
|
4419
|
+
try {
|
|
4420
|
+
const targetAgent = this.getAgent(channel, topic.baseagent);
|
|
4421
|
+
await targetAgent.setSessionName?.(topic.agentSessionId, newName);
|
|
4422
|
+
}
|
|
4423
|
+
catch { }
|
|
4424
|
+
}
|
|
4328
4425
|
this.eventBus.publish({ type: 'session:renamed', sessionId: topic.id, oldName, newName });
|
|
4329
4426
|
return {
|
|
4330
4427
|
data: {
|
|
@@ -4827,6 +4924,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
|
|
|
4827
4924
|
includeHidden,
|
|
4828
4925
|
projectPath: resolved.rootPath,
|
|
4829
4926
|
role: undefined,
|
|
4927
|
+
paWorkspace: resolved.scope === 'pa',
|
|
4830
4928
|
});
|
|
4831
4929
|
responsePath = resolved.relativePath;
|
|
4832
4930
|
dataRoot = resolved;
|
|
@@ -5015,9 +5113,9 @@ async function execMenuForSystemControl(payload, context) {
|
|
|
5015
5113
|
const isRoleRequest = name === 'role' || compatCmd === '/role';
|
|
5016
5114
|
const isConnectRequest = name === 'connect' || compatCmd === '/connect';
|
|
5017
5115
|
const requiresAgentTarget = isRoleRequest || isConnectRequest || [
|
|
5018
|
-
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid',
|
|
5116
|
+
'observable', 'baseagent', 'model', 'effort', 'trigger', 'capability', 'group', 'aid', 'pa-workspace',
|
|
5019
5117
|
].includes(name)
|
|
5020
|
-
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid'].includes(compatCmd ?? '')
|
|
5118
|
+
|| ['/observable', '/baseagent', '/model', '/effort', '/trigger', '/capability', '/group', '/aid', '/pa-workspace'].includes(compatCmd ?? '')
|
|
5021
5119
|
|| (!isProcessLevel && requestedContextKind !== undefined && requestedContextKind !== 'process');
|
|
5022
5120
|
const target = isProcessLevel
|
|
5023
5121
|
? { channel: SYSTEM_CONTROL_CHANNEL }
|
|
@@ -148,6 +148,7 @@ export const MENU_NAME_COMMANDS = Object.freeze({
|
|
|
148
148
|
file: '/file',
|
|
149
149
|
'agent-data-root': '/agent-data-root',
|
|
150
150
|
'relation-data-root': '/relation-data-root',
|
|
151
|
+
'pa-workspace': '/pa-workspace',
|
|
151
152
|
'agent-storage-root': '/agent-storage-root',
|
|
152
153
|
storage: '/storage',
|
|
153
154
|
gateway: '/gateway',
|
|
@@ -346,6 +347,54 @@ export function validateMenuRequest(request) {
|
|
|
346
347
|
if (taskError)
|
|
347
348
|
return taskError;
|
|
348
349
|
}
|
|
350
|
+
if (request.name === 'pa-workspace' || firstCommandToken(request.cmd) === '/pa-workspace') {
|
|
351
|
+
if (type !== 'menu.query')
|
|
352
|
+
return { code: 'NOT_SUPPORTED', message: 'pa-workspace only supports menu.query' };
|
|
353
|
+
const args = request.args;
|
|
354
|
+
const unknown = Object.keys(args ?? {}).find(key => !['view', 'protocolVersion', 'context', 'from', 'to', 'timezone'].includes(key));
|
|
355
|
+
if (unknown)
|
|
356
|
+
return { code: 'INVALID_ARGUMENT', message: `pa-workspace does not accept args.${unknown}` };
|
|
357
|
+
if (args?.view !== 'navigation' && args?.view !== 'calendar')
|
|
358
|
+
return { code: 'INVALID_ARGUMENT', message: 'pa-workspace requires args.view="navigation" or "calendar"' };
|
|
359
|
+
if (args?.view !== 'calendar' && (args?.from !== undefined || args?.to !== undefined || args?.timezone !== undefined)) {
|
|
360
|
+
return { code: 'INVALID_ARGUMENT', message: 'from, to and timezone are only valid for calendar view' };
|
|
361
|
+
}
|
|
362
|
+
if (args?.view === 'calendar') {
|
|
363
|
+
const parseDate = (value) => {
|
|
364
|
+
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(value))
|
|
365
|
+
return null;
|
|
366
|
+
const timestamp = Date.parse(`${value}T00:00:00Z`);
|
|
367
|
+
return Number.isFinite(timestamp) && new Date(timestamp).toISOString().slice(0, 10) === value
|
|
368
|
+
? timestamp
|
|
369
|
+
: null;
|
|
370
|
+
};
|
|
371
|
+
const from = args.from === undefined ? undefined : parseDate(args.from);
|
|
372
|
+
const to = args.to === undefined ? undefined : parseDate(args.to);
|
|
373
|
+
if ((args.from !== undefined && from === null) || (args.to !== undefined && to === null)) {
|
|
374
|
+
return { code: 'INVALID_ARGUMENT', message: 'calendar dates must use valid YYYY-MM-DD values' };
|
|
375
|
+
}
|
|
376
|
+
if (from !== undefined && from !== null && to !== undefined && to !== null) {
|
|
377
|
+
const days = Math.floor((to - from) / 86_400_000) + 1;
|
|
378
|
+
if (days < 1 || days > 62) {
|
|
379
|
+
return { code: 'INVALID_ARGUMENT', message: 'calendar range cannot exceed 62 days' };
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
if (args.timezone !== undefined) {
|
|
383
|
+
if (typeof args.timezone !== 'string' || !args.timezone.trim() || args.timezone.length > 100) {
|
|
384
|
+
return { code: 'INVALID_ARGUMENT', message: 'calendar timezone is invalid' };
|
|
385
|
+
}
|
|
386
|
+
try {
|
|
387
|
+
new Intl.DateTimeFormat('en-US', { timeZone: args.timezone }).format();
|
|
388
|
+
}
|
|
389
|
+
catch {
|
|
390
|
+
return { code: 'INVALID_ARGUMENT', message: 'calendar timezone is invalid' };
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
if (args?.protocolVersion !== undefined && args.protocolVersion !== 1) {
|
|
395
|
+
return { code: 'SCHEMA_VERSION_UNSUPPORTED', message: 'Unsupported PA workspace protocol version' };
|
|
396
|
+
}
|
|
397
|
+
}
|
|
349
398
|
if (type === 'menu.list' && Object.hasOwn(request, 'context')) {
|
|
350
399
|
return { code: 'INVALID_ARGUMENT', message: 'menu.list context must be inside args.context (for a daemon catalog, use args.context.kind=process)' };
|
|
351
400
|
}
|
|
@@ -520,6 +569,7 @@ const STABLE_CODES = new Set([
|
|
|
520
569
|
'TOPIC_SESSION_NOT_FOUND', 'TOPIC_SESSION_LOOKUP_FAILED',
|
|
521
570
|
'LOOP_TRIGGER_NOT_FOUND', 'LOOP_TRIGGER_DISABLED', 'LOOP_TRIGGER_INVALID',
|
|
522
571
|
'ROOT_NOT_FOUND', 'ROOT_FORBIDDEN', 'ROOT_EXPIRED', 'ROOT_SCOPE_MISMATCH', 'ROOT_PEER_MISMATCH',
|
|
572
|
+
'NOT_CONFIGURED', 'WORKSPACE_UNAVAILABLE',
|
|
523
573
|
'INVALID_ROOT_ID', 'MISSING_ROOT_ID', 'INVALID_ROOT_PATH', 'NOT_A_DIRECTORY', 'FILE_TOO_LARGE',
|
|
524
574
|
// Agent initialization uses these codes to distinguish a retryable failure,
|
|
525
575
|
// an actor mismatch, and a plan/state conflict at the App boundary.
|
|
@@ -770,6 +820,8 @@ function menuFlowBaseRecord(request, context) {
|
|
|
770
820
|
messageId: context.messageId,
|
|
771
821
|
selfAid: context.selfAid,
|
|
772
822
|
requesterAid: context.requesterAid,
|
|
823
|
+
requestType: typeof request.type === 'string' ? request.type : undefined,
|
|
824
|
+
requestName: typeof request.name === 'string' ? request.name : undefined,
|
|
773
825
|
authMethod: context.authMethod,
|
|
774
826
|
clientName: context.clientName,
|
|
775
827
|
};
|