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
|
@@ -23,7 +23,7 @@ import { resolveAunTargetKind } from '../../aun/group/identity.js';
|
|
|
23
23
|
import { readJsonFile, readLastJsonlLine, scanChatDirs, scanMetaFiles } from '../session/session-fs-store.js';
|
|
24
24
|
import { constrainResolvedModelForRole } from '../model/model-permission.js';
|
|
25
25
|
import { resolveRuntimePermissionMode, resolveRuntimeStringField } from '../role/runtime-policy.js';
|
|
26
|
-
import {
|
|
26
|
+
import { commitAgentConfigTransactionSync } from '../../config/peer-book-store.js';
|
|
27
27
|
import { readRoleDefinition, readRoleRegistry, registerRole, writeRoleDefinition, writeRoleRegistry, } from '../../config/role-service.js';
|
|
28
28
|
import { clearRoleStoreCache, readRoleStore, roleRegistryExists } from '../../config/role-store.js';
|
|
29
29
|
const ROLE_MENU_SCHEMA_VERSION = 1;
|
|
@@ -57,9 +57,9 @@ export function roleMenuOperation(kind, args, value) {
|
|
|
57
57
|
}
|
|
58
58
|
if (kind === 'action')
|
|
59
59
|
return 'role.policy.write';
|
|
60
|
-
if (
|
|
60
|
+
if (!['assignment', 'admin', 'defaultRoles'].includes(String(args?.resource)))
|
|
61
61
|
return 'role.policy.write';
|
|
62
|
-
if (args?.resource === 'admin')
|
|
62
|
+
if (args?.resource === 'admin' || args?.resource === 'defaultRoles')
|
|
63
63
|
return 'role.assign';
|
|
64
64
|
try {
|
|
65
65
|
return JSON.parse(value ?? '') === null ? 'role.revoke' : 'role.assign';
|
|
@@ -74,7 +74,13 @@ export async function roleMenuOptions(context, args) {
|
|
|
74
74
|
assertRoleDomainReady(context.self);
|
|
75
75
|
const option = stringArg(args?.option);
|
|
76
76
|
if (option === 'roles')
|
|
77
|
-
return roleItems(context.self)
|
|
77
|
+
return roleItems(context.self).map(item => ({
|
|
78
|
+
...item,
|
|
79
|
+
assignable: item.assignable && canAssignRoles(context),
|
|
80
|
+
editable: item.editable && (context.trustedFullAccess === true || context.isDaemonOwner === true),
|
|
81
|
+
deletable: item.deletable && (context.trustedFullAccess === true || context.isDaemonOwner === true),
|
|
82
|
+
resettable: item.resettable && (context.trustedFullAccess === true || context.isDaemonOwner === true),
|
|
83
|
+
}));
|
|
78
84
|
if (option === 'operations') {
|
|
79
85
|
return listOperations().map(operation => ({
|
|
80
86
|
value: operation.id,
|
|
@@ -114,15 +120,19 @@ export async function roleMenuQuery(context, args) {
|
|
|
114
120
|
const policyRevision = revision(policyDocument(agent));
|
|
115
121
|
if (view === 'capabilities') {
|
|
116
122
|
const hasAunDirectory = context.aunAvailable !== false;
|
|
123
|
+
const policyWrite = context.trustedFullAccess === true || context.isDaemonOwner === true;
|
|
124
|
+
const assignmentWrite = canAssignRoles(context);
|
|
117
125
|
return {
|
|
118
126
|
$schema_version: ROLE_MENU_SCHEMA_VERSION,
|
|
119
127
|
self: context.self,
|
|
120
128
|
capabilities: {
|
|
121
|
-
roleList: true, roleRead: true, roleWrite:
|
|
122
|
-
|
|
129
|
+
roleList: true, roleRead: true, roleWrite: policyWrite, roleCreate: policyWrite,
|
|
130
|
+
roleDelete: policyWrite, roleReset: policyWrite,
|
|
131
|
+
defaultRoleRead: true, defaultRoleWrite: assignmentWrite, permissionFields: true, permissionValues: true,
|
|
123
132
|
operations: true, privateTargetsList: true, joinedGroupsList: hasAunDirectory, assignmentInventory: true,
|
|
124
|
-
relationSnapshot: hasAunDirectory, privateRoleAssign: hasAunDirectory
|
|
125
|
-
|
|
133
|
+
relationSnapshot: hasAunDirectory, privateRoleAssign: hasAunDirectory && assignmentWrite,
|
|
134
|
+
groupRoleAssign: hasAunDirectory && assignmentWrite,
|
|
135
|
+
deleteWithReplacement: policyWrite, jsonStringUpdateValue: true,
|
|
126
136
|
},
|
|
127
137
|
};
|
|
128
138
|
}
|
|
@@ -144,7 +154,14 @@ export async function roleMenuQuery(context, args) {
|
|
|
144
154
|
self: context.self,
|
|
145
155
|
policyRevision,
|
|
146
156
|
roleId,
|
|
147
|
-
meta:
|
|
157
|
+
meta: {
|
|
158
|
+
...roleMeta(context.self, roleId),
|
|
159
|
+
editable: context.trustedFullAccess === true || context.isDaemonOwner === true,
|
|
160
|
+
deletable: roleMeta(context.self, roleId).deletable
|
|
161
|
+
&& (context.trustedFullAccess === true || context.isDaemonOwner === true),
|
|
162
|
+
resettable: roleMeta(context.self, roleId).resettable
|
|
163
|
+
&& (context.trustedFullAccess === true || context.isDaemonOwner === true),
|
|
164
|
+
},
|
|
148
165
|
definition: clone(definition),
|
|
149
166
|
};
|
|
150
167
|
}
|
|
@@ -178,6 +195,10 @@ export async function roleMenuGroupCount(context) {
|
|
|
178
195
|
}
|
|
179
196
|
export async function roleMenuUpdate(context, args, rawValue) {
|
|
180
197
|
assertRequest(context, args);
|
|
198
|
+
if (args?.resource === 'definition')
|
|
199
|
+
assertRolePolicyMutationTarget(context, args);
|
|
200
|
+
else
|
|
201
|
+
assertRoleAssignmentAuthority(context);
|
|
181
202
|
const value = parseUpdateValue(rawValue, context.self);
|
|
182
203
|
return withAgentMutation(context.self, async () => {
|
|
183
204
|
recoverRoleMutationSync(context.self);
|
|
@@ -186,7 +207,6 @@ export async function roleMenuUpdate(context, args, rawValue) {
|
|
|
186
207
|
const resource = stringArg(args?.resource);
|
|
187
208
|
let result;
|
|
188
209
|
if (resource === 'definition') {
|
|
189
|
-
assertRolePolicyMutationTarget(context, args);
|
|
190
210
|
result = updateDefinition(context.self, args, value);
|
|
191
211
|
}
|
|
192
212
|
else if (resource === 'defaultRoles')
|
|
@@ -203,6 +223,7 @@ export async function roleMenuUpdate(context, args, rawValue) {
|
|
|
203
223
|
}
|
|
204
224
|
export async function roleMenuAction(context, action, args) {
|
|
205
225
|
assertRequest(context, args);
|
|
226
|
+
assertRolePolicyMutationTarget(context, args);
|
|
206
227
|
return withAgentMutation(context.self, async () => {
|
|
207
228
|
recoverRoleMutationSync(context.self);
|
|
208
229
|
assertRoleDomainReady(context.self);
|
|
@@ -211,7 +232,6 @@ export async function roleMenuAction(context, action, args) {
|
|
|
211
232
|
if (action === 'create')
|
|
212
233
|
result = createRole(context.self, args);
|
|
213
234
|
else if (action === 'reset') {
|
|
214
|
-
assertRolePolicyMutationTarget(context, args);
|
|
215
235
|
result = resetRole(context.self, args);
|
|
216
236
|
}
|
|
217
237
|
else if (action === 'delete')
|
|
@@ -345,7 +365,8 @@ function assertRequest(context, args) {
|
|
|
345
365
|
receivingSelf: context.self,
|
|
346
366
|
});
|
|
347
367
|
}
|
|
348
|
-
if (!
|
|
368
|
+
if (!context.trustedFullAccess && context.isDaemonOwner !== true
|
|
369
|
+
&& context.actorRole !== 'owner' && context.actorRole !== 'admin') {
|
|
349
370
|
throw roleError('PERMISSION_DENIED', 'Role management requires Agent owner or admin', context.self, {
|
|
350
371
|
kind: 'role_permission_denied',
|
|
351
372
|
actorRole: context.actorRole,
|
|
@@ -353,12 +374,19 @@ function assertRequest(context, args) {
|
|
|
353
374
|
}
|
|
354
375
|
}
|
|
355
376
|
function assertRolePolicyMutationTarget(context, args) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
377
|
+
if (!context.trustedFullAccess && context.isDaemonOwner !== true) {
|
|
378
|
+
throw roleError('PERMISSION_DENIED', 'Role definitions require DaemonOwner authorization', context.self, {
|
|
379
|
+
kind: 'daemon_owner_required', actorRole: context.actorRole,
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
function canAssignRoles(context) {
|
|
384
|
+
return context.trustedFullAccess === true || isDaemonOwnerControl(context) || context.actorRole === 'owner';
|
|
385
|
+
}
|
|
386
|
+
function assertRoleAssignmentAuthority(context) {
|
|
387
|
+
if (!canAssignRoles(context)) {
|
|
388
|
+
throw roleError('PERMISSION_DENIED', 'Role assignment requires the Agent Owner', context.self, {
|
|
389
|
+
kind: 'agent_owner_required', actorRole: context.actorRole,
|
|
362
390
|
});
|
|
363
391
|
}
|
|
364
392
|
}
|
|
@@ -1573,11 +1601,7 @@ function normalizeRelationForScene(value, scene) {
|
|
|
1573
1601
|
return normalized;
|
|
1574
1602
|
}
|
|
1575
1603
|
function commitJournal(self, changes) {
|
|
1576
|
-
|
|
1577
|
-
selfAid: self,
|
|
1578
|
-
actor: 'role-delete-transaction',
|
|
1579
|
-
mutation: { type: 'sync-management-roles' },
|
|
1580
|
-
}, changes);
|
|
1604
|
+
commitAgentConfigTransactionSync(self, changes);
|
|
1581
1605
|
}
|
|
1582
1606
|
function removeJournalFiles(journalFile) {
|
|
1583
1607
|
// Remove backups first. If the process exits mid-cleanup, a committed main
|
|
@@ -302,43 +302,26 @@ function getAgentBusyCount(handler, aid, excludeSessionKey) {
|
|
|
302
302
|
}
|
|
303
303
|
async function getGitWorkingDirInfo(projectPath) {
|
|
304
304
|
try {
|
|
305
|
-
const {
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
})
|
|
305
|
+
const { execFile } = await import('child_process');
|
|
306
|
+
const git = (args) => new Promise((resolve, reject) => {
|
|
307
|
+
const child = execFile('git', args, {
|
|
308
|
+
cwd: projectPath, encoding: 'utf8', timeout: 1000,
|
|
309
|
+
windowsHide: process.platform === 'win32',
|
|
310
|
+
}, (error, stdout) => error ? reject(error) : resolve(stdout));
|
|
311
|
+
child.stdin?.end();
|
|
312
|
+
});
|
|
313
|
+
const isInsideWorkTree = (await git(['rev-parse', '--is-inside-work-tree'])).trim();
|
|
313
314
|
if (isInsideWorkTree !== 'true')
|
|
314
315
|
return null;
|
|
315
316
|
// 获取分支名
|
|
316
|
-
let branch =
|
|
317
|
-
cwd: projectPath,
|
|
318
|
-
encoding: 'utf8',
|
|
319
|
-
timeout: 1000,
|
|
320
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
321
|
-
windowsHide: process.platform === 'win32',
|
|
322
|
-
}).trim();
|
|
317
|
+
let branch = (await git(['branch', '--show-current'])).trim();
|
|
323
318
|
if (!branch) {
|
|
324
|
-
branch =
|
|
325
|
-
cwd: projectPath,
|
|
326
|
-
encoding: 'utf8',
|
|
327
|
-
timeout: 1000,
|
|
328
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
329
|
-
windowsHide: process.platform === 'win32',
|
|
330
|
-
}).trim();
|
|
319
|
+
branch = (await git(['rev-parse', '--abbrev-ref', 'HEAD'])).trim();
|
|
331
320
|
}
|
|
332
321
|
if (!branch)
|
|
333
322
|
return null;
|
|
334
323
|
// 检查文件状态
|
|
335
|
-
const statusOutput =
|
|
336
|
-
cwd: projectPath,
|
|
337
|
-
encoding: 'utf8',
|
|
338
|
-
timeout: 1000,
|
|
339
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
340
|
-
windowsHide: process.platform === 'win32',
|
|
341
|
-
});
|
|
324
|
+
const statusOutput = await git(['--no-optional-locks', 'status', '--porcelain']);
|
|
342
325
|
// 解析文件状态统计
|
|
343
326
|
const stats = { modified: 0, added: 0, deleted: 0, untracked: 0 };
|
|
344
327
|
const lines = statusOutput.trim().split('\n').filter(Boolean);
|
|
@@ -380,13 +363,7 @@ async function getGitWorkingDirInfo(projectPath) {
|
|
|
380
363
|
}
|
|
381
364
|
// 获取 ahead/behind 信息
|
|
382
365
|
try {
|
|
383
|
-
const revOutput =
|
|
384
|
-
cwd: projectPath,
|
|
385
|
-
timeout: 1000,
|
|
386
|
-
encoding: 'utf8',
|
|
387
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
388
|
-
windowsHide: process.platform === 'win32',
|
|
389
|
-
});
|
|
366
|
+
const revOutput = await git(['rev-list', '--left-right', '--count', '@{upstream}...HEAD']);
|
|
390
367
|
const revParts = revOutput.trim().split(/\s+/);
|
|
391
368
|
if (revParts.length === 2) {
|
|
392
369
|
const behind = parseInt(revParts[0], 10) || 0;
|
|
@@ -2609,7 +2586,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2609
2586
|
return { kind: 'command.error', text: `❌ 当前 Agent (${currentSessionAgent.name}) 不支持 /compact` };
|
|
2610
2587
|
}
|
|
2611
2588
|
if (sendMessage) {
|
|
2612
|
-
const text = '
|
|
2589
|
+
const text = '正在压缩会话上下文...';
|
|
2613
2590
|
await sendMessage(channelId, text, this.getReplyContext(session), {
|
|
2614
2591
|
kind: 'system.notice',
|
|
2615
2592
|
text,
|
|
@@ -2681,7 +2658,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
2681
2658
|
if (compactResult === true || compactResult?.ok === true) {
|
|
2682
2659
|
return {
|
|
2683
2660
|
kind: 'system.notice',
|
|
2684
|
-
text: '
|
|
2661
|
+
text: '会话压缩完成',
|
|
2685
2662
|
subtype: 'session.compacted',
|
|
2686
2663
|
};
|
|
2687
2664
|
}
|
|
@@ -3822,10 +3799,14 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3822
3799
|
if (!targetSession) {
|
|
3823
3800
|
return { kind: 'command.error', text: `❌ 会话不存在: ${sessionName}\n使用 /s 查看可用会话` };
|
|
3824
3801
|
}
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3802
|
+
// Context is presentation only: finish the switch before asynchronous I/O
|
|
3803
|
+
// so it cannot widen the idle-check-to-session-replacement window.
|
|
3804
|
+
const readLastInput = async () => {
|
|
3805
|
+
const lastInput = targetSession.agentSessionId
|
|
3806
|
+
? await this.sessionManager.readSessionLastUserMessage(targetSession.projectPath, targetSession.agentSessionId, targetSession.baseagent, targetSession.selfAID)
|
|
3807
|
+
: null;
|
|
3808
|
+
return { lastInput, lastInputLine: lastInput ? `\n 最后输入: "${lastInput}"` : '' };
|
|
3809
|
+
};
|
|
3829
3810
|
if (!session) {
|
|
3830
3811
|
const switched = await this.sessionManager.switchToSession(channel, channelId, targetSession.id);
|
|
3831
3812
|
if (!switched) {
|
|
@@ -3833,6 +3814,7 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3833
3814
|
}
|
|
3834
3815
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
3835
3816
|
return null;
|
|
3817
|
+
const { lastInputLine } = await readLastInput();
|
|
3836
3818
|
return { kind: 'command.result', text: `✓ 已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}\n 项目: ${path.basename(targetSession.projectPath)}${lastInputLine}` };
|
|
3837
3819
|
}
|
|
3838
3820
|
if (targetSession.id === session.id) {
|
|
@@ -3850,9 +3832,10 @@ export async function handleSlashCommand(content, channel, channelId, sendMessag
|
|
|
3850
3832
|
return { kind: 'command.error', text: `❌ 切换会话失败` };
|
|
3851
3833
|
}
|
|
3852
3834
|
this.eventBus.publish({ type: 'session:switched', sessionId: targetSession.id, fromSessionId: session.id, toSessionId: targetSession.id });
|
|
3853
|
-
const continueHint = lastInput ? '\n 将继续之前的对话历史' : '\n 当前会话未有发言';
|
|
3854
3835
|
if (this.shouldSuppressCardTriggerResult(source, channel))
|
|
3855
3836
|
return null;
|
|
3837
|
+
const { lastInput, lastInputLine } = await readLastInput();
|
|
3838
|
+
const continueHint = lastInput ? '\n 将继续之前的对话历史' : '\n 当前会话未有发言';
|
|
3856
3839
|
return { kind: 'command.result', text: `✓ 已切换到会话: ${displaySessionTitle(targetSession.name, sessionName)}${continueHint}${lastInputLine}` };
|
|
3857
3840
|
}
|
|
3858
3841
|
// /rename 或 /name 命令:重命名当前会话
|
|
@@ -105,9 +105,18 @@ async function preview(realPath, size) {
|
|
|
105
105
|
/** Derived private cache. No Skill files, workspace content or directory layouts are modified. */
|
|
106
106
|
export class TeamWorkspaceItemsIndex {
|
|
107
107
|
store;
|
|
108
|
+
cacheNamespace;
|
|
109
|
+
idleMs;
|
|
108
110
|
indexes = new Map();
|
|
109
|
-
|
|
111
|
+
listeners = new Set();
|
|
112
|
+
constructor(store = teamWorkspaceStore, cacheNamespace = 'team-workspace-items-v1', idleMs = IDLE_MS) {
|
|
110
113
|
this.store = store;
|
|
114
|
+
this.cacheNamespace = cacheNamespace;
|
|
115
|
+
this.idleMs = idleMs;
|
|
116
|
+
}
|
|
117
|
+
onCommitted(listener) {
|
|
118
|
+
this.listeners.add(listener);
|
|
119
|
+
return () => { this.listeners.delete(listener); };
|
|
111
120
|
}
|
|
112
121
|
warm(agentAid, state) {
|
|
113
122
|
// Navigation must not wait for cache JSON parsing or filesystem discovery.
|
|
@@ -134,6 +143,11 @@ export class TeamWorkspaceItemsIndex {
|
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
145
|
async query(agentAid, state, args) {
|
|
146
|
+
const { indexState: _indexState, watcherHealthy: _watcherHealthy, ...response } = await this.queryFiltered(agentAid, state, args);
|
|
147
|
+
return response;
|
|
148
|
+
}
|
|
149
|
+
/** Fixed-output queries share the bounded scanner, preview queue and path checks. */
|
|
150
|
+
async queryFiltered(agentAid, state, args, predicate = () => true, nonBlocking = false) {
|
|
137
151
|
validateTeamWorkspaceItemsArgs(args);
|
|
138
152
|
this.assertCurrent(agentAid, state);
|
|
139
153
|
const requestedPath = args.path;
|
|
@@ -141,13 +155,31 @@ export class TeamWorkspaceItemsIndex {
|
|
|
141
155
|
throw new DataRootError('FORBIDDEN', 'Path is not published in Team navigation');
|
|
142
156
|
this.store.resolvePath(state, requestedPath);
|
|
143
157
|
const index = this.get(agentAid, state);
|
|
158
|
+
if (index.watchDegraded) {
|
|
159
|
+
// A failed watcher is retried only on a legal read, never by a scan timer.
|
|
160
|
+
index.watchRestart ??= Promise.all((index.watchers ?? []).map(w => w.close())).then(() => {
|
|
161
|
+
if (index.closed)
|
|
162
|
+
return;
|
|
163
|
+
index.watchDegraded = false;
|
|
164
|
+
this.observe(index);
|
|
165
|
+
}).finally(() => { index.watchRestart = undefined; });
|
|
166
|
+
await index.watchRestart;
|
|
167
|
+
}
|
|
168
|
+
if (nonBlocking && index.scannedAt === 0) {
|
|
169
|
+
void this.refresh(index).catch(() => { index.rescan = true; });
|
|
170
|
+
return {
|
|
171
|
+
indexRevision: index.revision, items: [], total: 0,
|
|
172
|
+
nextOffset: null, hasMore: false, truncated: false, indexState: 'building',
|
|
173
|
+
watcherHealthy: index.watchReady === true && !index.watchDegraded,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
144
176
|
await this.refresh(index);
|
|
145
177
|
this.assertCurrent(agentAid, state);
|
|
146
178
|
if (args.indexRevision !== undefined && args.indexRevision !== index.revision) {
|
|
147
179
|
throw new DataRootError('INDEX_CHANGED', 'Team workspace items changed; restart pagination');
|
|
148
180
|
}
|
|
149
181
|
const snapshotRevision = index.revision;
|
|
150
|
-
const matching = index.sorted.filter(item => within(requestedPath, item.path));
|
|
182
|
+
const matching = index.sorted.filter(item => within(requestedPath, item.path) && predicate(item));
|
|
151
183
|
const offset = Number(args.offset ?? 0);
|
|
152
184
|
const limit = Number(args.limit ?? 20);
|
|
153
185
|
const window = matching.slice(offset, offset + limit);
|
|
@@ -181,6 +213,8 @@ export class TeamWorkspaceItemsIndex {
|
|
|
181
213
|
indexRevision: index.revision, path: requestedPath, offset,
|
|
182
214
|
total: matching.length, nextOffset: next < matching.length ? next : null,
|
|
183
215
|
hasMore: next < matching.length, truncated: index.truncated,
|
|
216
|
+
indexState: 'ready',
|
|
217
|
+
watcherHealthy: index.watchReady === true && !index.watchDegraded,
|
|
184
218
|
items: window.map(({ signature: _signature, realPath: _realPath, previewLoaded: _loaded, ...item }) => item),
|
|
185
219
|
};
|
|
186
220
|
// JSON escaping and long logical paths also consume transport space. A page
|
|
@@ -229,12 +263,14 @@ export class TeamWorkspaceItemsIndex {
|
|
|
229
263
|
this.observe(index);
|
|
230
264
|
}
|
|
231
265
|
clearTimeout(index.idle);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
this.indexes.
|
|
236
|
-
|
|
237
|
-
|
|
266
|
+
if (this.idleMs > 0) {
|
|
267
|
+
index.idle = setTimeout(() => {
|
|
268
|
+
this.release(index);
|
|
269
|
+
if (this.indexes.get(agentAid) === index)
|
|
270
|
+
this.indexes.delete(agentAid);
|
|
271
|
+
}, this.idleMs);
|
|
272
|
+
index.idle.unref();
|
|
273
|
+
}
|
|
238
274
|
// Bound watcher count even on a host with many PAs.
|
|
239
275
|
if (this.indexes.size > 16) {
|
|
240
276
|
const oldest = [...this.indexes.values()].find(candidate => candidate !== index && !candidate.pending);
|
|
@@ -245,7 +281,10 @@ export class TeamWorkspaceItemsIndex {
|
|
|
245
281
|
}
|
|
246
282
|
return index;
|
|
247
283
|
}
|
|
248
|
-
cachePath(index) {
|
|
284
|
+
cachePath(index) {
|
|
285
|
+
const safeNamespace = this.cacheNamespace.replace(/[^A-Za-z0-9._-]/g, '-');
|
|
286
|
+
return path.join(agentDataDir(index.agentAid), `${safeNamespace}.json`);
|
|
287
|
+
}
|
|
249
288
|
persist(index) {
|
|
250
289
|
if (index.closed || this.indexes.get(index.agentAid) !== index)
|
|
251
290
|
return;
|
|
@@ -311,6 +350,9 @@ export class TeamWorkspaceItemsIndex {
|
|
|
311
350
|
{ root: workspaceRoot, output: false },
|
|
312
351
|
...(outputRoot && outputRoot !== workspaceRoot ? [{ root: outputRoot, output: true }] : []),
|
|
313
352
|
];
|
|
353
|
+
index.watchReady = false;
|
|
354
|
+
const generation = index.watchGeneration = (index.watchGeneration ?? 0) + 1;
|
|
355
|
+
let pendingReady = roots.length;
|
|
314
356
|
index.watchers = roots.map(({ root, output }) => {
|
|
315
357
|
const allowed = index.state.entries.filter(entry => entry.availability !== 'unavailable'
|
|
316
358
|
&& (output ? entry.path === 'output' || entry.path.startsWith('output/') : !outputRoot || entry.path !== 'output' && !entry.path.startsWith('output/')));
|
|
@@ -326,7 +368,7 @@ export class TeamWorkspaceItemsIndex {
|
|
|
326
368
|
},
|
|
327
369
|
});
|
|
328
370
|
watcher.on('all', (event, absolute) => {
|
|
329
|
-
if (index.closed)
|
|
371
|
+
if (index.closed || index.watchGeneration !== generation)
|
|
330
372
|
return;
|
|
331
373
|
const relative = path.relative(root, absolute).split(path.sep).join('/');
|
|
332
374
|
const logical = logicalPath(relative);
|
|
@@ -338,8 +380,27 @@ export class TeamWorkspaceItemsIndex {
|
|
|
338
380
|
index.timer = setTimeout(() => { void this.refresh(index).catch(() => { index.rescan = true; }); }, 75);
|
|
339
381
|
index.timer.unref();
|
|
340
382
|
});
|
|
341
|
-
watcher.on('ready', () => {
|
|
342
|
-
|
|
383
|
+
watcher.on('ready', () => {
|
|
384
|
+
if (index.closed || index.watchDegraded || index.watchGeneration !== generation)
|
|
385
|
+
return;
|
|
386
|
+
if (--pendingReady === 0)
|
|
387
|
+
index.watchReady = true;
|
|
388
|
+
index.rescan = true;
|
|
389
|
+
void this.refresh(index).catch(() => { index.rescan = true; });
|
|
390
|
+
});
|
|
391
|
+
watcher.on('error', () => {
|
|
392
|
+
if (index.closed || index.watchDegraded || index.watchGeneration !== generation)
|
|
393
|
+
return;
|
|
394
|
+
index.watchDegraded = true;
|
|
395
|
+
index.watchReady = false;
|
|
396
|
+
index.rescan = true;
|
|
397
|
+
for (const listener of this.listeners) {
|
|
398
|
+
try {
|
|
399
|
+
listener(index.agentAid, index.revision, index.sorted, index.truncated, false);
|
|
400
|
+
}
|
|
401
|
+
catch { /* observers never block reads */ }
|
|
402
|
+
}
|
|
403
|
+
});
|
|
343
404
|
return watcher;
|
|
344
405
|
});
|
|
345
406
|
}
|
|
@@ -480,6 +541,14 @@ export class TeamWorkspaceItemsIndex {
|
|
|
480
541
|
index.revision = crypto.randomBytes(12).toString('hex');
|
|
481
542
|
if (changed || full)
|
|
482
543
|
this.persist(index);
|
|
544
|
+
if (changed || full && index.scannedAt !== 0) {
|
|
545
|
+
for (const listener of this.listeners) {
|
|
546
|
+
try {
|
|
547
|
+
listener(index.agentAid, index.revision, index.sorted, index.truncated, index.watchReady === true && !index.watchDegraded);
|
|
548
|
+
}
|
|
549
|
+
catch { /* observers never block reads */ }
|
|
550
|
+
}
|
|
551
|
+
}
|
|
483
552
|
}
|
|
484
553
|
release(index) {
|
|
485
554
|
index.closed = true;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
2
|
import { isValidAid } from '../../aun/aid/validation.js';
|
|
3
3
|
import { ConfigTarget, mutateConfig, read } from '../../config/config-manager.js';
|
|
4
|
-
import { getPeerSnapshot, isAcceptedPeer } from '../../config/peer-book.js';
|
|
5
4
|
import { readOwnerDirectoryMembership, refreshDirectoryMarkdown } from '../../directory/owner-directory-admission.js';
|
|
6
5
|
import { MY_AGENT_TEAM_LIMIT } from '../../directory/owner-directory-markdown.js';
|
|
7
6
|
import { entryOwnerAid } from '../../directory/owner-directory-scope.js';
|
|
8
|
-
import { readAunPeerKind } from '../relation/peer-identity.js';
|
|
9
7
|
export class TeamWorkspaceTeamError extends Error {
|
|
10
8
|
code;
|
|
11
9
|
data;
|
|
@@ -36,30 +34,12 @@ export function normalizeTeamMemberAids(value, selfAid) {
|
|
|
36
34
|
throw new TeamWorkspaceTeamError('INVALID_ARGUMENT', 'team cannot contain its own Agent AID');
|
|
37
35
|
return members;
|
|
38
36
|
}
|
|
39
|
-
function contactSnapshot(selfAid) {
|
|
40
|
-
try {
|
|
41
|
-
return getPeerSnapshot(selfAid);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
throw new TeamWorkspaceTeamError('CONTACT_BOOK_INVALID', 'The current Agent contact book is unavailable');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function assertPeerContacts(selfAid, members) {
|
|
48
|
-
const snapshot = contactSnapshot(selfAid);
|
|
49
|
-
for (const aid of members) {
|
|
50
|
-
if (readAunPeerKind(selfAid, aid).kind !== 'private' || !snapshot.contacts.has(aid) || !isAcceptedPeer(selfAid, aid)) {
|
|
51
|
-
throw new TeamWorkspaceTeamError('TEAM_MEMBER_NOT_CONTACT', `Team member must be an active private Agent contact: ${aid}`, { memberAid: aid });
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
37
|
function assertActiveContacts(selfAid, members) {
|
|
56
38
|
for (const aid of members) {
|
|
57
39
|
const membership = readOwnerDirectoryMembership(selfAid, aid);
|
|
58
|
-
//
|
|
59
|
-
// Keep the established peer-book admission path usable in that case.
|
|
40
|
+
// Team eligibility requires the Owner directory; peer state is not a fallback.
|
|
60
41
|
if (membership === undefined) {
|
|
61
|
-
|
|
62
|
-
return;
|
|
42
|
+
throw new TeamWorkspaceTeamError('CONTACT_DIRECTORY_UNAVAILABLE', 'Owner directory is not configured');
|
|
63
43
|
}
|
|
64
44
|
// Directory unavailable
|
|
65
45
|
if (membership.category === 'unavailable') {
|
|
@@ -103,61 +83,19 @@ export function readTeamMembersState(selfAid) {
|
|
|
103
83
|
}
|
|
104
84
|
/** Keep stale contacts visible to the Owner so they can be removed. */
|
|
105
85
|
export function readTeamMemberDetails(selfAid, members) {
|
|
106
|
-
// Keep the legacy/local contact-book view when no Owner directory is configured.
|
|
107
|
-
if (members.some(aid => readOwnerDirectoryMembership(selfAid, aid) === undefined)) {
|
|
108
|
-
const snapshot = contactSnapshot(selfAid);
|
|
109
|
-
return members.map(aid => {
|
|
110
|
-
const contact = snapshot.contacts.get(aid);
|
|
111
|
-
const contactStatus = contact ? contact.status ?? 'active' : 'missing';
|
|
112
|
-
const reason = !contact ? 'NOT_A_CONTACT'
|
|
113
|
-
: contactStatus !== 'active' ? 'CONTACT_NOT_ACTIVE'
|
|
114
|
-
: readAunPeerKind(selfAid, aid).kind !== 'private' ? 'NOT_PRIVATE_CONTACT' : undefined;
|
|
115
|
-
return {
|
|
116
|
-
aid,
|
|
117
|
-
...(contact?.displayName ? { displayName: contact.displayName } : {}),
|
|
118
|
-
contactStatus,
|
|
119
|
-
availability: reason ? 'unavailable' : 'available',
|
|
120
|
-
...(reason ? { reason } : {}),
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
86
|
return members.map(aid => {
|
|
125
87
|
const membership = readOwnerDirectoryMembership(selfAid, aid);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
aid,
|
|
130
|
-
contactStatus: 'unavailable',
|
|
131
|
-
availability: 'unavailable',
|
|
132
|
-
reason: 'OWNER_DIRECTORY_UNAVAILABLE',
|
|
133
|
-
};
|
|
88
|
+
if (!membership || membership.category === 'unavailable') {
|
|
89
|
+
return { aid, contactStatus: 'unavailable', availability: 'unavailable', reason: 'OWNER_DIRECTORY_UNAVAILABLE' };
|
|
134
90
|
}
|
|
135
|
-
// Not found in directory
|
|
136
91
|
if (membership.category === 'not_found') {
|
|
137
|
-
return {
|
|
138
|
-
aid,
|
|
139
|
-
contactStatus: 'missing',
|
|
140
|
-
availability: 'unavailable',
|
|
141
|
-
reason: 'NOT_IN_OWNER_DIRECTORY',
|
|
142
|
-
};
|
|
92
|
+
return { aid, contactStatus: 'missing', availability: 'unavailable', reason: 'NOT_IN_OWNER_DIRECTORY' };
|
|
143
93
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
aid,
|
|
148
|
-
displayName: membership.entry?.name,
|
|
149
|
-
contactStatus: membership.blocked ? 'missing' : 'unavailable',
|
|
150
|
-
availability: 'unavailable',
|
|
151
|
-
reason: membership.blocked ? 'NOT_IN_OWNER_DIRECTORY' : 'NOT_AGENT_TYPE',
|
|
152
|
-
};
|
|
94
|
+
if (membership.blocked || !['agent', 'human', 'assistant'].includes(membership.category)) {
|
|
95
|
+
return { aid, contactStatus: 'unavailable', availability: 'unavailable',
|
|
96
|
+
reason: membership.blocked ? 'NOT_IN_OWNER_DIRECTORY' : 'NOT_AGENT_TYPE' };
|
|
153
97
|
}
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
aid,
|
|
157
|
-
displayName: membership.entry?.name,
|
|
158
|
-
contactStatus: 'active',
|
|
159
|
-
availability: 'available',
|
|
160
|
-
};
|
|
98
|
+
return { aid, displayName: membership.entry?.name, contactStatus: 'active', availability: 'available' };
|
|
161
99
|
});
|
|
162
100
|
}
|
|
163
101
|
export function readTeamMembers(selfAid) {
|