evolcore 0.0.46 → 0.0.48
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 +93 -0
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +139 -39
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +43 -18
- package/dist/agents/codex/app-server-client.js +32 -23
- package/dist/agents/codex-runner.js +31 -16
- package/dist/agents/ecagent-runner.js +7 -4
- package/dist/agents/gemini-runner.js +5 -2
- package/dist/agents/runner-types.js +5 -21
- package/dist/aun/aid/agentmd.js +5 -1
- package/dist/aun/group/fs-download.js +1 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +100 -32
- package/dist/channels/daemon.js +10 -26
- package/dist/cli/aun-commands.js +86 -51
- package/dist/cli/code-stats.js +19 -8
- package/dist/cli/command-log.js +1 -1
- package/dist/cli/daemon-commands.js +65 -76
- package/dist/cli/daemon-lifecycle-client.js +17 -3
- package/dist/cli/directory.js +7 -1
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +2 -8
- package/dist/cli/init-channel.js +6 -8
- package/dist/cli/init.js +74 -46
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/restart-monitor.js +104 -28
- package/dist/cli/role.js +61 -17
- package/dist/cli/stats.js +3 -3
- package/dist/cli/task-context.js +83 -15
- package/dist/cli/thread-command.js +16 -51
- package/dist/cli/upgrade-command.js +4 -2
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-manager.js +31 -23
- package/dist/config/daemon-services.js +30 -3
- package/dist/config/gateway-config.js +2 -2
- package/dist/config/invoke-ipc-service.js +6 -4
- package/dist/config/peer-bind-code.js +3 -4
- package/dist/config/peer-book-store.js +59 -218
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +161 -6
- package/dist/config/provider-ipc-service.js +56 -11
- package/dist/config/provider-menu-request.js +24 -5
- package/dist/config/provider-templates.js +127 -0
- package/dist/config/providers-config.js +59 -8
- package/dist/config/providers-management.js +467 -49
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +228 -20
- package/dist/config/schema-registry.js +6 -2
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +10 -5
- package/dist/core/auth/agent-delegation.js +10 -4
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +3 -0
- package/dist/core/auth/delegation-diagnostics.js +56 -15
- package/dist/core/auth/operation-authorizer.js +26 -1
- package/dist/core/auth/operation-catalog.js +28 -64
- package/dist/core/capability/providers/codex-capability-provider.js +7 -8
- package/dist/core/channel-loader.js +18 -0
- package/dist/core/command/agent-control.js +32 -0
- package/dist/core/command/command-handler.js +81 -85
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +65 -153
- package/dist/core/command/menu-protocol.js +7 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +30 -49
- package/dist/core/command/team-workspace-items.js +81 -12
- package/dist/core/command/team-workspace-team.js +9 -71
- package/dist/core/command/topic-slash.js +9 -30
- package/dist/core/daemon-bootstrap.js +19 -10
- package/dist/core/daemon-control.js +8 -10
- package/dist/core/daemon-lifecycle.js +50 -40
- package/dist/core/evolagent-registry.js +22 -3
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/host-snapshot.js +9 -4
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +31 -8
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +6 -4
- package/dist/core/memory/consolidation.js +6 -6
- package/dist/core/message/aun-ipc-sender.js +165 -55
- package/dist/core/message/im-renderer.js +1 -1
- package/dist/core/message/message-bridge.js +51 -334
- package/dist/core/message/message-log.js +5 -0
- package/dist/core/message/message-queue.js +22 -0
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +429 -116
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/ownership/owner-resolver.js +355 -60
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/relation/peer-identity.js +28 -2
- package/dist/core/relation/same-owner-proof.js +81 -111
- package/dist/core/session/adapters/claude-session-file-adapter.js +1 -1
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +49 -14
- package/dist/core/session/session-fs-store.js +91 -35
- package/dist/core/session/session-manager.js +68 -24
- package/dist/core/session/session-mapper.js +14 -34
- package/dist/core/session/session-transcript.js +5 -1
- package/dist/core/task/task-activity-store.js +84 -0
- package/dist/core/task/task-image-resources.js +1 -1
- package/dist/core/task/task-recovery-service.js +12 -0
- package/dist/core/thread/command-parser.js +7 -12
- package/dist/core/thread/thread-context-storage.js +3 -2
- package/dist/core/thread/thread-operation.js +2 -13
- package/dist/core/thread/thread-service.js +15 -46
- package/dist/directory/owner-directory-admission.js +1 -1
- package/dist/directory/owner-directory-cache.js +45 -28
- package/dist/directory/owner-directory-markdown.js +13 -1
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/eck/message-renderer.js +84 -24
- package/dist/ecweb/basic-settings-service.js +3 -1
- package/dist/ecweb/message-context-service.js +1 -1
- package/dist/ecweb/pairing.js +4 -3
- package/dist/ecweb/providers-service.js +26 -1
- package/dist/ecweb/runtime/lifecycle.js +82 -23
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +6 -17
- package/dist/event-center/registry.js +13 -2
- package/dist/event-center/runtime.js +103 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +129 -93
- package/dist/ipc.js +15 -3
- package/dist/outputs/events.js +62 -0
- package/dist/outputs/protocol.js +102 -0
- package/dist/outputs/service.js +279 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +89 -4
- package/dist/services/ipc-operation.js +4 -15
- package/dist/services/pack-manager.js +12 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +1 -1
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +305 -24
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/role-budget.js +5 -2
- package/dist/stats/writer.js +10 -6
- package/dist/trigger/audit.js +7 -0
- package/dist/trigger/authorization.js +105 -11
- package/dist/trigger/feedback.js +10 -0
- package/dist/trigger/history.js +37 -11
- package/dist/trigger/ipc-service.js +12 -1
- package/dist/trigger/manager.js +1 -0
- package/dist/trigger/scheduler.js +11 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +9 -3
- package/dist/trigger/state.js +7 -0
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/aid-bind.js +155 -18
- package/dist/utils/atomic-write.js +3 -3
- package/dist/utils/cross-platform.js +97 -31
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +40 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/instance-registry.js +61 -0
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/process-introspect.js +158 -8
- package/dist/utils/process-tree.js +50 -2
- package/dist/utils/upgrade-jobs.js +4 -4
- package/dist/utils/windows-shell-trust.js +2 -0
- package/dist/workbench/protocol.js +80 -0
- package/dist/workbench/service.js +359 -0
- package/ecagent/dist/types.d.ts +6 -2
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +2 -2
- package/kits/docs/evolcore/aid.md +3 -1
- package/kits/docs/evolcore/config.md +12 -0
- package/kits/docs/evolcore/directory.md +22 -3
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +133 -5
- package/kits/docs/evolcore/role.md +80 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/team-workspace.md +1 -1
- package/kits/docs/evolcore/thread-chain.md +14 -15
- package/kits/docs/evolcore/tool-authorization.md +5 -0
- package/kits/docs/evolcore/trigger.md +10 -0
- package/kits/eck_message_manifest.json +12 -0
- package/kits/provider-templates.json +1213 -0
- package/kits/rules/04-relation.md +3 -3
- package/kits/schemas/_meta.json +14 -2
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/ec-group/SKILL.md +2 -2
- package/kits/skills/ec-identity/SKILL.md +19 -72
- package/kits/skills/ec-provider/SKILL.md +221 -0
- package/kits/skills/ec-provider/scripts/check-model.mjs +80 -0
- package/kits/skills/ec-trigger/SKILL.md +1 -1
- package/kits/skills/thread-ops/SKILL.md +34 -21
- package/kits/templates/message-fragments/group-batch-item.md +1 -1
- package/kits/templates/message-fragments/group-batch.md +1 -1
- package/kits/templates/message-fragments/inject-default.md +1 -1
- package/kits/templates/message-fragments/interrupt-insert.md +1 -0
- package/kits/templates/message-fragments/item-group.md +1 -1
- package/kits/templates/message-fragments/item-private.md +1 -1
- package/kits/templates/message-fragments/thread-context.md +1 -1
- package/kits/templates/message-fragments/trigger-session.md +1 -1
- package/kits/templates/message-fragments/trigger-thread-check.md +1 -1
- package/kits/templates/roles/admin.json +2 -19
- package/kits/templates/roles/member.json +0 -3
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +3 -3
- package/kits/templates/system-fragments/managed-runtime.md +1 -1
- package/kits/templates/system-fragments/relation.md +1 -1
- package/kits/templates/system-fragments/thread.md +6 -5
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +4 -1
- package/scripts/agent-template/shared/common.mjs +2 -3
- package/scripts/agent-template/shared/template-contract.mjs +2 -1
- package/scripts/agent-template/shared/template-package.mjs +9 -2
- package/scripts/agent-template/shared/template-runtime.mjs +20 -5
- package/scripts/agent-template/team-pack.mjs +6 -3
- package/dist/cli/peer.js +0 -127
- package/dist/config/peer-operation-service.js +0 -132
- package/dist/config/peer-request-service.js +0 -532
- package/dist/core/command/connect-menu.js +0 -624
|
@@ -3,7 +3,7 @@ import { loadedBaseagentIds } from '../../agents/baseagent-availability.js';
|
|
|
3
3
|
import { grantSessionPath, listRuntimePathGrants, revokeSessionPath } from '../permission/session-path-grants.js';
|
|
4
4
|
import { closeDiagnosticSession, diagnosticTokenHash, isDiagnosticSessionActive } from './diag-service.js';
|
|
5
5
|
import { parseMenuClientArgs } from '../../cli/menu-client.js';
|
|
6
|
-
import {
|
|
6
|
+
import { ensureSessionRuntimeDirAsync } from '../../cli/task-context.js';
|
|
7
7
|
import { renderCommandCardAsText } from '../interaction-router.js';
|
|
8
8
|
import { buildEnvelope, deliveryTargetFromSession, isInteractionSendAccepted, replyContextFromSession, sendInteractionPayload } from '../message/message-utils.js';
|
|
9
9
|
import { sessionTopicThreadId } from '../thread/topic-id.js';
|
|
@@ -12,7 +12,7 @@ import { loadAgent, loadDaemonConfig } from '../../config-store.js';
|
|
|
12
12
|
import { parseOwnershipCommand, executeOwnershipCommand, ownershipFailure } from '../../aun/aid/ownership-operation.js';
|
|
13
13
|
import { ownerResolver, refreshOwnershipForAuthorization } from '../ownership/owner-resolver.js';
|
|
14
14
|
import { logger } from '../../utils/logger.js';
|
|
15
|
-
import { resolvePeerRoleDetail, roleToSessionIdentity } from '../../config/peer-role-resolver.js';
|
|
15
|
+
import { resolveFreshPeerRoleDetail, 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
18
|
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
@@ -41,7 +41,6 @@ import { DirectoryQueryError, executeDirectoryQueryCommand, resolveDirectoryQuer
|
|
|
41
41
|
import { executeDirectoryRequestCommand, resolveDirectoryRequestCommand, } from '../../directory/owner-directory-request-operation.js';
|
|
42
42
|
import { executeResolvedRoleCommand, resolveRoleCommand } from '../../config/role-command-service.js';
|
|
43
43
|
import { applyApprovedRoleAssignment } from './role-menu.js';
|
|
44
|
-
import { executeResolvedPeerCommand, resolvePeerCommand } from '../../config/peer-operation-service.js';
|
|
45
44
|
import { hasTrustedFullAccessDelegation, trustedExecutionIdentityInput } from '../auth/agent-delegation.js';
|
|
46
45
|
import { executeManagedAidOperation, ManagedAidOperationError, managedAidShowViewForRole, resolveManagedAidOperation, } from '../../aun/aid/managed-operation.js';
|
|
47
46
|
import { MAX_AVATAR_SOURCE_BYTES } from '../../utils/avatar-upload.js';
|
|
@@ -137,6 +136,7 @@ export class CommandHandler {
|
|
|
137
136
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Menu requests must use the current Agent identity and session' };
|
|
138
137
|
try {
|
|
139
138
|
const channelId = parsePeerKey(grant.peerKey).channelId;
|
|
139
|
+
const managedTempPath = argv.includes('--request-file') ? await this.getManagedSessionTempDir(session) : undefined;
|
|
140
140
|
const subject = buildAuthSubject({ selfAid: grant.selfAid, actorId: grant.actorId, channel: grant.channel,
|
|
141
141
|
channelType: grant.channelType, channelId, chatType: grant.chatType, conversationId: channelId,
|
|
142
142
|
processOwners: [], ...trustedExecutionIdentityInput(grant) });
|
|
@@ -147,7 +147,7 @@ export class CommandHandler {
|
|
|
147
147
|
return { ok: false, code: decision.code, error: decision.reason };
|
|
148
148
|
const options = parseMenuClientArgs(argv, file => {
|
|
149
149
|
const target = fs.realpathSync(path.resolve(session.projectPath, file));
|
|
150
|
-
const roots = [session.projectPath,
|
|
150
|
+
const roots = [session.projectPath, managedTempPath].filter((v) => !!v)
|
|
151
151
|
.map(root => fs.realpathSync(root));
|
|
152
152
|
if (!roots.some(root => isSameOrDescendant(target, root))
|
|
153
153
|
|| (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(target) || isLClassPath(target))))
|
|
@@ -270,7 +270,7 @@ export class CommandHandler {
|
|
|
270
270
|
}
|
|
271
271
|
/** Return the stable temporary root for a managed session, if available. */
|
|
272
272
|
getManagedSessionTempDir(session) {
|
|
273
|
-
return
|
|
273
|
+
return ensureSessionRuntimeDirAsync(session.id);
|
|
274
274
|
}
|
|
275
275
|
formatBaseagentUnavailable(error) {
|
|
276
276
|
const available = error.availableBaseagents.length ? error.availableBaseagents.join(', ') : '(none)';
|
|
@@ -790,6 +790,12 @@ export class CommandHandler {
|
|
|
790
790
|
updatedAt: now,
|
|
791
791
|
...(authorizedBy ? { authorizedBy } : {}),
|
|
792
792
|
origin,
|
|
793
|
+
...(channel !== 'daemon' ? { creator: {
|
|
794
|
+
actor: (await resolveFreshPeerRoleDetail({ selfAid: schedulerAid, channelKey: channel,
|
|
795
|
+
channelType: origin.channelType, chatType: originChatType, actorId: peerId,
|
|
796
|
+
conversationId: originConversationId })).actor,
|
|
797
|
+
chatType: originChatType, conversationId: originConversationId,
|
|
798
|
+
} } : {}),
|
|
793
799
|
source,
|
|
794
800
|
execution: {
|
|
795
801
|
type: parsed.executionType,
|
|
@@ -1084,8 +1090,7 @@ export class CommandHandler {
|
|
|
1084
1090
|
const item = {
|
|
1085
1091
|
value: sessionTopicThreadId(s) ?? '',
|
|
1086
1092
|
label: displayName,
|
|
1087
|
-
|
|
1088
|
-
topicStatus: s.topicStatus ?? 'pending',
|
|
1093
|
+
topicStatus: s.topicStatus ?? 'active',
|
|
1089
1094
|
};
|
|
1090
1095
|
const forkSource = buildTopicForkSourcePayload(s);
|
|
1091
1096
|
if (forkSource)
|
|
@@ -2027,69 +2032,8 @@ export class CommandHandler {
|
|
|
2027
2032
|
? { ok: true, result }
|
|
2028
2033
|
: { ok: false, code: result.code, error: result.error, ...(result.data !== undefined ? { data: result.data } : {}) };
|
|
2029
2034
|
}
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
if (!this.agentDelegationRegistry) {
|
|
2033
|
-
return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task delegation is not configured' };
|
|
2034
|
-
}
|
|
2035
|
-
const delegation = this.agentDelegationRegistry.validate(delegationToken, sessionId, delegationCommandHash);
|
|
2036
|
-
if (!delegation.ok)
|
|
2037
|
-
return { ok: false, code: delegation.code, error: delegation.reason };
|
|
2038
|
-
const session = await this.sessionManager.getSessionById(sessionId);
|
|
2039
|
-
if (!session)
|
|
2040
|
-
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2041
|
-
const grant = delegation.grant;
|
|
2042
|
-
let conversationId;
|
|
2043
|
-
try {
|
|
2044
|
-
conversationId = parsePeerKey(grant.peerKey).channelId;
|
|
2045
|
-
}
|
|
2046
|
-
catch {
|
|
2047
|
-
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2048
|
-
}
|
|
2049
|
-
const resolvedArgv = argv.includes('--self') ? argv : [...argv, '--self', grant.selfAid];
|
|
2050
|
-
const resolved = resolvePeerCommand(resolvedArgv);
|
|
2051
|
-
if (!resolved.ok)
|
|
2052
|
-
return { ok: false, code: resolved.code, error: resolved.reason };
|
|
2053
|
-
if (resolved.command.selfAid !== grant.selfAid && !hasTrustedFullAccessDelegation(grant)) {
|
|
2054
|
-
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Only the current Agent contact book can be targeted' };
|
|
2055
|
-
}
|
|
2056
|
-
const primaryId = 'primaryId' in resolved.command ? resolved.command.primaryId : undefined;
|
|
2057
|
-
const subject = buildAuthSubject({
|
|
2058
|
-
selfAid: grant.selfAid,
|
|
2059
|
-
actorId: grant.actorId,
|
|
2060
|
-
channel: grant.channel,
|
|
2061
|
-
channelType: grant.channelType,
|
|
2062
|
-
channelId: conversationId,
|
|
2063
|
-
chatType: grant.chatType,
|
|
2064
|
-
conversationId,
|
|
2065
|
-
processOwners: ownerResolver.daemonOwners(),
|
|
2066
|
-
...trustedExecutionIdentityInput(grant),
|
|
2067
|
-
});
|
|
2068
|
-
const decision = await authorizeFreshOperation({
|
|
2069
|
-
source: 'agent-tool',
|
|
2070
|
-
subject,
|
|
2071
|
-
intent: {
|
|
2072
|
-
operation: resolved.command.operationId,
|
|
2073
|
-
scope: 'agent',
|
|
2074
|
-
source: 'agent-tool',
|
|
2075
|
-
args: {
|
|
2076
|
-
self: resolved.command.selfAid,
|
|
2077
|
-
targetAgentAid: resolved.command.selfAid,
|
|
2078
|
-
...(primaryId ? { primaryId } : {}),
|
|
2079
|
-
},
|
|
2080
|
-
},
|
|
2081
|
-
auditMetadata: {
|
|
2082
|
-
argvHash: hashArgv(resolved.command.canonicalArgv),
|
|
2083
|
-
taskId: grant.taskId,
|
|
2084
|
-
messageId: grant.messageId,
|
|
2085
|
-
},
|
|
2086
|
-
});
|
|
2087
|
-
if (!decision.allow)
|
|
2088
|
-
return { ok: false, code: decision.code, error: decision.reason };
|
|
2089
|
-
const result = await executeResolvedPeerCommand(resolved.command, grant.actorId);
|
|
2090
|
-
return result.ok
|
|
2091
|
-
? { ok: true, result }
|
|
2092
|
-
: { ok: false, code: result.code, error: result.error, ...(result.data ? { data: result.data } : {}) };
|
|
2035
|
+
async handleContactOperation(_argv, _sessionId, _delegationToken, _delegationCommandHash) {
|
|
2036
|
+
return { ok: false, code: 'NOT_SUPPORTED', error: 'peer has been retired; use directory' };
|
|
2093
2037
|
}
|
|
2094
2038
|
/** Agent-managed AID CLI entrypoint. Private key and CA access stay inside the daemon. */
|
|
2095
2039
|
async handleOwnershipOperation(argv, sessionId, delegationToken, delegationCommandHash) {
|
|
@@ -2160,11 +2104,28 @@ export class CommandHandler {
|
|
|
2160
2104
|
}
|
|
2161
2105
|
}
|
|
2162
2106
|
/**
|
|
2163
|
-
* Agent-managed role
|
|
2164
|
-
*
|
|
2165
|
-
* what actually applies the relation role.
|
|
2107
|
+
* Agent-managed role CLI. Quota policy uses the common authorization path;
|
|
2108
|
+
* the existing request workflow retains its Owner approval checks.
|
|
2166
2109
|
*/
|
|
2167
|
-
async handleRoleOperation(argv, sessionId, delegationToken, delegationCommandHash) {
|
|
2110
|
+
async handleRoleOperation(argv, sessionId, delegationToken, delegationCommandHash, localControl = false) {
|
|
2111
|
+
if (localControl) {
|
|
2112
|
+
const resolved = resolveRoleCommand(argv);
|
|
2113
|
+
if (!resolved.ok)
|
|
2114
|
+
return { ok: false, code: resolved.code, error: resolved.reason };
|
|
2115
|
+
if (resolved.command.kind !== 'quota') {
|
|
2116
|
+
return { ok: false, code: 'NOT_ALLOWED', error: 'Host control role operations support quota commands only' };
|
|
2117
|
+
}
|
|
2118
|
+
try {
|
|
2119
|
+
const result = await executeResolvedRoleCommand(resolved.command, 'local-cli', applyApprovedRoleAssignment, {
|
|
2120
|
+
self: resolved.command.selfAid, actorRole: 'none', actorAid: 'local-cli',
|
|
2121
|
+
isDaemonOwner: true, fromControlChannel: true, chatType: 'private',
|
|
2122
|
+
});
|
|
2123
|
+
return result.ok ? { ok: true, result } : result;
|
|
2124
|
+
}
|
|
2125
|
+
catch (error) {
|
|
2126
|
+
return { ok: false, code: error?.code ?? 'ROLE_OPERATION_FAILED', error: error?.message ?? String(error), data: error?.data };
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2168
2129
|
if (!this.agentDelegationRegistry) {
|
|
2169
2130
|
return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task delegation is not configured' };
|
|
2170
2131
|
}
|
|
@@ -2175,21 +2136,55 @@ export class CommandHandler {
|
|
|
2175
2136
|
if (!session)
|
|
2176
2137
|
return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
|
|
2177
2138
|
const grant = delegation.grant;
|
|
2139
|
+
if (session.selfAID !== grant.selfAid || grant.sessionId !== sessionId) {
|
|
2140
|
+
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation does not match the current session' };
|
|
2141
|
+
}
|
|
2178
2142
|
const resolvedArgv = argv.includes('--self') ? argv : [...argv, '--self', grant.selfAid];
|
|
2179
2143
|
const resolved = resolveRoleCommand(resolvedArgv);
|
|
2180
2144
|
if (!resolved.ok)
|
|
2181
2145
|
return { ok: false, code: resolved.code, error: resolved.reason };
|
|
2182
|
-
|
|
2146
|
+
const command = resolved.command;
|
|
2147
|
+
if (command.selfAid !== grant.selfAid && command.kind !== 'quota') {
|
|
2183
2148
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Only the current Agent role requests can be targeted' };
|
|
2184
2149
|
}
|
|
2185
2150
|
try {
|
|
2186
|
-
|
|
2151
|
+
if (command.kind === 'quota') {
|
|
2152
|
+
const conversationId = parsePeerKey(grant.peerKey).channelId;
|
|
2153
|
+
const subject = buildAuthSubject({
|
|
2154
|
+
selfAid: grant.selfAid, sessionId, actorId: grant.actorId,
|
|
2155
|
+
channel: grant.channel, channelType: grant.channelType, channelId: conversationId,
|
|
2156
|
+
chatType: grant.chatType, conversationId, processOwners: ownerResolver.daemonOwners(),
|
|
2157
|
+
...trustedExecutionIdentityInput(grant),
|
|
2158
|
+
});
|
|
2159
|
+
if (command.selfAid !== grant.selfAid && !subject.isDaemonOwner && !hasTrustedFullAccessDelegation(grant)) {
|
|
2160
|
+
return { ok: false, code: 'SCOPE_MISMATCH', error: 'A different Agent requires DaemonOwner authorization or trusted fullaccess' };
|
|
2161
|
+
}
|
|
2162
|
+
return await executeAuditedOperation({
|
|
2163
|
+
source: 'agent-tool', subject,
|
|
2164
|
+
intent: {
|
|
2165
|
+
operation: command.action === 'show' ? 'role.policy.read' : 'role.policy.write',
|
|
2166
|
+
scope: 'agent', source: 'agent-tool',
|
|
2167
|
+
args: { self: command.selfAid, targetAgentAid: command.selfAid, roleId: command.roleId },
|
|
2168
|
+
},
|
|
2169
|
+
auditMetadata: { argvHash: hashArgv(command.canonicalArgv), taskId: grant.taskId, messageId: grant.messageId },
|
|
2170
|
+
}, async (onExecutionStarted) => {
|
|
2171
|
+
onExecutionStarted();
|
|
2172
|
+
const result = await executeResolvedRoleCommand(command, grant.actorId, applyApprovedRoleAssignment, {
|
|
2173
|
+
self: command.selfAid, actorRole: subject.role, actorAid: subject.principalId ?? subject.actorId,
|
|
2174
|
+
chatType: grant.chatType,
|
|
2175
|
+
isDaemonOwner: subject.isDaemonOwner, fromControlChannel: subject.fromControlChannel,
|
|
2176
|
+
trustedFullAccess: subject.processRole === 'fullaccess-run' && subject.dataScope === 'daemon',
|
|
2177
|
+
});
|
|
2178
|
+
return result.ok ? { ok: true, result } : result;
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
const result = await executeResolvedRoleCommand(command, grant.actorId, applyApprovedRoleAssignment);
|
|
2187
2182
|
if (!result.ok)
|
|
2188
2183
|
return { ok: false, code: result.code, error: result.error, data: result.data };
|
|
2189
2184
|
return { ok: true, result };
|
|
2190
2185
|
}
|
|
2191
2186
|
catch (error) {
|
|
2192
|
-
return { ok: false, code: 'ROLE_OPERATION_FAILED', error: error?.message ?? String(error) };
|
|
2187
|
+
return { ok: false, code: error?.code ?? 'ROLE_OPERATION_FAILED', error: error?.message ?? String(error), data: error?.data };
|
|
2193
2188
|
}
|
|
2194
2189
|
}
|
|
2195
2190
|
/**
|
|
@@ -2239,7 +2234,8 @@ export class CommandHandler {
|
|
|
2239
2234
|
if (isRequest && targetAid !== grantSelfAid) {
|
|
2240
2235
|
return { ok: false, code: 'SCOPE_MISMATCH', error: '加好友申请只能由当前任务所属 Agent 发起' };
|
|
2241
2236
|
}
|
|
2242
|
-
const operation = isRequest ? 'ec.directory.request'
|
|
2237
|
+
const operation = isRequest ? 'ec.directory.request'
|
|
2238
|
+
: ['block', 'unblock'].includes(subArgv[0]) ? 'ec.directory.block' : 'ec.directory.query';
|
|
2243
2239
|
const subject = buildAuthSubject({
|
|
2244
2240
|
selfAid: grantSelfAid,
|
|
2245
2241
|
sessionId,
|
|
@@ -2309,7 +2305,7 @@ export class CommandHandler {
|
|
|
2309
2305
|
return { ok: false, code: 'SCOPE_MISMATCH', error: 'Resolved Agent target does not match the authorized target' };
|
|
2310
2306
|
}
|
|
2311
2307
|
onExecutionStarted();
|
|
2312
|
-
const result = await executeDirectoryQueryCommand(command);
|
|
2308
|
+
const result = await executeDirectoryQueryCommand(command, subject.principalId ?? subject.actorId);
|
|
2313
2309
|
return result.ok
|
|
2314
2310
|
? { ok: true, result }
|
|
2315
2311
|
: { ok: false, code: result.code, error: result.error };
|
|
@@ -2340,6 +2336,8 @@ export class CommandHandler {
|
|
|
2340
2336
|
catch {
|
|
2341
2337
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2342
2338
|
}
|
|
2339
|
+
const managedTempPath = parsed.command.kind === 'avatar' && parsed.command.filePath
|
|
2340
|
+
? await this.getManagedSessionTempDir(session) : undefined;
|
|
2343
2341
|
const subject = buildAuthSubject({
|
|
2344
2342
|
selfAid: delegation.grant.selfAid,
|
|
2345
2343
|
sessionId,
|
|
@@ -2376,9 +2374,9 @@ export class CommandHandler {
|
|
|
2376
2374
|
taskId: delegation.grant.taskId,
|
|
2377
2375
|
messageId: delegation.grant.messageId,
|
|
2378
2376
|
},
|
|
2379
|
-
}, onExecutionStarted => this.executeAuthorizedAidOperation(parsed.command, session, subject, delegation.grant, onExecutionStarted));
|
|
2377
|
+
}, onExecutionStarted => this.executeAuthorizedAidOperation(parsed.command, session, subject, delegation.grant, onExecutionStarted, managedTempPath));
|
|
2380
2378
|
}
|
|
2381
|
-
async executeAuthorizedAidOperation(command, session, subject, grant, onExecutionStarted) {
|
|
2379
|
+
async executeAuthorizedAidOperation(command, session, subject, grant, onExecutionStarted, managedTempPath) {
|
|
2382
2380
|
const grantSelfAid = grant.selfAid.replace(/^@/, '');
|
|
2383
2381
|
let avatarBuffer;
|
|
2384
2382
|
if (command.kind === 'avatar' && command.filePath) {
|
|
@@ -2387,7 +2385,6 @@ export class CommandHandler {
|
|
|
2387
2385
|
return { ok: false, code: 'INVALID_AVATAR_PATH', error: 'Avatar file requires a current session project path' };
|
|
2388
2386
|
}
|
|
2389
2387
|
const projectPath = path.resolve(session.projectPath);
|
|
2390
|
-
const managedTempPath = this.getManagedSessionTempDir(session);
|
|
2391
2388
|
const resolvedPath = path.isAbsolute(filePath) ? path.resolve(filePath) : path.resolve(projectPath, filePath);
|
|
2392
2389
|
// 对端发来的图片按原有机制落在本 Agent 的关系附件目录;直接引用原文件,
|
|
2393
2390
|
// 不要求先复制到项目里。只放开本 Agent 自己的目录,其它 Agent 的不在其中。
|
|
@@ -2514,6 +2511,7 @@ export class CommandHandler {
|
|
|
2514
2511
|
catch {
|
|
2515
2512
|
return { ok: false, code: 'INVALID_DELEGATION', error: 'Delegation contains an invalid relation key' };
|
|
2516
2513
|
}
|
|
2514
|
+
const managedTempPath = parsed.command.kind === 'rules.set' ? await this.getManagedSessionTempDir(session) : undefined;
|
|
2517
2515
|
const subject = buildAuthSubject({
|
|
2518
2516
|
selfAid: grant.selfAid,
|
|
2519
2517
|
actorId: grant.actorId,
|
|
@@ -2572,7 +2570,6 @@ export class CommandHandler {
|
|
|
2572
2570
|
const filePath = String(parsed.command.filePath || '');
|
|
2573
2571
|
const projectPath = path.resolve(session.projectPath);
|
|
2574
2572
|
const resolvedPath = path.resolve(projectPath, filePath);
|
|
2575
|
-
const managedTempPath = this.getManagedSessionTempDir(session);
|
|
2576
2573
|
const allowedPaths = [projectPath, managedTempPath].filter((value) => !!value);
|
|
2577
2574
|
if (!filePath || !allowedPaths.some(root => isSameOrDescendant(resolvedPath, root))) {
|
|
2578
2575
|
return { ok: false, code: 'INVALID_RULES_PATH', error: 'Rules file must be inside the current session project or managed TMPDIR' };
|
|
@@ -2897,6 +2894,7 @@ export class CommandHandler {
|
|
|
2897
2894
|
: actorAid;
|
|
2898
2895
|
const relationTarget = currentGroup
|
|
2899
2896
|
?? (grant.channelType === 'aun' && grant.chatType === 'private' ? relationId : undefined);
|
|
2897
|
+
const managedTempPath = parsed.command.kind === 'upload' ? await this.getManagedSessionTempDir(session) : undefined;
|
|
2900
2898
|
const subject = buildAuthSubject({
|
|
2901
2899
|
selfAid: grant.selfAid,
|
|
2902
2900
|
actorId: grant.actorId,
|
|
@@ -2948,7 +2946,6 @@ export class CommandHandler {
|
|
|
2948
2946
|
if (!localPath)
|
|
2949
2947
|
return { ok: false, code: 'INVALID_ARGUMENT', error: 'Managed upload source is required' };
|
|
2950
2948
|
const resolvedPath = path.resolve(projectPath, localPath);
|
|
2951
|
-
const managedTempPath = this.getManagedSessionTempDir(session);
|
|
2952
2949
|
const allowedRoots = [projectPath, managedTempPath].filter((value) => !!value);
|
|
2953
2950
|
if (!allowedRoots.some(root => isSameOrDescendant(resolvedPath, root))) {
|
|
2954
2951
|
return { ok: false, code: 'INVALID_LOCAL_PATH', error: 'Upload source must be inside the current session project or managed TMPDIR' };
|
|
@@ -3036,7 +3033,6 @@ export class CommandHandler {
|
|
|
3036
3033
|
threadId: topic.threadId,
|
|
3037
3034
|
name: topic.name,
|
|
3038
3035
|
topicStatus: topic.topicStatus,
|
|
3039
|
-
label: topic.label ?? null,
|
|
3040
3036
|
},
|
|
3041
3037
|
currentSummary: service.showSummary(input.selfAid, topic.sessionId) ?? null,
|
|
3042
3038
|
summaries,
|
|
@@ -70,6 +70,7 @@ const ENTRIES = [
|
|
|
70
70
|
{ id: 'event.register', type: 'setting', contexts: ['agent'], name: 'events', label: '事件注册', section: 'agent', order: 82.5, query: { cmd: '/events', args: { view: 'register' }, operation: 'event.register.list', scope: 'agent' }, update: { cmd: '/events', args: { resource: 'register' }, operation: 'event.register.update', scope: 'agent' }, valueSchema: { type: 'object' }, control: 'json' },
|
|
71
71
|
{ id: 'event.subscribers', type: 'list', contexts: ['agent'], name: 'events', label: '事件订阅者', section: 'agent', order: 82.6, query: { cmd: '/events', args: { view: 'subscribers' }, operation: 'event.subscribers.list', scope: 'agent' }, control: 'list' },
|
|
72
72
|
{ id: 'provider.list', type: 'list', contexts: ['process'], name: 'provider', label: 'Provider 注册表', section: 'process', order: 80, query: { cmd: '/provider', args: { scope: 'process', view: 'list' }, operation: 'provider.list', scope: 'process' }, control: 'list' },
|
|
73
|
+
{ id: 'provider.templates', type: 'list', contexts: ['process'], name: 'provider', label: '内置服务商模板', section: 'process', order: 80.5, query: { cmd: '/provider', args: { scope: 'process', view: 'templates' }, operation: 'provider.templates', scope: 'process' }, control: 'list' },
|
|
73
74
|
{ id: 'provider.create', type: 'action', contexts: ['process'], name: 'provider', label: '创建 Provider', section: 'process', order: 81, action: { cmd: '/provider', action: 'create', args: { scope: 'process' }, operation: 'provider.create', scope: 'process' } },
|
|
74
75
|
{ id: 'provider.import', type: 'action', contexts: ['process'], name: 'provider', label: '导入 Provider JSON', section: 'process', order: 82, action: { cmd: '/provider', action: 'import', args: { scope: 'process' }, operation: 'provider.import', scope: 'process' } },
|
|
75
76
|
{ id: 'provider.update', type: 'setting', contexts: ['process'], name: 'provider', label: '更新 Provider', section: 'process', order: 83, update: { cmd: '/provider', args: { scope: 'process', resource: 'provider' }, operation: 'provider.update', scope: 'process' }, valueSchema: { type: 'string' }, control: 'json' },
|