@ai-matrx/chat 0.7.11 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @ai-matrx/chat
2
2
 
3
+ ## 0.7.12
4
+ ### Unreleased
5
+ ### The variables a run used (Agent Factory R59)
6
+
7
+ - **`selectVariablesTheRunUsed(conversationId)`** (instance-variable-values selectors): the values a run's first turn was sent
8
+ with, frozen at send; before a send, the request merge. The builder's Side Chat helper reads it so a later edit of the field
9
+ cannot rewrite what the run was given.
10
+ - **Consumer action:** none.
11
+
12
+ ### A persisted answer paints with its markdown (spend register item 32, cold-load CLS at 1440)
13
+
14
+ - **`MarkdownStream`**: the engine chunk is requested when a conversation surface's module loads (`preloadMarkdownStream`), kept once
15
+ resolved, and rendered synchronously on the first render of a new instance. The per-instance `mounted` effect gate (an extra commit
16
+ after paint) is now `useSyncExternalStore` (still client-only: server and hydration render nothing). Before, the answer block painted
17
+ as a 36 px header and grew to its full height ~200 ms later, shifting everything below it (CLS 0.06-0.28 at 1440).
18
+ - **Consumer action:** none.
19
+
3
20
  ## 0.7.11
4
21
  ### continue-agent-json is exported again
5
22
 
@@ -6,7 +6,7 @@ import {
6
6
  useState,
7
7
  useEffect
8
8
  } from "react";
9
- import MarkdownStream from "../../../../ui/markdown-stream/MarkdownStream.js";
9
+ import MarkdownStream, { preloadMarkdownStream } from "../../../../ui/markdown-stream/MarkdownStream.js";
10
10
  import "../rich-document/chat-message-source.js";
11
11
  import { RecordAnnotations, annotationRecordOf } from "@ai-matrx/rich-content/host/app-bindings";
12
12
  import { useAppDispatch, useAppSelector } from "../../../../store/hooks.js";
@@ -91,6 +91,7 @@ import {
91
91
  } from "../../../../host/ui-slots.js";
92
92
  import { ErrorAlchemyMenu } from "../../../../host/ui-slots.js";
93
93
  import { useInPlaceTrigger } from "@ai-matrx/rich-editor/in-place/EditInPlace";
94
+ void preloadMarkdownStream();
94
95
  const _NO_LIVE_SOURCES = [];
95
96
  const _selectNoLiveSources = () => _NO_LIVE_SOURCES;
96
97
  function retryErrorMessage(err) {
@@ -105,6 +105,76 @@ export declare const selectOwnVariableValues: (conversationId: string) => ((stat
105
105
  memoize: typeof import("reselect").weakMapMemoize;
106
106
  argsMemoize: typeof import("reselect").weakMapMemoize;
107
107
  };
108
+ /**
109
+ * The variables a run USED: the values its first turn was sent with — frozen at
110
+ * send, host-wired names included — so a later edit of the variable field never
111
+ * rewrites what the run was given. Before any send it is what the next send would
112
+ * carry (the request merge, defaults included). Read by the agent builder's Side
113
+ * Chat helper to judge a test run.
114
+ */
115
+ export declare const selectVariablesTheRunUsed: (conversationId: string) => ((state: {
116
+ voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
117
+ agentDefinition: import("../../../types/agent-definition.types.js").AgentDefinitionSliceState;
118
+ conversationList: import("../../conversation-list/conversation-list.types.js").ConversationListState;
119
+ conversationHistory: import("../../conversation-history/types.js").ConversationHistoryState;
120
+ agentShortcut: import("../../agent-shortcuts/types.js").AgentShortcutSliceState;
121
+ agentShortcutCategory: import("../../agent-shortcut-categories/types.js").AgentShortcutCategorySliceState;
122
+ surfaceUserState: import("../../../../surfaces/redux/userStateSlice.js").SurfaceUserStateSlice;
123
+ conversations: import("../conversations/conversations.slice.js").ConversationsState;
124
+ chatIncognito: import("../../chat/chat-incognito.slice.js").ChatIncognitoState;
125
+ chatRoute: import("../../chat/chat-route.slice.js").ChatRouteState;
126
+ instanceModelOverrides: import("../instance-model-overrides/instance-model-overrides.slice.js").InstanceModelOverridesState;
127
+ instanceInputCapabilities: import("../instance-input-capabilities/instance-input-capabilities.slice.js").InstanceInputCapabilitiesState;
128
+ instanceVariableValues: import("./instance-variable-values.slice.js").InstanceVariableValuesState;
129
+ instanceResources: import("../instance-resources/instance-resources.slice.js").InstanceResourcesState;
130
+ instanceContext: import("../instance-context/instance-context.slice.js").InstanceContextState;
131
+ instanceWorkingDocument: import("../instance-working-document/instance-working-document.slice.js").InstanceWorkingDocumentSliceState;
132
+ instanceUserInput: import("../instance-user-input/instance-user-input.slice.js").InstanceUserInputSliceState;
133
+ instanceClientTools: import("../instance-client-tools/instance-client-tools.slice.js").InstanceClientToolsState;
134
+ pendingAsks: import("../../../ui-first-tools/redux/pending-asks.slice.js").PendingAsksState;
135
+ conversationInbox: import("../inbox/inbox.slice.js").ConversationInboxState;
136
+ agentLists: import("../../../ui-first-tools/redux/agent-lists.slice.js").AgentListsState;
137
+ instanceUIState: import("../instance-ui-state/instance-ui-state.slice.js").InstanceUIStateSlice;
138
+ activeTools: import("../active-tools/active-tools.slice.js").ActiveToolsState;
139
+ activeRequests: import("../active-requests/active-requests.slice.js").ActiveRequestsState;
140
+ runSets: import("../run-sets/run-sets.slice.js").RunSetsState;
141
+ messages: import("../messages/messages.slice.js").MessagesState;
142
+ observability: import("../observability/observability.slice.js").ObservabilityState;
143
+ contextState: import("../context-state/context-state.slice.js").ContextStateSliceState;
144
+ observationalMemory: import("../observational-memory/observational-memory.slice.js").ObservationalMemoryState;
145
+ cacheBypass: import("../message-crud/cache-bypass.slice.js").CacheBypassState;
146
+ conversationFocus: import("../conversation-focus/conversation-focus.slice.js").ConversationFocusState;
147
+ surfaces: import("../../surfaces/surfaces.slice.js").SurfacesState;
148
+ surfacesCatalog: import("../../../../surfaces/redux/surfacesCatalogSlice.js").SurfacesCatalogSliceState;
149
+ agentSurfaceBindings: import("../../../../surfaces/redux/agentSurfaceBindingsSlice.js").AgentSurfaceBindingsSliceState;
150
+ surfaceConfig: import("../../../../surfaces/redux/surfaceConfigSlice.js").SurfaceConfigSliceState;
151
+ agentAssistantMarkdownDraft: import("../../agent-assistant-markdown-draft.slice.js").AgentAssistantMarkdownDraftState;
152
+ mcp: import("../../mcp/mcp.slice.js").McpSliceState;
153
+ proposedDirectives: import("../../proposed-directives/proposedDirectivesSlice.js").ProposedDirectivesState;
154
+ conversationAttachments: import("../../../connectors/attachments.slice.js").AttachmentsSliceState;
155
+ chatHost: import("../../../../store/chat-host.slice.js").ChatHostState;
156
+ hostConversations: import("../host-conversations/host-conversations.slice.js").HostConversationsState;
157
+ } & import("../../../../store/root-state.js").ChatHostReadSlices) => Record<string, unknown>) & {
158
+ clearCache: () => void;
159
+ resultsCount: () => number;
160
+ resetResultsCount: () => void;
161
+ } & {
162
+ resultFunc: (resultFuncArgs_0: import("./instance-variable-values.slice.js").InstanceVariableValuesEntry) => Record<string, unknown>;
163
+ memoizedResultFunc: ((resultFuncArgs_0: import("./instance-variable-values.slice.js").InstanceVariableValuesEntry) => Record<string, unknown>) & {
164
+ clearCache: () => void;
165
+ resultsCount: () => number;
166
+ resetResultsCount: () => void;
167
+ };
168
+ lastResult: () => Record<string, unknown>;
169
+ dependencies: [(state: ChatRootState) => import("./instance-variable-values.slice.js").InstanceVariableValuesEntry];
170
+ recomputations: () => number;
171
+ resetRecomputations: () => void;
172
+ dependencyRecomputations: () => number;
173
+ resetDependencyRecomputations: () => void;
174
+ } & {
175
+ memoize: typeof import("reselect").weakMapMemoize;
176
+ argsMemoize: typeof import("reselect").weakMapMemoize;
177
+ };
108
178
  /** Immutable first-turn values, excluding names the host supplied. */
109
179
  export declare const selectOwnSubmittedFirstTurnValues: (conversationId: string) => ((state: {
110
180
  voiceAgent: import("../../../../voice-agent/types.js").VoiceAgentState;
@@ -25,6 +25,19 @@ const selectOwnVariableValues = (conversationId) => createSelector(
25
25
  return Object.keys(own).length === 0 ? EMPTY_RECORD : own;
26
26
  }
27
27
  );
28
+ const selectVariablesTheRunUsed = (conversationId) => createSelector(
29
+ (state) => state.instanceVariableValues.byConversationId[conversationId],
30
+ (entry) => {
31
+ if (!entry) return EMPTY_RECORD;
32
+ if (entry.submittedFirstTurnValues) return entry.submittedFirstTurnValues;
33
+ const merged = resolveVariablesForRequest({
34
+ definitions: entry.definitions,
35
+ userValues: entry.userValues,
36
+ scopeValues: entry.scopeValues
37
+ });
38
+ return Object.keys(merged).length > 0 ? merged : EMPTY_RECORD;
39
+ }
40
+ );
28
41
  const selectOwnSubmittedFirstTurnValues = (conversationId) => createSelector(
29
42
  (state) => state.instanceVariableValues.byConversationId[conversationId],
30
43
  (entry) => {
@@ -134,5 +147,6 @@ export {
134
147
  selectScopeVariableValues,
135
148
  selectUserVariableValues,
136
149
  selectVariableProvenance,
137
- selectVariablesForRequest
150
+ selectVariablesForRequest,
151
+ selectVariablesTheRunUsed
138
152
  };
@@ -83,6 +83,7 @@ export interface MarkdownStreamProps {
83
83
  */
84
84
  imagePolicy?: "self" | "other" | "ai" | "inherit";
85
85
  }
86
- declare function MarkdownStream(props: MarkdownStreamProps): import("react").FunctionComponentElement<import("react").SuspenseProps> | null;
86
+ export declare function preloadMarkdownStream(): Promise<void>;
87
+ declare function MarkdownStream(props: MarkdownStreamProps): import("react").FunctionComponentElement<import("react").SuspenseProps> | import("react").ReactElement<MarkdownStreamProps, string | import("react").JSXElementConstructor<any>> | null;
87
88
  export { MarkdownStream };
88
89
  export default MarkdownStream;
@@ -1,14 +1,33 @@
1
1
  "use client";
2
- import { createElement, lazy, Suspense, useEffect, useState } from "react";
2
+ import { createElement, lazy, Suspense, useSyncExternalStore } from "react";
3
3
  const MarkdownStreamImpl = lazy(() => import("./MarkdownStreamImpl.js"));
4
+ let loadedImpl = null;
5
+ let loading = null;
6
+ const readyListeners = /* @__PURE__ */ new Set();
7
+ function preloadMarkdownStream() {
8
+ if (typeof window === "undefined") return Promise.resolve();
9
+ loading ??= import("./MarkdownStreamImpl.js").then((m) => {
10
+ loadedImpl = m.default;
11
+ for (const notify of readyListeners) notify();
12
+ });
13
+ return loading;
14
+ }
15
+ const subscribeReady = (notify) => {
16
+ readyListeners.add(notify);
17
+ return () => readyListeners.delete(notify);
18
+ };
19
+ const clientReady = () => true;
20
+ const serverNotReady = () => false;
4
21
  function MarkdownStream(props) {
5
- const [mounted, setMounted] = useState(false);
6
- useEffect(() => setMounted(true), []);
7
- if (!mounted) return null;
22
+ const client = useSyncExternalStore(subscribeReady, clientReady, serverNotReady);
23
+ if (!client) return null;
24
+ if (loadedImpl) return createElement(loadedImpl, props);
25
+ void preloadMarkdownStream();
8
26
  return createElement(Suspense, { fallback: null }, createElement(MarkdownStreamImpl, props));
9
27
  }
10
28
  var MarkdownStream_default = MarkdownStream;
11
29
  export {
12
30
  MarkdownStream,
13
- MarkdownStream_default as default
31
+ MarkdownStream_default as default,
32
+ preloadMarkdownStream
14
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/chat",
3
- "version": "0.7.11",
3
+ "version": "0.7.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 explicit per-module subpaths @ai-matrx/chat/<domain>/<module> (no wildcards: scripts/public-modules.json) over a host contract (/host, /host/react) whose only required value is a db. One chat, one renderer: the old kernel entries (., /external-store, /matrx, /react, /tools, styles.css, tokens.css) are retired.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -4681,13 +4681,12 @@
4681
4681
  "server-only": "^0.0.1",
4682
4682
  "uuid": "^14.0.2",
4683
4683
  "zod": "^4.6.5",
4684
- "@ai-matrx/alchemy": "latest",
4685
4684
  "@ai-matrx/associations": "latest",
4686
4685
  "@ai-matrx/browser-audio": "latest",
4687
4686
  "@ai-matrx/canvas": "latest",
4688
- "@ai-matrx/content-ir": "latest",
4689
4687
  "@ai-matrx/agents": "latest",
4690
4688
  "@ai-matrx/content-ir-react": "latest",
4689
+ "@ai-matrx/alchemy": "latest",
4691
4690
  "@ai-matrx/data": "latest",
4692
4691
  "@ai-matrx/design-system": "latest",
4693
4692
  "@ai-matrx/icons": "latest",
@@ -4699,6 +4698,7 @@
4699
4698
  "@ai-matrx/records-ui": "latest",
4700
4699
  "@ai-matrx/rich-content": "latest",
4701
4700
  "@ai-matrx/rich-editor": "latest",
4701
+ "@ai-matrx/content-ir": "latest",
4702
4702
  "@ai-matrx/diff": "latest"
4703
4703
  },
4704
4704
  "devDependencies": {
@@ -4818,5 +4818,5 @@
4818
4818
  "check:side-effects": "node ../scripts/check-side-effects-listed.mjs . && node ../scripts/check-side-effects-listed.mjs --self-test",
4819
4819
  "check:public-surface": "node ./scripts/sync-public-surface.mjs --check && node ./scripts/sync-public-surface.mjs --self-test"
4820
4820
  },
4821
- "gitHead": "db3bd1fad7851f7648e0aeee094cf4df6152b3ae"
4821
+ "gitHead": "24ad46786a0c433cb3773b270bf74c9eb32898bc"
4822
4822
  }