@ai-matrx/chat 0.3.26 → 0.3.28

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 (29) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/agents/hooks/useAgentLauncher.js +4 -3
  3. package/dist/agents/redux/agent-definition/run-tier-record.d.ts +27 -0
  4. package/dist/agents/redux/agent-definition/run-tier-record.js +95 -0
  5. package/dist/agents/redux/agent-definition/selectors.d.ts +235 -231
  6. package/dist/agents/redux/agent-definition/selectors.js +3 -2
  7. package/dist/agents/redux/agent-definition/thunks.d.ts +2 -2
  8. package/dist/agents/redux/agent-definition/thunks.js +8 -63
  9. package/dist/agents/redux/conversation-list/conversation-list.selectors.js +2 -1
  10. package/dist/agents/redux/conversation-list/conversation-list.thunks.js +2 -1
  11. package/dist/agents/redux/conversation-list/record-conversation-from-execution.js +2 -1
  12. package/dist/agents/redux/execution-system/context-rules/request-context.js +8 -3
  13. package/dist/agents/redux/execution-system/instance-ui-state/instance-ui-state.selectors.js +6 -5
  14. package/dist/agents/redux/execution-system/thunks/create-instance.thunk.js +3 -2
  15. package/dist/agents/redux/execution-system/thunks/execute-manual-instance.thunk.js +3 -2
  16. package/dist/agents/redux/execution-system/thunks/launch-agent-execution.thunk.js +4 -4
  17. package/dist/agents/redux/execution-system/thunks/load-conversation.thunk.js +2 -1
  18. package/dist/agents/redux/execution-system/thunks/refresh-surface-scope.thunk.js +3 -2
  19. package/dist/agents/runtime/generation-job.js +2 -1
  20. package/dist/agents/runtime/get-model-capabilities.js +2 -1
  21. package/dist/cx-chat/hooks/useInstanceBootstrap.js +3 -1
  22. package/dist/host/db-types.d.ts +47 -1
  23. package/dist/ui/mandates-storage/mandateStorage.d.ts +19 -0
  24. package/dist/ui/mandates-storage/shortcutStorage.d.ts +38 -0
  25. package/dist/ui/permission-levels.d.ts +8 -2
  26. package/dist/ui/permission-levels.js +12 -1
  27. package/package.json +6 -6
  28. package/dist/agents/components/shared/AgentDuplicateOutcomeDialog.d.ts +0 -57
  29. package/dist/agents/components/shared/AgentDuplicateOutcomeDialog.js +0 -188
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-matrx/chat
2
2
 
3
+ ## 0.3.28
4
+
5
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
6
+ `git diff npm/chat/v0.3.27..npm/chat/v0.3.28 -- apps/shared/chat`).
7
+ No source changes intended and no consumer action required.
8
+
9
+ ## 0.3.27
10
+
11
+ Automatic changed-only republish (docs/metadata drift since the last tag — see
12
+ `git diff npm/chat/v0.3.26..npm/chat/v0.3.27 -- apps/shared/chat`).
13
+ No source changes intended and no consumer action required.
14
+
3
15
  ## 0.3.26 — 2026-10-07
4
16
 
5
17
  - `useDomCapturePrint` calls `captureDocumentPdf` (alchemy 0.20.2) — 0.3.22–0.3.25 imported the unpublished `documentToPdf`, so the PDF export reported an error.
@@ -22,6 +22,8 @@ import {
22
22
  } from "../../ui/projectCreateAiDebug.js";
23
23
  import { toast } from "../../host/notify.js";
24
24
  import { isNotAuthenticatedError } from "../../host/identity.js";
25
+ import { isOrganizationSelectionCancelled } from "../../host/org.js";
26
+ import { launchFailureMessage } from "../redux/execution-system/utils/launch-failure-message.js";
25
27
  function isConversationInvocation(options) {
26
28
  return "identity" in options && "engine" in options && "routing" in options && "origin" in options;
27
29
  }
@@ -289,6 +291,7 @@ function useAgentLauncher(agentId, optionsInput) {
289
291
  return;
290
292
  }
291
293
  if (isNotAuthenticatedError(err)) return;
294
+ if (isOrganizationSelectionCancelled(err)) return;
292
295
  if (isProjectCreateFlow(sourceFeature, agentId)) {
293
296
  warnProjectCreateAi(
294
297
  "useAgentLauncher \u2192 launchAgentExecution FAILED",
@@ -303,9 +306,7 @@ function useAgentLauncher(agentId, optionsInput) {
303
306
  } else {
304
307
  console.error("Failed to create agent conversation:", err);
305
308
  }
306
- toast.error(
307
- err instanceof Error && err.message ? err.message : "Failed to start the agent conversation."
308
- );
309
+ toast.error(launchFailureMessage(err, "Failed to start the agent conversation."));
309
310
  });
310
311
  return () => {
311
312
  launch.wanted = false;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * THE RUN TIER HAS ONE HOLDER (agent core B2 tail): the core run tier store
3
+ * (`@ai-matrx/agents/runtime`, bound by `agents/identity/run-tier-store.ts`). Chat's agent record
4
+ * never receives a copy of its answer. The record holds what the agent's OWN reads put there (the
5
+ * builder's full definition and unsaved edits, the fetch status the run thunks set); every field the
6
+ * record has not read is completed here, at read time, from the store's last answer:
7
+ *
8
+ * field the record READ (builder / edit) > run tier (`agx_get_run_tier`) > run controls
9
+ * access level: the dedicated `agx_get_access_level` answer > the record > the run tier
10
+ *
11
+ * The completed record is derived and cached per (record, answers) — the same object until one of
12
+ * them changes, so memoized selectors stay stable. The run thunks resolve the store BEFORE they
13
+ * dispatch (fetch status / fulfilled), so every `useAppSelector` re-reads after an answer lands.
14
+ */
15
+ import type { RunTierState } from "@ai-matrx/agents/runtime";
16
+ import type { AccessLevel, AgentDefinitionRecord } from "../../types/agent-definition.types.js";
17
+ export declare function toRegistryAccessLevel(value: string | null | undefined): AccessLevel | null;
18
+ /**
19
+ * The store's state — the one place chat reads run tier answers from. A host with no database
20
+ * bound yet (a unit test, the first render before the host binds) has no answers: the records
21
+ * read as they are.
22
+ */
23
+ export declare function readRunTierState(): RunTierState;
24
+ /** One record completed from the store's answers (unchanged when the store holds none). */
25
+ export declare function completeAgentRecord(record: AgentDefinitionRecord, state: RunTierState): AgentDefinitionRecord;
26
+ /** Every record completed — the map `selectAllAgents` returns. Same object until either input changes. */
27
+ export declare function completeAgentRecords(agents: Record<string, AgentDefinitionRecord>, state: RunTierState): Record<string, AgentDefinitionRecord>;
@@ -0,0 +1,95 @@
1
+ import { addField, hasField } from "@ai-matrx/agents/field-flags";
2
+ import { getRunTierStore } from "../../identity/run-tier-store.js";
3
+ import { parseSkillConfigJson } from "./converters.js";
4
+ const REGISTRY_ACCESS_LEVELS = ["owner", "admin", "editor", "viewer", "system"];
5
+ function toRegistryAccessLevel(value) {
6
+ return REGISTRY_ACCESS_LEVELS.find((level) => level === value) ?? null;
7
+ }
8
+ const NO_ANSWERS = Object.freeze({
9
+ runTier: {},
10
+ runControls: {},
11
+ accessLevel: {},
12
+ sharedWithMe: { status: "idle", data: null, error: null },
13
+ sharedForChat: { status: "idle", data: null, error: null }
14
+ });
15
+ function readRunTierState() {
16
+ try {
17
+ return getRunTierStore().getState();
18
+ } catch {
19
+ return NO_ANSWERS;
20
+ }
21
+ }
22
+ const cache = /* @__PURE__ */ new WeakMap();
23
+ function answersFor(state, id) {
24
+ return {
25
+ rt: state.runTier[id]?.data ?? null,
26
+ rc: state.runControls[id]?.data ?? null,
27
+ al: state.accessLevel[id]?.data ?? null
28
+ };
29
+ }
30
+ function completeAgentRecord(record, state) {
31
+ const answers = answersFor(state, record.id);
32
+ if (!answers.rt && !answers.rc && !answers.al) return record;
33
+ const hit = cache.get(record);
34
+ if (hit && hit.rt === answers.rt && hit.rc === answers.rc && hit.al === answers.al) return hit.out;
35
+ const loaded = { ...record._loadedFields };
36
+ const out = { ...record, _loadedFields: loaded };
37
+ const unread = (field) => !hasField(record._loadedFields, field);
38
+ const fill = (field, value) => {
39
+ out[field] = value;
40
+ addField(loaded, field);
41
+ };
42
+ const rt = answers.rt;
43
+ if (rt) {
44
+ if (unread("variableDefinitions")) fill("variableDefinitions", rt.variable_definitions);
45
+ if (unread("contextPolicies")) fill("contextPolicies", rt.context_policies ?? []);
46
+ if (unread("autoContextDisabled")) fill("autoContextDisabled", rt.auto_context_disabled === true);
47
+ if (rt.model_id && unread("modelId")) fill("modelId", rt.model_id);
48
+ if (unread("uiGates")) fill("uiGates", rt.ui_gates ?? {});
49
+ if (rt.tool_ids && unread("tools")) fill("tools", rt.tool_ids);
50
+ if (!out.name && unread("name")) fill("name", rt.name);
51
+ if (out.description == null && unread("description")) fill("description", rt.description ?? "");
52
+ if (!out.accessLevel) fill("accessLevel", toRegistryAccessLevel(rt.access_level));
53
+ fill("runCounts", {
54
+ customTools: rt.custom_tool_count ?? 0,
55
+ skills: rt.skill_count ?? 0,
56
+ connections: rt.connection_count ?? 0
57
+ });
58
+ }
59
+ const rc = answers.rc;
60
+ if (rc) {
61
+ fill("runControls", { customToolNames: rc.custom_tool_names ?? [] });
62
+ if (!hasField(loaded, "tools")) fill("tools", rc.tool_ids ?? []);
63
+ if (!hasField(loaded, "autoToolsDisabled")) fill("autoToolsDisabled", rc.auto_tools_disabled === true);
64
+ if (!hasField(loaded, "skillConfig")) fill("skillConfig", parseSkillConfigJson(rc.skill_config));
65
+ if (!hasField(loaded, "mcpServers")) fill("mcpServers", rc.mcp_servers ?? []);
66
+ }
67
+ const al = answers.al;
68
+ if (al) {
69
+ fill("isOwner", al.is_owner);
70
+ fill("accessLevel", al.access_level);
71
+ }
72
+ cache.set(record, { ...answers, out });
73
+ return out;
74
+ }
75
+ const mapCache = /* @__PURE__ */ new WeakMap();
76
+ function completeAgentRecords(agents, state) {
77
+ const hit = mapCache.get(agents);
78
+ if (hit && hit.state === state) return hit.out;
79
+ let changed = false;
80
+ const out = {};
81
+ for (const [id, record] of Object.entries(agents)) {
82
+ const done = completeAgentRecord(record, state);
83
+ if (done !== record) changed = true;
84
+ out[id] = done;
85
+ }
86
+ const result = changed ? out : agents;
87
+ mapCache.set(agents, { state, out: result });
88
+ return result;
89
+ }
90
+ export {
91
+ completeAgentRecord,
92
+ completeAgentRecords,
93
+ readRunTierState,
94
+ toRegistryAccessLevel
95
+ };