@ai-matrx/chat 0.3.33 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/agents/addressing/useAgentHref.js +4 -1
  3. package/dist/agents/api/submit-tool-results.js +11 -1
  4. package/dist/agents/components/ambient-assistant/intelligence-places.js +2 -2
  5. package/dist/agents/components/chat/intelligence-places.js +7 -7
  6. package/dist/agents/components/chat/useCanvasScopedToConversation.js +1 -1
  7. package/dist/agents/components/inputs/smart-input/RunToolPicker.js +7 -13
  8. package/dist/agents/components/inputs/smart-input/composer/ComposerAgentPill.js +3 -2
  9. package/dist/agents/components/inputs/smart-input/composer/useComposerAgent.js +5 -5
  10. package/dist/agents/components/inputs/smart-input/composer/useComposerAgentFilter.js +3 -2
  11. package/dist/agents/components/messages-display/AgentConversationDisplay.js +4 -1
  12. package/dist/agents/components/run-controls/RunConfigOverrides.js +10 -16
  13. package/dist/agents/components/run-controls/panels/shared.d.ts +1 -1
  14. package/dist/agents/components/shared/AgentConversationColumn.js +3 -2
  15. package/dist/agents/components/working-document/workingDocumentSurface.d.ts +1 -1
  16. package/dist/agents/hooks/useAgentModelLabel.js +4 -3
  17. package/dist/agents/hooks/useDiffEnrichment.js +3 -5
  18. package/dist/agents/hooks/useModelControls.d.ts +5 -161
  19. package/dist/agents/identity/model-catalog.d.ts +37 -0
  20. package/dist/agents/identity/model-catalog.js +105 -0
  21. package/dist/agents/redux/agent-definition/selectors.d.ts +237 -237
  22. package/dist/agents/redux/agent-definition/thunks.d.ts +1 -1
  23. package/dist/agents/redux/agent-settings/agentSettingsSlice.d.ts +1 -1
  24. package/dist/agents/redux/agent-settings/agentSettingsSlice.js +4 -6
  25. package/dist/agents/redux/agent-settings/selectors.d.ts +13 -152
  26. package/dist/agents/redux/agent-settings/selectors.js +0 -39
  27. package/dist/agents/redux/agent-settings/useNormalizedControls.d.ts +8 -0
  28. package/dist/agents/redux/agent-settings/useNormalizedControls.js +24 -0
  29. package/dist/agents/redux/agent-shortcut-categories/selectors.d.ts +50 -50
  30. package/dist/agents/redux/agent-shortcuts/selectors.d.ts +147 -147
  31. package/dist/agents/redux/conversation-history/selectors.d.ts +16 -16
  32. package/dist/agents/redux/conversation-list/conversation-list.selectors.d.ts +2 -2
  33. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.d.ts +54 -54
  34. package/dist/agents/redux/execution-system/context-state/context-state.selectors.d.ts +14 -14
  35. package/dist/agents/redux/execution-system/conversations/conversations.selectors.d.ts +5 -5
  36. package/dist/agents/redux/execution-system/host-conversations/conversation-abilities.d.ts +12 -0
  37. package/dist/agents/redux/execution-system/host-conversations/conversation-abilities.js +25 -0
  38. package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.d.ts +50 -0
  39. package/dist/agents/redux/execution-system/host-conversations/host-conversation.thunks.js +367 -0
  40. package/dist/agents/redux/execution-system/host-conversations/host-conversations.selectors.d.ts +28 -0
  41. package/dist/agents/redux/execution-system/host-conversations/host-conversations.selectors.js +41 -0
  42. package/dist/agents/redux/execution-system/host-conversations/host-conversations.slice.d.ts +43 -0
  43. package/dist/agents/redux/execution-system/host-conversations/host-conversations.slice.js +38 -0
  44. package/dist/agents/redux/execution-system/host-conversations/source-registry.d.ts +9 -0
  45. package/dist/agents/redux/execution-system/host-conversations/source-registry.js +15 -0
  46. package/dist/agents/redux/execution-system/host-conversations/useHostConversation.d.ts +4 -0
  47. package/dist/agents/redux/execution-system/host-conversations/useHostConversation.js +24 -0
  48. package/dist/agents/redux/execution-system/instance-context/instance-context.selectors.d.ts +3 -3
  49. package/dist/agents/redux/execution-system/instance-resources/default-remark-durability.d.ts +22 -0
  50. package/dist/agents/redux/execution-system/instance-resources/default-remark-durability.js +164 -0
  51. package/dist/agents/redux/execution-system/instance-resources/instance-resources.selectors.d.ts +8 -8
  52. package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.d.ts +5 -5
  53. package/dist/agents/redux/execution-system/instance-user-input/composer-draft-store.js +20 -0
  54. package/dist/agents/redux/execution-system/instance-user-input/useComposerDraftRestore.js +2 -1
  55. package/dist/agents/redux/execution-system/instance-variable-values/instance-variable-values.selectors.d.ts +7 -7
  56. package/dist/agents/redux/execution-system/messages/messages.selectors.d.ts +1 -1
  57. package/dist/agents/redux/execution-system/observability/observability.selectors.d.ts +7 -7
  58. package/dist/agents/redux/execution-system/observational-memory/observational-memory.selectors.d.ts +1 -1
  59. package/dist/agents/redux/execution-system/selectors/aggregate.selectors.d.ts +14 -14
  60. package/dist/agents/redux/execution-system/thunks/execute-instance.thunk.js +2 -1
  61. package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +4 -3
  62. package/dist/agents/redux/execution-system/thunks/load-conversation.thunk.js +6 -0
  63. package/dist/agents/redux/execution-system/thunks/load-older-messages.thunk.js +12 -0
  64. package/dist/agents/redux/execution-system/thunks/process-stream.js +5 -3
  65. package/dist/agents/redux/execution-system/thunks/resolve-base-url.js +1 -1
  66. package/dist/agents/redux/execution-system/thunks/smart-execute.thunk.js +43 -0
  67. package/dist/agents/redux/execution-system/utils/continuation-body.d.ts +1 -0
  68. package/dist/agents/redux/execution-system/utils/continuation-body.js +2 -1
  69. package/dist/agents/redux/model-registry.d.ts +6 -4
  70. package/dist/agents/redux/model-registry.js +23 -5
  71. package/dist/agents/redux/proposed-directives/proposedDirectivesSlice.d.ts +1 -1
  72. package/dist/agents/redux/tools/tools.selectors.d.ts +1 -1
  73. package/dist/agents/resources/default-picker-items.d.ts +17 -0
  74. package/dist/agents/resources/default-picker-items.js +48 -0
  75. package/dist/agents/runtime/generation-job.js +4 -7
  76. package/dist/agents/runtime/get-model-capabilities.js +3 -3
  77. package/dist/agents/types/instance.types.d.ts +2 -1
  78. package/dist/agents/ui-first-tools/redux/agent-lists.selectors.d.ts +2 -2
  79. package/dist/cx-chat/components/SsrSidebarChats.js +1 -1
  80. package/dist/cx-chat/components/sidebar/SidebarUserFooter.js +1 -1
  81. package/dist/host/app-identity.d.ts +20 -0
  82. package/dist/host/app-identity.js +21 -0
  83. package/dist/host/bare-host-chrome.d.ts +14 -0
  84. package/dist/host/bare-host-chrome.js +44 -0
  85. package/dist/host/configure.d.ts +9 -1
  86. package/dist/host/configure.js +44 -8
  87. package/dist/host/content-ir-slots.d.ts +5 -1
  88. package/dist/host/content-ir-slots.js +5 -1
  89. package/dist/host/contract.d.ts +39 -2
  90. package/dist/host/db-types.d.ts +375 -10
  91. package/dist/host/defaults/navigation-hooks.d.ts +2 -0
  92. package/dist/host/defaults/navigation-hooks.js +7 -1
  93. package/dist/host/defaults/navigation.d.ts +4 -3
  94. package/dist/host/defaults/navigation.js +38 -7
  95. package/dist/host/defaults/org.d.ts +12 -4
  96. package/dist/host/defaults/org.js +39 -1
  97. package/dist/host/defaults/workspace-gate.d.ts +16 -0
  98. package/dist/host/defaults/workspace-gate.js +88 -0
  99. package/dist/host/diagnostics.d.ts +7 -2
  100. package/dist/host/diagnostics.js +6 -0
  101. package/dist/host/identity.js +2 -1
  102. package/dist/host/index.d.ts +5 -2
  103. package/dist/host/index.js +21 -1
  104. package/dist/host/no-database.d.ts +38 -0
  105. package/dist/host/no-database.js +107 -0
  106. package/dist/host/react.d.ts +1 -0
  107. package/dist/host/react.js +25 -2
  108. package/dist/host/registered-source.js +2 -2
  109. package/dist/host/source.d.ts +109 -0
  110. package/dist/host/source.js +86 -0
  111. package/dist/host/ui-slots.d.ts +8 -8
  112. package/dist/host/ui-slots.js +5 -3
  113. package/dist/mandates/useMandate.js +13 -0
  114. package/dist/public-chat/components/PublicMessageOptionsMenu.js +1 -1
  115. package/dist/store/create-chat-store.d.ts +4 -4
  116. package/dist/store/middlewares.d.ts +5 -5
  117. package/dist/store/slices.d.ts +1 -1
  118. package/dist/store/slices.js +4 -3
  119. package/dist/surfaces/redux/selectors.d.ts +2 -2
  120. package/dist/testing/turn-harness.d.ts +35 -0
  121. package/dist/testing/turn-harness.js +85 -0
  122. package/dist/tool-call-visualization/intelligence-places.js +1 -1
  123. package/dist/tool-call-visualization/redux/selectors.d.ts +1 -1
  124. package/dist/voice-agent/intelligence-places.js +6 -6
  125. package/package.json +9 -6
  126. package/dist/agents/model-registry/modelRegistrySlice.d.ts +0 -691
  127. package/dist/agents/model-registry/modelRegistrySlice.js +0 -574
  128. package/dist/host/model-class.d.ts +0 -33
  129. package/dist/host/model-class.js +0 -21
@@ -0,0 +1,86 @@
1
+ class HostSendRefused extends Error {
2
+ code = "host-send-refused";
3
+ constructor(message) {
4
+ super(message);
5
+ this.name = "HostSendRefused";
6
+ }
7
+ }
8
+ function isHostSendRefused(error) {
9
+ return error instanceof HostSendRefused || typeof error === "object" && error !== null && error.code === "host-send-refused";
10
+ }
11
+ function eventsToResponse(events) {
12
+ const encoder = new TextEncoder();
13
+ const iterator = events[Symbol.asyncIterator]();
14
+ const body = new ReadableStream({
15
+ async pull(controller) {
16
+ try {
17
+ const next = await iterator.next();
18
+ if (next.done) {
19
+ controller.close();
20
+ return;
21
+ }
22
+ controller.enqueue(encoder.encode(`${JSON.stringify(next.value)}
23
+ `));
24
+ } catch (error) {
25
+ controller.error(error);
26
+ }
27
+ },
28
+ async cancel() {
29
+ await iterator.return?.();
30
+ }
31
+ });
32
+ return new Response(body, {
33
+ status: 200,
34
+ headers: { "content-type": "application/x-ndjson" }
35
+ });
36
+ }
37
+ function hostTurnResponse(turn) {
38
+ return turn.events instanceof Response ? turn.events : eventsToResponse(turn.events);
39
+ }
40
+ function createHostTurn(requestId) {
41
+ const buffer = [];
42
+ let finished = false;
43
+ let failure = null;
44
+ let wake = null;
45
+ const notify = () => {
46
+ const w = wake;
47
+ wake = null;
48
+ w?.();
49
+ };
50
+ async function* read() {
51
+ for (; ; ) {
52
+ if (buffer.length > 0) {
53
+ yield buffer.shift();
54
+ continue;
55
+ }
56
+ if (failure) throw failure.error;
57
+ if (finished) return;
58
+ await new Promise((resolve) => {
59
+ wake = resolve;
60
+ });
61
+ }
62
+ }
63
+ return {
64
+ turn: { requestId, events: read() },
65
+ push(event) {
66
+ if (finished || failure) return;
67
+ buffer.push(event);
68
+ notify();
69
+ },
70
+ end() {
71
+ finished = true;
72
+ notify();
73
+ },
74
+ fail(error) {
75
+ failure = { error };
76
+ notify();
77
+ }
78
+ };
79
+ }
80
+ export {
81
+ HostSendRefused,
82
+ createHostTurn,
83
+ eventsToResponse,
84
+ hostTurnResponse,
85
+ isHostSendRefused
86
+ };
@@ -48,11 +48,6 @@ interface InputSlotProps {
48
48
  interface TextInputDialogProps extends OpenChangeProps {
49
49
  onConfirm?: (value: string) => void | Promise<void>;
50
50
  }
51
- interface ModelListDropdownProps {
52
- onValueChange?: (modelId: string) => void;
53
- onOfferingPinChange?: (offeringId: string | undefined) => void;
54
- [extra: string]: any;
55
- }
56
51
  interface ItemMenuProps {
57
52
  onCloseAutoFocus?: (event: Event) => void;
58
53
  [extra: string]: any;
@@ -311,7 +306,6 @@ export interface ChatUiSlots {
311
306
  OrganizationContextNotice: AnyComponent;
312
307
  JsonInspector: AnyComponent;
313
308
  ConfirmDialog: SlotComponent<OpenChangeProps>;
314
- ModelListDropdown: SlotComponent<ModelListDropdownProps>;
315
309
  TextWithDoors: AnyComponent;
316
310
  EntityDoorControls: AnyComponent;
317
311
  StructuredValueView: AnyComponent;
@@ -530,7 +524,7 @@ export declare const ResourcePickerMenu: SlotComponent<ResourcePickerMenuProps>;
530
524
  export declare const FilesResourcePicker: SlotComponent<FilesPickerProps>;
531
525
  export declare const NotePickerPopover: SlotComponent<NotePickerProps>;
532
526
  export declare const SmartInputMessageTemplatePicker: SlotComponent<TemplatePickerProps>;
533
- /** A host with no resource picker offers no items. */
527
+ /** A host with no resource picker gets the package's own item list (labels + icons for every view). */
534
528
  export declare const flattenResourcePickerItems: () => Array<{
535
529
  id: string;
536
530
  label: string;
@@ -574,11 +568,17 @@ export declare const ReadFailure: AnyComponent;
574
568
  export declare const ItemRow: ComponentType<ItemRowProps>;
575
569
  export declare const UntrustedCount: AnyComponent;
576
570
  export declare const StaleDataNotice: AnyComponent;
571
+ /** A bare host gets the package's own organization picker (`defaults/workspace-gate`). */
577
572
  export declare const WorkspaceGate: AnyComponent;
578
573
  export declare const OrganizationContextNotice: AnyComponent;
579
574
  export declare const JsonInspector: AnyComponent;
580
575
  export declare const ConfirmDialog: SlotComponent<OpenChangeProps>;
581
- export declare const ModelListDropdown: SlotComponent<ModelListDropdownProps>;
576
+ /**
577
+ * THE model picker is the agents package's own (`@ai-matrx/agents/models/react`), not a slot: a
578
+ * bare host gets the real list (`BareHostChrome` mounts the catalog over `host.db`), a host with
579
+ * its own catalog mounts `ModelCatalogProvider` above the chat (matrx-frontend: ModelCatalogHost).
580
+ */
581
+ export { ModelListDropdown } from "@ai-matrx/agents/models/react";
582
582
  export declare const TextWithDoors: AnyComponent;
583
583
  export declare const EntityDoorControls: AnyComponent;
584
584
  export declare const StructuredValueView: AnyComponent;
@@ -1,9 +1,11 @@
1
1
  "use client";
2
+ import { defaultResourcePickerItems } from "../agents/resources/default-picker-items.js";
2
3
  import { isRfc9562Uuid } from "@ai-matrx/kit/uuid";
3
4
  import { createElement, Fragment, useRef } from "react";
4
5
  import { formatCost, usdToPoints } from "@ai-matrx/kit/format";
5
6
  import { reportUnregisteredHostSlot as reportUnregistered } from "./diagnostics.js";
6
7
  import { DefaultWebpageSnapshotView } from "./defaults/webpage-snapshot-view.js";
8
+ import { DefaultWorkspaceGate } from "./defaults/workspace-gate.js";
7
9
  import { DefaultFullScreenOverlay, DefaultWindowPanel } from "./defaults/window-panel.js";
8
10
  import { copyText } from "@ai-matrx/kit/clipboard";
9
11
  const slots = {};
@@ -264,7 +266,7 @@ const SmartInputMessageTemplatePicker = slotComponent(
264
266
  "SmartInputMessageTemplatePicker",
265
267
  unregisteredWidget("SmartInputMessageTemplatePicker")
266
268
  );
267
- const flattenResourcePickerItems = slotFn("flattenResourcePickerItems", () => []);
269
+ const flattenResourcePickerItems = slotFn("flattenResourcePickerItems", defaultResourcePickerItems);
268
270
  const useRunControlCounts = slotFn("useRunControlCounts", () => ({}));
269
271
  const useAttachResourcePicker = slotFn("useAttachResourcePicker", () => (_options) => void 0);
270
272
  const usePopoutContainer = slotFn("usePopoutContainer", () => void 0);
@@ -308,11 +310,11 @@ const ReadFailure = slotComponent("ReadFailure", unregisteredWidget("ReadFailure
308
310
  const ItemRow = slotComponent("ItemRow", unregisteredWidget("ItemRow"));
309
311
  const UntrustedCount = slotComponent("UntrustedCount", unregisteredWidget("UntrustedCount"));
310
312
  const StaleDataNotice = slotComponent("StaleDataNotice", unregisteredWidget("StaleDataNotice"));
311
- const WorkspaceGate = slotComponent("WorkspaceGate", unregisteredWidget("WorkspaceGate"));
313
+ const WorkspaceGate = slotComponent("WorkspaceGate", DefaultWorkspaceGate);
312
314
  const OrganizationContextNotice = slotComponent("OrganizationContextNotice", unregisteredWidget("OrganizationContextNotice"));
313
315
  const JsonInspector = slotComponent("JsonInspector", unregisteredWidget("JsonInspector"));
314
316
  const ConfirmDialog = slotComponent("ConfirmDialog", unregisteredWidget("ConfirmDialog"));
315
- const ModelListDropdown = slotComponent("ModelListDropdown", unregisteredWidget("ModelListDropdown"));
317
+ import { ModelListDropdown } from "@ai-matrx/agents/models/react";
316
318
  const TextWithDoors = slotComponent("TextWithDoors", unregisteredWidget("TextWithDoors"));
317
319
  const EntityDoorControls = slotComponent("EntityDoorControls", unregisteredWidget("EntityDoorControls"));
318
320
  const StructuredValueView = slotComponent("StructuredValueView", unregisteredWidget("StructuredValueView"));
@@ -8,6 +8,7 @@ import {
8
8
  import { extractErrorMessage } from "@ai-matrx/data/net";
9
9
  import { useAppSelector } from "../store/hooks.js";
10
10
  import { selectOrganizationId } from "../host/org.js";
11
+ import { chatHostHasDatabase } from "../host/configure.js";
11
12
  function useMandate(mandateKey, options = {}) {
12
13
  const hasMandateKey = mandateKey.trim().length > 0;
13
14
  const resolvableKey = hasMandateKey ? mandateKey : null;
@@ -45,6 +46,18 @@ function useMandate(mandateKey, options = {}) {
45
46
  const epoch = state.epoch;
46
47
  useEffect(() => {
47
48
  if (resolvableKey === null) return;
49
+ if (!chatHostHasDatabase()) {
50
+ setState((prev) => ({
51
+ ...prev,
52
+ key: question,
53
+ mandate: null,
54
+ loading: false,
55
+ error: null,
56
+ absent: true,
57
+ organizationPending: false
58
+ }));
59
+ return;
60
+ }
48
61
  let cancelled = false;
49
62
  const org = options.organizationId ?? null;
50
63
  const resolution = options.optional ? resolveMandate(resolvableKey, {
@@ -22,7 +22,7 @@ import { EmailInputDialog } from "../../host/ui-slots.js";
22
22
  import { AuthGateDialog } from "../../host/ui-slots.js";
23
23
  import { notesCreate } from "../../host/ui-slots.js";
24
24
  import { toast } from "../../host/notify.js";
25
- import { useSelector } from "react-redux";
25
+ import { useAppSelector as useSelector } from "../../store/hooks.js";
26
26
  import { selectIsAuthenticated } from "../../host/identity.js";
27
27
  import { useAppDispatch } from "../../store/hooks.js";
28
28
  import { openOverlay, CHAT_WINDOWS } from "../../host/windows.js";
@@ -9,6 +9,7 @@ export interface CreateChatStoreOptions {
9
9
  files?: Omit<FilesHost, "store">;
10
10
  }
11
11
  export declare function createChatStore(preloadedState?: Partial<ChatState>, options?: CreateChatStoreOptions): import("@reduxjs/toolkit").EnhancedStore<{
12
+ cloudFiles: import("@ai-matrx/media/files/engine").CloudFilesState;
12
13
  voiceAgent: import("../voice-agent/types.js").VoiceAgentState;
13
14
  agentDefinition: import("../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
14
15
  conversationList: import("../agents/redux/conversation-list/conversation-list.types.js").ConversationListState;
@@ -50,11 +51,11 @@ export declare function createChatStore(preloadedState?: Partial<ChatState>, opt
50
51
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
51
52
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
52
53
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
53
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
54
54
  chatHost: import("./chat-host.slice.js").ChatHostState;
55
- cloudFiles: import("@ai-matrx/media/files/engine").CloudFilesState;
55
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
56
56
  }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
57
57
  dispatch: import("redux-thunk").ThunkDispatch<{
58
+ cloudFiles: import("@ai-matrx/media/files/engine").CloudFilesState;
58
59
  voiceAgent: import("../voice-agent/types.js").VoiceAgentState;
59
60
  agentDefinition: import("../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
60
61
  conversationList: import("../agents/redux/conversation-list/conversation-list.types.js").ConversationListState;
@@ -96,9 +97,8 @@ export declare function createChatStore(preloadedState?: Partial<ChatState>, opt
96
97
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
97
98
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
98
99
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
99
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
100
100
  chatHost: import("./chat-host.slice.js").ChatHostState;
101
- cloudFiles: import("@ai-matrx/media/files/engine").CloudFilesState;
101
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
102
102
  }, undefined, import("redux").UnknownAction>;
103
103
  }>, import("redux").StoreEnhancer]>>;
104
104
  export type ChatStore = ReturnType<typeof createChatStore>;
@@ -41,8 +41,8 @@ export declare function chatMiddlewares(): readonly [Middleware<{}, any, import(
41
41
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
42
42
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
43
43
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
44
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
45
44
  chatHost: import("./chat-host.slice.js").ChatHostState;
45
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
46
46
  } & import("./root-state.js").ChatHostReadSlices, import("redux").Dispatch<import("redux").UnknownAction>>, Middleware<Record<string, never>, {
47
47
  voiceAgent: import("../voice-agent/types.js").VoiceAgentState;
48
48
  agentDefinition: import("../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
@@ -85,8 +85,8 @@ export declare function chatMiddlewares(): readonly [Middleware<{}, any, import(
85
85
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
86
86
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
87
87
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
88
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
89
88
  chatHost: import("./chat-host.slice.js").ChatHostState;
89
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
90
90
  } & import("./root-state.js").ChatHostReadSlices, import("redux").Dispatch<import("redux").UnknownAction>>, Middleware<object, {
91
91
  voiceAgent: import("../voice-agent/types.js").VoiceAgentState;
92
92
  agentDefinition: import("../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
@@ -129,8 +129,8 @@ export declare function chatMiddlewares(): readonly [Middleware<{}, any, import(
129
129
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
130
130
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
131
131
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
132
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
133
132
  chatHost: import("./chat-host.slice.js").ChatHostState;
133
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
134
134
  } & import("./root-state.js").ChatHostReadSlices, import("redux").Dispatch<import("redux").UnknownAction>>, Middleware<object, {
135
135
  voiceAgent: import("../voice-agent/types.js").VoiceAgentState;
136
136
  agentDefinition: import("../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
@@ -173,8 +173,8 @@ export declare function chatMiddlewares(): readonly [Middleware<{}, any, import(
173
173
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
174
174
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
175
175
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
176
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
177
176
  chatHost: import("./chat-host.slice.js").ChatHostState;
177
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
178
178
  } & import("./root-state.js").ChatHostReadSlices, import("redux").Dispatch<import("redux").UnknownAction>>, Middleware<object, {
179
179
  voiceAgent: import("../voice-agent/types.js").VoiceAgentState;
180
180
  agentDefinition: import("../agents/types/agent-definition.types.js").AgentDefinitionSliceState;
@@ -217,6 +217,6 @@ export declare function chatMiddlewares(): readonly [Middleware<{}, any, import(
217
217
  proposedDirectives: import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
218
218
  agentSettings: import("../agents/redux/agent-settings/types.js").AgentSettingsState;
219
219
  conversationAttachments: import("../agents/connectors/attachments.slice.js").AttachmentsSliceState;
220
- modelRegistry: import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
221
220
  chatHost: import("./chat-host.slice.js").ChatHostState;
221
+ hostConversations: import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
222
222
  } & import("./root-state.js").ChatHostReadSlices, import("redux").Dispatch<import("redux").UnknownAction>>];
@@ -40,8 +40,8 @@ export declare const chatReducers: {
40
40
  proposedDirectives: import("redux").Reducer<import("../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState>;
41
41
  agentSettings: import("redux").Reducer<import("../agents/redux/agent-settings/types.js").AgentSettingsState>;
42
42
  conversationAttachments: import("redux").Reducer<import("../agents/connectors/attachments.slice.js").AttachmentsSliceState>;
43
- modelRegistry: import("redux").Reducer<import("../agents/model-registry/modelRegistrySlice.js").ModelRegistryState>;
44
43
  chatHost: import("redux").Reducer<import("./chat-host.slice.js").ChatHostState>;
44
+ hostConversations: import("redux").Reducer<import("../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState>;
45
45
  };
46
46
  export type ChatReducers = typeof chatReducers;
47
47
  export type ChatSliceKey = keyof ChatReducers;
@@ -39,8 +39,8 @@ import agentAssistantMarkdownDraftReducer from "../agents/redux/agent-assistant-
39
39
  import proposedDirectivesReducer from "../agents/redux/proposed-directives/proposedDirectivesSlice.js";
40
40
  import agentSettingsReducer from "../agents/redux/agent-settings/agentSettingsSlice.js";
41
41
  import conversationAttachmentsReducer from "../agents/connectors/attachments.slice.js";
42
- import modelRegistryReducer from "../agents/model-registry/modelRegistrySlice.js";
43
42
  import { chatHostReducer } from "./chat-host.slice.js";
43
+ import { hostConversationsReducer } from "../agents/redux/execution-system/host-conversations/host-conversations.slice.js";
44
44
  const chatReducers = {
45
45
  voiceAgent: voiceAgentReducer,
46
46
  agentDefinition: agentDefinitionReducer,
@@ -89,9 +89,10 @@ const chatReducers = {
89
89
  // What is attached to each chat (connector picks); package-owned since P17.
90
90
  conversationAttachments: conversationAttachmentsReducer,
91
91
  // The AI model catalogue every picker and label reads; package-owned since P17b.
92
- modelRegistry: modelRegistryReducer,
93
92
  // Host state the package reads (identity, active org, server, prefs), synced by <ChatProvider> (P3).
94
- chatHost: chatHostReducer
93
+ chatHost: chatHostReducer,
94
+ // Conversations a host-owned message source carries (host/source, HOST-OWNED-SOURCE-PLAN P28a).
95
+ hostConversations: hostConversationsReducer
95
96
  };
96
97
  export {
97
98
  chatReducers
@@ -47,8 +47,8 @@ export declare const selectActiveSurfaces: ((state: {
47
47
  proposedDirectives: import("../../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
48
48
  agentSettings: import("../../agents/redux/agent-settings/types.js").AgentSettingsState;
49
49
  conversationAttachments: import("../../agents/connectors/attachments.slice.js").AttachmentsSliceState;
50
- modelRegistry: import("../../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
51
50
  chatHost: import("../../store/chat-host.slice.js").ChatHostState;
51
+ hostConversations: import("../../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
52
52
  } & import("../../store/root-state.js").ChatHostReadSlices) => import("../services/surfaces.service.js").SurfaceWithStats[]) & {
53
53
  clearCache: () => void;
54
54
  resultsCount: () => number;
@@ -120,8 +120,8 @@ export declare const makeSelectBindingsForAgent: (agentId: string) => ((state: {
120
120
  proposedDirectives: import("../../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
121
121
  agentSettings: import("../../agents/redux/agent-settings/types.js").AgentSettingsState;
122
122
  conversationAttachments: import("../../agents/connectors/attachments.slice.js").AttachmentsSliceState;
123
- modelRegistry: import("../../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
124
123
  chatHost: import("../../store/chat-host.slice.js").ChatHostState;
124
+ hostConversations: import("../../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
125
125
  } & import("../../store/root-state.js").ChatHostReadSlices) => AgentSurfaceBinding[]) & {
126
126
  clearCache: () => void;
127
127
  resultsCount: () => number;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The turn harness (HOST-OWNED-SOURCE-PLAN §3, shared with P24g): a recorded corpus turn as the
3
+ * real server bytes, a recording diagnostics port, and an in-memory prefs port — so a suite runs a
4
+ * real turn through `processStream` on the package's private store without a network.
5
+ *
6
+ * Every stream in it is the LIVE-captured NDJSON in `fixtures/corpus/` (a synthetic stream is a
7
+ * defect — vitest.config.ts).
8
+ */
9
+ import type { ChatDiagnosticContext, ChatDiagnosticsPort, ChatPrefsPort } from "../host/contract.js";
10
+ /** The recorded corpus file's raw NDJSON text. */
11
+ export declare function corpusText(name: string): string;
12
+ /**
13
+ * The corpus file as a streamed `Response`, one line per chunk — the way it came off the wire.
14
+ * `hold` stops before the last `n` lines until `release()` (a turn still running).
15
+ */
16
+ export declare function corpusResponse(name: string, options?: {
17
+ hold?: number;
18
+ }): {
19
+ response: Response;
20
+ release: () => void;
21
+ };
22
+ export interface RecordingDiagnostics extends ChatDiagnosticsPort {
23
+ entries: Array<{
24
+ error: unknown;
25
+ ctx: ChatDiagnosticContext;
26
+ stack: string;
27
+ }>;
28
+ /** Every feature the no-database stand-in refused. */
29
+ noDatabase(): string[];
30
+ }
31
+ export declare function createRecordingDiagnostics(): RecordingDiagnostics;
32
+ /** A host prefs port over a Map (what a host bridge — a file, IPC — would back). */
33
+ export declare function createMemoryPrefs(store?: Map<string, string>): ChatPrefsPort & {
34
+ store: Map<string, string>;
35
+ };
@@ -0,0 +1,85 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { NO_DATABASE_CODE_PREFIX } from "../host/no-database.js";
4
+ const CORPUS = join(__dirname, "..", "..", "fixtures", "corpus");
5
+ function corpusText(name) {
6
+ return readFileSync(join(CORPUS, `${name}.ndjson`), "utf8");
7
+ }
8
+ function corpusResponse(name, options = {}) {
9
+ const lines = corpusText(name).split("\n").filter((l) => l.trim().length > 0);
10
+ const encoder = new TextEncoder();
11
+ let release = () => {
12
+ };
13
+ const gate = new Promise((resolve) => {
14
+ release = resolve;
15
+ });
16
+ const holdAt = options.hold ? lines.length - options.hold : lines.length;
17
+ let i = 0;
18
+ const body = new ReadableStream({
19
+ async pull(controller) {
20
+ if (i === holdAt && options.hold) await gate;
21
+ if (i >= lines.length) {
22
+ controller.close();
23
+ return;
24
+ }
25
+ controller.enqueue(encoder.encode(`${lines[i]}
26
+ `));
27
+ i += 1;
28
+ }
29
+ });
30
+ return {
31
+ response: new Response(body, { status: 200, headers: { "content-type": "application/x-ndjson" } }),
32
+ release: () => release()
33
+ };
34
+ }
35
+ function createRecordingDiagnostics() {
36
+ const entries = [];
37
+ return {
38
+ entries,
39
+ capture(error, ctx) {
40
+ entries.push({ error, ctx, stack: new Error().stack ?? "" });
41
+ },
42
+ noDatabase() {
43
+ return entries.filter((e) => e.ctx.code.startsWith(NO_DATABASE_CODE_PREFIX)).map((e) => e.ctx.code.slice(NO_DATABASE_CODE_PREFIX.length));
44
+ }
45
+ };
46
+ }
47
+ function createMemoryPrefs(store = /* @__PURE__ */ new Map()) {
48
+ const listeners = /* @__PURE__ */ new Set();
49
+ const emit = (key) => {
50
+ for (const l of listeners) l(key);
51
+ };
52
+ return {
53
+ store,
54
+ get: (key) => store.get(key) ?? null,
55
+ set: (key, value) => {
56
+ store.set(key, value);
57
+ emit(key);
58
+ },
59
+ remove: (key) => {
60
+ store.delete(key);
61
+ emit(key);
62
+ },
63
+ subscribe: (listener) => {
64
+ listeners.add(listener);
65
+ return () => listeners.delete(listener);
66
+ },
67
+ knob: (key, fallback) => {
68
+ const raw = store.get(key);
69
+ if (raw == null) return fallback;
70
+ if (typeof fallback === "number") {
71
+ const n = Number(raw);
72
+ return Number.isFinite(n) ? n : fallback;
73
+ }
74
+ if (typeof fallback === "boolean") return raw === "true";
75
+ return raw;
76
+ },
77
+ snapshot: () => Object.fromEntries(store)
78
+ };
79
+ }
80
+ export {
81
+ corpusResponse,
82
+ corpusText,
83
+ createMemoryPrefs,
84
+ createRecordingDiagnostics
85
+ };
@@ -3,7 +3,7 @@ const K = MANDATE_KEYS;
3
3
  const TOOL_VIZ_PLACES = {
4
4
  feature: "tool_viz",
5
5
  label: "Tool displays",
6
- roots: ["features/tool-call-visualization", "packages/chat/src/tool-call-visualization"],
6
+ roots: ["features/tool-call-visualization", "apps/shared/chat/src/tool-call-visualization"],
7
7
  places: [
8
8
  {
9
9
  id: "component-generator",
@@ -64,8 +64,8 @@ export declare const selectOrderedToolLifecycles: (requestId: string) => ((state
64
64
  proposedDirectives: import("../../agents/redux/proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
65
65
  agentSettings: import("../../agents/redux/agent-settings/types.js").AgentSettingsState;
66
66
  conversationAttachments: import("../../agents/connectors/attachments.slice.js").AttachmentsSliceState;
67
- modelRegistry: import("../../agents/model-registry/modelRegistrySlice.js").ModelRegistryState;
68
67
  chatHost: import("../../store/chat-host.slice.js").ChatHostState;
68
+ hostConversations: import("../../agents/redux/execution-system/host-conversations/host-conversations.slice.js").HostConversationsState;
69
69
  } & import("../../store/root-state.js").ChatHostReadSlices) => ToolLifecycleEntry[]) & {
70
70
  clearCache: () => void;
71
71
  resultsCount: () => number;
@@ -9,7 +9,7 @@ const VOICE_PLACES = {
9
9
  // not pull into every page that shows the Intelligence icon.
10
10
  VOICE_COMMUNICATOR_MANDATE_KEY: MANDATE_KEYS.voice__communicator
11
11
  },
12
- roots: ["packages/chat/src/voice-agent", "app/(core)/voice", "app/(core)/chat/voice"],
12
+ roots: ["apps/shared/chat/src/voice-agent", "app/(core)/voice", "app/(core)/chat/voice"],
13
13
  places: [
14
14
  {
15
15
  id: "voice-chat",
@@ -19,7 +19,7 @@ const VOICE_PLACES = {
19
19
  mandateKeys: [MANDATE_KEYS.voice__intro],
20
20
  sources: [
21
21
  "app/(core)/chat/voice/page.tsx",
22
- "packages/chat/src/voice-agent/components/VoiceAgentSurface.tsx"
22
+ "apps/shared/chat/src/voice-agent/components/VoiceAgentSurface.tsx"
23
23
  ]
24
24
  },
25
25
  {
@@ -28,7 +28,7 @@ const VOICE_PLACES = {
28
28
  trigger: "Instructions editor",
29
29
  urlPattern: "/voice/playground",
30
30
  mandateKeys: [MANDATE_KEYS.voice__intro],
31
- sources: ["packages/chat/src/voice-agent/components/playground/InstructionsEditor.tsx"]
31
+ sources: ["apps/shared/chat/src/voice-agent/components/playground/InstructionsEditor.tsx"]
32
32
  },
33
33
  {
34
34
  id: "live-voice",
@@ -36,7 +36,7 @@ const VOICE_PLACES = {
36
36
  trigger: "Start a live session",
37
37
  urlPattern: "/chat/voice/gemini",
38
38
  mandateKeys: [MANDATE_KEYS.voice__gemini_live],
39
- sources: ["packages/chat/src/voice-agent/components/GoogleLiveSurface.tsx"]
39
+ sources: ["apps/shared/chat/src/voice-agent/components/GoogleLiveSurface.tsx"]
40
40
  },
41
41
  {
42
42
  id: "relay",
@@ -44,8 +44,8 @@ const VOICE_PLACES = {
44
44
  trigger: "Voice relay bar",
45
45
  mandateKeys: [MANDATE_KEYS.voice__communicator],
46
46
  sources: [
47
- "packages/chat/src/voice-agent/relay/VoiceRelayBar.tsx",
48
- "packages/chat/src/voice-agent/relay/VoiceRelayDock.tsx"
47
+ "apps/shared/chat/src/voice-agent/relay/VoiceRelayBar.tsx",
48
+ "apps/shared/chat/src/voice-agent/relay/VoiceRelayDock.tsx"
49
49
  ]
50
50
  }
51
51
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/chat",
3
- "version": "0.3.33",
3
+ "version": "0.4.2",
4
4
  "description": "THE one AI Matrx person-to-agent chat system: the full chat (running agents, conversations, tool calls, streaming, context, surfaces, voice) as per-module subpaths @ai-matrx/chat/<domain>/<module> over a host contract (/host, /host/react) whose only required value is a db; plus the kernel compatibility entries (., /external-store, /matrx, /react, /tools, styles.css, tokens.css) until P28.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -226,14 +226,14 @@
226
226
  "server-only": "^0.0.1",
227
227
  "uuid": "^14.0.2",
228
228
  "zod": "^4.6.5",
229
+ "@ai-matrx/agents": "latest",
230
+ "@ai-matrx/alchemy": "latest",
231
+ "@ai-matrx/associations": "latest",
229
232
  "@ai-matrx/browser-audio": "latest",
230
233
  "@ai-matrx/canvas": "latest",
231
234
  "@ai-matrx/content-ir": "latest",
232
- "@ai-matrx/alchemy": "latest",
233
- "@ai-matrx/agents": "latest",
234
- "@ai-matrx/associations": "latest",
235
- "@ai-matrx/content-ir-react": "latest",
236
235
  "@ai-matrx/data": "latest",
236
+ "@ai-matrx/content-ir-react": "latest",
237
237
  "@ai-matrx/design-system": "latest",
238
238
  "@ai-matrx/diff": "latest",
239
239
  "@ai-matrx/icons": "latest",
@@ -243,6 +243,7 @@
243
243
  "@ai-matrx/realtime": "latest",
244
244
  "@ai-matrx/records": "latest",
245
245
  "@ai-matrx/records-ui": "latest",
246
+ "@ai-matrx/rich-content": "latest",
246
247
  "@ai-matrx/tap-target": "latest"
247
248
  },
248
249
  "devDependencies": {
@@ -304,8 +305,9 @@
304
305
  "scripts": {
305
306
  "build": "pnpm clean && tsup && node ./scripts/copy-css.mjs && node ./scripts/tsc-own.mjs -p tsconfig.build.json && node ./scripts/finish-build.mjs",
306
307
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
307
- "check:package": "pnpm build && node ../scripts/check-exports-agreement.mjs && pnpm check:canonical-pickers && publint && pnpm verify:tarball && pnpm verify:modules-tarball && pnpm check:front-door:self-test && pnpm check:host-boundary && pnpm check:no-builder-tier && pnpm check:one-holder",
308
+ "check:package": "pnpm build && node ../scripts/check-exports-agreement.mjs && pnpm check:canonical-pickers && publint && pnpm verify:tarball && pnpm verify:modules-tarball && pnpm check:front-door:self-test && pnpm check:front-door:canary && pnpm check:host-boundary && pnpm check:no-builder-tier && pnpm check:one-holder && pnpm check:host-doors",
308
309
  "check:host-boundary": "node ./scripts/check-host-boundary.mjs && node ./scripts/check-host-boundary.mjs --self-test",
310
+ "check:host-doors": "node ./scripts/check-host-source-doors.mjs && node ./scripts/check-host-source-doors.mjs --self-test",
309
311
  "check:one-holder": "node ./scripts/check-chat-one-holder.mjs && node ./scripts/check-chat-one-holder.mjs --self-test",
310
312
  "check:no-builder-tier": "node ./scripts/check-chat-has-no-builder-tier.mjs && node ./scripts/check-chat-has-no-builder-tier.mjs --self-test",
311
313
  "typecheck": "node ./node_modules/typescript/bin/tsc -p tsconfig.json --noEmit && node ./scripts/tsc-own.mjs -p tsconfig.modules.json",
@@ -320,6 +322,7 @@
320
322
  "verify:modules-tarball": "node ./scripts/verify-modules-tarball.mjs",
321
323
  "check:front-door": "node ./scripts/check-front-door.mjs",
322
324
  "check:front-door:self-test": "node ./scripts/check-front-door.mjs --self-test",
325
+ "check:front-door:canary": "node ./scripts/check-front-door.mjs --root ./canary/src",
323
326
  "deps:write": "node ./scripts/finish-build.mjs --write-deps"
324
327
  }
325
328
  }