evolcore 0.0.47 → 0.0.49
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 +90 -1
- package/bin/ec-build.mjs +86 -0
- package/dist/agent-template/jobs.js +12 -4
- package/dist/agent-template/runtime.js +143 -40
- package/dist/agent-template/service.js +66 -13
- package/dist/agents/baseagent.js +60 -20
- package/dist/agents/claude-runner.js +34 -17
- package/dist/agents/codex-runner.js +36 -17
- 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/msg/p2p.js +2 -1
- package/dist/aun/service-proxy.js +4 -2
- package/dist/build-identity.json +1 -0
- package/dist/channels/aun.js +722 -295
- package/dist/channels/daemon.js +9 -25
- 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 +44 -43
- package/dist/cli/directory.js +13 -2
- package/dist/cli/ecmsg-gateway.js +5 -2
- package/dist/cli/index.js +9 -9
- package/dist/cli/init-channel.js +4 -6
- package/dist/cli/init.js +72 -50
- package/dist/cli/invoke-command.js +1 -1
- package/dist/cli/managed-command-guard.js +2 -0
- package/dist/cli/model.js +20 -5
- package/dist/cli/provider-command.js +74 -13
- package/dist/cli/quota.js +89 -0
- package/dist/cli/role.js +62 -17
- package/dist/cli/services-command.js +1 -0
- package/dist/cli/stats.js +3 -3
- package/dist/cli/team-workspace-command.js +56 -2
- package/dist/cli/thread-command.js +16 -51
- package/dist/config/boot-log.js +3 -9
- package/dist/config/builtin-roles.js +5 -7
- package/dist/config/config-field-policy.js +71 -1
- package/dist/config/config-manager.js +13 -7
- 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 +62 -229
- package/dist/config/peer-book.js +26 -27
- package/dist/config/peer-role-resolver.js +16 -1
- package/dist/config/provider-identity-migration.js +4 -1
- 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 +67 -12
- package/dist/config/providers-management.js +477 -51
- package/dist/config/resolved-config-op.js +3 -2
- package/dist/config/role-command-service.js +248 -1
- package/dist/config/schema-migration.js +105 -4
- package/dist/core/agent-application-service.js +6 -1
- package/dist/core/agent-runtime.js +4 -0
- package/dist/core/auth/agent-delegation.js +2 -1
- package/dist/core/auth/auth-gateway.js +2 -1
- package/dist/core/auth/delegation-authorization.js +36 -26
- package/dist/core/auth/operation-authorizer.js +25 -0
- package/dist/core/auth/operation-catalog.js +37 -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/cli-intent-parser.js +13 -0
- package/dist/core/command/command-handler.js +126 -87
- package/dist/core/command/menu-catalog.js +1 -0
- package/dist/core/command/menu-handler.js +67 -150
- package/dist/core/command/menu-protocol.js +31 -1
- package/dist/core/command/provider-menu.js +13 -3
- package/dist/core/command/remote-shell.js +565 -0
- package/dist/core/command/role-menu.js +47 -23
- package/dist/core/command/slash-handler.js +26 -43
- 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 +8 -1
- package/dist/core/daemon-control.js +64 -8
- package/dist/core/daemon-lifecycle.js +16 -2
- package/dist/core/evolagent-registry.js +20 -3
- package/dist/core/file-integrity/store.js +2 -0
- package/dist/core/handoff/runtime.js +37 -1
- package/dist/core/inference/text-inference.js +3 -1
- package/dist/core/initialization/service.js +11 -6
- package/dist/core/interaction-router.js +3 -0
- package/dist/core/invoke/executors/text.js +72 -19
- package/dist/core/ipc-registration.js +3 -1
- package/dist/core/message/aun-ipc-sender.js +279 -107
- package/dist/core/message/contact-admission.js +91 -6
- package/dist/core/message/contact-pending-inbound.js +113 -0
- package/dist/core/message/contact-thread-approval.js +212 -0
- package/dist/core/message/im-renderer.js +41 -2
- package/dist/core/message/message-admission.js +5 -39
- package/dist/core/message/message-bridge.js +140 -370
- package/dist/core/message/message-log.js +29 -0
- package/dist/core/message/message-queue.js +119 -15
- package/dist/core/message/message-utils.js +8 -0
- package/dist/core/message/response-engine.js +580 -134
- package/dist/core/message/send-routing.js +5 -1
- package/dist/core/model/catalog-service.js +31 -11
- package/dist/core/model/config-scope.js +6 -14
- package/dist/core/model/model-capabilities.js +22 -4
- package/dist/core/model/model-catalog.js +1 -0
- package/dist/core/model/model-diagnostics.js +19 -0
- package/dist/core/model/model-fallback.js +13 -2
- package/dist/core/ownership/owner-resolver.js +328 -50
- package/dist/core/pack-auth.js +3 -0
- package/dist/core/pack-install.js +1 -1
- package/dist/core/permission/ec-command-parser.js +106 -19
- package/dist/core/permission/protected-paths.js +6 -6
- package/dist/core/permission/services-path-acl.js +451 -0
- package/dist/core/permission/tool-policy.js +5 -1
- package/dist/core/relation/peer-identity.js +36 -1
- package/dist/core/relation/same-owner-proof.js +81 -112
- package/dist/core/session/adapters/codex-session-file-adapter.js +96 -15
- package/dist/core/session/session-file-health.js +13 -7
- 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-recovery-service.js +13 -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/core/thread/topic-id.js +15 -0
- package/dist/directory/owner-directory-admission.js +12 -9
- package/dist/directory/owner-directory-cache.js +64 -28
- package/dist/directory/owner-directory-markdown.js +14 -2
- package/dist/directory/owner-directory-policy.js +5 -30
- package/dist/directory/owner-directory-query-operation.js +29 -3
- package/dist/directory/owner-directory-remarks.js +11 -3
- package/dist/directory/owner-directory-request-operation.js +5 -2
- package/dist/eck/kit-renderer.js +1 -1
- package/dist/eck/message-renderer.js +112 -29
- 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 +18 -8
- package/dist/ecweb/runtime/proxy-access.js +74 -0
- package/dist/ecweb/runtime/supervisor.js +36 -6
- package/dist/event-center/center-config.js +9 -5
- package/dist/event-center/dispatcher.js +10 -1
- package/dist/event-center/ipc-operation.js +19 -0
- package/dist/event-center/registry.js +29 -3
- package/dist/event-center/runtime.js +106 -11
- package/dist/event-center/script-runner.js +5 -5
- package/dist/index.js +96 -59
- package/dist/ipc.js +38 -3
- package/dist/outputs/authorization.js +16 -0
- package/dist/outputs/cards.js +336 -0
- package/dist/outputs/events.js +63 -0
- package/dist/outputs/protocol.js +103 -0
- package/dist/outputs/service.js +266 -0
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +43 -13
- package/dist/services/index.js +114 -5
- package/dist/services/ipc-operation.js +88 -15
- package/dist/services/pack-manager.js +13 -1
- package/dist/services/router.js +21 -6
- package/dist/services/script-runner.js +5 -4
- package/dist/services/service-payload.js +13 -7
- package/dist/services/validation.js +1 -1
- package/dist/stats/budget.js +2 -2
- package/dist/stats/db.js +19 -0
- package/dist/stats/index.js +1 -1
- package/dist/stats/{price-resolver.js → model-resolver.js} +304 -23
- package/dist/stats/normalizer.js +2 -0
- package/dist/stats/query.js +35 -27
- package/dist/stats/quota-query.js +95 -0
- 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 +7 -5
- package/dist/trigger/script-executor.js +2 -1
- package/dist/trigger/script-sandbox.js +21 -3
- package/dist/trigger/validation.js +22 -0
- package/dist/utils/atomic-write.js +22 -8
- package/dist/utils/cross-platform.js +73 -26
- package/dist/utils/error-dict.json +94 -4
- package/dist/utils/error-utils.js +27 -4
- package/dist/utils/evolcore-version.js +36 -65
- package/dist/utils/host-info.js +100 -1
- package/dist/utils/msg-diag.js +1 -0
- package/dist/utils/npm-ops.js +43 -8
- package/dist/utils/process-introspect.js +12 -7
- package/dist/utils/process-tree.js +50 -2
- 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 +4 -2
- package/kits/docs/evolcore/aid.md +25 -0
- package/kits/docs/evolcore/config.md +16 -1
- package/kits/docs/evolcore/directory.md +30 -12
- package/kits/docs/evolcore/ecweb-lifecycle.md +15 -0
- package/kits/docs/evolcore/model.md +10 -0
- package/kits/docs/evolcore/msg.md +9 -0
- package/kits/docs/evolcore/peer.md +19 -65
- package/kits/docs/evolcore/provider.md +124 -4
- package/kits/docs/evolcore/quota.md +54 -0
- package/kits/docs/evolcore/role.md +83 -0
- package/kits/docs/evolcore/services.md +6 -6
- package/kits/docs/evolcore/stats.md +2 -0
- 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 +12 -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/agent-config.schema.20.json +24 -0
- package/kits/schemas/contact-book.schema.4.json +52 -0
- package/kits/schemas/providers.schema.3.json +200 -0
- package/kits/skills/.switches.json +8 -0
- package/kits/skills/ability/references/calling.md +1 -1
- package/kits/skills/agent-output-cards/SKILL.md +57 -0
- 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 +270 -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/roles/visitor.json +1 -0
- package/kits/templates/system-fragments/baseagent.md +6 -0
- package/kits/templates/system-fragments/commands.md +4 -3
- package/kits/templates/system-fragments/directory-contacts.md +3 -4
- 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 +7 -5
- package/kits/templates/system-fragments/venue.md +11 -0
- package/package.json +6 -4
- package/scripts/agent-template/inspect.mjs +50 -11
- package/scripts/agent-template/shared/common.mjs +11 -6
- package/scripts/agent-template/shared/team-schema.json +6 -4
- package/scripts/agent-template/shared/template-contract.mjs +62 -11
- package/scripts/agent-template/shared/template-package.mjs +189 -21
- package/scripts/agent-template/shared/template-runtime.mjs +54 -6
- package/scripts/agent-template/shared/template.mjs +2 -2
- package/scripts/agent-template/team-pack.mjs +52 -14
- 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
|
@@ -144,18 +144,26 @@ const QUEUE_OPERATIONS = [['read', 'Read the current Agent message queue'], ['cl
|
|
|
144
144
|
*
|
|
145
145
|
* 参照设计文档 docs/command-execution-role-permission-design.md 第 5 节
|
|
146
146
|
*/
|
|
147
|
-
const PROVIDER_OPERATIONS = ['list', 'show', 'create', 'import', 'update', 'delete', 'sync'].map(action => ({
|
|
147
|
+
const PROVIDER_OPERATIONS = ['list', 'show', 'templates', 'create', 'import', 'update', 'delete', 'sync'].map(action => ({
|
|
148
148
|
id: 'provider.' + action,
|
|
149
|
-
category:
|
|
150
|
-
dangerous:
|
|
149
|
+
category: ['list', 'show', 'templates'].includes(action) ? 'read' : 'process',
|
|
150
|
+
dangerous: !['list', 'show', 'templates'].includes(action),
|
|
151
151
|
defaultScopes: ['process'],
|
|
152
152
|
description: 'Manage the daemon Provider registry: ' + action,
|
|
153
153
|
sources: action === 'sync' ? ['control']
|
|
154
|
-
:
|
|
154
|
+
: ['list', 'show', 'templates'].includes(action) ? ['menu', 'control', 'ecweb', 'agent-tool'] : ['menu', 'control', 'ecweb'],
|
|
155
155
|
authorizationPolicy: { authority: 'daemon-owner', scope: 'process', channel: 'control',
|
|
156
|
-
allowDelegatedRead:
|
|
156
|
+
allowDelegatedRead: ['list', 'show', 'templates'].includes(action) },
|
|
157
157
|
}));
|
|
158
158
|
const OPERATIONS = [
|
|
159
|
+
{ id: 'invoke.execute', category: 'process', dangerous: false, defaultScopes: ['process'],
|
|
160
|
+
description: 'Invoke an already configured Provider', sources: ['agent-tool', 'control'],
|
|
161
|
+
authorizationPolicy: { authority: 'daemon-owner', scope: 'process', channel: 'control', allowDelegatedRead: true } },
|
|
162
|
+
{
|
|
163
|
+
id: 'provider.connection.repair', category: 'process', dangerous: true, defaultScopes: ['process'],
|
|
164
|
+
description: 'Submit a daemon-bound Provider connection repair card', sources: ['menu'],
|
|
165
|
+
requiredChannelType: 'aun', requiredChatType: 'private',
|
|
166
|
+
},
|
|
159
167
|
...[
|
|
160
168
|
['event.center.current', 'Read event center status'],
|
|
161
169
|
['event.center.update', 'Update event center status'],
|
|
@@ -712,7 +720,7 @@ const OPERATIONS = [
|
|
|
712
720
|
category: 'write-agent',
|
|
713
721
|
dangerous: false,
|
|
714
722
|
defaultScopes: ['agent'],
|
|
715
|
-
description: 'Assign
|
|
723
|
+
description: 'Assign an existing role to defaults or a private or group relation',
|
|
716
724
|
sources: ['menu', 'menu.cli', 'ecweb', 'control', 'agent-tool'],
|
|
717
725
|
},
|
|
718
726
|
{
|
|
@@ -729,7 +737,7 @@ const OPERATIONS = [
|
|
|
729
737
|
dangerous: false,
|
|
730
738
|
defaultScopes: ['agent'],
|
|
731
739
|
description: 'Read role definitions, command permissions, default roles, and usage limits',
|
|
732
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
740
|
+
sources: ['menu', 'ecweb', 'control', 'agent-tool'],
|
|
733
741
|
},
|
|
734
742
|
{
|
|
735
743
|
id: 'role.relation.read',
|
|
@@ -744,73 +752,29 @@ const OPERATIONS = [
|
|
|
744
752
|
category: 'write-agent',
|
|
745
753
|
dangerous: true,
|
|
746
754
|
defaultScopes: ['agent'],
|
|
747
|
-
description: '
|
|
748
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
id: 'peer.read',
|
|
752
|
-
category: 'read',
|
|
753
|
-
dangerous: false,
|
|
754
|
-
defaultScopes: ['agent'],
|
|
755
|
-
description: 'Read the Agent peer registry and locally blocked peers',
|
|
756
|
-
sources: ['agent-tool'],
|
|
755
|
+
description: 'Manage role definitions, command permissions, and usage limits (DaemonOwner)',
|
|
756
|
+
sources: ['menu', 'ecweb', 'control', 'agent-tool'],
|
|
757
757
|
},
|
|
758
758
|
{
|
|
759
|
-
id: '
|
|
759
|
+
id: 'ec.directory.block',
|
|
760
760
|
category: 'write-agent',
|
|
761
761
|
dangerous: false,
|
|
762
762
|
defaultScopes: ['agent'],
|
|
763
|
-
description: '
|
|
763
|
+
description: 'Manage the Agent local blacklist',
|
|
764
764
|
sources: ['agent-tool'],
|
|
765
|
+
authorizationTarget: 'current-agent',
|
|
766
|
+
authorizationPolicy: { authority: 'agent-owner', permissionMode: 'bypass', mode: 'require' },
|
|
765
767
|
},
|
|
766
|
-
{
|
|
767
|
-
id: '
|
|
768
|
-
category: 'read',
|
|
769
|
-
dangerous: false,
|
|
770
|
-
defaultScopes: ['agent'],
|
|
771
|
-
description: 'Read contacts, groups, assignments, or contact details',
|
|
772
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
id: 'connect.assign',
|
|
776
|
-
category: 'write-agent',
|
|
777
|
-
dangerous: false,
|
|
778
|
-
defaultScopes: ['agent'],
|
|
779
|
-
description: 'Assign a role to a relation',
|
|
780
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
id: 'connect.revoke',
|
|
784
|
-
category: 'write-agent',
|
|
785
|
-
dangerous: false,
|
|
786
|
-
defaultScopes: ['agent'],
|
|
787
|
-
description: 'Revoke a role assignment from a relation',
|
|
788
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
id: 'connect.admin',
|
|
792
|
-
category: 'write-agent',
|
|
793
|
-
dangerous: false,
|
|
794
|
-
defaultScopes: ['agent'],
|
|
795
|
-
description: 'Grant or revoke admin status',
|
|
796
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
id: 'connect.write',
|
|
800
|
-
category: 'write-agent',
|
|
768
|
+
...['read', 'write'].map(action => ({
|
|
769
|
+
id: 'agent.access.' + action,
|
|
770
|
+
category: action === 'read' ? 'read' : 'write-agent',
|
|
801
771
|
dangerous: false,
|
|
802
772
|
defaultScopes: ['agent'],
|
|
803
|
-
description: '
|
|
773
|
+
description: 'Read or modify the Agent access policy',
|
|
804
774
|
sources: ['menu', 'ecweb', 'control'],
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
category: 'write-agent',
|
|
809
|
-
dangerous: false,
|
|
810
|
-
defaultScopes: ['agent'],
|
|
811
|
-
description: 'Manage owner-only Agent access policy and request limit settings',
|
|
812
|
-
sources: ['menu', 'ecweb', 'control'],
|
|
813
|
-
},
|
|
775
|
+
authorizationTarget: 'current-agent',
|
|
776
|
+
minimumAgentRole: 'owner',
|
|
777
|
+
})),
|
|
814
778
|
// Agent Operations
|
|
815
779
|
{
|
|
816
780
|
id: 'agent.list',
|
|
@@ -1060,6 +1024,15 @@ const OPERATIONS = [
|
|
|
1060
1024
|
authorizationPolicy: { authority: 'trusted-fullaccess' },
|
|
1061
1025
|
},
|
|
1062
1026
|
// ── Stats Operations ──
|
|
1027
|
+
{
|
|
1028
|
+
id: 'quota.read',
|
|
1029
|
+
category: 'read',
|
|
1030
|
+
dangerous: false,
|
|
1031
|
+
defaultScopes: ['relation'],
|
|
1032
|
+
description: '查询 Agent 与当前关系的生效额度及余额',
|
|
1033
|
+
sources: ['agent-tool'],
|
|
1034
|
+
authorizationTarget: 'current-agent',
|
|
1035
|
+
},
|
|
1063
1036
|
{
|
|
1064
1037
|
id: 'stats.summary',
|
|
1065
1038
|
category: 'read',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { execCodexCli } from '../../../agents/baseagent.js';
|
|
4
4
|
import { discoverSkillDirectories } from '../skill-discovery.js';
|
|
5
5
|
function discoverSkills(ctx) {
|
|
6
6
|
const roots = [
|
|
@@ -21,12 +21,11 @@ function discoverSkills(ctx) {
|
|
|
21
21
|
}
|
|
22
22
|
return out;
|
|
23
23
|
}
|
|
24
|
-
function runCodexJson(args) {
|
|
24
|
+
async function runCodexJson(args) {
|
|
25
25
|
try {
|
|
26
|
-
const output =
|
|
26
|
+
const output = await execCodexCli(args, {
|
|
27
27
|
encoding: 'utf-8',
|
|
28
28
|
timeout: 3000,
|
|
29
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
30
29
|
});
|
|
31
30
|
return JSON.parse(output);
|
|
32
31
|
}
|
|
@@ -83,8 +82,8 @@ function normalizeMcpServerConfig(entry) {
|
|
|
83
82
|
}
|
|
84
83
|
return Object.keys(config).length > 0 ? config : undefined;
|
|
85
84
|
}
|
|
86
|
-
function discoverMcp() {
|
|
87
|
-
const parsed = runCodexJson(['mcp', 'list', '--json']);
|
|
85
|
+
async function discoverMcp() {
|
|
86
|
+
const parsed = await runCodexJson(['mcp', 'list', '--json']);
|
|
88
87
|
const list = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.servers) ? parsed.servers : [];
|
|
89
88
|
return list.map((entry) => {
|
|
90
89
|
const id = String(entry.name ?? entry.id ?? '').trim();
|
|
@@ -101,8 +100,8 @@ function discoverMcp() {
|
|
|
101
100
|
};
|
|
102
101
|
}).filter(Boolean);
|
|
103
102
|
}
|
|
104
|
-
function discoverPlugins() {
|
|
105
|
-
const parsed = runCodexJson(['plugin', 'list', '--json']);
|
|
103
|
+
async function discoverPlugins() {
|
|
104
|
+
const parsed = await runCodexJson(['plugin', 'list', '--json']);
|
|
106
105
|
const installed = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.installed) ? parsed.installed : [];
|
|
107
106
|
return installed.map((entry) => {
|
|
108
107
|
const id = String(entry.id ?? entry.name ?? entry.pluginId ?? '').trim();
|
|
@@ -592,6 +592,24 @@ export function buildReloadHooks(deps) {
|
|
|
592
592
|
},
|
|
593
593
|
};
|
|
594
594
|
}
|
|
595
|
+
export async function registerBuiltinChannelPlugins(channelLoader) {
|
|
596
|
+
channelLoader.register(new (await import('../channels/aun.js')).AUNChannelPlugin());
|
|
597
|
+
const providers = [
|
|
598
|
+
['feishu', async () => new (await import('../channels/feishu.js')).FeishuChannelPlugin()],
|
|
599
|
+
['wechat', async () => new (await import('../channels/wechat.js')).WechatChannelPlugin()],
|
|
600
|
+
['dingtalk', async () => new (await import('../channels/dingtalk.js')).DingtalkChannelPlugin()],
|
|
601
|
+
['qqbot', async () => new (await import('../channels/qqbot.js')).QQBotChannelPlugin()],
|
|
602
|
+
['wecom', async () => new (await import('../channels/wecom.js')).WecomChannelPlugin()],
|
|
603
|
+
];
|
|
604
|
+
for (const [channelType, load] of providers) {
|
|
605
|
+
try {
|
|
606
|
+
channelLoader.register(await load());
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
channelLoader.recordProviderFailure(channelType, error);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
595
613
|
export class ContactBindRegistry {
|
|
596
614
|
providers = new Map();
|
|
597
615
|
register(channelType, provider) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
|
+
import { readAccessPolicySnapshot, mutateAccessPolicy } from '../../config/access-policy.js';
|
|
3
|
+
import { refreshDirectoryMarkdown } from '../../directory/owner-directory-admission.js';
|
|
2
4
|
import { ownerResolver } from '../ownership/owner-resolver.js';
|
|
3
5
|
import { agentFullAccessStatus, agentFullAccessWriteError } from '../role/runtime-policy.js';
|
|
4
6
|
import { hasOrphanedInitializationMarker, initializationSummary, readInitialization, validateInitializationModelArgs } from '../../cli/agent-create.js';
|
|
@@ -725,6 +727,28 @@ async function runCreateInBackground(opts, w, service) {
|
|
|
725
727
|
* 调用方负责传入已兜底的 args.project(见 command-handler 装配)。 */
|
|
726
728
|
export async function execAgentAction(action, args, peerId, eventBus, service, subject) {
|
|
727
729
|
const a = args ?? {};
|
|
730
|
+
if (action === 'set-access') {
|
|
731
|
+
const resources = ['allowInternalContacts', 'allowExternalContacts', 'allowAllContacts', 'allowedAids', 'deniedAids', 'requestLimit'];
|
|
732
|
+
if (!isValidAid(a.aid ?? '') || !resources.includes(a.resource)
|
|
733
|
+
|| !Object.hasOwn(a, 'value') || typeof a.accessRevision !== 'string') {
|
|
734
|
+
return { error: 'set-access requires aid, resource, value and accessRevision', code: 'INVALID_ARGUMENT' };
|
|
735
|
+
}
|
|
736
|
+
try {
|
|
737
|
+
const result = mutateAccessPolicy({
|
|
738
|
+
selfAid: a.aid, actorAid: subject?.principalId ?? subject?.actorId ?? '',
|
|
739
|
+
actorRole: subject?.role, resource: ('access.' + a.resource),
|
|
740
|
+
expectedAccessRevision: a.accessRevision,
|
|
741
|
+
update: policy => ({ ...policy, [a.resource]: a.value }),
|
|
742
|
+
});
|
|
743
|
+
if (result.changed)
|
|
744
|
+
refreshDirectoryMarkdown(a.aid);
|
|
745
|
+
return { data: result };
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
return { error: error instanceof Error ? error.message : String(error),
|
|
749
|
+
code: error.code ?? 'ACCESS_WRITE_FAILED' };
|
|
750
|
+
}
|
|
751
|
+
}
|
|
728
752
|
if (action === 'create') {
|
|
729
753
|
if (a.initialize !== undefined && typeof a.initialize !== 'boolean')
|
|
730
754
|
return { error: 'initialize 必须是布尔值', code: 'INVALID_ARGS' };
|
|
@@ -1167,6 +1191,14 @@ export async function execAgentQuery(args, service, subject, runtime) {
|
|
|
1167
1191
|
return { error: '缺少 aid', code: 'INVALID_ARGS' };
|
|
1168
1192
|
if (typeof aid !== 'string' || !isValidAid(aid))
|
|
1169
1193
|
return { error: '无效 Agent AID', code: 'INVALID_ARGS' };
|
|
1194
|
+
if (args?.view === 'access') {
|
|
1195
|
+
try {
|
|
1196
|
+
return { data: readAccessPolicySnapshot(aid) };
|
|
1197
|
+
}
|
|
1198
|
+
catch (error) {
|
|
1199
|
+
return { error: error instanceof Error ? error.message : String(error), code: 'ACCESS_UNAVAILABLE' };
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1170
1202
|
const agentDir = path.join(resolvePaths().agentsDir, aid);
|
|
1171
1203
|
const initialization = initializationSummary(aid);
|
|
1172
1204
|
if (initialization?.code === 'INITIALIZE_STATE_INVALID') {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { parseAgentWelcomeArgs, parseInitializationArgs, resolveAgentCreateMode } from '../../cli/agent-create.js';
|
|
2
2
|
import { parseOwnershipCommand } from '../../aun/aid/ownership-operation.js';
|
|
3
3
|
import { normalizeCliArgv } from '../../cli/cli-argv.js';
|
|
4
|
+
import { parseQuotaCommand } from '../../stats/quota-query.js';
|
|
4
5
|
import { resolveConfigCommand, } from '../../config/resolved-config-op.js';
|
|
5
6
|
import { getOperationMeta } from '../auth/operation-catalog.js';
|
|
6
7
|
export { normalizeCliArgv, parseLegacyCliCommand, validateCliArgv } from '../../cli/cli-argv.js';
|
|
@@ -34,6 +35,18 @@ export function parseCliIntent(inputArgv, source = 'menu.cli', options = {}) {
|
|
|
34
35
|
result = parseConfigCommand(argv, source, options.defaultRelation);
|
|
35
36
|
else if (cmd === 'stats')
|
|
36
37
|
result = parseStatsCommand(argv, source);
|
|
38
|
+
else if (cmd === 'quota') {
|
|
39
|
+
try {
|
|
40
|
+
const command = parseQuotaCommand(argv);
|
|
41
|
+
result = recognized('quota.read', 'relation', source, {
|
|
42
|
+
...(command.selfAid ? { self: command.selfAid, targetAgentAid: command.selfAid } : {}),
|
|
43
|
+
...(command.peerKey ? { peer: command.peerKey, peerKey: command.peerKey } : {}),
|
|
44
|
+
}, argv);
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return { kind: 'invalid', code: error.code ?? 'INVALID_ARGUMENT', reason: error.message };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
37
50
|
else if (cmd === 'agent')
|
|
38
51
|
result = parseAgentCommand(argv, source);
|
|
39
52
|
else if (cmd === 'aid')
|