evolcore 0.0.41-test.0 → 0.0.41-test.2
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 +62 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/baseagent.js +88 -49
- package/dist/agents/claude-runner.js +177 -92
- package/dist/agents/codex-runner.js +146 -71
- package/dist/agents/ecagent-runner.js +1 -1
- package/dist/agents/gemini-runner.js +1 -1
- package/dist/aun/aid/agentmd.js +98 -11
- package/dist/aun/aid/client.js +1 -1
- package/dist/aun/aid/control-aid.js +26 -2
- package/dist/aun/aid/identity.js +91 -0
- package/dist/aun/aid/index.js +1 -1
- package/dist/aun/aid/managed-operation.js +1 -1
- package/dist/aun/aid/ownership-operation.js +23 -22
- package/dist/aun/group/fs-download.js +39 -0
- package/dist/aun/group/identity.js +36 -21
- package/dist/aun/group/operations.js +5 -0
- package/dist/aun/menu/client.js +27 -0
- package/dist/aun/msg/managed-operation.js +68 -7
- package/dist/aun/msg/p2p.js +8 -8
- package/dist/aun/service-proxy.js +53 -12
- package/dist/channels/aun.js +633 -32
- package/dist/channels/daemon.js +15 -1
- package/dist/cli/agent-command.js +5 -2
- package/dist/cli/agent-create.js +991 -233
- package/dist/cli/agent.js +49 -10
- package/dist/cli/aid-bind-command.js +48 -19
- package/dist/cli/aun-commands.js +48 -36
- package/dist/cli/daemon-commands.js +679 -697
- package/dist/cli/fs-command.js +64 -2
- package/dist/cli/index.js +72 -5
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +17 -1
- package/dist/cli/model.js +40 -40
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/proxy-command.js +92 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/role.js +85 -0
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/access-policy.js +7 -2
- package/dist/config/boot-log.js +39 -1
- package/dist/config/config-field-policy.js +17 -39
- package/dist/config/config-manager.js +183 -44
- package/dist/config/config-operation-service.js +5 -19
- package/dist/config/contact-book-store.js +47 -21
- package/dist/config/contact-book.js +18 -12
- package/dist/config/contact-operation-service.js +3 -4
- package/dist/config/contact-request-service.js +11 -0
- package/dist/config/daemon-services.js +11 -0
- package/dist/config/gateway-config.js +88 -594
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +15 -12
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-config.js +12 -7
- package/dist/config/providers-import.js +3 -21
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +11 -1
- package/dist/config/role-command-service.js +166 -0
- package/dist/config/role-request-service.js +193 -0
- package/dist/config/schema-migration.js +1000 -25
- package/dist/config-store.js +89 -4
- package/dist/contracts/ecweb-instance.js +41 -0
- package/dist/contracts/ecweb-service-protocol.js +4 -1
- package/dist/core/agent-application-service.js +60 -11
- package/dist/core/agent-create-status.js +203 -0
- package/dist/core/agent-creation-claim.js +177 -0
- package/dist/core/agent-ipc-registration.js +39 -18
- package/dist/core/agent-runtime.js +194 -24
- package/dist/core/auth/agent-delegation.js +6 -3
- package/dist/core/auth/auth-gateway.js +67 -2
- package/dist/core/auth/authorization-audit.js +58 -11
- package/dist/core/auth/delegation-authorization.js +5 -2
- package/dist/core/auth/operation-authorizer.js +43 -6
- package/dist/core/auth/operation-catalog.js +45 -7
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +260 -21
- package/dist/core/command/agent-storage-menu.js +5 -3
- package/dist/core/command/cli-intent-parser.js +8 -3
- package/dist/core/command/command-handler.js +112 -154
- package/dist/core/command/connect-menu.js +11 -3
- package/dist/core/command/data-root-resolver.js +5 -4
- package/dist/core/command/memory-slash.js +16 -8
- package/dist/core/command/menu-catalog.js +10 -6
- package/dist/core/command/menu-handler.js +106 -73
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/role-menu.js +147 -30
- package/dist/core/command/slash-handler.js +125 -255
- package/dist/core/daemon-control.js +26 -27
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +7 -5
- package/dist/core/evolagent.js +10 -8
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/inference/text-inference.js +31 -40
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +40 -24
- package/dist/core/memory/consolidation-context.js +51 -5
- package/dist/core/memory/consolidation-ops-records.js +96 -1
- package/dist/core/memory/consolidation-trigger.js +208 -191
- package/dist/core/memory/consolidation.js +333 -35
- package/dist/core/memory/index-manager.js +27 -5
- package/dist/core/memory/memory-admin.js +45 -5
- package/dist/core/memory/memory-writer.js +163 -18
- package/dist/core/memory/relation-idle-monitor.js +119 -58
- package/dist/core/memory/relation-sweep.js +55 -45
- package/dist/core/message/aun-ipc-sender.js +81 -69
- package/dist/core/message/im-renderer.js +25 -4
- package/dist/core/message/message-admission.js +89 -4
- package/dist/core/message/message-bridge.js +66 -21
- package/dist/core/message/response-engine.js +108 -35
- package/dist/core/model/catalog-service.js +5 -3
- package/dist/core/model/config-scope.js +29 -71
- package/dist/core/model/field-scope.js +1 -1
- package/dist/core/model/model-catalog.js +30 -41
- package/dist/core/model/model-diagnostics.js +4 -3
- package/dist/core/model/model-fallback.js +10 -7
- package/dist/core/model/model-permission.js +3 -2
- package/dist/core/ownership/owner-resolver.js +772 -158
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +62 -6
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/sandbox-runtime.js +18 -1
- package/dist/core/permission/tool-policy.js +21 -46
- package/dist/core/relation/peer-identity.js +64 -1
- package/dist/core/role/runtime-policy.js +72 -13
- package/dist/core/session/session-capsule.js +1 -1
- package/dist/core/session/session-idle-monitor.js +1 -1
- package/dist/core/session/session-manager.js +20 -0
- package/dist/core/session/session-renew.js +3 -3
- package/dist/core/skill/index-generator.js +15 -5
- package/dist/core/system-session/memory.js +43 -8
- package/dist/core/thread/thread-service.js +19 -6
- package/dist/directory/owner-directory-admission.js +95 -0
- package/dist/directory/owner-directory-authorization.js +309 -0
- package/dist/directory/owner-directory-cache.js +635 -0
- package/dist/eck/kit-renderer.js +2 -2
- package/dist/ecweb/basic-settings-service.js +33 -40
- package/dist/ecweb/init-menu.js +32 -0
- package/dist/ecweb/message-context-service.js +110 -0
- package/dist/index.js +93 -19
- package/dist/ipc.js +247 -29
- package/dist/paths.js +7 -0
- package/dist/proxy/command.js +122 -0
- package/dist/proxy/ipc-service.js +68 -0
- package/dist/proxy/manager.js +484 -0
- package/dist/proxy/service-supervisor.js +603 -0
- package/dist/response-system/engines/v1/proactive-flow.js +16 -6
- package/dist/trigger/authorization.js +27 -17
- package/dist/trigger/feedback.js +2 -3
- package/dist/trigger/ipc-service.js +105 -78
- package/dist/trigger/local-files.js +2 -1
- package/dist/trigger/manager.js +5 -3
- package/dist/trigger/scheduler.js +88 -6
- package/dist/utils/atomic-write.js +28 -0
- package/dist/utils/cross-platform.js +14 -0
- package/dist/utils/ecweb-supervisor.js +258 -83
- package/dist/utils/error-utils.js +26 -2
- package/dist/utils/logger.js +92 -6
- package/dist/utils/package-version-info.js +4 -2
- package/dist/utils/welcome.js +1 -1
- package/kits/docs/INDEX.md +1 -0
- package/kits/docs/aun/SDK.md +4 -1
- package/kits/docs/channels/aun.md +9 -0
- package/kits/docs/evolcore/INDEX.md +1 -0
- package/kits/docs/evolcore/agent.md +8 -1
- package/kits/docs/evolcore/aid.md +67 -17
- package/kits/docs/evolcore/config.md +28 -7
- package/kits/docs/evolcore/contact.md +3 -0
- package/kits/docs/evolcore/fs.md +11 -0
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -2
- package/kits/docs/evolcore/memory-consolidation.md +32 -8
- package/kits/docs/evolcore/memory.md +1 -1
- package/kits/docs/evolcore/menu-protocol.md +4 -0
- package/kits/docs/evolcore/model.md +23 -20
- package/kits/docs/evolcore/msg.md +4 -7
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +37 -4
- package/kits/schemas/agent-config.schema.13.json +8 -3
- package/kits/schemas/agent-config.schema.16.json +891 -0
- package/kits/schemas/daemon.schema.9.json +366 -0
- package/kits/schemas/defaults.schema.5.json +406 -127
- package/kits/schemas/relation-config.schema.11.json +277 -0
- package/kits/schemas/role-config.schema.1.json +7 -7
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-service-proxy/SKILL.md +118 -0
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- package/kits/skills/personal-assistant/SKILL.md +176 -0
- package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
- package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
- package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
- package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
- package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
- package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
- package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
- package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
- package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
- package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
- package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
- package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
- package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
- package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
- package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
- package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
- package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
- package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
- package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
- package/kits/skills/thread-ops/SKILL.md +5 -0
- package/kits/templates/memory-consolidation/forget.md +19 -6
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/memory-consolidation/profile.md +2 -2
- package/kits/templates/memory-consolidation/promote.md +20 -3
- package/kits/templates/roles/member.json +8 -1
- package/kits/templates/system-fragments/baseagent.md +2 -2
- package/kits/templates/system-fragments/memory.md +4 -4
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +7 -3
- package/dist/core/message/create-status.js +0 -96
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { getRoleDefinition } from '../../config/roles.js';
|
|
2
2
|
import { PUBLIC_PERMISSION_MODES } from '../permission/mode.js';
|
|
3
|
-
import { ConfigTarget, read } from '../../config/config-manager.js';
|
|
3
|
+
import { ConfigTarget, mutateConfig, read } from '../../config/config-manager.js';
|
|
4
4
|
import { resolvePrincipal } from '../../config/contact-book.js';
|
|
5
5
|
import { getDaemonOwners, ownerResolver } from '../ownership/owner-resolver.js';
|
|
6
6
|
import { hasTrustedPrincipal } from '../auth/authenticated-actor.js';
|
|
7
7
|
import { isTopicSession } from '../thread/topic-id.js';
|
|
8
|
+
import { formatPeerKey } from '../relation/peer-identity.js';
|
|
9
|
+
import { logger } from '../../utils/logger.js';
|
|
8
10
|
const PERMISSION_MODE_AUTHORITY = {
|
|
9
11
|
readonly: 0,
|
|
10
12
|
auto: 1,
|
|
@@ -161,30 +163,85 @@ export function agentFullAccessStatus(agentAid, principalId) {
|
|
|
161
163
|
return { enabled, eligible, effective: enabled && eligible };
|
|
162
164
|
}
|
|
163
165
|
export function sessionFullAccessStatus(session, principalId) {
|
|
164
|
-
const override = session.metadata?.sessionFullAccess;
|
|
165
166
|
const agentStatus = session.selfAID ? agentFullAccessStatus(session.selfAID, principalId) : {
|
|
166
167
|
enabled: false, eligible: false, effective: false,
|
|
167
168
|
};
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
// Agent policy is the global switch. Once enabled for an eligible owner it
|
|
170
|
+
// takes precedence over any per-main-session or per-topic /fa state.
|
|
171
|
+
const override = readSessionFullAccessOverride(session);
|
|
172
|
+
const localEnabled = override?.enabled === true;
|
|
173
|
+
const scope = isTopicSession(session) ? 'session' : 'relation';
|
|
174
|
+
if (agentStatus.enabled) {
|
|
175
|
+
return {
|
|
176
|
+
...agentStatus, effective: agentStatus.effective && session.chatType === 'private',
|
|
177
|
+
inherited: true, globalEnabled: true, localEnabled, scope, source: 'agent', mutable: false,
|
|
178
|
+
};
|
|
170
179
|
}
|
|
171
|
-
if (!override
|
|
172
|
-
return {
|
|
180
|
+
if (!override) {
|
|
181
|
+
return {
|
|
182
|
+
enabled: false, eligible: agentStatus.eligible, effective: false,
|
|
183
|
+
inherited: false, globalEnabled: false, localEnabled: false, scope, source: scope, mutable: true,
|
|
184
|
+
};
|
|
173
185
|
}
|
|
174
186
|
const eligible = !!session.selfAID && isAgentFullAccessOwner(session.selfAID, principalId);
|
|
175
187
|
return {
|
|
176
188
|
enabled: override.enabled === true,
|
|
177
189
|
eligible,
|
|
178
|
-
effective: override.enabled === true && eligible && principalId === override.authorizedBy
|
|
190
|
+
effective: override.enabled === true && eligible && principalId === override.authorizedBy
|
|
191
|
+
&& session.chatType === 'private',
|
|
179
192
|
inherited: false,
|
|
193
|
+
globalEnabled: false,
|
|
194
|
+
localEnabled,
|
|
195
|
+
scope,
|
|
196
|
+
source: scope,
|
|
197
|
+
mutable: true,
|
|
180
198
|
authorizedBy: override.authorizedBy,
|
|
181
199
|
};
|
|
182
200
|
}
|
|
183
|
-
|
|
184
|
-
|
|
201
|
+
/** Read the local /fa switch without applying the Agent-level global switch. */
|
|
202
|
+
export function readSessionFullAccessOverride(session) {
|
|
203
|
+
let value = session.metadata?.sessionFullAccess;
|
|
204
|
+
if (!isTopicSession(session)) {
|
|
205
|
+
const selector = mainSessionFullAccessSelector(session);
|
|
206
|
+
if (!selector)
|
|
207
|
+
return undefined;
|
|
208
|
+
try {
|
|
209
|
+
value = read(ConfigTarget.Relation, selector, { cache: false })?.sessionFullAccess;
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
logger.warn(`[FullAccess] Cannot read main-session policy for ${session.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
217
|
+
return undefined;
|
|
218
|
+
const config = value;
|
|
219
|
+
return typeof config.enabled === 'boolean'
|
|
220
|
+
&& typeof config.authorizedBy === 'string' && !!config.authorizedBy.trim()
|
|
221
|
+
? { enabled: config.enabled, authorizedBy: config.authorizedBy }
|
|
222
|
+
: undefined;
|
|
223
|
+
}
|
|
224
|
+
function mainSessionFullAccessSelector(session) {
|
|
225
|
+
const peerId = session.channelId;
|
|
226
|
+
if (isTopicSession(session) || session.chatType !== 'private' || !session.selfAID || !peerId)
|
|
227
|
+
return undefined;
|
|
228
|
+
return { self: session.selfAID, peerKey: formatPeerKey(session.channelType || session.channel, peerId) };
|
|
229
|
+
}
|
|
230
|
+
/** Persist the main-session /fa switch at relation scope (backend independent). */
|
|
231
|
+
export function updateRelationSessionFullAccess(session, config) {
|
|
232
|
+
const selector = mainSessionFullAccessSelector(session);
|
|
233
|
+
if (!selector) {
|
|
234
|
+
throw Object.assign(new Error('fullaccess main session requires a private relation'), { code: 'INVALID_CONTEXT' });
|
|
235
|
+
}
|
|
236
|
+
if (typeof config.enabled !== 'boolean' || !config.authorizedBy.trim()) {
|
|
237
|
+
throw Object.assign(new Error('invalid session fullaccess configuration'), { code: 'INVALID_ARGUMENT' });
|
|
238
|
+
}
|
|
239
|
+
mutateConfig(ConfigTarget.Relation, selector, current => {
|
|
240
|
+
current.sessionFullAccess = { ...config };
|
|
241
|
+
});
|
|
185
242
|
}
|
|
186
243
|
export function createSessionFullAccessAuthorization(input) {
|
|
187
|
-
const config = input.session
|
|
244
|
+
const config = readSessionFullAccessOverride(input.session);
|
|
188
245
|
if (!config?.enabled
|
|
189
246
|
|| input.session.chatType !== 'private'
|
|
190
247
|
|| (input.source !== undefined && input.source !== 'user')
|
|
@@ -209,16 +266,18 @@ export function assertSessionFullAccessAuthorization(authorization, session) {
|
|
|
209
266
|
if (authorization.source !== 'session-policy'
|
|
210
267
|
|| !session
|
|
211
268
|
|| authorization.sessionId !== session.id
|
|
212
|
-
|| !authorization.agentAid
|
|
269
|
+
|| !authorization.agentAid || authorization.agentAid !== session.selfAID
|
|
270
|
+
|| session.chatType !== 'private'
|
|
213
271
|
|| !authorization.policyActor
|
|
214
272
|
|| !hasTrustedPrincipal(authorization.policyActor)) {
|
|
215
273
|
throw new Error('session fullaccess authorization is missing or malformed');
|
|
216
274
|
}
|
|
217
275
|
const current = resolvePrincipal(authorization.agentAid, authorization.policyActor.operatorChannelType, authorization.policyActor.operatorId, authorization.policyActor.operatorChannelKey);
|
|
276
|
+
const config = readSessionFullAccessOverride(session);
|
|
218
277
|
if (!hasTrustedPrincipal({ ...authorization.policyActor, ...current })
|
|
219
278
|
|| current.principalId !== authorization.authorizedBy
|
|
220
|
-
||
|
|
221
|
-
||
|
|
279
|
+
|| config?.enabled !== true
|
|
280
|
+
|| config.authorizedBy !== authorization.authorizedBy
|
|
222
281
|
|| !isAgentFullAccessOwner(authorization.agentAid, authorization.authorizedBy)) {
|
|
223
282
|
throw new Error('session fullaccess authorization is no longer active');
|
|
224
283
|
}
|
|
@@ -165,7 +165,7 @@ export async function generateCapsuleContent(chatDir, source, cause, reader) {
|
|
|
165
165
|
const peer = source.chatType === 'group' ? source.metadata?.groupId || source.channelId
|
|
166
166
|
: source.metadata?.peerId || source.channelId;
|
|
167
167
|
const config = resolveEffective({ self: source.selfAID,
|
|
168
|
-
peerKey: formatPeerKey(source.channelType || source.channel, peer) }, { cache: true
|
|
168
|
+
peerKey: formatPeerKey(source.channelType || source.channel, peer) }, { cache: true });
|
|
169
169
|
const selection = config.Services?.auxiliary;
|
|
170
170
|
if (selection?.model) {
|
|
171
171
|
const provider = createTextInferenceProvider(source.baseagent, config);
|
|
@@ -47,7 +47,7 @@ export function readSessionLoopConfig(target) {
|
|
|
47
47
|
const relation = readConfig(ConfigTarget.Relation, {
|
|
48
48
|
self: target.session.selfAID,
|
|
49
49
|
peerKey: target.peerKey,
|
|
50
|
-
}, { cache: true
|
|
50
|
+
}, { cache: true });
|
|
51
51
|
value = relation?.sessionLoop;
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
@@ -2243,6 +2243,26 @@ export class SessionManager {
|
|
|
2243
2243
|
if (e.code !== 'ENOENT')
|
|
2244
2244
|
throw e;
|
|
2245
2245
|
}
|
|
2246
|
+
// bg / trigger 会话目录只挪 meta 会留下 health.jsonl + 空 _threads/ + _trash/ 的空壳,
|
|
2247
|
+
// 永不回收(bg 的 instanceId 一次性,每跑一次整理多一个)。没有存活 meta 时整个目录删掉。
|
|
2248
|
+
// trigger 的 channelId 可复用:清理期间若又跑出了新 meta,目录保留。
|
|
2249
|
+
// 删不掉(Windows 文件占用)就退回上面的软删除结果,下次不再重试。
|
|
2250
|
+
const disposable = cid.startsWith('bg:')
|
|
2251
|
+
|| (cid.startsWith('trigger:') && scanMetaFiles(dirPath).length === 0 && scanMetaFiles(threadsDir).length === 0);
|
|
2252
|
+
if (disposable) {
|
|
2253
|
+
try {
|
|
2254
|
+
fs.rmSync(dirPath, { recursive: true, force: true });
|
|
2255
|
+
}
|
|
2256
|
+
catch (e) {
|
|
2257
|
+
logger.warn(`[SessionManager] 删除 bg 会话目录失败,保留软删除结果: ${dirPath}: ${e?.message}`);
|
|
2258
|
+
}
|
|
2259
|
+
for (const [id, found] of this.sessionFileIndex) {
|
|
2260
|
+
if (found.chatDir === dirPath)
|
|
2261
|
+
this.sessionFileIndex.delete(id);
|
|
2262
|
+
}
|
|
2263
|
+
if (this.knownChatDirs)
|
|
2264
|
+
this.knownChatDirs = this.knownChatDirs.filter(dir => dir !== dirPath);
|
|
2265
|
+
}
|
|
2246
2266
|
}
|
|
2247
2267
|
}
|
|
2248
2268
|
async createNewSession(channel, channelId, projectPath, name, baseagent, identityMetadata, eventMetadata) {
|
|
@@ -221,11 +221,11 @@ export class SessionRenewService {
|
|
|
221
221
|
let decision;
|
|
222
222
|
let source = 'model';
|
|
223
223
|
let judgeMetadata = {
|
|
224
|
-
model: effectiveConfig.Services?.decision
|
|
224
|
+
model: effectiveConfig.Services?.decision?.model,
|
|
225
225
|
threshold,
|
|
226
226
|
};
|
|
227
227
|
try {
|
|
228
|
-
const model =
|
|
228
|
+
const model = effectiveConfig.Services?.decision?.model?.trim();
|
|
229
229
|
if (!model)
|
|
230
230
|
throw new SessionRenewJudgeError('decision_model_missing');
|
|
231
231
|
const provider = this.inferenceProviderResolver.getDecisionInferenceProvider(request.selfAid);
|
|
@@ -306,7 +306,7 @@ export class SessionRenewService {
|
|
|
306
306
|
return resolveEffective({
|
|
307
307
|
self: request.selfAid,
|
|
308
308
|
peerKey,
|
|
309
|
-
}, { cache: true
|
|
309
|
+
}, { cache: true });
|
|
310
310
|
}
|
|
311
311
|
readConversationEntries(session) {
|
|
312
312
|
const entries = readAllJsonlLines(messageLogPath(this.sessionManager.getChatDir(session)));
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { parseDocument } from 'yaml';
|
|
4
4
|
import { resolveSkills } from './switch-resolver.js';
|
|
5
5
|
import { logger } from '../../utils/logger.js';
|
|
6
|
-
import { isDevMode } from '../../paths.js';
|
|
6
|
+
import { isDevMode, resolveRoot, getPackageRoot } from '../../paths.js';
|
|
7
7
|
import { isShippedPath, readVerifiedText } from '../file-integrity/read.js';
|
|
8
8
|
/**
|
|
9
9
|
* 生成索引文件(汇总 → 分组 → 落两文件)。
|
|
@@ -21,11 +21,14 @@ export function generateSkillIndexes(agentDir, override) {
|
|
|
21
21
|
const localSkills = skills.filter(s => s.source === 'local');
|
|
22
22
|
const indexDir = path.join(agentDir, 'skills');
|
|
23
23
|
fs.mkdirSync(indexDir, { recursive: true });
|
|
24
|
+
// 取各组根目录用于「路径规则」块
|
|
25
|
+
const builtinRoot = override?.builtin ?? path.join(getPackageRoot(), 'kits', 'skills');
|
|
26
|
+
const localRoot = override?.local ?? path.join(resolveRoot(), 'skills');
|
|
24
27
|
// ③ 分别生成(或清理)
|
|
25
|
-
generateOneIndex(indexDir, '.index-builtin.md', builtinSkills, 'builtin');
|
|
26
|
-
generateOneIndex(indexDir, '.index-local.md', localSkills, 'local');
|
|
28
|
+
generateOneIndex(indexDir, '.index-builtin.md', builtinSkills, 'builtin', builtinRoot);
|
|
29
|
+
generateOneIndex(indexDir, '.index-local.md', localSkills, 'local', localRoot);
|
|
27
30
|
}
|
|
28
|
-
function generateOneIndex(indexDir, filename, skills, label) {
|
|
31
|
+
function generateOneIndex(indexDir, filename, skills, label, skillRoot) {
|
|
29
32
|
const filePath = path.join(indexDir, filename);
|
|
30
33
|
// 空集:删除旧文件
|
|
31
34
|
if (skills.length === 0) {
|
|
@@ -40,12 +43,19 @@ function generateOneIndex(indexDir, filename, skills, label) {
|
|
|
40
43
|
加载方式:
|
|
41
44
|
EC 技能用 \`ec skill load <技能名>\` 加载,命令直接输出 SKILL.md 正文并附带技能目录的绝对路径。
|
|
42
45
|
它们不是宿主工具自带的技能或斜杠命令,用 Skill/斜杠命令加载会报 Unknown skill/未知命令。
|
|
46
|
+
|
|
47
|
+
路径规则:
|
|
48
|
+
根目录: ${skillRoot}
|
|
49
|
+
技能目录 = 根目录 + "${path.sep}" + 技能名
|
|
50
|
+
执行脚本时必须写完整绝对路径。
|
|
43
51
|
`;
|
|
44
|
-
// 技能条目(name + description
|
|
52
|
+
// 技能条目(name + description),并附示例路径
|
|
45
53
|
const items = [];
|
|
46
54
|
for (const skill of skills) {
|
|
47
55
|
const desc = readSkillDescription(skill.skillDir);
|
|
48
56
|
items.push(`- ${skill.name}\n ${desc || '(无描述)'}`);
|
|
57
|
+
// 示例路径:用真实技能名,不是占位符
|
|
58
|
+
items.push(` 示例(技能名为 ${skill.name}): ${path.join(skill.skillDir, 'SKILL.md')}`);
|
|
49
59
|
}
|
|
50
60
|
const content = header + '\n' + items.join('\n\n') + '\n';
|
|
51
61
|
fs.writeFileSync(filePath, content, 'utf-8');
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import path from 'path';
|
|
19
19
|
import { resolveRoot } from '../../paths.js';
|
|
20
|
-
import { parseCodexToolCommand } from '../permission/ec-command-parser.js';
|
|
20
|
+
import { parseCodexToolCommand, resolveCodexShellCarrierArgv, resolveCodexShellCarrierString, literalShellParseRemedy, } from '../permission/ec-command-parser.js';
|
|
21
21
|
import { canonicalToolCall } from '../permission/tool-canonical.js';
|
|
22
22
|
import { checkReadonly } from '../permission/tool-policy.js';
|
|
23
23
|
import { analyzeReadonlyShellQuery } from '../permission/readonly-shell-query.js';
|
|
@@ -29,7 +29,8 @@ const MEMORY_MANIFEST = 'eck_manifest.memory.json';
|
|
|
29
29
|
const ALLOWED_MEMORY_SUBCOMMANDS = new Set(['create', 'update', 'archive']);
|
|
30
30
|
const BASH_COMMAND_RULE = 'Bash 只允许两类命令:单条 `ec memory create|update|archive`(不能与其他命令拼接);'
|
|
31
31
|
+ '或路径落在可读根内、可证明只读的查询(如 ls / cat / grep),多条查询可用 `&&` 或 `;` 连接,最多 8 段。'
|
|
32
|
-
+ '
|
|
32
|
+
+ '有文件工具时用 Read / Glob / Grep;只有 Bash/Shell 时可用 cat,明确的 pwsh/powershell -NoProfile -Command 包装内可用单条 Get-Content -LiteralPath <绝对路径> [-Raw]。'
|
|
33
|
+
+ '整理反馈用文件写入工具写到任务书指定的反馈文件。';
|
|
33
34
|
function layerDir(layer, ctx) {
|
|
34
35
|
const root = resolveRoot();
|
|
35
36
|
if (layer === 'agent')
|
|
@@ -68,14 +69,19 @@ export function memoryReadRoots(ctx) {
|
|
|
68
69
|
case 'profile':
|
|
69
70
|
add(...consolidated('relation'), messages);
|
|
70
71
|
break;
|
|
71
|
-
case 'forget':
|
|
72
|
+
case 'forget': {
|
|
72
73
|
// 一次会话只审一层:关系层由关系整理链逐关系审,agent 层只审 personal/memory 自身
|
|
73
74
|
if (ctx.memoryScope) {
|
|
74
75
|
add(...consolidated(ctx.memoryScope));
|
|
76
|
+
// 本层的遗忘日志:只给这一个文件,不给 archive/ 整个目录(归档的记忆正文不该进审查范围)
|
|
77
|
+
const layer = layerDir(ctx.memoryScope, ctx);
|
|
78
|
+
if (layer)
|
|
79
|
+
add(path.join(layer, 'archive', 'FORGET-LOG.md'));
|
|
75
80
|
if (ctx.memoryScope === 'relation')
|
|
76
81
|
add(messages);
|
|
77
82
|
}
|
|
78
83
|
break;
|
|
84
|
+
}
|
|
79
85
|
default:
|
|
80
86
|
break;
|
|
81
87
|
}
|
|
@@ -161,17 +167,46 @@ function isAllowedMemoryCommand(argv) {
|
|
|
161
167
|
return argv[0] === 'ec' && argv[1] === 'memory' && ALLOWED_MEMORY_SUBCOMMANDS.has(argv[2] ?? '');
|
|
162
168
|
}
|
|
163
169
|
function checkShell(input, ctx) {
|
|
164
|
-
const parsed = parseCodexToolCommand(input);
|
|
170
|
+
const parsed = parseCodexToolCommand(input, { managedTempDir: ctx.managedTempDir });
|
|
165
171
|
if (parsed.ok && isAllowedMemoryCommand(parsed.argv))
|
|
166
172
|
return { allow: true, ecCommand: true };
|
|
173
|
+
const shellCarrier = Array.isArray(input.commandArgv) && input.commandArgv.every(value => typeof value === 'string')
|
|
174
|
+
? resolveCodexShellCarrierArgv(input.commandArgv)
|
|
175
|
+
: typeof input.command === 'string' ? resolveCodexShellCarrierString(input.command) : undefined;
|
|
176
|
+
if (shellCarrier?.dialect === 'powershell' && parsed.ok && parsed.argv[0]?.toLowerCase() === 'get-content') {
|
|
177
|
+
const argv = parsed.argv;
|
|
178
|
+
if ((argv.length !== 3 && argv.length !== 4)
|
|
179
|
+
|| argv[1].toLowerCase() !== '-literalpath'
|
|
180
|
+
|| (argv.length === 4 && argv[3].toLowerCase() !== '-raw')
|
|
181
|
+
|| !path.isAbsolute(argv[2])
|
|
182
|
+
|| /[\0\r\n]/u.test(argv[2])
|
|
183
|
+
|| (process.platform === 'win32' && /:/u.test(argv[2].replace(/^[a-z]:/i, '')))) {
|
|
184
|
+
return deny('memory_session_command_forbidden', BASH_COMMAND_RULE);
|
|
185
|
+
}
|
|
186
|
+
const result = checkReadWithinMatrix('Read', { file_path: argv[2] }, ctx);
|
|
187
|
+
return result.behavior === 'allow'
|
|
188
|
+
? { allow: true }
|
|
189
|
+
: deny('memory_session_command_forbidden', result.message);
|
|
190
|
+
}
|
|
191
|
+
if (shellCarrier?.parseFailure || (shellCarrier && shellCarrier.dialect !== 'posix')) {
|
|
192
|
+
return deny('memory_session_command_forbidden', BASH_COMMAND_RULE);
|
|
193
|
+
}
|
|
194
|
+
if (Array.isArray(input.commandArgv) && !parsed.ok) {
|
|
195
|
+
return deny('memory_session_command_forbidden', BASH_COMMAND_RULE);
|
|
196
|
+
}
|
|
197
|
+
const readonlyInput = shellCarrier
|
|
198
|
+
? { ...input, command: shellCarrier.command }
|
|
199
|
+
: Array.isArray(input.commandArgv) && parsed.ok
|
|
200
|
+
? { ...input, command: parsed.argv.map(value => "'" + value.replaceAll("'", "'\\''") + "'").join(' ') }
|
|
201
|
+
: input;
|
|
167
202
|
// Codex 没有 Read 工具,读任务书只能靠可证明只读的 shell 查询
|
|
168
|
-
const readonly = checkReadWithinMatrix('Bash',
|
|
203
|
+
const readonly = checkReadWithinMatrix('Bash', readonlyInput, ctx);
|
|
169
204
|
if (readonly.behavior === 'allow')
|
|
170
205
|
return { allow: true };
|
|
171
|
-
const rawCommand = typeof
|
|
206
|
+
const rawCommand = typeof readonlyInput.command === 'string' ? readonlyInput.command : '';
|
|
172
207
|
// ec 命令按 ec 解析器归因;ec 解析器的 issue 只描述 ec 命令,不能拿来解释普通 shell 查询
|
|
173
208
|
if (looksLikeMemoryCommand(rawCommand)) {
|
|
174
|
-
const remedy = parsed.ok ? undefined : shellIssueRemedy(parsed.issue);
|
|
209
|
+
const remedy = parsed.ok ? undefined : literalShellParseRemedy(parsed) ?? shellIssueRemedy(parsed.issue);
|
|
175
210
|
if (remedy) {
|
|
176
211
|
return deny('memory_session_command_forbidden', `这条命令本身就是 \`ec memory\`,但未能解析成单条字面命令。${remedy}`);
|
|
177
212
|
}
|
|
@@ -210,7 +245,7 @@ function readonlyDenialHint(command, policyCode, ctx) {
|
|
|
210
245
|
+ '静态确定不了会读哪些文件。列文件请用 Glob 并给绝对 path。';
|
|
211
246
|
case 'unsupported-command-or-option':
|
|
212
247
|
return '命令或选项不在只读查询白名单内。不需要 `cd`:把绝对路径直接写进命令里。'
|
|
213
|
-
+ '
|
|
248
|
+
+ '只有 Shell 时用 cat,或在明确的 pwsh/powershell -NoProfile -Command 包装内使用 Get-Content -LiteralPath <绝对路径> [-Raw];有文件工具时也可用 Read / Glob / Grep。';
|
|
214
249
|
case 'unsupported-pipeline-filter':
|
|
215
250
|
return '管道 `|` 后面的命令不是纯 stdin 过滤命令。';
|
|
216
251
|
case 'pipeline-filter-must-use-stdin':
|
|
@@ -210,7 +210,11 @@ export class ThreadService {
|
|
|
210
210
|
topicStatus: last.topicStatus ?? 'pending',
|
|
211
211
|
createdAt: last.createdAt ?? 0,
|
|
212
212
|
lastActiveAt: last.updatedAt ?? 0,
|
|
213
|
-
...(
|
|
213
|
+
...(typeof last.metadata?.nameUpdatedAt === 'number'
|
|
214
|
+
? { nameUpdatedAt: last.metadata.nameUpdatedAt }
|
|
215
|
+
: typeof last.nameUpdatedAt === 'number'
|
|
216
|
+
? { nameUpdatedAt: last.nameUpdatedAt }
|
|
217
|
+
: {}),
|
|
214
218
|
};
|
|
215
219
|
}
|
|
216
220
|
catch {
|
|
@@ -253,7 +257,7 @@ export class ThreadService {
|
|
|
253
257
|
peer, // channelId
|
|
254
258
|
'', // defaultProjectPath — threads are not bound to a project
|
|
255
259
|
threadId, // threadId
|
|
256
|
-
{ peerName: peer }, // metadata
|
|
260
|
+
{ peerName: peer, nameUpdatedAt: now }, // metadata
|
|
257
261
|
sanitized, // name
|
|
258
262
|
undefined, // userId
|
|
259
263
|
peerKind === 'group' ? 'group' : 'private', // chatType
|
|
@@ -271,6 +275,7 @@ export class ThreadService {
|
|
|
271
275
|
channelType: 'aun',
|
|
272
276
|
peerKind,
|
|
273
277
|
name: sanitized,
|
|
278
|
+
nameUpdatedAt: now,
|
|
274
279
|
label: label ?? null,
|
|
275
280
|
topicStatus: topicStatus ?? 'pending',
|
|
276
281
|
createdAt: now,
|
|
@@ -321,7 +326,7 @@ export class ThreadService {
|
|
|
321
326
|
throw new ThreadServiceError(`话题不存在: ${threadId}`, 'TOPIC_NOT_FOUND');
|
|
322
327
|
if (entry.name === sanitized)
|
|
323
328
|
return { changed: false, name: sanitized };
|
|
324
|
-
const nameUpdatedAt = Date.now();
|
|
329
|
+
const nameUpdatedAt = Math.max(Date.now(), Number(entry.nameUpdatedAt ?? entry.createdAt ?? 0) + 1);
|
|
325
330
|
entry.name = sanitized;
|
|
326
331
|
entry.nameUpdatedAt = nameUpdatedAt;
|
|
327
332
|
entry.lastActiveAt = nameUpdatedAt;
|
|
@@ -330,7 +335,7 @@ export class ThreadService {
|
|
|
330
335
|
// Sync to session
|
|
331
336
|
const session = await this.sessionManager.getThreadSession(entryChannelType(entry), entry.peer, threadId, selfAid);
|
|
332
337
|
if (session) {
|
|
333
|
-
await this.sessionManager.renameSession(session.id, sanitized);
|
|
338
|
+
await this.sessionManager.renameSession(session.id, sanitized, nameUpdatedAt);
|
|
334
339
|
}
|
|
335
340
|
return { changed: true, name: sanitized, nameUpdatedAt, peerKind: entry.peerKind };
|
|
336
341
|
}
|
|
@@ -390,7 +395,7 @@ export class ThreadService {
|
|
|
390
395
|
this.appendThreadSnapshot(input.selfAid, entry);
|
|
391
396
|
const session = await this.sessionManager.getThreadSession(entryChannelType(entry), entry.peer, input.threadId, input.selfAid);
|
|
392
397
|
if (session)
|
|
393
|
-
await this.sessionManager.renameSession(session.id, sanitized);
|
|
398
|
+
await this.sessionManager.renameSession(session.id, sanitized, input.nameUpdatedAt);
|
|
394
399
|
return { applied: true };
|
|
395
400
|
}
|
|
396
401
|
// ── P1a.1.6: 话题标签 ──
|
|
@@ -790,6 +795,11 @@ export class ThreadService {
|
|
|
790
795
|
channelType: parsedDir?.channelType ?? 'aun',
|
|
791
796
|
peerKind: last.chatType === 'group' ? 'group' : 'private',
|
|
792
797
|
name: last.name ?? last.threadId,
|
|
798
|
+
...(typeof last.metadata?.nameUpdatedAt === 'number'
|
|
799
|
+
? { nameUpdatedAt: last.metadata.nameUpdatedAt }
|
|
800
|
+
: typeof last.nameUpdatedAt === 'number'
|
|
801
|
+
? { nameUpdatedAt: last.nameUpdatedAt }
|
|
802
|
+
: {}),
|
|
793
803
|
label: last.label ?? null,
|
|
794
804
|
topicStatus: last.topicStatus ?? 'pending',
|
|
795
805
|
createdAt: last.createdAt ?? 0,
|
|
@@ -973,7 +983,10 @@ export class ThreadService {
|
|
|
973
983
|
id: latest.id ?? entry.sessionId,
|
|
974
984
|
projectPath: latest.projectPath ?? '',
|
|
975
985
|
chatType: entry.peerKind === 'group' ? 'group' : 'private',
|
|
976
|
-
metadata:
|
|
986
|
+
metadata: {
|
|
987
|
+
...(latest.metadata ?? {}),
|
|
988
|
+
...(entry.nameUpdatedAt !== undefined ? { nameUpdatedAt: entry.nameUpdatedAt } : {}),
|
|
989
|
+
},
|
|
977
990
|
// topic metadata — updated values
|
|
978
991
|
threadId: entry.threadId,
|
|
979
992
|
channelIdAlias: entry.peer,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { agentDir } from '../paths.js';
|
|
4
|
+
import { ownerResolver } from '../core/ownership/owner-resolver.js';
|
|
5
|
+
import { OwnerDirectoryCache, OWNER_DIRECTORY_INITIAL_WAIT_MS, OWNER_DIRECTORY_SCOPES, } from './owner-directory-cache.js';
|
|
6
|
+
const liveDirectories = new Map();
|
|
7
|
+
// Coalesce negative lookups from unrelated senders as well as concurrent calls.
|
|
8
|
+
const MISS_REFRESH_INTERVAL_MS = 60_000;
|
|
9
|
+
/** Register only the channel's existing client-backed cache; no SDK connections are created here. */
|
|
10
|
+
export function registerOwnerDirectoryAdmission(input) {
|
|
11
|
+
const current = liveDirectories.get(input.selfAid);
|
|
12
|
+
if (current?.cache === input.cache)
|
|
13
|
+
return;
|
|
14
|
+
liveDirectories.set(input.selfAid, { ...input, missAttemptAt: {} });
|
|
15
|
+
}
|
|
16
|
+
/** Cache misses get one bounded synchronization attempt before admission, using the live channel. */
|
|
17
|
+
export async function prepareOwnerDirectoryAdmission(selfAid, aid) {
|
|
18
|
+
const live = liveDirectories.get(selfAid);
|
|
19
|
+
if (!live)
|
|
20
|
+
return;
|
|
21
|
+
if (!live.isCurrent()) {
|
|
22
|
+
liveDirectories.delete(selfAid);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (ownerResolver.owner(selfAid) !== live.ownerAid)
|
|
26
|
+
return;
|
|
27
|
+
const agents = live.cache.readSnapshot('agents');
|
|
28
|
+
if (agents?.entries.some(entry => entry.aid === aid)) {
|
|
29
|
+
// The higher-priority Agent category is already known. Only its stale refresh may run.
|
|
30
|
+
void live.cache.lookupByAid('agents', aid).catch(() => { });
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const contacts = live.cache.readSnapshot('contacts');
|
|
34
|
+
if (contacts?.entries.some(entry => entry.aid === aid)
|
|
35
|
+
&& (agents || live.cache.scopeAccess('agents') === 'not_authorized')) {
|
|
36
|
+
void live.cache.refreshIfNeeded().catch(() => { });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const tasks = [];
|
|
40
|
+
for (const scope of OWNER_DIRECTORY_SCOPES) {
|
|
41
|
+
if (live.cache.scopeAccess(scope) !== 'authorized')
|
|
42
|
+
continue;
|
|
43
|
+
const found = live.cache.readSnapshot(scope)?.entries.some(entry => entry.aid === aid);
|
|
44
|
+
const now = Date.now();
|
|
45
|
+
if (!found) {
|
|
46
|
+
if (now - (live.missAttemptAt[scope] ?? 0) < MISS_REFRESH_INTERVAL_MS)
|
|
47
|
+
continue;
|
|
48
|
+
live.missAttemptAt[scope] = now;
|
|
49
|
+
}
|
|
50
|
+
tasks.push(live.cache.lookupByAid(scope, aid));
|
|
51
|
+
}
|
|
52
|
+
if (tasks.length === 0)
|
|
53
|
+
return;
|
|
54
|
+
let timer;
|
|
55
|
+
try {
|
|
56
|
+
await Promise.race([
|
|
57
|
+
Promise.allSettled(tasks),
|
|
58
|
+
new Promise(resolve => { timer = setTimeout(resolve, OWNER_DIRECTORY_INITIAL_WAIT_MS); }),
|
|
59
|
+
]);
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
if (timer)
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Local-only classification. A stale or changed Owner can never authorize an old snapshot. */
|
|
67
|
+
export function readOwnerDirectoryMembership(selfAid, aid) {
|
|
68
|
+
const directory = path.join(agentDir(selfAid), 'directory');
|
|
69
|
+
const configured = ['authorization.json', 'authorization.json_', 'agents.json', 'contacts.json']
|
|
70
|
+
.some(name => fs.existsSync(path.join(directory, name)));
|
|
71
|
+
if (!configured)
|
|
72
|
+
return undefined;
|
|
73
|
+
const unknown = { agents: 'unavailable', contacts: 'unavailable' };
|
|
74
|
+
const ownerAid = ownerResolver.owner(selfAid);
|
|
75
|
+
if (!ownerAid)
|
|
76
|
+
return unknown;
|
|
77
|
+
try {
|
|
78
|
+
const cache = new OwnerDirectoryCache({ selfAid, ownerAid, directory });
|
|
79
|
+
const membership = { ...unknown };
|
|
80
|
+
for (const scope of OWNER_DIRECTORY_SCOPES) {
|
|
81
|
+
const access = cache.scopeAccess(scope);
|
|
82
|
+
if (access === 'not_authorized')
|
|
83
|
+
membership[scope] = 'not_authorized';
|
|
84
|
+
else if (access === 'authorized') {
|
|
85
|
+
const snapshot = cache.readSnapshot(scope);
|
|
86
|
+
if (snapshot)
|
|
87
|
+
membership[scope] = snapshot.entries.some(entry => entry.aid === aid) ? 'found' : 'not_found';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return membership;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return unknown;
|
|
94
|
+
}
|
|
95
|
+
}
|