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.
Files changed (127) hide show
  1. package/CHANGELOG.md +49 -36
  2. package/dist/agents/baseagent.js +68 -6
  3. package/dist/agents/codex-runner.js +62 -43
  4. package/dist/aun/aid/agentmd.js +98 -11
  5. package/dist/aun/aid/client.js +1 -1
  6. package/dist/aun/aid/control-aid.js +26 -2
  7. package/dist/aun/aid/identity.js +91 -0
  8. package/dist/aun/aid/index.js +1 -1
  9. package/dist/aun/aid/managed-operation.js +1 -1
  10. package/dist/aun/aid/ownership-operation.js +23 -22
  11. package/dist/aun/menu/client.js +27 -0
  12. package/dist/aun/msg/p2p.js +3 -8
  13. package/dist/aun/service-proxy.js +17 -0
  14. package/dist/channels/aun.js +321 -34
  15. package/dist/cli/agent-command.js +5 -2
  16. package/dist/cli/agent-create.js +991 -233
  17. package/dist/cli/agent.js +49 -10
  18. package/dist/cli/aid-bind-command.js +48 -19
  19. package/dist/cli/aun-commands.js +44 -16
  20. package/dist/cli/daemon-commands.js +1 -0
  21. package/dist/cli/index.js +24 -1
  22. package/dist/cli/init-channel.js +1 -1
  23. package/dist/cli/init.js +75 -1
  24. package/dist/cli/managed-command-guard.js +13 -1
  25. package/dist/cli/provider-command.js +57 -0
  26. package/dist/cli/restart-monitor.js +4 -2
  27. package/dist/cli/stats.js +10 -3
  28. package/dist/cli/task-context.js +19 -0
  29. package/dist/config/boot-log.js +3 -2
  30. package/dist/config/config-field-policy.js +12 -7
  31. package/dist/config/config-manager.js +138 -6
  32. package/dist/config/owner-config.js +2 -2
  33. package/dist/config/peer-role-resolver.js +2 -1
  34. package/dist/config/provider-ipc-service.js +132 -0
  35. package/dist/config/provider-menu-request.js +58 -0
  36. package/dist/config/providers-management.js +78 -5
  37. package/dist/config/resolved-config-op.js +8 -1
  38. package/dist/config/schema-migration.js +322 -8
  39. package/dist/config-store.js +10 -1
  40. package/dist/contracts/ecweb-service-protocol.js +2 -1
  41. package/dist/core/agent-application-service.js +60 -11
  42. package/dist/core/agent-create-status.js +203 -0
  43. package/dist/core/agent-creation-claim.js +177 -0
  44. package/dist/core/agent-ipc-registration.js +39 -18
  45. package/dist/core/agent-runtime.js +193 -23
  46. package/dist/core/auth/agent-delegation.js +4 -2
  47. package/dist/core/auth/auth-gateway.js +66 -1
  48. package/dist/core/auth/authorization-audit.js +41 -5
  49. package/dist/core/auth/delegation-authorization.js +2 -1
  50. package/dist/core/auth/operation-authorizer.js +28 -6
  51. package/dist/core/auth/operation-catalog.js +14 -1
  52. package/dist/core/channel-loader.js +2 -0
  53. package/dist/core/command/agent-control.js +257 -14
  54. package/dist/core/command/cli-intent-parser.js +6 -2
  55. package/dist/core/command/command-handler.js +64 -55
  56. package/dist/core/command/memory-slash.js +1 -1
  57. package/dist/core/command/menu-catalog.js +5 -0
  58. package/dist/core/command/menu-handler.js +64 -18
  59. package/dist/core/command/menu-protocol.js +15 -1
  60. package/dist/core/command/provider-menu.js +46 -0
  61. package/dist/core/command/slash-handler.js +2 -1
  62. package/dist/core/daemon-control.js +18 -13
  63. package/dist/core/event-catalog.js +10 -0
  64. package/dist/core/evolagent-registry.js +3 -1
  65. package/dist/core/evolagent.js +8 -6
  66. package/dist/core/file-integrity/store.js +11 -0
  67. package/dist/core/handoff/ipc-registration.js +3 -0
  68. package/dist/core/initialization/service.js +491 -0
  69. package/dist/core/ipc-registration.js +34 -22
  70. package/dist/core/memory/consolidation-ops-records.js +95 -0
  71. package/dist/core/memory/consolidation-trigger.js +19 -2
  72. package/dist/core/memory/consolidation.js +19 -8
  73. package/dist/core/memory/memory-admin.js +1 -1
  74. package/dist/core/memory/relation-sweep.js +11 -6
  75. package/dist/core/message/aun-ipc-sender.js +73 -67
  76. package/dist/core/message/im-renderer.js +18 -0
  77. package/dist/core/message/message-bridge.js +35 -3
  78. package/dist/core/message/response-engine.js +32 -28
  79. package/dist/core/model/catalog-service.js +1 -1
  80. package/dist/core/model/config-scope.js +5 -7
  81. package/dist/core/ownership/owner-resolver.js +755 -143
  82. package/dist/core/permission/approval-gateway.js +103 -403
  83. package/dist/core/permission/ec-command-parser.js +32 -4
  84. package/dist/core/permission/index.js +1 -0
  85. package/dist/core/permission/permission-result.js +78 -0
  86. package/dist/core/permission/tool-policy.js +7 -43
  87. package/dist/core/system-session/memory.js +37 -7
  88. package/dist/directory/owner-directory-cache.js +2 -2
  89. package/dist/ecweb/init-menu.js +32 -0
  90. package/dist/index.js +17 -5
  91. package/dist/ipc.js +85 -25
  92. package/dist/paths.js +3 -0
  93. package/dist/proxy/manager.js +6 -7
  94. package/dist/trigger/authorization.js +27 -17
  95. package/dist/trigger/feedback.js +2 -3
  96. package/dist/trigger/ipc-service.js +105 -78
  97. package/dist/trigger/local-files.js +2 -1
  98. package/dist/trigger/manager.js +5 -3
  99. package/dist/trigger/scheduler.js +88 -6
  100. package/dist/utils/atomic-write.js +28 -0
  101. package/dist/utils/error-utils.js +24 -0
  102. package/dist/utils/logger.js +68 -1
  103. package/dist/utils/welcome.js +1 -1
  104. package/kits/docs/INDEX.md +1 -0
  105. package/kits/docs/aun/SDK.md +4 -1
  106. package/kits/docs/evolcore/INDEX.md +1 -0
  107. package/kits/docs/evolcore/agent.md +8 -1
  108. package/kits/docs/evolcore/aid.md +67 -17
  109. package/kits/docs/evolcore/config.md +11 -1
  110. package/kits/docs/evolcore/group.md +1 -1
  111. package/kits/docs/evolcore/provider.md +50 -0
  112. package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
  113. package/kits/rules/01-overview.md +3 -0
  114. package/kits/rules/04-relation.md +1 -1
  115. package/kits/schemas/_meta.json +2 -2
  116. package/kits/schemas/agent-config.schema.16.json +3 -3
  117. package/kits/schemas/relation-config.schema.11.json +17 -0
  118. package/kits/skills/.switches.json +8 -0
  119. package/kits/skills/ec-agent-create/SKILL.md +3 -0
  120. package/kits/skills/ec-identity/SKILL.md +2 -2
  121. package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
  122. package/kits/skills/ec-trigger/SKILL.md +5 -13
  123. package/kits/skills/thread-ops/SKILL.md +5 -0
  124. package/kits/templates/system-fragments/venue.md +1 -1
  125. package/package.json +3 -3
  126. package/dist/core/memory/forget-log.js +0 -96
  127. package/dist/core/message/create-status.js +0 -96
@@ -43,7 +43,7 @@ import { hasTrustedFullAccessDelegation, trustedExecutionIdentityInput } from '.
43
43
  import { executeManagedAidOperation, ManagedAidOperationError, managedAidShowViewForRole, resolveManagedAidOperation, } from '../../aun/aid/managed-operation.js';
44
44
  import { MAX_AVATAR_SOURCE_BYTES } from '../../utils/avatar-upload.js';
45
45
  import { executeManagedGroupOperation, isManagedGroupRelationRead, isManagedGroupRelationWrite, ManagedGroupOperationError, resolveManagedGroupOperation, executeManagedMsgOperation, ManagedMsgOperationError, resolveManagedMsgOperation, executeManagedFsOperation, ManagedFsOperationError, resolveManagedFsOperation, } from '../../aun/msg/managed-operation.js';
46
- import { authorizeFreshOperation, buildAuthSubject } from '../auth/auth-gateway.js';
46
+ import { authorizeFreshOperation, buildAuthSubject, executeAuditedOperation } from '../auth/auth-gateway.js';
47
47
  import { isHClassPath, isLClassPath, isSameOrDescendant } from '../permission/protected-paths.js';
48
48
  import { validateModelSelectionForRole } from '../model/model-permission.js';
49
49
  import { getModelInfo } from '../model/model-catalog.js';
@@ -141,7 +141,8 @@ export class CommandHandler {
141
141
  const target = fs.realpathSync(path.resolve(session.projectPath, file));
142
142
  const roots = [session.projectPath, this.getManagedSessionTempDir(session)].filter((v) => !!v)
143
143
  .map(root => fs.realpathSync(root));
144
- if (!roots.some(root => isSameOrDescendant(target, root)) || isHClassPath(target) || isLClassPath(target))
144
+ if (!roots.some(root => isSameOrDescendant(target, root))
145
+ || (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(target) || isLClassPath(target))))
145
146
  throw new Error('Menu request file must be an unprotected file in the project or session TMPDIR');
146
147
  const stat = fs.statSync(target);
147
148
  if (!stat.isFile() || stat.nlink > 1 || stat.size > 128 * 1024)
@@ -1039,7 +1040,7 @@ export class CommandHandler {
1039
1040
  return false;
1040
1041
  return !!userId && topic.metadata?.peerId === userId;
1041
1042
  }
1042
- buildTopicMenuItem(s) {
1043
+ buildTopicMenuItem(s, metadataOnly = false) {
1043
1044
  const displayName = displaySessionTitle(s.name, sessionTopicThreadId(s) || s.id.slice(0, 8));
1044
1045
  const item = {
1045
1046
  value: sessionTopicThreadId(s) ?? '',
@@ -1052,12 +1053,14 @@ export class CommandHandler {
1052
1053
  item.forkSource = forkSource;
1053
1054
  if (s.agentSessionId) {
1054
1055
  item.agentSessionId = s.agentSessionId;
1055
- const fileInfo = this.sessionManager.getSessionFileInfo(s.projectPath, s.agentSessionId, s.baseagent, s.selfAID);
1056
- if (fileInfo.turns)
1057
- item.turns = fileInfo.turns;
1058
- const firstMsg = this.sessionManager.readSessionFirstMessage(s.projectPath, s.agentSessionId, s.baseagent, s.selfAID);
1059
- if (firstMsg)
1060
- item.preview = firstMsg.length > 80 ? firstMsg.slice(0, 80) + '...' : firstMsg;
1056
+ if (!metadataOnly) {
1057
+ const fileInfo = this.sessionManager.getSessionFileInfo(s.projectPath, s.agentSessionId, s.baseagent, s.selfAID);
1058
+ if (fileInfo.turns)
1059
+ item.turns = fileInfo.turns;
1060
+ const firstMsg = this.sessionManager.readSessionFirstMessage(s.projectPath, s.agentSessionId, s.baseagent, s.selfAID);
1061
+ if (firstMsg)
1062
+ item.preview = firstMsg.length > 80 ? firstMsg.slice(0, 80) + '...' : firstMsg;
1063
+ }
1061
1064
  }
1062
1065
  if (s.updatedAt)
1063
1066
  item.lastActive = s.updatedAt;
@@ -1870,16 +1873,16 @@ export class CommandHandler {
1870
1873
  * Agent managed CLI config entrypoint. Identity and relation are resolved
1871
1874
  * from the daemon-owned session rather than caller-provided flags.
1872
1875
  */
1873
- async handleConfigOperation(argv, sessionId, delegationToken, delegationCommandHash) {
1876
+ async handleConfigOperation(argv, sessionId, delegationToken, delegationCommandHash, requestId) {
1874
1877
  if (!this.agentDelegationRegistry) {
1875
1878
  return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task delegation is not configured' };
1876
1879
  }
1877
1880
  const delegation = this.agentDelegationRegistry.validate(delegationToken, sessionId, delegationCommandHash);
1878
1881
  if (!delegation.ok)
1879
1882
  return { ok: false, code: delegation.code, error: delegation.reason };
1880
- return this.executeConfigOperation(argv, sessionId, delegation.grant);
1883
+ return this.executeConfigOperation(argv, sessionId, delegation.grant, requestId);
1881
1884
  }
1882
- async executeConfigOperation(argv, sessionId, grant) {
1885
+ async executeConfigOperation(argv, sessionId, grant, requestId) {
1883
1886
  const session = await this.sessionManager.getSessionById(sessionId);
1884
1887
  if (!session)
1885
1888
  return { ok: false, code: 'INVALID_SESSION', error: 'Invalid session' };
@@ -1903,6 +1906,8 @@ export class CommandHandler {
1903
1906
  }
1904
1907
  const subject = buildAuthSubject({
1905
1908
  selfAid: grant.selfAid,
1909
+ sessionId,
1910
+ requestId,
1906
1911
  actorId: grant.actorId,
1907
1912
  channel: grant.channel,
1908
1913
  channelType: grant.channelType,
@@ -1912,13 +1917,13 @@ export class CommandHandler {
1912
1917
  processOwners: ownerResolver.daemonOwners(),
1913
1918
  ...trustedExecutionIdentityInput(grant),
1914
1919
  });
1915
- const executeOne = async (fieldArgv) => {
1920
+ const executeOne = async (fieldArgv, itemIndex) => {
1916
1921
  const resolved = resolveConfigCommand(fieldArgv, {
1917
1922
  defaultRelation: { self: grant.selfAid, peerKey: grant.peerKey },
1918
1923
  });
1919
1924
  if (!resolved.ok)
1920
1925
  return { ok: false, code: resolved.code, error: resolved.reason };
1921
- const decision = await authorizeFreshOperation({
1926
+ return executeAuditedOperation({
1922
1927
  source: 'agent-tool',
1923
1928
  subject,
1924
1929
  intent: {
@@ -1939,28 +1944,28 @@ export class CommandHandler {
1939
1944
  taskId: grant.taskId,
1940
1945
  messageId: grant.messageId,
1941
1946
  },
1942
- });
1943
- if (!decision.allow)
1944
- return { ok: false, code: decision.code, error: decision.reason };
1945
- const roleContext = {
1946
- self: grant.selfAid,
1947
- actorRole: subject.role,
1948
- actorRoleSource: subject.roleSource,
1949
- actorAllowAccess: subject.allowAccess,
1950
- actorAid: grant.actorId,
1951
- isDaemonOwner: subject.isDaemonOwner,
1952
- fromControlChannel: subject.fromControlChannel,
1953
- chatType: grant.chatType,
1954
- };
1955
- return await executeResolvedConfigCommandAsync(resolved.command, {
1956
- role: subject.role,
1957
- roleContext,
1958
- });
1947
+ }, async (onExecutionStarted) => {
1948
+ const roleContext = {
1949
+ self: grant.selfAid,
1950
+ actorRole: subject.role,
1951
+ actorRoleSource: subject.roleSource,
1952
+ actorAllowAccess: subject.allowAccess,
1953
+ actorAid: grant.actorId,
1954
+ isDaemonOwner: subject.isDaemonOwner,
1955
+ fromControlChannel: subject.fromControlChannel,
1956
+ chatType: grant.chatType,
1957
+ };
1958
+ onExecutionStarted();
1959
+ return executeResolvedConfigCommandAsync(resolved.command, {
1960
+ role: subject.role,
1961
+ roleContext,
1962
+ });
1963
+ }, itemIndex);
1959
1964
  };
1960
1965
  const batch = splitConfigBatchGetArgv(argv);
1961
1966
  if (batch && batch.fields.length > 1) {
1962
- const results = await Promise.all(batch.fields.map(async (field) => {
1963
- const result = await executeOne(['config', 'get', field, ...batch.rest]);
1967
+ const results = await Promise.all(batch.fields.map(async (field, itemIndex) => {
1968
+ const result = await executeOne(['config', 'get', field, ...batch.rest], itemIndex);
1964
1969
  if (!result.ok)
1965
1970
  return { ok: false, field, code: result.code, error: result.error };
1966
1971
  if (result.subcommand !== 'get') {
@@ -2101,9 +2106,6 @@ export class CommandHandler {
2101
2106
  if (!delegation?.ok)
2102
2107
  return { ok: false, code: 'INVALID_DELEGATION', error: 'Valid task delegation is required' };
2103
2108
  const grant = delegation.grant;
2104
- if (grant.executionIdentity) {
2105
- return { ok: false, code: 'NOT_ALLOWED', error: 'Fullaccess execution does not grant protocol Owner binding authority' };
2106
- }
2107
2109
  const session = await this.sessionManager.getSessionById(sessionId);
2108
2110
  if (!session || session.selfAID !== grant.selfAid)
2109
2111
  return { ok: false, code: 'INVALID_SESSION', error: 'Delegation does not match the session identity' };
@@ -2111,11 +2113,13 @@ export class CommandHandler {
2111
2113
  const command = parseOwnershipCommand(argv);
2112
2114
  const targetAid = command.subjectAid ?? grant.selfAid;
2113
2115
  ownerResolver.assertLocalSubject(targetAid);
2114
- const isMutation = command.action !== 'status';
2115
- if (isMutation && !['request', 'bypass'].includes(grant.permissionMode ?? '')) {
2116
+ if (command.action === 'status') {
2117
+ return { ok: true, state: await executeOwnershipCommand(command, grant.selfAid) };
2118
+ }
2119
+ if (!['request', 'bypass'].includes(grant.permissionMode ?? '')) {
2116
2120
  return { ok: false, code: 'NOT_ALLOWED', error: 'Binding changes and decisions require a request or bypass task' };
2117
2121
  }
2118
- await refreshOwnershipForAuthorization(targetAid);
2122
+ await refreshOwnershipForAuthorization(targetAid, { includeDaemon: true });
2119
2123
  let conversationId;
2120
2124
  try {
2121
2125
  conversationId = parsePeerKey(grant.peerKey).channelId;
@@ -2132,16 +2136,18 @@ export class CommandHandler {
2132
2136
  if (targetAid !== grant.selfAid && !subject.isDaemonOwner) {
2133
2137
  return { ok: false, code: 'SCOPE_MISMATCH', error: 'A different local subject requires the current daemon Owner' };
2134
2138
  }
2135
- if (!subject.isDaemonOwner && (isMutation ? subject.role !== 'owner' : !isManagementRole(subject.role))) {
2139
+ if (!subject.isDaemonOwner && subject.role !== 'owner') {
2136
2140
  return { ok: false, code: 'OWNER_REQUIRED', error: 'Ownership binding requires the subject Owner or daemon Owner; first daemon binding uses the local CLI' };
2137
2141
  }
2138
2142
  const decision = await authorizeFreshOperation({
2139
2143
  source: 'agent-tool', subject,
2140
2144
  intent: {
2141
- operation: isMutation ? 'ec.aid.bind' : 'ec.aid.bind.status', scope: 'agent', source: 'agent-tool',
2145
+ operation: command.action === 'transfer' ? 'ec.aid.transfer' : 'ec.aid.bind',
2146
+ scope: 'agent', source: 'agent-tool',
2142
2147
  args: {
2143
2148
  self: targetAid,
2144
2149
  ...(command.action === 'bind' ? { ownerAid: command.ownerAid } : {}),
2150
+ ...(command.action === 'transfer' ? { subAid: command.subAid, newOwnerAid: command.newOwnerAid } : {}),
2145
2151
  ...(command.action === 'accept' || command.action === 'reject'
2146
2152
  ? { decision: command.action, operationId: command.operationId } : {}),
2147
2153
  },
@@ -2189,7 +2195,7 @@ export class CommandHandler {
2189
2195
  return { ok: false, code: 'ROLE_OPERATION_FAILED', error: error?.message ?? String(error) };
2190
2196
  }
2191
2197
  }
2192
- async handleAidOperation(argv, sessionId, delegationToken, delegationCommandHash) {
2198
+ async handleAidOperation(argv, sessionId, delegationToken, delegationCommandHash, requestId) {
2193
2199
  if (!this.agentDelegationRegistry) {
2194
2200
  return { ok: false, code: 'DELEGATION_REQUIRED', error: 'Task delegation is not configured' };
2195
2201
  }
@@ -2225,6 +2231,8 @@ export class CommandHandler {
2225
2231
  }
2226
2232
  const subject = buildAuthSubject({
2227
2233
  selfAid: delegation.grant.selfAid,
2234
+ sessionId,
2235
+ requestId,
2228
2236
  actorId: delegation.grant.actorId,
2229
2237
  channel: delegation.grant.channel,
2230
2238
  channelType: delegation.grant.channelType,
@@ -2235,7 +2243,7 @@ export class CommandHandler {
2235
2243
  ...trustedExecutionIdentityInput(delegation.grant),
2236
2244
  });
2237
2245
  const managementRole = isManagementRole(subject.role);
2238
- const decision = await authorizeFreshOperation({
2246
+ return executeAuditedOperation({
2239
2247
  source: 'agent-tool',
2240
2248
  subject,
2241
2249
  intent: {
@@ -2249,12 +2257,12 @@ export class CommandHandler {
2249
2257
  taskId: delegation.grant.taskId,
2250
2258
  messageId: delegation.grant.messageId,
2251
2259
  },
2252
- });
2253
- if (!decision.allow)
2254
- return { ok: false, code: decision.code, error: decision.reason };
2260
+ }, onExecutionStarted => this.executeAuthorizedAidOperation(parsed.command, session, subject, delegation.grant, onExecutionStarted));
2261
+ }
2262
+ async executeAuthorizedAidOperation(command, session, subject, grant, onExecutionStarted) {
2255
2263
  let avatarBuffer;
2256
- if (parsed.command.kind === 'avatar' && parsed.command.filePath) {
2257
- const filePath = String(parsed.command.filePath || '').trim();
2264
+ if (command.kind === 'avatar' && command.filePath) {
2265
+ const filePath = String(command.filePath || '').trim();
2258
2266
  if (typeof session.projectPath !== 'string' || !session.projectPath.trim()) {
2259
2267
  return { ok: false, code: 'INVALID_AVATAR_PATH', error: 'Avatar file requires a current session project path' };
2260
2268
  }
@@ -2265,7 +2273,7 @@ export class CommandHandler {
2265
2273
  if (!filePath || !allowedRoots.some(root => isSameOrDescendant(resolvedPath, root))) {
2266
2274
  return { ok: false, code: 'INVALID_AVATAR_PATH', error: 'Avatar file must be inside the current session project or managed TMPDIR' };
2267
2275
  }
2268
- if (isHClassPath(resolvedPath) || isLClassPath(resolvedPath)) {
2276
+ if (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(resolvedPath) || isLClassPath(resolvedPath))) {
2269
2277
  return { ok: false, code: 'PROTECTED_AVATAR_PATH', error: 'Avatar file cannot be read from a protected EvolCore path' };
2270
2278
  }
2271
2279
  let fd;
@@ -2281,7 +2289,7 @@ export class CommandHandler {
2281
2289
  if (!realAllowedRoots.some(root => isSameOrDescendant(realPath, root))) {
2282
2290
  return { ok: false, code: 'INVALID_AVATAR_PATH', error: 'Avatar file resolves outside the current session project or managed TMPDIR' };
2283
2291
  }
2284
- if (isHClassPath(realPath) || isLClassPath(realPath)) {
2292
+ if (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(realPath) || isLClassPath(realPath))) {
2285
2293
  return { ok: false, code: 'PROTECTED_AVATAR_PATH', error: 'Avatar file cannot be read from a protected EvolCore path' };
2286
2294
  }
2287
2295
  const stat = fs.lstatSync(resolvedPath);
@@ -2313,7 +2321,8 @@ export class CommandHandler {
2313
2321
  }
2314
2322
  }
2315
2323
  try {
2316
- const result = await executeManagedAidOperation(parsed.command, {
2324
+ onExecutionStarted();
2325
+ const result = await executeManagedAidOperation(command, {
2317
2326
  showView: managedAidShowViewForRole(subject.role),
2318
2327
  ...(avatarBuffer ? { avatarBuffer } : {}),
2319
2328
  });
@@ -2446,7 +2455,7 @@ export class CommandHandler {
2446
2455
  if (!filePath || !allowedPaths.some(root => isSameOrDescendant(resolvedPath, root))) {
2447
2456
  return { ok: false, code: 'INVALID_RULES_PATH', error: 'Rules file must be inside the current session project or managed TMPDIR' };
2448
2457
  }
2449
- if (isHClassPath(resolvedPath) || isLClassPath(resolvedPath)) {
2458
+ if (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(resolvedPath) || isLClassPath(resolvedPath))) {
2450
2459
  return { ok: false, code: 'PROTECTED_RULES_PATH', error: 'Rules file cannot be read from a protected EvolCore path' };
2451
2460
  }
2452
2461
  let rulesFd;
@@ -2464,7 +2473,7 @@ export class CommandHandler {
2464
2473
  if (!realAllowedPaths.some(root => isSameOrDescendant(realPath, root))) {
2465
2474
  return { ok: false, code: 'INVALID_RULES_PATH', error: 'Rules file resolves outside the current session project or managed TMPDIR' };
2466
2475
  }
2467
- if (isHClassPath(realPath) || isLClassPath(realPath)) {
2476
+ if (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(realPath) || isLClassPath(realPath))) {
2468
2477
  return { ok: false, code: 'PROTECTED_RULES_PATH', error: 'Rules file cannot be read from a protected EvolCore path' };
2469
2478
  }
2470
2479
  rulesFd = fs.openSync(realPath, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW);
@@ -2822,7 +2831,7 @@ export class CommandHandler {
2822
2831
  if (!allowedRoots.some(root => isSameOrDescendant(resolvedPath, root))) {
2823
2832
  return { ok: false, code: 'INVALID_LOCAL_PATH', error: 'Upload source must be inside the current session project or managed TMPDIR' };
2824
2833
  }
2825
- if (isHClassPath(resolvedPath) || isLClassPath(resolvedPath)) {
2834
+ if (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(resolvedPath) || isLClassPath(resolvedPath))) {
2826
2835
  return { ok: false, code: 'PROTECTED_LOCAL_PATH', error: 'Upload source cannot be a protected EvolCore path' };
2827
2836
  }
2828
2837
  try {
@@ -2841,7 +2850,7 @@ export class CommandHandler {
2841
2850
  }
2842
2851
  const realAllowedRoots = [realProjectPath, realManagedTempPath].filter((value) => !!value);
2843
2852
  if (!realAllowedRoots.some(root => isSameOrDescendant(realPath, root))
2844
- || isHClassPath(realPath) || isLClassPath(realPath)) {
2853
+ || (!hasTrustedFullAccessDelegation(grant) && (isHClassPath(realPath) || isLClassPath(realPath)))) {
2845
2854
  return { ok: false, code: 'PROTECTED_LOCAL_PATH', error: 'Upload source resolves outside the allowed project or managed TMPDIR path' };
2846
2855
  }
2847
2856
  if (realManagedTempPath && isSameOrDescendant(realPath, realManagedTempPath) && stat.nlink > 1) {
@@ -9,7 +9,7 @@
9
9
  */
10
10
  import { CONSOLIDATION_MODES, MODE_SCOPE } from '../memory/consolidation-context.js';
11
11
  import { formatQueueDetails } from '../memory/consolidation-queue-format.js';
12
- import { FORGET_REASON_MAX_CHARS, normalizeForgetReason } from '../memory/forget-log.js';
12
+ import { FORGET_REASON_MAX_CHARS, normalizeForgetReason } from '../memory/consolidation-ops-records.js';
13
13
  import { MEMORY_SCOPES, isMemoryScope, memoryOverview, listMemoryFiles, formatMemoryFiles, readMemoryIndex, showMemoryFile, formatPendingNotes, showPendingNote, reindexScope, dropNote, archiveMemoryFile, restoreMemoryFile, } from '../memory/memory-admin.js';
14
14
  const USAGE = [
15
15
  '用法:',
@@ -67,6 +67,11 @@ const relation = (id, name, label, order, cmd, operation, extra) => ({
67
67
  ...extra,
68
68
  });
69
69
  const ENTRIES = [
70
+ { id: 'provider.list', type: 'list', contexts: ['process'], name: 'provider', label: 'Provider 注册表', section: 'process', order: 80, query: { cmd: '/provider', args: { scope: 'process', view: 'list' }, operation: 'provider.list', scope: 'process' }, control: 'list' },
71
+ { id: 'provider.create', type: 'action', contexts: ['process'], name: 'provider', label: '创建 Provider', section: 'process', order: 81, action: { cmd: '/provider', action: 'create', args: { scope: 'process' }, operation: 'provider.create', scope: 'process' } },
72
+ { id: 'provider.import', type: 'action', contexts: ['process'], name: 'provider', label: '导入 Provider JSON', section: 'process', order: 82, action: { cmd: '/provider', action: 'import', args: { scope: 'process' }, operation: 'provider.import', scope: 'process' } },
73
+ { id: 'provider.update', type: 'setting', contexts: ['process'], name: 'provider', label: '更新 Provider', section: 'process', order: 83, update: { cmd: '/provider', args: { scope: 'process', resource: 'provider' }, operation: 'provider.update', scope: 'process' }, valueSchema: { type: 'string' }, control: 'json' },
74
+ { id: 'provider.delete', type: 'action', contexts: ['process'], name: 'provider', label: '删除 Provider', section: 'process', order: 84, action: { cmd: '/provider', action: 'delete', args: { scope: 'process' }, operation: 'provider.delete', scope: 'process' } },
70
75
  {
71
76
  id: 'session.loop',
72
77
  type: 'setting',
@@ -1,4 +1,5 @@
1
1
  import { memoryHelpEntries } from './memory-slash.js';
2
+ import { executeProviderMenu } from './provider-menu.js';
2
3
  import { getBaseagentSnapshot, loadedBaseagentIds } from '../../agents/baseagent-availability.js';
3
4
  import { normalizePeer, writeAgentModelConfig } from '../model/config-scope.js';
4
5
  import { formatPeerKey } from '../relation/peer-identity.js';
@@ -25,7 +26,7 @@ import { scanInstances } from '../../utils/instance-registry.js';
25
26
  import { loadDefaults, loadDaemonConfig } from '../../config-store.js';
26
27
  import { WEB_PACKAGE_NAME, RESTART_REQUEST_ID_ENV, RUNTIME_HOME_ENV, SESSION_ID_ENV } from '../../product.js';
27
28
  import { read as cfgRead, resolveEffective, resolveEffectiveFieldWithSource, routeFieldPath, write as cfgWrite, ConfigTarget, } from '../../config/config-manager.js';
28
- import { execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
29
+ import { agentCreateCapabilities, execAgentAction, execAgentQuery, execAgentOptions, execAidAvatar, resolveProjectPath } from './agent-control.js';
29
30
  import { readInitialization } from '../../cli/agent-create.js';
30
31
  import { isValidAid } from '../../aun/aid/validation.js';
31
32
  import { gatewayList, gatewayUpdate, gatewayDelete, gatewayTest, gatewayModels, gatewaySetPrice } from '../../config/gateway-config.js';
@@ -735,10 +736,7 @@ function readMenuPermission(target) {
735
736
  source: decision.decidedBy === 'role' ? 'role' : 'builtin',
736
737
  };
737
738
  }
738
- /**
739
- * 模型参数只在 Agent 级。旧客户端可能仍带 scope=relation 查询:读取结果与 Agent 级相同,
740
- * 一律解析到 Agent 级;写入的鉴权固定为 agent scope(见 intent 映射)。
741
- */
739
+ /** Model and effort menus are valid only in Agent settings. */
742
740
  function menuModelScope(args) {
743
741
  const raw = menuStringArg(args, 'scope') ?? 'agent';
744
742
  if (raw === 'agent' || raw === 'relation')
@@ -891,6 +889,8 @@ export const SELF_MANAGE_AGENT_ACTIONS = new Set(['update', 'reload']);
891
889
  /** 判断 (cmdBase, action) 是否为进程级操作(仅控制 channel 可执行)。
892
890
  * /system 全部进程级;/agent 仅 create/delete/enable/disable 进程级;其余关系级。 */
893
891
  export function isProcessLevelAction(cmdBase, action) {
892
+ if (cmdBase === '/provider')
893
+ return true;
894
894
  if (cmdBase === '/baseagent-models')
895
895
  return true;
896
896
  if (cmdBase === '/system')
@@ -943,9 +943,10 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
943
943
  source: 'menu',
944
944
  args: { ...payload, ...(extra ?? {}) },
945
945
  });
946
- // 读取与写入都固定为 agent scope;客户端可能仍带 scope=relation,忽略它。
947
- const modelScope = 'agent';
948
- void args?.scope;
946
+ // Legacy relation-menu requests must not be silently promoted into Agent reads.
947
+ const modelScope = verb === 'update'
948
+ ? 'agent'
949
+ : args?.scope === 'relation' ? 'relation' : 'agent';
949
950
  if (verb === 'query') {
950
951
  if (cmdBase === '/baseagent-models')
951
952
  return intent('baseagent.models.list', 'process');
@@ -1089,8 +1090,6 @@ function buildMenuIntent(verb, cmdBase, args, action, value, fromControlChannel
1089
1090
  if (cmdBase === '/trigger') {
1090
1091
  if (action === 'create' || action === 'set')
1091
1092
  return intent('trigger.create', 'relation', { action });
1092
- if (action === 'show')
1093
- return intent('trigger.show', 'relation', { action });
1094
1093
  if (action === 'history')
1095
1094
  return intent('trigger.history', 'relation', { action });
1096
1095
  if (action === 'enable' || action === 'disable')
@@ -1754,6 +1753,12 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
1754
1753
  lifecycle: ag.lifecycle ?? null,
1755
1754
  baseagent: ag.baseagent ?? null,
1756
1755
  projectPath: ag.projectPath ?? null,
1756
+ ...(ag.mode === 'one_shot' ? {
1757
+ mode: ag.mode,
1758
+ initialization: ag.initialization,
1759
+ createProgress: ag.createProgress,
1760
+ ownership: ag.ownership,
1761
+ } : {}),
1757
1762
  }));
1758
1763
  }
1759
1764
  // agent channel:直接读取自身,避免先枚举全部 Agent 再过滤。
@@ -1773,6 +1778,12 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
1773
1778
  lifecycle: ag.lifecycle ?? null,
1774
1779
  baseagent: ag.baseagent ?? null,
1775
1780
  projectPath: ag.projectPath ?? null,
1781
+ ...(ag.mode === 'one_shot' ? {
1782
+ mode: ag.mode,
1783
+ initialization: ag.initialization,
1784
+ createProgress: ag.createProgress,
1785
+ ownership: ag.ownership,
1786
+ } : {}),
1776
1787
  }];
1777
1788
  }
1778
1789
  if (cmd === '/capability') {
@@ -1867,9 +1878,10 @@ export async function getSubMenuItems(cmd, channel, channelId, userId, args, ove
1867
1878
  throw { code: 'INVALID_ARGS', message: error.message };
1868
1879
  }
1869
1880
  }
1881
+ const metadataOnly = args?.metadataOnly === true;
1870
1882
  return sessions
1871
1883
  .filter((s) => isTopicSession(s) && (!hasLabel || s.label === label) && (!topicStatus || s.topicStatus === topicStatus))
1872
- .map((s) => this.buildTopicMenuItem(s));
1884
+ .map((s) => this.buildTopicMenuItem(s, metadataOnly));
1873
1885
  }
1874
1886
  if (cmd === '/s' || cmd === '/session' || cmd === '/del') {
1875
1887
  const sessions = await this.sessionManager.listSessions(channel, channelId);
@@ -2085,6 +2097,9 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
2085
2097
  const cmdBase = cmd.trim().split(' ')[0];
2086
2098
  if (!cmdBase)
2087
2099
  return { error: '缺少命令', code: 'MISSING_CMD' };
2100
+ if (cmdBase === '/provider') {
2101
+ return executeProviderMenu({ name: 'provider', cmd, type: 'menu.query', args }, fromControlChannel ? authSubject : undefined, source);
2102
+ }
2088
2103
  const isRequesterRoleQuery = cmdBase === '/role' && args?.view === 'requester';
2089
2104
  if (isRequesterRoleQuery && Object.keys(args).some(key => key !== 'view')) {
2090
2105
  return { error: 'role requester query only accepts args.view', code: 'INVALID_ARGUMENT' };
@@ -2831,6 +2846,7 @@ export async function execMenuQuery(cmd, channel, channelId, userId, args, expli
2831
2846
  }
2832
2847
  catch { }
2833
2848
  data.avatarCreateSupported = true;
2849
+ data.agentCreate = agentCreateCapabilities();
2834
2850
  return { data };
2835
2851
  }
2836
2852
  if (view === 'monitor') {
@@ -2947,6 +2963,9 @@ export async function execMenuUpdate(cmd, value, channel, channelId, userId, ove
2947
2963
  const cmdBase = cmd.trim().split(' ')[0];
2948
2964
  if (!cmdBase)
2949
2965
  return { error: '缺少命令', code: 'MISSING_CMD' };
2966
+ if (cmdBase === '/provider') {
2967
+ return executeProviderMenu({ name: 'provider', cmd, type: 'menu.update', args, value }, fromControlChannel ? authSubject : undefined, source);
2968
+ }
2950
2969
  const isLoopUpdate = cmdBase === '/session' && args?.resource === 'loop';
2951
2970
  const isFullAccessUpdate = cmdBase === '/session' && args?.resource === 'fullaccess';
2952
2971
  if (isLoopUpdate) {
@@ -3479,6 +3498,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
3479
3498
  const cmdBase = cmd.trim().split(' ')[0];
3480
3499
  if (!cmdBase)
3481
3500
  return { error: '缺少命令', code: 'MISSING_CMD' };
3501
+ if (cmdBase === '/provider') {
3502
+ return executeProviderMenu({ name: 'provider', cmd, type: 'menu.action', args, action }, fromControlChannel ? authSubject : undefined, source);
3503
+ }
3482
3504
  if (!action)
3483
3505
  return { error: '缺少 action', code: 'MISSING_VALUE' };
3484
3506
  if (cmdBase === '/file' && action === 'search') {
@@ -3596,6 +3618,16 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
3596
3618
  });
3597
3619
  if (authDenied)
3598
3620
  return authDenied;
3621
+ // Both create and initialize policies apply to the compatibility adapter.
3622
+ if (cmdBase === '/agent' && action === 'create' && args?.initialize === true) {
3623
+ const initializeDenied = await authorizeMenuIntent.call(this, {
3624
+ intent: buildMenuIntent('action', cmdBase, args, 'initialize', undefined, fromControlChannel),
3625
+ identity: authIdentity, subject, session: authSession, explicitChatType,
3626
+ channel, channelId, userId, fromControlChannel, source,
3627
+ });
3628
+ if (initializeDenied)
3629
+ return initializeDenied;
3630
+ }
3599
3631
  // ── /gateway action(进程级,gate 已确保 fromControlChannel) ──
3600
3632
  // test=连通性测试;delete=删除配置;models=模型+价格;set-price=改网关价格。
3601
3633
  if (cmdBase === '/gateway') {
@@ -3660,8 +3692,19 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
3660
3692
  args = { ...(args ?? {}), aid: selfAid };
3661
3693
  }
3662
3694
  const a = { ...(args ?? {}) };
3663
- if (action === 'create') {
3664
- a.project = resolveProjectPath(a.project, a.aid ?? '', loadDefaults());
3695
+ if (action === 'create' && a.resume !== true && a.cancel !== true) {
3696
+ if (a.project !== undefined && typeof a.project !== 'string')
3697
+ return { error: 'project 必须是字符串', code: 'INVALID_ARGS' };
3698
+ let previousProject;
3699
+ if (a.initialize === true && !a.project?.trim() && typeof a.aid === 'string' && isValidAid(a.aid)) {
3700
+ try {
3701
+ previousProject = readInitialization(a.aid)?.plan.project;
3702
+ }
3703
+ catch {
3704
+ return { error: '初始化状态无效', code: 'INITIALIZE_STATE_INVALID' };
3705
+ }
3706
+ }
3707
+ a.project = previousProject ?? resolveProjectPath(a.project, a.aid ?? '', loadDefaults());
3665
3708
  }
3666
3709
  else if (action === 'initialize' && a.resume !== true) {
3667
3710
  const suppliedPlan = a.plan && typeof a.plan === 'object' && !Array.isArray(a.plan) ? a.plan : undefined;
@@ -3790,6 +3833,9 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
3790
3833
  const triggerScheduler = this.getTriggerSchedulerForChannel?.(channel);
3791
3834
  if (!triggerScheduler)
3792
3835
  return { error: '触发器功能未启用', code: 'NOT_SUPPORTED' };
3836
+ if (action === 'show') {
3837
+ return { error: 'Trigger details use menu.query with args.view="detail"', code: 'NOT_SUPPORTED' };
3838
+ }
3793
3839
  if (action === 'create' || action === 'set') {
3794
3840
  // args 结构化 → 直接组装 ParsedTriggerSet(绕过 parseTriggerSet 文本解析,无注入风险)
3795
3841
  if (!args?.scheduleType || (args.scheduleType !== 'once' && !args?.scheduleValue) || !args?.prompt) {
@@ -4677,7 +4723,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4677
4723
  const executionIntent = parsedCommands[0]?.intent;
4678
4724
  const ownershipOperation = executionIntent?.operation;
4679
4725
  let rawExecution;
4680
- if (ownershipOperation === 'ec.aid.bind' || ownershipOperation === 'ec.aid.bind.status') {
4726
+ if (ownershipOperation === 'ec.aid.bind' || ownershipOperation === 'ec.aid.transfer' || ownershipOperation === 'ec.aid.bind.status') {
4681
4727
  try {
4682
4728
  rawExecution = { data: { ok: true, state: await executeOwnershipCommand(parseOwnershipCommand(argv), cliSelfAid) } };
4683
4729
  }
@@ -4685,7 +4731,7 @@ export async function execMenuAction(cmd, action, args, channel, channelId, user
4685
4731
  const failure = ownershipFailure(error);
4686
4732
  const code = ['INVALID_ARGUMENT', 'INVALID_AID', 'INVALID_OWNER', 'INVALID_OPERATION'].includes(failure.code) ? 'INVALID_ARGUMENT'
4687
4733
  : ['SUBJECT_REQUIRED', 'SUBJECT_UNAVAILABLE', 'REQUEST_NOT_FOUND', 'not_found'].includes(failure.code) ? 'NOT_FOUND'
4688
- : ['OWNER_ALREADY_BOUND', 'BIND_CONFLICT', 'BIND_UNCERTAIN', 'CONSENSUS_REQUIRED', 'CLIENT_REPLACED', 'conflict', 'owner_locked'].includes(failure.code)
4734
+ : ['OWNER_ALREADY_BOUND', 'BIND_CONFLICT', 'TRANSFER_CONFLICT', 'BIND_UNCERTAIN', 'CONSENSUS_REQUIRED', 'CLIENT_REPLACED', 'conflict', 'owner_locked'].includes(failure.code)
4689
4735
  ? 'CONFLICT' : 'INTERNAL_ERROR';
4690
4736
  rawExecution = { error: failure.error, code, data: failure };
4691
4737
  }
@@ -4927,7 +4973,7 @@ function menuCommandToken(cmd) {
4927
4973
  }
4928
4974
  function isProcessLevelMenu(name, cmd) {
4929
4975
  const cmdToken = menuCommandToken(cmd);
4930
- return name === 'system' || name === 'agent' || name === 'gateway' || name === 'config' || name === 'baseagent-models' || name === 'baseagents'
4976
+ return name === 'provider' || cmdToken === '/provider' || name === 'system' || name === 'agent' || name === 'gateway' || name === 'config' || name === 'baseagent-models' || name === 'baseagents'
4931
4977
  || cmdToken === '/system' || cmdToken === '/agent' || cmdToken === '/gateway' || cmdToken === '/config' || cmdToken === '/baseagent-models' || cmdToken === '/baseagents';
4932
4978
  }
4933
4979
  function isProcessContextMenu(payload) {
@@ -5010,6 +5056,7 @@ async function execMenuForSystemControl(payload, context) {
5010
5056
  }
5011
5057
  : undefined,
5012
5058
  });
5059
+ trustedSubject.menuEncrypted = context.encrypted;
5013
5060
  const trustedIdentity = trustedSubject.identity;
5014
5061
  trustedSubject.agentFullAccessManagement = context.source === 'control' && context.authMethod === 'daemon-owner';
5015
5062
  const cmd = name ? (menuCommandForName(name) ?? payload.cmd) : payload.cmd;
@@ -5148,7 +5195,6 @@ async function execMenuForSystemControl(payload, context) {
5148
5195
  }
5149
5196
  /** ECWeb 专用入口:只信任 IPC 信封中的服务端认证上下文,不信任 Menu payload 自报身份。 */
5150
5197
  export async function execMenuForEcweb(payload, trusted) {
5151
- await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
5152
5198
  const id = payload?.id ?? '';
5153
5199
  const name = payload?.name;
5154
5200
  const validationError = validateMenuRequest(payload ?? {});
@@ -5192,12 +5238,12 @@ export async function execMenuForEcweb(payload, trusted) {
5192
5238
  * process authorization path. The authenticated envelope peerId remains the
5193
5239
  * requester; token mode maps to a configured owner as its management actor. */
5194
5240
  export async function execMenuForControl(payload, peerId, auth = {}) {
5195
- await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
5196
5241
  const id = payload?.id ?? '';
5197
5242
  const name = payload?.name;
5198
5243
  const validationError = validateMenuRequest(payload ?? {});
5199
5244
  if (validationError)
5200
5245
  return menuFailure({ id, ...(name ? { name } : {}) }, validationError);
5246
+ await refreshOwnershipForAuthorization(undefined, { maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS, allowTransient: true });
5201
5247
  const owners = getDaemonOwners();
5202
5248
  const compatCmd = menuCommandToken(payload?.cmd);
5203
5249
  const isRoleRequest = name === 'role' || compatCmd === '/role';
@@ -6,6 +6,7 @@ import { compareStableSemver, parseStableSemver } from '../../utils/stable-semve
6
6
  import { logger } from '../../utils/logger.js';
7
7
  import { validateIdleSeconds } from '../session/session-idle-monitor.js';
8
8
  import { parseFileSearchArgs } from './file-search.js';
9
+ import { validateProviderMenuRequest } from '../../config/provider-menu-request.js';
9
10
  export const MENU_REQUEST_TYPES = new Set([
10
11
  'menu.token.request',
11
12
  'menu.list',
@@ -143,6 +144,7 @@ export const MENU_NAME_COMMANDS = Object.freeze({
143
144
  agent: '/agent',
144
145
  aid: '/aid',
145
146
  trigger: '/trigger',
147
+ provider: '/provider',
146
148
  file: '/file',
147
149
  'agent-data-root': '/agent-data-root',
148
150
  'relation-data-root': '/relation-data-root',
@@ -334,6 +336,9 @@ export function validateMenuRequest(request) {
334
336
  if (request.args !== undefined && (!request.args || typeof request.args !== 'object' || Array.isArray(request.args))) {
335
337
  return { code: 'INVALID_ARGUMENT', message: 'Menu request args must be an object' };
336
338
  }
339
+ if (request.name === 'provider' || firstCommandToken(request.cmd) === '/provider') {
340
+ return validateProviderMenuRequest(request);
341
+ }
337
342
  if (request.name === 'task' || request.cmd === '/task') {
338
343
  if (type !== 'menu.query')
339
344
  return { code: 'NOT_SUPPORTED', message: 'task only supports menu.query' };
@@ -521,7 +526,8 @@ const STABLE_CODES = new Set([
521
526
  'INITIALIZE_PLAN_CONFLICT', 'INITIALIZE_OWNER_MISMATCH', 'INITIALIZE_CANCELLED',
522
527
  'INITIALIZE_STATE_INVALID', 'INITIALIZE_TARGET_CHANGED', 'INITIALIZE_TARGET_EXISTS',
523
528
  'INITIALIZE_AGENTMD_VERIFY_FAILED', 'INITIALIZE_OWNER_CONFLICT', 'INITIALIZE_AVATAR_FAILED',
524
- 'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE',
529
+ 'INITIALIZE_FAILED', 'MODEL_UNAVAILABLE', 'MODEL_NOT_CONFIGURED', 'BASEAGENT_REQUIRED',
530
+ 'CONTROL_AID_RESERVED', 'CONTROL_AID_CONFLICT', 'HOST_AID_RESERVED', 'AGENT_IDENTITY_UNVERIFIED',
525
531
  ]);
526
532
  export function normalizeMenuError(error) {
527
533
  const source = error && typeof error === 'object' ? error : {};
@@ -538,6 +544,8 @@ export function normalizeMenuError(error) {
538
544
  code = 'INVALID_ARGUMENT';
539
545
  else if (rawCode === 'UNKNOWN_NAME' || rawCode === 'NOT_APPLICABLE' || rawCode === 'UNSUPPORTED_FIELD')
540
546
  code = 'NOT_SUPPORTED';
547
+ else if (rawCode === 'UNKNOWN_FIELD' || rawCode === 'INVALID_CONFIG_VALUE' || rawCode === 'INVALID_CONFIG_COMMAND')
548
+ code = 'INVALID_ARGUMENT';
541
549
  else if (rawCode === 'NO_PERMISSION' || rawCode === 'SCOPE_MISMATCH')
542
550
  code = 'PERMISSION_DENIED';
543
551
  else if (rawCode === 'DANGEROUS_NOT_GRANTED')
@@ -660,6 +668,8 @@ const SENSITIVE_LOG_KEY = /(?:^|[_-])(?:api[_-]?key|access[_-]?token|refresh[_-]
660
668
  const SENSITIVE_LOG_ARG = /(?:api[_-]?key|access[_-]?token|refresh[_-]?token|menu[_-]?token|token|secret|password|passwd|credential|authorization|cookie|private[_-]?key|seed)/i;
661
669
  function isSensitiveLogKey(key) {
662
670
  const normalized = key.replace(/([a-z0-9])([A-Z])/g, '$1_$2');
671
+ if (/^(?:provider|providers|provider_config)$/i.test(normalized))
672
+ return true;
663
673
  return SENSITIVE_LOG_KEY.test(normalized) || /^(?:next[_-]?)?cursor$|^(?:download[_-]?)?url$|^ticket$/i.test(normalized);
664
674
  }
665
675
  function sanitizeInlineLogSecrets(value) {
@@ -765,6 +775,10 @@ function menuFlowBaseRecord(request, context) {
765
775
  };
766
776
  }
767
777
  function menuRequestBusinessFields(request) {
778
+ if (request.name === 'provider' || firstCommandToken(request.cmd) === '/provider') {
779
+ return { type: request.type, name: 'provider', action: ['create', 'import', 'delete'].includes(String(request.action)) ? request.action : undefined,
780
+ args: '[REDACTED_PROVIDER_INPUT]', ...(request.value === undefined ? {} : { value: '[REDACTED_PROVIDER_INPUT]' }) };
781
+ }
768
782
  return sanitizeMenuLogValue({
769
783
  type: request.type,
770
784
  name: request.name,