@ai-matrx/chat 0.4.9 → 0.4.12

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 (123) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/agents/components/context-items/bodies/ContextInputBody.js +1 -1
  3. package/dist/agents/components/context-items/bodies/GenericBody.js +1 -1
  4. package/dist/agents/components/conversation-actions/conversation-verbs.js +1 -1
  5. package/dist/agents/components/inputs/smart-input/RunSkillPicker.js +1 -1
  6. package/dist/agents/components/live-run/LiveRunDisplay.js +1 -1
  7. package/dist/agents/components/live-run/LiveRunProgress.js +1 -1
  8. package/dist/agents/components/live-run/RunSetDisplay.js +1 -1
  9. package/dist/agents/components/messages-display/assistant/AgentAssistantMessage.js +2 -2
  10. package/dist/agents/components/messages-display/assistant/InPlaceAnswerEditor.js +1 -1
  11. package/dist/agents/components/messages-display/conversation-tools/find-in-conversation.js +1 -1
  12. package/dist/agents/components/messages-display/message-options/buildTaskSeedFromMessage.js +1 -1
  13. package/dist/agents/components/messages-display/user/AgentUserMessage.js +1 -1
  14. package/dist/agents/components/messages-display/user/FirstTurnVariables.js +1 -1
  15. package/dist/agents/components/run/AgentStatusIndicator.js +1 -1
  16. package/dist/agents/components/run/RunJobWorkingLine.js +1 -1
  17. package/dist/agents/components/shared/AgentNewRunButton.js +1 -1
  18. package/dist/agents/components/shared/AgentPlanningIndicator.js +1 -1
  19. package/dist/agents/conversation-export/conversation-transfer.js +1 -1
  20. package/dist/agents/conversation-export/document-markdown.js +1 -1
  21. package/dist/agents/hooks/useConversationRoutePromotion.js +1 -1
  22. package/dist/agents/hooks/useModelControls.js +1 -1
  23. package/dist/agents/redux/agent-definition/converters.js +1 -1
  24. package/dist/agents/redux/agent-definition/slice.js +1 -1
  25. package/dist/agents/redux/conversation-list/conversation-list.thunks.js +1 -1
  26. package/dist/agents/redux/execution-system/active-requests/active-requests.selectors.js +1 -1
  27. package/dist/agents/redux/execution-system/instance-context/sync-canvas-item-context.thunk.js +1 -1
  28. package/dist/agents/redux/execution-system/thunks/process-stream.js +1 -1
  29. package/dist/agents/redux/execution-system/thunks/resolve-base-url.js +17 -0
  30. package/dist/agents/redux/execution-system/thunks/run-ai-stream.d.ts +7 -0
  31. package/dist/agents/redux/execution-system/thunks/run-ai-stream.js +13 -0
  32. package/dist/agents/redux/execution-system/thunks/run-headless-agent-json.js +14 -2
  33. package/dist/agents/redux/execution-system/utils/assemble-cx-content-blocks.js +1 -1
  34. package/dist/agents/redux/execution-system/utils/normalize-content-blocks.js +1 -1
  35. package/dist/agents/redux/execution-system/utils/output-contract-guard.js +1 -1
  36. package/dist/agents/redux/execution-system/utils/stream-block-accumulator.js +8 -8
  37. package/dist/agents/routing/confidential-routing.d.ts +52 -0
  38. package/dist/agents/routing/confidential-routing.js +38 -0
  39. package/dist/agents/utils/canvasItemContext.js +1 -1
  40. package/dist/canvas/workspace/ChatPanelTitleMenu.js +1 -1
  41. package/dist/canvas/workspace/useCanvasWorkspaceConversation.js +1 -1
  42. package/dist/cx-chat/components/SsrSidebarChats.js +1 -1
  43. package/dist/cx-chat/components/core/ChatConversationClient.js +1 -1
  44. package/dist/cx-chat/components/messages/AssistantMessage.js +1 -1
  45. package/dist/cx-chat/hooks/useInstanceBootstrap.js +1 -1
  46. package/dist/cx-conversation/AssistantMessage.js +1 -1
  47. package/dist/host/configure.js +4 -1
  48. package/dist/host/contract.d.ts +14 -1
  49. package/dist/host/index.d.ts +1 -0
  50. package/dist/host/index.js +1 -0
  51. package/dist/mandates/llm-params.d.ts +1 -1
  52. package/dist/mandates/output-contract.js +1 -1
  53. package/dist/mandates/service.d.ts +1 -1
  54. package/dist/mandates/service.js +1 -1
  55. package/dist/mandates/test-run-core.js +1 -1
  56. package/dist/public-chat/components/PublicMessageOptionsMenu.js +1 -1
  57. package/dist/surfaces/services/surface-config.service.js +1 -1
  58. package/dist/tool-call-visualization/components/ToolCallBatch.js +1 -1
  59. package/dist/tool-call-visualization/components/ToolCallVisualization.js +1 -1
  60. package/dist/tool-call-visualization/renderers/agent-call/AgentCallInline.js +1 -1
  61. package/dist/tool-call-visualization/renderers/agent-call/CollabCallCard.js +1 -1
  62. package/dist/tool-call-visualization/renderers/agent-call/collab-subtitle.js +3 -3
  63. package/dist/tool-call-visualization/renderers/skill/SkillInline.js +1 -1
  64. package/dist/tool-call-visualization/result-fields/KeyValueGrid.js +1 -1
  65. package/dist/tool-call-visualization/result-fields/ResultValue.js +1 -1
  66. package/dist/tool-call-visualization/result-fields/shape.js +1 -1
  67. package/dist/tool-call-visualization/utils/cxToolCallToLifecycleEntry.js +2 -2
  68. package/dist/tool-call-visualization/utils/human-copy.js +3 -3
  69. package/dist/ui/mandates-storage/provision-shapes.d.ts +1 -1
  70. package/dist/ui/mandates-storage/provision-shapes.js +1 -1
  71. package/dist/ui/markdown-stream/EnhancedChatMarkdown.js +1 -1
  72. package/dist/ui/treatment-shape.d.ts +1 -1
  73. package/dist/ui/treatment-shape.js +1 -1
  74. package/dist/voice-agent/relay/useVoiceRelaySession.js +1 -1
  75. package/package.json +26 -9
  76. package/dist/agents/hooks/useWarmAgent.d.ts +0 -8
  77. package/dist/agents/hooks/useWarmAgent.js +0 -25
  78. package/dist/agents/utils/artifactId.d.ts +0 -34
  79. package/dist/agents/utils/artifactId.js +0 -15
  80. package/dist/ui/ShimmerText.d.ts +0 -5
  81. package/dist/ui/ShimmerText.js +0 -21
  82. package/dist/ui/addressWithoutNavigating.d.ts +0 -68
  83. package/dist/ui/addressWithoutNavigating.js +0 -60
  84. package/dist/utils/content-ir/decision-answers-ids.d.ts +0 -3
  85. package/dist/utils/content-ir/decision-answers-ids.js +0 -6
  86. package/dist/utils/content-ir/envelope-parity.d.ts +0 -12
  87. package/dist/utils/content-ir/envelope-parity.js +0 -32
  88. package/dist/utils/content-ir/instance-title.d.ts +0 -26
  89. package/dist/utils/content-ir/instance-title.js +0 -39
  90. package/dist/utils/content-ir/kinds/kind-markdown-utils.d.ts +0 -84
  91. package/dist/utils/content-ir/kinds/kind-markdown-utils.js +0 -233
  92. package/dist/utils/content-ir/kinds/kind-value-markdown.d.ts +0 -5
  93. package/dist/utils/content-ir/kinds/kind-value-markdown.js +0 -17
  94. package/dist/utils/content-ir/legacy-quiz-envelope.d.ts +0 -3
  95. package/dist/utils/content-ir/legacy-quiz-envelope.js +0 -45
  96. package/dist/utils/content-ir/surfaces/embedded-kind-json.d.ts +0 -140
  97. package/dist/utils/content-ir/surfaces/embedded-kind-json.js +0 -527
  98. package/dist/utils/content-ir/surfaces/json-kind-signal.d.ts +0 -307
  99. package/dist/utils/content-ir/surfaces/json-kind-signal.js +0 -945
  100. package/dist/utils/content-ir/surfaces/kind-image-alt.d.ts +0 -27
  101. package/dist/utils/content-ir/surfaces/kind-image-alt.js +0 -117
  102. package/dist/utils/content-ir/surfaces/kind-one-line.d.ts +0 -67
  103. package/dist/utils/content-ir/surfaces/kind-one-line.js +0 -209
  104. package/dist/utils/content-ir/surfaces/kind-text-label.d.ts +0 -20
  105. package/dist/utils/content-ir/surfaces/kind-text-label.js +0 -50
  106. package/dist/utils/content-ir/surfaces/kind-text-to-markdown.d.ts +0 -47
  107. package/dist/utils/content-ir/surfaces/kind-text-to-markdown.js +0 -399
  108. package/dist/utils/content-ir/surfaces/markdown-escaped-kind.d.ts +0 -54
  109. package/dist/utils/content-ir/surfaces/markdown-escaped-kind.js +0 -128
  110. package/dist/utils/content-ir/surfaces/quoted-kind-lift.d.ts +0 -61
  111. package/dist/utils/content-ir/surfaces/quoted-kind-lift.js +0 -215
  112. package/dist/utils/inline-decision/decision-options.d.ts +0 -21
  113. package/dist/utils/inline-decision/decision-options.js +0 -32
  114. package/dist/utils/json.d.ts +0 -63
  115. package/dist/utils/json.js +0 -22
  116. package/dist/utils/markdown/plain-title.d.ts +0 -25
  117. package/dist/utils/markdown/plain-title.js +0 -51
  118. package/dist/utils/rendered-find.d.ts +0 -9
  119. package/dist/utils/rendered-find.js +0 -68
  120. package/dist/utils/rich-editor/core/caret-context.d.ts +0 -24
  121. package/dist/utils/rich-editor/core/caret-context.js +0 -73
  122. package/dist/utils/rich-editor/in-place/caret-handoff.d.ts +0 -3
  123. package/dist/utils/rich-editor/in-place/caret-handoff.js +0 -15
@@ -1,4 +1,4 @@
1
- import { isMaterializedArtifactId } from "./artifactId.js";
1
+ import { isMaterializedArtifactId } from "@ai-matrx/rich-content/utils/lifted/artifactId";
2
2
  const CANVAS_ITEM_SOURCE_KIND = "canvas_item";
3
3
  const DESCRIPTION = "A pinned conversation artifact (code or JSON). Read with ctx_get on this key (the artifact UUID). Apply every change with ctx_patch \u2014 edits save as a new version of the same artifact. Do NOT recreate it; extend or edit it.";
4
4
  function isCanvasItemContextKey(key) {
@@ -8,7 +8,7 @@ import { useAppSelector } from "../../store/hooks.js";
8
8
  import { selectConversationTitle } from "../../agents/redux/execution-system/conversations/conversations.selectors.js";
9
9
  import { selectConversationListItemById } from "../../agents/redux/conversation-list/conversation-list.selectors.js";
10
10
  import { conversationRenameOpener } from "../../agents/components/conversation-actions/rename/conversationRenameOpener.js";
11
- import { conversationTitleText } from "../../utils/content-ir/surfaces/kind-text-label.js";
11
+ import { conversationTitleText } from "@ai-matrx/content-ir/surfaces";
12
12
  import { Button, Tile } from "@ai-matrx/design-system/controls";
13
13
  import { ConversationHistorySidebar } from "../../agents/components/conversation-history/ConversationHistorySidebar.js";
14
14
  const PANEL_HISTORY_SCOPE = "chat-panel-menu";
@@ -7,7 +7,7 @@ import { resumeConversation } from "../../agents/redux/execution-system/thunks/r
7
7
  import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
8
8
  import { selectShouldPromptForOrganization } from "../../host/ui-slots.js";
9
9
  import { selectIsCacheOnly } from "../../agents/redux/execution-system/conversations/conversations.selectors.js";
10
- import { replaceAddressWithoutNavigating } from "../../ui/addressWithoutNavigating.js";
10
+ import { replaceAddressWithoutNavigating } from "@ai-matrx/rich-content/utils/addressWithoutNavigating";
11
11
  import { describeLaunchError } from "./describe-launch-error.js";
12
12
  import { selectOrganizationId, ensureOrganizationContext, isOrganizationSelectionCancelled } from "../../host/org.js";
13
13
  function initialRequest(start) {
@@ -37,7 +37,7 @@ const toSidebarItem = (c) => ({
37
37
  status: c.status
38
38
  });
39
39
  const selectSidebarConversations = (state) => selectGlobalConversationList(state);
40
- import { conversationTitleText } from "../../utils/content-ir/surfaces/kind-text-label.js";
40
+ import { conversationTitleText } from "@ai-matrx/content-ir/surfaces";
41
41
  const GROUP_ORDER = ["Today", "Yesterday", "This Week", "This Month", "Older"];
42
42
  function groupByTime(items) {
43
43
  const now = /* @__PURE__ */ new Date();
@@ -24,7 +24,7 @@ import { useComposerMode } from "../../../agents/components/inputs/smart-input/c
24
24
  import { ProposedDirectivesZone } from "../../../host/ui-slots.js";
25
25
  import { ServerOperationBanner } from "../../../agents/runtime-reconnect/ServerOperationBanner.js";
26
26
  import { pushAppHref } from "../../../host/ui-slots.js";
27
- import { replaceAddressWithoutNavigating } from "../../../ui/addressWithoutNavigating.js";
27
+ import { replaceAddressWithoutNavigating } from "@ai-matrx/rich-content/utils/addressWithoutNavigating";
28
28
  import { Button } from "@ai-matrx/design-system/controls";
29
29
  function ChatConversationClient({
30
30
  conversationId,
@@ -13,7 +13,7 @@ import {
13
13
  Save
14
14
  } from "lucide-react";
15
15
  import { Button } from "@ai-matrx/design-system/controls";
16
- import { MarkdownStream } from "../../../ui/markdown-stream/MarkdownStream.js";
16
+ import MarkdownStream from "../../../ui/markdown-stream/MarkdownStream.js";
17
17
  import AudioOutputBlockSkeleton from "../../../ui/AudioOutputBlockSkeleton.js";
18
18
  import { useDomCapturePrint } from "../../../conversation/hooks/useDomCapturePrint.js";
19
19
  import { useAppSelector, useAppDispatch } from "../../../store/hooks.js";
@@ -12,7 +12,7 @@ import { toast } from "../../host/notify.js";
12
12
  import { isNotAuthenticatedError } from "../../host/identity.js";
13
13
  import { isOrganizationSelectionCancelled } from "../../host/org.js";
14
14
  import { DEFAULT_AGENT_ID } from "../components/agent/local-agents.js";
15
- import { replaceAddressWithoutNavigating } from "../../ui/addressWithoutNavigating.js";
15
+ import { replaceAddressWithoutNavigating } from "@ai-matrx/rich-content/utils/addressWithoutNavigating";
16
16
  import { ensureAgentCatalog, isAgentCatalogStale } from "../../agents/identity/agent-identity.js";
17
17
  function parseChatUrl(pathname, searchParams) {
18
18
  const agentPathMatch = pathname.match(/\/demos\/chat\/a\/([^/?]+)/);
@@ -13,7 +13,7 @@ import {
13
13
  Save
14
14
  } from "lucide-react";
15
15
  import { Button } from "@ai-matrx/design-system/controls";
16
- import { MarkdownStream } from "../ui/markdown-stream/MarkdownStream.js";
16
+ import MarkdownStream from "../ui/markdown-stream/MarkdownStream.js";
17
17
  import AudioOutputBlockSkeleton from "../ui/AudioOutputBlockSkeleton.js";
18
18
  import { useDomCapturePrint } from "../conversation/hooks/useDomCapturePrint.js";
19
19
  import { useAppSelector, useAppDispatch } from "../store/hooks.js";
@@ -44,8 +44,10 @@ const PORTS = [
44
44
  "chrome",
45
45
  "feedback",
46
46
  "routes",
47
- "canvas"
47
+ "canvas",
48
+ "routing"
48
49
  ];
50
+ const ANY_ROUTING = Object.freeze({ policy: () => "any" });
49
51
  const EMPTY_REGISTRATIONS = Object.freeze({});
50
52
  function assertDb(host) {
51
53
  const db = host?.db;
@@ -127,6 +129,7 @@ function resolveChatHost(host) {
127
129
  feedback: host.feedback ?? createDbFeedback(db, () => ref.identity),
128
130
  routes: { ...DEFAULT_CHAT_ROUTES, ...host.routes },
129
131
  canvas: host.canvas ?? createUnhostedCanvas(() => ref.diagnostics),
132
+ routing: host.routing ?? ANY_ROUTING,
130
133
  overridden
131
134
  });
132
135
  return ref;
@@ -25,6 +25,7 @@ import type { ChatCanvasTabKind } from "./canvas-tabs.js";
25
25
  import type { ChatWindowOpeners } from "./window-openers.js";
26
26
  import type { DefaultChatServerApi, DefaultChatServerTypes } from "./defaults/server-api.js";
27
27
  import type { ChatMessageSource } from "./source.js";
28
+ import type { ChatRoutingPolicy } from "../agents/routing/confidential-routing.js";
28
29
  /**
29
30
  * The connection contract (R10). Authenticated, RLS applies. Typed with the
30
31
  * package's own `ChatDatabase` (`./db-types`, generated: the schemas the
@@ -731,6 +732,15 @@ export interface ChatAppIdentity {
731
732
  /** `source_feature` for every conversation this app starts; absent keeps each screen's own. */
732
733
  sourceFeature?: string;
733
734
  }
735
+ /**
736
+ * Where each conversation's text may go (lanes/agents-chat-proposal.md W0(a)). The package enforces
737
+ * the answer at the one place every send resolves its target (`resolveBackendForConversation`): a
738
+ * `"local-only"` (confidential) conversation refuses every target but the Matrx Local engine on this
739
+ * computer, loudly, before a byte leaves the machine. Default: `"any"` for every conversation.
740
+ */
741
+ export interface ChatRoutingPort {
742
+ policy(conversationId: string): ChatRoutingPolicy;
743
+ }
734
744
  export interface ChatHost {
735
745
  /**
736
746
  * R10 connection contract. Authenticated, RLS applies. Required unless `source` is given: a
@@ -791,8 +801,10 @@ export interface ChatHost {
791
801
  routes?: Partial<ChatRoutes>;
792
802
  /** Default: no canvas here — every open refuses and says so. */
793
803
  canvas?: ChatCanvasPort;
804
+ /** Default: every conversation may go to any target (`"any"`). */
805
+ routing?: ChatRoutingPort;
794
806
  }
795
- export type ChatPortName = "identity" | "org" | "server" | "notify" | "diagnostics" | "prefs" | "navigation" | "windows" | "catalog" | "registry" | "chrome" | "feedback" | "routes" | "canvas";
807
+ export type ChatPortName = "identity" | "org" | "server" | "notify" | "diagnostics" | "prefs" | "navigation" | "windows" | "catalog" | "registry" | "chrome" | "feedback" | "routes" | "canvas" | "routing";
796
808
  /** Every port present. `overridden` names the ports the host supplied itself. */
797
809
  export interface ResolvedChatHost {
798
810
  /** The host's client, or the no-database stand-in when it gave only a `source`. */
@@ -818,5 +830,6 @@ export interface ResolvedChatHost {
818
830
  feedback: ChatFeedbackPort;
819
831
  routes: ChatRoutes;
820
832
  canvas: ChatCanvasPort;
833
+ routing: ChatRoutingPort;
821
834
  overridden: ReadonlySet<ChatPortName>;
822
835
  }
@@ -24,3 +24,4 @@ export { createClient, getClaimsUser, schedulerDb, supabase, type ChatClaimsUser
24
24
  export type { ChatDatabase } from "./db-types.js";
25
25
  export { ChatNoDatabaseError, NO_DATABASE_CODE_PREFIX, createNoDatabaseStandIn, isChatNoDatabaseError, isNoDatabase, } from "./no-database.js";
26
26
  export * from "./source.js";
27
+ export * from "../agents/routing/confidential-routing.js";
@@ -55,6 +55,7 @@ import {
55
55
  isNoDatabase
56
56
  } from "./no-database.js";
57
57
  export * from "./source.js";
58
+ export * from "../agents/routing/confidential-routing.js";
58
59
  export {
59
60
  CHAT_ACTIVE_ORG_STORAGE_KEY,
60
61
  CHAT_PREFS_PREFIX,
@@ -5,6 +5,6 @@
5
5
  * keys the client run path honours. Field by field, no casts; unknown keys
6
6
  * are dropped LOUDLY (the server's apply_overrides stays the authority).
7
7
  */
8
- import type { JsonObject } from "../utils/json.js";
8
+ import type { JsonObject } from "@ai-matrx/rich-content/utils/json";
9
9
  import type { FeLlmParams } from "../agents/types/agent-api-types.js";
10
10
  export declare function toLlmParams(obj: JsonObject): Partial<FeLlmParams>;
@@ -1,5 +1,5 @@
1
1
  import { createClient } from "../host/db.js";
2
- import { isJsonObject } from "../utils/json.js";
2
+ import { isJsonObject } from "@ai-matrx/rich-content/utils/json";
3
3
  import { hasBrowserSession } from "../host/identity.js";
4
4
  function outputSchemaKeys(outputSchema) {
5
5
  if (!isJsonObject(outputSchema)) return /* @__PURE__ */ new Set();
@@ -1,7 +1,7 @@
1
1
  import type { FeLlmParams } from "../agents/types/agent-api-types.js";
2
2
  import { type OrganizationAdmission } from "../host/server/organization-admission.js";
3
3
  import { type MandateContract } from "@ai-matrx/agents/mandates";
4
- import type { JsonObject } from "../utils/json.js";
4
+ import type { JsonObject } from "@ai-matrx/rich-content/utils/json";
5
5
  import type { AnyMandateKey } from "@ai-matrx/agents/mandates";
6
6
  import { type BindingPresentation } from "../ui/treatment-shape.js";
7
7
  export interface ResolvedMandate {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { createClient } from "../host/db.js";
3
3
  import { getClaimsUser } from "../host/db.js";
4
- import { isJsonObject } from "../utils/json.js";
4
+ import { isJsonObject } from "@ai-matrx/rich-content/utils/json";
5
5
  import { recordUnavailable } from "../host/diagnostics.js";
6
6
  import { apiGet, buildPath } from "../host/server/typed-client.js";
7
7
  import { BackendApiError } from "@ai-matrx/agents/matrx";
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { isJsonObject } from "../utils/json.js";
2
+ import { isJsonObject } from "@ai-matrx/rich-content/utils/json";
3
3
  import { usableServerNotes } from "../ui/usable-server-notes.js";
4
4
  function readMandateRunHolder(result) {
5
5
  if (!isJsonObject(result)) {
@@ -26,7 +26,7 @@ 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";
29
- import { kindTextToMarkdown } from "../../utils/content-ir/surfaces/kind-text-to-markdown.js";
29
+ import { kindTextToMarkdown } from "@ai-matrx/content-ir/surfaces";
30
30
  import { removeCodeSpans, replaceFences } from "@ai-matrx/content-ir/source";
31
31
  import { selectOrganizationId, ensureOrganizationContext, isOrganizationSelectionCancelled } from "../../host/org.js";
32
32
  import { downloadFile } from "@ai-matrx/kit/download";
@@ -3,7 +3,7 @@ import { storedMandateKey } from "@ai-matrx/agents/mandates";
3
3
  import { createClient } from "../../host/db.js";
4
4
  import { writeOne } from "@ai-matrx/data/db";
5
5
  import { getClaimsUser } from "../../host/db.js";
6
- import { isJsonObject } from "../../utils/json.js";
6
+ import { isJsonObject } from "@ai-matrx/rich-content/utils/json";
7
7
  import { fetchMandatePins } from "../../mandates/service.js";
8
8
  import {
9
9
  getNamespaceHandler,
@@ -4,7 +4,7 @@ import { useEffect, useState } from "react";
4
4
  import { ChevronDown, ChevronRight } from "lucide-react";
5
5
  import { cn } from "@ai-matrx/design-system";
6
6
  import { useAppSelector } from "../../store/hooks.js";
7
- import { ShimmerText } from "../../ui/ShimmerText.js";
7
+ import { ShimmerText } from "@ai-matrx/rich-content/utils/lifted/ShimmerText";
8
8
  import { getToolDisplayName } from "../registry/registry.js";
9
9
  import { DIFF_START_OPEN_KNOB, readSurfaceWrite } from "../surface-write/readSurfaceWrite.js";
10
10
  import { holdsADecision } from "./holdsADecision.js";
@@ -11,7 +11,7 @@ import { cn } from "@ai-matrx/design-system";
11
11
  import { useAppDispatch, useAppSelector } from "../../store/hooks.js";
12
12
  import { smartExecute } from "../../agents/redux/execution-system/thunks/smart-execute.thunk.js";
13
13
  import { openOverlay, CHAT_WINDOWS } from "../../host/windows.js";
14
- import { ShimmerText } from "../../ui/ShimmerText.js";
14
+ import { ShimmerText } from "@ai-matrx/rich-content/utils/lifted/ShimmerText";
15
15
  import {
16
16
  getInlineRenderer,
17
17
  getToolDisplayName,
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useMemo } from "react";
4
4
  import { Aperture, ImageIcon } from "lucide-react";
5
- import { MarkdownStream } from "../../../ui/markdown-stream/MarkdownStream.js";
5
+ import MarkdownStream from "../../../ui/markdown-stream/MarkdownStream.js";
6
6
  import { useAppSelector } from "../../../store/hooks.js";
7
7
  import { selectAgentCallChildStream } from "../../../agents/redux/execution-system/active-requests/active-requests.selectors.js";
8
8
  import { GenericRenderer } from "../../registry/GenericRenderer.js";
@@ -7,7 +7,7 @@ import { useAppSelector } from "../../../store/hooks.js";
7
7
  import { selectAgentCallChildStream } from "../../../agents/redux/execution-system/active-requests/active-requests.selectors.js";
8
8
  import { useConversationTitle } from "../../../agents/hooks/useConversationTitle.js";
9
9
  import { EntityRef } from "../../../host/ui-slots.js";
10
- import { MarkdownStream } from "../../../ui/markdown-stream/MarkdownStream.js";
10
+ import MarkdownStream from "../../../ui/markdown-stream/MarkdownStream.js";
11
11
  import { AnswerValueView } from "../../../host/ui-slots.js";
12
12
  import { stripThinkingStreaming } from "@ai-matrx/kit/text";
13
13
  import { cn } from "@ai-matrx/design-system";
@@ -1,6 +1,6 @@
1
- import { kindTextLabel } from "../../../utils/content-ir/surfaces/kind-text-label.js";
2
- import { deriveInstanceTitle } from "../../../utils/content-ir/instance-title.js";
3
- import { humanizeKind } from "../../../utils/content-ir/kinds/kind-markdown-utils.js";
1
+ import { kindTextLabel } from "@ai-matrx/content-ir/surfaces";
2
+ import { deriveInstanceTitle } from "@ai-matrx/content-ir/surfaces";
3
+ import { humanizeKind } from "@ai-matrx/content-ir/surfaces";
4
4
  import { getCollabCallInfo } from "./collab.js";
5
5
  const MAX = 90;
6
6
  function valueLabel(value) {
@@ -7,7 +7,7 @@ import { GenericRenderer } from "../../registry/GenericRenderer.js";
7
7
  import { ToolErrorCard } from "../../result-fields/ToolErrorCard.js";
8
8
  import { humanizeEnumValue } from "../../result-fields/shape.js";
9
9
  import { ToolResultCard } from "../_shared-entity/ToolResultCard.js";
10
- import { catalogProseText } from "../../../utils/content-ir/surfaces/kind-one-line.js";
10
+ import { catalogProseText } from "@ai-matrx/content-ir/surfaces";
11
11
  const SKILL_ICON_TINT = "text-violet-600 dark:text-violet-400";
12
12
  function humanType(raw) {
13
13
  if (typeof raw !== "string" || !raw) return null;
@@ -15,7 +15,7 @@ import {
15
15
  useStructuredDocumentPresentation
16
16
  } from "./document-presentation.js";
17
17
  import { KindValueNode } from "./KindValueNode.js";
18
- import { rootKindSlug } from "../../utils/content-ir/surfaces/json-kind-signal.js";
18
+ import { rootKindSlug } from "@ai-matrx/content-ir/surfaces";
19
19
  import { useReportKindAtRawRenderer } from "@ai-matrx/rich-content/utils/report-kind-at-raw-renderer";
20
20
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
21
21
  import { Button } from "@ai-matrx/design-system/controls";
@@ -16,7 +16,7 @@ import { ShortId, IdListChip } from "./ShortId.js";
16
16
  import { KindValueNode } from "./KindValueNode.js";
17
17
  import { ResultRecordRef } from "./ResultRecordRef.js";
18
18
  import { TextWithDoors } from "../../host/ui-slots.js";
19
- import { valueCarriesKind } from "../../utils/content-ir/surfaces/json-kind-signal.js";
19
+ import { valueCarriesKind } from "@ai-matrx/content-ir/surfaces";
20
20
  import { useReportKindAtRawRenderer } from "@ai-matrx/rich-content/utils/report-kind-at-raw-renderer";
21
21
  import { Button } from "@ai-matrx/design-system/controls";
22
22
  const INLINE_MAX_DEPTH = 2;
@@ -9,7 +9,7 @@ import {
9
9
  markdownCarriesKind,
10
10
  rootKindSlug,
11
11
  valueCarriesKind
12
- } from "../../utils/content-ir/surfaces/json-kind-signal.js";
12
+ } from "@ai-matrx/content-ir/surfaces";
13
13
  import { humanizeIdentifier } from "@ai-matrx/kit/text-case";
14
14
  const hasMarkdownTable = (value) => findTableStart(value.split("\n")) !== -1;
15
15
  function isPlainObject(value) {
@@ -1,8 +1,8 @@
1
- import { humanizeKind } from "../../utils/content-ir/kinds/kind-markdown-utils.js";
1
+ import { humanizeKind } from "@ai-matrx/content-ir/surfaces";
2
2
  import {
3
3
  firstKindSlug,
4
4
  jsonKindSignal
5
- } from "../../utils/content-ir/surfaces/json-kind-signal.js";
5
+ } from "@ai-matrx/content-ir/surfaces";
6
6
  import { displayNameFromToolEvents } from "./toolDisplayName.js";
7
7
  function parseOutput(raw) {
8
8
  if (!raw) return null;
@@ -1,6 +1,6 @@
1
- import { kindValueToMarkdown } from "../../utils/content-ir/kinds/kind-value-markdown.js";
2
- import { valueCarriesKind } from "../../utils/content-ir/surfaces/json-kind-signal.js";
3
- import { kindTextToMarkdown } from "../../utils/content-ir/surfaces/kind-text-to-markdown.js";
1
+ import { kindValueToMarkdown } from "@ai-matrx/content-ir/surfaces";
2
+ import { valueCarriesKind } from "@ai-matrx/content-ir/surfaces";
3
+ import { kindTextToMarkdown } from "@ai-matrx/content-ir/surfaces";
4
4
  function prettyJson(value) {
5
5
  try {
6
6
  return JSON.stringify(value, null, 2);
@@ -31,7 +31,7 @@
31
31
  * HERE at ingress with runtime validation — never a cast on the row.
32
32
  */
33
33
  import type { Json } from "../../host/db-types.js";
34
- import { type JsonObject } from "../../utils/json.js";
34
+ import { type JsonObject } from "@ai-matrx/rich-content/utils/json";
35
35
  import type { ValueMapping } from "../../surfaces/types.js";
36
36
  import type { AnyMandateKey } from "@ai-matrx/agents/mandates";
37
37
  /** Kind slugs whose values are prompt-substitutable scalars. Anything else
@@ -1,4 +1,4 @@
1
- import { isJsonObject } from "../../utils/json.js";
1
+ import { isJsonObject } from "@ai-matrx/rich-content/utils/json";
2
2
  import { humanizeIdentifier, displayLabel } from "@ai-matrx/kit/text-case";
3
3
  const SCALAR_VALUE_KINDS = /* @__PURE__ */ new Set([
4
4
  "text",
@@ -14,7 +14,7 @@ function MaybeSourceEdit({ source, save, children }) {
14
14
  return /* @__PURE__ */ jsx(OptionalMarkdownSourceEditProvider, { source, save, children });
15
15
  }
16
16
  import { RichCopySplit } from "../../agent-copy/RichCopySplit.js";
17
- import { ShimmerText } from "../ShimmerText.js";
17
+ import { ShimmerText } from "@ai-matrx/rich-content/utils/lifted/ShimmerText";
18
18
  import {
19
19
  RunJobWorkingLine,
20
20
  useIsRunJob
@@ -1,4 +1,4 @@
1
- import { type JsonObject, type JsonValue } from "../utils/json.js";
1
+ import { type JsonObject, type JsonValue } from "@ai-matrx/rich-content/utils/json";
2
2
  import type { ResultDisplayMode } from "../agents/utils/run-ui-utils.js";
3
3
  import type { VariablesPanelStyle } from "../agents/components/inputs/variable-input-variations/variable-input-options.js";
4
4
  import type { WritePolicyMap } from "../surfaces/types.js";
@@ -1,4 +1,4 @@
1
- import { isJsonObject } from "../utils/json.js";
1
+ import { isJsonObject } from "@ai-matrx/rich-content/utils/json";
2
2
  const TREATMENT_TIER_WIDGET = "widget";
3
3
  const TREATMENT_SCHEMA_VERSION = 1;
4
4
  function defaultPresentation() {
@@ -28,7 +28,7 @@ import {
28
28
  setContextEntry
29
29
  } from "../../agents/redux/execution-system/instance-context/instance-context.slice.js";
30
30
  import { MANDATE_KEYS } from "@ai-matrx/agents/mandates";
31
- import { kindTextToMarkdown } from "../../utils/content-ir/surfaces/kind-text-to-markdown.js";
31
+ import { kindTextToMarkdown } from "@ai-matrx/content-ir/surfaces";
32
32
  const VOICE_COMMUNICATOR_MANDATE_KEY = MANDATE_KEYS.voice__communicator;
33
33
  const NARRATION_DELAY_MS = 2500;
34
34
  registerCommunicationLedgerTool();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/chat",
3
- "version": "0.4.9",
3
+ "version": "0.4.12",
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",
@@ -227,25 +227,25 @@
227
227
  "uuid": "^14.0.2",
228
228
  "zod": "^4.6.5",
229
229
  "@ai-matrx/agents": "latest",
230
+ "@ai-matrx/alchemy": "latest",
230
231
  "@ai-matrx/associations": "latest",
231
232
  "@ai-matrx/browser-audio": "latest",
232
- "@ai-matrx/alchemy": "latest",
233
- "@ai-matrx/canvas": "latest",
234
233
  "@ai-matrx/content-ir": "latest",
235
- "@ai-matrx/diff": "latest",
234
+ "@ai-matrx/canvas": "latest",
235
+ "@ai-matrx/data": "latest",
236
236
  "@ai-matrx/content-ir-react": "latest",
237
237
  "@ai-matrx/design-system": "latest",
238
- "@ai-matrx/data": "latest",
238
+ "@ai-matrx/diff": "latest",
239
239
  "@ai-matrx/icons": "latest",
240
- "@ai-matrx/media": "latest",
241
- "@ai-matrx/print": "latest",
242
240
  "@ai-matrx/kit": "latest",
241
+ "@ai-matrx/media": "latest",
243
242
  "@ai-matrx/realtime": "latest",
244
- "@ai-matrx/records": "latest",
243
+ "@ai-matrx/records-ui": "latest",
245
244
  "@ai-matrx/rich-content": "latest",
245
+ "@ai-matrx/print": "latest",
246
246
  "@ai-matrx/rich-editor": "latest",
247
247
  "@ai-matrx/tap-target": "latest",
248
- "@ai-matrx/records-ui": "latest"
248
+ "@ai-matrx/records": "latest"
249
249
  },
250
250
  "devDependencies": {
251
251
  "@arethetypeswrong/cli": "^0.18.5",
@@ -303,6 +303,23 @@
303
303
  "optional": true
304
304
  }
305
305
  },
306
+ "matrx": {
307
+ "charter": "The whole person-to-agent chat.",
308
+ "owns": [
309
+ "running agents",
310
+ "conversations",
311
+ "tool calls",
312
+ "streaming",
313
+ "context",
314
+ "voice"
315
+ ],
316
+ "mustNotOwn": [
317
+ "another package's logic",
318
+ "a second chat (src/compat, retiring)",
319
+ "its own host-slot copies"
320
+ ],
321
+ "layer": 9
322
+ },
306
323
  "scripts": {
307
324
  "build": "pnpm --filter @ai-matrx/rich-editor build && pnpm clean && tsup && node ./scripts/copy-css.mjs && node ./scripts/tsc-own.mjs -p tsconfig.build.json && node ./scripts/finish-build.mjs",
308
325
  "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
@@ -1,8 +0,0 @@
1
- interface UseWarmAgentOptions {
2
- /** Pass true when the id is an agx_version id rather than an agent.definition id. */
3
- isVersion?: boolean;
4
- /** Skip warming entirely (e.g. when the id isn't ready yet). */
5
- enabled?: boolean;
6
- }
7
- export declare function useWarmAgent(agentId: string | null | undefined, { isVersion, enabled }?: UseWarmAgentOptions): void;
8
- export {};
@@ -1,25 +0,0 @@
1
- "use client";
2
- import { useEffect } from "react";
3
- import { useAppSelector } from "../../store/hooks.js";
4
- import { selectResolvedBaseUrl } from "../../host/server/api-config.js";
5
- import { warmAgent } from "@ai-matrx/agents/matrx";
6
- function useWarmAgent(agentId, { isVersion = false, enabled = true } = {}) {
7
- const baseUrl = useAppSelector(
8
- selectResolvedBaseUrl
9
- );
10
- useEffect(() => {
11
- if (!enabled || !agentId || !baseUrl) return void 0;
12
- const fire = () => warmAgent(agentId, { baseUrl, isVersion });
13
- const ric = typeof window !== "undefined" ? window.requestIdleCallback : void 0;
14
- const cancel = typeof window !== "undefined" ? window.cancelIdleCallback : void 0;
15
- if (ric) {
16
- const handle2 = ric(fire, { timeout: 2e3 });
17
- return () => cancel?.(handle2);
18
- }
19
- const handle = window.setTimeout(fire, 500);
20
- return () => window.clearTimeout(handle);
21
- }, [agentId, baseUrl, isVersion, enabled]);
22
- }
23
- export {
24
- useWarmAgent
25
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * isMaterializedArtifactId — the R3 recognition primitive.
3
- *
4
- * An `<artifact>` (and every artifact renderer) carries an `id` that is EITHER:
5
- * - a real `canvas_items` UUID → the artifact is MATERIALIZED (persisted). The
6
- * UI renders the live row by id; data-touching types (tasks) can link/convert
7
- * against the stable artifact id.
8
- * - the model's own `artifact_N` (or a splitter fallback like `artifact-3`, or
9
- * nothing) → NOT yet materialized → render inline; it's a materialization
10
- * candidate, not a known artifact.
11
- *
12
- * This single UUID-shape test is what makes the whole system safe (vision R3):
13
- * it does NOT matter whether the model ever learns to emit the shape — a
14
- * non-UUID id is always treated as "new / unmaterialized", a UUID as "this exact
15
- * persisted artifact." Used by the renderers (render-by-id vs inline) and by
16
- * materialization (skip-already-materialized vs create-new).
17
- *
18
- * See `/Users/armanisadeghi/code/common-docs/systems/publish/artifacts/VISION.md` (R1–R3).
19
- */
20
- /** True only for a canonical UUID — i.e. a real, persisted `canvas_items.id`. */
21
- export declare function isMaterializedArtifactId(id?: string | null): boolean;
22
- /**
23
- * readArtifactPointerId — the pointer-shape reader.
24
- *
25
- * A canvas item whose artifact has been MATERIALIZED stores only a POINTER in
26
- * `content.data`: `{ artifactId }`. The body lives in the `canvas_items` row.
27
- * Anything that consumes `content.data` (render, share, export) must recognise
28
- * that shape instead of treating the pointer as the content — publishing a
29
- * pointer produces a page with nothing in it.
30
- *
31
- * Returns the materialized artifact UUID, or undefined when `data` is real
32
- * content (string, or an object that is not a pointer).
33
- */
34
- export declare function readArtifactPointerId(data: unknown): string | undefined;
@@ -1,15 +0,0 @@
1
- import { isUuidShape } from "@ai-matrx/kit/uuid";
2
- function isMaterializedArtifactId(id) {
3
- return typeof id === "string" && isUuidShape(id.trim());
4
- }
5
- function readArtifactPointerId(data) {
6
- if (typeof data !== "object" || data === null) return void 0;
7
- if (!("artifactId" in data)) return void 0;
8
- const id = data.artifactId;
9
- if (typeof id !== "string") return void 0;
10
- return isMaterializedArtifactId(id) ? id : void 0;
11
- }
12
- export {
13
- isMaterializedArtifactId,
14
- readArtifactPointerId
15
- };
@@ -1,5 +0,0 @@
1
- export interface ShimmerTextProps {
2
- text: string;
3
- className?: string;
4
- }
5
- export declare function ShimmerText({ text, className }: ShimmerTextProps): import("react").JSX.Element;
@@ -1,21 +0,0 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { cn } from "@ai-matrx/design-system";
4
- function ShimmerText({ text, className }) {
5
- return /* @__PURE__ */ jsx(
6
- "span",
7
- {
8
- className: cn(
9
- "inline-block bg-clip-text text-transparent bg-[length:200%_100%] animate-shimmer",
10
- className
11
- ),
12
- style: {
13
- backgroundImage: "linear-gradient(90deg, hsl(var(--muted-foreground) / 0.3) 0%, hsl(var(--foreground)) 50%, hsl(var(--muted-foreground) / 0.3) 100%)"
14
- },
15
- children: text
16
- }
17
- );
18
- }
19
- export {
20
- ShimmerText
21
- };