evolcore 0.0.42-test.0 → 0.0.43-test.0
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 +31 -2
- package/bin/ec-safe-output.js +4 -1
- package/dist/ability/application-service.js +882 -0
- package/dist/ability/authorization.js +70 -0
- package/dist/ability/command-contract.js +105 -0
- package/dist/ability/daemon.js +137 -0
- package/dist/ability/development.js +450 -0
- package/dist/ability/environment.js +75 -0
- package/dist/ability/interop-v1.js +547 -0
- package/dist/ability/management.js +79 -0
- package/dist/ability/package.js +264 -0
- package/dist/ability/provider.js +73 -0
- package/dist/ability/publication.js +107 -0
- package/dist/ability/resources.js +106 -0
- package/dist/ability/runtime.js +212 -0
- package/dist/ability/secrets.js +47 -0
- package/dist/ability/store.js +112 -0
- package/dist/ability/toolchain.js +69 -0
- package/dist/ability/types.js +14 -0
- package/dist/ability/versions.js +32 -0
- package/dist/agents/baseagent.js +2 -2
- package/dist/agents/claude-runner.js +4 -0
- package/dist/agents/codex-runner.js +81 -17
- package/dist/agents/ecagent-plugin-lazy.js +41 -0
- package/dist/agents/ecagent-runner.js +18 -11
- package/dist/aun/ability-device-routing.js +12 -1
- package/dist/aun/aid/agentmd.js +2 -2
- package/dist/aun/aid/identity.js +45 -0
- package/dist/aun/aid/index.js +1 -0
- package/dist/aun/aid/managed-operation.js +73 -2
- package/dist/channels/aun.js +64 -18
- package/dist/channels/builtin-plugins.js +14 -0
- package/dist/channels/dingtalk.js +78 -26
- package/dist/channels/feishu.js +89 -14
- package/dist/channels/qqbot.js +84 -19
- package/dist/channels/wechat.js +77 -19
- package/dist/channels/wecom.js +67 -22
- package/dist/cli/ability-command.js +92 -0
- package/dist/cli/aun-commands.js +124 -85
- package/dist/cli/daemon-commands.js +37 -85
- package/dist/cli/index.js +14 -0
- package/dist/cli/init.js +11 -13
- package/dist/cli/managed-command-guard.js +6 -0
- package/dist/cli/model.js +101 -104
- package/dist/cli/provider-command.js +6 -4
- package/dist/cli/restart-monitor.js +52 -11
- package/dist/cli/upgrade-command.js +102 -0
- package/dist/cli/version.js +1 -1
- package/dist/config/access-policy.js +4 -2
- package/dist/config/builtin-roles.js +1 -0
- package/dist/config/config-field-policy.js +4 -0
- package/dist/config/config-manager.js +7 -0
- package/dist/config/provider-ipc-service.js +10 -0
- package/dist/config/providers-config.js +12 -3
- package/dist/config/providers-management.js +45 -9
- package/dist/config/schema-migration.js +40 -22
- package/dist/contracts/ecweb-service-protocol.js +2 -1
- package/dist/core/auth/agent-delegation.js +21 -5
- package/dist/core/auth/auth-gateway.js +31 -9
- package/dist/core/auth/authorization-audit.js +52 -4
- package/dist/core/auth/delegation-authorization.js +140 -4
- package/dist/core/auth/operation-authorizer.js +114 -13
- package/dist/core/auth/operation-catalog.js +118 -4
- package/dist/core/baseagent-loader.js +14 -1
- package/dist/core/channel-loader.js +47 -9
- package/dist/core/channel-runtime.js +1 -1
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/cli-intent-parser.js +26 -13
- package/dist/core/command/command-handler.js +232 -76
- package/dist/core/command/connect-menu.js +10 -4
- package/dist/core/command/daemon-diagnostics.js +3 -3
- package/dist/core/command/data-root-resolver.js +2 -3
- package/dist/core/command/menu-catalog.js +10 -3
- package/dist/core/command/menu-handler.js +321 -46
- package/dist/core/command/menu-protocol.js +53 -7
- package/dist/core/command/pa-workspace-calendar.js +1 -2
- package/dist/core/command/pa-workspace-items.js +486 -0
- package/dist/core/command/pa-workspace-store.js +10 -1
- package/dist/core/command/slash-gate.js +2 -2
- package/dist/core/command/slash-handler.js +67 -25
- package/dist/core/contact-bind-registry.js +27 -0
- package/dist/core/daemon-control.js +3 -3
- package/dist/core/daemon-lifecycle.js +2 -1
- package/dist/core/event-bus.js +9 -2
- package/dist/core/handoff/ipc-registration.js +1 -0
- package/dist/core/host-snapshot.js +1 -2
- package/dist/core/initialization/service.js +32 -11
- package/dist/core/ipc-registration.js +18 -5
- package/dist/core/memory/consolidation-context.js +2 -2
- package/dist/core/message/aun-request-registry.js +99 -18
- package/dist/core/message/im-renderer.js +16 -11
- package/dist/core/message/message-admission.js +25 -20
- package/dist/core/message/message-bridge.js +21 -47
- package/dist/core/message/message-queue.js +3 -0
- package/dist/core/message/response-engine.js +7 -5
- package/dist/core/model/catalog-service.js +1 -1
- package/dist/core/permission/ec-command-parser.js +41 -9
- package/dist/core/permission/permission-result.js +1 -0
- package/dist/core/permission/protected-paths.js +25 -14
- package/dist/core/permission/tool-policy.js +108 -107
- package/dist/core/plugin-lifecycle.js +133 -0
- package/dist/core/runner-reload-transaction.js +4 -1
- package/dist/core/system-session/memory.js +16 -3
- package/dist/core/task/task-activity-store.js +50 -0
- package/dist/core/task/task-image-resources.js +140 -0
- package/dist/core/thread/ipc-operation.js +1 -1
- package/dist/core/thread/thread-service.js +0 -1
- package/dist/directory/canonical-digest.js +5 -3
- package/dist/directory/owner-directory-admission.js +22 -2
- package/dist/directory/owner-directory-cache.js +394 -60
- package/dist/directory/owner-directory-markdown.js +29 -2
- package/dist/directory/owner-directory-scope.js +35 -16
- package/dist/ecweb/basic-settings-service.js +4 -1
- package/dist/ecweb/pairing.js +41 -0
- package/dist/ecweb/providers-service.js +8 -1
- package/dist/{utils/ecweb-utils.js → ecweb/runtime/launch.js} +3 -27
- package/dist/ecweb/runtime/lifecycle.js +184 -0
- package/dist/{utils/ecweb-supervisor.js → ecweb/runtime/supervisor.js} +32 -27
- package/dist/index.js +34 -25
- package/dist/ipc.js +124 -7
- package/dist/response-system/engines/v1/proactive-flow.js +1 -1
- package/dist/trigger/authorization.js +2 -2
- package/dist/utils/atomic-write.js +24 -0
- package/dist/utils/avatar-upload.js +3 -1
- package/dist/utils/cross-platform.js +31 -2
- package/dist/utils/host-info.js +36 -0
- package/dist/utils/instance-registry.js +38 -11
- package/dist/utils/logger.js +9 -0
- package/dist/utils/{process-tree-stats.js → process-tree.js} +29 -0
- package/dist/utils/tool-summary.js +9 -1
- package/dist/utils/upgrade-jobs.js +96 -15
- package/dist/utils/windows-autostart.js +1 -1
- package/ecagent/README.md +19 -0
- package/ecagent/dist/harness/agent-harness.js +9 -0
- package/ecagent/dist/harness/env/nodejs.js +71 -11
- package/ecagent/dist/harness/env/windows-shell.d.ts +7 -0
- package/ecagent/dist/harness/env/windows-shell.js +132 -0
- package/kits/docs/aun/ABILITY_CALLING.md +38 -9
- package/kits/docs/evolcore/INDEX.md +5 -1
- package/kits/docs/evolcore/ability.md +181 -0
- package/kits/docs/evolcore/aid.md +20 -0
- package/kits/docs/evolcore/config.md +10 -6
- package/kits/docs/evolcore/menu-protocol.md +40 -1
- package/kits/docs/evolcore/provider.md +2 -2
- package/kits/docs/evolcore/tool-authorization.md +270 -0
- package/kits/runtime/ability-job.ps1 +41 -0
- package/kits/runtime/ability-runner.mjs +67 -0
- package/kits/runtime/ability-secret.ps1 +59 -0
- package/kits/runtime/ability-templates/go/main.go +59 -0
- package/kits/runtime/ability-templates/java/Json.java +67 -0
- package/kits/runtime/ability-templates/java/Runner.java +42 -0
- package/kits/runtime/ability-templates/python/runner.py +48 -0
- package/kits/runtime/ability-templates/rust/json.rs +87 -0
- package/kits/runtime/ability-templates/rust/runner.rs +35 -0
- package/kits/schemas/_meta.json +12 -1
- package/kits/schemas/ability-plugin.schema.1.json +107 -0
- package/kits/schemas/ability-project.schema.1.json +31 -0
- package/kits/schemas/agent-config.schema.16.json +20 -0
- package/kits/schemas/agent-config.schema.17.json +20 -0
- package/kits/schemas/agent-config.schema.18.json +917 -0
- package/kits/skills/.switches.json +4 -0
- package/kits/skills/aid-ability/SKILL.md +5 -4
- package/kits/skills/ec-ability/SKILL.md +67 -0
- package/kits/skills/ec-ability/references/contract-checklist.md +37 -0
- package/kits/skills/ec-ability/references/development.md +104 -0
- package/kits/skills/ec-ability/references/management.md +117 -0
- package/kits/skills/ec-ability/references/recovery.md +27 -0
- package/kits/skills/ec-ability/references/runtime-protocol.md +109 -0
- package/kits/skills/ec-ability/references/workflows.md +15 -0
- package/kits/skills/ec-service-proxy/SKILL.md +12 -0
- package/kits/skills/personal-assistant/SKILL.md +240 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +78 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +397 -0
- package/kits/skills/personal-assistant/scripts/init.mjs +113 -25
- package/kits/skills/personal-assistant/scripts/lock.mjs +189 -0
- package/kits/skills/personal-assistant/scripts/migrate.mjs +35 -10
- package/kits/skills/personal-assistant/scripts/verify.mjs +2 -1
- package/kits/skills/personal-assistant/templates/persona-section.md +54 -0
- package/kits/skills/personal-assistant/triggers/ingest-daily.json +1 -1
- package/kits/templates/memory-consolidation/notes.md +1 -1
- package/kits/templates/system-fragments/channel.md +2 -1
- package/kits/templates/system-fragments/commands.md +1 -0
- package/package.json +4 -2
- package/dist/core/command/data-root-error.js +0 -10
- package/dist/utils/machine-info.js +0 -46
- package/dist/utils/process-tree-worker.js +0 -31
- package/dist/utils/windows-output.js +0 -36
|
@@ -1705,6 +1705,7 @@ export class CodexRunner {
|
|
|
1705
1705
|
correlationId: callId,
|
|
1706
1706
|
taskId: context?.taskId,
|
|
1707
1707
|
matchedPath: details?.matchedPath,
|
|
1708
|
+
matchedRule: details?.matchedRule,
|
|
1708
1709
|
});
|
|
1709
1710
|
try {
|
|
1710
1711
|
context?.recordPreflightDenial?.({
|
|
@@ -1714,6 +1715,7 @@ export class CodexRunner {
|
|
|
1714
1715
|
policyCode,
|
|
1715
1716
|
...(details?.errorDetailCode ? { errorDetailCode: details.errorDetailCode } : {}),
|
|
1716
1717
|
...(details?.matchedPath ? { matchedPath: details.matchedPath } : {}),
|
|
1718
|
+
...(details?.matchedRule ? { matchedRule: details.matchedRule } : {}),
|
|
1717
1719
|
...(callId ? { callId, correlationId: callId } : {}),
|
|
1718
1720
|
});
|
|
1719
1721
|
}
|
|
@@ -1817,6 +1819,7 @@ export class CodexRunner {
|
|
|
1817
1819
|
await recordPreToolUseDenial(preflight.policyCode ?? 'tool_preflight_denied', reason, {
|
|
1818
1820
|
errorDetailCode: preflight.errorDetailCode,
|
|
1819
1821
|
matchedPath: preflight.matchedPath,
|
|
1822
|
+
matchedRule: preflight.matchedRule,
|
|
1820
1823
|
});
|
|
1821
1824
|
return { ok: true, applicable: true, decision: 'deny', reason };
|
|
1822
1825
|
}
|
|
@@ -3890,7 +3893,7 @@ export class CodexRunner {
|
|
|
3890
3893
|
...(errorDetailCode ? { errorDetailCode } : {}),
|
|
3891
3894
|
reason: message,
|
|
3892
3895
|
});
|
|
3893
|
-
this.logAppServerApprovalAudit(request, sessionKey, toolName, 'deny', 'infrastructure', policyCode, message, canonicalEcApproval?.parseFailure);
|
|
3896
|
+
this.logAppServerApprovalAudit(request, sessionKey, toolName, 'deny', 'infrastructure', policyCode, message, canonicalEcApproval?.parseFailure, undefined, canonicalEcApproval);
|
|
3894
3897
|
setImmediate(() => this.steerPolicyReason(sessionKey, policyCode, message));
|
|
3895
3898
|
return response;
|
|
3896
3899
|
};
|
|
@@ -3965,7 +3968,7 @@ export class CodexRunner {
|
|
|
3965
3968
|
}
|
|
3966
3969
|
this.logAppServerApprovalAudit(request, sessionKey, toolName, decision === 'deny' ? 'deny' : 'allow', decision === 'deny' ? decisionSource : 'approval', decision === 'deny' ? policyCode : undefined, decision === 'deny'
|
|
3967
3970
|
? denialReason
|
|
3968
|
-
: 'approval accepted', undefined, { ...resolutionMeta, errorDetailCode });
|
|
3971
|
+
: 'approval accepted', undefined, { ...resolutionMeta, errorDetailCode }, canonicalEcApproval);
|
|
3969
3972
|
logger.info(`[CodexRunner] app-server approval response id=${request.id} method=${request.method} decision=${decision} response=${JSON.stringify(response)}`);
|
|
3970
3973
|
return response;
|
|
3971
3974
|
}
|
|
@@ -3975,7 +3978,7 @@ export class CodexRunner {
|
|
|
3975
3978
|
throw error;
|
|
3976
3979
|
}
|
|
3977
3980
|
}
|
|
3978
|
-
logAppServerApprovalAudit(request, sessionKey, toolName, decision, decisionSource, policyCode, reason, parseFailure, resolution) {
|
|
3981
|
+
logAppServerApprovalAudit(request, sessionKey, toolName, decision, decisionSource, policyCode, reason, parseFailure, resolution, canonical) {
|
|
3979
3982
|
const approvalMetadata = {
|
|
3980
3983
|
approvalRequestId: resolution?.requestId,
|
|
3981
3984
|
errorDetailCode: resolution?.errorDetailCode,
|
|
@@ -3991,6 +3994,12 @@ export class CodexRunner {
|
|
|
3991
3994
|
const rawSummary = summarizeToolInputForAudit(toolName, toolInput);
|
|
3992
3995
|
const auditSummary = (rawSummary
|
|
3993
3996
|
|| summarizeToolInputForAudit('Bash', { command: this.summarizeAppServerRequest(request.method, params) })).slice(0, 512);
|
|
3997
|
+
const commandIntent = toolName === 'Bash'
|
|
3998
|
+
? canonical?.argv || canonical?.parseFailure ? 'ec' : 'none'
|
|
3999
|
+
: undefined;
|
|
4000
|
+
const canonicalizationStage = canonical?.parseFailure?.canonicalizationStage
|
|
4001
|
+
?? (canonical?.argv ? 'canonical-argv' : commandIntent === 'none' ? 'not-ec' : undefined);
|
|
4002
|
+
const canonicalWrapper = canonical?.parseFailure?.wrapper ?? canonical?.spec?.wrapper;
|
|
3994
4003
|
const threadId = this.requestThreadId(params);
|
|
3995
4004
|
const rawCwd = typeof toolInput.cwd === 'string' && toolInput.cwd
|
|
3996
4005
|
? toolInput.cwd
|
|
@@ -4019,6 +4028,9 @@ export class CodexRunner {
|
|
|
4019
4028
|
cwd: rawCwd,
|
|
4020
4029
|
reason: reason ?? policyCode ?? (decision === 'allow' ? 'approval accepted' : 'approval denied'),
|
|
4021
4030
|
parseFailure,
|
|
4031
|
+
commandIntent,
|
|
4032
|
+
canonicalizationStage,
|
|
4033
|
+
canonicalWrapper,
|
|
4022
4034
|
});
|
|
4023
4035
|
const lifecycleRequestId = request.id !== undefined
|
|
4024
4036
|
? String(request.id)
|
|
@@ -4140,13 +4152,36 @@ export class CodexRunner {
|
|
|
4140
4152
|
return hasAllow && hasDeny;
|
|
4141
4153
|
});
|
|
4142
4154
|
}
|
|
4143
|
-
denyUntrackedExternalToolApproval(params) {
|
|
4155
|
+
denyUntrackedExternalToolApproval(params, policyCode = 'mcp_approval_metadata_missing', toolName = 'MCP:untracked') {
|
|
4144
4156
|
const questions = Array.isArray(params.questions) ? params.questions : [];
|
|
4145
4157
|
const answers = {};
|
|
4146
4158
|
for (const question of questions) {
|
|
4147
4159
|
const questionId = typeof question.id === 'string' ? question.id : `q-${Object.keys(answers).length + 1}`;
|
|
4148
4160
|
answers[questionId] = { answers: [this.selectMcpApprovalAnswer(question, false)] };
|
|
4149
4161
|
}
|
|
4162
|
+
const sessionKey = this.findSessionKeyByThread(params.threadId, params.conversationId);
|
|
4163
|
+
const permissionContext = this.permissionContexts.get(sessionKey);
|
|
4164
|
+
auditToolPreflightDenial({
|
|
4165
|
+
toolName,
|
|
4166
|
+
policyCode,
|
|
4167
|
+
reason: policyCode === 'mcp_approval_metadata_missing'
|
|
4168
|
+
? 'external tool approval lacked trusted call metadata'
|
|
4169
|
+
: policyCode === 'mcp_capability_boundary_denied'
|
|
4170
|
+
? 'external tool is excluded by the configured capability boundary'
|
|
4171
|
+
: 'external tool approval denied by policy',
|
|
4172
|
+
summary: summarizeToolInputForAudit(toolName, { questions }).slice(0, 512),
|
|
4173
|
+
sessionId: sessionKey,
|
|
4174
|
+
agentAid: permissionContext?.selfAid,
|
|
4175
|
+
agentName: permissionContext?.agentName,
|
|
4176
|
+
permissionMode: normalizeExecutionPermissionMode(this.chatModes.get(sessionKey) ?? this.currentMode),
|
|
4177
|
+
channel: permissionContext?.channel,
|
|
4178
|
+
actorId: permissionContext?.userId,
|
|
4179
|
+
role: permissionContext?.role,
|
|
4180
|
+
selfAid: permissionContext?.selfAid,
|
|
4181
|
+
taskId: permissionContext?.taskId,
|
|
4182
|
+
requestId: typeof params.requestId === 'string' ? params.requestId : undefined,
|
|
4183
|
+
callId: typeof params.itemId === 'string' ? params.itemId : undefined,
|
|
4184
|
+
});
|
|
4150
4185
|
logger.warn(`[CodexRunner] external tool approval denied because mcpToolCall metadata is missing: thread=${params.threadId ?? '<missing>'} item=${params.itemId ?? '<missing>'}`);
|
|
4151
4186
|
return { answers };
|
|
4152
4187
|
}
|
|
@@ -4180,7 +4215,7 @@ export class CodexRunner {
|
|
|
4180
4215
|
logger.warn(`[CodexRunner] failed to record unattended MCP denial: session=${sessionKey} tool=${toolName} error=${error instanceof Error ? error.message : String(error)}`);
|
|
4181
4216
|
}
|
|
4182
4217
|
logger.info(`[CodexRunner] unattended MCP approval denied: session=${sessionKey} tool=${toolName}`);
|
|
4183
|
-
return this.denyUntrackedExternalToolApproval(params);
|
|
4218
|
+
return this.denyUntrackedExternalToolApproval(params, 'permission_mode_denied', toolName);
|
|
4184
4219
|
}
|
|
4185
4220
|
async handleMcpToolApproval(params, trackedItem) {
|
|
4186
4221
|
const questions = Array.isArray(params.questions) ? params.questions : [];
|
|
@@ -4188,8 +4223,9 @@ export class CodexRunner {
|
|
|
4188
4223
|
throw new Error('Codex MCP 审批未包含问题,已拒绝');
|
|
4189
4224
|
const sessionKey = this.findSessionKeyByThread(params.threadId, params.conversationId);
|
|
4190
4225
|
if ((this.chatModes.get(sessionKey) ?? this.currentMode) === 'fullaccess') {
|
|
4191
|
-
if (!this.isTrustedFullAccessSession(sessionKey))
|
|
4192
|
-
return this.denyUntrackedExternalToolApproval(params);
|
|
4226
|
+
if (!this.isTrustedFullAccessSession(sessionKey)) {
|
|
4227
|
+
return this.denyUntrackedExternalToolApproval(params, 'fullaccess_context_untrusted');
|
|
4228
|
+
}
|
|
4193
4229
|
const answers = {};
|
|
4194
4230
|
for (const question of questions) {
|
|
4195
4231
|
const questionId = typeof question.id === 'string' ? question.id : `q-${Object.keys(answers).length + 1}`;
|
|
@@ -4214,14 +4250,14 @@ export class CodexRunner {
|
|
|
4214
4250
|
&& Object.prototype.hasOwnProperty.call(trackedItem, 'arguments');
|
|
4215
4251
|
if (!hasExactIdentity) {
|
|
4216
4252
|
logger.warn(`[CodexRunner] MCP approval denied because exact tool metadata is missing: thread=${params.threadId ?? '<missing>'} item=${params.itemId ?? '<missing>'}`);
|
|
4217
|
-
return this.denyUntrackedExternalToolApproval(params);
|
|
4253
|
+
return this.denyUntrackedExternalToolApproval(params, 'mcp_approval_metadata_missing', `MCP:${String(trackedItem.server || 'unknown')}/${String(trackedItem.tool || 'unknown')}`);
|
|
4218
4254
|
}
|
|
4219
4255
|
const threadId = this.requestThreadId(params);
|
|
4220
4256
|
const configFingerprint = threadId ? this.threadExternalToolFingerprints.get(threadId) : undefined;
|
|
4221
4257
|
const boundary = threadId ? this.threadExternalToolBoundaries.get(threadId) : undefined;
|
|
4222
4258
|
if (!configFingerprint || !boundary) {
|
|
4223
4259
|
logger.warn(`[CodexRunner] MCP approval denied because the hardened external-tool config is unbound: thread=${threadId ?? '<missing>'}`);
|
|
4224
|
-
return this.denyUntrackedExternalToolApproval(params);
|
|
4260
|
+
return this.denyUntrackedExternalToolApproval(params, 'mcp_capability_config_unbound', `MCP:${String(trackedItem.server)}/${String(trackedItem.tool)}`);
|
|
4225
4261
|
}
|
|
4226
4262
|
const server = trackedItem.server;
|
|
4227
4263
|
const tool = trackedItem.tool;
|
|
@@ -4233,7 +4269,7 @@ export class CodexRunner {
|
|
|
4233
4269
|
const isAllowedApp = !isAppCall || boundary.allowedApps.has(server) || boundary.allowAnyApp;
|
|
4234
4270
|
if (isExplicitlyDenied || !isAllowedApp) {
|
|
4235
4271
|
logger.warn(`[CodexRunner] MCP approval denied by the explicit capability boundary: thread=${threadId} server=${server}`);
|
|
4236
|
-
return this.denyUntrackedExternalToolApproval(params);
|
|
4272
|
+
return this.denyUntrackedExternalToolApproval(params, 'mcp_capability_boundary_denied', `MCP:${server}/${tool}`);
|
|
4237
4273
|
}
|
|
4238
4274
|
const toolName = `MCP:${server}/${tool}`;
|
|
4239
4275
|
const toolInput = {
|
|
@@ -4244,19 +4280,46 @@ export class CodexRunner {
|
|
|
4244
4280
|
...(typeof trackedItem.mcpAppResourceUri === 'string' ? { mcpAppResourceUri: trackedItem.mcpAppResourceUri } : {}),
|
|
4245
4281
|
...(trackedItem.appContext && typeof trackedItem.appContext === 'object' ? { appContext: trackedItem.appContext } : {}),
|
|
4246
4282
|
};
|
|
4247
|
-
const
|
|
4248
|
-
const
|
|
4283
|
+
const permissionContext = this.permissionContexts.get(sessionKey);
|
|
4284
|
+
const policyResult = permissionContext?.policyHook?.(toolName, toolInput);
|
|
4285
|
+
const systemSessionCheck = permissionContext?.systemSessionCheck;
|
|
4249
4286
|
const workspacePath = this.resolvePermissionWorkspacePath(params);
|
|
4250
4287
|
const mode = normalizeExecutionPermissionMode(this.chatModes.get(sessionKey) ?? this.currentMode);
|
|
4251
4288
|
// MCP servers are inherited unless capability config explicitly disables
|
|
4252
4289
|
// them. Apps retain their separate request/bypass lifecycle policy.
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4290
|
+
const systemSessionDecision = systemSessionCheck?.(toolName, toolInput);
|
|
4291
|
+
const policyDenied = !!policyResult?.block;
|
|
4292
|
+
let allow = systemSessionDecision
|
|
4293
|
+
? systemSessionDecision.allow
|
|
4294
|
+
: !policyDenied
|
|
4256
4295
|
&& !!workspacePath
|
|
4257
4296
|
&& (isAppCall
|
|
4258
4297
|
? mode === 'request' || mode === 'bypass'
|
|
4259
4298
|
: mode !== 'readonly');
|
|
4299
|
+
if (!allow && (systemSessionDecision && !systemSessionDecision.allow || policyDenied)) {
|
|
4300
|
+
const policyCode = systemSessionDecision && !systemSessionDecision.allow
|
|
4301
|
+
? systemSessionDecision.code
|
|
4302
|
+
: policyResult?.policyCode ?? 'session_policy_hook';
|
|
4303
|
+
auditToolPreflightDenial({
|
|
4304
|
+
toolName,
|
|
4305
|
+
policyCode,
|
|
4306
|
+
reason: systemSessionDecision && !systemSessionDecision.allow
|
|
4307
|
+
? systemSessionDecision.reason
|
|
4308
|
+
: policyResult?.reason ?? 'session policy denied MCP tool',
|
|
4309
|
+
summary: summarizeToolInputForAudit(toolName, toolInput).slice(0, 512),
|
|
4310
|
+
sessionId: sessionKey,
|
|
4311
|
+
agentAid: permissionContext?.selfAid,
|
|
4312
|
+
agentName: permissionContext?.agentName,
|
|
4313
|
+
permissionMode: mode,
|
|
4314
|
+
channel: permissionContext?.channel,
|
|
4315
|
+
actorId: permissionContext?.userId,
|
|
4316
|
+
role: permissionContext?.role,
|
|
4317
|
+
selfAid: permissionContext?.selfAid,
|
|
4318
|
+
taskId: permissionContext?.taskId,
|
|
4319
|
+
requestId: typeof params.requestId === 'string' ? params.requestId : undefined,
|
|
4320
|
+
callId: typeof params.itemId === 'string' ? params.itemId : undefined,
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4260
4323
|
if (allow) {
|
|
4261
4324
|
try {
|
|
4262
4325
|
for (const question of questions)
|
|
@@ -4698,7 +4761,7 @@ export class CodexRunner {
|
|
|
4698
4761
|
}
|
|
4699
4762
|
return 'allow';
|
|
4700
4763
|
}
|
|
4701
|
-
const recordBlockedOperation = async (policyCode, operationInput = toolInput, denialReason = 'policy denied', matchedPath) => {
|
|
4764
|
+
const recordBlockedOperation = async (policyCode, operationInput = toolInput, denialReason = 'policy denied', matchedPath, matchedRule) => {
|
|
4702
4765
|
const summary = summarizeToolInputForAudit(toolName, operationInput).slice(0, 512);
|
|
4703
4766
|
auditToolPreflightDenial({
|
|
4704
4767
|
toolName,
|
|
@@ -4718,6 +4781,7 @@ export class CodexRunner {
|
|
|
4718
4781
|
correlationId: callId,
|
|
4719
4782
|
taskId: permissionContext?.taskId,
|
|
4720
4783
|
matchedPath,
|
|
4784
|
+
matchedRule,
|
|
4721
4785
|
});
|
|
4722
4786
|
try {
|
|
4723
4787
|
await permissionContext?.recordExecutionAnomaly?.({
|
|
@@ -4762,7 +4826,7 @@ export class CodexRunner {
|
|
|
4762
4826
|
logger.warn(`[CodexRunner] tool preflight denied: session=${sessionKey} tool=${toolName} ` +
|
|
4763
4827
|
`policy=${preflight.policyCode ?? 'unknown'} reason=${preflight.message ?? 'policy denied'}`);
|
|
4764
4828
|
if (preflight.policyCode) {
|
|
4765
|
-
await recordBlockedOperation(preflight.policyCode, toolInput, preflight.message ?? 'tool preflight denied', preflight.matchedPath);
|
|
4829
|
+
await recordBlockedOperation(preflight.policyCode, toolInput, preflight.message ?? 'tool preflight denied', preflight.matchedPath, preflight.matchedRule);
|
|
4766
4830
|
}
|
|
4767
4831
|
return {
|
|
4768
4832
|
decision: 'deny',
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ecagent 插件的懒加载外壳。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要这一层:`agents/ecagent-runner.js` 会连带加载整个 ecagent 运行时
|
|
5
|
+
* (它依赖 typebox,模块图里仅 typebox 就有两千多次 resolve)。实测这段独占
|
|
6
|
+
* 约 360ms,是 daemon 启动模块加载中最大的一块。而绝大多数部署根本不用 ecagent
|
|
7
|
+
* ——本机一个声明了 `baseagents.ecagent` 的 Agent 都没有。
|
|
8
|
+
*
|
|
9
|
+
* 因此这里只保留插件身份和一个轻量的启用判定;真正的 Runner 在第一次需要时才
|
|
10
|
+
* 加载。判定逻辑与 `resolveEcagentConfig` 一致(它位于 baseagent.ts,不依赖
|
|
11
|
+
* 运行时),所以「能否启用」的结论与按需加载后完全相同。
|
|
12
|
+
*/
|
|
13
|
+
import { resolveEcagentConfig } from './baseagent.js';
|
|
14
|
+
/** 真正的实现模块只加载一次,失败也不重复尝试。 */
|
|
15
|
+
let realPluginPromise = null;
|
|
16
|
+
function loadRealPlugin() {
|
|
17
|
+
realPluginPromise ??= import('./ecagent-runner.js').then(module => new module.EcagentAgentPlugin());
|
|
18
|
+
return realPluginPromise;
|
|
19
|
+
}
|
|
20
|
+
export class EcagentAgentPluginLazy {
|
|
21
|
+
name = 'ecagent';
|
|
22
|
+
isEnabled(agent) {
|
|
23
|
+
const override = agent.config.baseagents?.ecagent;
|
|
24
|
+
if (!override)
|
|
25
|
+
return false;
|
|
26
|
+
try {
|
|
27
|
+
resolveEcagentConfig({ agents: { ecagent: override } }, override);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async createAgent(agent, callbacks, lifecycle) {
|
|
35
|
+
// 调用方已经通过 isEnabled 判定过,这里再确认一次以保持与直接使用真插件时一致的行为。
|
|
36
|
+
const plugin = await loadRealPlugin();
|
|
37
|
+
if (!plugin.isEnabled(agent))
|
|
38
|
+
return null;
|
|
39
|
+
return plugin.createAgent(agent, callbacks, lifecycle);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -711,14 +711,14 @@ function createTools(env, projectPath, runtimeEnv, bootstrapAgentMdPath, fullacc
|
|
|
711
711
|
const bash = {
|
|
712
712
|
name: 'Bash', label: 'Bash', description: 'Run a shell command in the project.',
|
|
713
713
|
parameters: Type.Object({
|
|
714
|
-
command: Type.String(), timeout: Type.Optional(Type.Number({ minimum: 1, maximum: 600_000 })),
|
|
714
|
+
command: Type.String(), timeout: Type.Optional(Type.Number({ minimum: 1, maximum: 600_000, description: 'Timeout in milliseconds (default 120000, maximum 600000).' })),
|
|
715
715
|
description: Type.Optional(Type.String({ description: '<命令目标描述> [<风险等级>],风险等级为 低/中/高 之一,例如 "查看工作区未提交的改动 [低]"。缺失或格式不符时调用被拒。' })),
|
|
716
716
|
}), executionMode: 'sequential',
|
|
717
717
|
async execute(_id, params, signal) {
|
|
718
718
|
const result = await env.exec(params.command, {
|
|
719
719
|
cwd: projectPath,
|
|
720
720
|
env: runtimeEnv,
|
|
721
|
-
timeout: params.timeout ?? DEFAULT_BASH_TIMEOUT_MS,
|
|
721
|
+
timeout: (params.timeout ?? DEFAULT_BASH_TIMEOUT_MS) / 1000,
|
|
722
722
|
abortSignal: signal,
|
|
723
723
|
});
|
|
724
724
|
if (!result.ok)
|
|
@@ -1023,7 +1023,7 @@ export class EcagentRunner {
|
|
|
1023
1023
|
if (pauseResult === 'cancelled')
|
|
1024
1024
|
return cancelledDecision();
|
|
1025
1025
|
}
|
|
1026
|
-
const decision = await this.authorizeTool(request.sessionId, request.projectPath, permissionMode, event.toolName, event.input, stats.numTurns + 1);
|
|
1026
|
+
const decision = await this.authorizeTool(request.sessionId, request.projectPath, permissionMode, event.toolName, event.input, stats.numTurns + 1, event.toolCallId);
|
|
1027
1027
|
const cancelled = lifecycle.cancelled || signal?.aborted;
|
|
1028
1028
|
const result = decision.block
|
|
1029
1029
|
? { ...decision, details: { ...decision.details, ...(cancelled ? { cancelled: true, abortSource: lifecycle.cancelled ? 'runner_interrupt' : 'abort_signal' } : {}) } }
|
|
@@ -1321,8 +1321,8 @@ export class EcagentRunner {
|
|
|
1321
1321
|
model: model.id, effort,
|
|
1322
1322
|
};
|
|
1323
1323
|
}
|
|
1324
|
-
async authorizeTool(sessionId, projectPath, mode, toolName, input, turn) {
|
|
1325
|
-
const decision = await this.evaluateToolPermission(sessionId, projectPath, mode, toolName, input, turn);
|
|
1324
|
+
async authorizeTool(sessionId, projectPath, mode, toolName, input, turn, callId) {
|
|
1325
|
+
const decision = await this.evaluateToolPermission(sessionId, projectPath, mode, toolName, input, turn, callId);
|
|
1326
1326
|
return decision.block ? {
|
|
1327
1327
|
...decision,
|
|
1328
1328
|
details: {
|
|
@@ -1331,7 +1331,7 @@ export class EcagentRunner {
|
|
|
1331
1331
|
},
|
|
1332
1332
|
} : decision;
|
|
1333
1333
|
}
|
|
1334
|
-
async evaluateToolPermission(sessionId, projectPath, mode, toolName, input, turn) {
|
|
1334
|
+
async evaluateToolPermission(sessionId, projectPath, mode, toolName, input, turn, callId) {
|
|
1335
1335
|
const permissionContext = this.permissionContexts.get(sessionId);
|
|
1336
1336
|
try {
|
|
1337
1337
|
await assertOwnershipAuthorization(permissionContext);
|
|
@@ -1339,12 +1339,12 @@ export class EcagentRunner {
|
|
|
1339
1339
|
catch (error) {
|
|
1340
1340
|
return { block: true, reason: error instanceof Error ? error.message : String(error) };
|
|
1341
1341
|
}
|
|
1342
|
-
const recordBlockedOperation = async (policyCode, operationInput = input,
|
|
1342
|
+
const recordBlockedOperation = async (policyCode, operationInput = input, details = {}) => {
|
|
1343
1343
|
const summary = summarizeToolInputForAudit(toolName, operationInput).slice(0, 512);
|
|
1344
1344
|
auditToolPreflightDenial({
|
|
1345
1345
|
toolName,
|
|
1346
1346
|
policyCode,
|
|
1347
|
-
reason: 'policy denied',
|
|
1347
|
+
reason: details.reason ?? 'policy denied',
|
|
1348
1348
|
summary,
|
|
1349
1349
|
sessionId,
|
|
1350
1350
|
agentAid: permissionContext?.selfAid,
|
|
@@ -1355,7 +1355,9 @@ export class EcagentRunner {
|
|
|
1355
1355
|
role: permissionContext?.role,
|
|
1356
1356
|
selfAid: permissionContext?.selfAid,
|
|
1357
1357
|
taskId: permissionContext?.taskId,
|
|
1358
|
-
|
|
1358
|
+
callId,
|
|
1359
|
+
matchedPath: details.matchedPath,
|
|
1360
|
+
matchedRule: details.matchedRule,
|
|
1359
1361
|
});
|
|
1360
1362
|
try {
|
|
1361
1363
|
await permissionContext?.recordExecutionAnomaly?.({
|
|
@@ -1418,7 +1420,9 @@ export class EcagentRunner {
|
|
|
1418
1420
|
});
|
|
1419
1421
|
if (preflight.behavior === 'deny') {
|
|
1420
1422
|
if (preflight.policyCode) {
|
|
1421
|
-
await recordBlockedOperation(preflight.policyCode, input,
|
|
1423
|
+
await recordBlockedOperation(preflight.policyCode, input, {
|
|
1424
|
+
reason: preflight.message, matchedPath: preflight.matchedPath, matchedRule: preflight.matchedRule,
|
|
1425
|
+
});
|
|
1422
1426
|
}
|
|
1423
1427
|
return { block: true, reason: preflight.message, details: { policyCode: preflight.policyCode } };
|
|
1424
1428
|
}
|
|
@@ -1431,7 +1435,10 @@ export class EcagentRunner {
|
|
|
1431
1435
|
allowReadonlySourceDiagnostics: permissionContext?.allowReadonlySourceDiagnostics === true,
|
|
1432
1436
|
});
|
|
1433
1437
|
if (decision.behavior === 'deny') {
|
|
1434
|
-
await recordBlockedOperation(decision.policyCode ?? 'readonly_mode', checkedInput
|
|
1438
|
+
await recordBlockedOperation(decision.policyCode ?? 'readonly_mode', checkedInput, {
|
|
1439
|
+
reason: decision.message,
|
|
1440
|
+
matchedPath: decision.matchedPath,
|
|
1441
|
+
});
|
|
1435
1442
|
return { block: true, reason: decision.message };
|
|
1436
1443
|
}
|
|
1437
1444
|
return {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** This read-only business query collects responses from every online device. */
|
|
2
2
|
export function isAidWideDeviceStatusQuery(payload) {
|
|
3
3
|
const params = payload?.params;
|
|
4
4
|
return payload?.type === 'ability' && payload.role === 'call'
|
|
@@ -6,12 +6,23 @@ export function isAidWideDeviceStatusQuery(payload) {
|
|
|
6
6
|
&& !!params && typeof params === 'object' && !Array.isArray(params)
|
|
7
7
|
&& params.action === 'read';
|
|
8
8
|
}
|
|
9
|
+
/** Discovery and status reads collect results across the Provider's devices. */
|
|
10
|
+
export function isAidWideAbilityQuery(payload) {
|
|
11
|
+
return (payload?.type === 'ability' && payload.role === 'call'
|
|
12
|
+
&& payload.ability_path === 'protocol/discover') || isAidWideDeviceStatusQuery(payload);
|
|
13
|
+
}
|
|
9
14
|
/** Device routing belongs to message.send, never to the Ability payload. */
|
|
10
15
|
export function resolveAunSendDevice(deviceId, scope, payload) {
|
|
11
16
|
if (deviceId !== undefined && (scope !== 'msg' || typeof deviceId !== 'string'
|
|
12
17
|
|| !deviceId || deviceId.length > 256 || /[\s\x00-\x1f\x7f]/.test(deviceId))) {
|
|
13
18
|
throw Object.assign(new Error('--device-id requires a nonempty private target device ID'), { code: 'INVALID_DEVICE_ID' });
|
|
14
19
|
}
|
|
20
|
+
if (payload?.type === 'ability' && payload.role === 'call' && payload.ability_path === 'protocol/discover') {
|
|
21
|
+
if (scope !== 'msg' || deviceId !== undefined) {
|
|
22
|
+
throw Object.assign(new Error('protocol/discover collects the Provider AID devices; omit --device-id and use a private AID target'), { code: 'ABILITY_DEVICE_NOT_ALLOWED' });
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
15
26
|
if (isAidWideDeviceStatusQuery(payload)) {
|
|
16
27
|
if (scope !== 'msg' || deviceId !== undefined) {
|
|
17
28
|
throw Object.assign(new Error('device/status queries the AID online devices; omit --device-id and use a private AID target'), { code: 'ABILITY_DEVICE_NOT_ALLOWED' });
|
package/dist/aun/aid/agentmd.js
CHANGED
|
@@ -818,7 +818,7 @@ export async function agentmdPutInitializationProfile(content, opts) {
|
|
|
818
818
|
const payload = stripAgentMdSignature(current.content);
|
|
819
819
|
// Use the SDK's upload schema as well as signature verification. Download
|
|
820
820
|
// compatibility alone also accepts historical cards without Ownership 2.1.
|
|
821
|
-
const { frontmatter } = validateAgentMdDocument(payload, { expectedAid: opts.aid,
|
|
821
|
+
const { frontmatter } = validateAgentMdDocument(payload, { expectedAid: opts.aid, validateOwnership: true });
|
|
822
822
|
const ownership = frontmatter.ownership;
|
|
823
823
|
const statement = ownership?.statement;
|
|
824
824
|
if (frontmatter.owner !== ownerAid || statement?.owner_aid !== ownerAid
|
|
@@ -841,7 +841,7 @@ export async function agentmdPutInitializationProfile(content, opts) {
|
|
|
841
841
|
document.set(field, profile[field]);
|
|
842
842
|
}
|
|
843
843
|
const updated = `---\n${document.toString({ lineWidth: 0 })}---\n${payload.slice(match[0].length)}`;
|
|
844
|
-
validateAgentMdDocument(updated, { expectedAid: opts.aid,
|
|
844
|
+
validateAgentMdDocument(updated, { expectedAid: opts.aid, validateOwnership: true });
|
|
845
845
|
return await publishAgentMd(updated, { ...opts, store, aunPath, expectedRemoteVersion: version });
|
|
846
846
|
}
|
|
847
847
|
finally {
|
package/dist/aun/aid/identity.js
CHANGED
|
@@ -88,6 +88,51 @@ export function aidList(aunPath) {
|
|
|
88
88
|
}
|
|
89
89
|
return [...seen.values()];
|
|
90
90
|
}
|
|
91
|
+
export async function aidRenewCertificate(aid, opts) {
|
|
92
|
+
const target = aid.trim();
|
|
93
|
+
if (!isValidAid(target)) {
|
|
94
|
+
throw Object.assign(new Error(`invalid AID: ${target}`), { code: 'INVALID_AID' });
|
|
95
|
+
}
|
|
96
|
+
const store = await getAidStore({ slotId: SLOT.cli, aunPath: opts?.aunPath });
|
|
97
|
+
try {
|
|
98
|
+
let loaded = store.load(target);
|
|
99
|
+
if (!loaded.ok && loaded.error.code === 'CERT_NOT_FOUND') {
|
|
100
|
+
const aunPath = opts?.aunPath ?? defaultAunPath();
|
|
101
|
+
const privateDir = path.join(aunPath, 'AIDs', target, 'private');
|
|
102
|
+
const hasPrivateKeyFile = ['key.json', 'key.json.v1']
|
|
103
|
+
.some(name => fs.existsSync(path.join(privateDir, name)));
|
|
104
|
+
if (!hasPrivateKeyFile) {
|
|
105
|
+
throw Object.assign(new Error(`private key required for aid: ${target}`), { code: 'PRIVATE_KEY_REQUIRED' });
|
|
106
|
+
}
|
|
107
|
+
const recovered = await store.resolve(target, { forceRefresh: true, skipAgentMd: true });
|
|
108
|
+
loaded = store.load(target);
|
|
109
|
+
if (!loaded.ok) {
|
|
110
|
+
const error = loaded.error.code === 'CERT_NOT_FOUND' && !recovered.ok
|
|
111
|
+
? recovered.error
|
|
112
|
+
: loaded.error;
|
|
113
|
+
throw Object.assign(new Error(error.message), { code: error.code });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else if (!loaded.ok) {
|
|
117
|
+
throw Object.assign(new Error(loaded.error.message), { code: loaded.error.code });
|
|
118
|
+
}
|
|
119
|
+
if (!loaded.data.aid.isPrivateKeyValid()) {
|
|
120
|
+
throw Object.assign(new Error(`private key required for aid: ${target}`), { code: 'PRIVATE_KEY_REQUIRED' });
|
|
121
|
+
}
|
|
122
|
+
const result = await store.renewCert(target);
|
|
123
|
+
if (!result.ok) {
|
|
124
|
+
throw Object.assign(new Error(result.error.message), { code: result.error.code });
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
aid: target,
|
|
128
|
+
newCertExpiresAt: new Date(result.data.new_cert_not_after).toISOString(),
|
|
129
|
+
newFingerprint: result.data.new_fingerprint,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
store.close();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
91
136
|
// ==================== Sign Self-Test ====================
|
|
92
137
|
/**
|
|
93
138
|
* 实跑一次本地 sign + verify,验证 AID 是否真能签名/验签。
|
package/dist/aun/aid/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { AgentMdVersionUnavailableError, AgentMdVersionConflictError } from './agentmd.js';
|
|
2
2
|
export { AGENT_TAG_MAX_LENGTH, validateAgentTag, validateAgentTags, } from './agentmd.js';
|
|
3
3
|
export { isValidAid, aidList, aidListVerified, aidCreate, aidCreateIdentityOnly, aidEnsureOwnerBinding, aidShow, aidDelete, aidLookup, verifySignAbility, probePkiRecoverability, appendAidLifecycle, readAidLifecycle } from './identity.js';
|
|
4
|
+
export { aidRenewCertificate } from './identity.js';
|
|
4
5
|
export { AGENT_TYPES, DEFAULT_AGENT_DESCRIPTION, DEFAULT_AGENT_TYPE, normalizeAgentType, validateAgentType, buildInitialAgentMd, buildOwnershipStatement, validateAgentMdFrontmatter, agentmdGet, agentmdPut, agentmdPutInitializationProfile, agentmdSet, agentmdSync, invalidateAgentDisplayName, parseAgentDisplayName, refreshAgentDisplayName, resolveAgentDisplayName, stripAgentMdSignature, updateAgentMdFrontmatterAvatar, updateAgentMdFrontmatterFieldValue, updateAgentMdFrontmatterName, } from './agentmd.js';
|
|
5
6
|
export { MIN_AUN_CORE_SDK, AUN_CORE_SDK_PKG, isAunSdkVersionOk, resolveAunCoreSdkPkg, ensureAunSdk, isAunSdkReady, downloadCaRoot, suppressSdkLogs, } from './client.js';
|
|
6
7
|
export { getAidStore, loadClient, loadAid, AidLoadError, SLOT } from './store.js';
|
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import { resolveRoot } from '../../paths.js';
|
|
4
4
|
import { agentmdGet, agentmdPut, agentmdSet, } from './agentmd.js';
|
|
5
5
|
import { uploadAvatarBuffer, uploadAvatarUrl } from '../../utils/avatar-upload.js';
|
|
6
|
-
import { aidLookup, aidShow } from './identity.js';
|
|
6
|
+
import { aidList, aidListVerified, aidLookup, aidShow } from './identity.js';
|
|
7
7
|
import { isValidAid } from './validation.js';
|
|
8
8
|
export class ManagedAidOperationError extends Error {
|
|
9
9
|
code;
|
|
@@ -21,6 +21,52 @@ function hasOnlyOptionalJsonFormat(args, aidIndex) {
|
|
|
21
21
|
const suffix = args.slice(aidIndex + 1);
|
|
22
22
|
return suffix.length === 0 || (suffix.length === 2 && suffix[0] === '--format' && suffix[1] === 'json');
|
|
23
23
|
}
|
|
24
|
+
function parseList(args) {
|
|
25
|
+
const supported = new Set(['--mine', '--broken', '--peer-cert', '--no-cert', '--no-verify']);
|
|
26
|
+
const options = [];
|
|
27
|
+
const provided = new Set();
|
|
28
|
+
let formatSeen = false;
|
|
29
|
+
for (let index = 1; index < args.length; index += 1) {
|
|
30
|
+
const token = args[index];
|
|
31
|
+
if (token === '--format=json') {
|
|
32
|
+
if (formatSeen)
|
|
33
|
+
return { ok: false, code: 'NOT_ALLOWED', reason: 'Duplicate --format' };
|
|
34
|
+
formatSeen = true;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (token === '--format') {
|
|
38
|
+
if (formatSeen || args[index + 1] !== 'json') {
|
|
39
|
+
return { ok: false, code: 'NOT_ALLOWED', reason: 'Only one --format json option is supported' };
|
|
40
|
+
}
|
|
41
|
+
formatSeen = true;
|
|
42
|
+
index += 1;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const flag = token;
|
|
46
|
+
if (!supported.has(flag) || provided.has(flag)) {
|
|
47
|
+
return { ok: false, code: 'NOT_ALLOWED', reason: 'aid list only supports unique category filters and an optional --format json suffix' };
|
|
48
|
+
}
|
|
49
|
+
provided.add(flag);
|
|
50
|
+
options.push(flag);
|
|
51
|
+
}
|
|
52
|
+
const filters = {
|
|
53
|
+
mine: provided.has('--mine'),
|
|
54
|
+
broken: provided.has('--broken'),
|
|
55
|
+
peerCert: provided.has('--peer-cert'),
|
|
56
|
+
noCert: provided.has('--no-cert'),
|
|
57
|
+
noVerify: provided.has('--no-verify'),
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
ok: true,
|
|
61
|
+
command: {
|
|
62
|
+
kind: 'list',
|
|
63
|
+
aid: '',
|
|
64
|
+
filters,
|
|
65
|
+
operationId: 'ec.aid.list',
|
|
66
|
+
canonicalArgv: ['aid', 'list', ...options],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
24
70
|
function parseAid(value) {
|
|
25
71
|
const aid = normalizeAid(value);
|
|
26
72
|
if (!aid)
|
|
@@ -112,6 +158,8 @@ export function resolveManagedAidOperation(argv) {
|
|
|
112
158
|
const subcommand = args[0];
|
|
113
159
|
if (subcommand === 'avatar')
|
|
114
160
|
return parseAvatar(args);
|
|
161
|
+
if (subcommand === 'list')
|
|
162
|
+
return parseList(args);
|
|
115
163
|
if ((subcommand === 'show' || subcommand === 'lookup') && hasOnlyOptionalJsonFormat(args, 1)) {
|
|
116
164
|
const parsedAid = parseAid(args[1]);
|
|
117
165
|
if (!parsedAid.ok)
|
|
@@ -146,7 +194,7 @@ export function resolveManagedAidOperation(argv) {
|
|
|
146
194
|
return {
|
|
147
195
|
ok: false,
|
|
148
196
|
code: 'NOT_ALLOWED',
|
|
149
|
-
reason: 'Managed AID operations only allow exact show, lookup, agentmd get, agentmd put, agentmd set, or avatar commands with supported options',
|
|
197
|
+
reason: 'Managed AID operations only allow exact list, show, lookup, agentmd get, agentmd put, agentmd set, or avatar commands with supported options',
|
|
150
198
|
};
|
|
151
199
|
}
|
|
152
200
|
export function managedAidShowViewForRole(role) {
|
|
@@ -165,6 +213,8 @@ export function redactAidShowResult(value) {
|
|
|
165
213
|
}
|
|
166
214
|
const defaultDependencies = () => ({
|
|
167
215
|
root: resolveRoot(),
|
|
216
|
+
aidList,
|
|
217
|
+
aidListVerified,
|
|
168
218
|
aidShow,
|
|
169
219
|
aidLookup,
|
|
170
220
|
agentmdGet,
|
|
@@ -181,6 +231,27 @@ export async function executeManagedAidOperation(command, options = {}) {
|
|
|
181
231
|
const deps = { ...defaultDependencies(), ...overrides };
|
|
182
232
|
const aunPath = deps.root;
|
|
183
233
|
switch (command.kind) {
|
|
234
|
+
case 'list': {
|
|
235
|
+
// Keep accepting commands constructed by older callers that did not
|
|
236
|
+
// carry the optional list filter object.
|
|
237
|
+
const filters = command.filters ?? {
|
|
238
|
+
mine: false,
|
|
239
|
+
broken: false,
|
|
240
|
+
peerCert: false,
|
|
241
|
+
noCert: false,
|
|
242
|
+
noVerify: false,
|
|
243
|
+
};
|
|
244
|
+
const all = filters.noVerify
|
|
245
|
+
? deps.aidList(aunPath)
|
|
246
|
+
: await deps.aidListVerified(aunPath);
|
|
247
|
+
const anyFilter = filters.mine || filters.broken || filters.peerCert || filters.noCert;
|
|
248
|
+
const value = all.filter(item => ((filters.mine && item.category === 'mine')
|
|
249
|
+
|| (filters.broken && item.category === 'broken')
|
|
250
|
+
|| (filters.peerCert && item.category === 'peer-cert')
|
|
251
|
+
|| (filters.noCert && item.category === 'no-cert')
|
|
252
|
+
|| (!anyFilter && item.category !== 'no-cert')));
|
|
253
|
+
return { kind: command.kind, aid: '', value };
|
|
254
|
+
}
|
|
184
255
|
case 'show': {
|
|
185
256
|
const value = await deps.aidShow(command.aid, { aunPath });
|
|
186
257
|
return {
|