@ai-matrx/associations 0.10.6 → 0.11.0

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.
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
- import { j as AssociationsNotifier, W as WindowShellPort, k as CapturePort, P as PickerOverrideMap, E as EntityDoorsPort, l as AuthorDisplayPort, m as AssociationsStore, n as CategoryMutationResult, o as CategoryDimension, p as PlatformCategory, q as CategoriesEntry, r as EntityTypeToken, s as UniversalCandidate, t as CandidateRecord, u as PlatformComment, v as CommentsEntry, w as CommentMutationResult, e as AssociationPickerProps, x as EntityDoorProps, y as EntityRefProps, z as ContentRole } from '../CommentThread-DobuYuwz.cjs';
4
- export { B as AssociationCaptureToolbar, A as AssociationCaptureToolbarProps, D as AssociationCard, F as AssociationCardGrid, b as AssociationCardGridProps, a as AssociationCardProps, G as AssociationEntitySelect, H as AssociationEntitySelectAdapter, I as AssociationEntitySelectItem, c as AssociationEntitySelectProps, J as AssociationList, d as AssociationListProps, K as AssociationWindow, f as AssociationWindowProps, L as AssociationWriteResult, M as AttachedItemsSheet, g as AttachedItemsSheetProps, N as CaptureAttach, O as CaptureAttachResult, Q as CaptureToolbarAction, R as CategorySelect, C as CategorySelectProps, S as CategoryTagPicker, h as CategoryTagPickerProps, T as CommentComposer, V as CommentComposerProps, X as CommentThread, i as CommentThreadProps, Y as ContainerLink, Z as ContainerResourceRow, _ as ContainerResourcesAdapter, $ as DefaultEntityIcon, a0 as PrimaryEntity, a1 as PrimaryEntityProvider, a2 as TagPickerIcon, a3 as UniversalAssociationPicker, U as UniversalAssociationPickerProps, a4 as UseAssociationEntitySelectAdapterArgs, a5 as UseAssociationsArgs, a6 as UseAssociationsReturn, a7 as UseContainerLinksArgs, a8 as UseContainerLinksReturn, a9 as attachedKey, aa as buildCommentTree, ab as useAssociationEntitySelectAdapter, ac as useAssociations, ad as useContainerLinks, ae as useContainerLinksAdapter, af as useEntityRelationships, ag as usePrimaryEntity } from '../CommentThread-DobuYuwz.cjs';
3
+ import { j as AssociationsNotifier, W as WindowShellPort, k as CapturePort, P as PickerOverrideMap, E as EntityDoorsPort, l as AuthorDisplayPort, m as AssociationsStore, n as CategoryMutationResult, o as CategoryDimension, p as PlatformCategory, q as CategoriesEntry, r as EntityTypeToken, s as UniversalCandidate, t as CandidateRecord, u as PlatformComment, v as CommentsEntry, w as CommentMutationResult, e as AssociationPickerProps, x as EntityDoorProps, y as EntityRefProps, z as ContentRole } from '../CommentThread-ZWiJVDpI.cjs';
4
+ export { B as AssociationCaptureToolbar, A as AssociationCaptureToolbarProps, D as AssociationCard, F as AssociationCardGrid, b as AssociationCardGridProps, a as AssociationCardProps, G as AssociationEntitySelect, H as AssociationEntitySelectAdapter, I as AssociationEntitySelectItem, c as AssociationEntitySelectProps, J as AssociationList, d as AssociationListProps, K as AssociationWindow, f as AssociationWindowProps, L as AssociationWriteResult, M as AttachedItemsSheet, g as AttachedItemsSheetProps, N as CaptureAttach, O as CaptureAttachResult, Q as CaptureToolbarAction, R as CategorySelect, C as CategorySelectProps, S as CategoryTagPicker, h as CategoryTagPickerProps, T as CommentComposer, V as CommentComposerProps, X as CommentThread, i as CommentThreadProps, Y as ContainerLink, Z as ContainerResourceRow, _ as ContainerResourcesAdapter, $ as DefaultEntityIcon, a0 as PrimaryContainerEntity, a1 as PrimaryEntity, a2 as PrimaryEntityProvider, a3 as PrimaryFiledEntity, a4 as TagPickerIcon, a5 as UniversalAssociationPicker, U as UniversalAssociationPickerProps, a6 as UseAssociationEntitySelectAdapterArgs, a7 as UseAssociationsArgs, a8 as UseAssociationsReturn, a9 as UseContainerLinksArgs, aa as UseContainerLinksReturn, ab as attachedKey, ac as buildCommentTree, ad as containerLinksArgs, ae as useAssociationEntitySelectAdapter, af as useAssociations, ag as useContainerLinks, ah as useContainerLinksAdapter, ai as useEntityRelationships, aj as usePrimaryEntity } from '../CommentThread-ZWiJVDpI.cjs';
5
5
 
6
6
  interface AssociationsUiPorts {
7
7
  notifier?: AssociationsNotifier;
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
- import { j as AssociationsNotifier, W as WindowShellPort, k as CapturePort, P as PickerOverrideMap, E as EntityDoorsPort, l as AuthorDisplayPort, m as AssociationsStore, n as CategoryMutationResult, o as CategoryDimension, p as PlatformCategory, q as CategoriesEntry, r as EntityTypeToken, s as UniversalCandidate, t as CandidateRecord, u as PlatformComment, v as CommentsEntry, w as CommentMutationResult, e as AssociationPickerProps, x as EntityDoorProps, y as EntityRefProps, z as ContentRole } from '../CommentThread-DobuYuwz.js';
4
- export { B as AssociationCaptureToolbar, A as AssociationCaptureToolbarProps, D as AssociationCard, F as AssociationCardGrid, b as AssociationCardGridProps, a as AssociationCardProps, G as AssociationEntitySelect, H as AssociationEntitySelectAdapter, I as AssociationEntitySelectItem, c as AssociationEntitySelectProps, J as AssociationList, d as AssociationListProps, K as AssociationWindow, f as AssociationWindowProps, L as AssociationWriteResult, M as AttachedItemsSheet, g as AttachedItemsSheetProps, N as CaptureAttach, O as CaptureAttachResult, Q as CaptureToolbarAction, R as CategorySelect, C as CategorySelectProps, S as CategoryTagPicker, h as CategoryTagPickerProps, T as CommentComposer, V as CommentComposerProps, X as CommentThread, i as CommentThreadProps, Y as ContainerLink, Z as ContainerResourceRow, _ as ContainerResourcesAdapter, $ as DefaultEntityIcon, a0 as PrimaryEntity, a1 as PrimaryEntityProvider, a2 as TagPickerIcon, a3 as UniversalAssociationPicker, U as UniversalAssociationPickerProps, a4 as UseAssociationEntitySelectAdapterArgs, a5 as UseAssociationsArgs, a6 as UseAssociationsReturn, a7 as UseContainerLinksArgs, a8 as UseContainerLinksReturn, a9 as attachedKey, aa as buildCommentTree, ab as useAssociationEntitySelectAdapter, ac as useAssociations, ad as useContainerLinks, ae as useContainerLinksAdapter, af as useEntityRelationships, ag as usePrimaryEntity } from '../CommentThread-DobuYuwz.js';
3
+ import { j as AssociationsNotifier, W as WindowShellPort, k as CapturePort, P as PickerOverrideMap, E as EntityDoorsPort, l as AuthorDisplayPort, m as AssociationsStore, n as CategoryMutationResult, o as CategoryDimension, p as PlatformCategory, q as CategoriesEntry, r as EntityTypeToken, s as UniversalCandidate, t as CandidateRecord, u as PlatformComment, v as CommentsEntry, w as CommentMutationResult, e as AssociationPickerProps, x as EntityDoorProps, y as EntityRefProps, z as ContentRole } from '../CommentThread-ZWiJVDpI.js';
4
+ export { B as AssociationCaptureToolbar, A as AssociationCaptureToolbarProps, D as AssociationCard, F as AssociationCardGrid, b as AssociationCardGridProps, a as AssociationCardProps, G as AssociationEntitySelect, H as AssociationEntitySelectAdapter, I as AssociationEntitySelectItem, c as AssociationEntitySelectProps, J as AssociationList, d as AssociationListProps, K as AssociationWindow, f as AssociationWindowProps, L as AssociationWriteResult, M as AttachedItemsSheet, g as AttachedItemsSheetProps, N as CaptureAttach, O as CaptureAttachResult, Q as CaptureToolbarAction, R as CategorySelect, C as CategorySelectProps, S as CategoryTagPicker, h as CategoryTagPickerProps, T as CommentComposer, V as CommentComposerProps, X as CommentThread, i as CommentThreadProps, Y as ContainerLink, Z as ContainerResourceRow, _ as ContainerResourcesAdapter, $ as DefaultEntityIcon, a0 as PrimaryContainerEntity, a1 as PrimaryEntity, a2 as PrimaryEntityProvider, a3 as PrimaryFiledEntity, a4 as TagPickerIcon, a5 as UniversalAssociationPicker, U as UniversalAssociationPickerProps, a6 as UseAssociationEntitySelectAdapterArgs, a7 as UseAssociationsArgs, a8 as UseAssociationsReturn, a9 as UseContainerLinksArgs, aa as UseContainerLinksReturn, ab as attachedKey, ac as buildCommentTree, ad as containerLinksArgs, ae as useAssociationEntitySelectAdapter, af as useAssociations, ag as useContainerLinks, ah as useContainerLinksAdapter, ai as useEntityRelationships, aj as usePrimaryEntity } from '../CommentThread-ZWiJVDpI.js';
5
5
 
6
6
  interface AssociationsUiPorts {
7
7
  notifier?: AssociationsNotifier;
@@ -1193,6 +1193,73 @@ import {
1193
1193
  useRef as useRef3,
1194
1194
  useState
1195
1195
  } from "react";
1196
+
1197
+ // src/edges.ts
1198
+ var ASSOCIATION_TARGET_TYPES = [
1199
+ "organization",
1200
+ // an org — the top-level container resources attach into
1201
+ "scope",
1202
+ "scope_type",
1203
+ "project",
1204
+ "task",
1205
+ "context_item",
1206
+ "thread",
1207
+ "war_room",
1208
+ "category",
1209
+ "conversation",
1210
+ // a chat conversation a working_document is attached to
1211
+ "fc_set",
1212
+ // a flashcard set (card→set membership)
1213
+ "fc_card",
1214
+ // a flashcard (card→card hierarchy, quiz→card)
1215
+ "study_media",
1216
+ // a study-media artifact (summary/mind_map) — converter lineage target
1217
+ "assessment",
1218
+ // a quiz / practice test — a converter lineage target + origin (assessment→artifact 'source')
1219
+ "note",
1220
+ // a note — the origin a converted study artifact links back to (artifact→note 'source' lineage, P4)
1221
+ "file",
1222
+ // a file (card→file media + source lineage)
1223
+ "quiz_session",
1224
+ // a quiz a card is used in
1225
+ "agent",
1226
+ // an orchestrator agent — the container an Orchestra's member agents attach into (role 'member'); an 'orchestra' self-edge marks the orchestrator
1227
+ "agent_term_list",
1228
+ // a term list — durable file attachments target its vocabulary resource
1229
+ "research_tag",
1230
+ // a research tag a source is filed under (rs_source_tag M2M collapsed into associations)
1231
+ "skill",
1232
+ // a skill — projects link to it (skill→project, role 'member'); code_files attach as resources (code_file→skill, role 'resource')
1233
+ "surface",
1234
+ // a UI surface — agents bind here (agent→surface); context menu reads via agent.menu_surface
1235
+ "plan_entity",
1236
+ // a Content Planning source/media citation — plan_node role edges (about/cites/embeds) target it
1237
+ "plan_node",
1238
+ // a planned page — research topics/tags attach here and follow realization into web_page
1239
+ "web_site",
1240
+ // a web.site — parties attach onto a site's roster (party→web_site role 'writes_for')
1241
+ "seo_topic",
1242
+ // a taxonomy topic — plan_node/plan_entity tag into it (role 'topic')
1243
+ "seo_keyword",
1244
+ // a keyword — plan_node attaches secondaries (role 'secondary_keyword'; the primary is an FK, never an edge)
1245
+ "web_page",
1246
+ // a canonical page — the page workspace attaches notes/tasks/files/keywords onto it (keyword edges: role 'primary'|'supporting')
1247
+ "web_screenshot",
1248
+ // a page capture — per-image attachments on the page workspace
1249
+ "party",
1250
+ // a CRM person/company (crm.party) — the record page attaches tasks/files/notes onto it
1251
+ "crm_outreach_list",
1252
+ // a CRM outreach list (a worked send/dial queue) — parties and resources attach into it
1253
+ "crm_deal",
1254
+ // a CRM deal (crm.deal) — people on it (role 'deal_contact'), tasks/files attach onto it
1255
+ "rulebook"
1256
+ // a Masterwork Rulebook — its Scout interviews attach here (conversation→rulebook, role 'interview')
1257
+ ];
1258
+ function isAssociationTargetType(value) {
1259
+ return typeof value === "string" && ASSOCIATION_TARGET_TYPES.includes(value);
1260
+ }
1261
+
1262
+ // src/react/hooks/useContainerLinks.ts
1196
1263
  function metadataRecord(metadata) {
1197
1264
  if (metadata === null || typeof metadata !== "object" || Array.isArray(metadata)) {
1198
1265
  return metadata == null ? {} : null;
@@ -1201,6 +1268,7 @@ function metadataRecord(metadata) {
1201
1268
  }
1202
1269
  function useContainerLinks(args) {
1203
1270
  const { containerType, containerId, orgId } = args;
1271
+ const outgoing = args.direction === "outgoing";
1204
1272
  const store = useAssociationsStore();
1205
1273
  const {
1206
1274
  edges,
@@ -1211,7 +1279,7 @@ function useContainerLinks(args) {
1211
1279
  type: containerType,
1212
1280
  id: containerId
1213
1281
  });
1214
- const conversationKey = containerType === "conversation" && containerId ? `conversation:${containerId}` : null;
1282
+ const conversationKey = !outgoing && containerType === "conversation" && containerId ? `conversation:${containerId}` : null;
1215
1283
  const activeConversationKey = useRef3(conversationKey);
1216
1284
  const conversationGeneration = useRef3(0);
1217
1285
  const [conversationResult, setConversationResult] = useState(null);
@@ -1267,9 +1335,9 @@ function useContainerLinks(args) {
1267
1335
  }, [loadConversationFiles]);
1268
1336
  const conversationFiles = conversationResult?.key === conversationKey ? conversationResult.files : [];
1269
1337
  const conversationFileError = conversationResult?.key === conversationKey ? conversationResult.error : null;
1270
- const conversationFileStatus = containerType !== "conversation" ? "idle" : conversationResult?.key !== conversationKey ? "loading" : conversationResult.loading ? "loading" : conversationFileError ? "error" : "ready";
1338
+ const conversationFileStatus = outgoing || containerType !== "conversation" ? "idle" : conversationResult?.key !== conversationKey ? "loading" : conversationResult.loading ? "loading" : conversationFileError ? "error" : "ready";
1271
1339
  const incomingGeneric = edges.filter(
1272
- (edge) => edge.direction === "incoming" && !(containerType === "conversation" && edge.otherType === "file")
1340
+ (edge) => outgoing ? edge.direction === "outgoing" : edge.direction === "incoming" && !(containerType === "conversation" && edge.otherType === "file")
1273
1341
  ).map((edge) => ({
1274
1342
  edgeId: edge.id,
1275
1343
  resourceId: edge.otherId,
@@ -1278,7 +1346,29 @@ function useContainerLinks(args) {
1278
1346
  label: edge.label ?? null,
1279
1347
  metadata: edge.metadata ?? {}
1280
1348
  }));
1281
- const incoming = containerType === "conversation" ? [...incomingGeneric, ...conversationFiles] : incomingGeneric;
1349
+ const incoming = !outgoing && containerType === "conversation" ? [...incomingGeneric, ...conversationFiles] : incomingGeneric;
1350
+ const endpoints = (token, resourceId) => {
1351
+ if (!containerId) return { error: "Missing container id" };
1352
+ if (outgoing) {
1353
+ if (!isAssociationTargetType(token)) {
1354
+ return {
1355
+ error: `A ${token.replace(/_/g, " ")} cannot be filed under: it is not a container type.`
1356
+ };
1357
+ }
1358
+ return {
1359
+ sourceType: containerType,
1360
+ sourceId: containerId,
1361
+ targetType: token,
1362
+ targetId: resourceId
1363
+ };
1364
+ }
1365
+ return {
1366
+ sourceType: token,
1367
+ sourceId: resourceId,
1368
+ targetType: containerType,
1369
+ targetId: containerId
1370
+ };
1371
+ };
1282
1372
  const linksFor = (token) => incoming.filter((link) => link.token === token);
1283
1373
  const countFor = (token) => incoming.reduce((n, link) => link.token === token ? n + 1 : n, 0);
1284
1374
  const attachedIdsFor = (token) => {
@@ -1289,39 +1379,36 @@ function useContainerLinks(args) {
1289
1379
  return set;
1290
1380
  };
1291
1381
  const attach = async (token, resourceId, label, metadata, options) => {
1292
- if (!containerId) return { ok: false, error: "Missing container id" };
1382
+ const ends = endpoints(token, resourceId);
1383
+ if ("error" in ends) return { ok: false, error: ends.error };
1293
1384
  const result = await store.add({
1294
- sourceType: token,
1295
- sourceId: resourceId,
1296
- targetType: containerType,
1297
- targetId: containerId,
1385
+ ...ends,
1298
1386
  ...orgId != null ? { orgId } : {},
1299
1387
  ...label !== void 0 ? { label } : {},
1300
1388
  ...metadata !== void 0 ? { metadata } : {},
1301
1389
  ...options?.role !== void 0 ? { role: options.role } : {},
1302
1390
  ...options?.replaceMetadata !== void 0 ? { replaceMetadata: options.replaceMetadata } : {}
1303
1391
  });
1304
- if (result.ok && containerType === "conversation" && token === "file") {
1392
+ if (result.ok && !outgoing && containerType === "conversation" && token === "file") {
1305
1393
  await loadConversationFiles();
1306
1394
  }
1307
1395
  return result;
1308
1396
  };
1309
1397
  const detach = async (token, resourceId, role) => {
1310
- if (!containerId) return { ok: false, error: "Missing container id" };
1398
+ const ends = endpoints(token, resourceId);
1399
+ if ("error" in ends) return { ok: false, error: ends.error };
1311
1400
  const result = await store.remove({
1312
- sourceType: token,
1313
- sourceId: resourceId,
1314
- targetType: containerType,
1315
- targetId: containerId,
1401
+ ...ends,
1316
1402
  ...role !== void 0 ? { role } : {}
1317
1403
  });
1318
- if (result.ok && containerType === "conversation" && token === "file") {
1404
+ if (result.ok && !outgoing && containerType === "conversation" && token === "file") {
1319
1405
  await loadConversationFiles();
1320
1406
  }
1321
1407
  return result;
1322
1408
  };
1323
1409
  const setPinned = async (token, resourceId, pinned, role) => {
1324
- if (!containerId) return { ok: false, error: "Missing container id" };
1410
+ const ends = endpoints(token, resourceId);
1411
+ if ("error" in ends) return { ok: false, error: ends.error };
1325
1412
  const exactRole = role ?? null;
1326
1413
  const link = incoming.find(
1327
1414
  (candidate) => candidate.token === token && candidate.resourceId === resourceId && candidate.role === exactRole
@@ -1335,10 +1422,7 @@ function useContainerLinks(args) {
1335
1422
  };
1336
1423
  }
1337
1424
  return store.add({
1338
- sourceType: token,
1339
- sourceId: resourceId,
1340
- targetType: containerType,
1341
- targetId: containerId,
1425
+ ...ends,
1342
1426
  ...orgId != null ? { orgId } : {},
1343
1427
  ...link.label != null ? { label: link.label } : {},
1344
1428
  ...role !== void 0 ? { role } : {},
@@ -1348,10 +1432,10 @@ function useContainerLinks(args) {
1348
1432
  const reload = async () => {
1349
1433
  await Promise.all([
1350
1434
  reloadGeneric(),
1351
- containerType === "conversation" ? loadConversationFiles() : Promise.resolve()
1435
+ !outgoing && containerType === "conversation" ? loadConversationFiles() : Promise.resolve()
1352
1436
  ]);
1353
1437
  };
1354
- const status = !containerId ? genericStatus : conversationFileStatus === "error" ? "error" : containerType === "conversation" && (conversationFileStatus === "idle" || conversationFileStatus === "loading") ? "loading" : genericStatus;
1438
+ const status = !containerId ? genericStatus : conversationFileStatus === "error" ? "error" : !outgoing && containerType === "conversation" && (conversationFileStatus === "idle" || conversationFileStatus === "loading") ? "loading" : genericStatus;
1355
1439
  const error = conversationFileError ?? genericError;
1356
1440
  return {
1357
1441
  status,
@@ -1366,6 +1450,21 @@ function useContainerLinks(args) {
1366
1450
  setPinned
1367
1451
  };
1368
1452
  }
1453
+ function containerLinksArgs(container) {
1454
+ if (container?.direction === "outgoing") {
1455
+ return {
1456
+ containerType: container.type,
1457
+ containerId: container.id,
1458
+ orgId: container.orgId ?? null,
1459
+ direction: "outgoing"
1460
+ };
1461
+ }
1462
+ return {
1463
+ containerType: container?.type ?? "organization",
1464
+ containerId: container?.id ?? null,
1465
+ orgId: container?.orgId ?? null
1466
+ };
1467
+ }
1369
1468
 
1370
1469
  // src/react/hooks/useEntityTitles.ts
1371
1470
  import { useEffect as useEffect3, useState as useState2 } from "react";
@@ -2206,7 +2305,7 @@ function AssociationPicker(props) {
2206
2305
  const Override = pickerOverrides?.[props.token];
2207
2306
  if (Override) return /* @__PURE__ */ jsx6(Override, { ...props });
2208
2307
  const title = `Add ${info.labelPlural}`;
2209
- const subtitle = props.containerLabel ? `Attach to ${props.containerLabel}` : "Click an item to attach or detach it";
2308
+ const subtitle = props.filing ? `File ${props.containerLabel ?? "this"} under a ${info.label.toLowerCase()}` : props.containerLabel ? `Attach to ${props.containerLabel}` : "Click an item to attach or detach it";
2210
2309
  if (!props.open) return null;
2211
2310
  return /* @__PURE__ */ jsx6(
2212
2311
  AssociationWindow,
@@ -2823,8 +2922,9 @@ function AttachedItemsSheet(props) {
2823
2922
  const Icon = info.Icon ?? DefaultEntityIcon;
2824
2923
  const title = info.labelPlural;
2825
2924
  const containerName = props.container?.label ?? props.containerLabel;
2925
+ const filing = props.container?.direction === "outgoing";
2826
2926
  const subtitle = props.container ? /* @__PURE__ */ jsxs7("span", { className: "inline-flex min-w-0 max-w-full items-center gap-1", children: [
2827
- "Attached to",
2927
+ filing ? "What this is filed under:" : "Attached to",
2828
2928
  /* @__PURE__ */ jsx9(
2829
2929
  DoorRef,
2830
2930
  {
@@ -3100,11 +3200,7 @@ function AssociationCard({
3100
3200
  attach,
3101
3201
  detach,
3102
3202
  setPinned
3103
- } = useContainerLinks({
3104
- containerType: container?.type ?? "organization",
3105
- containerId: container?.id ?? null,
3106
- orgId: container?.orgId ?? null
3107
- });
3203
+ } = useContainerLinks(containerLinksArgs(container));
3108
3204
  if (!container) {
3109
3205
  store.errorSink({
3110
3206
  code: "association_card_no_container",
@@ -3115,7 +3211,8 @@ function AssociationCard({
3115
3211
  }
3116
3212
  const count = countFor(token);
3117
3213
  const loading = status === "loading" || status === "idle";
3118
- const canAttach = info.canListCandidates;
3214
+ const filing = container.direction === "outgoing";
3215
+ const canAttach = info.canListCandidates && (!filing || isAssociationTargetType(token));
3119
3216
  const canDrillIn = count > 0;
3120
3217
  return /* @__PURE__ */ jsxs8(Fragment3, { children: [
3121
3218
  /* @__PURE__ */ jsxs8(
@@ -3163,7 +3260,7 @@ function AssociationCard({
3163
3260
  /* @__PURE__ */ jsx10("span", { className: "block text-[11px] text-muted-foreground tabular-nums", children: loading ? /* @__PURE__ */ jsxs8("span", { className: "inline-flex items-center gap-1", children: [
3164
3261
  /* @__PURE__ */ jsx10(SpinnerIcon, { className: "h-3 w-3 animate-spin" }),
3165
3262
  "Loading\u2026"
3166
- ] }) : `${count} attached` })
3263
+ ] }) : `${count} ${container.direction === "outgoing" ? "filed under" : "attached"}` })
3167
3264
  ] })
3168
3265
  ]
3169
3266
  }
@@ -3209,6 +3306,7 @@ function AssociationCard({
3209
3306
  token,
3210
3307
  ...container.label !== void 0 ? { containerLabel: container.label } : {},
3211
3308
  orgId: container.orgId ?? null,
3309
+ ...filing ? { filing: true } : {},
3212
3310
  attachedIds: attachedIdsFor(token),
3213
3311
  onAttach: (resourceId, title) => attach(token, resourceId, title),
3214
3312
  onDetach: (resourceId) => detach(token, resourceId)
@@ -3226,9 +3324,11 @@ function AssociationCardGrid({
3226
3324
  className
3227
3325
  }) {
3228
3326
  const store = useAssociationsStore();
3327
+ const primary = usePrimaryEntity();
3229
3328
  const excluded = new Set(excludeTokens ?? []);
3329
+ const filing = primary?.direction === "outgoing";
3230
3330
  const list = (tokens ?? store.registry.curatedTokens()).filter(
3231
- (token) => !excluded.has(token)
3331
+ (token) => !excluded.has(token) && (!filing || isAssociationTargetType(token))
3232
3332
  );
3233
3333
  return /* @__PURE__ */ jsx11("div", { className: cn7("space-y-5", className), children: CONTENT_ROLES.map((role) => {
3234
3334
  const inRole = list.filter(
@@ -3262,11 +3362,7 @@ function metadataIsPinned2(metadata) {
3262
3362
  }
3263
3363
  function useContainerLinksAdapter(container, tokens) {
3264
3364
  const store = useAssociationsStore();
3265
- const links = useContainerLinks({
3266
- containerType: container?.type ?? "organization",
3267
- containerId: container?.id ?? null,
3268
- orgId: container?.orgId ?? null
3269
- });
3365
+ const links = useContainerLinks(containerLinksArgs(container));
3270
3366
  const rows = container ? (tokens ?? store.registry.curatedTokens()).flatMap(
3271
3367
  (token) => links.linksFor(token).map((l) => ({
3272
3368
  key: l.edgeId,
@@ -5320,6 +5416,7 @@ export {
5320
5416
  UnresolvedRef,
5321
5417
  attachedKey,
5322
5418
  buildCommentTree,
5419
+ containerLinksArgs,
5323
5420
  getContentRoleMeta,
5324
5421
  lazyPickerOverride,
5325
5422
  lazyWindowShell,