evolcore 0.0.41-test.0 → 0.0.41-test.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/agents/baseagent-availability.js +1 -1
  3. package/dist/agents/baseagent.js +88 -49
  4. package/dist/agents/claude-runner.js +177 -92
  5. package/dist/agents/codex-runner.js +146 -71
  6. package/dist/agents/ecagent-runner.js +1 -1
  7. package/dist/agents/gemini-runner.js +1 -1
  8. package/dist/aun/aid/agentmd.js +98 -11
  9. package/dist/aun/aid/client.js +1 -1
  10. package/dist/aun/aid/control-aid.js +26 -2
  11. package/dist/aun/aid/identity.js +91 -0
  12. package/dist/aun/aid/index.js +1 -1
  13. package/dist/aun/aid/managed-operation.js +1 -1
  14. package/dist/aun/aid/ownership-operation.js +23 -22
  15. package/dist/aun/group/fs-download.js +39 -0
  16. package/dist/aun/group/identity.js +36 -21
  17. package/dist/aun/group/operations.js +5 -0
  18. package/dist/aun/menu/client.js +27 -0
  19. package/dist/aun/msg/managed-operation.js +68 -7
  20. package/dist/aun/msg/p2p.js +8 -8
  21. package/dist/aun/service-proxy.js +53 -12
  22. package/dist/channels/aun.js +633 -32
  23. package/dist/channels/daemon.js +15 -1
  24. package/dist/cli/agent-command.js +5 -2
  25. package/dist/cli/agent-create.js +991 -233
  26. package/dist/cli/agent.js +49 -10
  27. package/dist/cli/aid-bind-command.js +48 -19
  28. package/dist/cli/aun-commands.js +48 -36
  29. package/dist/cli/daemon-commands.js +679 -697
  30. package/dist/cli/fs-command.js +64 -2
  31. package/dist/cli/index.js +72 -5
  32. package/dist/cli/init-channel.js +1 -1
  33. package/dist/cli/init.js +75 -1
  34. package/dist/cli/managed-command-guard.js +17 -1
  35. package/dist/cli/model.js +40 -40
  36. package/dist/cli/provider-command.js +57 -0
  37. package/dist/cli/proxy-command.js +92 -0
  38. package/dist/cli/restart-monitor.js +4 -2
  39. package/dist/cli/role.js +85 -0
  40. package/dist/cli/stats.js +10 -3
  41. package/dist/cli/task-context.js +19 -0
  42. package/dist/config/access-policy.js +7 -2
  43. package/dist/config/boot-log.js +39 -1
  44. package/dist/config/config-field-policy.js +17 -39
  45. package/dist/config/config-manager.js +183 -44
  46. package/dist/config/config-operation-service.js +5 -19
  47. package/dist/config/contact-book-store.js +47 -21
  48. package/dist/config/contact-book.js +18 -12
  49. package/dist/config/contact-operation-service.js +3 -4
  50. package/dist/config/contact-request-service.js +11 -0
  51. package/dist/config/daemon-services.js +11 -0
  52. package/dist/config/gateway-config.js +88 -594
  53. package/dist/config/owner-config.js +2 -2
  54. package/dist/config/peer-role-resolver.js +15 -12
  55. package/dist/config/provider-ipc-service.js +132 -0
  56. package/dist/config/provider-menu-request.js +58 -0
  57. package/dist/config/providers-config.js +12 -7
  58. package/dist/config/providers-import.js +3 -21
  59. package/dist/config/providers-management.js +78 -5
  60. package/dist/config/resolved-config-op.js +11 -1
  61. package/dist/config/role-command-service.js +166 -0
  62. package/dist/config/role-request-service.js +193 -0
  63. package/dist/config/schema-migration.js +1000 -25
  64. package/dist/config-store.js +89 -4
  65. package/dist/contracts/ecweb-instance.js +41 -0
  66. package/dist/contracts/ecweb-service-protocol.js +4 -1
  67. package/dist/core/agent-application-service.js +60 -11
  68. package/dist/core/agent-create-status.js +203 -0
  69. package/dist/core/agent-creation-claim.js +177 -0
  70. package/dist/core/agent-ipc-registration.js +39 -18
  71. package/dist/core/agent-runtime.js +194 -24
  72. package/dist/core/auth/agent-delegation.js +6 -3
  73. package/dist/core/auth/auth-gateway.js +67 -2
  74. package/dist/core/auth/authorization-audit.js +58 -11
  75. package/dist/core/auth/delegation-authorization.js +5 -2
  76. package/dist/core/auth/operation-authorizer.js +43 -6
  77. package/dist/core/auth/operation-catalog.js +45 -7
  78. package/dist/core/channel-loader.js +2 -0
  79. package/dist/core/command/agent-control.js +260 -21
  80. package/dist/core/command/agent-storage-menu.js +5 -3
  81. package/dist/core/command/cli-intent-parser.js +8 -3
  82. package/dist/core/command/command-handler.js +112 -154
  83. package/dist/core/command/connect-menu.js +11 -3
  84. package/dist/core/command/data-root-resolver.js +5 -4
  85. package/dist/core/command/memory-slash.js +16 -8
  86. package/dist/core/command/menu-catalog.js +10 -6
  87. package/dist/core/command/menu-handler.js +106 -73
  88. package/dist/core/command/menu-protocol.js +15 -1
  89. package/dist/core/command/provider-menu.js +46 -0
  90. package/dist/core/command/role-menu.js +147 -30
  91. package/dist/core/command/slash-handler.js +125 -255
  92. package/dist/core/daemon-control.js +26 -27
  93. package/dist/core/event-catalog.js +10 -0
  94. package/dist/core/evolagent-registry.js +7 -5
  95. package/dist/core/evolagent.js +10 -8
  96. package/dist/core/file-integrity/store.js +11 -0
  97. package/dist/core/handoff/ipc-registration.js +3 -0
  98. package/dist/core/inference/text-inference.js +31 -40
  99. package/dist/core/initialization/service.js +491 -0
  100. package/dist/core/ipc-registration.js +40 -24
  101. package/dist/core/memory/consolidation-context.js +51 -5
  102. package/dist/core/memory/consolidation-ops-records.js +96 -1
  103. package/dist/core/memory/consolidation-trigger.js +208 -191
  104. package/dist/core/memory/consolidation.js +333 -35
  105. package/dist/core/memory/index-manager.js +27 -5
  106. package/dist/core/memory/memory-admin.js +45 -5
  107. package/dist/core/memory/memory-writer.js +163 -18
  108. package/dist/core/memory/relation-idle-monitor.js +119 -58
  109. package/dist/core/memory/relation-sweep.js +55 -45
  110. package/dist/core/message/aun-ipc-sender.js +81 -69
  111. package/dist/core/message/im-renderer.js +25 -4
  112. package/dist/core/message/message-admission.js +89 -4
  113. package/dist/core/message/message-bridge.js +66 -21
  114. package/dist/core/message/response-engine.js +108 -35
  115. package/dist/core/model/catalog-service.js +5 -3
  116. package/dist/core/model/config-scope.js +29 -71
  117. package/dist/core/model/field-scope.js +1 -1
  118. package/dist/core/model/model-catalog.js +30 -41
  119. package/dist/core/model/model-diagnostics.js +4 -3
  120. package/dist/core/model/model-fallback.js +10 -7
  121. package/dist/core/model/model-permission.js +3 -2
  122. package/dist/core/ownership/owner-resolver.js +772 -158
  123. package/dist/core/permission/approval-gateway.js +103 -403
  124. package/dist/core/permission/ec-command-parser.js +62 -6
  125. package/dist/core/permission/index.js +1 -0
  126. package/dist/core/permission/permission-result.js +78 -0
  127. package/dist/core/permission/sandbox-runtime.js +18 -1
  128. package/dist/core/permission/tool-policy.js +21 -46
  129. package/dist/core/relation/peer-identity.js +64 -1
  130. package/dist/core/role/runtime-policy.js +72 -13
  131. package/dist/core/session/session-capsule.js +1 -1
  132. package/dist/core/session/session-idle-monitor.js +1 -1
  133. package/dist/core/session/session-manager.js +20 -0
  134. package/dist/core/session/session-renew.js +3 -3
  135. package/dist/core/skill/index-generator.js +15 -5
  136. package/dist/core/system-session/memory.js +43 -8
  137. package/dist/core/thread/thread-service.js +19 -6
  138. package/dist/directory/owner-directory-admission.js +95 -0
  139. package/dist/directory/owner-directory-authorization.js +309 -0
  140. package/dist/directory/owner-directory-cache.js +635 -0
  141. package/dist/eck/kit-renderer.js +2 -2
  142. package/dist/ecweb/basic-settings-service.js +33 -40
  143. package/dist/ecweb/init-menu.js +32 -0
  144. package/dist/ecweb/message-context-service.js +110 -0
  145. package/dist/index.js +93 -19
  146. package/dist/ipc.js +247 -29
  147. package/dist/paths.js +7 -0
  148. package/dist/proxy/command.js +122 -0
  149. package/dist/proxy/ipc-service.js +68 -0
  150. package/dist/proxy/manager.js +484 -0
  151. package/dist/proxy/service-supervisor.js +603 -0
  152. package/dist/response-system/engines/v1/proactive-flow.js +16 -6
  153. package/dist/trigger/authorization.js +27 -17
  154. package/dist/trigger/feedback.js +2 -3
  155. package/dist/trigger/ipc-service.js +105 -78
  156. package/dist/trigger/local-files.js +2 -1
  157. package/dist/trigger/manager.js +5 -3
  158. package/dist/trigger/scheduler.js +88 -6
  159. package/dist/utils/atomic-write.js +28 -0
  160. package/dist/utils/cross-platform.js +14 -0
  161. package/dist/utils/ecweb-supervisor.js +258 -83
  162. package/dist/utils/error-utils.js +26 -2
  163. package/dist/utils/logger.js +92 -6
  164. package/dist/utils/package-version-info.js +4 -2
  165. package/dist/utils/welcome.js +1 -1
  166. package/kits/docs/INDEX.md +1 -0
  167. package/kits/docs/aun/SDK.md +4 -1
  168. package/kits/docs/channels/aun.md +9 -0
  169. package/kits/docs/evolcore/INDEX.md +1 -0
  170. package/kits/docs/evolcore/agent.md +8 -1
  171. package/kits/docs/evolcore/aid.md +67 -17
  172. package/kits/docs/evolcore/config.md +28 -7
  173. package/kits/docs/evolcore/contact.md +3 -0
  174. package/kits/docs/evolcore/fs.md +11 -0
  175. package/kits/docs/evolcore/group.md +1 -1
  176. package/kits/docs/evolcore/memory-architecture.md +2 -2
  177. package/kits/docs/evolcore/memory-consolidation.md +32 -8
  178. package/kits/docs/evolcore/memory.md +1 -1
  179. package/kits/docs/evolcore/menu-protocol.md +4 -0
  180. package/kits/docs/evolcore/model.md +23 -20
  181. package/kits/docs/evolcore/msg.md +4 -7
  182. package/kits/docs/evolcore/provider.md +50 -0
  183. package/kits/docs/identity/AID_PROFILE_SPEC.md +52 -17
  184. package/kits/migrations/migrate-contact-book-v2.mjs +30 -11
  185. package/kits/rules/01-overview.md +3 -0
  186. package/kits/rules/04-relation.md +1 -1
  187. package/kits/schemas/_meta.json +37 -4
  188. package/kits/schemas/agent-config.schema.13.json +8 -3
  189. package/kits/schemas/agent-config.schema.16.json +891 -0
  190. package/kits/schemas/daemon.schema.9.json +366 -0
  191. package/kits/schemas/defaults.schema.5.json +406 -127
  192. package/kits/schemas/relation-config.schema.11.json +277 -0
  193. package/kits/schemas/role-config.schema.1.json +7 -7
  194. package/kits/skills/.switches.json +4 -0
  195. package/kits/skills/ec-agent-create/SKILL.md +3 -0
  196. package/kits/skills/ec-identity/SKILL.md +2 -2
  197. package/kits/skills/ec-service-proxy/SKILL.md +118 -0
  198. package/kits/skills/ec-skill/scripts/skill.mjs +6 -0
  199. package/kits/skills/personal-assistant/SKILL.md +176 -0
  200. package/kits/skills/personal-assistant/references/01-workspace-spec.md +333 -0
  201. package/kits/skills/personal-assistant/references/02-bootstrap.md +205 -0
  202. package/kits/skills/personal-assistant/references/03-data-flow-and-gaps.md +177 -0
  203. package/kits/skills/personal-assistant/references/04-frontend-contract.md +439 -0
  204. package/kits/skills/personal-assistant/references/05-directory-reference.md +292 -0
  205. package/kits/skills/personal-assistant/references/06-render-config.md +350 -0
  206. package/kits/skills/personal-assistant/schema/workspace.schema.json +85 -0
  207. package/kits/skills/personal-assistant/schema/workspace.v1.json +66 -0
  208. package/kits/skills/personal-assistant/scripts/archive.mjs +154 -0
  209. package/kits/skills/personal-assistant/scripts/check.mjs +114 -0
  210. package/kits/skills/personal-assistant/scripts/index-rebuild.mjs +252 -0
  211. package/kits/skills/personal-assistant/scripts/ingest.mjs +344 -0
  212. package/kits/skills/personal-assistant/scripts/init.mjs +270 -0
  213. package/kits/skills/personal-assistant/scripts/lib/apply.mjs +92 -0
  214. package/kits/skills/personal-assistant/scripts/lib/schema.mjs +96 -0
  215. package/kits/skills/personal-assistant/scripts/lib/time.mjs +28 -0
  216. package/kits/skills/personal-assistant/scripts/migrate.mjs +172 -0
  217. package/kits/skills/personal-assistant/scripts/search.mjs +172 -0
  218. package/kits/skills/personal-assistant/scripts/verify.mjs +196 -0
  219. package/kits/skills/personal-assistant/templates/INDEX.md.tpl +24 -0
  220. package/kits/skills/personal-assistant/templates/README.md.tpl +108 -0
  221. package/kits/skills/personal-assistant/triggers/ingest-daily.json +23 -0
  222. package/kits/skills/personal-assistant/triggers/memory-consolidate.json +23 -0
  223. package/kits/skills/personal-assistant/triggers/report-daily.json +23 -0
  224. package/kits/skills/personal-assistant/triggers/report-weekly.json +23 -0
  225. package/kits/skills/thread-ops/SKILL.md +5 -0
  226. package/kits/templates/memory-consolidation/forget.md +19 -6
  227. package/kits/templates/memory-consolidation/notes.md +1 -1
  228. package/kits/templates/memory-consolidation/profile.md +2 -2
  229. package/kits/templates/memory-consolidation/promote.md +20 -3
  230. package/kits/templates/roles/member.json +8 -1
  231. package/kits/templates/system-fragments/baseagent.md +2 -2
  232. package/kits/templates/system-fragments/memory.md +4 -4
  233. package/kits/templates/system-fragments/venue.md +1 -1
  234. package/package.json +7 -3
  235. package/dist/core/message/create-status.js +0 -96
@@ -18,8 +18,8 @@ import { resolveContactView, resolvePeerDisplayLabel, resolvePrincipal } from '.
18
18
  import { findContactRequestNote, expirePendingContactRequests, reviewContactRequest, submitContactRequest, contactRequestSubmissionProtocolResult, queryOwnContactRequestStatus, } from '../../config/contact-request-service.js';
19
19
  import { isValidAid } from '../../aun/aid/validation.js';
20
20
  import { PeerIdentityCache, formatPeerKey } from '../relation/peer-identity.js';
21
- import { ownerResolver } from '../ownership/owner-resolver.js';
22
- import { isMainSession, isTopicSession, sessionLocalTopicId } from '../thread/topic-id.js';
21
+ import { ownerResolver, OWNERSHIP_CACHE_MAX_AGE_MS } from '../ownership/owner-resolver.js';
22
+ import { isTopicSession, sessionLocalTopicId } from '../thread/topic-id.js';
23
23
  import { resolveEffective } from '../../config/config-manager.js';
24
24
  import { createDecisionInferenceProvider } from '../inference/text-inference.js';
25
25
  import { AutoMentionGate } from './auto-mention-gate.js';
@@ -39,10 +39,11 @@ import { recordCausationSpan } from '../causation/audit.js';
39
39
  import { renderActionAsText } from '../interaction-router.js';
40
40
  import { planApprovalRoute } from '../permission/approval-gateway.js';
41
41
  import { guardGroupSlashCommand, parseFullAccessCommand } from '../command/slash-gate.js';
42
- import { createAgentPolicyAuthorization, createSessionFullAccessAuthorization, hasSessionFullAccessOverride } from '../role/runtime-policy.js';
42
+ import { createAgentPolicyAuthorization, createSessionFullAccessAuthorization } from '../role/runtime-policy.js';
43
43
  import { auditFullAccessEvent } from '../auth/authorization-audit.js';
44
44
  import { DIAGNOSTIC_AGENT_AID, DiagnosticSessionRouter, parseDiagnosticEvent, isDiagnosticSessionActive } from '../command/diag-service.js';
45
- import { consumeAdmissionReplyBudget, clearAdmissionReplyBudgets, evaluateInboundAdmissionPreflight, evaluateOrdinaryInboundAdmission, } from './message-admission.js';
45
+ import { consumeAdmissionReplyBudget, clearAdmissionReplyBudgets, evaluateInboundAdmissionPreflight, evaluateOrdinaryInboundAdmission, evaluateOwnerDirectoryInboundAdmission, } from './message-admission.js';
46
+ import { prepareOwnerDirectoryAdmission } from '../../directory/owner-directory-admission.js';
46
47
  const CONTACT_REJECTION_NOTICE = '[rejection] Not accepting messages from you.';
47
48
  const REJECTABLE_PEER_TYPES = new Set(['ai', 'bot', 'agent', 'service']);
48
49
  const REJECTION_MAX = 3;
@@ -118,16 +119,16 @@ export class MessageBridge {
118
119
  const config = resolveEffective({
119
120
  self: item.selfAid,
120
121
  peerKey: formatPeerKey('aun', item.groupId),
121
- }, { cache: true, expand: true });
122
- const model = config.Services?.decision ? config.Services.decision.model?.trim() : config.decision_model?.model?.trim();
123
- const provider = createDecisionInferenceProvider(config.decision_model, config.Services);
122
+ }, { cache: true });
123
+ const model = config.Services?.decision?.model?.trim();
124
+ const provider = createDecisionInferenceProvider(config.Services);
124
125
  return model && provider ? { model, provider } : undefined;
125
126
  },
126
127
  resolveResources: async (item) => {
127
128
  const config = resolveEffective({
128
129
  self: item.selfAid,
129
130
  peerKey: formatPeerKey('aun', item.groupId),
130
- }, { cache: true, expand: true });
131
+ }, { cache: true });
131
132
  const resources = {};
132
133
  if (config.groupRules?.mode !== 'ignore') {
133
134
  try {
@@ -165,7 +166,7 @@ export class MessageBridge {
165
166
  resolveQuietWindowMs: item => resolveEffective({
166
167
  self: item.selfAid,
167
168
  peerKey: formatPeerKey('aun', item.groupId),
168
- }, { cache: true, expand: true }).autoMentionQuietWindowMs,
169
+ }, { cache: true }).autoMentionQuietWindowMs,
169
170
  resolveMessageState: item => {
170
171
  if (!item.messageId)
171
172
  return 'missing';
@@ -276,7 +277,7 @@ export class MessageBridge {
276
277
  if (args.length === 0) {
277
278
  const configuredOwner = ownerResolver.configuredOwnerList(selfAid)[0];
278
279
  if (configuredOwner !== actorId) {
279
- return { handled: true, status: 'not-first-owner', reply: '仅 Agent 配置中的首个 Owner 可在 AUN 私聊发送 /bind 发起 ownership 绑定。' };
280
+ return { handled: true, status: 'not-first-owner', reply: '仅兼容绑定目标中的首个 AID 可在 AUN 私聊发送 /bind 发起 ownership 绑定。' };
280
281
  }
281
282
  try {
282
283
  const current = await ownerResolver.refresh(selfAid, { force: true });
@@ -434,7 +435,7 @@ export class MessageBridge {
434
435
  }
435
436
  }
436
437
  aunSelfServiceBindUsage() {
437
- return `用法:/bind(首个配置 Owner 发起 ownership 绑定);/bind <渠道> [实例名](联系人绑定)。支持渠道:${SELF_SERVICE_CONTACT_BIND_TYPES.join('、')}。`;
438
+ return `用法:/bind(首个兼容绑定目标发起 ownership 绑定);/bind <渠道> [实例名](联系人绑定)。支持渠道:${SELF_SERVICE_CONTACT_BIND_TYPES.join('、')}。`;
438
439
  }
439
440
  aunSelfServiceBindInstances(channelType, instances) {
440
441
  const names = instances.map(instance => String(instance.name || '').trim()).filter(Boolean);
@@ -532,6 +533,7 @@ export class MessageBridge {
532
533
  applicantAid: context.primaryId,
533
534
  note: requestMatch[1],
534
535
  sourceChannelKey: context.channelKey,
536
+ routeKind: 'private',
535
537
  });
536
538
  if ((submission.code === 'submitted' || submission.code === 'resubmitted') && submission.requestId) {
537
539
  void this.deliverContactReviewCard(context.selfAid, context.primaryId, submission, owningAgent)
@@ -596,6 +598,7 @@ export class MessageBridge {
596
598
  applicantAid: context.primaryId,
597
599
  note: typeof protocolPayload?.note === 'string' ? protocolPayload.note : undefined,
598
600
  sourceChannelKey: context.channelKey,
601
+ routeKind: 'private',
599
602
  });
600
603
  result = contactRequestSubmissionProtocolResult(submission);
601
604
  if ((submission.code === 'submitted' || submission.code === 'resubmitted') && submission.requestId) {
@@ -945,6 +948,17 @@ export class MessageBridge {
945
948
  && resolvedChannelType === 'aun'
946
949
  && !!selfAid
947
950
  && actorId === selfAid;
951
+ if (selfAid && !trustedHandoffEcho) {
952
+ // Admission reads Owner synchronously; wait here before classifying
953
+ // a sender against an expired or invalidated ownership cache.
954
+ const ownership = ownerResolver.snapshot(selfAid);
955
+ if (ownership.connected || ownership.relation) {
956
+ await ownerResolver.refresh(selfAid, {
957
+ maxAgeMs: OWNERSHIP_CACHE_MAX_AGE_MS,
958
+ allowTransient: true,
959
+ });
960
+ }
961
+ }
948
962
  const admissionPreflight = evaluateInboundAdmissionPreflight({
949
963
  selfAid,
950
964
  channelKey,
@@ -953,6 +967,16 @@ export class MessageBridge {
953
967
  actorId,
954
968
  trustedHandoffEcho,
955
969
  });
970
+ if (admissionPreflight.allow && !trustedHandoffEcho && !admissionPreflight.context.isOwner) {
971
+ if (selfAid && admissionPreflight.context.primaryId) {
972
+ await prepareOwnerDirectoryAdmission(selfAid, admissionPreflight.context.primaryId);
973
+ }
974
+ const directoryDecision = evaluateOwnerDirectoryInboundAdmission(admissionPreflight.context);
975
+ if (directoryDecision && !directoryDecision.allow) {
976
+ logger.info(`[MessageBridge] Owner directory admission denied before control routing: self=${selfAid} actor=${actorId ?? '<none>'} reason=${directoryDecision.reason}`);
977
+ return;
978
+ }
979
+ }
956
980
  if (!trustedHandoffEcho && await this.handleContactRequestProtocol({
957
981
  context: admissionPreflight.context,
958
982
  msg,
@@ -963,6 +987,27 @@ export class MessageBridge {
963
987
  })) {
964
988
  return;
965
989
  }
990
+ const ownershipFailure = selfAid ? ownerResolver.snapshot(selfAid) : undefined;
991
+ if (!trustedHandoffEcho && !admissionPreflight.context.isOwner
992
+ && (admissionPreflight.allow || admissionPreflight.reason === 'restricted_mode_without_owner')
993
+ && admissionPreflight.context.primaryId
994
+ && !/^\s*\/(?:bind|request)(?:\s|$)/i.test(content)
995
+ && ownershipFailure?.refreshFailure
996
+ && admissionPreflight.context.primaryId === ownershipFailure.relation?.ownerAid) {
997
+ const errorCode = ownershipFailure.refreshFailure.code;
998
+ const notice = `Owner 身份核验未完成(${errorCode}),本次消息未执行。`;
999
+ if (chatType === 'private') {
1000
+ if (menuControl.isMenu && hasValidMenuId(menuControl)) {
1001
+ await this.sendAdmissionMenuResponse(admissionPreflight.context, adapter, channelName, msg, menuFailure({ id: menuControl.id }, { code: 'OWNER_UNAVAILABLE', message: notice }));
1002
+ }
1003
+ else if (!menuControl.isMenu) {
1004
+ await this.sendAdmissionControlReply(admissionPreflight.context, msg, sendReply, notice);
1005
+ }
1006
+ }
1007
+ logger.warn(`[MessageBridge] Owner verification failed before admission: self=${selfAid}`
1008
+ + ` actor=${actorId} code=${errorCode} reason=${ownershipFailure.refreshFailure.reason}`);
1009
+ return;
1010
+ }
966
1011
  if (!admissionPreflight.allow) {
967
1012
  const requestCommand = /^\s*\/request(?:\s|$)/i.test(content);
968
1013
  if (admissionPreflight.reason === 'blocked' && admissionPreflight.context.primaryId) {
@@ -1010,8 +1055,11 @@ export class MessageBridge {
1010
1055
  return;
1011
1056
  }
1012
1057
  const admissionDecision = evaluateOrdinaryInboundAdmission(admissionPreflight.context);
1013
- if (!admissionDecision.allow && !isPrivateMenuTokenRequest) {
1014
- if (chatType === 'private') {
1058
+ const directoryDenied = !admissionDecision.allow && (admissionDecision.reason === 'owner_directory_contacts_disabled'
1059
+ || admissionDecision.reason === 'owner_agent_directory_disabled'
1060
+ || admissionDecision.reason === 'owner_directory_unavailable');
1061
+ if (!admissionDecision.allow && (!isPrivateMenuTokenRequest || directoryDenied)) {
1062
+ if (chatType === 'private' && !directoryDenied) {
1015
1063
  if (menuControl.isMenu) {
1016
1064
  if (hasValidMenuId(menuControl)) {
1017
1065
  const header = { id: menuControl.id, ...(menuControl.name?.trim() ? { name: menuControl.name } : {}) };
@@ -1285,7 +1333,7 @@ export class MessageBridge {
1285
1333
  let autoMode = false;
1286
1334
  if (resolvedChannelType === 'aun' && chatType === 'group' && selfAid && msg.source !== 'handoff') {
1287
1335
  try {
1288
- const config = resolveEffective({ self: selfAid, peerKey: formatPeerKey('aun', msg.groupId || msg.channelId) }, { cache: true, expand: true });
1336
+ const config = resolveEffective({ self: selfAid, peerKey: formatPeerKey('aun', msg.groupId || msg.channelId) }, { cache: true });
1289
1337
  autoMode = config.mentionMode === 'auto';
1290
1338
  }
1291
1339
  catch (error) {
@@ -1511,18 +1559,15 @@ export class MessageBridge {
1511
1559
  });
1512
1560
  session = renewResult.session;
1513
1561
  if (!executionPermissionOverride && selfAid && owningAgent?.aid === selfAid) {
1514
- executionPermissionOverride = createSessionFullAccessAuthorization({
1562
+ executionPermissionOverride = createAgentPolicyAuthorization({
1563
+ agentAid: selfAid, actor: roleDetail.actor, chatType,
1564
+ source: msg.source, peerType: msg.peerType,
1565
+ }) ?? createSessionFullAccessAuthorization({
1515
1566
  session,
1516
1567
  actor: roleDetail.actor,
1517
1568
  source: msg.source,
1518
1569
  peerType: msg.peerType,
1519
1570
  });
1520
- if (!executionPermissionOverride && isMainSession(session) && !hasSessionFullAccessOverride(session)) {
1521
- executionPermissionOverride = createAgentPolicyAuthorization({
1522
- agentAid: selfAid, actor: roleDetail.actor, chatType,
1523
- source: msg.source, peerType: msg.peerType,
1524
- });
1525
- }
1526
1571
  }
1527
1572
  if ('renewed' in renewResult && renewResult.renewed) {
1528
1573
  const notice = '已自动切换到新会话';
@@ -21,7 +21,7 @@ import { createDecisionInferenceProvider, createTextInferenceProvider } from '..
21
21
  import { StreamIdleMonitor } from './stream-idle-monitor.js';
22
22
  import { logger } from '../../utils/logger.js';
23
23
  import { isHostChinese } from '../../utils/locale.js';
24
- import { ExecutionTimeoutError, OrphanedTargetSessionError, isExecutionFailure, getErrorMessage, getErrorRawText, getToolResultErrorText, classifyError, normalizeCoreErrorReason, normalizeCoreErrorSubtype, ErrorType, ERROR_PREFIX, isInfraError, isAbortTerminalReason, prefixErrorType, isRetryableError, isContextTooLongText, isPolicyRejectedError } from '../../utils/error-utils.js';
24
+ import { ExecutionTimeoutError, OrphanedTargetSessionError, UnattendedInputRequiredError, isExecutionFailure, getErrorMessage, getErrorRawText, getToolResultErrorText, classifyError, normalizeCoreErrorReason, normalizeCoreErrorSubtype, ErrorType, ERROR_PREFIX, isInfraError, isAbortTerminalReason, prefixErrorType, isRetryableError, isContextTooLongText, isPolicyRejectedError } from '../../utils/error-utils.js';
25
25
  import { readEvolcoreRuntimeFlavor, tagErrorTextWithEvolcoreVersion } from '../../utils/evolcore-version.js';
26
26
  import { describeProactiveSendCommandFailure, isExactEvolcoreSendCommandForSession, isThreadRoutedEvolcoreSendCommand, parseCodexToolCommand, resolveCodexShellCarrierArgv, resolveCodexShellCarrierString, } from '../permission/ec-command-parser.js';
27
27
  import { resolveThreadRouteTarget } from '../thread/thread-route.js';
@@ -653,6 +653,39 @@ function findDiagnosticShellSeparator(value, startOffset, endOffset) {
653
653
  }
654
654
  return -1;
655
655
  }
656
+ function findDiagnosticPatchDocumentEnd(value, startOffset, endOffset) {
657
+ let lineStart = startOffset;
658
+ while (lineStart < endOffset && (value[lineStart] === ' ' || value[lineStart] === '\t'))
659
+ lineStart++;
660
+ const beginEnd = diagnosticLineEnd(value, lineStart);
661
+ if (value.slice(lineStart, beginEnd).replace(/\r$/u, '') !== '*** Begin Patch')
662
+ return undefined;
663
+ let cursor = beginEnd < endOffset ? beginEnd + 1 : endOffset;
664
+ while (cursor < endOffset) {
665
+ const lineEnd = diagnosticLineEnd(value, cursor);
666
+ if (value.slice(cursor, lineEnd).replace(/\r$/u, '') === '*** End Patch')
667
+ return lineEnd;
668
+ if (lineEnd >= endOffset)
669
+ break;
670
+ cursor = lineEnd + 1;
671
+ }
672
+ return undefined;
673
+ }
674
+ function findDiagnosticTrailingCommand(value, startOffset, endOffset) {
675
+ let cursor = startOffset;
676
+ while (cursor < endOffset) {
677
+ const lineEnd = diagnosticLineEnd(value, cursor);
678
+ const line = value.slice(cursor, lineEnd).trim();
679
+ if (line && !line.startsWith('#')) {
680
+ const leadingWhitespace = value.slice(cursor, lineEnd).length - value.slice(cursor, lineEnd).trimStart().length;
681
+ return cursor + leadingWhitespace;
682
+ }
683
+ if (lineEnd >= endOffset)
684
+ break;
685
+ cursor = lineEnd + 1;
686
+ }
687
+ return undefined;
688
+ }
656
689
  function diagnosticLocation(source, startOffset, endOffset = startOffset) {
657
690
  const start = Math.max(0, Math.min(startOffset, source.value.length));
658
691
  const end = Math.max(start, Math.min(endOffset, source.value.length));
@@ -751,9 +784,21 @@ function addApplyPatchCompositionFinding(findings, candidate) {
751
784
  return;
752
785
  const heredocOffset = findUnquotedDiagnosticText(candidate.command, '<<', argumentsOffset);
753
786
  const endOffset = heredocOffset >= 0 ? heredocOffset : candidate.command.length;
754
- const separator = findDiagnosticShellSeparator(candidate.command, argumentsOffset, endOffset);
787
+ let separator = findDiagnosticShellSeparator(candidate.command, argumentsOffset, endOffset);
755
788
  if (separator < 0)
756
789
  return;
790
+ if (candidate.command[separator] === '\n' || candidate.command[separator] === '\r') {
791
+ const newlineLength = candidate.command[separator] === '\r' && candidate.command[separator + 1] === '\n' ? 2 : 1;
792
+ const patchEnd = findDiagnosticPatchDocumentEnd(candidate.command, separator + newlineLength, candidate.command.length);
793
+ if (patchEnd !== undefined) {
794
+ const afterPatch = patchEnd + (candidate.command[patchEnd] === '\r' && candidate.command[patchEnd + 1] === '\n'
795
+ ? 2 : candidate.command[patchEnd] === '\n' ? 1 : 0);
796
+ const trailingCommand = findDiagnosticTrailingCommand(candidate.command, afterPatch, candidate.command.length);
797
+ if (trailingCommand === undefined)
798
+ return;
799
+ separator = trailingCommand;
800
+ }
801
+ }
757
802
  findings.push(diagnosticFinding('apply-patch-composed-command', 'apply_patch 与其它 Shell 命令组合提交', '一次工具调用只提交完整的 apply_patch;测试、检查或其它命令另行调用。', '高', candidate.source, candidate.commandOffset + separator, candidate.commandOffset + separator + 1));
758
803
  }
759
804
  function addNestedShellDiagnosticFinding(findings, candidate) {
@@ -1417,15 +1462,15 @@ export class ResponseEngine {
1417
1462
  const aid = selfAID || (channel ? this.agentRegistry?.resolveByChannel(channel)?.aid : undefined);
1418
1463
  if (!aid)
1419
1464
  return undefined;
1420
- const config = resolveEffective({ self: aid }, { cache: true, expand: true });
1465
+ const config = resolveEffective({ self: aid }, { cache: true });
1421
1466
  return createTextInferenceProvider(baseagent, config);
1422
1467
  }
1423
1468
  getDecisionInferenceProvider(selfAID) {
1424
1469
  const aid = selfAID;
1425
1470
  if (!aid)
1426
1471
  return undefined;
1427
- const config = resolveEffective({ self: aid }, { cache: true, expand: true });
1428
- return createDecisionInferenceProvider(config.decision_model, config.Services);
1472
+ const config = resolveEffective({ self: aid }, { cache: true });
1473
+ return createDecisionInferenceProvider(config.Services);
1429
1474
  }
1430
1475
  getAvailableBaseagentsForOwner(evolName) {
1431
1476
  return loadedBaseagentIds(this.agentMap.keys(), evolName);
@@ -2578,7 +2623,7 @@ export class ResponseEngine {
2578
2623
  * them immediately before every Runner invocation, including retries.
2579
2624
  */
2580
2625
  async assertCurrentFullAccessExecutionAuthorization(authorization, agent) {
2581
- await refreshOwnershipForAuthorization(authorization.agentAid, { allowTransient: true });
2626
+ await refreshOwnershipForAuthorization(authorization.agentAid, { allowTransient: true, includeDaemon: true });
2582
2627
  if (authorization.permissionMode !== 'fullaccess'
2583
2628
  || authorization.processRole !== 'fullaccess-run'
2584
2629
  || authorization.dataScope !== 'daemon'
@@ -2613,13 +2658,6 @@ export class ResponseEngine {
2613
2658
  resolveTriggerExecutionIdentity(message, selfAid) {
2614
2659
  if (message.source !== 'trigger' || !message.triggerMeta?.triggerId)
2615
2660
  return undefined;
2616
- // 跨话题复查(target_session 投递):本轮是"T2 侧 agent 被自己的复查通知唤醒",
2617
- // 身份就是 T2 会话自身的对端,与普通入站消息一致。
2618
- // 若沿用 originPeerId(来源话题 T1 的对端),整个轮次的角色与权限都会错位。
2619
- if (message.triggerMeta.reviewKind === 'cross-thread-review'
2620
- || message.triggerMeta.labels?.kind === 'cross-thread-review') {
2621
- return undefined;
2622
- }
2623
2661
  const actorId = message.triggerMeta.originPeerId;
2624
2662
  const channelType = message.triggerMeta.originChannelType;
2625
2663
  const originChannelKey = message.triggerMeta.originChannelKey;
@@ -2951,10 +2989,7 @@ export class ResponseEngine {
2951
2989
  const triggerExecutionIdentity = this.resolveTriggerExecutionIdentity(message, selfAidForAccess);
2952
2990
  const handoffExecutionIdentity = this.resolveHandoffOriginExecutionIdentity(message, selfAidForAccess);
2953
2991
  const executionIdentity = triggerExecutionIdentity ?? handoffExecutionIdentity;
2954
- // 跨话题复查走会话自身身份,本来就解析不出 Trigger 的 origin 身份,不属于"身份缺失"。
2955
- const isCrossThreadReview = message.triggerMeta?.reviewKind === 'cross-thread-review'
2956
- || message.triggerMeta?.labels?.kind === 'cross-thread-review';
2957
- if (message.source === 'trigger' && !triggerExecutionIdentity && !isCrossThreadReview) {
2992
+ if (message.source === 'trigger' && !triggerExecutionIdentity) {
2958
2993
  logger.warn(`[ResponseEngine] Trigger execution identity missing: trigger=${message.triggerMeta?.triggerId ?? '<none>'}`);
2959
2994
  const channelInfo = this.resolveChannelInfo(accessChannelKey);
2960
2995
  if (channelInfo) {
@@ -3570,15 +3605,7 @@ export class ResponseEngine {
3570
3605
  // operator. Keep the historical private-chat fallback (where channelId
3571
3606
  // is the peer identity for AUN), but fail closed for group messages that
3572
3607
  // arrive without a sender/operator ID.
3573
- // 跨话题复查投递的 message.peerId 是占位的 `trigger:<id>`,不是真实对端。这一轮身份
3574
- // 按 T2 会话自身的对端算(resolveTriggerExecutionIdentity 对这类投递返回 undefined),
3575
- // 私聊即 channelId;否则 actor 落成伪身份,在唤醒话题里连本条复查都管不了。
3576
- const isCrossThreadReviewTurn = message.source === 'trigger'
3577
- && (message.triggerMeta?.reviewKind === 'cross-thread-review'
3578
- || message.triggerMeta?.labels?.kind === 'cross-thread-review');
3579
- const turnPeerId = isCrossThreadReviewTurn && configChatType === 'private'
3580
- ? message.channelId
3581
- : peerIdRaw;
3608
+ const turnPeerId = peerIdRaw;
3582
3609
  const configActorId = authorizationIdentity?.actorId
3583
3610
  ?? (turnPeerId || (configChatType === 'private' ? message.channelId : undefined));
3584
3611
  const peerKeyId = authorizationIdentity?.actorId ?? (session.chatType === 'group'
@@ -3622,11 +3649,13 @@ export class ResponseEngine {
3622
3649
  ?? (peerRoleDetail
3623
3650
  ? (peerRoleDetail.effectiveRole ?? 'none')
3624
3651
  : (session.identity?.role ?? 'none'));
3652
+ let effectiveAgentConfigError;
3625
3653
  const effectiveAgentConfig = (() => {
3626
3654
  try {
3627
3655
  return resolveEffective({ self: selfAid || undefined, peerKey }, { cache: true });
3628
3656
  }
3629
3657
  catch (e) {
3658
+ effectiveAgentConfigError = e;
3630
3659
  logger.warn(`[ResponseEngine] resolveEffective failed: ${e instanceof Error ? e.message : String(e)}`);
3631
3660
  return undefined;
3632
3661
  }
@@ -4022,6 +4051,43 @@ export class ResponseEngine {
4022
4051
  return;
4023
4052
  }
4024
4053
  }
4054
+ // ── 模型取 Agent/defaults 配置;缺失时不回落 runner 的隐式默认值 ──
4055
+ {
4056
+ if (effectiveAgentConfigError) {
4057
+ this.touchAgentActivity(channelKey);
4058
+ adapter.send(envelope, {
4059
+ kind: 'system.error',
4060
+ text: isHostChinese()
4061
+ ? '⚠️ 无法读取当前 Agent 的模型配置,请管理员检查配置读取错误日志后重试。'
4062
+ : '⚠️ Cannot read this Agent\'s model configuration. Ask an administrator to check the configuration error log and retry.',
4063
+ subtype: 'model_config_unreadable',
4064
+ recoverable: true,
4065
+ }).catch(() => { });
4066
+ adapter.send(envelope, { kind: 'status.completed', metadata: { durationMs: 0 } }).catch(() => { });
4067
+ this.publishTriggerExecutionFailure(message, 'model_config_unreadable');
4068
+ return;
4069
+ }
4070
+ const modelBaseagent = normalizeBaseagent(agent.name).canonical;
4071
+ const agentModel = effectiveAgentConfig?.baseagents?.[modelBaseagent]?.model;
4072
+ const triggerModel = message.triggerMeta?.modelOverride;
4073
+ const hasModel = (typeof agentModel === 'string' && agentModel.trim().length > 0)
4074
+ || (typeof triggerModel === 'string' && triggerModel.trim().length > 0);
4075
+ if (modelBaseagent !== 'unknown' && !hasModel) {
4076
+ logger.warn(`[ResponseEngine] No Agent-level model configured: agent=${selfAid ?? session.selfAID ?? '<none>'} baseagent=${modelBaseagent} session=${session.id}`);
4077
+ this.touchAgentActivity(channelKey);
4078
+ adapter.send(envelope, {
4079
+ kind: 'system.error',
4080
+ text: isHostChinese()
4081
+ ? `⚠️ 当前 Agent 未配置模型(baseagents.${modelBaseagent}.model),无法回复。请 Agent 的 owner/admin 使用 /model 设置模型。`
4082
+ : `⚠️ This Agent has no model configured (baseagents.${modelBaseagent}.model) and cannot reply. An Agent owner/admin must set one with /model.`,
4083
+ subtype: 'model_not_configured',
4084
+ recoverable: false,
4085
+ }).catch(() => { });
4086
+ adapter.send(envelope, { kind: 'status.completed', metadata: { durationMs: 0 } }).catch(() => { });
4087
+ this.publishTriggerExecutionFailure(message, 'model_not_configured');
4088
+ return;
4089
+ }
4090
+ }
4025
4091
  const imageInfo = message.images && message.images.length > 0 ? ` [${message.images.length} image(s)]` : '';
4026
4092
  const modeInfo = isBackground ? ' [\u540e\u53f0]' : '';
4027
4093
  const e2eeInfo = message.replyContext?.metadata?.encrypted != null ? ` encrypt=${message.replyContext.metadata.encrypted}` : '';
@@ -4495,7 +4561,7 @@ export class ResponseEngine {
4495
4561
  action: 'owner_approval',
4496
4562
  requestId: permissionEvent.requestId,
4497
4563
  toolName: permissionEvent.toolName,
4498
- message: '等待 owner 审批',
4564
+ message: '等待审批',
4499
4565
  expiresAt: permissionEvent.expiresAt,
4500
4566
  },
4501
4567
  };
@@ -4512,7 +4578,7 @@ export class ResponseEngine {
4512
4578
  if (permissionEvent.state === 'approved') {
4513
4579
  await adapter.send(executionEnvelope, {
4514
4580
  kind: 'status.progress',
4515
- metadata: { activityType: 'progress', state: 'processing', text: 'owner 已批准,继续执行' },
4581
+ metadata: { activityType: 'progress', state: 'processing', text: '审批已批准,继续执行' },
4516
4582
  });
4517
4583
  return;
4518
4584
  }
@@ -4528,6 +4594,12 @@ export class ResponseEngine {
4528
4594
  errorType: `permission_${permissionEvent.reason}`,
4529
4595
  message: permissionEvent.message,
4530
4596
  requestId: permissionEvent.requestId,
4597
+ decisionSource: permissionEvent.decisionSource,
4598
+ policyCode: permissionEvent.policyCode,
4599
+ errorDetailCode: permissionEvent.errorDetailCode,
4600
+ approverOperatorId: permissionEvent.approverOperatorId,
4601
+ approverChannelKey: permissionEvent.approverChannelKey,
4602
+ approverPrincipalId: permissionEvent.approverPrincipalId,
4531
4603
  },
4532
4604
  });
4533
4605
  }
@@ -4692,7 +4764,7 @@ export class ResponseEngine {
4692
4764
  || !message.triggerMeta.authorizedBy) {
4693
4765
  throw new Error('fullaccess Trigger override lacks trusted scheduler identity or approval provenance');
4694
4766
  }
4695
- await refreshOwnershipForAuthorization(selfAid, { allowTransient: true });
4767
+ await refreshOwnershipForAuthorization(selfAid, { allowTransient: true, includeDaemon: true });
4696
4768
  const currentOwners = new Set(getDaemonOwners());
4697
4769
  if (!currentOwners.has(message.triggerMeta.authorizedBy)) {
4698
4770
  throw new Error('fullaccess Trigger approval is no longer owned');
@@ -4732,8 +4804,8 @@ export class ResponseEngine {
4732
4804
  fullAccessMessagePromptContext = fullAccessAuthorization
4733
4805
  ? FULL_ACCESS_MESSAGE_PROMPT_CONTEXT
4734
4806
  : undefined;
4735
- // 按 关系级 > agent级 > 全局 解析本次调用的模型/强度,作为 per-call 入参传入 runQuery。
4736
- // 不缓存、不绑会话——改关系级/agent级后该范围所有会话的下条消息即时生效;
4807
+ // 模型/强度只取 Agent 级配置(再经角色约束),作为 per-call 入参传入 runQuery。
4808
+ // 不缓存、不绑会话——改 Agent 级后该 Agent 所有会话的下条消息即时生效;
4737
4809
  // 多对端并发各自独立解析、各自传参,无共享状态可被污染。
4738
4810
  let effectiveModel;
4739
4811
  let effectiveModelSource;
@@ -4970,7 +5042,7 @@ export class ResponseEngine {
4970
5042
  }
4971
5043
  };
4972
5044
  // 预压缩必须使用与本轮 runQuery 相同的有效模型/强度覆盖。
4973
- // 模型解析完成后再执行,避免关系级模型存在时回落到 runner 默认模型。
5045
+ // 模型解析完成后再执行,避免回落到 runner 默认模型。
4974
5046
  await this.runPendingAutoCompactAtTaskStart(session, agent, absoluteProjectPath, renderer, modelOverride, () => this.assertCurrentExecutionAuthorization(permissionContext, agent));
4975
5047
  startTime = Date.now();
4976
5048
  const causationPath = inputCausation.trigger?.path ?? [];
@@ -5061,7 +5133,8 @@ export class ResponseEngine {
5061
5133
  isBootstrapping,
5062
5134
  hasPersona: !!persona,
5063
5135
  peerId: peerIdRaw || undefined,
5064
- peerKey,
5136
+ // 与任务上下文同源:系统会话取目标关系,否则 peer-profile / relation 索引会按 bg: 伪对端注入
5137
+ peerKey: systemSessionContext?.peerKey ?? peerKey,
5065
5138
  peerName: peerName || undefined,
5066
5139
  // 系统会话与角色体系无关:不给 peerRole,消息头就不渲染 `· role:` 段
5067
5140
  peerRole: systemSessionMarker ? undefined : peerRole,
@@ -5604,7 +5677,7 @@ export class ResponseEngine {
5604
5677
  if (permissionContext.approvalInteractionPolicy === 'deny') {
5605
5678
  logger.info(`[AsyncQuestions] no interactive recipient for unattended task: session=${session.id}`);
5606
5679
  if (blocking)
5607
- throw new Error('阻塞式用户问题无法在无人值守任务中继续');
5680
+ throw new UnattendedInputRequiredError();
5608
5681
  return;
5609
5682
  }
5610
5683
  if (blocking) {
@@ -6685,7 +6758,7 @@ export class ResponseEngine {
6685
6758
  else {
6686
6759
  logger.error(`[${message.channel}] Error:`, error);
6687
6760
  }
6688
- const errorType = prefixErrorType(ERROR_PREFIX.INFRA, errType);
6761
+ const errorType = prefixErrorType(errType === ErrorType.INPUT_REQUIRED ? ERROR_PREFIX.AGENT : ERROR_PREFIX.INFRA, errType);
6689
6762
  // 用户主动打断:流被掐断抛出的异常不是真正的失败。打断发生时 source
6690
6763
  // (message-queue / slash-handler)已发过 task:interrupted(它填充了
6691
6764
  // interruptedSessions,isUserInterrupt 才会为真),stats 侧已据此收尾任务。
@@ -104,7 +104,7 @@ export function parseModelList(json, _url) {
104
104
  }
105
105
  const BUILTIN_IDS = {
106
106
  codex: ['gpt-5.5', 'gpt-5.4', 'gpt-5.4-mini', 'gpt-5.3-codex', 'gpt-5.2'],
107
- claude: ['claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k2.6', 'kimi-k2.5', 'glm-5.1', 'glm-5', 'glm-4.7', 'MiniMax-M2.7'],
107
+ claude: ['claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-5-5', 'claude-opus-5', 'claude-sonnet-5', 'claude-opus-4-8', 'claude-opus-4-7', 'claude-opus-4-6', 'claude-sonnet-4-6', 'claude-haiku-4-5-20251001', 'claude-fable-5', 'claude-fable-5-1', 'deepseek-v4.1-flash', 'deepseek-v4-pro', 'deepseek-v4-flash', 'kimi-k3', 'glm-5.3', 'glm-5.3-flash', 'glm-5.3-flashx', 'glm-5.2'],
108
108
  ecagent: ['claude-sonnet-4-6'],
109
109
  gemini: ['gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'],
110
110
  };
@@ -359,7 +359,9 @@ export class ModelCatalogService {
359
359
  diagnostics.push({ code: auth ? 'AUTH_FAILED' : 'GATEWAY_UNAVAILABLE', message: auth ? '当前模型网关鉴权失败' : '当前模型网关不可用或响应格式不支持', ...(status ? { status } : {}) });
360
360
  if (previous?.source === 'gateway')
361
361
  return { ...previous, freshness: 'stale', diagnostics: [...diagnostics, { code: 'STALE_CACHE', message: '使用同一连接的最近成功目录' }] };
362
- if (auth)
362
+ // 有显式 provider 时,鉴权失败返回空网关目录(提示是凭据问题);环境变量
363
+ // 兜底(无 providerId)则继续往下回落内置清单,避免兜底变成空列表。
364
+ if (auth && context.providerId)
363
365
  return this.make(context, 'gateway', 'fallback', [], diagnostics);
364
366
  }
365
367
  }
@@ -367,7 +369,7 @@ export class ModelCatalogService {
367
369
  return { ...previous, freshness: 'stale', diagnostics: [...diagnostics, { code: 'STALE_CACHE', message: '使用同一连接的最近成功目录' }] };
368
370
  if (context.providerId)
369
371
  return this.make(context, 'gateway', 'fallback', [], diagnostics);
370
- if (!context.configUnavailable && this.options.native) {
372
+ if (!context.configUnavailable && !diagnostics.some(diagnostic => diagnostic.code === 'AUTH_FAILED') && this.options.native) {
371
373
  try {
372
374
  const native = await this.options.native(context);
373
375
  if (native !== null) {