evolcore 0.0.41-test.1 → 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 +49 -36
- package/dist/agents/baseagent.js +68 -6
- package/dist/agents/codex-runner.js +62 -43
- 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/menu/client.js +27 -0
- package/dist/aun/msg/p2p.js +3 -8
- package/dist/aun/service-proxy.js +17 -0
- package/dist/channels/aun.js +321 -34
- 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 +44 -16
- package/dist/cli/daemon-commands.js +1 -0
- package/dist/cli/index.js +24 -1
- package/dist/cli/init-channel.js +1 -1
- package/dist/cli/init.js +75 -1
- package/dist/cli/managed-command-guard.js +13 -1
- package/dist/cli/provider-command.js +57 -0
- package/dist/cli/restart-monitor.js +4 -2
- package/dist/cli/stats.js +10 -3
- package/dist/cli/task-context.js +19 -0
- package/dist/config/boot-log.js +3 -2
- package/dist/config/config-field-policy.js +12 -7
- package/dist/config/config-manager.js +138 -6
- package/dist/config/owner-config.js +2 -2
- package/dist/config/peer-role-resolver.js +2 -1
- package/dist/config/provider-ipc-service.js +132 -0
- package/dist/config/provider-menu-request.js +58 -0
- package/dist/config/providers-management.js +78 -5
- package/dist/config/resolved-config-op.js +8 -1
- package/dist/config/schema-migration.js +322 -8
- package/dist/config-store.js +10 -1
- package/dist/contracts/ecweb-service-protocol.js +2 -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 +193 -23
- package/dist/core/auth/agent-delegation.js +4 -2
- package/dist/core/auth/auth-gateway.js +66 -1
- package/dist/core/auth/authorization-audit.js +41 -5
- package/dist/core/auth/delegation-authorization.js +2 -1
- package/dist/core/auth/operation-authorizer.js +28 -6
- package/dist/core/auth/operation-catalog.js +14 -1
- package/dist/core/channel-loader.js +2 -0
- package/dist/core/command/agent-control.js +257 -14
- package/dist/core/command/cli-intent-parser.js +6 -2
- package/dist/core/command/command-handler.js +64 -55
- package/dist/core/command/memory-slash.js +1 -1
- package/dist/core/command/menu-catalog.js +5 -0
- package/dist/core/command/menu-handler.js +64 -18
- package/dist/core/command/menu-protocol.js +15 -1
- package/dist/core/command/provider-menu.js +46 -0
- package/dist/core/command/slash-handler.js +2 -1
- package/dist/core/daemon-control.js +18 -13
- package/dist/core/event-catalog.js +10 -0
- package/dist/core/evolagent-registry.js +3 -1
- package/dist/core/evolagent.js +8 -6
- package/dist/core/file-integrity/store.js +11 -0
- package/dist/core/handoff/ipc-registration.js +3 -0
- package/dist/core/initialization/service.js +491 -0
- package/dist/core/ipc-registration.js +34 -22
- package/dist/core/memory/consolidation-ops-records.js +95 -0
- package/dist/core/memory/consolidation-trigger.js +19 -2
- package/dist/core/memory/consolidation.js +19 -8
- package/dist/core/memory/memory-admin.js +1 -1
- package/dist/core/memory/relation-sweep.js +11 -6
- package/dist/core/message/aun-ipc-sender.js +73 -67
- package/dist/core/message/im-renderer.js +18 -0
- package/dist/core/message/message-bridge.js +35 -3
- package/dist/core/message/response-engine.js +32 -28
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/model/config-scope.js +5 -7
- package/dist/core/ownership/owner-resolver.js +755 -143
- package/dist/core/permission/approval-gateway.js +103 -403
- package/dist/core/permission/ec-command-parser.js +32 -4
- package/dist/core/permission/index.js +1 -0
- package/dist/core/permission/permission-result.js +78 -0
- package/dist/core/permission/tool-policy.js +7 -43
- package/dist/core/system-session/memory.js +37 -7
- package/dist/directory/owner-directory-cache.js +2 -2
- package/dist/ecweb/init-menu.js +32 -0
- package/dist/index.js +17 -5
- package/dist/ipc.js +85 -25
- package/dist/paths.js +3 -0
- package/dist/proxy/manager.js +6 -7
- 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/error-utils.js +24 -0
- package/dist/utils/logger.js +68 -1
- 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/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 +11 -1
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/provider.md +50 -0
- package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
- package/kits/rules/01-overview.md +3 -0
- package/kits/rules/04-relation.md +1 -1
- package/kits/schemas/_meta.json +2 -2
- package/kits/schemas/agent-config.schema.16.json +3 -3
- package/kits/schemas/relation-config.schema.11.json +17 -0
- package/kits/skills/.switches.json +8 -0
- package/kits/skills/ec-agent-create/SKILL.md +3 -0
- package/kits/skills/ec-identity/SKILL.md +2 -2
- package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
- package/kits/skills/ec-trigger/SKILL.md +5 -13
- package/kits/skills/thread-ops/SKILL.md +5 -0
- package/kits/templates/system-fragments/venue.md +1 -1
- package/package.json +3 -3
- package/dist/core/memory/forget-log.js +0 -96
- package/dist/core/message/create-status.js +0 -96
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
1
3
|
import { buildReloadHooks } from './channel-loader.js';
|
|
2
4
|
import { AgentReloadBusyError, AgentReloadCoordinator } from './agent-reload-coordinator.js';
|
|
3
5
|
import { detectDuplicates } from './evolagent-registry.js';
|
|
4
6
|
import { createRunnerReloadTransaction, disposeAgentInstances } from './runner-reload-transaction.js';
|
|
5
|
-
import { ConfigTarget, read as readConfig } from '../config/config-manager.js';
|
|
7
|
+
import { ConfigTarget, assertAgentAidAvailable, read as readConfig } from '../config/config-manager.js';
|
|
6
8
|
import { invalidateKitCache } from '../eck/kit-renderer.js';
|
|
7
9
|
import { logger } from '../utils/logger.js';
|
|
8
10
|
import fs from 'fs';
|
|
9
11
|
import path from 'path';
|
|
10
12
|
import { resolvePaths } from '../paths.js';
|
|
11
|
-
import { ownerResolver
|
|
12
|
-
import { AgentInitializationService, readInitialization } from '../cli/agent-create.js';
|
|
13
|
+
import { ownerResolver } from './ownership/owner-resolver.js';
|
|
14
|
+
import { AgentInitializationService, InitializationStateError, initializationErrorCode, readInitialization } from '../cli/agent-create.js';
|
|
15
|
+
import { getAidStore, loadClient } from '../aun/aid/store.js';
|
|
16
|
+
import { isValidAid } from '../aun/aid/validation.js';
|
|
13
17
|
export function loadStartupAgentRegistry(agentRegistry) {
|
|
14
18
|
agentRegistry.loadAll();
|
|
15
19
|
const agentInfos = agentRegistry.list();
|
|
@@ -211,35 +215,81 @@ export function createAgentReloadRuntime({ agentRegistry, agentLoader, sessionMa
|
|
|
211
215
|
});
|
|
212
216
|
return { reloadHooks, reloadCoordinator };
|
|
213
217
|
}
|
|
218
|
+
/** A strict authoritative observation for the initialization completion gate. */
|
|
219
|
+
export async function checkInitializationOwner(aid, expectedOwnerAid, expectedRelationVersion) {
|
|
220
|
+
const view = await ownerResolver.refresh(aid, { force: true, allowTransient: false });
|
|
221
|
+
const checkedAt = view.refreshFailure ? undefined : view.checkedAt;
|
|
222
|
+
const consensus = view.consensus;
|
|
223
|
+
const relationVersion = consensus?.relation_version;
|
|
224
|
+
const lock = consensus?.lock;
|
|
225
|
+
const details = view.refreshFailure
|
|
226
|
+
? { consensusStatus: 'unavailable',
|
|
227
|
+
code: initializationErrorCode(view.refreshFailure, 'INITIALIZE_OWNER_CHECK_FAILED'),
|
|
228
|
+
retryable: view.refreshFailure.kind === 'transient' }
|
|
229
|
+
: {
|
|
230
|
+
consensusStatus: view.consensusStatus,
|
|
231
|
+
...(typeof relationVersion === 'number' && Number.isSafeInteger(relationVersion) && relationVersion >= 0 ? { relationVersion } : {}),
|
|
232
|
+
...(lock === 'locked' || lock === 'unlocked' ? { lock } : {}),
|
|
233
|
+
...(consensus?.code !== undefined ? { code: initializationErrorCode(consensus, 'INITIALIZE_OWNER_CHECK_FAILED') } : {}),
|
|
234
|
+
...(typeof consensus?.retryable === 'boolean' ? { retryable: consensus.retryable } : {}),
|
|
235
|
+
};
|
|
236
|
+
if (view.consensusStatus === 'consensus' && view.authorizationStatus === 'verified'
|
|
237
|
+
&& (expectedRelationVersion === undefined || view.consensus?.relation_version === expectedRelationVersion)
|
|
238
|
+
&& checkedAt !== undefined)
|
|
239
|
+
return {
|
|
240
|
+
status: view.ownerAid === expectedOwnerAid ? 'confirmed' : 'conflict',
|
|
241
|
+
ownerAid: view.ownerAid, checkedAt, ...details,
|
|
242
|
+
};
|
|
243
|
+
return { status: 'pending', ...(checkedAt !== undefined ? { checkedAt } : {}), ...details };
|
|
244
|
+
}
|
|
214
245
|
export function createAgentInitializationRuntime({ agentRegistry, agentMap, channelInstances, hotLoad, activate, }) {
|
|
215
246
|
const isConnected = (aid) => channelInstances.some(instance => instance.channelType === 'aun'
|
|
216
247
|
&& instance.channel.getAidState?.()?.aid === aid
|
|
217
248
|
&& instance.channel.getAidState?.()?.status === 'connected');
|
|
218
249
|
return new AgentInitializationService({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
250
|
+
ownershipBeforePublication: true,
|
|
251
|
+
register: async (aid, _ownerAid, mode) => {
|
|
252
|
+
assertAgentAidAvailable(aid);
|
|
253
|
+
const { aidCreate, aidCreateIdentityOnly } = await import('../aun/aid/identity.js');
|
|
254
|
+
const { assertAgentIdentityReusable } = await import('../aun/aid/agentmd.js');
|
|
255
|
+
const created = mode === 'one_shot'
|
|
256
|
+
? await aidCreateIdentityOnly(aid)
|
|
257
|
+
: await aidCreate(aid, { type: 'agent' });
|
|
258
|
+
try {
|
|
259
|
+
if (created.alreadyExisted)
|
|
260
|
+
await assertAgentIdentityReusable(aid, { store: created.store });
|
|
261
|
+
}
|
|
262
|
+
finally {
|
|
263
|
+
try {
|
|
264
|
+
await created.client.close();
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
created.store.close();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
225
270
|
},
|
|
226
271
|
bindOwner: async (aid, ownerAid) => {
|
|
227
|
-
|
|
272
|
+
// Keep the exact SDK task returned by this invocation. The
|
|
273
|
+
// initialization service validates and persists its operation ID beside
|
|
274
|
+
// the creation receipt; it must never reconstruct a task from snapshot().
|
|
275
|
+
return readInitialization(aid)?.mode === 'one_shot'
|
|
276
|
+
? await bindInitializationOwner(aid, ownerAid)
|
|
277
|
+
: await ownerResolver.bind(aid, ownerAid);
|
|
228
278
|
},
|
|
229
279
|
ownerBindActive: (aid, ownerAid) => {
|
|
230
280
|
const task = ownerResolver.snapshot(aid).task;
|
|
231
281
|
return task?.operation === 'bind' && task.owner_aid === ownerAid
|
|
232
282
|
&& (task.status === 'pending' || task.status === 'completed');
|
|
233
283
|
},
|
|
234
|
-
checkOwner:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
284
|
+
checkOwner: (aid, ownerAid) => isConnected(aid)
|
|
285
|
+
? checkInitializationOwner(aid, ownerAid, readInitialization(aid)?.mode === 'one_shot' ? 1 : undefined)
|
|
286
|
+
: checkBootstrapInitializationOwner(aid, ownerAid),
|
|
287
|
+
publish: async (aid, content, ownerAid) => {
|
|
288
|
+
const { agentmdPut, agentmdPutInitializationProfile } = await import('../aun/aid/agentmd.js');
|
|
289
|
+
if (ownerAid)
|
|
290
|
+
await agentmdPutInitializationProfile(content, { aid, ownerAid });
|
|
291
|
+
else
|
|
292
|
+
await agentmdPut(content, { aid });
|
|
243
293
|
},
|
|
244
294
|
fetch: async (aid) => {
|
|
245
295
|
const { agentmdGet } = await import('../aun/aid/agentmd.js');
|
|
@@ -271,16 +321,26 @@ export function recoverIncompleteAgentInitializations(service, agentsDir = resol
|
|
|
271
321
|
continue;
|
|
272
322
|
try {
|
|
273
323
|
const record = readInitialization(entry.name);
|
|
274
|
-
if (record?.status === 'in_progress')
|
|
275
|
-
service.resume(entry.name, record.actor);
|
|
324
|
+
if (record?.status === 'in_progress') {
|
|
325
|
+
service.resume(entry.name, record.actor, record.mode === 'one_shot' ? record.clientRequestId : undefined);
|
|
326
|
+
}
|
|
276
327
|
}
|
|
277
|
-
catch {
|
|
278
|
-
|
|
328
|
+
catch (error) {
|
|
329
|
+
const code = error?.code;
|
|
330
|
+
logger.warn(`[Initialization] Recovery requires review for an incomplete operation ${JSON.stringify({
|
|
331
|
+
aid: entry.name,
|
|
332
|
+
errorCode: typeof code === 'string' && /^[A-Z][A-Z0-9_]{0,63}$/.test(code)
|
|
333
|
+
? code : 'INITIALIZE_RECOVERY_FAILED',
|
|
334
|
+
...(error instanceof InitializationStateError ? {
|
|
335
|
+
validationFailure: error.validationFailure, ...error.fingerprintDiagnostic,
|
|
336
|
+
} : {}),
|
|
337
|
+
})}`);
|
|
279
338
|
}
|
|
280
339
|
}
|
|
281
340
|
}
|
|
282
341
|
export function createAgentRuntimeOperations({ agentRegistry, agentLoader, sessionManager, agentMap, permissionGateway, processor, channelLoader, channelInstances, registerChannelInstance, markChannelConnected, aidStatsCollector, handoffRuntime, triggerSchedulers, ensureTriggerSchedulerStarted, startTriggerScheduler, reloadCoordinator, unregisterRuntimeChannel, messageQueue, setAgentRuntimeState, setAgentRuntimeError, }) {
|
|
283
342
|
const hotLoad = async (aid) => {
|
|
343
|
+
assertAgentAidAvailable(aid);
|
|
284
344
|
handoffRuntime.pauseAgent(aid);
|
|
285
345
|
let resumed = false;
|
|
286
346
|
try {
|
|
@@ -450,3 +510,113 @@ export function createAgentRuntimeOperations({ agentRegistry, agentLoader, sessi
|
|
|
450
510
|
};
|
|
451
511
|
return { hotLoad, resync };
|
|
452
512
|
}
|
|
513
|
+
// fastaun 0.5.28 start()/capture() only read and verify documents. All writes
|
|
514
|
+
// and notifications occur in execute(), which converts transport failures to
|
|
515
|
+
// an error task with its original operation_id. Only this audited artifact
|
|
516
|
+
// therefore proves that a raw ECONNRESET rejection preceded submission.
|
|
517
|
+
// A different SDK version or workflow must fall back to unknown until its
|
|
518
|
+
// boundary is reviewed, even when another version reuses this workflow file.
|
|
519
|
+
const AUDITED_SDK_VERSION = '0.5.28';
|
|
520
|
+
const AUDITED_WORKFLOW_SHA256 = 'cd736d1fcce0812013ba7d7c2148f86c8f3d3d2d39e451e52a0f9cc2a4d4fb51';
|
|
521
|
+
export function initializationBindPreflightFailure(error) {
|
|
522
|
+
if (!(error instanceof Error) || error.code !== 'ECONNRESET')
|
|
523
|
+
return false;
|
|
524
|
+
try {
|
|
525
|
+
const entry = import.meta.resolve('@agentunion/fastaun');
|
|
526
|
+
const manifest = JSON.parse(readFileSync(new URL('../package.json', entry), 'utf8'));
|
|
527
|
+
if (manifest.version !== AUDITED_SDK_VERSION)
|
|
528
|
+
return false;
|
|
529
|
+
const workflow = new URL('ownership-workflow.js', entry);
|
|
530
|
+
return createHash('sha256').update(readFileSync(workflow)).digest('hex') === AUDITED_WORKFLOW_SHA256;
|
|
531
|
+
}
|
|
532
|
+
catch {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
/** Initial binding precedes the daemon channel; use an independent short slot. */
|
|
537
|
+
async function withInitializationClient(aid, action) {
|
|
538
|
+
let store;
|
|
539
|
+
let client;
|
|
540
|
+
let actionStarted = false;
|
|
541
|
+
try {
|
|
542
|
+
store = await getAidStore({ slotId: 'evolcore-initialization' });
|
|
543
|
+
client = await loadClient(store, aid);
|
|
544
|
+
if (client.currentAid?.aid !== aid || !client.currentAid.isCertValid() || !client.currentAid.isPrivateKeyValid()) {
|
|
545
|
+
throw Object.assign(new Error('Initialization identity is unavailable'), { code: 'INITIALIZE_IDENTITY_UNAVAILABLE' });
|
|
546
|
+
}
|
|
547
|
+
await client.connect({ connection_kind: 'short', short_ttl_ms: 120_000,
|
|
548
|
+
background_sync: false, auto_reconnect: false, connect_timeout: 10, call_timeout: 30 });
|
|
549
|
+
// An entered bind can have remote effects. Its adapter may only mark an
|
|
550
|
+
// audited read-only preflight as not started; all other failures stay unknown.
|
|
551
|
+
actionStarted = true;
|
|
552
|
+
return await action(client);
|
|
553
|
+
}
|
|
554
|
+
catch (error) {
|
|
555
|
+
if (!actionStarted) {
|
|
556
|
+
const original = error instanceof Error ? error : new Error(String(error));
|
|
557
|
+
throw Object.assign(new Error(original.message), {
|
|
558
|
+
code: 'INITIALIZE_BIND_NOT_STARTED',
|
|
559
|
+
cause: error,
|
|
560
|
+
causeCode: error?.code,
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
throw error;
|
|
564
|
+
}
|
|
565
|
+
finally {
|
|
566
|
+
// A close failure must not discard the exact task already returned by bind.
|
|
567
|
+
try {
|
|
568
|
+
await client?.close();
|
|
569
|
+
}
|
|
570
|
+
catch { /* preserve operation result */ }
|
|
571
|
+
try {
|
|
572
|
+
store?.close();
|
|
573
|
+
}
|
|
574
|
+
catch { /* preserve operation result */ }
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
export async function bindInitializationOwner(aid, ownerAid) {
|
|
578
|
+
return withInitializationClient(aid, async (client) => {
|
|
579
|
+
try {
|
|
580
|
+
return await client.bindOwneraid(ownerAid);
|
|
581
|
+
}
|
|
582
|
+
catch (error) {
|
|
583
|
+
if (initializationBindPreflightFailure(error)) {
|
|
584
|
+
throw Object.assign(new Error('Owner binding preparation failed before submission'), {
|
|
585
|
+
code: 'INITIALIZE_BIND_NOT_STARTED', cause: error,
|
|
586
|
+
causeCode: initializationErrorCode(error, 'INITIALIZE_BIND_FAILED'),
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
throw error;
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
/** Each bootstrap observation has a new SDK client and no cached consensus. */
|
|
594
|
+
export async function checkBootstrapInitializationOwner(aid, ownerAid) {
|
|
595
|
+
try {
|
|
596
|
+
return await withInitializationClient(aid, async (client) => {
|
|
597
|
+
const view = await client.checkOwnershipConsensus(aid);
|
|
598
|
+
const checkedAt = Date.now();
|
|
599
|
+
const details = {
|
|
600
|
+
...(['consensus', 'released', 'unbound', 'single_sided', 'invalid', 'unavailable', 'not_applicable'].includes(view.status)
|
|
601
|
+
? { consensusStatus: view.status } : {}),
|
|
602
|
+
...(Number.isSafeInteger(view.relation_version) && view.relation_version >= 0 ? { relationVersion: view.relation_version } : {}),
|
|
603
|
+
...(['locked', 'unlocked'].includes(view.lock) ? { lock: view.lock } : {}),
|
|
604
|
+
...(view.code ? { code: initializationErrorCode(view, 'INITIALIZE_OWNER_CHECK_FAILED') } : {}),
|
|
605
|
+
...(typeof view.retryable === 'boolean' ? { retryable: view.retryable } : {}),
|
|
606
|
+
};
|
|
607
|
+
if (view.status === 'consensus' && view.sub_aid === aid && view.lock === 'locked'
|
|
608
|
+
&& view.relation_version === 1 && typeof view.owner_aid === 'string' && isValidAid(view.owner_aid) && view.owner_aid !== aid) {
|
|
609
|
+
return { status: view.owner_aid === ownerAid ? 'confirmed' : 'conflict', ownerAid: view.owner_aid, checkedAt, ...details };
|
|
610
|
+
}
|
|
611
|
+
return { status: 'pending', checkedAt, ...details };
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
catch (error) {
|
|
615
|
+
// An unavailable observation never confirms a relation or replays bind.
|
|
616
|
+
const codeSource = error?.code === 'INITIALIZE_BIND_NOT_STARTED'
|
|
617
|
+
? { code: error.causeCode }
|
|
618
|
+
: error;
|
|
619
|
+
return { status: 'pending', consensusStatus: 'unavailable',
|
|
620
|
+
code: initializationErrorCode(codeSource, 'INITIALIZE_OWNER_CHECK_FAILED'), retryable: true };
|
|
621
|
+
}
|
|
622
|
+
}
|
|
@@ -443,7 +443,9 @@ export async function authorizeDelegatedAunMsgSend(registry, input) {
|
|
|
443
443
|
catch {
|
|
444
444
|
return { ok: false, code: 'INVALID_DELEGATION', reason: 'Delegation relation key is invalid' };
|
|
445
445
|
}
|
|
446
|
-
await refreshOwnershipForAuthorization(grant.selfAid, {
|
|
446
|
+
await refreshOwnershipForAuthorization(grant.selfAid, {
|
|
447
|
+
allowTransient: true, includeDaemon: hasTrustedFullAccessDelegation(grant),
|
|
448
|
+
});
|
|
447
449
|
const builtSubject = buildAuthSubject({
|
|
448
450
|
selfAid: grant.selfAid,
|
|
449
451
|
actorId: grant.actorId,
|
|
@@ -533,7 +535,7 @@ function approvedCommandBindingKey(sessionTokenHash, sessionId, approvalId) {
|
|
|
533
535
|
function isDelegationCommandHash(value) {
|
|
534
536
|
return /^[a-f0-9]{64}$/.test(value);
|
|
535
537
|
}
|
|
536
|
-
function delegationFailureDetailCode(cause) {
|
|
538
|
+
export function delegationFailureDetailCode(cause) {
|
|
537
539
|
switch (cause) {
|
|
538
540
|
case 'missing_token': return 'DELEGATION_TOKEN_MISSING';
|
|
539
541
|
case 'unknown_token': return 'DELEGATION_TOKEN_UNKNOWN';
|
|
@@ -7,6 +7,7 @@ import { hasTrustedPrincipal } from './authenticated-actor.js';
|
|
|
7
7
|
import { ownerResolver, refreshOwnershipForAuthorization, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
|
|
8
8
|
import { getOperationMeta } from './operation-catalog.js';
|
|
9
9
|
import { resolveRuntimePermissionMode } from '../role/runtime-policy.js';
|
|
10
|
+
import { buildAuthorizationEventKey } from '../audit/event-key.js';
|
|
10
11
|
export function isCrossAgentTriggerOperationAllowed(input) {
|
|
11
12
|
return input.control || input.daemonOwner === true || input.taskAgentAid === input.targetAgentAid;
|
|
12
13
|
}
|
|
@@ -143,6 +144,69 @@ export async function authorizeFreshOperation(params) {
|
|
|
143
144
|
}
|
|
144
145
|
return authorizeOperation(params);
|
|
145
146
|
}
|
|
147
|
+
/** Record managed command stages using the existing transport request identity. */
|
|
148
|
+
export async function executeAuditedOperation(params, execute, itemIndex) {
|
|
149
|
+
const startedAt = Date.now();
|
|
150
|
+
const metadata = params.auditMetadata;
|
|
151
|
+
const eventKey = metadata?.eventKey ?? buildAuthorizationEventKey({
|
|
152
|
+
sessionId: metadata?.sessionId ?? params.subject.sessionId,
|
|
153
|
+
requestId: metadata?.requestId ?? params.subject.requestId,
|
|
154
|
+
callId: metadata?.callId,
|
|
155
|
+
correlationId: metadata?.correlationId,
|
|
156
|
+
operation: params.intent.operation,
|
|
157
|
+
});
|
|
158
|
+
const auditedParams = {
|
|
159
|
+
...params,
|
|
160
|
+
auditMetadata: {
|
|
161
|
+
...metadata,
|
|
162
|
+
eventKey: itemIndex === undefined ? eventKey : `${eventKey}:item:${itemIndex}`,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
let snapshot = {
|
|
166
|
+
allow: true,
|
|
167
|
+
operation: params.intent.operation,
|
|
168
|
+
scope: params.intent.scope,
|
|
169
|
+
role: params.subject.role,
|
|
170
|
+
dangerous: params.intent.dangerous ?? getOperationMeta(params.intent.operation)?.dangerous ?? false,
|
|
171
|
+
};
|
|
172
|
+
const record = (overrides) => {
|
|
173
|
+
if (params.audit !== false)
|
|
174
|
+
auditDecision(auditedParams, snapshot, overrides);
|
|
175
|
+
};
|
|
176
|
+
record({ eventPhase: 'request', decision: 'pending', decisionSource: 'command', executionState: 'requested' });
|
|
177
|
+
let executed = false;
|
|
178
|
+
try {
|
|
179
|
+
const decision = await authorizeFreshOperation(auditedParams);
|
|
180
|
+
if (decision.command)
|
|
181
|
+
snapshot = decision.command;
|
|
182
|
+
if (!decision.allow) {
|
|
183
|
+
record({
|
|
184
|
+
eventPhase: 'response', decision: 'deny', executionState: 'blocked',
|
|
185
|
+
decisionSource: decision.command ? undefined : 'policy',
|
|
186
|
+
code: decision.code, durationMs: Date.now() - startedAt,
|
|
187
|
+
});
|
|
188
|
+
return { ok: false, code: decision.code, error: decision.reason };
|
|
189
|
+
}
|
|
190
|
+
const result = await execute(() => { executed = true; });
|
|
191
|
+
record({
|
|
192
|
+
eventPhase: 'response', executed,
|
|
193
|
+
executionState: result.ok ? 'completed' : executed ? 'failed' : 'blocked',
|
|
194
|
+
code: result.ok ? undefined : result.code,
|
|
195
|
+
errorCode: result.ok ? undefined : 'EXECUTION_FAILED',
|
|
196
|
+
durationMs: Date.now() - startedAt,
|
|
197
|
+
});
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
record({
|
|
202
|
+
eventPhase: 'response', executed, executionState: executed ? 'failed' : 'blocked',
|
|
203
|
+
decision: executed ? 'allow' : 'pending',
|
|
204
|
+
decisionSource: executed ? 'command' : 'infrastructure',
|
|
205
|
+
errorCode: 'EXECUTION_FAILED', durationMs: Date.now() - startedAt,
|
|
206
|
+
});
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
146
210
|
export function authorizeOperation(params) {
|
|
147
211
|
const access = authorizeAccess(params.subject);
|
|
148
212
|
if (!access.allow) {
|
|
@@ -228,7 +292,7 @@ function resolveRoleDetail(input) {
|
|
|
228
292
|
peerType: input.peerType,
|
|
229
293
|
});
|
|
230
294
|
}
|
|
231
|
-
function auditDecision(params, decision) {
|
|
295
|
+
function auditDecision(params, decision, overrides) {
|
|
232
296
|
const roleDenial = !decision.allow && decision.code === 'ROLE_ACCESS_DENIED';
|
|
233
297
|
auditCommandAuthorization({
|
|
234
298
|
ts: Date.now(),
|
|
@@ -278,5 +342,6 @@ function auditDecision(params, decision) {
|
|
|
278
342
|
reason: decision.allow ? undefined : decision.reason,
|
|
279
343
|
matchedRule: decision.matchedRule,
|
|
280
344
|
argsSummary: params.intent.args,
|
|
345
|
+
...Object.fromEntries(Object.entries(overrides ?? {}).filter(([, value]) => value !== undefined)),
|
|
281
346
|
});
|
|
282
347
|
}
|
|
@@ -5,11 +5,22 @@ import crypto from 'node:crypto';
|
|
|
5
5
|
import { buildAuthorizationEventKey, buildToolLifecycleEventKey, normalizeToolCorrelation } from '../audit/event-key.js';
|
|
6
6
|
import { normalizeExecutionPermissionMode } from '../permission/mode.js';
|
|
7
7
|
import { normalizeToolErrorClassification } from '../permission/tool-error-code.js';
|
|
8
|
+
function permissionAuditDetails(input) {
|
|
9
|
+
return Object.fromEntries(Object.entries({
|
|
10
|
+
approvalRequestId: input.approvalRequestId,
|
|
11
|
+
approverOperatorId: input.approverOperatorId,
|
|
12
|
+
approverChannelKey: input.approverChannelKey,
|
|
13
|
+
approverPrincipalId: input.approverPrincipalId,
|
|
14
|
+
}).filter((entry) => typeof entry[1] === 'string'));
|
|
15
|
+
}
|
|
8
16
|
export function auditCommandAuthorization(event) {
|
|
9
17
|
const shouldAudit = event.source === 'menu.cli' ||
|
|
10
18
|
event.decision === 'deny' ||
|
|
11
19
|
(event.decision === 'allow' && event.dangerous) ||
|
|
12
20
|
(event.source === 'agent-tool' && event.operation.startsWith('config.')) ||
|
|
21
|
+
(event.source === 'agent-tool' && event.decisionSource === 'command'
|
|
22
|
+
&& (event.eventPhase === 'request' || event.eventPhase === 'response'
|
|
23
|
+
|| (event.eventPhase === 'final' && !!event.requestId))) ||
|
|
13
24
|
event.operation === 'codex.approval' ||
|
|
14
25
|
event.operation === 'permission.approval' ||
|
|
15
26
|
event.operation.startsWith('permission.runtime') ||
|
|
@@ -180,15 +191,17 @@ export function auditCodexApprovalDecision(input) {
|
|
|
180
191
|
approvalMethod: input.method,
|
|
181
192
|
policyCode: input.policyCode,
|
|
182
193
|
protectionClass: protectionClassForPolicy(input.policyCode),
|
|
194
|
+
parseFailure: sanitizeParseFailure(input.parseFailure),
|
|
183
195
|
reason: input.reason,
|
|
184
196
|
role: input.role ?? 'unknown',
|
|
185
197
|
taskId: input.taskId,
|
|
186
198
|
argsSummary: {
|
|
199
|
+
...permissionAuditDetails(input),
|
|
187
200
|
method: input.method,
|
|
188
201
|
...(input.summary ? { summary: input.summary } : {}),
|
|
189
202
|
...(input.threadId ? { threadId: input.threadId } : {}),
|
|
190
203
|
...(input.cwd ? { cwd: input.cwd } : {}),
|
|
191
|
-
...(input.parseFailure ? { parseFailure: input.parseFailure } : {}),
|
|
204
|
+
...(input.parseFailure ? { parseFailure: sanitizeParseFailure(input.parseFailure) } : {}),
|
|
192
205
|
},
|
|
193
206
|
});
|
|
194
207
|
}
|
|
@@ -200,6 +213,7 @@ export function auditCodexApprovalDecision(input) {
|
|
|
200
213
|
export function auditPermissionDecision(input) {
|
|
201
214
|
const requestId = input.requestId ?? `perm-audit-${crypto.randomUUID()}`;
|
|
202
215
|
auditPermissionLifecycle({
|
|
216
|
+
...input,
|
|
203
217
|
phase: 'final',
|
|
204
218
|
requestId,
|
|
205
219
|
callId: input.callId,
|
|
@@ -244,6 +258,7 @@ export function auditPermissionLifecycle(input) {
|
|
|
244
258
|
approvalMethod: input.approvalMethod,
|
|
245
259
|
policyCode: input.policyCode,
|
|
246
260
|
decisionSource: input.decisionSource,
|
|
261
|
+
errorDetailCode: input.errorDetailCode,
|
|
247
262
|
errorCode: input.decision === 'deny'
|
|
248
263
|
? input.decisionSource === 'approval'
|
|
249
264
|
? 'USER_DENIED'
|
|
@@ -257,8 +272,9 @@ export function auditPermissionLifecycle(input) {
|
|
|
257
272
|
dangerous: false,
|
|
258
273
|
role: input.role ?? 'unknown',
|
|
259
274
|
taskId: input.taskId,
|
|
260
|
-
argsSummary: input.summary || input.response
|
|
275
|
+
argsSummary: input.summary || input.response || Object.keys(permissionAuditDetails(input)).length
|
|
261
276
|
? {
|
|
277
|
+
...permissionAuditDetails(input),
|
|
262
278
|
...(input.summary ? { summary: input.summary } : {}),
|
|
263
279
|
...(input.response ? { response: input.response } : {}),
|
|
264
280
|
}
|
|
@@ -267,9 +283,9 @@ export function auditPermissionLifecycle(input) {
|
|
|
267
283
|
executed: false,
|
|
268
284
|
executionState: input.phase === 'request'
|
|
269
285
|
? 'requested'
|
|
270
|
-
: input.
|
|
271
|
-
? '
|
|
272
|
-
: input.
|
|
286
|
+
: input.decision === 'deny'
|
|
287
|
+
? 'blocked'
|
|
288
|
+
: input.phase === 'response' ? 'responded' : 'authorized',
|
|
273
289
|
reason: input.reason,
|
|
274
290
|
});
|
|
275
291
|
}
|
|
@@ -317,6 +333,8 @@ export function auditToolInfrastructureFailure(input) {
|
|
|
317
333
|
});
|
|
318
334
|
}
|
|
319
335
|
function infrastructureErrorCode(policyCode) {
|
|
336
|
+
if (policyCode === 'approval_expired' || policyCode === 'approval_timeout')
|
|
337
|
+
return 'APPROVAL_TIMEOUT';
|
|
320
338
|
const code = String(policyCode ?? '').toLowerCase();
|
|
321
339
|
if (/delegat|carrier|not.?armed/.test(code))
|
|
322
340
|
return 'DELEGATION_FAILED';
|
|
@@ -406,6 +424,7 @@ function buildAuditRecord(event) {
|
|
|
406
424
|
policyCode: event.policyCode ?? event.code,
|
|
407
425
|
protectionClass: event.protectionClass,
|
|
408
426
|
matchedPath: event.matchedPath,
|
|
427
|
+
parseFailure: sanitizeParseFailure(event.parseFailure),
|
|
409
428
|
decisionSource,
|
|
410
429
|
ecwebRequestId: event.ecwebRequestId,
|
|
411
430
|
targetAgentAid: redactIdentifier(event.targetAgentAid),
|
|
@@ -452,6 +471,22 @@ function namespaceAuditRequestId(source, sessionId, sourceRequestId) {
|
|
|
452
471
|
const parts = [...namespace, sourceRequestId].map(part => encodeURIComponent(JSON.stringify(part).slice(1, -1)));
|
|
453
472
|
return `audit:v1:${parts.join(':')}`;
|
|
454
473
|
}
|
|
474
|
+
function sanitizeParseFailure(value) {
|
|
475
|
+
if (!value || typeof value !== 'object')
|
|
476
|
+
return undefined;
|
|
477
|
+
const candidate = value;
|
|
478
|
+
const issues = ['empty-command', 'invalid-control-char', 'unsafe-expansion', 'invalid-quote',
|
|
479
|
+
'structural-newline', 'unsupported-escape', 'lossy-cmd-shim', 'shell-composition', 'untrusted-shell'];
|
|
480
|
+
if (typeof candidate.issue !== 'string' || !issues.includes(candidate.issue)
|
|
481
|
+
|| typeof candidate.dialect !== 'string' || !['posix', 'powershell', 'cmd'].includes(candidate.dialect))
|
|
482
|
+
return undefined;
|
|
483
|
+
const { offset, tokenIndex, inputLength } = candidate;
|
|
484
|
+
if (typeof offset !== 'number' || typeof tokenIndex !== 'number' || typeof inputLength !== 'number'
|
|
485
|
+
|| ![offset, tokenIndex, inputLength].every(value => Number.isSafeInteger(value) && value >= 0)
|
|
486
|
+
|| offset > inputLength || tokenIndex > inputLength)
|
|
487
|
+
return undefined;
|
|
488
|
+
return { issue: candidate.issue, dialect: candidate.dialect, offset, tokenIndex, inputLength };
|
|
489
|
+
}
|
|
455
490
|
function resolveAgentName(event) {
|
|
456
491
|
const displayName = typeof event.agentName === 'string' ? event.agentName.trim() : '';
|
|
457
492
|
if (displayName && !isUnknownAgentLabel(displayName))
|
|
@@ -534,6 +569,7 @@ function logAuditEvent(record) {
|
|
|
534
569
|
record.policyCode ? `policy=${record.policyCode}` : null,
|
|
535
570
|
record.protectionClass ? `protectionClass=${record.protectionClass}` : null,
|
|
536
571
|
record.matchedPath ? `matchedPath=${JSON.stringify(record.matchedPath)}` : null,
|
|
572
|
+
record.parseFailure ? `parseFailure=${JSON.stringify(record.parseFailure)}` : null,
|
|
537
573
|
record.decisionSource ? `decisionSource=${record.decisionSource}` : null,
|
|
538
574
|
`executed=${record.executed}`,
|
|
539
575
|
`executionState=${record.executionState}`,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { authorizeFreshOperation as authorizeOperation, buildAuthSubject } from './auth-gateway.js';
|
|
2
|
-
import { trustedExecutionIdentityInput } from './agent-delegation.js';
|
|
2
|
+
import { hasTrustedFullAccessDelegation, trustedExecutionIdentityInput } from './agent-delegation.js';
|
|
3
3
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
4
4
|
import { parsePeerKey } from '../relation/peer-identity.js';
|
|
5
5
|
export function createDelegationAuthorizer({ agentDelegationRegistry, sessionManager, getProcessOwners, }) {
|
|
@@ -53,6 +53,7 @@ export function createDelegationAuthorizer({ agentDelegationRegistry, sessionMan
|
|
|
53
53
|
ok: true,
|
|
54
54
|
aid: subject.dataScope === 'daemon' ? (params.targetAid ?? delegation.grant.selfAid) : delegation.grant.selfAid,
|
|
55
55
|
dataScope: subject.dataScope,
|
|
56
|
+
fullAccess: hasTrustedFullAccessDelegation(delegation.grant),
|
|
56
57
|
management: isManagementRole(subject.role),
|
|
57
58
|
sessionRuntimeDir: delegation.grant.sessionRuntimeDir,
|
|
58
59
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getRoleDefinition } from '../../config/roles.js';
|
|
2
2
|
import { isManagementRole } from '../../config/builtin-roles.js';
|
|
3
|
-
import { isUnsupportedBaseagentConfigField, relationFieldWriteOperation, resolveRoleFieldPermission, } from '../../config/config-field-policy.js';
|
|
3
|
+
import { isAgentOnlyBaseagentField, isUnsupportedBaseagentConfigField, relationFieldWriteOperation, resolveRoleFieldPermission, } from '../../config/config-field-policy.js';
|
|
4
4
|
import { isResolvedConfigMutation, } from '../../config/resolved-config-op.js';
|
|
5
5
|
import { normalizePeer } from '../model/config-scope.js';
|
|
6
6
|
import { getOperationMeta } from './operation-catalog.js';
|
|
@@ -103,6 +103,14 @@ function authorizeCommandInternal(ctx, resolvedConfigCommand) {
|
|
|
103
103
|
if (!opMeta) {
|
|
104
104
|
return denyDecision(ctx, 'NOT_ALLOWED', `Unknown operation: ${operation}`, operation, intent.scope);
|
|
105
105
|
}
|
|
106
|
+
if (operation.startsWith('provider.')) {
|
|
107
|
+
if (intent.scope !== 'process' || !ctx.fromControlChannel
|
|
108
|
+
|| !(ctx.isDaemonOwner === true || ctx.processRole === 'daemon-owner')
|
|
109
|
+
|| !['menu', 'control', 'ecweb'].includes(ctx.source)) {
|
|
110
|
+
return denyDecision(ctx, 'NOT_ALLOWED', 'Provider management requires DaemonOwner process control', operation, intent.scope, opMeta.dangerous);
|
|
111
|
+
}
|
|
112
|
+
return { allow: true, operation, scope: intent.scope, role: 'daemon-owner', dangerous: opMeta.dangerous, matchedRule: 'provider-process-owner' };
|
|
113
|
+
}
|
|
106
114
|
if (isFieldConfigOperation(operation) && !resolvedConfigCommand) {
|
|
107
115
|
return denyDecision(ctx, 'NOT_ALLOWED', 'Resolved config operation is required', operation, intent.scope, opMeta.dangerous);
|
|
108
116
|
}
|
|
@@ -121,7 +129,10 @@ function authorizeCommandInternal(ctx, resolvedConfigCommand) {
|
|
|
121
129
|
// but relation/Agent role rules, source lists, and daemon-owner gates are
|
|
122
130
|
// not meaningful limits for code already approved for host-level execution.
|
|
123
131
|
if (ctx.processRole === 'fullaccess-run' && ctx.dataScope === 'daemon'
|
|
124
|
-
&& operation !== 'ec.aid.bind' && operation !== 'ec.aid.bind.status') {
|
|
132
|
+
&& operation !== 'ec.aid.bind' && operation !== 'ec.aid.transfer' && operation !== 'ec.aid.bind.status') {
|
|
133
|
+
if (operation === 'system.restart' || operation === 'system.upgrade') {
|
|
134
|
+
return denyDecision(ctx, 'NOT_ALLOWED', 'The EvolCore instance hosting the current fullaccess task is protected from lifecycle changes', operation, intent.scope, opMeta.dangerous, 'fullaccess-current-runtime-protected');
|
|
135
|
+
}
|
|
125
136
|
return {
|
|
126
137
|
allow: true,
|
|
127
138
|
operation,
|
|
@@ -142,12 +153,18 @@ function authorizeCommandInternal(ctx, resolvedConfigCommand) {
|
|
|
142
153
|
if (!sourceAllowed) {
|
|
143
154
|
return denyDecision(ctx, 'NOT_ALLOWED', `Operation ${operation} is not available from source ${ctx.source}`, operation, intent.scope, opMeta.dangerous);
|
|
144
155
|
}
|
|
145
|
-
if (operation === 'ec.aid.bind
|
|
146
|
-
|
|
156
|
+
if (operation === 'ec.aid.bind.status') {
|
|
157
|
+
if (intent.scope !== 'agent') {
|
|
158
|
+
return denyDecision(ctx, 'NOT_ALLOWED', 'Ownership status is only available for an Agent subject', operation, intent.scope, opMeta.dangerous);
|
|
159
|
+
}
|
|
160
|
+
return { allow: true, operation, scope: intent.scope, role, dangerous: opMeta.dangerous, matchedRule: 'ownership-status-read' };
|
|
161
|
+
}
|
|
162
|
+
if (operation === 'ec.aid.bind' || operation === 'ec.aid.transfer') {
|
|
163
|
+
const permitted = intent.scope === 'agent' && ctx.processRole !== 'daemon-service'
|
|
147
164
|
&& (ctx.isDaemonOwner === true || ctx.processRole === 'daemon-owner'
|
|
148
|
-
|| (isCurrentAgentTarget(ctx) &&
|
|
165
|
+
|| (isCurrentAgentTarget(ctx) && role === 'owner'));
|
|
149
166
|
if (!permitted)
|
|
150
|
-
return denyDecision(ctx, 'NOT_ALLOWED', 'Protocol Owner binding requires the subject Owner or daemon Owner', operation, intent.scope, opMeta.dangerous);
|
|
167
|
+
return denyDecision(ctx, 'NOT_ALLOWED', 'Protocol Owner binding or transfer requires the subject Owner or daemon Owner', operation, intent.scope, opMeta.dangerous);
|
|
151
168
|
return { allow: true, operation, scope: intent.scope, role, dangerous: opMeta.dangerous, matchedRule: 'protocol-owner-binding' };
|
|
152
169
|
}
|
|
153
170
|
if (ctx.processRole === 'daemon-service') {
|
|
@@ -675,6 +692,11 @@ function checkConfigFieldPolicy(ctx, policy, resolvedConfigOp) {
|
|
|
675
692
|
return { ok: false, reason: 'Resolved config operation is required' };
|
|
676
693
|
const field = resolvedConfigOp.field;
|
|
677
694
|
if (!resolvedConfigOp.route || (resolvedConfigOp.fieldRule.class !== 'safe-scalar' && resolvedConfigOp.fieldRule.class !== 'safe-readonly-object')) {
|
|
695
|
+
if (policy === 'behavior-read'
|
|
696
|
+
&& resolvedConfigOp.configScope === 'relation'
|
|
697
|
+
&& isAgentOnlyBaseagentField(field)) {
|
|
698
|
+
return { ok: true };
|
|
699
|
+
}
|
|
678
700
|
if (policy === 'behavior-read'
|
|
679
701
|
&& !isCurrentAgentTarget(ctx)
|
|
680
702
|
&& hasDaemonOwnerRole(ctx)
|
|
@@ -128,7 +128,16 @@ const QUEUE_OPERATIONS = [['read', 'Read the current Agent message queue'], ['cl
|
|
|
128
128
|
*
|
|
129
129
|
* 参照设计文档 docs/command-execution-role-permission-design.md 第 5 节
|
|
130
130
|
*/
|
|
131
|
+
const PROVIDER_OPERATIONS = ['list', 'show', 'create', 'import', 'update', 'delete'].map(action => ({
|
|
132
|
+
id: 'provider.' + action,
|
|
133
|
+
category: action === 'list' || action === 'show' ? 'read' : 'process',
|
|
134
|
+
dangerous: action !== 'list' && action !== 'show',
|
|
135
|
+
defaultScopes: ['process'],
|
|
136
|
+
description: 'Manage the daemon Provider registry: ' + action,
|
|
137
|
+
sources: ['menu', 'control', 'ecweb'],
|
|
138
|
+
}));
|
|
131
139
|
const OPERATIONS = [
|
|
140
|
+
...PROVIDER_OPERATIONS,
|
|
132
141
|
{
|
|
133
142
|
id: 'proxy.read',
|
|
134
143
|
category: 'read',
|
|
@@ -1174,9 +1183,13 @@ const OPERATIONS = [
|
|
|
1174
1183
|
id: 'ec.aid.bind', category: 'write-agent', dangerous: true, defaultScopes: ['agent'],
|
|
1175
1184
|
description: 'Request or decide a protocol Owner binding using the subject SDK client', sources: ['agent-tool', 'menu.cli'],
|
|
1176
1185
|
},
|
|
1186
|
+
{
|
|
1187
|
+
id: 'ec.aid.transfer', category: 'write-agent', dangerous: true, defaultScopes: ['agent'],
|
|
1188
|
+
description: 'Transfer a protocol Owner relationship to a new Owner using the subject SDK client', sources: ['agent-tool', 'menu.cli'],
|
|
1189
|
+
},
|
|
1177
1190
|
{
|
|
1178
1191
|
id: 'ec.aid.bind.status', category: 'read', dangerous: false, defaultScopes: ['agent'],
|
|
1179
|
-
description: '
|
|
1192
|
+
description: 'Read the protocol Owner consensus and binding task projection; status --refresh forces a fresh query', sources: ['agent-tool', 'menu.cli'],
|
|
1180
1193
|
},
|
|
1181
1194
|
{
|
|
1182
1195
|
id: 'ec.aid.lookup',
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* The main service (index.ts) handles registration and message flow wiring.
|
|
7
7
|
*/
|
|
8
8
|
import { logger } from '../utils/logger.js';
|
|
9
|
+
import { assertAgentAidAvailable } from '../config/config-manager.js';
|
|
9
10
|
// ── Shared helpers for plugins ─────────────────────────────────────────────
|
|
10
11
|
/** Resolve showActivities for a single instance (instance overrides default). */
|
|
11
12
|
export function resolveShowActivities(inst) {
|
|
@@ -49,6 +50,7 @@ export class ChannelLoader {
|
|
|
49
50
|
* AUN is always created implicitly from agent.aid (no explicit entry required).
|
|
50
51
|
*/
|
|
51
52
|
async createForAgent(agent) {
|
|
53
|
+
assertAgentAidAvailable(agent.aid);
|
|
52
54
|
const ctx = {
|
|
53
55
|
agentName: agent.aid,
|
|
54
56
|
defaultProjectPath: agent.config.projects?.defaultPath ?? process.cwd(),
|