@ai-matrx/associations 0.13.136 → 0.13.138

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.
@@ -11696,7 +11696,7 @@ declare const ENTITY_TYPE_METADATA: {
11696
11696
  readonly token: "processed_document";
11697
11697
  readonly schema: "docproc";
11698
11698
  readonly table: "processed_documents";
11699
- readonly label: "Processed document";
11699
+ readonly label: "Source";
11700
11700
  readonly baseTier: 1;
11701
11701
  readonly isComponent: false;
11702
11702
  readonly isModule: false;
@@ -16496,7 +16496,7 @@ declare const ENTITY_TYPE_METADATA: {
16496
16496
  readonly token: "web_page";
16497
16497
  readonly schema: "web";
16498
16498
  readonly table: "page";
16499
- readonly label: "Canonical Page";
16499
+ readonly label: "Site page";
16500
16500
  readonly baseTier: 1;
16501
16501
  readonly isComponent: true;
16502
16502
  readonly isModule: false;
@@ -11696,7 +11696,7 @@ declare const ENTITY_TYPE_METADATA: {
11696
11696
  readonly token: "processed_document";
11697
11697
  readonly schema: "docproc";
11698
11698
  readonly table: "processed_documents";
11699
- readonly label: "Processed document";
11699
+ readonly label: "Source";
11700
11700
  readonly baseTier: 1;
11701
11701
  readonly isComponent: false;
11702
11702
  readonly isModule: false;
@@ -16496,7 +16496,7 @@ declare const ENTITY_TYPE_METADATA: {
16496
16496
  readonly token: "web_page";
16497
16497
  readonly schema: "web";
16498
16498
  readonly table: "page";
16499
- readonly label: "Canonical Page";
16499
+ readonly label: "Site page";
16500
16500
  readonly baseTier: 1;
16501
16501
  readonly isComponent: true;
16502
16502
  readonly isModule: false;
@@ -1575,6 +1575,8 @@ var ASSOCIATION_PAIRS = /* @__PURE__ */ new Set([
1575
1575
  "rulebook>masterwork_source",
1576
1576
  "sch_task>record",
1577
1577
  "sch_task>scope",
1578
+ "scope>record",
1579
+ "scope>scope",
1578
1580
  "seo_keyword>project",
1579
1581
  "seo_keyword>web_page",
1580
1582
  "seo_map_topic>seo_map_facet_value",
@@ -1821,6 +1823,66 @@ function metadataRecord(metadata) {
1821
1823
  }
1822
1824
  return Object.fromEntries(Object.entries(metadata));
1823
1825
  }
1826
+ var conversationFileCaches = /* @__PURE__ */ new WeakMap();
1827
+ function conversationFilesFor(store) {
1828
+ const existing = conversationFileCaches.get(store);
1829
+ if (existing) return existing;
1830
+ const entries = /* @__PURE__ */ new Map();
1831
+ const inflight = /* @__PURE__ */ new Map();
1832
+ const seqs = /* @__PURE__ */ new Map();
1833
+ const listeners = /* @__PURE__ */ new Set();
1834
+ const set = (entry) => {
1835
+ entries.set(entry.key, entry);
1836
+ for (const listener of listeners) listener();
1837
+ };
1838
+ const cache = {
1839
+ get: (key) => entries.get(key) ?? null,
1840
+ subscribe(listener) {
1841
+ listeners.add(listener);
1842
+ return () => {
1843
+ listeners.delete(listener);
1844
+ };
1845
+ },
1846
+ load(key, conversationId, force) {
1847
+ const kept = entries.get(key);
1848
+ if (!force) {
1849
+ const running = inflight.get(key);
1850
+ if (running) return running;
1851
+ if (kept && !kept.loading && kept.error === null) return Promise.resolve();
1852
+ }
1853
+ const seq = (seqs.get(key) ?? 0) + 1;
1854
+ seqs.set(key, seq);
1855
+ set({ key, files: kept?.files ?? [], error: kept?.error ?? null, loading: true });
1856
+ const request = store.services.associations.listConversationFiles(conversationId).then((result) => {
1857
+ if (seqs.get(key) !== seq) return;
1858
+ if (isAssociationsRpcErr(result)) {
1859
+ set({ key, files: entries.get(key)?.files ?? [], error: result.error.message, loading: false });
1860
+ return;
1861
+ }
1862
+ set({
1863
+ key,
1864
+ files: result.data.files.map((file) => ({
1865
+ edgeId: `conversation-file:${file.fileId}`,
1866
+ resourceId: file.fileId,
1867
+ token: "file",
1868
+ role: null,
1869
+ label: file.label,
1870
+ metadata: file.metadata
1871
+ })),
1872
+ error: null,
1873
+ loading: false
1874
+ });
1875
+ });
1876
+ const tracked = request.finally(() => {
1877
+ if (inflight.get(key) === tracked) inflight.delete(key);
1878
+ });
1879
+ inflight.set(key, tracked);
1880
+ return tracked;
1881
+ }
1882
+ };
1883
+ conversationFileCaches.set(store, cache);
1884
+ return cache;
1885
+ }
1824
1886
  function useContainerLinks(args) {
1825
1887
  const { containerType, containerId, orgId } = args;
1826
1888
  const outgoing = args.direction === "outgoing";
@@ -1836,58 +1898,21 @@ function useContainerLinks(args) {
1836
1898
  id: containerId
1837
1899
  });
1838
1900
  const conversationKey = !outgoing && containerType === "conversation" && containerId ? `conversation:${containerId}` : null;
1839
- const activeConversationKey = (0, import_react3.useRef)(conversationKey);
1840
- const conversationGeneration = (0, import_react3.useRef)(0);
1841
- const [conversationResult, setConversationResult] = (0, import_react3.useState)(null);
1842
- (0, import_react3.useLayoutEffect)(() => {
1843
- activeConversationKey.current = conversationKey;
1844
- conversationGeneration.current += 1;
1845
- }, [conversationKey]);
1846
- const loadConversationFiles = (0, import_react3.useCallback)(async () => {
1847
- const key = conversationKey;
1848
- if (!key || !containerId) return;
1849
- if (activeConversationKey.current !== key) return;
1850
- const generation = ++conversationGeneration.current;
1851
- setConversationResult((current) => ({
1852
- key,
1853
- files: current?.key === key ? current.files : [],
1854
- // Keep the visible failure context while retrying so the same control
1855
- // can disable itself and show progress instead of disappearing.
1856
- error: current?.key === key ? current.error : null,
1857
- loading: true
1858
- }));
1859
- const result = await store.services.associations.listConversationFiles(containerId);
1860
- if (generation !== conversationGeneration.current || activeConversationKey.current !== key) {
1861
- return;
1862
- }
1863
- if (isAssociationsRpcErr(result)) {
1864
- setConversationResult((current) => ({
1865
- key,
1866
- files: current?.key === key ? current.files : [],
1867
- error: result.error.message,
1868
- loading: false
1869
- }));
1870
- return;
1871
- }
1872
- setConversationResult({
1873
- key,
1874
- files: result.data.files.map((file) => ({
1875
- edgeId: `conversation-file:${file.fileId}`,
1876
- resourceId: file.fileId,
1877
- token: "file",
1878
- role: null,
1879
- label: file.label,
1880
- metadata: file.metadata
1881
- })),
1882
- error: null,
1883
- loading: false
1884
- });
1885
- }, [containerId, conversationKey, store]);
1901
+ const files = conversationFilesFor(store);
1902
+ const conversationResult = (0, import_react3.useSyncExternalStore)(
1903
+ files.subscribe,
1904
+ () => conversationKey ? files.get(conversationKey) : null,
1905
+ () => null
1906
+ );
1907
+ const loadConversationFiles = (0, import_react3.useCallback)(
1908
+ async (force = true) => {
1909
+ if (!conversationKey || !containerId) return;
1910
+ await files.load(conversationKey, containerId, force);
1911
+ },
1912
+ [containerId, conversationKey, files]
1913
+ );
1886
1914
  (0, import_react3.useEffect)(() => {
1887
- const timeout = setTimeout(() => {
1888
- void loadConversationFiles();
1889
- }, 0);
1890
- return () => clearTimeout(timeout);
1915
+ void loadConversationFiles(false);
1891
1916
  }, [loadConversationFiles]);
1892
1917
  const lastGenericFetch = (0, import_react3.useRef)({
1893
1918
  key: conversationKey,
@@ -4157,17 +4182,13 @@ var TILE_GRID = "grid grid-cols-1 gap-2 @md:grid-cols-2 @3xl:grid-cols-3";
4157
4182
  function GroupHeader({
4158
4183
  look,
4159
4184
  title,
4160
- tagline,
4161
4185
  dotClassName
4162
4186
  }) {
4163
4187
  if (look !== "tiles") return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { className: SIMPLE_GROUP_LABEL, children: title });
4164
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "mb-2.5 flex items-baseline gap-3 pl-1.5", children: [
4165
- dotClassName ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
4166
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: (0, import_design_system8.cn)("h-2.5 w-2.5 rounded-full", dotClassName) }),
4167
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { className: "text-sm font-semibold text-foreground", children: title })
4168
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { className: "text-sm font-semibold text-foreground", children: title }),
4169
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "hidden text-xs text-muted-foreground sm:block", children: tagline })
4170
- ] });
4188
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mb-2.5 flex items-baseline gap-3 pl-1.5", children: dotClassName ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
4189
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: (0, import_design_system8.cn)("h-2.5 w-2.5 rounded-full", dotClassName) }),
4190
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { className: "text-sm font-semibold text-foreground", children: title })
4191
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { className: "text-sm font-semibold text-foreground", children: title }) });
4171
4192
  }
4172
4193
  function AssociationCardGrid({
4173
4194
  tokens,
@@ -4213,7 +4234,6 @@ function AssociationCardGrid({
4213
4234
  {
4214
4235
  look,
4215
4236
  title: role.title,
4216
- tagline: role.tagline,
4217
4237
  dotClassName: role.accentBar
4218
4238
  }
4219
4239
  ),
@@ -4225,8 +4245,7 @@ function AssociationCardGrid({
4225
4245
  GroupHeader,
4226
4246
  {
4227
4247
  look,
4228
- title: "Filed under",
4229
- tagline: "Libraries, topics and other places this is kept."
4248
+ title: "Filed under"
4230
4249
  }
4231
4250
  ),
4232
4251
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: rowClass, children: roleless.map((token) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AssociationCard, { token, look }, token)) })