evolcore 0.0.42-test.0 → 0.0.43-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -2
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +4 -2
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -23,7 +23,8 @@ import fs from 'fs';
|
|
|
23
23
|
import { parseDocument } from 'yaml';
|
|
24
24
|
import { agentmdGet } from '../../aun/aid/agentmd.js';
|
|
25
25
|
import { parseDuration, parseTriggerSet, parseTriggerUpdate } from '../../trigger/parser.js';
|
|
26
|
-
|
|
26
|
+
// 不要静态导入 trigger/patch.js:它带着一整棵 patch 校验依赖(实测独占约 150ms),
|
|
27
|
+
// 而只有"修改 Trigger 定义"这一条分支会用到。改在分支内按需加载。
|
|
27
28
|
import { definitionRevision } from '../../trigger/validation.js';
|
|
28
29
|
import { isDaemonEventSessionTrigger, matchTriggerEvent } from '../../trigger/event-source.js';
|
|
29
30
|
import { isTriggerOperator } from '../../trigger/authorization.js';
|
|
@@ -44,11 +45,13 @@ import { executeResolvedPeerCommand, resolvePeerCommand } from '../../config/pee
|
|
|
44
45
|
import { hasTrustedFullAccessDelegation, trustedExecutionIdentityInput } from '../auth/agent-delegation.js';
|
|
45
46
|
import { executeManagedAidOperation, ManagedAidOperationError, managedAidShowViewForRole, resolveManagedAidOperation, } from '../../aun/aid/managed-operation.js';
|
|
46
47
|
import { MAX_AVATAR_SOURCE_BYTES } from '../../utils/avatar-upload.js';
|
|
47
|
-
import { executeManagedGroupOperation,
|
|
48
|
+
import { executeManagedGroupOperation, ManagedGroupOperationError, resolveManagedGroupOperation, executeManagedMsgOperation, ManagedMsgOperationError, resolveManagedMsgOperation, executeManagedFsOperation, ManagedFsOperationError, resolveManagedFsOperation, } from '../../aun/msg/managed-operation.js';
|
|
48
49
|
import { authorizeFreshOperation, buildAuthSubject, executeAuditedOperation } from '../auth/auth-gateway.js';
|
|
49
50
|
import { getExistingRelationAttachmentDirs, isHClassPath, isLClassPath, isSameOrDescendant } from '../permission/protected-paths.js';
|
|
50
51
|
import { validateModelSelectionForRole } from '../model/model-permission.js';
|
|
51
52
|
import { getModelInfo } from '../model/model-catalog.js';
|
|
53
|
+
import { normalizePeer } from '../model/config-scope.js';
|
|
54
|
+
import { executeModelRead } from '../../cli/model.js';
|
|
52
55
|
import { constrainRuntimePermissionMode, resolveRuntimePermissionMode, validateRuntimeStringFieldOverride } from '../role/runtime-policy.js';
|
|
53
56
|
import { parsePeerKey } from '../relation/peer-identity.js';
|
|
54
57
|
import { isQuickCommand } from './slash-gate.js';
|
|
@@ -1560,6 +1563,7 @@ export class CommandHandler {
|
|
|
1560
1563
|
}
|
|
1561
1564
|
let updated;
|
|
1562
1565
|
try {
|
|
1566
|
+
const { applyTriggerPatch, replaceEditableTriggerDefinition } = await import('../../trigger/patch.js');
|
|
1563
1567
|
const { nameOrId: _nameOrId, expectedRevision: _expectedRevision, ...definitionPatch } = patch;
|
|
1564
1568
|
updated = definitionPatch.definition !== undefined
|
|
1565
1569
|
? replaceEditableTriggerDefinition(definition, definitionPatch.definition)
|
|
@@ -2028,6 +2032,7 @@ export class CommandHandler {
|
|
|
2028
2032
|
source: 'agent-tool',
|
|
2029
2033
|
args: {
|
|
2030
2034
|
self: resolved.command.selfAid,
|
|
2035
|
+
targetAgentAid: resolved.command.selfAid,
|
|
2031
2036
|
...(primaryId ? { primaryId } : {}),
|
|
2032
2037
|
},
|
|
2033
2038
|
},
|
|
@@ -2056,11 +2061,12 @@ export class CommandHandler {
|
|
|
2056
2061
|
try {
|
|
2057
2062
|
const command = parseOwnershipCommand(argv);
|
|
2058
2063
|
const targetAid = command.subjectAid ?? grant.selfAid;
|
|
2064
|
+
const fullAccess = hasTrustedFullAccessDelegation(grant);
|
|
2059
2065
|
ownerResolver.assertLocalSubject(targetAid);
|
|
2060
2066
|
if (command.action === 'status') {
|
|
2061
2067
|
return { ok: true, state: await executeOwnershipCommand(command, grant.selfAid) };
|
|
2062
2068
|
}
|
|
2063
|
-
if (!['request', 'bypass'].includes(grant.permissionMode ?? '')) {
|
|
2069
|
+
if (!fullAccess && !['request', 'bypass'].includes(grant.permissionMode ?? '')) {
|
|
2064
2070
|
return { ok: false, code: 'NOT_ALLOWED', error: 'Binding changes and decisions require a request or bypass task' };
|
|
2065
2071
|
}
|
|
2066
2072
|
await refreshOwnershipForAuthorization(targetAid, { includeDaemon: true });
|
|
@@ -2076,11 +2082,12 @@ export class CommandHandler {
|
|
|
2076
2082
|
channelId: conversationId, chatType: grant.chatType, conversationId,
|
|
2077
2083
|
sessionId,
|
|
2078
2084
|
processOwners: ownerResolver.daemonOwners(),
|
|
2085
|
+
...trustedExecutionIdentityInput(grant),
|
|
2079
2086
|
});
|
|
2080
|
-
if (targetAid !== grant.selfAid && !subject.isDaemonOwner) {
|
|
2087
|
+
if (targetAid !== grant.selfAid && !subject.isDaemonOwner && !fullAccess) {
|
|
2081
2088
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'A different local subject requires the current daemon Owner' };
|
|
2082
2089
|
}
|
|
2083
|
-
if (!subject.isDaemonOwner && subject.role !== 'owner') {
|
|
2090
|
+
if (!subject.isDaemonOwner && subject.role !== 'owner' && !fullAccess) {
|
|
2084
2091
|
return { ok: false, code: 'OWNER_REQUIRED', error: 'Ownership binding requires the subject Owner or daemon Owner; first daemon binding uses the local CLI' };
|
|
2085
2092
|
}
|
|
2086
2093
|
const decision = await authorizeFreshOperation({
|
|
@@ -2090,6 +2097,7 @@ export class CommandHandler {
|
|
|
2090
2097
|
scope: 'agent', source: 'agent-tool',
|
|
2091
2098
|
args: {
|
|
2092
2099
|
self: targetAid,
|
|
2100
|
+
targetAgentAid: targetAid,
|
|
2093
2101
|
...(command.action === 'bind' ? { ownerAid: command.ownerAid } : {}),
|
|
2094
2102
|
...(command.action === 'transfer' ? { subAid: command.subAid, newOwnerAid: command.newOwnerAid } : {}),
|
|
2095
2103
|
...(command.action === 'accept' || command.action === 'reject'
|
|
@@ -2160,48 +2168,107 @@ export class CommandHandler {
|
|
|
2160
2168
|
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2161
2169
|
// argv 形如 ['directory', '<sub>', ...]:remark 是写操作,其余是读查询。
|
|
2162
2170
|
const isRemark = argv[1] === 'remark';
|
|
2163
|
-
const subArgv = argv.slice(2);
|
|
2164
|
-
let command;
|
|
2165
|
-
try {
|
|
2166
|
-
command = isRemark
|
|
2167
|
-
? resolveDirectoryRemarkCommand(subArgv)
|
|
2168
|
-
: resolveDirectoryQueryCommand(subArgv);
|
|
2169
|
-
}
|
|
2170
|
-
catch (error) {
|
|
2171
|
-
const known = error instanceof DirectoryRemarkError || error instanceof DirectoryQueryError;
|
|
2172
|
-
return {
|
|
2173
|
-
ok: false,
|
|
2174
|
-
code: known ? error.code : 'INVALID_ARGUMENT',
|
|
2175
|
-
error: error instanceof Error ? error.message : String(error),
|
|
2176
|
-
};
|
|
2177
|
-
}
|
|
2171
|
+
const subArgv = argv.slice(isRemark ? 2 : 1);
|
|
2178
2172
|
const grantSelfAid = delegation.grant.selfAid.replace(/^@/, '');
|
|
2179
2173
|
const sessionSelfAid = session.selfAID?.replace(/^@/, '');
|
|
2180
2174
|
if (sessionSelfAid && sessionSelfAid !== grantSelfAid) {
|
|
2181
2175
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation self agent does not match the active session' };
|
|
2182
2176
|
}
|
|
2183
|
-
|
|
2184
|
-
|
|
2177
|
+
const selfIndex = subArgv.indexOf('--self');
|
|
2178
|
+
const targetAid = selfIndex >= 0 && selfIndex === subArgv.lastIndexOf('--self')
|
|
2179
|
+
? subArgv[selfIndex + 1]
|
|
2180
|
+
: undefined;
|
|
2181
|
+
if (!targetAid || targetAid.startsWith('--')) {
|
|
2182
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: '--self <agent-aid> is required' };
|
|
2183
|
+
}
|
|
2184
|
+
let conversationId;
|
|
2185
|
+
try {
|
|
2186
|
+
conversationId = parsePeerKey(delegation.grant.peerKey).channelId;
|
|
2187
|
+
}
|
|
2188
|
+
catch {
|
|
2189
|
+
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2185
2190
|
}
|
|
2186
|
-
|
|
2187
|
-
|
|
2191
|
+
const operation = isRemark ? 'ec.directory.remark' : 'ec.directory.query';
|
|
2192
|
+
const subject = buildAuthSubject({
|
|
2193
|
+
selfAid: grantSelfAid,
|
|
2194
|
+
sessionId,
|
|
2195
|
+
actorId: delegation.grant.actorId,
|
|
2196
|
+
channel: delegation.grant.channel,
|
|
2197
|
+
channelType: delegation.grant.channelType,
|
|
2198
|
+
channelId: conversationId,
|
|
2199
|
+
chatType: delegation.grant.chatType,
|
|
2200
|
+
conversationId,
|
|
2201
|
+
permissionMode: delegation.grant.permissionMode,
|
|
2202
|
+
processOwners: ownerResolver.daemonOwners(),
|
|
2203
|
+
...trustedExecutionIdentityInput(delegation.grant),
|
|
2204
|
+
});
|
|
2205
|
+
return executeAuditedOperation({
|
|
2206
|
+
source: 'agent-tool',
|
|
2207
|
+
subject,
|
|
2208
|
+
intent: {
|
|
2209
|
+
operation,
|
|
2210
|
+
scope: 'agent',
|
|
2211
|
+
source: 'agent-tool',
|
|
2212
|
+
args: { self: grantSelfAid, targetAgentAid: targetAid, action: subArgv[0] },
|
|
2213
|
+
},
|
|
2214
|
+
auditMetadata: {
|
|
2215
|
+
argvHash: hashArgv(argv),
|
|
2216
|
+
taskId: delegation.grant.taskId,
|
|
2217
|
+
messageId: delegation.grant.messageId,
|
|
2218
|
+
},
|
|
2219
|
+
}, async (onExecutionStarted) => {
|
|
2220
|
+
const bodyFileIndex = isRemark ? subArgv.indexOf('--body-file') : -1;
|
|
2221
|
+
if (bodyFileIndex >= 0) {
|
|
2222
|
+
const rawBodyFile = subArgv[bodyFileIndex + 1];
|
|
2223
|
+
if (!rawBodyFile || rawBodyFile.startsWith('--') || bodyFileIndex !== subArgv.lastIndexOf('--body-file')) {
|
|
2224
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: '--body-file must occur once with a file path' };
|
|
2225
|
+
}
|
|
2226
|
+
try {
|
|
2227
|
+
const projectPath = path.resolve(session.projectPath);
|
|
2228
|
+
const tempPath = this.getManagedSessionTempDir(session);
|
|
2229
|
+
const allowedRoots = [projectPath, tempPath].filter((value) => !!value)
|
|
2230
|
+
.map(root => fs.realpathSync(root));
|
|
2231
|
+
const requestedPath = path.resolve(projectPath, rawBodyFile);
|
|
2232
|
+
const stat = fs.lstatSync(requestedPath);
|
|
2233
|
+
const realPath = fs.realpathSync(requestedPath);
|
|
2234
|
+
const inManagedTemp = !!tempPath && isSameOrDescendant(realPath, fs.realpathSync(tempPath));
|
|
2235
|
+
if (stat.isSymbolicLink() || !stat.isFile() || stat.size > 16 * 1024
|
|
2236
|
+
|| !allowedRoots.some(root => isSameOrDescendant(realPath, root))
|
|
2237
|
+
|| (!hasTrustedFullAccessDelegation(delegation.grant) && (isHClassPath(realPath) || isLClassPath(realPath)))
|
|
2238
|
+
|| (inManagedTemp && stat.nlink > 1)) {
|
|
2239
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: '--body-file must be a small regular file in the session project or TMPDIR' };
|
|
2240
|
+
}
|
|
2241
|
+
subArgv[bodyFileIndex + 1] = realPath;
|
|
2242
|
+
}
|
|
2243
|
+
catch (error) {
|
|
2244
|
+
return { ok: false, code: 'INVALID_ARGUMENT', error: `cannot access --body-file: ${error instanceof Error ? error.message : String(error)}` };
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
let command;
|
|
2248
|
+
try {
|
|
2249
|
+
command = isRemark
|
|
2250
|
+
? resolveDirectoryRemarkCommand(subArgv)
|
|
2251
|
+
: resolveDirectoryQueryCommand(subArgv);
|
|
2252
|
+
}
|
|
2253
|
+
catch (error) {
|
|
2254
|
+
const known = error instanceof DirectoryRemarkError || error instanceof DirectoryQueryError;
|
|
2255
|
+
return {
|
|
2256
|
+
ok: false,
|
|
2257
|
+
code: known ? error.code : 'INVALID_ARGUMENT',
|
|
2258
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2259
|
+
};
|
|
2260
|
+
}
|
|
2261
|
+
if (command.selfAid !== targetAid) {
|
|
2262
|
+
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Resolved Agent target does not match the authorized target' };
|
|
2263
|
+
}
|
|
2264
|
+
onExecutionStarted();
|
|
2265
|
+
const result = isRemark
|
|
2266
|
+
? executeDirectoryRemarkCommand(command)
|
|
2267
|
+
: await executeDirectoryQueryCommand(command);
|
|
2188
2268
|
return result.ok
|
|
2189
2269
|
? { ok: true, result }
|
|
2190
2270
|
: { ok: false, code: result.code, error: result.error };
|
|
2191
|
-
}
|
|
2192
|
-
const result = await executeDirectoryQueryCommand(command);
|
|
2193
|
-
return result.ok
|
|
2194
|
-
? { ok: true, result }
|
|
2195
|
-
: { ok: false, code: result.code, error: result.error };
|
|
2196
|
-
}
|
|
2197
|
-
canMaintainDirectory(callerAid, targetAid) {
|
|
2198
|
-
if (callerAid === targetAid)
|
|
2199
|
-
return true;
|
|
2200
|
-
const callerOwner = ownerResolver.owner(callerAid) ?? ownerResolver.knownOwner(callerAid);
|
|
2201
|
-
if (!callerOwner)
|
|
2202
|
-
return false;
|
|
2203
|
-
const targetOwner = ownerResolver.owner(targetAid) ?? ownerResolver.knownOwner(targetAid);
|
|
2204
|
-
return !!targetOwner && targetOwner === callerOwner;
|
|
2271
|
+
});
|
|
2205
2272
|
}
|
|
2206
2273
|
async handleAidOperation(argv, sessionId, delegationToken, delegationCommandHash, requestId) {
|
|
2207
2274
|
if (!this.agentDelegationRegistry) {
|
|
@@ -2221,15 +2288,6 @@ export class CommandHandler {
|
|
|
2221
2288
|
if (sessionSelfAid && sessionSelfAid !== grantSelfAid) {
|
|
2222
2289
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation self agent does not match the active session' };
|
|
2223
2290
|
}
|
|
2224
|
-
const requiresSelfAid = parsed.command.kind === 'show'
|
|
2225
|
-
|| parsed.command.kind === 'agentmd.put'
|
|
2226
|
-
|| parsed.command.kind === 'agentmd.set'
|
|
2227
|
-
|| parsed.command.kind === 'avatar';
|
|
2228
|
-
if (requiresSelfAid
|
|
2229
|
-
&& parsed.command.aid !== grantSelfAid
|
|
2230
|
-
&& (parsed.command.kind === 'avatar' || !hasTrustedFullAccessDelegation(delegation.grant))) {
|
|
2231
|
-
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Only the current Agent AID can be targeted' };
|
|
2232
|
-
}
|
|
2233
2291
|
let conversationId;
|
|
2234
2292
|
try {
|
|
2235
2293
|
conversationId = parsePeerKey(delegation.grant.peerKey).channelId;
|
|
@@ -2247,6 +2305,7 @@ export class CommandHandler {
|
|
|
2247
2305
|
channelId: conversationId,
|
|
2248
2306
|
chatType: delegation.grant.chatType,
|
|
2249
2307
|
conversationId,
|
|
2308
|
+
permissionMode: delegation.grant.permissionMode,
|
|
2250
2309
|
processOwners: ownerResolver.daemonOwners(),
|
|
2251
2310
|
...trustedExecutionIdentityInput(delegation.grant),
|
|
2252
2311
|
});
|
|
@@ -2258,7 +2317,14 @@ export class CommandHandler {
|
|
|
2258
2317
|
operation: parsed.command.operationId,
|
|
2259
2318
|
scope: managementRole ? 'agent' : 'relation',
|
|
2260
2319
|
source: 'agent-tool',
|
|
2261
|
-
args: {
|
|
2320
|
+
args: {
|
|
2321
|
+
self: delegation.grant.selfAid,
|
|
2322
|
+
targetAgentAid: parsed.command.kind === 'list'
|
|
2323
|
+
? delegation.grant.selfAid : parsed.command.aid,
|
|
2324
|
+
targetId: parsed.command.kind === 'list' ? delegation.grant.selfAid : parsed.command.aid,
|
|
2325
|
+
aid: parsed.command.kind === 'list' ? undefined : parsed.command.aid,
|
|
2326
|
+
...(parsed.command.kind === 'list' ? { filters: parsed.command.filters } : {}),
|
|
2327
|
+
},
|
|
2262
2328
|
},
|
|
2263
2329
|
auditMetadata: {
|
|
2264
2330
|
argvHash: hashArgv(parsed.command.canonicalArgv),
|
|
@@ -2415,25 +2481,17 @@ export class CommandHandler {
|
|
|
2415
2481
|
...trustedExecutionIdentityInput(grant),
|
|
2416
2482
|
});
|
|
2417
2483
|
const managementRole = isManagementRole(subject.role) || subject.dataScope === 'daemon';
|
|
2418
|
-
if (subject.dataScope !== 'daemon'
|
|
2419
|
-
&& !managementRole
|
|
2420
|
-
&& (grant.channelType !== 'aun'
|
|
2421
|
-
|| !(isManagedGroupRelationRead(parsed.command) || isManagedGroupRelationWrite(parsed.command)))) {
|
|
2422
|
-
return { ok: false, code: 'ROLE_ACCESS_DENIED', error: `Role ${subject.role} cannot manage Agent group membership or settings` };
|
|
2423
|
-
}
|
|
2424
|
-
if ((parsed.command.kind === 'dissolve' || parsed.command.kind === 'owner')
|
|
2425
|
-
&& subject.dataScope !== 'daemon' && subject.role !== 'owner') {
|
|
2426
|
-
return { ok: false, code: 'ROLE_ACCESS_DENIED', error: `${parsed.command.kind} requires Agent owner permission` };
|
|
2427
|
-
}
|
|
2428
2484
|
const decision = await authorizeFreshOperation({
|
|
2429
2485
|
source: 'agent-tool',
|
|
2430
2486
|
subject,
|
|
2431
2487
|
intent: {
|
|
2432
2488
|
operation: parsed.command.operationId,
|
|
2433
|
-
scope: managementRole ? 'agent' : 'relation',
|
|
2489
|
+
scope: managementRole || parsed.command.kind === 'list' ? 'agent' : 'relation',
|
|
2434
2490
|
source: 'agent-tool',
|
|
2435
2491
|
args: {
|
|
2436
2492
|
self: parsed.command.from,
|
|
2493
|
+
targetAgentAid: parsed.command.from,
|
|
2494
|
+
...(parsed.command.memberAid ? { memberAid: parsed.command.memberAid } : {}),
|
|
2437
2495
|
...(parsed.command.groupId ? {
|
|
2438
2496
|
targetId: parsed.command.groupId,
|
|
2439
2497
|
peer: parsed.command.groupId,
|
|
@@ -2451,9 +2509,8 @@ export class CommandHandler {
|
|
|
2451
2509
|
if (!decision.allow)
|
|
2452
2510
|
return { ok: false, code: decision.code, error: decision.reason };
|
|
2453
2511
|
if (parsed.command.kind === 'accept-invite' || parsed.command.kind === 'reject-invite') {
|
|
2454
|
-
if (
|
|
2455
|
-
|
|
2456
|
-
return { ok: false, code: 'ROLE_ACCESS_DENIED', error: 'Targeted invitation decisions require the current Agent Owner' };
|
|
2512
|
+
if (parsed.command.from !== grantSelfAid || !this.groupInviteDecisionResolver) {
|
|
2513
|
+
return { ok: false, code: 'NOT_CONFIGURED', error: 'Targeted invitation decision service is unavailable' };
|
|
2457
2514
|
}
|
|
2458
2515
|
try {
|
|
2459
2516
|
const result = await this.groupInviteDecisionResolver(grantSelfAid, grant.actorId, parsed.command.inviteId, parsed.command.kind === 'accept-invite' ? 'accept' : 'reject');
|
|
@@ -2654,6 +2711,7 @@ export class CommandHandler {
|
|
|
2654
2711
|
source: 'agent-tool',
|
|
2655
2712
|
args: {
|
|
2656
2713
|
self: parsed.command.from,
|
|
2714
|
+
targetAgentAid: parsed.command.from,
|
|
2657
2715
|
targetId,
|
|
2658
2716
|
peer: targetId,
|
|
2659
2717
|
peerKey: targetPeerKey,
|
|
@@ -2757,9 +2815,6 @@ export class CommandHandler {
|
|
|
2757
2815
|
}
|
|
2758
2816
|
let currentGroup;
|
|
2759
2817
|
if (storageBackend === 'personal' && isSelfTarget) {
|
|
2760
|
-
if (grant.issuedRole !== 'owner' && !hasTrustedFullAccessDelegation(grant)) {
|
|
2761
|
-
return { ok: false, code: 'NO_PERMISSION', error: 'Managed personal storage requires the current Agent owner relation' };
|
|
2762
|
-
}
|
|
2763
2818
|
if (parsed.command.actorAid && parsed.command.actorAid !== actorAid) {
|
|
2764
2819
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Only the current Agent can access its personal storage' };
|
|
2765
2820
|
}
|
|
@@ -2810,6 +2865,8 @@ export class CommandHandler {
|
|
|
2810
2865
|
});
|
|
2811
2866
|
const intentArgs = {
|
|
2812
2867
|
self: actorAid,
|
|
2868
|
+
targetAgentAid: grant.selfAid,
|
|
2869
|
+
personalStorage: storageBackend === 'personal' && isSelfTarget,
|
|
2813
2870
|
targetId: parsed.command.targetAid,
|
|
2814
2871
|
peer: relationTarget ?? actorAid,
|
|
2815
2872
|
peerKey: formatPeerKey('aun', relationTarget ?? actorAid),
|
|
@@ -2970,16 +3027,115 @@ export class CommandHandler {
|
|
|
2970
3027
|
}
|
|
2971
3028
|
if (argv[0] !== 'model' && argv[0] !== 'response')
|
|
2972
3029
|
return invalid('Expected a model or response command');
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
const
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
if (
|
|
2980
|
-
|
|
2981
|
-
|
|
3030
|
+
const rawArgs = argv.slice(2);
|
|
3031
|
+
const selector = {};
|
|
3032
|
+
let hasFormat = false;
|
|
3033
|
+
const positionalsAndOptions = [];
|
|
3034
|
+
for (let index = 0; index < rawArgs.length; index += 1) {
|
|
3035
|
+
const arg = rawArgs[index];
|
|
3036
|
+
if (arg === '--format=json') {
|
|
3037
|
+
if (hasFormat)
|
|
3038
|
+
return invalid('Duplicate --format');
|
|
3039
|
+
hasFormat = true;
|
|
3040
|
+
continue;
|
|
3041
|
+
}
|
|
3042
|
+
if (arg === '--format') {
|
|
3043
|
+
if (hasFormat || rawArgs[index + 1] !== 'json')
|
|
3044
|
+
return invalid('--format must be json');
|
|
3045
|
+
hasFormat = true;
|
|
3046
|
+
index += 1;
|
|
3047
|
+
continue;
|
|
3048
|
+
}
|
|
3049
|
+
if (arg === '--self' || arg === '--peer' || arg === '--role') {
|
|
3050
|
+
const value = rawArgs[index + 1];
|
|
3051
|
+
if (!value || value.startsWith('--'))
|
|
3052
|
+
return invalid(`${arg} requires a value`);
|
|
3053
|
+
const key = arg === '--peer' ? 'peerKey' : arg.slice(2);
|
|
3054
|
+
if (selector[key] !== undefined)
|
|
3055
|
+
return invalid(`Duplicate ${arg}`);
|
|
3056
|
+
if (arg === '--self')
|
|
3057
|
+
selector.self = value;
|
|
3058
|
+
else if (arg === '--role')
|
|
3059
|
+
selector.role = value;
|
|
3060
|
+
else {
|
|
3061
|
+
try {
|
|
3062
|
+
selector.peerKey = normalizePeer(value);
|
|
3063
|
+
}
|
|
3064
|
+
catch (error) {
|
|
3065
|
+
return invalid(error instanceof Error ? error.message : String(error));
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
index += 1;
|
|
3069
|
+
}
|
|
3070
|
+
else {
|
|
3071
|
+
positionalsAndOptions.push(arg);
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
const hasModelSelector = Object.keys(selector).length > 0;
|
|
3075
|
+
const isModelRead = argv[0] === 'model' && ['list', 'current', 'info', 'check'].includes(argv[1]);
|
|
3076
|
+
const fullAccess = hasTrustedFullAccessDelegation(grant);
|
|
3077
|
+
if (hasModelSelector) {
|
|
3078
|
+
if (!isModelRead) {
|
|
3079
|
+
return { ok: false, code: 'NOT_ALLOWED', error: 'Managed model selectors are available only for Owner bypass read-only previews' };
|
|
3080
|
+
}
|
|
3081
|
+
if ((selector.peerKey || selector.role) && !selector.self)
|
|
3082
|
+
return invalid('--peer/--role requires --self');
|
|
3083
|
+
if (selector.peerKey && selector.role)
|
|
3084
|
+
return invalid('Select either --peer or --role');
|
|
3085
|
+
const sub = argv[1];
|
|
3086
|
+
if (sub === 'info'
|
|
3087
|
+
? positionalsAndOptions.length !== 1 || !positionalsAndOptions[0] || /\s|^--/.test(positionalsAndOptions[0])
|
|
3088
|
+
: positionalsAndOptions.length !== 0)
|
|
3089
|
+
return invalid('Invalid managed model read arguments');
|
|
3090
|
+
const session = await this.sessionManager.getSessionById(sessionId);
|
|
3091
|
+
if (!session)
|
|
3092
|
+
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
3093
|
+
if (session.selfAID !== grant.selfAid || grant.sessionId !== sessionId) {
|
|
3094
|
+
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation does not match the current session' };
|
|
3095
|
+
}
|
|
3096
|
+
let conversationId;
|
|
3097
|
+
try {
|
|
3098
|
+
conversationId = parsePeerKey(grant.peerKey).channelId;
|
|
3099
|
+
}
|
|
3100
|
+
catch {
|
|
3101
|
+
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
3102
|
+
}
|
|
3103
|
+
const subject = buildAuthSubject({
|
|
3104
|
+
selfAid: grant.selfAid,
|
|
3105
|
+
sessionId,
|
|
3106
|
+
actorId: grant.actorId,
|
|
3107
|
+
channel: grant.channel,
|
|
3108
|
+
channelType: grant.channelType,
|
|
3109
|
+
channelId: conversationId,
|
|
3110
|
+
chatType: grant.chatType,
|
|
3111
|
+
conversationId,
|
|
3112
|
+
permissionMode: grant.permissionMode,
|
|
3113
|
+
processOwners: ownerResolver.daemonOwners(),
|
|
3114
|
+
...trustedExecutionIdentityInput(grant),
|
|
3115
|
+
});
|
|
3116
|
+
return executeAuditedOperation({
|
|
3117
|
+
source: 'agent-tool',
|
|
3118
|
+
subject,
|
|
3119
|
+
intent: {
|
|
3120
|
+
operation: `model.${sub}`,
|
|
3121
|
+
scope: sub === 'check' ? 'agent' : selector.peerKey ? 'relation' : selector.role ? 'role' : 'agent',
|
|
3122
|
+
source: 'agent-tool',
|
|
3123
|
+
args: {
|
|
3124
|
+
self: selector.self ?? grant.selfAid,
|
|
3125
|
+
targetAgentAid: selector.self ?? grant.selfAid,
|
|
3126
|
+
...(!fullAccess ? { preview: true } : {}),
|
|
3127
|
+
...(selector.peerKey ? { peer: selector.peerKey, peerKey: selector.peerKey } : {}),
|
|
3128
|
+
...(selector.role ? { role: selector.role } : {}),
|
|
3129
|
+
},
|
|
3130
|
+
},
|
|
3131
|
+
auditMetadata: { argvHash: hashArgv(argv), taskId: grant.taskId, messageId: grant.messageId },
|
|
3132
|
+
}, async (onExecutionStarted) => {
|
|
3133
|
+
onExecutionStarted();
|
|
3134
|
+
const result = await executeModelRead(sub, { ...selector, self: selector.self ?? grant.selfAid }, positionalsAndOptions[0]);
|
|
3135
|
+
return { ok: true, result: result.text(), data: result.data };
|
|
3136
|
+
});
|
|
2982
3137
|
}
|
|
3138
|
+
const args = positionalsAndOptions;
|
|
2983
3139
|
const sub = argv[1];
|
|
2984
3140
|
if (argv[0] === 'model') {
|
|
2985
3141
|
let command;
|
|
@@ -3211,7 +3367,7 @@ export class CommandHandler {
|
|
|
3211
3367
|
}
|
|
3212
3368
|
resolveCtlIntent(cmd, selfAid, peerKey) {
|
|
3213
3369
|
const [name = '', ...args] = cmd.trim().slice(1).trim().split(/\s+/);
|
|
3214
|
-
const relationArgs = { self: selfAid, peer: peerKey, peerKey };
|
|
3370
|
+
const relationArgs = { self: selfAid, targetAgentAid: selfAid, peer: peerKey, peerKey };
|
|
3215
3371
|
const intent = (operation, extra = {}) => ({
|
|
3216
3372
|
operation,
|
|
3217
3373
|
scope: 'relation',
|
|
@@ -3244,7 +3400,7 @@ export class CommandHandler {
|
|
|
3244
3400
|
operation,
|
|
3245
3401
|
scope: 'agent',
|
|
3246
3402
|
source: 'agent-tool',
|
|
3247
|
-
args: { self: selfAid, ...extra },
|
|
3403
|
+
args: { self: selfAid, targetAgentAid: selfAid, ...extra },
|
|
3248
3404
|
});
|
|
3249
3405
|
if (name === 'model') {
|
|
3250
3406
|
if (args.length === 0 || args[0] === 'list')
|
|
@@ -4,6 +4,7 @@ import { mutateAccessPolicy, readAccessPolicySnapshot, } from '../../config/acce
|
|
|
4
4
|
import { expirePendingPeerRequests, addPeer, mutatePeerWithOperation, reviewPeerRequest, } from '../../config/peer-request-service.js';
|
|
5
5
|
import { formatPeerKey, parsePeerKey } from '../relation/peer-identity.js';
|
|
6
6
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
7
|
+
import { refreshDirectoryMarkdown } from '../../directory/owner-directory-admission.js';
|
|
7
8
|
/**
|
|
8
9
|
* Connect Menu — 联系人与关系管理协议
|
|
9
10
|
*
|
|
@@ -267,7 +268,7 @@ async function handleAction(req, self, context) {
|
|
|
267
268
|
function isAccessUpdateResource(resource) {
|
|
268
269
|
return resource === 'allowInternalContacts'
|
|
269
270
|
|| resource === 'allowExternalContacts'
|
|
270
|
-
|| resource === '
|
|
271
|
+
|| resource === 'allowAllContacts'
|
|
271
272
|
|| resource === 'allowedAids'
|
|
272
273
|
|| resource === 'deniedAids'
|
|
273
274
|
|| resource === 'requestLimit';
|
|
@@ -281,7 +282,7 @@ function updateAccessResource(req, context, resource) {
|
|
|
281
282
|
const self = context.self;
|
|
282
283
|
const expectedAccessRevision = requireAccessRevision(args);
|
|
283
284
|
const decoded = decodeAccessUpdateValue(req.value);
|
|
284
|
-
if (resource === 'allowInternalContacts' || resource === 'allowExternalContacts' || resource === '
|
|
285
|
+
if (resource === 'allowInternalContacts' || resource === 'allowExternalContacts' || resource === 'allowAllContacts') {
|
|
285
286
|
if (typeof decoded !== 'boolean') {
|
|
286
287
|
return fail('INVALID_ARGUMENT', `${resource} must be a JSON boolean`);
|
|
287
288
|
}
|
|
@@ -314,6 +315,11 @@ function updateAccessResource(req, context, resource) {
|
|
|
314
315
|
expectedAccessRevision,
|
|
315
316
|
update: current => accessPolicyWithUpdate(current, resource, decoded),
|
|
316
317
|
});
|
|
318
|
+
// 外部联系开关是唯一会改变 directory.md 内容的开关:准入每次现读 config,
|
|
319
|
+
// 立刻生效;注入内容是渲染产物,不重算就停在旧版本。
|
|
320
|
+
if (result.changed && resource === 'allowExternalContacts') {
|
|
321
|
+
refreshDirectoryMarkdown(self);
|
|
322
|
+
}
|
|
317
323
|
return ok({
|
|
318
324
|
self,
|
|
319
325
|
resource,
|
|
@@ -547,8 +553,8 @@ function accessPolicyWithUpdate(current, resource, decoded) {
|
|
|
547
553
|
if (resource === 'allowExternalContacts') {
|
|
548
554
|
return { ...current, allowExternalContacts: decoded };
|
|
549
555
|
}
|
|
550
|
-
if (resource === '
|
|
551
|
-
return { ...current,
|
|
556
|
+
if (resource === 'allowAllContacts') {
|
|
557
|
+
return { ...current, allowAllContacts: decoded };
|
|
552
558
|
}
|
|
553
559
|
if (resource === 'allowedAids') {
|
|
554
560
|
return { ...current, allowedAids: [...decoded] };
|
|
@@ -47,9 +47,9 @@ const LOG_SOURCES = [
|
|
|
47
47
|
{ id: 'stdout', label: 'Standard output', pattern: /^stdout\.log(?:\..+)?$/ },
|
|
48
48
|
{ id: 'aun', label: 'AUN', pattern: /^aun(?:-.+)?\.log$/ },
|
|
49
49
|
{ id: 'sdk', label: 'TypeScript SDK', pattern: /^ts-sdk-.+\.log$/ },
|
|
50
|
-
{ id: 'events', label: 'Events', pattern: /^events
|
|
51
|
-
{ id: 'channel-in', label: 'Channel · inbound', pattern: /^channel-in
|
|
52
|
-
{ id: 'channel-out', label: 'Channel · outbound', pattern: /^channel-out
|
|
50
|
+
{ id: 'events', label: 'Events', pattern: /^events(?:-.+)?\.log$/ },
|
|
51
|
+
{ id: 'channel-in', label: 'Channel · inbound', pattern: /^channel-in(?:-.+)?\.log$/ },
|
|
52
|
+
{ id: 'channel-out', label: 'Channel · outbound', pattern: /^channel-out(?:-.+)?\.log$/ },
|
|
53
53
|
{ id: 'commands', label: 'Commands', pattern: /^commands-.+\.jsonl$/ },
|
|
54
54
|
{ id: 'triggers', label: 'Trigger runs', pattern: /^trigger-runs(?:-.+)?\.(?:log|jsonl)$/ },
|
|
55
55
|
{ id: 'restart', label: 'Restart', pattern: /^restart\.log$/ },
|
|
@@ -5,9 +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 { paWorkspaceStore } from './pa-workspace-store.js';
|
|
9
|
-
|
|
10
|
-
export { DataRootError } from './data-root-error.js';
|
|
8
|
+
import { DataRootError, paWorkspaceStore } from './pa-workspace-store.js';
|
|
9
|
+
export { DataRootError } from './pa-workspace-store.js';
|
|
11
10
|
const DEFAULT_ROOT_TTL_MS = 10 * 60 * 1000;
|
|
12
11
|
const TOKEN_PREFIX = 'dr1';
|
|
13
12
|
function base64Url(value) {
|
|
@@ -121,8 +121,8 @@ const ENTRIES = [
|
|
|
121
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' },
|
|
122
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' },
|
|
123
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' } },
|
|
124
|
-
{ id: 'system.upgrade', type: 'action', contexts: ['process'], name: 'system', label: '检查更新', section: 'process', order: 30, action: { cmd: '/system', action: 'upgrade', args: { mode: 'check' }, operation: 'system.upgrade', scope: 'process' } },
|
|
125
|
-
{ id: 'system.upgrade.update', type: 'action', contexts: ['process'], name: 'system', label: '执行更新', section: 'process', order: 31, action: { cmd: '/system', action: 'upgrade', args: { mode: 'update' }, operation: 'system.
|
|
124
|
+
{ id: 'system.upgrade', type: 'action', contexts: ['process'], name: 'system', label: '检查更新', section: 'process', order: 30, action: { cmd: '/system', action: 'upgrade', args: { mode: 'check' }, operation: 'system.upgrade.check', scope: 'process' } },
|
|
125
|
+
{ id: 'system.upgrade.update', type: 'action', contexts: ['process'], name: 'system', label: '执行更新', section: 'process', order: 31, action: { cmd: '/system', action: 'upgrade', args: { mode: 'update' }, operation: 'system.update', scope: 'process' } },
|
|
126
126
|
{ id: 'system.paircode', type: 'action', contexts: ['process'], name: 'system', label: '获取配对码', section: 'process', order: 35, action: { cmd: '/system', action: 'paircode', operation: 'system.paircode', scope: 'process' } },
|
|
127
127
|
{ id: 'agent.list', type: 'list', contexts: ['process'], name: 'agent', label: 'Agent 列表', section: 'process', order: 40, options: { cmd: '/agent', args: { options: 'all' }, operation: 'agent.list', scope: 'control', mode: 'dynamic' }, control: 'list' },
|
|
128
128
|
{ id: 'agent.create', type: 'action', contexts: ['process'], name: 'agent', label: '创建 Agent', section: 'process', order: 50, action: { cmd: '/agent', action: 'create', operation: 'agent.create', scope: 'control' } },
|
|
@@ -375,7 +375,14 @@ function configuredHostBaseagentEntries() {
|
|
|
375
375
|
function menuEntryDefinitions(context) {
|
|
376
376
|
return context.kind === 'process' ? [...ENTRIES, ...configuredHostBaseagentEntries()] : ENTRIES;
|
|
377
377
|
}
|
|
378
|
-
function intentFor(binding, context) {
|
|
378
|
+
function intentFor(binding, context) {
|
|
379
|
+
return {
|
|
380
|
+
operation: binding.operation,
|
|
381
|
+
scope: binding.scope,
|
|
382
|
+
source: 'menu',
|
|
383
|
+
args: { ...bindingArgs(binding, context), targetAgentAid: context.self },
|
|
384
|
+
};
|
|
385
|
+
}
|
|
379
386
|
async function operationView(binding, context, options = {}) {
|
|
380
387
|
if (!binding)
|
|
381
388
|
return undefined;
|