@mgamadeus/ddd-agents 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +111 -8
  2. package/boundary.json +15 -1
  3. package/dist/admin-chat-widgets.js +158 -0
  4. package/dist/admin-chat-widgets.js.map +1 -0
  5. package/dist/admin.js +90 -63
  6. package/dist/admin.js.map +1 -1
  7. package/dist/chat.js +16 -16
  8. package/dist/chat.js.map +1 -1
  9. package/dist/chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js +304 -0
  10. package/dist/chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js.map +1 -0
  11. package/dist/chunks/{ConversationMarkdown-DNQcVuz-.js → ConversationMarkdown-W8NzeAT1.js} +5 -5
  12. package/dist/chunks/{ConversationMarkdown-DNQcVuz-.js.map → ConversationMarkdown-W8NzeAT1.js.map} +1 -1
  13. package/dist/chunks/{ConversationMessageInputComposerWidgets-BlpIule7.js → ConversationMessageInputComposerWidgets-BH7axorv.js} +6 -6
  14. package/dist/chunks/{ConversationMessageInputComposerWidgets-BlpIule7.js.map → ConversationMessageInputComposerWidgets-BH7axorv.js.map} +1 -1
  15. package/dist/chunks/{VoiceBarsIcon-eODB_UTI.js → VoiceBarsIcon-CT2HQSBH.js} +4 -4
  16. package/dist/chunks/{VoiceBarsIcon-eODB_UTI.js.map → VoiceBarsIcon-CT2HQSBH.js.map} +1 -1
  17. package/dist/chunks/{WebSearchResultsConversationWidget-l9Aek_lG.js → WebSearchResultsConversationWidget-BM624Fcx.js} +71 -62
  18. package/dist/chunks/WebSearchResultsConversationWidget-BM624Fcx.js.map +1 -0
  19. package/dist/chunks/{agents-http-trace-mappers-rsbGAf2_.js → agents-http-trace-mappers-CuGZOFu-.js} +53 -14
  20. package/dist/chunks/agents-http-trace-mappers-CuGZOFu-.js.map +1 -0
  21. package/dist/chunks/{browser-request-interception-D678IemW.js → browser-request-interception-BnOQWLaJ.js} +2 -2
  22. package/dist/chunks/{browser-request-interception-D678IemW.js.map → browser-request-interception-BnOQWLaJ.js.map} +1 -1
  23. package/dist/chunks/{canvas-label-context-C1Pc_Ldo.js → canvas-label-context-BKRsrpye.js} +3 -3
  24. package/dist/chunks/{canvas-label-context-C1Pc_Ldo.js.map → canvas-label-context-BKRsrpye.js.map} +1 -1
  25. package/dist/chunks/{canvas-reducers-BYArW_Ji.js → canvas-reducers-CZaOPvdt.js} +2 -2
  26. package/dist/chunks/{canvas-reducers-BYArW_Ji.js.map → canvas-reducers-CZaOPvdt.js.map} +1 -1
  27. package/dist/chunks/{canvasBodies-BpLPp-S8.js → canvasBodies-CMqo5eHg.js} +4 -4
  28. package/dist/chunks/{canvasBodies-BpLPp-S8.js.map → canvasBodies-CMqo5eHg.js.map} +1 -1
  29. package/dist/chunks/{canvasStorage-DSspwRMg.js → canvasStorage-ceJ7yaBd.js} +2 -2
  30. package/dist/chunks/{canvasStorage-DSspwRMg.js.map → canvasStorage-ceJ7yaBd.js.map} +1 -1
  31. package/dist/chunks/{content-from-unified-diff-DWyBHRSy.js → content-from-unified-diff-BKdgop63.js} +39 -5
  32. package/dist/chunks/content-from-unified-diff-BKdgop63.js.map +1 -0
  33. package/dist/chunks/{contract-DtFmOk91.js → contract-CQ6PO_e8.js} +2 -2
  34. package/dist/chunks/{contract-DtFmOk91.js.map → contract-CQ6PO_e8.js.map} +1 -1
  35. package/dist/chunks/{conversation-Cbrqtx-_.js → conversation-VosmRbsr.js} +4 -2
  36. package/dist/chunks/{conversation-Cbrqtx-_.js.map → conversation-VosmRbsr.js.map} +1 -1
  37. package/dist/chunks/conversation-trace-fVeh6Lg6.js.map +1 -1
  38. package/dist/chunks/{widget-name-resolver-DXIE9JUr.js → conversationWidgetRegistry-BW-U_RvC.js} +810 -530
  39. package/dist/chunks/conversationWidgetRegistry-BW-U_RvC.js.map +1 -0
  40. package/dist/chunks/{index-DZovGMpG.js → index-DAEGct6X.js} +61 -61
  41. package/dist/chunks/index-DAEGct6X.js.map +1 -0
  42. package/dist/chunks/{link-navigation-a_sRfmsj.js → link-navigation-DQWyeNkx.js} +2 -2
  43. package/dist/chunks/{link-navigation-a_sRfmsj.js.map → link-navigation-DQWyeNkx.js.map} +1 -1
  44. package/dist/chunks/{withPollingChangeSubscription-Cz3Diolr.js → withPollingChangeSubscription-Ct8kjmlL.js} +19 -2
  45. package/dist/chunks/withPollingChangeSubscription-Ct8kjmlL.js.map +1 -0
  46. package/dist/client-testing.js +39 -5
  47. package/dist/client-testing.js.map +1 -1
  48. package/dist/client.js +43 -14
  49. package/dist/client.js.map +1 -1
  50. package/dist/contract.js +4 -3
  51. package/dist/files/i18n-keys.json +619 -15
  52. package/dist/files/widgets/DriveFilesConversationWidget/DriveFilesConversationWidget.md +4 -2
  53. package/dist/files/widgets/OwnerStepConfirmationConversationWidget/OwnerStepConfirmationConversationWidget.md +54 -0
  54. package/dist/files/widgets/OwnerStepConfirmationConversationWidget/owner-step-confirmation.preview-fixtures.json +16 -0
  55. package/dist/image-render.js +8 -8
  56. package/dist/index.js +16 -16
  57. package/dist/kit.js +2 -2
  58. package/dist/preview.js +124 -117
  59. package/dist/preview.js.map +1 -1
  60. package/dist/provider.js +2 -2
  61. package/dist/renderer.js +53 -52
  62. package/dist/styles.css +46 -0
  63. package/dist/types/admin/schedules/AgentScheduleOrderDraftPanel.d.ts +45 -0
  64. package/dist/types/admin/schedules/AgentSchedulesPanel.d.ts +11 -3
  65. package/dist/types/admin/schedules/agent-schedules-api.d.ts +38 -2
  66. package/dist/types/admin/schedules/agent-schedules-format.d.ts +22 -1
  67. package/dist/types/admin/schedules/agent-schedules-types.d.ts +91 -1
  68. package/dist/types/admin-chat-widgets/ScheduleOrderApprovalConversationWidget.d.ts +37 -0
  69. package/dist/types/admin-chat-widgets/registerScheduleOrderApprovalWidget.d.ts +11 -0
  70. package/dist/types/chat/trace/TurnMetaLine.d.ts +5 -3
  71. package/dist/types/chat/trace/trace-counts.d.ts +2 -0
  72. package/dist/types/chat/trace/trace-types.d.ts +4 -0
  73. package/dist/types/client/AgentsConversationClient.d.ts +17 -1
  74. package/dist/types/client/http/agents-http-mappers.d.ts +4 -2
  75. package/dist/types/client/http/agents-http-trace-wire.d.ts +2 -0
  76. package/dist/types/client/http/agents-http-wire.d.ts +24 -0
  77. package/dist/types/client/testing/createInMemoryAgentsConversationClient.d.ts +13 -1
  78. package/dist/types/contract/conversation-trace.d.ts +4 -0
  79. package/dist/types/contract/conversation.d.ts +43 -0
  80. package/dist/types/entries/admin-chat-widgets.d.ts +2 -0
  81. package/dist/types/entries/admin.d.ts +4 -2
  82. package/dist/types/entries/renderer.d.ts +1 -1
  83. package/dist/types/renderer/widget-tree/composed-node-schema.d.ts +20 -3
  84. package/dist/types/widgets/DriveFilesConversationWidget/shared/drive-files.d.ts +3 -1
  85. package/dist/voice.js +2 -2
  86. package/dist/widgets.js +4 -4
  87. package/package.json +7 -1
  88. package/public-api.json +39 -0
  89. package/dist/chunks/WebSearchResultsConversationWidget-l9Aek_lG.js.map +0 -1
  90. package/dist/chunks/agents-http-trace-mappers-rsbGAf2_.js.map +0 -1
  91. package/dist/chunks/content-from-unified-diff-DWyBHRSy.js.map +0 -1
  92. package/dist/chunks/index-DZovGMpG.js.map +0 -1
  93. package/dist/chunks/widget-name-resolver-DXIE9JUr.js.map +0 -1
  94. package/dist/chunks/withPollingChangeSubscription-Cz3Diolr.js.map +0 -1
package/README.md CHANGED
@@ -13,12 +13,12 @@ npm install @mgamadeus/ddd-agents@~0.1.1 @types/google.maps@^3.55.0 apexcharts@^
13
13
  ```
14
14
 
15
15
  The second part is the peer set (React 19 assumed present). `@mgamadeus/ddd-admin-ui`, `@mgamadeus/ddd-web` and
16
- `lucide-react` are optional peers: only `/voice/admin` and `/admin` load them.
16
+ `lucide-react` are optional peers: only `/voice/admin`, `/admin` and `/admin/chat-widgets` load them.
17
17
  `react-apexcharts` stays below 1.6.0: from 1.6.0 it needs apexcharts 4, the package draws with apexcharts 3.
18
18
  The agent skills come with the Composer package (`vendor/mgamadeus/ddd-agents/.claude/skills`), not with this one.
19
19
 
20
20
  Entries: `@mgamadeus/ddd-agents` (provider and setup), `/provider` (the provider alone), `/chat`, `/renderer`, `/widgets`, `/kit`, `/contract`,
21
- `/client`, `/client/testing`, `/preview`, `/image-render`, `/ui`, `/voice`, `/voice/admin`, `/admin`, and the stylesheet `@mgamadeus/ddd-agents/styles.css`
21
+ `/client`, `/client/testing`, `/preview`, `/image-render`, `/ui`, `/voice`, `/voice/admin`, `/admin`, `/admin/chat-widgets`, and the stylesheet `@mgamadeus/ddd-agents/styles.css`
22
22
  (import it once). Non-code files (widget documentation, preview fixtures, contracts, the node schema, the
23
23
  sandbox frame, SCSS tokens) are exported one subpath per file at their path below `src`. React 19 and the libraries listed under `peerDependencies` come from the application.
24
24
 
@@ -58,6 +58,7 @@ const client = createAgentsHttpConversationClient({
58
58
  | `postMessage`, `injectSignal`, `retryConversation` | `POST /{id}/postMessage`, `/{id}/injectSignal`, `/{id}/retry` |
59
59
  | `renameConversation`, `deleteConversation` | `PATCH /{id}/title`, `DELETE /{id}` |
60
60
  | `stopBackgroundJob` | `POST /{id}/backgroundJobs/{backgroundJobId}/stop` (`AgentConversationBackgroundJobsTrait`, which the application mounts beside the reads and writes) |
61
+ | `getStepConfirmation`, `executeStepConfirmation`, `discardStepConfirmation` | `GET /{id}/stepConfirmations/{stepConfirmationId}`, `POST …/execute` (`{ contentHash }`), `POST …/discard` (`AgentConversationStepConfirmationsTrait`, which the application mounts when `AI.ownerConsent.stepConfirmation.byButtonInChat` is on) |
61
62
  | `getSelectableModels` | `GET /selectable-models`, only with `hasSelectableModelsRoute: true` |
62
63
 
63
64
  Further options: `fetch` (default: the global one), `extraRequestParameters` (query parameters per operation),
@@ -80,6 +81,19 @@ reads the stop in its next turn, it is not woken. `withPollingChangeSubscription
80
81
  `WireBackgroundJob`, `WireBackgroundJobStopResponse`, `mapWireBackgroundJob`, `mapWireRunningBackgroundJobs`,
81
82
  `mapWireBackgroundJobStop`.
82
83
 
84
+ **Steps that wait for the owner's click.** The widget `OwnerStepConfirmation` (a stored step of a tool's consent
85
+ step) reads and acts through three optional port functions: `getStepConfirmation(conversationId, stepConfirmationId)`
86
+ answers `ConversationStepConfirmation` (two lines and their text keys `ConversationStepConfirmationLine`, state
87
+ `ConversationStepConfirmationStatus` of `CONVERSATION_STEP_CONFIRMATION_STATUSES`, hash, result excerpt);
88
+ `executeStepConfirmation(conversationId, stepConfirmationId, contentHash)` runs exactly the step shown (the server
89
+ refuses a changed step with HTTP 400 and a closed one with 403) and `discardStepConfirmation(…)` says no; both answer
90
+ the step as stored. No chat message is sent: the server signals the conversation. A binding without
91
+ `getStepConfirmation` shows the widget as one line that the step cannot be confirmed here; one without the two actions
92
+ shows the step without buttons. `withPollingChangeSubscription` passes them through (an action reads at once) and
93
+ `createInMemoryAgentsConversationClient` serves them from `RecordedConversation.stepConfirmations`. Wire shapes and
94
+ mapper for a binding of its own: `WireStepConfirmationResponse`, `WireStepConfirmation`, `WireOwnerConsentLine`,
95
+ `mapWireStepConfirmation`.
96
+
83
97
  **Client context.** `clientContext(operation)` tells the agent what the owner sees: it is read on every start, posted
84
98
  message and injected signal and sent as the body field `clientContext` — the route path, the route parameters (a flat
85
99
  map), the record kind and id, the tab (`AgentsClientContext`). The server stores it on that owner message, and the agent
@@ -281,6 +295,16 @@ restores only while the anchor message still carries one of them. An id of the p
281
295
  any other id the app's `furtherCanvasBehaviours` entry wins over the kind's behaviour, so a host can tune a kind (its
282
296
  width, its lifetime). `unregisterCanvasKind(canvasId)` takes a kind off again.
283
297
 
298
+ ## Widgets of a further package inside a `ComposedView`
299
+
300
+ The reader of a `ComposedView` keeps a `Widget` node only when the node schema knows its type. A further package whose
301
+ backend classes declare widget types or nodes commits its part of the schema (`composed-node-schema-part.json`,
302
+ `ComposedNodeSchemaPackagePart`, written by its PHP test) and registers it from its own register function, before the
303
+ first chat: `registerComposedNodeSchemaPart(part)` of `@mgamadeus/ddd-agents/renderer`. `getComposedNodeSchema()`
304
+ merges this package's schema, every registered part and the application's part (last); registering the same part
305
+ again changes nothing. Without it a `Widget` node of that package's type is dropped as unknown instead of lifted.
306
+ Backend side: `ddd-module-agents-widgets-specialist` › composed-view nodes, "The schema".
307
+
284
308
  ## AgentChat in a host window
285
309
 
286
310
  | Prop | Default | |
@@ -383,7 +407,11 @@ Pass one stable component (what changes comes through a context of the host), or
383
407
  arguments and result (those of the real tool for a call through `call_tool`), a model call with its figures and
384
408
  "Context of this call", a decision with its kind, status, result and what was sent and answered, a compaction, a
385
409
  signal, a widget's payload, the loaded skills with their cause — and the turn's figures (`TurnMetaLine`). Decisions,
386
- model calls, compactions and signals are verbose-only.
410
+ model calls, compactions and signals are verbose-only. The figures tell the context apart from the sum over all model
411
+ calls: "Context 25,949 tokens" (the input of the turn's last model call, `newestModelCallInputTokens`), "10 model
412
+ calls · 250,520 tokens in total" (`modelCallCount`) and "85 % cached" as pills of their own, one pill "Context … ·
413
+ … % cached" for a turn of one call; without the two optional fields of `TraceTurnTotals` the line keeps one pill.
414
+ The debug switch "Tokens + costs" hides them; the running turn's status line reads "… tokens in total".
387
415
  - **While the turn runs** (`phase="live"`): the group stands open, steps arrive one line each, `RunStatusLine` shows
388
416
  the clock and Stop, the task plan stands above (its items when the trace names them). A host that also shows an
389
417
  activity ticker keeps one source of live step rows: the trace in `normal` and `verbose`, the ticker in `summary`.
@@ -401,9 +429,11 @@ Pass one stable component (what changes comes through a context of the host), or
401
429
  - **A step that waits for the owner's click.** A write the server stored for the owner's click on its widget (setting
402
430
  `AI.ownerConsent.stepConfirmation.byButtonInChat`) arrives as `ConversationTraceStep.isAwaitingOwnerClick` without
403
431
  `isHeldForConsent`: it reads as waiting (key `Click on a step`), and no approval card is drawn beside it — the
404
- widget `OwnerStepConfirmation` is the question. The package ships no component for that widget nor for
405
- `ScheduleOrderApproval` (the approval of a scheduled task): a host that turns them on renders both itself, on the
406
- routes of the backend's host duties (`ddd-module-agents-specialist` › host-duties, section 11).
432
+ widget `OwnerStepConfirmation` is the question. The package renders that widget through the conversation client's
433
+ optional step-confirmation functions ("Steps that wait for the owner's click" above) and ships the widget of
434
+ `ScheduleOrderApproval` (the approval of a scheduled task) in `./admin/chat-widgets`, which a host registers with
435
+ `registerScheduleOrderApprovalWidget` ("Approval of a scheduled task's order" below); the routes are the backend's
436
+ host duties (`ddd-module-agents-specialist` › host-duties, section 11).
407
437
  - **Reads.** All traces of a conversation share one `ConversationTraceLoader` (`getConversationTraceLoader`): the
408
438
  turns on screen are read in windows, a live turn is followed with `afterMessageIndex`, a new message reads again.
409
439
  A failed read renders nothing; the chat is never broken by its trace. `useConversationTraces` gives a pane beside
@@ -540,10 +570,12 @@ not.
540
570
  ### The admin screens of the calls (`/voice/admin`)
541
571
 
542
572
  The calls an administrator may read, on the blocks of `@mgamadeus/ddd-admin-ui`: the RTK Query client of the admin
543
- call routes (`AdminAgentVoiceCallsTrait`) and two screens. This entry and `/admin` are the two that load the optional peers
573
+ call routes (`AdminAgentVoiceCallsTrait`) and two screens. This entry, `/admin` and `/admin/chat-widgets` are the ones that load the optional peers
544
574
  `@mgamadeus/ddd-admin-ui` (≥ 0.7.0), `@mgamadeus/ddd-web` (≥ 0.13.0) and `lucide-react`; an application that uses the
545
575
  other entries installs none of them (`boundary.json` names the three for this entry, `scripts/check-package.mjs` fails
546
- the build when another entry loads one).
576
+ the build when another entry loads one). `boundary.json` also names the entries a server render may import
577
+ (`serverLoadableSubpaths`: `./widgets`, `./contract`, `./client`, `./provider`, `./ui`, `./voice/admin`, `./admin`);
578
+ the build imports each from `dist` in Node without `window` and `document` and fails on a throw.
547
579
 
548
580
  ```tsx
549
581
  import { AgentVoiceCallDetailScreen, AgentVoiceCallsScreen, createAgentVoiceAdminApi } from "@mgamadeus/ddd-agents/voice/admin";
@@ -676,6 +708,77 @@ export const agentSkillCatalogApi = createAgentSkillCatalogApi({ baseApi: adminA
676
708
  `diffLines` (a line diff by longest common subsequence; above `maximumCells` it lists removed then added lines and says
677
709
  so) and `foldEqualLines`.
678
710
 
711
+ **Approval of a scheduled task's order.** A task the agent sets up waits in `PENDING_APPROVAL` until its owner
712
+ approves exactly the draft shown. `createAgentSchedulesApi` adds `useAgentScheduleOrderDraftQuery({ scheduleId })` on
713
+ `GET <prefix>/{scheduleId}/draft` (`AgentScheduleOrderDraft`) and `useApproveAgentScheduleMutation({ scheduleId,
714
+ draftHash })` on `POST <prefix>/{scheduleId}/approve` (`AgentScheduleApproveResponse`: `approved`, or `refusalReason`
715
+ `DRAFT_CHANGED` / `NO_DRAFT` / `STATUS`). `AgentScheduleOrderDraftPanel` (`api`, `scheduleId`, `shownDraftHash?`,
716
+ `interactive?`, `writesAllowed?`, `viewerAccountId?`, `onApproved?` and the host's words `describeCronSchedule`,
717
+ `describeRunPurpose`, `describePermission`, `agentName`) shows what the task does, when it is done, when and in which
718
+ zone it runs, how its runs work, where they report and what they may do without asking. A permission
719
+ (`AgentScheduleOrderPermission`: `mandateId`, `actionClass`, `description`, `agentConnectionId`,
720
+ `containsExternalRecipients`) shows a translated name per package action class (`AGENT_SCHEDULE_ORDER_ACTION_CLASSES`:
721
+ `CONNECTION_MAIL_SEND`, `CONNECTION_FILE_WRITE`, `CONNECTION_CHAT_POST`, `SCHEDULED_ORDER`; else "Permission"), below
722
+ it its connection and the server's `description` unchanged, "External recipients" as a badge: the limits (recipients,
723
+ folder, channels) are shown as the server words them until the draft carries them as fields.
724
+ `describePermission(permission)` gets the whole permission and answers `{ label, detail?, connection? }` in the host's
725
+ words (a `label` replaces the name, a `detail` the server's description, a `connection` the line "Connection #N"; an
726
+ absent or empty part keeps the package's), or null for the package's. A refusal names its reason in the package's
727
+ words (`NO_DRAFT`, `STATUS`, else "The task could not be approved."), never the server's English; a task deleted
728
+ meanwhile (404) reads "This task no longer exists.", not an error. "Approve" sends the hash of the
729
+ draft it shows, a newer draft is announced and shown only after "Show the new draft", a `DRAFT_CHANGED` refusal says so
730
+ — nothing is ever approved silently. `AgentSchedulesPanel` opens it as a dialog ("Review and approve") for a schedule
731
+ in `PENDING_APPROVAL` and passes the same words (`describeRunPurpose`, `describePermission`, `agentName`,
732
+ `viewerAccountId`). The chat widget of the backend's `ScheduleOrderApproval` block needs the host's api, so the host
733
+ registers it once, before the first chat. It comes with its own entry, `@mgamadeus/ddd-agents/admin/chat-widgets`,
734
+ because it loads the chat's widget registry (and with it the package's widgets and charts, which need `window`):
735
+ `./admin` imports nothing of it and stays loadable in a server render, so a host imports `./admin/chat-widgets` only
736
+ where it sets up the chat, in the browser:
737
+
738
+ ```ts
739
+ import { createAgentSchedulesApi } from "@mgamadeus/ddd-agents/admin";
740
+ import { registerScheduleOrderApprovalWidget } from "@mgamadeus/ddd-agents/admin/chat-widgets";
741
+
742
+ export const agentSchedulesApi = createAgentSchedulesApi({ baseApi: adminApi, apiPrefix: "/api/admin/ai/agentSchedules" });
743
+
744
+ registerScheduleOrderApprovalWidget({
745
+ api: agentSchedulesApi,
746
+ describeCronSchedule: (expression) => describeRhythm(expression), // the host's words, or null for the expression
747
+ describeRunPurpose: (runPurpose) => runPurposeLabel(runPurpose), // null keeps "Standard run" / the purpose's name
748
+ describePermission: (permission) => permissionWords(permission), // { label, detail?, connection? }, or null for the package's
749
+ // a hook for words a host reads in a component (its list of mandates); called on every render, wins over describePermission
750
+ useDescribePermission: (scheduleId) => useMandatePermissionWords(scheduleId),
751
+ agentName: "Ada",
752
+ useViewerAccountId: () => useSignedInAccountId(), // a hook; a viewer who is not the owner reads who approves
753
+ });
754
+ ```
755
+
756
+ The widget shows the panel; while the task waits, the owner (any viewer when `useViewerAccountId` answers null) gets
757
+ "Change", which puts "Please change the task: " into the composer (not sent), and "Discard", which reads the task
758
+ again and deletes it after a confirmation (`useConfirm`) only while it still waits — a task approved meanwhile in
759
+ another tab is not deleted. Every write control follows the admin UI's
760
+ `WriteAccessProvider` above it (a host that locks writes wraps its area in one) and the panel's `writesAllowed`; the
761
+ server checks again. A later call replaces the options (hot reload); a host component registered under the name before
762
+ must go (two registrations throw). Tailwind has to scan `dist/` for the widget too (the panel's classes are in a shared
763
+ chunk). Inside the chat the panel uses no `ul`/`li`/`p`/`h*` (lists are `role="list"`): the message markdown's rules
764
+ would restyle them.
765
+
766
+ The parts for a host that builds its own approval screen: the host's words are `AgentScheduleOrderTexts`
767
+ (`describeCronSchedule`, `describeRunPurpose`, `describePermission`, `agentName`; the panel's props and the widget's
768
+ options extend it), one permission's words `AgentScheduleOrderPermissionWords`; the draft route answers
769
+ `AgentScheduleOrderDraftResponse` (`draft`), a refusal carries `AgentScheduleApprovalRefusalReason`.
770
+ `readAgentScheduleApprovalOutcome(answer)` reads an approve answer as `AgentScheduleApprovalOutcome` (`approved`,
771
+ `draftChanged`, or `refused` with the server's `refusalReason` and English `refusalText`, data for a log);
772
+ `isShownScheduleDraftStale(shownDraftHash, storedDraftHash)` is true only while a newer draft waits (after the approval
773
+ no draft waits, which is no change to show); `formatScheduleMoment(utcDateTime, timeZone, locale)` writes a stored UTC
774
+ moment in the task's zone (`""` when unreadable, UTC for an unknown zone); `DEFAULT_SCHEDULE_RUN_PURPOSE`
775
+ (`Schedule.Run`) is the purpose that reads as "Standard run". `./admin/chat-widgets` also exports the widget's pieces
776
+ for a host that registers it under its own registry call: `SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE` (the wire name
777
+ `ScheduleOrderApproval`), `parseScheduleOrderApprovalPayload(payload)` (`ScheduleOrderApprovalPayload`: `scheduleId`,
778
+ `draftHash`; null when it does not decode), `createScheduleOrderApprovalConversationWidget(readOptions)` (the component,
779
+ reading `ScheduleOrderApprovalWidgetOptions` on every render) and `RegisterScheduleOrderApprovalWidgetOptions` (the
780
+ options of `registerScheduleOrderApprovalWidget`, the same type).
781
+
679
782
  **Background jobs of a conversation.** `AgentConversationDetailScreen` has the tab `backgroundJobs`
680
783
  (`AGENT_CONVERSATION_DETAIL_TABS`): the jobs of the conversation's tree, newest first, with every stored field — state
681
784
  (`AGENT_BACKGROUND_JOB_STATE`, context `AGENT_BACKGROUND_JOB_STATE_CONTEXT`), delivery, live status, deadline, checks,
package/boundary.json CHANGED
@@ -13,6 +13,20 @@
13
13
  "@mgamadeus/ddd-admin-ui",
14
14
  "@mgamadeus/ddd-web",
15
15
  "lucide-react"
16
+ ],
17
+ "./admin/chat-widgets": [
18
+ "@mgamadeus/ddd-admin-ui",
19
+ "@mgamadeus/ddd-web",
20
+ "lucide-react"
16
21
  ]
17
- }
22
+ },
23
+ "serverLoadableSubpaths": [
24
+ "./widgets",
25
+ "./contract",
26
+ "./client",
27
+ "./provider",
28
+ "./ui",
29
+ "./voice/admin",
30
+ "./admin"
31
+ ]
18
32
  }
@@ -0,0 +1,158 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { normalizeDddError } from "@mgamadeus/ddd-web/contract";
4
+ import { useTranslate } from "@mgamadeus/ddd-admin-ui/i18n";
5
+ import { useConfirm, useWriteAccess, notify } from "@mgamadeus/ddd-admin-ui/logic";
6
+ import { Button } from "@mgamadeus/ddd-admin-ui/primitives";
7
+ import { MessageSquareText, Trash2 } from "lucide-react";
8
+ import { useMemo, useState, useRef } from "react";
9
+ import { u as useReportWidgetRenderStatus, a as useConversationWidgetContext } from "./chunks/WebSearchResultsConversationWidget-BM624Fcx.js";
10
+ import { A as AgentScheduleOrderDraftPanel } from "./chunks/AgentScheduleOrderDraftPanel-DM6pz_hc.js";
11
+ import { h as registerConversationWidgets } from "./chunks/conversationWidgetRegistry-BW-U_RvC.js";
12
+ const SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE = "ScheduleOrderApproval";
13
+ const parseScheduleOrderApprovalPayload = (payload) => {
14
+ if (typeof payload !== "string") return null;
15
+ let parsed;
16
+ try {
17
+ parsed = JSON.parse(payload);
18
+ } catch {
19
+ return null;
20
+ }
21
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return null;
22
+ const fields = parsed;
23
+ const scheduleId = typeof fields.scheduleId === "number" ? fields.scheduleId : Number(fields.scheduleId);
24
+ const draftHash = typeof fields.draftHash === "string" ? fields.draftHash.trim() : "";
25
+ if (!Number.isInteger(scheduleId) || scheduleId <= 0 || draftHash === "") return null;
26
+ return { scheduleId, draftHash };
27
+ };
28
+ const useNoViewerAccountId = () => null;
29
+ const useNoDescribePermission = () => void 0;
30
+ const createScheduleOrderApprovalConversationWidget = (readOptions) => {
31
+ const ScheduleOrderApprovalConversationWidget = ({ payload, interactive = false }) => {
32
+ const { t } = useTranslate();
33
+ const parsedPayload = useMemo(() => parseScheduleOrderApprovalPayload(payload), [payload]);
34
+ useReportWidgetRenderStatus(
35
+ parsedPayload === null ? "failed" : "mounted",
36
+ parsedPayload === null ? "INVALID_PROP" : void 0,
37
+ parsedPayload === null ? "the block names no schedule or no draft hash" : void 0
38
+ );
39
+ if (parsedPayload === null) {
40
+ return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: t("This approval cannot be shown.") });
41
+ }
42
+ return /* @__PURE__ */ jsx(ScheduleOrderApprovalBody, { options: readOptions(), scheduleId: parsedPayload.scheduleId, draftHash: parsedPayload.draftHash, interactive });
43
+ };
44
+ return ScheduleOrderApprovalConversationWidget;
45
+ };
46
+ const ScheduleOrderApprovalBody = ({ options, scheduleId, draftHash, interactive }) => {
47
+ const { api, useViewerAccountId = useNoViewerAccountId, useDescribePermission = useNoDescribePermission, ...texts } = options;
48
+ const { t } = useTranslate();
49
+ const confirm = useConfirm();
50
+ const writeAccess = useWriteAccess();
51
+ const viewerAccountId = useViewerAccountId();
52
+ const describePermissionOfHook = useDescribePermission(scheduleId);
53
+ const describePermission = describePermissionOfHook ?? texts.describePermission;
54
+ const { prefillComposer } = useConversationWidgetContext();
55
+ const draftQuery = api.useAgentScheduleOrderDraftQuery({ scheduleId });
56
+ const [deleteSchedule, deleteState] = api.useDeleteAgentScheduleMutation();
57
+ const [isDiscarded, setIsDiscarded] = useState(false);
58
+ const isDiscardingRef = useRef(false);
59
+ const isWaiting = draftQuery.data?.draft?.scheduleStatus === "PENDING_APPROVAL";
60
+ const ownerAccountId = draftQuery.data?.draft?.ownerAccountId ?? null;
61
+ const isOwner = viewerAccountId === null || ownerAccountId === null || viewerAccountId === ownerAccountId;
62
+ const discard = async () => {
63
+ if (isDiscardingRef.current) return;
64
+ isDiscardingRef.current = true;
65
+ try {
66
+ const refetchCall = draftQuery.refetch();
67
+ const storedDraft = refetchCall ? (await refetchCall.unwrap()).draft : draftQuery.data?.draft;
68
+ if (storedDraft?.scheduleStatus !== "PENDING_APPROVAL") return;
69
+ const isConfirmed = await confirm({
70
+ title: t("Discard this task?"),
71
+ description: t("The task is deleted and does not run any more."),
72
+ confirmLabel: t("Discard", { context: "agent-schedule-order" }),
73
+ confirmVariant: "destructive"
74
+ });
75
+ if (!isConfirmed) return;
76
+ await deleteSchedule({ scheduleId }).unwrap();
77
+ setIsDiscarded(true);
78
+ notify.success(t("Task discarded."));
79
+ } catch (caught) {
80
+ notify.error(normalizeDddError(caught, t("The task could not be deleted.")).message);
81
+ } finally {
82
+ isDiscardingRef.current = false;
83
+ }
84
+ };
85
+ if (isDiscarded) {
86
+ return /* @__PURE__ */ jsx("div", { role: "status", "data-slot": "schedule-order-approval-discarded", className: "text-sm text-muted-foreground", children: t("The task was discarded.") });
87
+ }
88
+ return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-2", "data-slot": "schedule-order-approval-widget", children: [
89
+ /* @__PURE__ */ jsx(
90
+ AgentScheduleOrderDraftPanel,
91
+ {
92
+ api,
93
+ scheduleId,
94
+ shownDraftHash: draftHash,
95
+ interactive,
96
+ viewerAccountId,
97
+ ...texts,
98
+ describePermission
99
+ }
100
+ ),
101
+ interactive && isWaiting && isOwner && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
102
+ /* @__PURE__ */ jsxs(
103
+ Button,
104
+ {
105
+ type: "button",
106
+ size: "sm",
107
+ rounded: "full",
108
+ variant: "outline",
109
+ "data-slot": "schedule-order-approval-change",
110
+ title: !writeAccess.allowed ? writeAccess.reason : void 0,
111
+ disabled: !writeAccess.allowed,
112
+ onClick: () => prefillComposer(`${t("Please change the task:")} `),
113
+ children: [
114
+ /* @__PURE__ */ jsx(MessageSquareText, { "aria-hidden": true }),
115
+ t("Change", { context: "agent-schedule-order" })
116
+ ]
117
+ }
118
+ ),
119
+ /* @__PURE__ */ jsxs(
120
+ Button,
121
+ {
122
+ type: "button",
123
+ size: "sm",
124
+ rounded: "full",
125
+ variant: "ghost",
126
+ className: "text-destructive",
127
+ "data-slot": "schedule-order-approval-discard",
128
+ title: !writeAccess.allowed ? writeAccess.reason : void 0,
129
+ disabled: !writeAccess.allowed || deleteState.isLoading,
130
+ onClick: () => void discard(),
131
+ children: [
132
+ /* @__PURE__ */ jsx(Trash2, { "aria-hidden": true }),
133
+ t("Discard", { context: "agent-schedule-order" })
134
+ ]
135
+ }
136
+ )
137
+ ] })
138
+ ] });
139
+ };
140
+ let currentOptions = null;
141
+ let isWidgetRegistered = false;
142
+ const readCurrentOptions = () => {
143
+ if (currentOptions === null) throw new Error("registerScheduleOrderApprovalWidget has not been called.");
144
+ return currentOptions;
145
+ };
146
+ const registerScheduleOrderApprovalWidget = (options) => {
147
+ currentOptions = options;
148
+ if (isWidgetRegistered) return;
149
+ registerConversationWidgets([{ name: SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE, component: createScheduleOrderApprovalConversationWidget(readCurrentOptions) }]);
150
+ isWidgetRegistered = true;
151
+ };
152
+ export {
153
+ SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE,
154
+ createScheduleOrderApprovalConversationWidget,
155
+ parseScheduleOrderApprovalPayload,
156
+ registerScheduleOrderApprovalWidget
157
+ };
158
+ //# sourceMappingURL=admin-chat-widgets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-chat-widgets.js","sources":["../src/admin-chat-widgets/ScheduleOrderApprovalConversationWidget.tsx","../src/admin-chat-widgets/registerScheduleOrderApprovalWidget.ts"],"sourcesContent":["import { normalizeDddError } from \"@mgamadeus/ddd-web/contract\";\nimport { useTranslate } from \"@mgamadeus/ddd-admin-ui/i18n\";\nimport { notify, useConfirm, useWriteAccess } from \"@mgamadeus/ddd-admin-ui/logic\";\nimport { Button } from \"@mgamadeus/ddd-admin-ui/primitives\";\nimport { MessageSquareText, Trash2 } from \"lucide-react\";\nimport { type ComponentType, useMemo, useRef, useState } from \"react\";\nimport { useConversationWidgetContext } from \"../renderer/ConversationWidgetCallbacksContext\";\nimport type { PayloadConversationWidgetProps } from \"../renderer/conversation-widget-props\";\nimport { useReportWidgetRenderStatus } from \"../renderer/render-report/widget-render-report\";\nimport type { AgentSchedulesApi } from \"../admin/schedules/agent-schedules-api\";\nimport { AgentScheduleOrderDraftPanel, type AgentScheduleOrderDraftPanelProps, type AgentScheduleOrderTexts } from \"../admin/schedules/AgentScheduleOrderDraftPanel\";\n\n/** The wire name the backend writes (`ScheduleOrderApprovalConversationWidget::WIDGET_TYPE`). */\nexport const SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE = \"ScheduleOrderApproval\";\n\n/** The fields of a `ScheduleOrderApproval` block: the task and the hash of the draft the tool stored. */\nexport interface ScheduleOrderApprovalPayload {\n scheduleId: number;\n draftHash: string;\n}\n\n/** The payload of a block, or null when it does not decode or names no schedule id above 0 or no hash. */\nexport const parseScheduleOrderApprovalPayload = (payload: string | undefined): ScheduleOrderApprovalPayload | null => {\n if (typeof payload !== \"string\") return null;\n let parsed: unknown;\n try {\n parsed = JSON.parse(payload);\n } catch {\n return null;\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) return null;\n const fields = parsed as Record<string, unknown>;\n const scheduleId = typeof fields.scheduleId === \"number\" ? fields.scheduleId : Number(fields.scheduleId);\n const draftHash = typeof fields.draftHash === \"string\" ? fields.draftHash.trim() : \"\";\n if (!Number.isInteger(scheduleId) || scheduleId <= 0 || draftHash === \"\") return null;\n return { scheduleId, draftHash };\n};\n\n/** What the chat widget of an approval needs from the host. */\nexport interface ScheduleOrderApprovalWidgetOptions extends AgentScheduleOrderTexts {\n /** `createAgentSchedulesApi(…)` of the host (where it mounts `AdminAgentSchedulesTrait`). */\n api: AgentSchedulesApi;\n /**\n * A hook answering the signed-in account's id (the host's session): a viewer who is not the task's owner reads who\n * approves instead of the button. Absent: the button shows for everyone and the server refuses anyone but the owner.\n */\n useViewerAccountId?: () => number | null;\n /**\n * A hook answering the words of the permissions for the block's task (`scheduleId`), for a host that reads them in a\n * component (its own list of mandates): called on every render of the widget; its answer wins over\n * `describePermission`. Absent: no hook is called.\n */\n useDescribePermission?: (scheduleId: number) => AgentScheduleOrderDraftPanelProps[\"describePermission\"];\n}\n\nconst useNoViewerAccountId = (): number | null => null;\nconst useNoDescribePermission = (): AgentScheduleOrderDraftPanelProps[\"describePermission\"] => undefined;\n\n/**\n * Builds the chat widget of `ScheduleOrderApproval` (written by the task tools after they stored a draft, never by the\n * model) on the host's api and words: the order from the stored rows (`AgentScheduleOrderDraftPanel`), approved with the\n * hash the block carries — a draft that changed since is announced and shown only on request. While the task waits:\n * \"Change\" puts a request into the composer (the owner says what to change; it is not sent), \"Discard\" deletes the task\n * after a confirmation. Writes follow an `@mgamadeus/ddd-admin-ui` `WriteAccessProvider` above the chat.\n */\nexport const createScheduleOrderApprovalConversationWidget = (\n readOptions: () => ScheduleOrderApprovalWidgetOptions,\n): ComponentType<PayloadConversationWidgetProps> => {\n const ScheduleOrderApprovalConversationWidget = ({ payload, interactive = false }: PayloadConversationWidgetProps) => {\n const { t } = useTranslate();\n const parsedPayload = useMemo(() => parseScheduleOrderApprovalPayload(payload), [payload]);\n useReportWidgetRenderStatus(\n parsedPayload === null ? \"failed\" : \"mounted\",\n parsedPayload === null ? \"INVALID_PROP\" : undefined,\n parsedPayload === null ? \"the block names no schedule or no draft hash\" : undefined,\n );\n if (parsedPayload === null) {\n return <div className=\"text-sm text-muted-foreground\">{t(\"This approval cannot be shown.\")}</div>;\n }\n return <ScheduleOrderApprovalBody options={readOptions()} scheduleId={parsedPayload.scheduleId} draftHash={parsedPayload.draftHash} interactive={interactive} />;\n };\n return ScheduleOrderApprovalConversationWidget;\n};\n\ninterface ScheduleOrderApprovalBodyProps {\n options: ScheduleOrderApprovalWidgetOptions;\n scheduleId: number;\n draftHash: string;\n interactive: boolean;\n}\n\nconst ScheduleOrderApprovalBody = ({ options, scheduleId, draftHash, interactive }: ScheduleOrderApprovalBodyProps) => {\n const { api, useViewerAccountId = useNoViewerAccountId, useDescribePermission = useNoDescribePermission, ...texts } = options;\n const { t } = useTranslate();\n const confirm = useConfirm();\n const writeAccess = useWriteAccess();\n const viewerAccountId = useViewerAccountId();\n const describePermissionOfHook = useDescribePermission(scheduleId);\n const describePermission = describePermissionOfHook ?? texts.describePermission;\n const { prefillComposer } = useConversationWidgetContext();\n const draftQuery = api.useAgentScheduleOrderDraftQuery({ scheduleId });\n const [deleteSchedule, deleteState] = api.useDeleteAgentScheduleMutation();\n const [isDiscarded, setIsDiscarded] = useState(false);\n const isDiscardingRef = useRef(false);\n const isWaiting = draftQuery.data?.draft?.scheduleStatus === \"PENDING_APPROVAL\";\n // \"Change\" and \"Discard\" are the owner's, like \"Approve\": a viewer known to be someone else does not see them\n const ownerAccountId = draftQuery.data?.draft?.ownerAccountId ?? null;\n const isOwner = viewerAccountId === null || ownerAccountId === null || viewerAccountId === ownerAccountId;\n\n const discard = async () => {\n if (isDiscardingRef.current) return;\n isDiscardingRef.current = true;\n try {\n // decided on the stored state, not the cache: a task approved meanwhile (another tab) runs and is not discarded\n // here; the widget then shows it as it stands\n const refetchCall = draftQuery.refetch();\n const storedDraft = refetchCall ? (await refetchCall.unwrap()).draft : draftQuery.data?.draft;\n if (storedDraft?.scheduleStatus !== \"PENDING_APPROVAL\") return;\n const isConfirmed = await confirm({\n title: t(\"Discard this task?\"),\n description: t(\"The task is deleted and does not run any more.\"),\n confirmLabel: t(\"Discard\", { context: \"agent-schedule-order\" }),\n confirmVariant: \"destructive\",\n });\n if (!isConfirmed) return;\n await deleteSchedule({ scheduleId }).unwrap();\n setIsDiscarded(true);\n notify.success(t(\"Task discarded.\"));\n } catch (caught) {\n notify.error(normalizeDddError(caught, t(\"The task could not be deleted.\")).message);\n } finally {\n isDiscardingRef.current = false;\n }\n };\n\n if (isDiscarded) {\n return (\n <div role=\"status\" data-slot=\"schedule-order-approval-discarded\" className=\"text-sm text-muted-foreground\">\n {t(\"The task was discarded.\")}\n </div>\n );\n }\n return (\n <div className=\"flex min-w-0 flex-col gap-2\" data-slot=\"schedule-order-approval-widget\">\n <AgentScheduleOrderDraftPanel\n api={api}\n scheduleId={scheduleId}\n shownDraftHash={draftHash}\n interactive={interactive}\n viewerAccountId={viewerAccountId}\n {...texts}\n describePermission={describePermission}\n />\n {interactive && isWaiting && isOwner && (\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n rounded=\"full\"\n variant=\"outline\"\n data-slot=\"schedule-order-approval-change\"\n title={!writeAccess.allowed ? writeAccess.reason : undefined}\n disabled={!writeAccess.allowed}\n onClick={() => prefillComposer(`${t(\"Please change the task:\")} `)}\n >\n <MessageSquareText aria-hidden />\n {t(\"Change\", { context: \"agent-schedule-order\" })}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n rounded=\"full\"\n variant=\"ghost\"\n className=\"text-destructive\"\n data-slot=\"schedule-order-approval-discard\"\n title={!writeAccess.allowed ? writeAccess.reason : undefined}\n disabled={!writeAccess.allowed || deleteState.isLoading}\n onClick={() => void discard()}\n >\n <Trash2 aria-hidden />\n {t(\"Discard\", { context: \"agent-schedule-order\" })}\n </Button>\n </div>\n )}\n </div>\n );\n};\n","import { registerConversationWidgets } from \"../renderer/conversationWidgetRegistry\";\nimport {\n createScheduleOrderApprovalConversationWidget,\n SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE,\n type ScheduleOrderApprovalWidgetOptions,\n} from \"./ScheduleOrderApprovalConversationWidget\";\n\nexport type RegisterScheduleOrderApprovalWidgetOptions = ScheduleOrderApprovalWidgetOptions;\n\n// the widget registry refuses a name twice: the widget is registered once and reads the options of the latest call\n// (a hot reload calls again with a new api or new words)\nlet currentOptions: ScheduleOrderApprovalWidgetOptions | null = null;\nlet isWidgetRegistered = false;\n\nconst readCurrentOptions = (): ScheduleOrderApprovalWidgetOptions => {\n if (currentOptions === null) throw new Error(\"registerScheduleOrderApprovalWidget has not been called.\");\n return currentOptions;\n};\n\n/**\n * Registers the chat widget of `ScheduleOrderApproval` — the approval of a scheduled task's order, which the task tools\n * write after they stored a draft. Without it the block renders nothing and every new task waits in\n * `PENDING_APPROVAL` with no way to approve it from the chat. Call it once, outside React, before the first chat, with\n * the host's `createAgentSchedulesApi(…)` and its words for the rhythm, the run purpose, the permissions and the\n * agent's name. A later call replaces the options; the widget itself is registered once. A host that registered its own\n * component under the name before removes that registration (two registrations of one name throw).\n */\nexport const registerScheduleOrderApprovalWidget = (options: RegisterScheduleOrderApprovalWidgetOptions): void => {\n currentOptions = options;\n if (isWidgetRegistered) return;\n registerConversationWidgets([{ name: SCHEDULE_ORDER_APPROVAL_WIDGET_TYPE, component: createScheduleOrderApprovalConversationWidget(readCurrentOptions) }]);\n isWidgetRegistered = true;\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAaO,MAAM,sCAAsC;AAS5C,MAAM,oCAAoC,CAAC,YAAqE;AACrH,MAAI,OAAO,YAAY,SAAU,QAAO;AACxC,MAAI;AACJ,MAAI;AACF,aAAS,KAAK,MAAM,OAAO;AAAA,EAC7B,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,OAAO,WAAW,YAAY,WAAW,QAAQ,MAAM,QAAQ,MAAM,EAAG,QAAO;AACnF,QAAM,SAAS;AACf,QAAM,aAAa,OAAO,OAAO,eAAe,WAAW,OAAO,aAAa,OAAO,OAAO,UAAU;AACvG,QAAM,YAAY,OAAO,OAAO,cAAc,WAAW,OAAO,UAAU,SAAS;AACnF,MAAI,CAAC,OAAO,UAAU,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