@xopcai/xopc 0.0.307 → 0.0.308

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 (165) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CZeQo09T.js → agent-avatar-dicebear-dUotwUO6.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C6LflMXr.js +1 -0
  5. package/dist/gateway/static/root/assets/{agents-BlrHMbRx.js → agents-VPDIGRSS.js} +1 -1
  6. package/dist/gateway/static/root/assets/{app-management-settings-panel-Bzw4fQP8.js → app-management-settings-panel-zPz0rOND.js} +1 -1
  7. package/dist/gateway/static/root/assets/{appearance-settings-8GZpUXva.js → appearance-settings-DhvhR43G.js} +1 -1
  8. package/dist/gateway/static/root/assets/{apps-page-BkQQtIxH.js → apps-page-Pmslbzzr.js} +1 -1
  9. package/dist/gateway/static/root/assets/{archive-plugin-CQ2NaoHb.js → archive-plugin-BQVZMreT.js} +1 -1
  10. package/dist/gateway/static/root/assets/{attachment-load-BFi1H7yJ.js → attachment-load-CPE-TMPf.js} +1 -1
  11. package/dist/gateway/static/root/assets/{automations-page-CDBXcii_.js → automations-page-C4IAy_zF.js} +1 -1
  12. package/dist/gateway/static/root/assets/automations-workspace-Fx5VUJRu.js +6 -0
  13. package/dist/gateway/static/root/assets/{binary-plugins-D07eWmOx.js → binary-plugins-DgTl7diZ.js} +1 -1
  14. package/dist/gateway/static/root/assets/{block-editor-CtVnjyYU.js → block-editor-CcOVA-Gw.js} +3 -3
  15. package/dist/gateway/static/root/assets/{browser-automations-page-DyrSbDdG.js → browser-automations-page--zKAgj1k.js} +1 -1
  16. package/dist/gateway/static/root/assets/browser-settings-page-DBms6d35.js +3 -0
  17. package/dist/gateway/static/root/assets/capabilities-settings-panel-epdDWIZy.js +8 -0
  18. package/dist/gateway/static/root/assets/{channels-settings-DAD9qE3J.js → channels-settings-B0bsDtmP.js} +1 -1
  19. package/dist/gateway/static/root/assets/{chat-terminal-dock-B62SZdAo.js → chat-terminal-dock-BfLd2rIJ.js} +1 -1
  20. package/dist/gateway/static/root/assets/{computer-settings-page-ClSresNq.js → computer-settings-page-Ckgc0Py-.js} +1 -1
  21. package/dist/gateway/static/root/assets/connector-service-page-BlC1OXX4.js +1 -0
  22. package/dist/gateway/static/root/assets/connectors-page-By33-bF1.js +2 -0
  23. package/dist/gateway/static/root/assets/{cron-expression-CTMi_tql.js → cron-expression-CqNE-nf6.js} +1 -1
  24. package/dist/gateway/static/root/assets/{date-picker-B71AJK50.js → date-picker-BS9ZjzYJ.js} +1 -1
  25. package/dist/gateway/static/root/assets/{dependency-picker-DlyGK-kA.js → dependency-picker-CF_zYzxX.js} +1 -1
  26. package/dist/gateway/static/root/assets/{desktop-pet-DGkbTE8_.js → desktop-pet-CDwtLR7Z.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-settings-BY8r9j66.js → desktop-pet-settings-C0djIc1J.js} +1 -1
  28. package/dist/gateway/static/root/assets/{device-pairing-wizard-DzRrgd59.js → device-pairing-wizard-CDKj9LQj.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-debug-page-L8Mm1n3A.js → extension-debug-page-CX5OXxEU.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-page-CFc4vSNU.js → extension-page-BytR1PaY.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-settings-page-B5zWyHr3.js → extension-settings-page-CkaMJA5F.js} +1 -1
  32. package/dist/gateway/static/root/assets/{gateway-settings-D7qmTH4R.js → gateway-settings-_YU-1p0z.js} +1 -1
  33. package/dist/gateway/static/root/assets/{heartbeat-settings-Glsl3X5b.js → heartbeat-settings-CVIvvm4x.js} +1 -1
  34. package/dist/gateway/static/root/assets/home-page-COCHelcL.js +1 -0
  35. package/dist/gateway/static/root/assets/{imports-page-ByBX7ome.js → imports-page-DrtbjL8O.js} +1 -1
  36. package/dist/gateway/static/root/assets/index-CDfcPiPb.js +79 -0
  37. package/dist/gateway/static/root/assets/index-CRu1p38D.css +1 -0
  38. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C45RlO8a.js → keyboard-shortcuts-settings-BlZh41Xq.js} +1 -1
  39. package/dist/gateway/static/root/assets/{local-app-workbench-page-DP0x2jpR.js → local-app-workbench-page-D7_Raxjw.js} +2 -2
  40. package/dist/gateway/static/root/assets/{local-apps-page-C_AQc2bI.js → local-apps-page-DbP7wWuh.js} +1 -1
  41. package/dist/gateway/static/root/assets/{logs-page-DvM8Pyok.js → logs-page-C0n66FiO.js} +1 -1
  42. package/dist/gateway/static/root/assets/{management-settings-D1uwSutV.js → management-settings-i6GhxpGV.js} +1 -1
  43. package/dist/gateway/static/root/assets/{media-plugins-C4mhf13f.js → media-plugins-CnWChQ3Y.js} +1 -1
  44. package/dist/gateway/static/root/assets/note-detail-panel-C59d8vDW.js +5 -0
  45. package/dist/gateway/static/root/assets/notes-page-C1GBPrVI.js +8 -0
  46. package/dist/gateway/static/root/assets/{page-tabs-1go_BtX1.js → page-tabs-BWitjb3e.js} +1 -1
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-DmoSC0j1.js → preview-open-alternatives-UaCWCxZv.js} +1 -1
  48. package/dist/gateway/static/root/assets/{proactive-page-xAjKTIID.js → proactive-page-CtSFJxoM.js} +1 -1
  49. package/dist/gateway/static/root/assets/project-detail-page-ILTmQ1YN.js +1 -0
  50. package/dist/gateway/static/root/assets/projects-page-snl4rOQZ.js +1 -0
  51. package/dist/gateway/static/root/assets/remote-access-hub-BbaAcEN3.js +1 -0
  52. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-ClkOoxDl.js → runtime-tools-settings-panel-CtOjKGWg.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-BuEmLiaU.js → schema-form-DkyyDcl2.js} +1 -1
  54. package/dist/gateway/static/root/assets/sessions-page-DrWL71O8.js +1 -0
  55. package/dist/gateway/static/root/assets/settings-advanced-gate-BG0kl4HT.js +1 -0
  56. package/dist/gateway/static/root/assets/{settings-form-section-Dor39QON.js → settings-form-section-C0JDGN_V.js} +1 -1
  57. package/dist/gateway/static/root/assets/{settings-page-Xj-yvIc8.js → settings-page-DiIyMQ52.js} +1 -1
  58. package/dist/gateway/static/root/assets/setup-status-panel-EPazhoZO.js +1 -0
  59. package/dist/gateway/static/root/assets/{share-preview-page-BFWZoXdm.js → share-preview-page-Bt1K657Y.js} +1 -1
  60. package/dist/gateway/static/root/assets/shares-settings-g2MdRXSZ.js +1 -0
  61. package/dist/gateway/static/root/assets/skill-reload-api-B1DPzu98.js +1 -0
  62. package/dist/gateway/static/root/assets/skills-page-Wd0uYSPG.js +2 -0
  63. package/dist/gateway/static/root/assets/{skills-page.utils-Ii8qeXhs.js → skills-page.utils-vq5Ujm03.js} +1 -1
  64. package/dist/gateway/static/root/assets/{system-settings-panel-Di6OSO-0.js → system-settings-panel-Cz1P-HDH.js} +1 -1
  65. package/dist/gateway/static/root/assets/task-detail-page-BG3A5gPZ.js +1 -0
  66. package/dist/gateway/static/root/assets/{tunnel-api-DDOlOYlj.js → tunnel-api-DQGoFuZO.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-autosave-CQ8uWNnB.js → use-autosave-DVDlBb95.js} +1 -1
  68. package/dist/gateway/static/root/assets/user-model-page-qM5UiTGx.js +2 -0
  69. package/dist/gateway/static/root/assets/{voice-api-key-field-COTzshjL.js → voice-api-key-field-B2pZCcxY.js} +1 -1
  70. package/dist/gateway/static/root/assets/{work-discovery-overlay-_URrXbi4.js → work-discovery-overlay-Bptv7bEY.js} +1 -1
  71. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CALs-1nd.js → workflow-run-setup-panel-BijCrNc4.js} +2 -2
  72. package/dist/gateway/static/root/assets/workflows-page-DRy1RAYH.js +6 -0
  73. package/dist/gateway/static/root/index.html +2 -2
  74. package/dist/package.js +1 -1
  75. package/dist/packages/gateway-contract/src/notifications.js +1 -1
  76. package/dist/src/agent/background-review/prompts.js +3 -1
  77. package/dist/src/agent/context/execution-context.js +4 -4
  78. package/dist/src/agent/memory/compaction-promotion.d.ts +1 -1
  79. package/dist/src/agent/memory/compaction-promotion.js +4 -3
  80. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +1 -1
  81. package/dist/src/agent/tools/knowledge-memory-tool.js +3 -3
  82. package/dist/src/agent/tools/user-context-tool.js +17 -7
  83. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  84. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  85. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  86. package/dist/src/config/schema.d.ts +2 -4
  87. package/dist/src/config/schema.js +2 -2
  88. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  89. package/dist/src/connectors/connected-source-understanding.js +1 -0
  90. package/dist/src/connectors/learning-coordinator.js +31 -9
  91. package/dist/src/gateway/hono/lib/config-payload.d.ts +2 -2
  92. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  93. package/dist/src/gateway/hono/routes/context-sources.js +0 -23
  94. package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
  95. package/dist/src/gateway/hono/routes/projects.js +8 -0
  96. package/dist/src/gateway/hono/routes/user-model-refresh.d.ts +5 -0
  97. package/dist/src/gateway/hono/routes/user-model-refresh.js +128 -0
  98. package/dist/src/gateway/hono/routes/user-model.js +12 -5
  99. package/dist/src/gateway/hono/routes/work-discovery.js +0 -30
  100. package/dist/src/gateway/service.js +6 -6
  101. package/dist/src/infra/update-restart.js +1 -1
  102. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  103. package/dist/src/knowledge-memory/index.js +2 -2
  104. package/dist/src/knowledge-memory/repository.d.ts +7 -0
  105. package/dist/src/knowledge-memory/repository.js +58 -8
  106. package/dist/src/memory-maintenance/service.js +61 -31
  107. package/dist/src/migrations/memory-config.d.ts +2 -0
  108. package/dist/src/migrations/memory-config.js +77 -0
  109. package/dist/src/migrations/runner.js +2 -2
  110. package/dist/src/notifications/planner.js +5 -5
  111. package/dist/src/notifications/service.d.ts +2 -2
  112. package/dist/src/notifications/service.js +1 -1
  113. package/dist/src/storage/sqlite/migrations/184_memory_suppressions.sql +12 -0
  114. package/dist/src/storage/sqlite/migrations/185_understanding_refresh_batches.sql +6 -0
  115. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  116. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  117. package/dist/src/storage/sqlite/schema.js +1 -1
  118. package/dist/src/user-context/config.d.ts +4 -9
  119. package/dist/src/user-context/config.js +7 -27
  120. package/dist/src/user-context/memory-suppression.d.ts +7 -0
  121. package/dist/src/user-context/memory-suppression.js +23 -0
  122. package/dist/src/user-context/relationship-continuity.js +1 -1
  123. package/dist/src/user-context/sources/refresh-service.d.ts +48 -0
  124. package/dist/src/user-context/sources/refresh-service.js +221 -0
  125. package/dist/src/user-context/sources/repository.js +1 -1
  126. package/dist/src/user-model/bootstrap.js +27 -24
  127. package/dist/src/user-model/capture/executor.d.ts +1 -1
  128. package/dist/src/user-model/capture/executor.js +17 -11
  129. package/dist/src/user-model/capture/semantic.js +1 -1
  130. package/dist/src/user-model/domain.d.ts +6 -2
  131. package/dist/src/user-model/index.js +3 -3
  132. package/dist/src/user-model/profile.js +1 -1
  133. package/dist/src/user-model/repository.d.ts +4 -1
  134. package/dist/src/user-model/repository.js +96 -6
  135. package/dist/src/user-model/usage-policy.d.ts +2 -0
  136. package/dist/src/user-model/usage-policy.js +6 -2
  137. package/dist/src/work-discovery/project-understanding.js +2 -1
  138. package/dist/src/work-discovery/service.d.ts +8 -24
  139. package/dist/src/work-discovery/service.js +138 -180
  140. package/package.json +3 -3
  141. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +0 -1
  142. package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +0 -6
  143. package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +0 -3
  144. package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +0 -8
  145. package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +0 -1
  146. package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +0 -2
  147. package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +0 -1
  148. package/dist/gateway/static/root/assets/index-RBCkv8a_.js +0 -79
  149. package/dist/gateway/static/root/assets/index-cFU4S35z.css +0 -1
  150. package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +0 -5
  151. package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +0 -8
  152. package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +0 -1
  153. package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +0 -1
  154. package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +0 -1
  155. package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +0 -1
  156. package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +0 -1
  157. package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +0 -1
  158. package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +0 -1
  159. package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +0 -1
  160. package/dist/gateway/static/root/assets/skills-page-BE9JXz4U.js +0 -2
  161. package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +0 -1
  162. package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +0 -2
  163. package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +0 -6
  164. package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +0 -2
  165. package/dist/src/migrations/knowledge-memory-read-policy-config.js +0 -48
@@ -1,5 +1,6 @@
1
1
  import { createLogger } from "../utils/logger/index.js";
2
2
  import { init_logger } from "../utils/logger.js";
3
+ import { init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
3
4
  import { createContextEvidence } from "../storage/sqlite/context-evidence-repository.js";
4
5
  import { ensureSessionRecord, patchSessionMetadata } from "../storage/sqlite/session-repository.js";
5
6
  import "../storage/sqlite/index.js";
@@ -12,12 +13,12 @@ import { init_providers, resolveModel } from "../providers/index.js";
12
13
  import { writeKnowledgeItem } from "../knowledge-memory/repository.js";
13
14
  import "../knowledge-memory/index.js";
14
15
  import { createPriorityWindow, createUserGoal } from "../user-model/goals.js";
15
- import { getAssertionSlot, getUserAssertion, linkAssertionEvidence, reconcileAssertion, setAssertionStatus } from "../user-model/repository.js";
16
+ import { linkAssertionEvidence, reconcileAssertion } from "../user-model/repository.js";
16
17
  import "../user-model/index.js";
17
18
  import { isLocalModelBaseUrl } from "../providers/model-call.js";
18
19
  import { allowsRemoteSourceProcessing } from "../user-context/sources/processing-policy.js";
19
20
  import { analyzeUnderstandingSources, analyzeWorkContext, workDiscoveryResultMarkdown } from "./analyzer.js";
20
- import { createUnderstandingSourceRun, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
21
+ import { createUnderstandingSourceRun, getUnderstandingSourceGrant, getUnderstandingSourceRun, updateUnderstandingSourceGrantCheckpoint, updateUnderstandingSourceGrantPolicies, updateUnderstandingSourceRun, upsertUnderstandingSourceGrant } from "../user-context/sources/repository.js";
21
22
  import { clusterActivityTopics } from "../user-context/sources/activity-clustering.js";
22
23
  import { isLocalUnderstandingSourceId } from "../user-context/sources/local-source-contract.js";
23
24
  import { discoverWorkCandidates } from "./candidate-discovery.js";
@@ -36,6 +37,7 @@ init_schema();
36
37
  init_providers();
37
38
  init_session_key();
38
39
  init_resolve_route();
40
+ init_transaction();
39
41
  init_logger();
40
42
  const log = createLogger("WorkDiscovery");
41
43
  const MAX_UNDERSTANDING_ITEMS = 150;
@@ -199,45 +201,6 @@ function persistUnderstandingCandidate(candidate, scope, sourceRef) {
199
201
  evidenceConfidence: candidate.confidence === "high" ? .9 : .7
200
202
  }).assertion;
201
203
  }
202
- function decideAssertion(input, _expectedSourcePrefix) {
203
- const current = getUserAssertion(input.assertionId);
204
- if (!current || current.status === "archived") return void 0;
205
- if (input.status === "rejected") return setAssertionStatus(current.id, "rejected", {
206
- actor: "user",
207
- reason: "Rejected in work discovery review."
208
- });
209
- const statement = input.status === "edited" ? input.statement?.trim().slice(0, 500) : void 0;
210
- if (input.status === "edited" && !statement) return void 0;
211
- if (!statement) return setAssertionStatus(current.id, "active", {
212
- actor: "user",
213
- reason: "Accepted in work discovery review."
214
- });
215
- const slot = getAssertionSlot(current.slotId);
216
- if (!slot) return void 0;
217
- return reconcileAssertion({
218
- subject: slot.subject,
219
- predicate: slot.predicate,
220
- cardinality: slot.cardinality,
221
- scope: slot.scope,
222
- kind: current.kind,
223
- value: statement,
224
- normalizedValue: statement.toLocaleLowerCase(),
225
- statement,
226
- authority: "user_explicit",
227
- confidence: 1,
228
- declaredImportance: current.declaredImportance ?? .7,
229
- inferredImportance: current.inferredImportance,
230
- consequence: current.consequence,
231
- actionability: current.actionability,
232
- volatility: current.volatility,
233
- sensitivity: current.sensitivity,
234
- disclosurePolicy: current.disclosurePolicy,
235
- applicability: current.applicability,
236
- observedAt: Date.now(),
237
- createdBy: "user",
238
- correctionOfAssertionId: current.id
239
- }).assertion;
240
- }
241
204
  function persistWorkKnowledge(input) {
242
205
  const now = Date.now();
243
206
  return writeKnowledgeItem({
@@ -518,8 +481,17 @@ var WorkDiscoveryService = class {
518
481
  revokeDirectorySource(id) {
519
482
  return revokeWorkDiscoveryDirectorySource(id);
520
483
  }
521
- async importUnderstandingSources(rawItems, processingPolicy, signal, runId, rawCheckpoints) {
484
+ async importUnderstandingSources(rawItems, processingPolicy, signal, runId, rawCheckpoints, refresh) {
522
485
  const items = normalizeUnderstandingSourceItems(rawItems);
486
+ const assertRefreshAuthorized = () => {
487
+ signal?.throwIfAborted();
488
+ if (!refresh) return;
489
+ const config = this.options.getConfig();
490
+ if (!config.userContext.enabled || !config.userContext.userModel.enabled) throw new Error("User understanding is disabled.");
491
+ const grant = getUnderstandingSourceGrant(refresh.grantId);
492
+ if (!grant || grant.status !== "active" || grant.processingPolicy !== processingPolicy || items.some((item) => item.sourceId !== grant.adapterId)) throw new Error("Source authorization changed during update.");
493
+ };
494
+ assertRefreshAuthorized();
523
495
  if (!items.length) throw new Error("No readable understanding source items were provided");
524
496
  const target = this.getModelProcessingTarget();
525
497
  const agentId = getDefaultAgentId(this.options.getConfig());
@@ -541,7 +513,7 @@ var WorkDiscoveryService = class {
541
513
  const sourceItems = items.filter((item) => item.sourceId === sourceId);
542
514
  const category = sourceItems.some((item) => item.type === "calendar_event") ? "calendar" : sourceItems.some((item) => item.type === "task") ? "tasks" : sourceItems.some((item) => item.type === "note") ? "notes" : sourceItems.some((item) => item.type === "mail") ? "mail" : sourceItems.some((item) => item.type === "message") ? "messages" : sourceItems.some((item) => item.type === "code_activity") ? "code_activity" : "recent_documents";
543
515
  const platform = sourceId.startsWith("apple-") ? "darwin" : sourceId.startsWith("windows-") ? "win32" : sourceId.startsWith("linux-") ? "linux" : "all";
544
- let grant = upsertUnderstandingSourceGrant({
516
+ let grant = refresh ? getUnderstandingSourceGrant(refresh.grantId) : upsertUnderstandingSourceGrant({
545
517
  sourceKey: `understanding-source:${sourceId}`,
546
518
  adapterId: sourceId,
547
519
  category,
@@ -552,11 +524,11 @@ var WorkDiscoveryService = class {
552
524
  processingPolicy: effectiveProcessingPolicy,
553
525
  config: { readOnly: true }
554
526
  });
555
- if (grant.processingPolicy !== effectiveProcessingPolicy) grant = updateUnderstandingSourceGrantPolicies(grant.id, { processingPolicy: effectiveProcessingPolicy }) ?? grant;
527
+ if (!refresh && grant.processingPolicy !== effectiveProcessingPolicy) grant = updateUnderstandingSourceGrantPolicies(grant.id, { processingPolicy: effectiveProcessingPolicy }) ?? grant;
556
528
  sourceGrants.set(sourceId, grant);
557
529
  const checkpoint = checkpoints.get(sourceId);
558
530
  const previousFingerprint = typeof grant.checkpoint.fingerprint === "string" ? grant.checkpoint.fingerprint : void 0;
559
- const unchanged = Boolean(checkpoint && previousFingerprint === checkpoint.fingerprint);
531
+ const unchanged = !refresh && Boolean(checkpoint && previousFingerprint === checkpoint.fingerprint);
560
532
  const kind = !previousFingerprint ? "bootstrap" : unchanged ? "fingerprint" : "incremental";
561
533
  const sourceRun = createUnderstandingSourceRun({
562
534
  grantId: grant.id,
@@ -625,6 +597,8 @@ var WorkDiscoveryService = class {
625
597
  status: "completed"
626
598
  }))
627
599
  };
600
+ assertRefreshAuthorized();
601
+ if (refresh && analysis.sourceStatuses.some((source) => source.status !== "completed")) throw new Error("Source analysis did not complete. Please retry.");
628
602
  const statusBySource = new Map(analysis.sourceStatuses.map((item) => [item.sourceId, item]));
629
603
  for (const [sourceId, sourceRunId] of sourceRuns) {
630
604
  if (!changedSourceIds.has(sourceId)) continue;
@@ -665,123 +639,127 @@ var WorkDiscoveryService = class {
665
639
  }
666
640
  throw error;
667
641
  }
668
- const rawContents = analysisItems.flatMap((item) => item.text ? [item.text] : []);
669
- const activityTopics = clusterActivityTopics(analysisItems);
670
- const safeProfileCandidates = analysis.profileCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.statement, rawContents));
671
- const safeWorkThreadCandidates = analysis.workThreadCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.title, rawContents) && !hasLongVerbatimOverlap(candidate.summary, rawContents));
672
- const profileCandidates = safeProfileCandidates.map((candidate) => {
673
- const assertion = persistUnderstandingCandidate(candidate, { type: "global" }, "understanding-source:onboarding");
674
- const evidenceSourceIds = new Set((candidate.evidenceRefs ?? []).map((ref) => ref.split("://", 1)[0]).filter(Boolean));
675
- for (const sourceId of evidenceSourceIds) {
676
- const sourceRunId = sourceRuns.get(sourceId);
677
- if (!sourceRunId) continue;
678
- const sourceRun = getUnderstandingSourceRun(sourceRunId);
679
- if (!sourceRun) continue;
680
- const evidence = createContextEvidence({
681
- sourceType: "runtime",
682
- sourceRef: `understanding-source-grant:${sourceRun.grantId}:${candidate.id}`,
683
- redactedExcerpt: candidate.evidence.join(" · ").slice(0, 600),
684
- trustLevel: "trusted",
685
- observedAt: Date.now()
642
+ return runSqliteWriteTransaction(() => {
643
+ const rawContents = analysisItems.flatMap((item) => item.text ? [item.text] : []);
644
+ const activityTopics = clusterActivityTopics(analysisItems);
645
+ const safeProfileCandidates = analysis.profileCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.statement, rawContents));
646
+ const safeWorkThreadCandidates = analysis.workThreadCandidates.filter((candidate) => !hasLongVerbatimOverlap(candidate.title, rawContents) && !hasLongVerbatimOverlap(candidate.summary, rawContents));
647
+ const profileCandidates = safeProfileCandidates.flatMap((candidate) => {
648
+ const assertion = persistUnderstandingCandidate(candidate, { type: "global" }, "understanding-source:onboarding");
649
+ if (!assertion) return [];
650
+ const evidenceSourceIds = new Set((candidate.evidenceRefs ?? []).map((ref) => ref.split("://", 1)[0]).filter(Boolean));
651
+ for (const sourceId of evidenceSourceIds) {
652
+ const sourceRunId = sourceRuns.get(sourceId);
653
+ if (!sourceRunId) continue;
654
+ const sourceRun = getUnderstandingSourceRun(sourceRunId);
655
+ if (!sourceRun) continue;
656
+ const evidence = createContextEvidence({
657
+ sourceType: "runtime",
658
+ sourceRef: `understanding-source-grant:${sourceRun.grantId}:${candidate.id}`,
659
+ redactedExcerpt: candidate.evidence.join(" · ").slice(0, 600),
660
+ trustLevel: "trusted",
661
+ observedAt: Date.now()
662
+ });
663
+ linkAssertionEvidence(assertion.id, evidence.id, "supports", assertion.confidence);
664
+ }
665
+ return {
666
+ ...candidate,
667
+ status: assertion.status === "rejected" ? "rejected" : "pending",
668
+ assertionId: assertion.id
669
+ };
670
+ });
671
+ const investigation = linkedRun ? getWorkUnderstandingInvestigationForRun(linkedRun.id) : null;
672
+ const contextEvidence = investigation ? safeWorkThreadCandidates.map((candidate) => {
673
+ const topicHash = createHash("sha256").update(candidate.topicKey).digest("hex").slice(0, 16);
674
+ return appendWorkUnderstandingEvidence({
675
+ investigationId: investigation.id,
676
+ projectId: linkedRun.projectId,
677
+ sourceType: "understanding_source",
678
+ sourceRef: `understanding-source://thread/${topicHash}`,
679
+ observation: candidate.summary,
680
+ contentHash: createHash("sha256").update(JSON.stringify(candidate.evidenceRefs)).digest("hex"),
681
+ sensitivity: "normal"
686
682
  });
687
- linkAssertionEvidence(assertion.id, evidence.id, "supports", assertion.confidence);
688
- }
689
- return {
690
- ...candidate,
691
- status: assertion.status === "rejected" ? "rejected" : "pending",
692
- assertionId: assertion.id
693
- };
694
- });
695
- const investigation = linkedRun ? getWorkUnderstandingInvestigationForRun(linkedRun.id) : null;
696
- const contextEvidence = investigation ? safeWorkThreadCandidates.map((candidate) => {
697
- const topicHash = createHash("sha256").update(candidate.topicKey).digest("hex").slice(0, 16);
698
- return appendWorkUnderstandingEvidence({
699
- investigationId: investigation.id,
683
+ }) : [];
684
+ const workThreads = linkedRun && contextEvidence.length ? persistWorkThreadsFromDiscovery({
700
685
  projectId: linkedRun.projectId,
701
- sourceType: "understanding_source",
702
- sourceRef: `understanding-source://thread/${topicHash}`,
703
- observation: candidate.summary,
704
- contentHash: createHash("sha256").update(JSON.stringify(candidate.evidenceRefs)).digest("hex"),
705
- sensitivity: "normal"
706
- });
707
- }) : [];
708
- const workThreads = linkedRun && contextEvidence.length ? persistWorkThreadsFromDiscovery({
709
- projectId: linkedRun.projectId,
710
- result: {
711
- projectSummary: "Connected source context",
712
- currentState: "Work streams inferred from sources the user explicitly connected.",
713
- uncertainties: [],
714
- suggestions: [],
715
- workThreadCandidates: safeWorkThreadCandidates.map((candidate, index) => ({
716
- ...candidate,
717
- evidenceRefs: contextEvidence[index] ? [contextEvidence[index].sourceRef] : []
718
- }))
719
- },
720
- snapshot: {
721
- root: {
722
- displayName: "Connected Sources",
723
- projectKind: "general",
724
- markerReasons: ["explicitly_connected_understanding_sources"]
686
+ result: {
687
+ projectSummary: "Connected source context",
688
+ currentState: "Work streams inferred from sources the user explicitly connected.",
689
+ uncertainties: [],
690
+ suggestions: [],
691
+ workThreadCandidates: safeWorkThreadCandidates.map((candidate, index) => ({
692
+ ...candidate,
693
+ evidenceRefs: contextEvidence[index] ? [contextEvidence[index].sourceRef] : []
694
+ }))
725
695
  },
726
- structure: {
727
- sampledPaths: [],
728
- metadataOnlyFiles: [],
729
- omittedPathCount: 0
696
+ snapshot: {
697
+ root: {
698
+ displayName: "Connected Sources",
699
+ projectKind: "general",
700
+ markerReasons: ["explicitly_connected_understanding_sources"]
701
+ },
702
+ structure: {
703
+ sampledPaths: [],
704
+ metadataOnlyFiles: [],
705
+ omittedPathCount: 0
706
+ },
707
+ documents: [],
708
+ limits: {
709
+ policyVersion: 1,
710
+ fileCount: 0,
711
+ contentBytes: 0,
712
+ truncated: false
713
+ }
730
714
  },
731
- documents: [],
732
- limits: {
733
- policyVersion: 1,
734
- fileCount: 0,
735
- contentBytes: 0,
736
- truncated: false
737
- }
738
- },
739
- evidence: contextEvidence
740
- }) : [];
741
- const activityEvidence = new Set(activityTopics.flatMap((topic) => topic.evidenceRefs));
742
- const activityKnowledge = activityTopics.map((topic) => persistWorkKnowledge({
743
- canonicalKey: topic.canonicalKey,
744
- title: topic.title,
745
- summary: topic.summary,
746
- horizon: topic.horizon,
747
- confidence: topic.confidence,
748
- scope: {
749
- type: "agent",
750
- id: agentId
751
- },
752
- evidenceRefs: topic.evidenceRefs
753
- }));
754
- const modelKnowledge = safeWorkThreadCandidates.filter((candidate) => !candidate.evidenceRefs.some((ref) => activityEvidence.has(ref))).map((candidate) => persistWorkKnowledge({
755
- canonicalKey: `source-knowledge:${candidate.topicKey}`,
756
- title: candidate.title,
757
- summary: candidate.summary,
758
- horizon: candidate.horizon,
759
- confidence: candidate.confidence === "high" ? .9 : candidate.confidence === "medium" ? .72 : .55,
760
- scope: {
761
- type: "agent",
762
- id: agentId
763
- },
764
- evidenceRefs: candidate.evidenceRefs
765
- }));
766
- const knowledgeCandidates = [...activityKnowledge, ...modelKnowledge];
767
- log.info({
768
- runId,
769
- itemCount: items.length,
770
- candidateCount: profileCandidates.length,
771
- knowledgeCount: knowledgeCandidates.length,
772
- incompleteSourceCount: analysis.sourceStatuses.filter((item) => item.status !== "completed").length
773
- }, "Understanding sources analyzed");
774
- return {
775
- profileCandidates,
776
- workThreads,
777
- knowledgeCandidates,
778
- sourceStatuses: analysis.sourceStatuses
779
- };
715
+ evidence: contextEvidence
716
+ }) : [];
717
+ const activityEvidence = new Set(activityTopics.flatMap((topic) => topic.evidenceRefs));
718
+ const activityKnowledge = activityTopics.map((topic) => persistWorkKnowledge({
719
+ canonicalKey: topic.canonicalKey,
720
+ title: topic.title,
721
+ summary: topic.summary,
722
+ horizon: topic.horizon,
723
+ confidence: topic.confidence,
724
+ scope: {
725
+ type: "agent",
726
+ id: agentId
727
+ },
728
+ evidenceRefs: topic.evidenceRefs
729
+ }));
730
+ const modelKnowledge = safeWorkThreadCandidates.filter((candidate) => !candidate.evidenceRefs.some((ref) => activityEvidence.has(ref))).map((candidate) => persistWorkKnowledge({
731
+ canonicalKey: `source-knowledge:${candidate.topicKey}`,
732
+ title: candidate.title,
733
+ summary: candidate.summary,
734
+ horizon: candidate.horizon,
735
+ confidence: candidate.confidence === "high" ? .9 : candidate.confidence === "medium" ? .72 : .55,
736
+ scope: {
737
+ type: "agent",
738
+ id: agentId
739
+ },
740
+ evidenceRefs: candidate.evidenceRefs
741
+ }));
742
+ const knowledgeCandidates = [...activityKnowledge, ...modelKnowledge].filter((item) => item !== void 0);
743
+ log.info({
744
+ runId,
745
+ itemCount: items.length,
746
+ candidateCount: profileCandidates.length,
747
+ knowledgeCount: knowledgeCandidates.length,
748
+ incompleteSourceCount: analysis.sourceStatuses.filter((item) => item.status !== "completed").length
749
+ }, "Understanding sources analyzed");
750
+ return {
751
+ profileCandidates,
752
+ workThreads,
753
+ knowledgeCandidates,
754
+ sourceStatuses: analysis.sourceStatuses
755
+ };
756
+ });
780
757
  }
781
758
  async rescanDirectorySource(input) {
782
759
  const source = getWorkDiscoveryDirectorySource(input.id);
783
760
  if (!source || source.status !== "active") throw new Error("Approved work folder not found");
784
761
  const preview = await previewWorkDiscoveryRoot(source.rootPath);
762
+ if (getUnderstandingSourceGrant(source.id)?.status !== "active" || getUnderstandingSourceGrant(source.id)?.processingPolicy !== source.processingPolicy) throw new Error("Work folder authorization was revoked.");
785
763
  upsertWorkDiscoveryDirectorySource({
786
764
  rootPath: preview.canonicalRootPath,
787
765
  displayName: preview.displayName,
@@ -1010,6 +988,8 @@ var WorkDiscoveryService = class {
1010
988
  },
1011
989
  ...discoveredProjects?.length ? { discoveredProjects } : {}
1012
990
  };
991
+ signal.throwIfAborted();
992
+ if (approvedSource && (getUnderstandingSourceGrant(approvedSource.id)?.status !== "active" || getUnderstandingSourceGrant(approvedSource.id)?.processingPolicy !== approvedSource.processingPolicy)) throw new Error("Work folder authorization was revoked during analysis.");
1013
993
  const workThreads = persistWorkThreadsFromDiscovery({
1014
994
  projectId: run.projectId,
1015
995
  result: baseResult,
@@ -1070,6 +1050,8 @@ var WorkDiscoveryService = class {
1070
1050
  });
1071
1051
  if (approvedSource) try {
1072
1052
  const preview = await previewWorkDiscoveryRoot(run.rootPath);
1053
+ signal.throwIfAborted();
1054
+ if (getUnderstandingSourceGrant(approvedSource.id)?.status !== "active") throw new Error("Work folder authorization was revoked.");
1073
1055
  upsertWorkDiscoveryDirectorySource({
1074
1056
  rootPath: preview.canonicalRootPath,
1075
1057
  displayName: preview.displayName,
@@ -1195,42 +1177,18 @@ var WorkDiscoveryService = class {
1195
1177
  }
1196
1178
  persistProfileCandidates(run, result) {
1197
1179
  if (!result.profileCandidates?.length) return result;
1198
- const profileCandidates = result.profileCandidates.map((candidate) => {
1180
+ const profileCandidates = result.profileCandidates.flatMap((candidate) => {
1199
1181
  const assertion = persistUnderstandingCandidate(candidate, { type: "global" }, `work-discovery:${run.id}`);
1200
- return {
1182
+ return assertion ? [{
1201
1183
  ...candidate,
1202
1184
  assertionId: assertion.id
1203
- };
1185
+ }] : [];
1204
1186
  });
1205
1187
  return {
1206
1188
  ...result,
1207
1189
  profileCandidates
1208
1190
  };
1209
1191
  }
1210
- updateProfileCandidates(input) {
1211
- const run = getWorkDiscoveryRun(input.runId);
1212
- if (!run?.result?.profileCandidates?.length) return null;
1213
- const decisions = new Map(input.decisions.map((decision) => [decision.id, decision]));
1214
- const profileCandidates = run.result.profileCandidates.map((candidate) => {
1215
- const decision = decisions.get(candidate.id);
1216
- if (!decision || !candidate.assertionId) return candidate;
1217
- const updated = decideAssertion({
1218
- assertionId: candidate.assertionId,
1219
- ...decision
1220
- }, `work-discovery:${run.id}:`);
1221
- if (!updated) return candidate;
1222
- return {
1223
- ...candidate,
1224
- assertionId: updated.id,
1225
- statement: updated.statement,
1226
- status: decision.status
1227
- };
1228
- });
1229
- return updateWorkDiscoveryRun(run.id, { result: {
1230
- ...run.result,
1231
- profileCandidates
1232
- } });
1233
- }
1234
1192
  cancelRun(id) {
1235
1193
  const run = getWorkDiscoveryRun(id);
1236
1194
  if (!run) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xopcai/xopc",
3
- "version": "0.0.307",
3
+ "version": "0.0.308",
4
4
  "description": "Local-first personal AI assistant with reviewable user understanding, durable tasks, workflows, automations, and local or cloud models.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -171,8 +171,8 @@
171
171
  "@xopcai/endpoint-tools-client": "0.0.0",
172
172
  "@xopcai/endpoint-tools-protocol": "0.0.0",
173
173
  "@xopcai/gateway-contract": "0.0.0",
174
- "@xopcai/realtime-client": "0.0.0",
175
- "@xopcai/realtime-protocol": "0.0.0"
174
+ "@xopcai/realtime-protocol": "0.0.0",
175
+ "@xopcai/realtime-client": "0.0.0"
176
176
  },
177
177
  "scripts": {
178
178
  "assets:brand": "node scripts/generate-brand-assets.mjs",
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as a}from"./popover-select-9i-ZtHXL.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./cn-JdwAhgNB.js";import{c as l,n as u}from"./locale-store-msTfRK8P.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{t as f}from"./button-CS04eWY9.js";import{r as p}from"./gateway-config-swr-B6wHa6ZI.js";import{t as m}from"./skeleton-BwbyijEw.js";import{n as h,t as g}from"./registry-api-BSWtko7U.js";import{Dc as _,Gl as v,Gu as y,Ic as b,bl as x,dn as S,gc as C,il as w,li as T,nn as E,qu as D,rn as O,vc as ee,xc as k,y as te}from"./index-RBCkv8a_.js";import{n as A,r as j}from"./settings-page-layout-X1x-2Cp9.js";import{n as M,t as ne}from"./use-autosave-CQ8uWNnB.js";import{u as N}from"./voice-config-api-DgJML_uM.js";import{r as re}from"./image-generation-api-Ck_pyDom.js";var P=e(t(),1),ie=n(),F=r(),I={"xopc-cloud":`XOPC Cloud`,"xopc-local":`XOPC Local`,alibaba:`Alibaba Cloud`,edge:`Microsoft Edge`,groq:`Groq`,minimax:`MiniMax`,openai:`OpenAI`,"tts-local-cli":`Local TTS`};function L(e,t,n){let r=e?.[t]?.[n];return typeof r==`string`&&r.trim()?r.trim():void 0}function R(e){return I[e]??e}function z(e){let t=(0,ie.c)(17),{icon:n,label:r,enabled:i,details:a,zh:o}=e,s;t[0]===n?s=t[1]:(s=(0,F.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,F.jsx)(n,{className:`size-4`,"aria-hidden":!0})}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,F.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=c);let l=i?o?`已启用`:`On`:o?`已关闭`:`Off`,u;t[4]===l?u=t[5]:(u=(0,F.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-fg-muted`,children:l}),t[4]=l,t[5]=u);let d;t[6]!==c||t[7]!==u?(d=(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[6]=c,t[7]=u,t[8]=d):d=t[8];let f=i?a:o?`不处理语音`:`Voice processing is disabled`,p;t[9]===f?p=t[10]:(p=(0,F.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,F.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;return t[14]!==s||t[15]!==m?(h=(0,F.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl bg-surface-base/55 p-4`,children:[s,m]}),t[14]=s,t[15]=m,t[16]=h):h=t[16],h}function B(e){let t=(0,ie.c)(27),{zh:n}=e,{data:r,error:a,isLoading:o}=p(!0),s=r?.payload?.config,c,l,u;if(t[0]!==s){u=s===void 0?void 0:N(s);let e=u?L(u.stt.providers,u.stt.provider,`model`):void 0,n=u?L(u.tts.providers,u.tts.provider,`model`):void 0,r=u?L(u.tts.providers,u.tts.provider,`voice`):void 0;c=u?[R(u.stt.provider),e].filter(Boolean).join(` · `):void 0,l=u?[R(u.tts.provider),n,r].filter(Boolean).join(` · `):void 0,t[0]=s,t[1]=c,t[2]=l,t[3]=u}else c=t[1],l=t[2],u=t[3];let d=l,h=n?`语音能力`:`Voice capabilities`,g;t[4]===h?g=t[5]:(g=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:h}),t[4]=h,t[5]=g);let _=n?`语音识别和朗读由所有智能体共用,在语音设置中统一管理。`:`STT and TTS are shared by every agent and managed in global voice settings.`,v;t[6]===_?v=t[7]:(v=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:_}),t[6]=_,t[7]=v);let b;t[8]!==g||t[9]!==v?(b=(0,F.jsxs)(`div`,{children:[g,v]}),t[8]=g,t[9]=v,t[10]=b):b=t[10];let x=n?`管理语音设置`:`Manage voice settings`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,F.jsx)(D,{className:`size-4`,"aria-hidden":!0}),t[11]=S):S=t[11];let C;t[12]===x?C=t[13]:(C=(0,F.jsx)(f,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,F.jsxs)(i,{to:`/settings/capabilities/voice`,children:[x,S]})}),t[12]=x,t[13]=C);let T;t[14]!==b||t[15]!==C?(T=(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b,C]}),t[14]=b,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==o||t[19]!==c||t[20]!==d||t[21]!==u||t[22]!==n?(E=o||!u?a?(0,F.jsx)(`p`,{className:`mt-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:n?`暂时无法读取语音配置。`:`Voice settings could not be loaded.`}):(0,F.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,F.jsx)(m,{className:`h-20 rounded-xl`}),(0,F.jsx)(m,{className:`h-20 rounded-xl`})]}):(0,F.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[(0,F.jsx)(z,{icon:w,label:n?`语音转文字(STT)`:`Speech to text (STT)`,enabled:u.stt.enabled,details:c,zh:n}),(0,F.jsx)(z,{icon:y,label:n?`文字转语音(TTS)`:`Text to speech (TTS)`,enabled:u.tts.enabled,details:d,zh:n})]}),t[17]=a,t[18]=o,t[19]=c,t[20]=d,t[21]=u,t[22]=n,t[23]=E):E=t[23];let O;return t[24]!==T||t[25]!==E?(O=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=O):O=t[26],O}var V=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],H=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,U={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function W(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function ae(e){let t=(0,ie.c)(35),{primary:n,value:r,models:i,loading:a,error:o,zh:c,onChange:l}=e,u;if(t[0]!==i||t[1]!==n||t[2]!==r){let e;t[4]!==n||t[5]!==r?(e=e=>e.id!==n&&!r.includes(e.id),t[4]=n,t[5]=r,t[6]=e):e=t[6],u=i.filter(e),t[0]=i,t[1]=n,t[2]=r,t[3]=u}else u=t[3];let d=u,f=c?`回退顺序`:`Fallback order`,p;t[7]===f?p=t[8]:(p=(0,F.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),t[7]=f,t[8]=p);let m=c?`主模型不可用时,按从左到右的顺序尝试。`:`Tried from left to right when the primary model is unavailable.`,h;t[9]===m?h=t[10]:(h=(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:m}),t[9]=m,t[10]=h);let g;t[11]!==p||t[12]!==h?(g=(0,F.jsx)(`div`,{className:`flex items-center justify-between gap-3`,children:(0,F.jsxs)(`div`,{children:[p,h]})}),t[11]=p,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==i||t[15]!==l||t[16]!==r||t[17]!==c?(_=r.length>0?(0,F.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r.map((e,t)=>(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full bg-surface-base/70 py-1 pl-2.5 pr-1 text-xs text-fg`,children:[(0,F.jsx)(`span`,{className:`text-fg-subtle`,children:t+1}),(0,F.jsx)(`span`,{children:i.find(t=>t.id===e)?.name??e}),(0,F.jsx)(`button`,{type:`button`,"aria-label":c?`移除 ${e}`:`Remove ${e}`,className:`rounded-full p-1 text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>l(r.filter(t=>t!==e)),children:(0,F.jsx)(s,{className:`size-3`})})]},e))}):(0,F.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:c?`未设置回退模型。`:`No fallback models configured.`}),t[14]=i,t[15]=l,t[16]=r,t[17]=c,t[18]=_):_=t[18];let v=c?`添加回退模型`:`Add fallback model`,y=c?`搜索模型或服务商`:`Search models or providers`,b=c?`没有可添加的模型`:`No models available to add`,x=c?`添加回退模型`:`Add fallback model`,S;t[19]!==l||t[20]!==r?(S=e=>{e&&l([...r,e])},t[19]=l,t[20]=r,t[21]=S):S=t[21];let C;t[22]!==d||t[23]!==o||t[24]!==a||t[25]!==b||t[26]!==x||t[27]!==S||t[28]!==v||t[29]!==y?(C=(0,F.jsx)(T,{value:``,models:d,modelsLoading:a,modelsError:o,placeholder:v,searchPlaceholder:y,noMatches:b,showProviderInTrigger:!1,contentAlign:`start`,className:`mt-3 w-full max-w-md`,ariaLabel:x,onChange:S}),t[22]=d,t[23]=o,t[24]=a,t[25]=b,t[26]=x,t[27]=S,t[28]=v,t[29]=y,t[30]=C):C=t[30];let w;return t[31]!==C||t[32]!==g||t[33]!==_?(w=(0,F.jsxs)(`div`,{children:[g,_,C]}),t[31]=C,t[32]=g,t[33]=_,t[34]=w):w=t[34],w}function G(e){let t=(0,ie.c)(121),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let o=d(g,h,a),s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[1]=s):s=t[1];let c=d(`agent-defaults-image-models`,re,s),l;t[2]===o.data?l=t[3]:(l=o.data??[],t[2]=o.data,t[3]=l);let u=l,p;t[4]===c.data?p=t[5]:(p=c.data??[],t[4]=c.data,t[5]=p);let m;t[6]===p?m=t[7]:(m=p.flatMap(K),t[6]=p,t[7]=m);let _=m,v=i?U.zh:U.en,y;t[8]!==n||t[9]!==r?(y=(e,t)=>{let i={...n.models.intents};t?i[e]=W(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[8]=n,t[9]=r,t[10]=y):y=t[10];let b=y,x=i?`默认对话模型`:`Default conversation model`,S;t[11]===x?S=t[12]:(S=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:x}),t[11]=x,t[12]=S);let C=i?`大多数对话和没有专用路由的任务都会使用它。`:`Used for most conversations and every task without a dedicated route.`,w;t[13]===C?w=t[14]:(w=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[13]=C,t[14]=w);let E;t[15]!==w||t[16]!==S?(E=(0,F.jsxs)(`div`,{children:[S,w]}),t[15]=w,t[16]=S,t[17]=E):E=t[17];let D=i?`主模型`:`Primary model`,O;t[18]===D?O=t[19]:(O=(0,F.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:D}),t[18]=D,t[19]=O);let ee=i?`选择模型`:`Select a model`,k=i?`搜索模型或服务商`:`Search models or providers`,te=i?`没有匹配的模型`:`No matching models`,A=i?`默认对话模型`:`Default conversation model`,j;t[20]!==n||t[21]!==r?(j=e=>r({...n,models:{...n.models,chat:{...n.models.chat,primary:e}}}),t[20]=n,t[21]=r,t[22]=j):j=t[22];let M;t[23]!==n.models.chat.primary||t[24]!==ee||t[25]!==k||t[26]!==te||t[27]!==A||t[28]!==j?(M=(0,F.jsx)(T,{value:n.models.chat.primary,placeholder:ee,searchPlaceholder:k,noMatches:te,showProviderSettingsFooter:!0,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:A,onChange:j}),t[23]=n.models.chat.primary,t[24]=ee,t[25]=k,t[26]=te,t[27]=A,t[28]=j,t[29]=M):M=t[29];let ne;t[30]!==O||t[31]!==M?(ne=(0,F.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[O,M]}),t[30]=O,t[31]=M,t[32]=ne):ne=t[32];let N;t[33]!==n||t[34]!==r?(N=e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}}),t[33]=n,t[34]=r,t[35]=N):N=t[35];let P;t[36]!==n.models.chat.fallbacks||t[37]!==n.models.chat.primary||t[38]!==u||t[39]!==o.error||t[40]!==o.isLoading||t[41]!==N||t[42]!==i?(P=(0,F.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,F.jsx)(ae,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:u,loading:o.isLoading,error:o.error,zh:i,onChange:N})}),t[36]=n.models.chat.fallbacks,t[37]=n.models.chat.primary,t[38]=u,t[39]=o.error,t[40]=o.isLoading,t[41]=N,t[42]=i,t[43]=P):P=t[43];let I;t[44]!==E||t[45]!==ne||t[46]!==P?(I=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[E,ne,P]}),t[44]=E,t[45]=ne,t[46]=P,t[47]=I):I=t[47];let L=i?`图片能力`:`Image capabilities`,R;t[48]===L?R=t[49]:(R=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:L}),t[48]=L,t[49]=R);let z=i?`没有图片任务时可以保持关闭。`:`Leave these off when the agents do not work with images.`,G;t[50]===z?G=t[51]:(G=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:z}),t[50]=z,t[51]=G);let q=i?`图片理解模型`:`Image understanding model`,J;t[52]===q?J=t[53]:(J=(0,F.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:q}),t[52]=q,t[53]=J);let Y=n.models.imageUnderstanding?.primary??``,X=i?`关闭图片理解`:`Image understanding off`,Z=i?`搜索视觉模型`:`Search vision models`,Q=i?`没有可用的视觉模型`:`No vision models available`,oe=i?`关闭图片理解`:`Image understanding off`,se=i?`图片理解模型`:`Image understanding model`,ce;t[54]!==n||t[55]!==r?(ce=e=>{let t={...n.models};e?t.imageUnderstanding=W(t.imageUnderstanding,e):delete t.imageUnderstanding,r({...n,models:t})},t[54]=n,t[55]=r,t[56]=ce):ce=t[56];let le;t[57]!==Y||t[58]!==X||t[59]!==Z||t[60]!==Q||t[61]!==oe||t[62]!==se||t[63]!==ce?(le=(0,F.jsx)(T,{value:Y,placeholder:X,searchPlaceholder:Z,noMatches:Q,capabilitiesFilter:`vision`,allowEmpty:!0,emptyLabel:oe,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:se,onChange:ce}),t[57]=Y,t[58]=X,t[59]=Z,t[60]=Q,t[61]=oe,t[62]=se,t[63]=ce,t[64]=le):le=t[64];let ue;t[65]!==J||t[66]!==le?(ue=(0,F.jsxs)(`div`,{children:[J,le]}),t[65]=J,t[66]=le,t[67]=ue):ue=t[67];let de=i?`图片生成模型`:`Image generation model`,fe;t[68]===de?fe=t[69]:(fe=(0,F.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:de}),t[68]=de,t[69]=fe);let pe=n.models.imageGeneration?.primary??``,me=i?`关闭图片生成`:`Image generation off`,he=i?`搜索图片模型或服务商`:`Search image models or providers`,ge=i?`没有可用的图片生成模型`:`No image generation models available`,_e=i?`关闭图片生成`:`Image generation off`,ve=i?`图片生成模型`:`Image generation model`,$;t[70]!==n||t[71]!==r?($=e=>{let t={...n.models};e?t.imageGeneration={primary:e,fallbacks:t.imageGeneration?.fallbacks??[],timeoutMs:t.imageGeneration?.timeoutMs,autoProviderFallback:t.imageGeneration?.autoProviderFallback??!0}:delete t.imageGeneration,r({...n,models:t})},t[70]=n,t[71]=r,t[72]=$):$=t[72];let ye;t[73]!==_||t[74]!==c.error||t[75]!==c.isLoading||t[76]!==pe||t[77]!==me||t[78]!==he||t[79]!==ge||t[80]!==_e||t[81]!==ve||t[82]!==$?(ye=(0,F.jsx)(T,{value:pe,models:_,modelsLoading:c.isLoading,modelsError:c.error,placeholder:me,searchPlaceholder:he,noMatches:ge,allowEmpty:!0,emptyLabel:_e,contentAlign:`start`,className:`mt-2 w-full`,ariaLabel:ve,onChange:$}),t[73]=_,t[74]=c.error,t[75]=c.isLoading,t[76]=pe,t[77]=me,t[78]=he,t[79]=ge,t[80]=_e,t[81]=ve,t[82]=$,t[83]=ye):ye=t[83];let be;t[84]!==fe||t[85]!==ye?(be=(0,F.jsxs)(`div`,{children:[fe,ye]}),t[84]=fe,t[85]=ye,t[86]=be):be=t[86];let xe;t[87]!==ue||t[88]!==be?(xe=(0,F.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-2`,children:[ue,be]}),t[87]=ue,t[88]=be,t[89]=xe):xe=t[89];let Se;t[90]!==n||t[91]!==r||t[92]!==i?(Se=n.models.imageGeneration?(0,F.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,F.jsx)(`input`,{type:`number`,min:1,className:`${H} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,F.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,F.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,F.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[!0,!1].map(e=>(0,F.jsx)(f,{variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]}):null,t[90]=n,t[91]=r,t[92]=i,t[93]=Se):Se=t[93];let Ce;t[94]!==R||t[95]!==G||t[96]!==xe||t[97]!==Se?(Ce=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[R,G,xe,Se]}),t[94]=R,t[95]=G,t[96]=xe,t[97]=Se,t[98]=Ce):Ce=t[98];let we;t[99]===i?we=t[100]:(we=(0,F.jsx)(B,{zh:i}),t[99]=i,t[100]=we);let Te=i?`按任务选择模型`:`Route by task`,Ee;t[101]===Te?Ee=t[102]:(Ee=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:Te}),t[101]=Te,t[102]=Ee);let De=i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`,Oe;t[103]===De?Oe=t[104]:(Oe=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:De}),t[103]=De,t[104]=Oe);let ke;t[105]!==v||t[106]!==n.models.intents||t[107]!==b||t[108]!==i?(ke=V.map(e=>(0,F.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,F.jsxs)(`div`,{className:`mb-3`,children:[(0,F.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:v[e][0]}),(0,F.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:v[e][1]})]}),(0,F.jsx)(T,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${v[e][0]}模型`:`${v[e][0]} model`,onChange:t=>b(e,t)})]},e)),t[105]=v,t[106]=n.models.intents,t[107]=b,t[108]=i,t[109]=ke):ke=t[109];let Ae;t[110]===ke?Ae=t[111]:(Ae=(0,F.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:ke}),t[110]=ke,t[111]=Ae);let je;t[112]!==Ee||t[113]!==Oe||t[114]!==Ae?(je=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[Ee,Oe,Ae]}),t[112]=Ee,t[113]=Oe,t[114]=Ae,t[115]=je):je=t[115];let Me;return t[116]!==I||t[117]!==Ce||t[118]!==we||t[119]!==je?(Me=(0,F.jsxs)(`div`,{className:`space-y-5`,children:[I,Ce,we,je]}),t[116]=I,t[117]=Ce,t[118]=we,t[119]=je,t[120]=Me):Me=t[120],Me}function K(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}var q=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`;function J(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function Y(e){let t=(0,ie.c)(151),{draft:n,setDraft:r,zh:i}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=d(`agent-defaults-workflows`,te,o),l;t[1]===s.data?l=t[2]:(l=s.data??[],t[1]=s.data,t[2]=l);let u;t[3]===l?u=t[4]:(u=l.map(X),t[3]=l,t[4]=u);let p=u,m=n.workflows.allowed===void 0,h;t[5]!==n||t[6]!==r?(h=(e,t)=>{let i=n.workflows.allowed??[],a=t?[...new Set([...i,e])]:i.filter(t=>t!==e);r({...n,workflows:{...n.workflows,allowed:a}})},t[5]=n,t[6]=r,t[7]=h):h=t[7];let g=h,_=i?`执行限制`:`Execution limits`,v;t[8]===_?v=t[9]:(v=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:_}),t[8]=_,t[9]=v);let y=i?`为所有智能体设置安全上限;留空时使用系统默认值。`:`Set safe upper bounds for every agent. Empty fields use system defaults.`,b;t[10]===y?b=t[11]:(b=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[10]=y,t[11]=b);let x=i?`每次运行最多轮数`:`Maximum turns per run`,S=n.runtime.maxTurns??``,C=i?`系统默认`:`System default`,w;t[12]!==n||t[13]!==r?(w=e=>r({...n,runtime:{...n.runtime,maxTurns:J(e.target.value)}}),t[12]=n,t[13]=r,t[14]=w):w=t[14];let T;t[15]!==S||t[16]!==C||t[17]!==w?(T=(0,F.jsx)(`input`,{type:`number`,min:1,value:S,placeholder:C,onChange:w,className:`${q} mt-2`}),t[15]=S,t[16]=C,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,F.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i?`单轮超时(毫秒)`:`Turn timeout (ms)`,O=n.runtime.timeoutMs??``,ee=i?`系统默认`:`System default`,k;t[22]!==n||t[23]!==r?(k=e=>r({...n,runtime:{...n.runtime,timeoutMs:J(e.target.value)}}),t[22]=n,t[23]=r,t[24]=k):k=t[24];let A;t[25]!==O||t[26]!==ee||t[27]!==k?(A=(0,F.jsx)(`input`,{type:`number`,min:1,value:O,placeholder:ee,onChange:k,className:`${q} mt-2`}),t[25]=O,t[26]=ee,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==D||t[30]!==A?(j=(0,F.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[D,A]}),t[29]=D,t[30]=A,t[31]=j):j=t[31];let M=i?`每轮最多工具失败次数`:`Maximum tool failures per turn`,ne=n.runtime.maxToolFailuresPerTurn??``,N=i?`系统默认`:`System default`,re;t[32]!==n||t[33]!==r?(re=e=>r({...n,runtime:{...n.runtime,maxToolFailuresPerTurn:J(e.target.value)}}),t[32]=n,t[33]=r,t[34]=re):re=t[34];let P;t[35]!==ne||t[36]!==N||t[37]!==re?(P=(0,F.jsx)(`input`,{type:`number`,min:1,value:ne,placeholder:N,onChange:re,className:`${q} mt-2`}),t[35]=ne,t[36]=N,t[37]=re,t[38]=P):P=t[38];let I;t[39]!==M||t[40]!==P?(I=(0,F.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[M,P]}),t[39]=M,t[40]=P,t[41]=I):I=t[41];let L;t[42]!==E||t[43]!==j||t[44]!==I?(L=(0,F.jsxs)(`div`,{className:`mt-5 grid gap-4 md:grid-cols-3`,children:[E,j,I]}),t[42]=E,t[43]=j,t[44]=I,t[45]=L):L=t[45];let R;t[46]!==L||t[47]!==v||t[48]!==b?(R=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[v,b,L]}),t[46]=L,t[47]=v,t[48]=b,t[49]=R):R=t[49];let z=i?`提示词缓存`:`Prompt cache`,B;t[50]===z?B=t[51]:(B=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:z}),t[50]=z,t[51]=B);let V=i?`复用稳定的上下文以降低响应延迟和模型费用。`:`Reuse stable context to reduce latency and model cost.`,H;t[52]===V?H=t[53]:(H=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:V}),t[52]=V,t[53]=H);let U=i?`缓存模式`:`Cache mode`,W;t[54]===U?W=t[55]:(W=(0,F.jsx)(`span`,{children:U}),t[54]=U,t[55]=W);let ae;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(ae=[`auto`,`off`],t[56]=ae):ae=t[56];let G;t[57]!==n||t[58]!==r||t[59]!==i?(G=(0,F.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:ae.map(e=>(0,F.jsx)(f,{variant:n.runtime.promptCache?.mode===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:e,lifetime:n.runtime.promptCache?.lifetime??`short`}}}),children:e===`auto`?i?`自动`:`Automatic`:i?`关闭`:`Off`},e))}),t[57]=n,t[58]=r,t[59]=i,t[60]=G):G=t[60];let K;t[61]!==W||t[62]!==G?(K=(0,F.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[W,G]}),t[61]=W,t[62]=G,t[63]=K):K=t[63];let Y;t[64]!==n||t[65]!==r||t[66]!==i?(Y=n.runtime.promptCache?.mode===`auto`?(0,F.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,F.jsx)(`span`,{children:i?`缓存周期`:`Cache lifetime`}),(0,F.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[`short`,`long`].map(e=>(0,F.jsx)(f,{variant:n.runtime.promptCache?.lifetime===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,runtime:{...n.runtime,promptCache:{mode:`auto`,lifetime:e}}}),children:e===`short`?i?`短期`:`Short`:i?`长期`:`Long`},e))})]}):null,t[64]=n,t[65]=r,t[66]=i,t[67]=Y):Y=t[67];let Z;t[68]!==K||t[69]!==Y?(Z=(0,F.jsxs)(`div`,{className:`mt-5 grid gap-4 sm:grid-cols-2`,children:[K,Y]}),t[68]=K,t[69]=Y,t[70]=Z):Z=t[70];let Q;t[71]!==B||t[72]!==H||t[73]!==Z?(Q=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[B,H,Z]}),t[71]=B,t[72]=H,t[73]=Z,t[74]=Q):Q=t[74];let oe=i?`工作流`:`Workflows`,se;t[75]===oe?se=t[76]:(se=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:oe}),t[75]=oe,t[76]=se);let ce=i?`设置默认工作流,并决定智能体可以调用哪些工作流。`:`Set a default workflow and control which workflows agents may invoke.`,le;t[77]===ce?le=t[78]:(le=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ce}),t[77]=ce,t[78]=le);let ue=i?`默认工作流`:`Default workflow`,de;t[79]===ue?de=t[80]:(de=(0,F.jsx)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:ue}),t[79]=ue,t[80]=de);let fe=n.workflows.default??``,pe=s.isLoading?i?`正在加载…`:`Loading…`:i?`不设置默认工作流`:`No default workflow`,me=i?`不设置默认工作流`:`No default workflow`,he=i?`默认工作流`:`Default workflow`,ge;t[81]!==n||t[82]!==r?(ge=e=>r({...n,workflows:{...n.workflows,default:e||void 0}}),t[81]=n,t[82]=r,t[83]=ge):ge=t[83];let _e;t[84]!==fe||t[85]!==pe||t[86]!==me||t[87]!==he||t[88]!==ge||t[89]!==p||t[90]!==s.isLoading?(_e=(0,F.jsx)(a,{value:fe,options:p,placeholder:pe,emptyLabel:me,disabled:s.isLoading,ariaLabel:he,onChange:ge,triggerClassName:`mt-2`}),t[84]=fe,t[85]=pe,t[86]=me,t[87]=he,t[88]=ge,t[89]=p,t[90]=s.isLoading,t[91]=_e):_e=t[91];let ve;t[92]!==de||t[93]!==_e?(ve=(0,F.jsxs)(`div`,{className:`mt-5 max-w-xl`,children:[de,_e]}),t[92]=de,t[93]=_e,t[94]=ve):ve=t[94];let $;t[95]===s.error?$=t[96]:($=s.error?(0,F.jsx)(`p`,{className:`mt-3 text-sm text-red-600`,children:s.error instanceof Error?s.error.message:String(s.error)}):null,t[95]=s.error,t[96]=$);let ye=i?`允许调用的工作流`:`Allowed workflows`,be;t[97]===ye?be=t[98]:(be=(0,F.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:ye}),t[97]=ye,t[98]=be);let xe;t[99]!==n||t[100]!==r?(xe=()=>r({...n,workflows:{...n.workflows,allowed:void 0}}),t[99]=n,t[100]=r,t[101]=xe):xe=t[101];let Se=m?`bg-accent-soft shadow-surface`:`hover:bg-surface-hover`,Ce;t[102]===Se?Ce=t[103]:(Ce=c(`rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Se),t[102]=Se,t[103]=Ce);let we=i?`允许全部工作流`:`Allow every workflow`,Te;t[104]===we?Te=t[105]:(Te=(0,F.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:we}),t[104]=we,t[105]=Te);let Ee=i?`新增工作流也会自动可用。`:`New workflows become available automatically.`,De;t[106]===Ee?De=t[107]:(De=(0,F.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Ee}),t[106]=Ee,t[107]=De);let Oe;t[108]!==xe||t[109]!==Ce||t[110]!==Te||t[111]!==De?(Oe=(0,F.jsxs)(`button`,{type:`button`,onClick:xe,className:Ce,children:[Te,De]}),t[108]=xe,t[109]=Ce,t[110]=Te,t[111]=De,t[112]=Oe):Oe=t[112];let ke;t[113]!==n||t[114]!==r?(ke=()=>r({...n,workflows:{...n.workflows,allowed:[]}}),t[113]=n,t[114]=r,t[115]=ke):ke=t[115];let Ae=m?`hover:bg-surface-hover`:`bg-accent-soft shadow-surface`,je;t[116]===Ae?je=t[117]:(je=c(`rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,Ae),t[116]=Ae,t[117]=je);let Me=i?`只允许选中的工作流`:`Allow selected workflows only`,Ne;t[118]===Me?Ne=t[119]:(Ne=(0,F.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:Me}),t[118]=Me,t[119]=Ne);let Pe=i?`未选中的工作流不能被调用。`:`Unselected workflows cannot be invoked.`,Fe;t[120]===Pe?Fe=t[121]:(Fe=(0,F.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:Pe}),t[120]=Pe,t[121]=Fe);let Ie;t[122]!==ke||t[123]!==je||t[124]!==Ne||t[125]!==Fe?(Ie=(0,F.jsxs)(`button`,{type:`button`,onClick:ke,className:je,children:[Ne,Fe]}),t[122]=ke,t[123]=je,t[124]=Ne,t[125]=Fe,t[126]=Ie):Ie=t[126];let Le;t[127]!==Oe||t[128]!==Ie?(Le=(0,F.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[Oe,Ie]}),t[127]=Oe,t[128]=Ie,t[129]=Le):Le=t[129];let Re;t[130]!==m||t[131]!==n.workflows.allowed||t[132]!==g||t[133]!==s.data||t[134]!==s.isLoading||t[135]!==i?(Re=m?null:(0,F.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1 rounded-xl bg-surface-base/45 p-1 [&>label]:rounded-lg [&>label]:bg-surface-panel/55`,children:[(s.data??[]).map(e=>(0,F.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:n.workflows.allowed?.includes(e.id)??!1,onChange:t=>g(e.id,t.target.checked),className:`mt-0.5 size-4 accent-[var(--color-accent)]`}),(0,F.jsxs)(`span`,{children:[(0,F.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:e.title||e.name}),e.description?(0,F.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e.description}):null]})]},e.id)),(s.data??[]).length===0&&!s.isLoading?(0,F.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`还没有工作流。`:`No workflows yet.`}):null]}),t[130]=m,t[131]=n.workflows.allowed,t[132]=g,t[133]=s.data,t[134]=s.isLoading,t[135]=i,t[136]=Re):Re=t[136];let ze;t[137]!==be||t[138]!==Le||t[139]!==Re?(ze=(0,F.jsxs)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:[be,Le,Re]}),t[137]=be,t[138]=Le,t[139]=Re,t[140]=ze):ze=t[140];let Be;t[141]!==se||t[142]!==le||t[143]!==ve||t[144]!==$||t[145]!==ze?(Be=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[se,le,ve,$,ze]}),t[141]=se,t[142]=le,t[143]=ve,t[144]=$,t[145]=ze,t[146]=Be):Be=t[146];let Ve;return t[147]!==R||t[148]!==Q||t[149]!==Be?(Ve=(0,F.jsxs)(`div`,{className:`space-y-5`,children:[R,Q,Be]}),t[147]=R,t[148]=Q,t[149]=Be,t[150]=Ve):Ve=t[150],Ve}function X(e){return{value:e.id,label:e.title||e.name}}function Z(e){return[...new Set(e)].sort()}function Q(e){let t=(0,ie.c)(99),{draft:n,setDraft:r,zh:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},t[0]=a):a=t[0];let{data:s,error:l,isLoading:u}=d(`agent-defaults-skills-catalog`,S,a),[f,p]=(0,P.useState)(``),m=n.skills.mode===`selected`?n.skills.include:n.skills.exclude;s?.catalog;let h;if(t[1]!==m||t[2]!==s?.catalog||t[3]!==f){let e=[...s?.catalog??[]],n=new Set(e.map(ce));for(let t of m)n.has(t)||e.push({name:t,description:``,enabled:!0});let r=f.trim().toLowerCase();h=e.filter(e=>!r||`${e.name} ${e.description}`.toLowerCase().includes(r)).sort(se),t[1]=m,t[2]=s?.catalog,t[3]=f,t[4]=h}else h=t[4];let g=h,v;t[5]!==n.skills.exclude||t[6]!==n.skills.include||t[7]!==n.skills.mode?(v=e=>n.skills.mode===`selected`?n.skills.include.includes(e):!n.skills.exclude.includes(e),t[5]=n.skills.exclude,t[6]=n.skills.include,t[7]=n.skills.mode,t[8]=v):v=t[8];let y=v,b;t[9]!==n||t[10]!==r?(b=e=>{if(n.skills.mode===`selected`){let t=n.skills.include.includes(e)?n.skills.include.filter(t=>t!==e):Z([...n.skills.include,e]);r({...n,skills:{mode:`selected`,include:t}});return}let t=n.skills.exclude.includes(e)?n.skills.exclude.filter(t=>t!==e):Z([...n.skills.exclude,e]);r({...n,skills:{mode:`all-enabled`,exclude:t}})},t[9]=n,t[10]=r,t[11]=b):b=t[11];let C=b,w;t[12]===s?.catalog?w=t[13]:(w=s?.catalog??[],t[12]=s?.catalog,t[13]=w);let T;if(t[14]!==y||t[15]!==w){let e;t[17]===y?e=t[18]:(e=e=>e.enabled&&y(e.name),t[17]=y,t[18]=e),T=w.filter(e),t[14]=y,t[15]=w,t[16]=T}else T=t[16];let E=T.length,D=i?`技能策略`:`Skill policy`,O;t[19]===D?O=t[20]:(O=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:D}),t[19]=D,t[20]=O);let ee=i?`决定所有智能体默认可以使用哪些技能。`:`Choose which skills every agent can discover and use by default.`,k;t[21]===ee?k=t[22]:(k=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ee}),t[21]=ee,t[22]=k);let te;t[23]!==n||t[24]!==r?(te=()=>r({...n,skills:{mode:`all-enabled`,exclude:[]}}),t[23]=n,t[24]=r,t[25]=te):te=t[25];let A=n.skills.mode===`all-enabled`?`bg-accent-soft shadow-surface`:`hover:bg-surface-hover`,j;t[26]===A?j=t[27]:(j=c(`flex items-start gap-3 rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,A),t[26]=A,t[27]=j);let M;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,F.jsx)(o,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[28]=M):M=t[28];let ne=i?`使用所有已启用技能`:`Use every enabled skill`,N;t[29]===ne?N=t[30]:(N=(0,F.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:ne}),t[29]=ne,t[30]=N);let re=i?`推荐。以后启用的新技能也会自动可用,可单独排除。`:`Recommended. Newly enabled skills become available automatically; exclude exceptions below.`,I;t[31]===re?I=t[32]:(I=(0,F.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:re}),t[31]=re,t[32]=I);let L;t[33]!==N||t[34]!==I?(L=(0,F.jsxs)(`span`,{children:[N,I]}),t[33]=N,t[34]=I,t[35]=L):L=t[35];let R;t[36]!==te||t[37]!==j||t[38]!==L?(R=(0,F.jsxs)(`button`,{type:`button`,onClick:te,className:j,children:[M,L]}),t[36]=te,t[37]=j,t[38]=L,t[39]=R):R=t[39];let z;t[40]!==n||t[41]!==r?(z=()=>r({...n,skills:{mode:`selected`,include:[]}}),t[40]=n,t[41]=r,t[42]=z):z=t[42];let B=n.skills.mode===`selected`?`bg-accent-soft shadow-surface`:`hover:bg-surface-hover`,V;t[43]===B?V=t[44]:(V=c(`flex items-start gap-3 rounded-xl bg-surface-base/55 p-4 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,B),t[43]=B,t[44]=V);let H;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,F.jsx)(x,{className:`mt-0.5 size-5 shrink-0 text-accent`}),t[45]=H):H=t[45];let U=i?`只使用选中的技能`:`Use selected skills only`,W;t[46]===U?W=t[47]:(W=(0,F.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:U}),t[46]=U,t[47]=W);let ae=i?`适合严格受控的环境;新增技能不会自动加入。`:`For tightly controlled environments; new skills are not added automatically.`,G;t[48]===ae?G=t[49]:(G=(0,F.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:ae}),t[48]=ae,t[49]=G);let K;t[50]!==W||t[51]!==G?(K=(0,F.jsxs)(`span`,{children:[W,G]}),t[50]=W,t[51]=G,t[52]=K):K=t[52];let q;t[53]!==z||t[54]!==V||t[55]!==K?(q=(0,F.jsxs)(`button`,{type:`button`,onClick:z,className:V,children:[H,K]}),t[53]=z,t[54]=V,t[55]=K,t[56]=q):q=t[56];let J;t[57]!==R||t[58]!==q?(J=(0,F.jsxs)(`div`,{className:`mt-5 grid gap-3 sm:grid-cols-2`,children:[R,q]}),t[57]=R,t[58]=q,t[59]=J):J=t[59];let Y;t[60]!==k||t[61]!==J||t[62]!==O?(Y=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[O,k,J]}),t[60]=k,t[61]=J,t[62]=O,t[63]=Y):Y=t[63];let X=n.skills.mode===`selected`?i?`选择可用技能`:`Select available skills`:i?`管理例外`:`Manage exceptions`,Q;t[64]===X?Q=t[65]:(Q=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:X}),t[64]=X,t[65]=Q);let le=i?`当前默认可用 ${E} 个技能。`:`${E} skills are available by default.`,ue;t[66]===le?ue=t[67]:(ue=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:le}),t[66]=le,t[67]=ue);let de;t[68]!==Q||t[69]!==ue?(de=(0,F.jsxs)(`div`,{children:[Q,ue]}),t[68]=Q,t[69]=ue,t[70]=de):de=t[70];let fe=i?`搜索技能`:`Search skills`,pe;t[71]===fe?pe=t[72]:(pe=(0,F.jsx)(`span`,{className:`sr-only`,children:fe}),t[71]=fe,t[72]=pe);let me;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[73]=me):me=t[73];let he;t[74]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>p(e.target.value),t[74]=he):he=t[74];let ge=i?`搜索技能`:`Search skills`,_e;t[75]!==f||t[76]!==ge?(_e=(0,F.jsx)(`input`,{type:`search`,value:f,onChange:he,placeholder:ge,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[75]=f,t[76]=ge,t[77]=_e):_e=t[77];let ve;t[78]!==pe||t[79]!==_e?(ve=(0,F.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[pe,me,_e]}),t[78]=pe,t[79]=_e,t[80]=ve):ve=t[80];let $;t[81]!==de||t[82]!==ve?($=(0,F.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3`,children:[de,ve]}),t[81]=de,t[82]=ve,t[83]=$):$=t[83];let ye;t[84]===l?ye=t[85]:(ye=l?(0,F.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l instanceof Error?l.message:String(l)}):null,t[84]=l,t[85]=ye);let be;t[86]!==y||t[87]!==u||t[88]!==g||t[89]!==C||t[90]!==i?(be=u?(0,F.jsx)(`div`,{className:`mt-4 space-y-2`,children:[0,1,2,3].map(oe)}):(0,F.jsxs)(`div`,{className:`mt-4 flex max-h-[32rem] flex-col gap-1 overflow-y-auto rounded-xl bg-surface-base/45 p-1 [&>label]:rounded-lg [&>label]:bg-surface-panel/55`,children:[g.map(e=>{let t=y(e.name);return(0,F.jsxs)(`label`,{className:c(`flex cursor-pointer items-start gap-3 px-4 py-3 hover:bg-surface-hover/60`,!e.enabled&&`cursor-not-allowed opacity-55`),children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:t,disabled:!e.enabled,onChange:()=>C(e.name),className:`mt-0.5 size-4 rounded border-edge accent-[var(--color-accent)]`}),(0,F.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.name}),e.enabled?null:(0,F.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] text-fg-muted`,children:i?`全局未启用`:`Disabled globally`})]}),e.description?(0,F.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]})]},e.name)}),g.length===0?(0,F.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-fg-muted`,children:i?`没有匹配的技能。`:`No matching skills.`}):null]}),t[86]=y,t[87]=u,t[88]=g,t[89]=C,t[90]=i,t[91]=be):be=t[91];let xe;t[92]!==$||t[93]!==ye||t[94]!==be?(xe=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[$,ye,be]}),t[92]=$,t[93]=ye,t[94]=be,t[95]=xe):xe=t[95];let Se;return t[96]!==Y||t[97]!==xe?(Se=(0,F.jsxs)(`div`,{className:`space-y-5`,children:[Y,xe]}),t[96]=Y,t[97]=xe,t[98]=Se):Se=t[98],Se}function oe(e){return(0,F.jsx)(m,{className:`h-14 rounded-xl`},e)}function se(e,t){return e.name.localeCompare(t.name)}function ce(e){return e.name}function le(e){let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>0?t:void 0}function ue(e){let t=(0,ie.c)(92),{draft:n,setDraft:r,builtinTools:i,zh:a}=e,[o,s]=(0,P.useState)(``),[l,u]=(0,P.useState)(`all`),[d,p]=(0,P.useState)(),m;t[0]===i?m=t[1]:(m=new Map(i.map(fe)),t[0]=i,t[1]=m);let h=m,g;t[2]!==i||t[3]!==n.tools?(g=[...new Set([...i.map(de),...Object.keys(n.tools)])].sort(),t[2]=i,t[3]=n.tools,t[4]=g):g=t[4];let v=g,y;if(t[5]!==v||t[6]!==n.tools){let e;t[8]===n.tools?e=t[9]:(e=e=>(n.tools[e]?.mode??`allow`)===`allow`,t[8]=n.tools,t[9]=e),y=v.filter(e),t[5]=v,t[6]=n.tools,t[7]=y}else y=t[7];let b=y.length,x;if(t[10]!==v||t[11]!==n.tools){let e;t[13]===n.tools?e=t[14]:(e=e=>n.tools[e]?.mode===`ask`,t[13]=n.tools,t[14]=e),x=v.filter(e),t[10]=v,t[11]=n.tools,t[12]=x}else x=t[12];let S=x.length,C;if(t[15]!==v||t[16]!==n.tools){let e;t[18]===n.tools?e=t[19]:(e=e=>n.tools[e]?.mode===`deny`,t[18]=n.tools,t[19]=e),C=v.filter(e),t[15]=v,t[16]=n.tools,t[17]=C}else C=t[17];let w;t[20]!==y.length||t[21]!==x.length||t[22]!==C.length?(w={allow:b,ask:S,deny:C.length},t[20]=y.length,t[21]=x.length,t[22]=C.length,t[23]=w):w=t[23];let T=w,E;if(t[24]!==v||t[25]!==h||t[26]!==n.tools||t[27]!==l||t[28]!==o){let e=o.trim().toLowerCase();E=v.filter(t=>{let r=n.tools[t]?.mode??`allow`,i=h.get(t),a=`${t} ${i?.en??``} ${i?.zh??``}`.toLowerCase();return(!e||a.includes(e))&&(l===`all`||r===l)}),t[24]=v,t[25]=h,t[26]=n.tools,t[27]=l,t[28]=o,t[29]=E}else E=t[29];let D=E,O;t[30]!==n||t[31]!==r?(O=(e,t)=>{let i=n.tools[e]??{mode:`allow`};r({...n,tools:{...n.tools,[e]:{...i,...t}}})},t[30]=n,t[31]=r,t[32]=O):O=t[32];let k=O,te=a?`全部 ${v.length}`:`All ${v.length}`,A;t[33]===te?A=t[34]:(A={id:`all`,label:te},t[33]=te,t[34]=A);let j=a?`允许 ${T.allow}`:`Allow ${T.allow}`,M;t[35]===j?M=t[36]:(M={id:`allow`,label:j},t[35]=j,t[36]=M);let ne=a?`询问 ${T.ask}`:`Ask ${T.ask}`,N;t[37]===ne?N=t[38]:(N={id:`ask`,label:ne},t[37]=ne,t[38]=N);let re=a?`禁用 ${T.deny}`:`Deny ${T.deny}`,I;t[39]===re?I=t[40]:(I={id:`deny`,label:re},t[39]=re,t[40]=I);let L;t[41]!==A||t[42]!==M||t[43]!==N||t[44]!==I?(L=[A,M,N,I],t[41]=A,t[42]=M,t[43]=N,t[44]=I,t[45]=L):L=t[45];let R=L,z=a?`默认工具权限`:`Default tool permissions`,B;t[46]===z?B=t[47]:(B=(0,F.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:z}),t[46]=z,t[47]=B);let V=a?`允许:直接执行;询问:执行前确认;禁用:智能体无法使用。`:`Allow runs directly, Ask requires confirmation, and Deny makes the tool unavailable.`,H;t[48]===V?H=t[49]:(H=(0,F.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:V}),t[48]=V,t[49]=H);let U;t[50]!==B||t[51]!==H?(U=(0,F.jsxs)(`div`,{children:[B,H]}),t[50]=B,t[51]=H,t[52]=U):U=t[52];let W;t[53]!==l||t[54]!==R?(W=(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1 rounded-xl bg-surface-panel p-1`,children:R.map(e=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>u(e.id),className:c(`rounded-lg px-3 py-1.5 text-xs font-medium`,l===e.id?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`),children:e.label},e.id))}),t[53]=l,t[54]=R,t[55]=W):W=t[55];let ae=a?`搜索工具`:`Search tools`,G;t[56]===ae?G=t[57]:(G=(0,F.jsx)(`span`,{className:`sr-only`,children:ae}),t[56]=ae,t[57]=G);let K;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,F.jsx)(_,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`}),t[58]=K):K=t[58];let q;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>s(e.target.value),t[59]=q):q=t[59];let J=a?`搜索工具`:`Search tools`,Y;t[60]!==o||t[61]!==J?(Y=(0,F.jsx)(`input`,{type:`search`,value:o,onChange:q,placeholder:J,className:`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg outline-none focus:border-accent`}),t[60]=o,t[61]=J,t[62]=Y):Y=t[62];let X;t[63]!==G||t[64]!==Y?(X=(0,F.jsxs)(`label`,{className:`relative block w-full sm:w-72`,children:[G,K,Y]}),t[63]=G,t[64]=Y,t[65]=X):X=t[65];let Z;t[66]!==W||t[67]!==X?(Z=(0,F.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center justify-between gap-3`,children:[W,X]}),t[66]=W,t[67]=X,t[68]=Z):Z=t[68];let Q;if(t[69]!==h||t[70]!==n.tools||t[71]!==d||t[72]!==k||t[73]!==D||t[74]!==a){let e;t[76]!==h||t[77]!==n.tools||t[78]!==d||t[79]!==k||t[80]!==a?(e=e=>{let t=n.tools[e]??{mode:`allow`},r=h.get(e),i=d===e;return(0,F.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`code`,{className:`text-xs font-medium text-fg`,children:e}),r?(0,F.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:a?r.zh:r.en}):null]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`flex rounded-lg bg-surface-base p-1`,children:[`allow`,`ask`,`deny`].map(n=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>k(e,{mode:n}),className:c(`rounded-md px-2.5 py-1 text-xs font-medium capitalize`,t.mode===n?`bg-accent text-on-accent`:`text-fg-muted hover:text-fg`),children:n===`allow`?a?`允许`:`Allow`:n===`ask`?a?`询问`:`Ask`:a?`禁用`:`Deny`},n))}),(0,F.jsx)(f,{variant:`ghost`,className:`px-2 py-1`,"aria-label":a?`${e} 调用限制`:`${e} call limits`,onClick:()=>p(i?void 0:e),children:(0,F.jsx)(ee,{className:`size-4`})})]})]}),i?(0,F.jsxs)(`div`,{className:`mt-3 grid gap-3 rounded-lg bg-surface-base p-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`每轮最多调用次数`:`Maximum calls per turn`,(0,F.jsx)(`input`,{type:`number`,min:1,value:t.maxCallsPerTurn??``,placeholder:a?`不限制`:`Unlimited`,onChange:t=>k(e,{maxCallsPerTurn:le(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]}),(0,F.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a?`单次超时(毫秒)`:`Call timeout (ms)`,(0,F.jsx)(`input`,{type:`number`,min:1,value:t.timeoutMs??``,placeholder:a?`使用系统默认值`:`Use system default`,onChange:t=>k(e,{timeoutMs:le(t.target.value)}),className:`mt-2 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent`})]})]}):null]},e)},t[76]=h,t[77]=n.tools,t[78]=d,t[79]=k,t[80]=a,t[81]=e):e=t[81],Q=D.map(e),t[69]=h,t[70]=n.tools,t[71]=d,t[72]=k,t[73]=D,t[74]=a,t[75]=Q}else Q=t[75];let oe;t[82]!==D.length||t[83]!==a?(oe=D.length===0?(0,F.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-fg-muted`,children:a?`没有匹配的工具。`:`No matching tools.`}):null,t[82]=D.length,t[83]=a,t[84]=oe):oe=t[84];let se;t[85]!==Q||t[86]!==oe?(se=(0,F.jsxs)(`div`,{className:`mt-4 flex max-h-[38rem] flex-col gap-1 overflow-y-auto rounded-xl bg-surface-base/45 p-1 [&>*]:rounded-lg [&>*]:bg-surface-panel/55`,children:[Q,oe]}),t[85]=Q,t[86]=oe,t[87]=se):se=t[87];let ce;return t[88]!==U||t[89]!==Z||t[90]!==se?(ce=(0,F.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[U,Z,se]}),t[88]=U,t[89]=Z,t[90]=se,t[91]=ce):ce=t[91],ce}function de(e){return e.id}function fe(e){return[e.id,e.description]}function pe(){let e=(0,ie.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsxs)(j,{gap:`gap-5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(m,{className:`h-7 w-56`}),(0,F.jsx)(m,{className:`h-4 w-96 max-w-full`})]}),(0,F.jsx)(m,{className:`h-9 w-28`})]}),(0,F.jsx)(m,{className:`h-20 rounded-2xl`}),(0,F.jsx)(m,{className:`h-12 rounded-xl`}),(0,F.jsx)(m,{className:`h-72 rounded-2xl`})]}),e[0]=t):t=e[0],t}function me(e){let t=(0,ie.c)(67),{initial:n,builtinTools:r,zh:i}=e,[a,o]=(0,P.useState)(`models`),s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[l,u]=(0,P.useState)(s),d;t[2]===n?d=t[3]:(d=()=>structuredClone(n),t[2]=n,t[3]=d);let[p,m]=(0,P.useState)(d),h;t[4]===l?h=t[5]:(h=JSON.stringify(l),t[4]=l,t[5]=h);let g;t[6]===p?g=t[7]:(g=JSON.stringify(p),t[6]=p,t[7]=g);let _=h!==g,y=i?`模型`:`Models`,x;t[8]===y?x=t[9]:(x={id:`models`,label:y,icon:C},t[8]=y,t[9]=x);let S=i?`技能`:`Skills`,w;t[10]===S?w=t[11]:(w={id:`skills`,label:S,icon:b},t[10]=S,t[11]=w);let T=i?`工具`:`Tools`,E;t[12]===T?E=t[13]:(E={id:`tools`,label:T,icon:k},t[12]=T,t[13]=E);let D=i?`运行`:`Runtime`,ee;t[14]===D?ee=t[15]:(ee={id:`runtime`,label:D,icon:v},t[14]=D,t[15]=ee);let te;t[16]!==E||t[17]!==ee||t[18]!==x||t[19]!==w?(te=[x,w,E,ee],t[16]=E,t[17]=ee,t[18]=x,t[19]=w,t[20]=te):te=t[20];let N=te,re;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(re=async e=>{let t=structuredClone(e),n=await O(t),r=structuredClone(n.defaults);u(e=>JSON.stringify(e)===JSON.stringify(t)?r:e),m(structuredClone(r))},t[21]=re):re=t[21];let I=re,L;t[22]!==_||t[23]!==l?(L={value:l,dirty:_,onSave:I,delayMs:0},t[22]=_,t[23]=l,t[24]=L):L=t[24];let R=ne(L),z=R.onBlurCapture,B=i?`智能体设置`:`Agent settings`,V;t[25]!==R.error||t[26]!==R.status?(V=(0,F.jsx)(M,{status:R.status,error:R.error}),t[25]=R.error,t[26]=R.status,t[27]=V):V=t[27];let H;t[28]!==B||t[29]!==V?(H=(0,F.jsx)(A,{title:B,actions:V}),t[28]=B,t[29]=V,t[30]=H):H=t[30];let U;t[31]!==R.error||t[32]!==R.retry||t[33]!==i?(U=R.error?(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:[(0,F.jsx)(`span`,{children:R.error}),(0,F.jsx)(f,{type:`button`,variant:`ghost`,className:`h-8 text-red-600`,onClick:R.retry,children:i?`重试`:`Retry`})]}):null,t[31]=R.error,t[32]=R.retry,t[33]=i,t[34]=U):U=t[34];let W=i?`默认配置分区`:`Default configuration sections`,ae;t[35]!==a||t[36]!==N?(ae=N.map(e=>{let{id:t,label:n,icon:r}=e;return(0,F.jsxs)(`button`,{type:`button`,"aria-pressed":a===t,onClick:()=>o(t),className:c(`flex min-w-0 items-center justify-center gap-2 rounded-lg px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,a===t?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),children:[(0,F.jsx)(r,{className:c(`size-4 shrink-0`,a===t?`text-accent`:`text-fg-subtle`)}),(0,F.jsx)(`span`,{className:`text-sm font-medium`,children:n})]},t)}),t[35]=a,t[36]=N,t[37]=ae):ae=t[37];let K;t[38]!==W||t[39]!==ae?(K=(0,F.jsx)(`nav`,{className:`grid grid-cols-2 gap-1 rounded-xl bg-surface-hover/20 p-1 lg:grid-cols-4`,"aria-label":W,children:ae}),t[38]=W,t[39]=ae,t[40]=K):K=t[40];let q;t[41]!==a||t[42]!==l||t[43]!==i?(q=a===`models`?(0,F.jsx)(G,{draft:l,setDraft:u,zh:i}):null,t[41]=a,t[42]=l,t[43]=i,t[44]=q):q=t[44];let J;t[45]!==a||t[46]!==l||t[47]!==i?(J=a===`skills`?(0,F.jsx)(Q,{draft:l,setDraft:u,zh:i}):null,t[45]=a,t[46]=l,t[47]=i,t[48]=J):J=t[48];let X;t[49]!==a||t[50]!==r||t[51]!==l||t[52]!==i?(X=a===`tools`?(0,F.jsx)(ue,{draft:l,setDraft:u,builtinTools:r,zh:i}):null,t[49]=a,t[50]=r,t[51]=l,t[52]=i,t[53]=X):X=t[53];let Z;t[54]!==a||t[55]!==l||t[56]!==i?(Z=a===`runtime`?(0,F.jsx)(Y,{draft:l,setDraft:u,zh:i}):null,t[54]=a,t[55]=l,t[56]=i,t[57]=Z):Z=t[57];let oe;return t[58]!==R.onBlurCapture||t[59]!==H||t[60]!==U||t[61]!==K||t[62]!==q||t[63]!==J||t[64]!==X||t[65]!==Z?(oe=(0,F.jsxs)(j,{gap:`gap-5`,onBlurCapture:z,children:[H,U,K,q,J,X,Z]}),t[58]=R.onBlurCapture,t[59]=H,t[60]=U,t[61]=K,t[62]=q,t[63]=J,t[64]=X,t[65]=Z,t[66]=oe):oe=t[66],oe}function he(){let e=(0,ie.c)(17),t=l(_e),n=u(ge)===`zh`,{data:r,error:i,isLoading:a,mutate:o}=d(t?`settings-agent-defaults`:null,E);if(!t){let t=n?`需要本机服务令牌。`:`Local service token required.`,r;return e[0]===t?r=e[1]:(r=(0,F.jsx)(j,{children:(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t})}),e[0]=t,e[1]=r),r}if(i&&!r){let t=String(i),r;e[2]===t?r=e[3]:(r=(0,F.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:t}),e[2]=t,e[3]=r);let a;e[4]===o?a=e[5]:(a=()=>void o(),e[4]=o,e[5]=a);let s=n?`重试`:`Retry`,c;e[6]!==a||e[7]!==s?(c=(0,F.jsx)(f,{onClick:a,children:s}),e[6]=a,e[7]=s,e[8]=c):c=e[8];let l;return e[9]!==r||e[10]!==c?(l=(0,F.jsxs)(j,{children:[r,c]}),e[9]=r,e[10]=c,e[11]=l):l=e[11],l}if(a||!r){let t;return e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)(pe,{}),e[12]=t):t=e[12],t}let s;return e[13]!==r.builtinTools||e[14]!==r.defaults||e[15]!==n?(s=(0,F.jsx)(me,{initial:r.defaults,builtinTools:r.builtinTools,zh:n}),e[13]=r.builtinTools,e[14]=r.defaults,e[15]=n,e[16]=s):s=e[16],s}function ge(e){return e.language}function _e(e){return e.conversationId}export{he as AgentDefaultsSettingsPanel};