@ai-matrx/associations 0.14.81 → 0.14.83

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/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { r as ASSOCIATION_TARGET_TYPES, s as AssociationDirection, h as AssociationEdge, t as AssociationPickerProps, j as AssociationSourceEdge, i as AssociationTargetEdge, f as AssociationTargetType, q as AssociationsConfig, d as AssociationsDataSource, n as AssociationsEntry, e as AssociationsIdentity, u as AssociationsNotifier, A as AssociationsRpcError, v as AssociationsRpcErrorCode, w as AssociationsRpcOnlyDataSource, g as AssociationsRpcResult, x as AuthorDisplayInput, y as AuthorDisplayPort, z as CapturePickOpts, B as CapturePort, D as CaptureShownTo, F as CaptureUploadOpts, G as CaptureUploadResult, o as CategoriesEntry, C as CategoryDimension, H as CommentAgentAuthor, l as CommentAnchor, I as CommentAuthor, p as CommentsEntry, J as ComponentEntityToken, K as ENTITY_TYPE_METADATA, L as ENTITY_TYPE_TOKENS, M as EntityDoorProps, N as EntityDoorsPort, b as EntityOverlayEntry, E as EntityOverlayMap, O as EntityRefProps, Q as EntityTypeMeta, a as EntityTypeToken, c as ErrorSink, R as ListedEntityToken, S as ModuleEntityToken, T as PartAnchor, V as PgError, W as PickerOverrideMap, P as PlatformCategory, m as PlatformComment, X as REFERENCE_CATEGORY_DISPLAY, Y as ReferencePickableEntityToken, Z as SCHEMA_DISPLAY, _ as ScopeableEntityToken, k as UserEntityState, U as UserStateKind, $ as WindowShellPort, a0 as isAssociationTargetType, a1 as isAssociationsRpcErr, a2 as isEntityTypeToken, a3 as partKeyOf } from './results-Du0dzBb4.cjs';
1
+ export { r as ASSOCIATION_TARGET_TYPES, s as AssociationDirection, h as AssociationEdge, t as AssociationPickerProps, j as AssociationSourceEdge, i as AssociationTargetEdge, f as AssociationTargetType, q as AssociationsConfig, d as AssociationsDataSource, n as AssociationsEntry, e as AssociationsIdentity, u as AssociationsNotifier, A as AssociationsRpcError, v as AssociationsRpcErrorCode, w as AssociationsRpcOnlyDataSource, g as AssociationsRpcResult, x as AuthorDisplayInput, y as AuthorDisplayPort, z as CapturePickOpts, B as CapturePort, D as CaptureShownTo, F as CaptureUploadOpts, G as CaptureUploadResult, o as CategoriesEntry, C as CategoryDimension, H as CommentAgentAuthor, l as CommentAnchor, I as CommentAuthor, p as CommentsEntry, J as ComponentEntityToken, K as ENTITY_TYPE_METADATA, L as ENTITY_TYPE_TOKENS, M as EntityDoorProps, N as EntityDoorsPort, b as EntityOverlayEntry, E as EntityOverlayMap, O as EntityRefProps, Q as EntityTypeMeta, a as EntityTypeToken, c as ErrorSink, R as ListedEntityToken, S as ModuleEntityToken, T as PartAnchor, V as PgError, W as PickerOverrideMap, P as PlatformCategory, m as PlatformComment, X as REFERENCE_CATEGORY_DISPLAY, Y as ReferencePickableEntityToken, Z as SCHEMA_DISPLAY, _ as ScopeableEntityToken, k as UserEntityState, U as UserStateKind, $ as WindowShellPort, a0 as isAssociationTargetType, a1 as isAssociationsRpcErr, a2 as isEntityTypeToken, a3 as partKeyOf } from './results-HJm2RJQp.cjs';
2
2
  import 'react';
3
3
  import '@ai-matrx/data/db';
4
4
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { r as ASSOCIATION_TARGET_TYPES, s as AssociationDirection, h as AssociationEdge, t as AssociationPickerProps, j as AssociationSourceEdge, i as AssociationTargetEdge, f as AssociationTargetType, q as AssociationsConfig, d as AssociationsDataSource, n as AssociationsEntry, e as AssociationsIdentity, u as AssociationsNotifier, A as AssociationsRpcError, v as AssociationsRpcErrorCode, w as AssociationsRpcOnlyDataSource, g as AssociationsRpcResult, x as AuthorDisplayInput, y as AuthorDisplayPort, z as CapturePickOpts, B as CapturePort, D as CaptureShownTo, F as CaptureUploadOpts, G as CaptureUploadResult, o as CategoriesEntry, C as CategoryDimension, H as CommentAgentAuthor, l as CommentAnchor, I as CommentAuthor, p as CommentsEntry, J as ComponentEntityToken, K as ENTITY_TYPE_METADATA, L as ENTITY_TYPE_TOKENS, M as EntityDoorProps, N as EntityDoorsPort, b as EntityOverlayEntry, E as EntityOverlayMap, O as EntityRefProps, Q as EntityTypeMeta, a as EntityTypeToken, c as ErrorSink, R as ListedEntityToken, S as ModuleEntityToken, T as PartAnchor, V as PgError, W as PickerOverrideMap, P as PlatformCategory, m as PlatformComment, X as REFERENCE_CATEGORY_DISPLAY, Y as ReferencePickableEntityToken, Z as SCHEMA_DISPLAY, _ as ScopeableEntityToken, k as UserEntityState, U as UserStateKind, $ as WindowShellPort, a0 as isAssociationTargetType, a1 as isAssociationsRpcErr, a2 as isEntityTypeToken, a3 as partKeyOf } from './results-Du0dzBb4.js';
1
+ export { r as ASSOCIATION_TARGET_TYPES, s as AssociationDirection, h as AssociationEdge, t as AssociationPickerProps, j as AssociationSourceEdge, i as AssociationTargetEdge, f as AssociationTargetType, q as AssociationsConfig, d as AssociationsDataSource, n as AssociationsEntry, e as AssociationsIdentity, u as AssociationsNotifier, A as AssociationsRpcError, v as AssociationsRpcErrorCode, w as AssociationsRpcOnlyDataSource, g as AssociationsRpcResult, x as AuthorDisplayInput, y as AuthorDisplayPort, z as CapturePickOpts, B as CapturePort, D as CaptureShownTo, F as CaptureUploadOpts, G as CaptureUploadResult, o as CategoriesEntry, C as CategoryDimension, H as CommentAgentAuthor, l as CommentAnchor, I as CommentAuthor, p as CommentsEntry, J as ComponentEntityToken, K as ENTITY_TYPE_METADATA, L as ENTITY_TYPE_TOKENS, M as EntityDoorProps, N as EntityDoorsPort, b as EntityOverlayEntry, E as EntityOverlayMap, O as EntityRefProps, Q as EntityTypeMeta, a as EntityTypeToken, c as ErrorSink, R as ListedEntityToken, S as ModuleEntityToken, T as PartAnchor, V as PgError, W as PickerOverrideMap, P as PlatformCategory, m as PlatformComment, X as REFERENCE_CATEGORY_DISPLAY, Y as ReferencePickableEntityToken, Z as SCHEMA_DISPLAY, _ as ScopeableEntityToken, k as UserEntityState, U as UserStateKind, $ as WindowShellPort, a0 as isAssociationTargetType, a1 as isAssociationsRpcErr, a2 as isEntityTypeToken, a3 as partKeyOf } from './results-HJm2RJQp.js';
2
2
  import 'react';
3
3
  import '@ai-matrx/data/db';
4
4
 
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  recordStoreNoun,
14
14
  registeredEdgeLabel,
15
15
  registeredEdgeLabels
16
- } from "./chunk-server-TFJNKVMM.js";
16
+ } from "./chunk-server-Y4DGNHLP.js";
17
17
 
18
18
  // src/edges.ts
19
19
  var ASSOCIATION_TARGET_TYPES = [
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/edges.ts","../src/comments.ts","../src/demanded-rpcs.generated.ts"],"sourcesContent":["// src/edges.ts — @ai-matrx/associations\n//\n// The association-edge, per-user-state, and category row/cache types — ported\n// verbatim from matrx-frontend `features/scopes/types.ts` (associations\n// extraction W1, 2026-08-29). One seam inverted: the host contract's `Json`\n// becomes `unknown` (the packaging standard's JSON-boundary rule — real\n// hosts' generated Supabase contracts emit `type Json = unknown`).\n//\n// The load-bearing boundary travels with these types: an association is a\n// LINK, never an access grant — access lives in iam.permissions /\n// iam.memberships; the only sanctioned bridge is DB-side conveyance\n// (`association_types.conveys_max` → reachability). This package makes zero\n// access decisions.\n\nimport type { EntityTypeToken } from \"./entity-types.generated\";\n\n// Allowed TARGET tokens for a `platform.associations` edge. There is NO DB CHECK\n// constraint on the type columns — the only gate is the FK to\n// `platform.entity_types.token` (any registered token is accepted). This list is\n// the client-side guard that keeps `add`/`setTargets` callers honest about which\n// containers we deliberately attach into.\n//\n// `satisfies readonly EntityTypeToken[]` PROVES at compile time that every token\n// here is a real, registered entity type — so this curated list can never drift\n// to a token that doesn't exist in `platform.entity_types`. A `source_type` is\n// validated at runtime (the full registry is allowed there); only the deliberate\n// container set is narrowed here.\nexport const ASSOCIATION_TARGET_TYPES = [\n \"organization\", // an org — the top-level container resources attach into\n \"scope\",\n \"tag\", // a platform tag (platform.tag) — items are filed under it (`<kind> -> tag`); FTS-4\n \"scope_type\",\n \"project\",\n \"task\",\n \"context_item\",\n \"thread\",\n \"war_room\",\n \"category\",\n \"conversation\", // a chat conversation a working_document is attached to\n \"fc_set\", // a flashcard set (card→set membership)\n \"fc_card\", // a flashcard (card→card hierarchy, quiz→card)\n \"study_media\", // a study-media artifact (summary/mind_map) — converter lineage target\n \"assessment\", // a quiz / practice test — a converter lineage target + origin (assessment→artifact 'source')\n \"note\", // a note — the origin a converted study artifact links back to (artifact→note 'source' lineage, P4)\n \"file\", // a file (card→file media + source lineage)\n \"processed_document\", // a processed source document (study-aid source lineage and kit membership)\n \"quiz_session\", // a quiz a card is used in\n \"agent\", // an orchestrator agent — the container an Orchestra's member agents attach into (role 'member'); an 'orchestra' self-edge marks the orchestrator\n \"agent_term_list\", // a term list — durable file attachments target its vocabulary resource\n \"research_tag\", // a research tag a source is filed under (rs_source_tag M2M collapsed into associations)\n \"skill\", // a skill — projects link to it (skill→project, role 'member'); code_files attach as resources (code_file→skill, role 'resource')\n \"surface\", // a UI surface — agents bind here (agent→surface); context menu reads via agent.menu_surface\n \"plan_entity\", // a Content Planning source/media citation — plan_node role edges (about/cites/embeds) target it\n \"plan_node\", // a planned page — research topics/tags attach here and follow realization into web_page\n \"web_site\", // a web.site — parties attach onto a site's roster (party→web_site role 'writes_for')\n \"seo_topic\", // a taxonomy topic — plan_node/plan_entity tag into it (role 'topic')\n \"seo_keyword\", // a keyword — plan_node attaches secondaries (role 'secondary_keyword'; the primary is an FK, never an edge)\n \"web_page\", // a canonical page — the page workspace attaches notes/tasks/files/keywords onto it (keyword edges: role 'primary'|'supporting')\n \"web_screenshot\", // a page capture — per-image attachments on the page workspace\n \"party\", // a CRM person/company (crm.party) — the record page attaches tasks/files/notes onto it\n \"crm_outreach_list\", // a CRM outreach list (a worked send/dial queue) — parties and resources attach into it\n \"crm_deal\", // a CRM deal (crm.deal) — people on it (role 'deal_contact'), tasks/files attach onto it\n \"rulebook\", // a Masterwork Rulebook — its Scout interviews attach here (conversation→rulebook, role 'interview')\n \"research_topic\", // a research topic — Sources are filed under it (processed_document→research_topic, the landing door's edge)\n \"media_source_library\", // a media-catalog Library — Sources are catalogued into it (processed_document→media_source_library)\n \"membership\", // a person's place in one organization (iam.memberships) — the org chart's Person box (role 'org_chart')\n \"team\", // an iam.team — a box on the org chart (role 'org_chart')\n \"position\", // an agent.position, a named seat (\"SEO Lead\") — a box on the org chart (role 'org_chart')\n \"board\", // a projects.board — conversations are filed on it (conversation→board, container_side none); the Board chat tile's own list\n \"web_brand\", // a web.brand — the people on a brand attach to it (party→web_brand, role 'owns' | 'key_person'); Smart Add \"Related\"\n] as const satisfies readonly EntityTypeToken[];\n\nexport type AssociationTargetType = (typeof ASSOCIATION_TARGET_TYPES)[number];\n\n/** Runtime guard: is this token one of the deliberate container (target) types? */\nexport function isAssociationTargetType(\n value: unknown,\n): value is AssociationTargetType {\n return (\n typeof value === \"string\" &&\n (ASSOCIATION_TARGET_TYPES as readonly string[]).includes(value)\n );\n}\n\n/**\n * Which edges a primary entity's association surfaces read and write.\n * - `incoming` (default) — the primary is a CONTAINER: it lists what is\n * attached INTO it (`resource → primary`) and \"+\" attaches resources to it.\n * - `outgoing` — the primary is FILED UNDER things (a Source under a project,\n * a research topic, a Library): it lists its own `primary → container`\n * edges and \"+\" files it under a container. Only container (target) types\n * can be filed under.\n */\nexport type AssociationDirection = \"incoming\" | \"outgoing\";\n\n// ─── Association edges (per-entity, both-directions cache) ─────────────\n//\n// One row of `assoc_for_entity(p_type, p_id)` — every edge touching the\n// entity in BOTH directions. `direction` is relative to the queried entity:\n// \"outgoing\" = the entity is the edge's source; \"incoming\" = it is the\n// target. `otherType`/`otherId` is the entity on the far end.\n\nexport interface AssociationEdge {\n id: string;\n direction: \"outgoing\" | \"incoming\";\n otherType: string;\n otherId: string;\n role: string | null; // the relationship's kind (e.g. member, expands_into, source)\n label: string | null;\n position: number | null; // ordering within a role (e.g. card order in a set)\n metadata: unknown;\n orgId: string | null;\n createdAt: string;\n}\n\n// One row of `assoc_for_targets(p_target_type, p_target_ids[])` — every INCOMING\n// edge (a member → one of the queried containers). `targetId` says which queried\n// target the edge points at, so a caller loading MANY containers at once can\n// group rows back by container in one pass. The batch counterpart of\n// `AssociationEdge` (single entity, both directions).\nexport interface AssociationTargetEdge {\n id: string;\n targetId: string;\n sourceType: string;\n sourceId: string;\n role: string | null;\n label: string | null;\n position: number | null;\n metadata: unknown;\n orgId: string | null;\n createdAt: string;\n}\n\n// One row of `assoc_for_sources` — the source-side batch counterpart of\n// `AssociationTargetEdge`. Every OUTGOING edge from a set of sources of one\n// type (optionally filtered to one target type). `sourceId` lets callers\n// group results back by source.\nexport interface AssociationSourceEdge {\n id: string;\n sourceId: string;\n targetType: string;\n targetId: string;\n role: string | null;\n label: string | null;\n position: number | null;\n metadata: unknown;\n orgId: string | null;\n createdAt: string;\n}\n\n// Cache entry for one `${type}:${id}` endpoint — the stable shape the\n// package-owned store (`/core`, W2) returns from `getEdges`.\nexport interface AssociationsEntry {\n status: \"idle\" | \"loading\" | \"ready\" | \"error\";\n edges: AssociationEdge[];\n fetchedAt: number | null;\n error: string | null;\n}\n\n// ─── Per-user entity state (platform.user_entity_state) ────────────────\n//\n// One row of the canonical per-user state ledger — the caller's favorite /\n// pinned / hidden flags + recency on a single entity. Reached ONLY via the\n// `ues_*` SECURITY-DEFINER RPCs. `entityType` is FREE TEXT in the DB\n// (per-user state is tracked for non-graph things too — e.g. `\"nav\"`\n// destinations — so the table has no entity_type CHECK), hence `string` here\n// rather than the constrained token union.\nexport interface UserEntityState {\n entityType: string;\n entityId: string;\n isFavorite: boolean;\n isPinned: boolean;\n isHidden: boolean;\n lastViewedAt: string | null;\n}\n\n/** The three boolean dimensions of per-user state, as accepted by `ues_list`. */\nexport type UserStateKind = \"favorite\" | \"pinned\" | \"hidden\";\n\n// ─── Categories (platform.categories) ─────────────────────────────────\n//\n// The canonical faceted taxonomy. ONE table, partitioned by `dimension`\n// (the facet — `agent-shortcut`, `skill`, `industry`, …). System/global\n// categories belong to the Matrx System org and carry `isSystem=true`;\n// ordinary categories belong to their tenant org. The client has NO direct\n// grant on `platform.categories`; every read/write goes through the PUBLIC\n// SECURITY-DEFINER `cat_*` RPCs.\n//\n// ASSIGNMENT of a category to an entity is NOT a category concern: it reuses\n// the association edge (`assoc_add(source, 'category', categoryId, orgId)`).\n// `category` is already a valid `AssociationTargetType`. A category is the\n// noun; the association is the verb.\n\n/**\n * The facet a category belongs to. Open vocabulary (new dimensions need no\n * migration — `dimension` is free text in the DB); hosts enumerate their\n * known dimensions as constants.\n */\nexport type CategoryDimension = string;\n\n/** One `platform.categories` row, camelCased (mirrors `cat_list`'s return). */\nexport interface PlatformCategory {\n id: string;\n /** Owning organization; system/global rows use the Matrx System org. */\n orgId: string | null;\n dimension: CategoryDimension;\n name: string;\n slug: string | null;\n parentId: string | null;\n isSystem: boolean;\n color: string | null;\n icon: string | null;\n position: number | null;\n /**\n * The row's jsonb metadata — category rows CARRY semantics: e.g. a\n * `deal_pipeline` stage stores `{outcome: \"won\"|\"lost\", probability: 0..100}`\n * here. Null when empty or when hydrated from an older cache entry.\n */\n metadata: Record<string, unknown> | null;\n}\n\n/** Cache entry for one `dimension` — mirrors `AssociationsEntry`. */\nexport interface CategoriesEntry {\n status: \"idle\" | \"loading\" | \"ready\" | \"error\";\n categories: PlatformCategory[];\n fetchedAt: number | null;\n error: string | null;\n}\n","// src/comments.ts — @ai-matrx/associations\n//\n// Canonical types for the unified comments primitive — `platform.comments`\n// (W6: the comments canonical UI is built IN this package, ruling C4). One\n// comment table for EVERY entity on the platform, threaded via `parentId`,\n// reached ONLY through the four PUBLIC SECURITY-DEFINER RPCs\n// (`cmt_list` / `cmt_add` / `cmt_edit` / `cmt_delete`) — part of this\n// package's demanded schema, called only by `/core`'s comments service.\n//\n// Types ported from matrx-frontend `features/comments/types.ts`\n// (2026-08-29) and renamed to the package vocabulary (`PlatformComment`,\n// mirroring `PlatformCategory`). The access boundary travels with them: a\n// comment rides the association/access model — read and write rights\n// are decided INSIDE the RPCs (org membership + authorship), this package\n// makes zero access decisions.\n\n/** The author of a comment, denormalized by `cmt_list` from the auth user. */\nexport interface CommentAuthor {\n email: string | null;\n displayName: string | null;\n avatarUrl: string | null;\n}\n\n/**\n * One `platform.comments` row, camelCased (mirrors `cmt_list`'s return).\n * Threading is by `parentId`: a top-level comment has `parentId === null`;\n * a reply points at its parent. `cmt_list` returns rows oldest→newest so\n * callers can build the thread in one pass.\n */\nexport interface PlatformComment {\n id: string;\n orgId: string | null;\n entityType: string;\n entityId: string;\n parentId: string | null;\n body: string;\n createdAt: string;\n updatedAt: string;\n createdBy: string | null;\n author: CommentAuthor;\n /**\n * The platform agent that wrote this comment (a reply the agent made in the\n * thread), or null when a person did. `createdBy` stays the person whose\n * authority it ran under — an agent's comment is never \"mine\" and has no Edit.\n */\n authorAgent: CommentAgentAuthor | null;\n /** The comment's anchor (`text_anchor` passage, `part_anchor` part, ...), or null for the whole record. */\n anchor: CommentAnchor | null;\n}\n\n/** The agent behind a comment (`cmt_list`'s author_agent_id/name). */\nexport interface CommentAgentAuthor {\n id: string;\n name: string | null;\n}\n\n/** A comment's anchor as stored: a `__kind`-marked object (`platform.comments.anchor`). */\nexport type CommentAnchor = { __kind: string } & Record<string, unknown>;\n\n/**\n * `part_anchor`: a comment on one PART of a record that is not a record of its\n * own — a board-only tile is `tile:<tile id>`. The database validates it\n * (`platform.part_anchor_problem`, and for a board that the tile exists).\n */\nexport interface PartAnchor extends Record<string, unknown> {\n __kind: \"part_anchor\";\n part_key: string;\n label?: string;\n}\n\n/** The part a comment is on, or null when it is on the whole record / a passage. */\nexport function partKeyOf(comment: Pick<PlatformComment, \"anchor\">): string | null {\n const a = comment.anchor;\n return a && a.__kind === \"part_anchor\" && typeof a.part_key === \"string\" ? a.part_key : null;\n}\n\n/**\n * One cached comment thread (per `${entityType}:${entityId}` endpoint) — the\n * same lifecycle shape as `AssociationsEntry`/`CategoriesEntry`: pending\n * keeps previous comments AND the visible error; `fetchedAt` is the last\n * successful load.\n */\nexport interface CommentsEntry {\n status: \"idle\" | \"loading\" | \"ready\" | \"error\";\n comments: readonly PlatformComment[];\n fetchedAt: number | null;\n error: string | null;\n}\n","// ─────────────────────────────────────────────────────────────────────────\n// AUTOGENERATED — DO NOT EDIT BY HAND.\n//\n// The TYPED half of this package's DEMANDED SCHEMA: the 29 SECURITY\n// DEFINER RPC families every operation goes through (the client holds NO\n// grant on `platform.associations` itself). Sliced from the live-generated\n// Supabase contract of the platform DB.\n// Regenerate: pnpm gen:demanded-rpcs -- /path/to/database.types.ts\n//\n// A database that cannot answer these functions is not this package's\n// database — the runtime PGRST202 scream (`mapPgError`, /core) and the\n// `demanded_schema_violation` error code scream exactly that.\n//\n// NOT demanded, deliberately: the DB's legacy `assoc_link` / `assoc_list` /\n// `assoc_unlink` trio (zero client callers — flagged for server-side\n// retirement, never adopted here).\n//\n// `unknown` stands in for the host contract's `Json` (JSON-boundary rule in\n// /policies/typescript-package-standard.md).\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Per-RPC Args/Returns for every demanded function, straight from the live DB. */\nexport interface DemandedRpcSignatures {\n // ── edges — writes ──\n assoc_add: {\n Args: {\n p_label?: string\n p_metadata?: unknown\n p_org_id?: string\n p_payload?: unknown\n p_payload_kind?: string\n p_position?: number\n p_role?: string\n p_source_id: string\n p_source_type: string\n p_target_id: string\n p_target_type: string\n }\n Returns: string\n };\n assoc_remove: {\n Args: {\n p_role?: string\n p_source_id: string\n p_source_type: string\n p_target_id: string\n p_target_type: string\n }\n Returns: undefined\n };\n assoc_set_targets: {\n Args: {\n p_org_id?: string\n p_role?: string\n p_source_id: string\n p_source_type: string\n p_target_ids: string[]\n p_target_type: string\n }\n Returns: undefined\n };\n assoc_remove_for_entity: {\n Args: { p_id: string; p_type: string }\n Returns: undefined\n };\n // ── edges — reads ──\n assoc_for_entity: {\n Args: { p_id: string; p_type: string }\n Returns: {\n created_at: string\n direction: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n other_id: string\n other_type: string\n position: number\n role: string\n }[]\n };\n assoc_for_targets: {\n Args: { p_target_ids: string[]; p_target_type: string }\n Returns: {\n created_at: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n position: number\n role: string\n source_id: string\n source_type: string\n target_id: string\n }[]\n };\n assoc_for_sources: {\n Args: {\n p_source_ids: string[]\n p_source_type: string\n p_target_type?: string\n }\n Returns: {\n created_at: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n position: number\n role: string\n source_id: string\n target_id: string\n target_type: string\n }[]\n };\n assoc_members_visible: {\n Args: { p_target_ids: string[]; p_target_type: string }\n Returns: {\n created_at: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n position: number\n role: string\n source_id: string\n source_type: string\n target_id: string\n }[]\n };\n // ── conversation files (stricter access-conveying pair) ──\n conversation_file_add: {\n Args: {\n p_conversation_id: string\n p_file_id: string\n p_label?: string\n p_metadata?: unknown\n p_replace_metadata?: boolean\n }\n Returns: string\n };\n conversation_file_remove: {\n Args: { p_conversation_id: string; p_file_id: string }\n Returns: undefined\n };\n conversation_files: {\n Args: { p_conversation_id: string }\n Returns: {\n created_at: string\n file_id: string\n label: string\n metadata: unknown\n }[]\n };\n // ── agent resources (editor-gated containment authoring) ──\n agent_resource_add: {\n Args: {\n p_agent_id: string\n p_label?: string\n p_metadata?: unknown\n p_source_id: string\n p_source_type: string\n }\n Returns: string\n };\n agent_resource_remove: {\n Args: { p_agent_id: string; p_source_id: string; p_source_type: string }\n Returns: undefined\n };\n // ── categories ──\n cat_list: {\n Args: { p_dimension?: string }\n Returns: {\n color: string\n dimension: string\n icon: string\n id: string\n is_system: boolean\n metadata: unknown\n name: string\n organization_id: string\n parent_id: string\n position: number\n slug: string\n }[]\n };\n cat_create: {\n Args: {\n p_color?: string\n p_dimension: string\n p_icon?: string\n p_name: string\n p_org_id: string\n p_parent_id?: string\n p_slug?: string\n }\n Returns: string\n };\n cat_update: {\n Args: {\n p_category_id: string\n p_color?: string\n p_icon?: string\n p_name: string\n p_position?: number\n p_slug?: string\n }\n Returns: string\n };\n cat_reparent: {\n Args: { p_category_id: string; p_parent_id?: string }\n Returns: string\n };\n cat_delete: { Args: { p_category_id: string }; Returns: string };\n // ── favorites / recents ──\n ues_set: {\n Args: {\n p_entity_id: string\n p_entity_type: string\n p_is_favorite?: boolean\n p_is_hidden?: boolean\n p_is_pinned?: boolean\n }\n Returns: undefined\n };\n ues_list: {\n Args: { p_kind?: string }\n Returns: {\n entity_id: string\n entity_type: string\n is_favorite: boolean\n is_hidden: boolean\n is_pinned: boolean\n last_viewed_at: string\n updated_at: string\n }[]\n };\n ues_get_bulk: {\n Args: { p_entity_ids: string[]; p_entity_type: string }\n Returns: {\n entity_id: string\n is_favorite: boolean\n is_hidden: boolean\n is_pinned: boolean\n last_viewed_at: string\n }[]\n };\n ues_touch: {\n Args: { p_entity_id: string; p_entity_type: string }\n Returns: undefined\n };\n // ── candidates ──\n reference_search_candidates: {\n Args: {\n p_ids?: string[]\n p_limit?: number\n p_mine?: boolean\n p_offset?: number\n p_order?: string\n p_organization_id?: string\n p_search?: string\n p_show_system_files?: boolean\n p_token: string\n }\n Returns: {\n id: string\n title: string\n updated_at: string\n }[]\n };\n // ── entity rows (the generic create-a-new-one door) ──\n entity_row_create: {\n Args: { p_organization_id: string; p_title: string; p_token: string }\n Returns: unknown\n };\n entity_row_rename: {\n Args: { p_id: string; p_title: string; p_token: string }\n Returns: unknown\n };\n // ── comments (threaded comment on any entity, W6) ──\n cmt_list: {\n Args: { p_entity_id: string; p_entity_type: string }\n Returns: {\n anchor: unknown\n author_agent_id: string\n author_agent_name: string\n author_avatar_url: string\n author_display_name: string\n author_email: string\n body: string\n client_request_id: string\n created_at: string\n created_by: string\n created_by_tier: string\n edited_at: string\n entity_id: string\n entity_type: string\n id: string\n organization_id: string\n parent_id: string\n resolved_at: string\n resolved_by: string\n suggested_text: string\n updated_at: string\n version: number\n }[]\n };\n cmt_add: {\n Args: {\n p_anchor?: unknown\n p_body: string\n p_client_request_id?: string\n p_entity_id: string\n p_entity_type: string\n p_org_id?: string\n p_parent_id?: string\n p_suggested_text?: string\n }\n Returns: string\n };\n cmt_edit: {\n Args: { p_body: string; p_expected_version?: number; p_id: string }\n Returns: number\n };\n cmt_delete: { Args: { p_id: string }; Returns: undefined };\n}\n\n/** The name of any demanded RPC — the only strings the dataSource port accepts. */\nexport type DemandedRpcName = keyof DemandedRpcSignatures;\n\n/** Every demanded RPC name, for iteration (the schema probe walks this). */\nexport const DEMANDED_RPC_NAMES: readonly DemandedRpcName[] = [\n \"assoc_add\",\n \"assoc_remove\",\n \"assoc_set_targets\",\n \"assoc_remove_for_entity\",\n \"assoc_for_entity\",\n \"assoc_for_targets\",\n \"assoc_for_sources\",\n \"assoc_members_visible\",\n \"conversation_file_add\",\n \"conversation_file_remove\",\n \"conversation_files\",\n \"agent_resource_add\",\n \"agent_resource_remove\",\n \"cat_list\",\n \"cat_create\",\n \"cat_update\",\n \"cat_reparent\",\n \"cat_delete\",\n \"ues_set\",\n \"ues_list\",\n \"ues_get_bulk\",\n \"ues_touch\",\n \"reference_search_candidates\",\n \"entity_row_create\",\n \"entity_row_rename\",\n \"cmt_list\",\n \"cmt_add\",\n \"cmt_edit\",\n \"cmt_delete\",\n];\n\n/** Args type for one demanded RPC. */\nexport type DemandedRpcArgs<N extends DemandedRpcName> =\n DemandedRpcSignatures[N][\"Args\"];\n\n/** Returns type for one demanded RPC. */\nexport type DemandedRpcReturns<N extends DemandedRpcName> =\n DemandedRpcSignatures[N][\"Returns\"];\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BO,IAAM,2BAA2B;AAAA,EACtC;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAKO,SAAS,wBACd,OACgC;AAChC,SACE,OAAO,UAAU,YAChB,yBAA+C,SAAS,KAAK;AAElE;;;ACXO,SAAS,UAAU,SAAyD;AACjF,QAAM,IAAI,QAAQ;AAClB,SAAO,KAAK,EAAE,WAAW,iBAAiB,OAAO,EAAE,aAAa,WAAW,EAAE,WAAW;AAC1F;;;ACiQO,IAAM,qBAAiD;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/edges.ts","../src/comments.ts","../src/demanded-rpcs.generated.ts"],"sourcesContent":["// src/edges.ts — @ai-matrx/associations\n//\n// The association-edge, per-user-state, and category row/cache types — ported\n// verbatim from matrx-frontend `features/scopes/types.ts` (associations\n// extraction W1, 2026-08-29). One seam inverted: the host contract's `Json`\n// becomes `unknown` (the packaging standard's JSON-boundary rule — real\n// hosts' generated Supabase contracts emit `type Json = unknown`).\n//\n// The load-bearing boundary travels with these types: an association is a\n// LINK, never an access grant — access lives in iam.permissions /\n// iam.memberships; the only sanctioned bridge is DB-side conveyance\n// (`association_types.conveys_max` → reachability). This package makes zero\n// access decisions.\n\nimport type { EntityTypeToken } from \"./entity-types.generated\";\n\n// Allowed TARGET tokens for a `platform.associations` edge. There is NO DB CHECK\n// constraint on the type columns — the only gate is the FK to\n// `platform.entity_types.token` (any registered token is accepted). This list is\n// the client-side guard that keeps `add`/`setTargets` callers honest about which\n// containers we deliberately attach into.\n//\n// `satisfies readonly EntityTypeToken[]` PROVES at compile time that every token\n// here is a real, registered entity type — so this curated list can never drift\n// to a token that doesn't exist in `platform.entity_types`. A `source_type` is\n// validated at runtime (the full registry is allowed there); only the deliberate\n// container set is narrowed here.\nexport const ASSOCIATION_TARGET_TYPES = [\n \"organization\", // an org — the top-level container resources attach into\n \"scope\",\n \"tag\", // a platform tag (platform.tag) — items are filed under it (`<kind> -> tag`); FTS-4\n \"scope_type\",\n \"project\",\n \"task\",\n \"context_item\",\n \"thread\",\n \"war_room\",\n \"category\",\n \"conversation\", // a chat conversation a working_document is attached to\n \"fc_set\", // a flashcard set (card→set membership)\n \"fc_card\", // a flashcard (card→card hierarchy, quiz→card)\n \"study_media\", // a study-media artifact (summary/mind_map) — converter lineage target\n \"assessment\", // a quiz / practice test — a converter lineage target + origin (assessment→artifact 'source')\n \"note\", // a note — the origin a converted study artifact links back to (artifact→note 'source' lineage, P4)\n \"file\", // a file (card→file media + source lineage)\n \"processed_document\", // a processed source document (study-aid source lineage and kit membership)\n \"quiz_session\", // a quiz a card is used in\n \"agent\", // an orchestrator agent — the container an Orchestra's member agents attach into (role 'member'); an 'orchestra' self-edge marks the orchestrator\n \"agent_term_list\", // a term list — durable file attachments target its vocabulary resource\n \"research_tag\", // a research tag a source is filed under (rs_source_tag M2M collapsed into associations)\n \"skill\", // a skill — projects link to it (skill→project, role 'member'); code_files attach as resources (code_file→skill, role 'resource')\n \"surface\", // a UI surface — agents bind here (agent→surface); context menu reads via agent.menu_surface\n \"plan_entity\", // a Content Planning source/media citation — plan_node role edges (about/cites/embeds) target it\n \"plan_node\", // a planned page — research topics/tags attach here and follow realization into web_page\n \"web_site\", // a web.site — parties attach onto a site's roster (party→web_site role 'writes_for')\n \"seo_topic\", // a taxonomy topic — plan_node/plan_entity tag into it (role 'topic')\n \"seo_keyword\", // a keyword — plan_node attaches secondaries (role 'secondary_keyword'; the primary is an FK, never an edge)\n \"web_page\", // a canonical page — the page workspace attaches notes/tasks/files/keywords onto it (keyword edges: role 'primary'|'supporting')\n \"web_screenshot\", // a page capture — per-image attachments on the page workspace\n \"party\", // a CRM person/company (crm.party) — the record page attaches tasks/files/notes onto it\n \"crm_outreach_list\", // a CRM outreach list (a worked send/dial queue) — parties and resources attach into it\n \"crm_deal\", // a CRM deal (crm.deal) — people on it (role 'deal_contact'), tasks/files attach onto it\n \"rulebook\", // a Masterwork Rulebook — its Scout interviews attach here (conversation→rulebook, role 'interview')\n \"research_topic\", // a research topic — Sources are filed under it (processed_document→research_topic, the landing door's edge)\n \"media_source_library\", // a media-catalog Library — Sources are catalogued into it (processed_document→media_source_library)\n \"membership\", // a person's place in one organization (iam.memberships) — the org chart's Person box (role 'org_chart')\n \"team\", // an iam.team — a box on the org chart (role 'org_chart')\n \"position\", // an agent.position, a named seat (\"SEO Lead\") — a box on the org chart (role 'org_chart')\n \"board\", // a projects.board — conversations are filed on it (conversation→board, container_side none); the Board chat tile's own list\n \"web_brand\", // a web.brand — the people on a brand attach to it (party→web_brand, role 'owns' | 'key_person'); Smart Add \"Related\"\n] as const satisfies readonly EntityTypeToken[];\n\nexport type AssociationTargetType = (typeof ASSOCIATION_TARGET_TYPES)[number];\n\n/** Runtime guard: is this token one of the deliberate container (target) types? */\nexport function isAssociationTargetType(\n value: unknown,\n): value is AssociationTargetType {\n return (\n typeof value === \"string\" &&\n (ASSOCIATION_TARGET_TYPES as readonly string[]).includes(value)\n );\n}\n\n/**\n * Which edges a primary entity's association surfaces read and write.\n * - `incoming` (default) — the primary is a CONTAINER: it lists what is\n * attached INTO it (`resource → primary`) and \"+\" attaches resources to it.\n * - `outgoing` — the primary is FILED UNDER things (a Source under a project,\n * a research topic, a Library): it lists its own `primary → container`\n * edges and \"+\" files it under a container. Only container (target) types\n * can be filed under.\n */\nexport type AssociationDirection = \"incoming\" | \"outgoing\";\n\n// ─── Association edges (per-entity, both-directions cache) ─────────────\n//\n// One row of `assoc_for_entity(p_type, p_id)` — every edge touching the\n// entity in BOTH directions. `direction` is relative to the queried entity:\n// \"outgoing\" = the entity is the edge's source; \"incoming\" = it is the\n// target. `otherType`/`otherId` is the entity on the far end.\n\nexport interface AssociationEdge {\n id: string;\n direction: \"outgoing\" | \"incoming\";\n otherType: string;\n otherId: string;\n role: string | null; // the relationship's kind (e.g. member, expands_into, source)\n label: string | null;\n position: number | null; // ordering within a role (e.g. card order in a set)\n metadata: unknown;\n orgId: string | null;\n createdAt: string;\n}\n\n// One row of `assoc_for_targets(p_target_type, p_target_ids[])` — every INCOMING\n// edge (a member → one of the queried containers). `targetId` says which queried\n// target the edge points at, so a caller loading MANY containers at once can\n// group rows back by container in one pass. The batch counterpart of\n// `AssociationEdge` (single entity, both directions).\nexport interface AssociationTargetEdge {\n id: string;\n targetId: string;\n sourceType: string;\n sourceId: string;\n role: string | null;\n label: string | null;\n position: number | null;\n metadata: unknown;\n orgId: string | null;\n createdAt: string;\n}\n\n// One row of `assoc_for_sources` — the source-side batch counterpart of\n// `AssociationTargetEdge`. Every OUTGOING edge from a set of sources of one\n// type (optionally filtered to one target type). `sourceId` lets callers\n// group results back by source.\nexport interface AssociationSourceEdge {\n id: string;\n sourceId: string;\n targetType: string;\n targetId: string;\n role: string | null;\n label: string | null;\n position: number | null;\n metadata: unknown;\n orgId: string | null;\n createdAt: string;\n}\n\n// Cache entry for one `${type}:${id}` endpoint — the stable shape the\n// package-owned store (`/core`, W2) returns from `getEdges`.\nexport interface AssociationsEntry {\n status: \"idle\" | \"loading\" | \"ready\" | \"error\";\n edges: AssociationEdge[];\n fetchedAt: number | null;\n error: string | null;\n}\n\n// ─── Per-user entity state (platform.user_entity_state) ────────────────\n//\n// One row of the canonical per-user state ledger — the caller's favorite /\n// pinned / hidden flags + recency on a single entity. Reached ONLY via the\n// `ues_*` SECURITY-DEFINER RPCs. `entityType` is FREE TEXT in the DB\n// (per-user state is tracked for non-graph things too — e.g. `\"nav\"`\n// destinations — so the table has no entity_type CHECK), hence `string` here\n// rather than the constrained token union.\nexport interface UserEntityState {\n entityType: string;\n entityId: string;\n isFavorite: boolean;\n isPinned: boolean;\n isHidden: boolean;\n lastViewedAt: string | null;\n}\n\n/** The three boolean dimensions of per-user state, as accepted by `ues_list`. */\nexport type UserStateKind = \"favorite\" | \"pinned\" | \"hidden\";\n\n// ─── Categories (platform.categories) ─────────────────────────────────\n//\n// The canonical faceted taxonomy. ONE table, partitioned by `dimension`\n// (the facet — `agent-shortcut`, `skill`, `industry`, …). System/global\n// categories belong to the Matrx System org and carry `isSystem=true`;\n// ordinary categories belong to their tenant org. The client has NO direct\n// grant on `platform.categories`; every read/write goes through the PUBLIC\n// SECURITY-DEFINER `cat_*` RPCs.\n//\n// ASSIGNMENT of a category to an entity is NOT a category concern: it reuses\n// the association edge (`assoc_add(source, 'category', categoryId, orgId)`).\n// `category` is already a valid `AssociationTargetType`. A category is the\n// noun; the association is the verb.\n\n/**\n * The facet a category belongs to. Open vocabulary (new dimensions need no\n * migration — `dimension` is free text in the DB); hosts enumerate their\n * known dimensions as constants.\n */\nexport type CategoryDimension = string;\n\n/** One `platform.categories` row, camelCased (mirrors `cat_list`'s return). */\nexport interface PlatformCategory {\n id: string;\n /** Owning organization; system/global rows use the Matrx System org. */\n orgId: string | null;\n dimension: CategoryDimension;\n name: string;\n slug: string | null;\n parentId: string | null;\n isSystem: boolean;\n color: string | null;\n icon: string | null;\n position: number | null;\n /**\n * The row's jsonb metadata — category rows CARRY semantics: e.g. a\n * `deal_pipeline` stage stores `{outcome: \"won\"|\"lost\", probability: 0..100}`\n * here. Null when empty or when hydrated from an older cache entry.\n */\n metadata: Record<string, unknown> | null;\n}\n\n/** Cache entry for one `dimension` — mirrors `AssociationsEntry`. */\nexport interface CategoriesEntry {\n status: \"idle\" | \"loading\" | \"ready\" | \"error\";\n categories: PlatformCategory[];\n fetchedAt: number | null;\n error: string | null;\n}\n","// src/comments.ts — @ai-matrx/associations\n//\n// Canonical types for the unified comments primitive — `platform.comments`\n// (W6: the comments canonical UI is built IN this package, ruling C4). One\n// comment table for EVERY entity on the platform, threaded via `parentId`,\n// reached ONLY through the four PUBLIC SECURITY-DEFINER RPCs\n// (`cmt_list` / `cmt_add` / `cmt_edit` / `cmt_delete`) — part of this\n// package's demanded schema, called only by `/core`'s comments service.\n//\n// Types ported from matrx-frontend `features/comments/types.ts`\n// (2026-08-29) and renamed to the package vocabulary (`PlatformComment`,\n// mirroring `PlatformCategory`). The access boundary travels with them: a\n// comment rides the association/access model — read and write rights\n// are decided INSIDE the RPCs (org membership + authorship), this package\n// makes zero access decisions.\n\n/** The author of a comment, denormalized by `cmt_list` from the auth user. */\nexport interface CommentAuthor {\n email: string | null;\n displayName: string | null;\n avatarUrl: string | null;\n}\n\n/**\n * One `platform.comments` row, camelCased (mirrors `cmt_list`'s return).\n * Threading is by `parentId`: a top-level comment has `parentId === null`;\n * a reply points at its parent. `cmt_list` returns rows oldest→newest so\n * callers can build the thread in one pass.\n */\nexport interface PlatformComment {\n id: string;\n orgId: string | null;\n entityType: string;\n entityId: string;\n parentId: string | null;\n body: string;\n createdAt: string;\n updatedAt: string;\n createdBy: string | null;\n author: CommentAuthor;\n /**\n * The platform agent that wrote this comment (a reply the agent made in the\n * thread), or null when a person did. `createdBy` stays the person whose\n * authority it ran under — an agent's comment is never \"mine\" and has no Edit.\n */\n authorAgent: CommentAgentAuthor | null;\n /**\n * The platform itself wrote this comment (`created_by_tier = 'system'`, e.g. the opener of\n * an edit remark's thread): credited to the system, never to `createdBy`, never editable.\n */\n authorSystem?: boolean;\n /** The comment's anchor (`text_anchor` passage, `part_anchor` part, ...), or null for the whole record. */\n anchor: CommentAnchor | null;\n}\n\n/** The agent behind a comment (`cmt_list`'s author_agent_id/name). */\nexport interface CommentAgentAuthor {\n id: string;\n name: string | null;\n}\n\n/** A comment's anchor as stored: a `__kind`-marked object (`platform.comments.anchor`). */\nexport type CommentAnchor = { __kind: string } & Record<string, unknown>;\n\n/**\n * `part_anchor`: a comment on one PART of a record that is not a record of its\n * own — a board-only tile is `tile:<tile id>`. The database validates it\n * (`platform.part_anchor_problem`, and for a board that the tile exists).\n */\nexport interface PartAnchor extends Record<string, unknown> {\n __kind: \"part_anchor\";\n part_key: string;\n label?: string;\n}\n\n/** The part a comment is on, or null when it is on the whole record / a passage. */\nexport function partKeyOf(comment: Pick<PlatformComment, \"anchor\">): string | null {\n const a = comment.anchor;\n return a && a.__kind === \"part_anchor\" && typeof a.part_key === \"string\" ? a.part_key : null;\n}\n\n/**\n * One cached comment thread (per `${entityType}:${entityId}` endpoint) — the\n * same lifecycle shape as `AssociationsEntry`/`CategoriesEntry`: pending\n * keeps previous comments AND the visible error; `fetchedAt` is the last\n * successful load.\n */\nexport interface CommentsEntry {\n status: \"idle\" | \"loading\" | \"ready\" | \"error\";\n comments: readonly PlatformComment[];\n fetchedAt: number | null;\n error: string | null;\n}\n","// ─────────────────────────────────────────────────────────────────────────\n// AUTOGENERATED — DO NOT EDIT BY HAND.\n//\n// The TYPED half of this package's DEMANDED SCHEMA: the 29 SECURITY\n// DEFINER RPC families every operation goes through (the client holds NO\n// grant on `platform.associations` itself). Sliced from the live-generated\n// Supabase contract of the platform DB.\n// Regenerate: pnpm gen:demanded-rpcs -- /path/to/database.types.ts\n//\n// A database that cannot answer these functions is not this package's\n// database — the runtime PGRST202 scream (`mapPgError`, /core) and the\n// `demanded_schema_violation` error code scream exactly that.\n//\n// NOT demanded, deliberately: the DB's legacy `assoc_link` / `assoc_list` /\n// `assoc_unlink` trio (zero client callers — flagged for server-side\n// retirement, never adopted here).\n//\n// `unknown` stands in for the host contract's `Json` (JSON-boundary rule in\n// /policies/typescript-package-standard.md).\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Per-RPC Args/Returns for every demanded function, straight from the live DB. */\nexport interface DemandedRpcSignatures {\n // ── edges — writes ──\n assoc_add: {\n Args: {\n p_label?: string\n p_metadata?: unknown\n p_org_id?: string\n p_payload?: unknown\n p_payload_kind?: string\n p_position?: number\n p_role?: string\n p_source_id: string\n p_source_type: string\n p_target_id: string\n p_target_type: string\n }\n Returns: string\n };\n assoc_remove: {\n Args: {\n p_role?: string\n p_source_id: string\n p_source_type: string\n p_target_id: string\n p_target_type: string\n }\n Returns: undefined\n };\n assoc_set_targets: {\n Args: {\n p_org_id?: string\n p_role?: string\n p_source_id: string\n p_source_type: string\n p_target_ids: string[]\n p_target_type: string\n }\n Returns: undefined\n };\n assoc_remove_for_entity: {\n Args: { p_id: string; p_type: string }\n Returns: undefined\n };\n // ── edges — reads ──\n assoc_for_entity: {\n Args: { p_id: string; p_type: string }\n Returns: {\n created_at: string\n direction: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n other_id: string\n other_type: string\n position: number\n role: string\n }[]\n };\n assoc_for_targets: {\n Args: { p_target_ids: string[]; p_target_type: string }\n Returns: {\n created_at: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n position: number\n role: string\n source_id: string\n source_type: string\n target_id: string\n }[]\n };\n assoc_for_sources: {\n Args: {\n p_source_ids: string[]\n p_source_type: string\n p_target_type?: string\n }\n Returns: {\n created_at: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n position: number\n role: string\n source_id: string\n target_id: string\n target_type: string\n }[]\n };\n assoc_members_visible: {\n Args: { p_target_ids: string[]; p_target_type: string }\n Returns: {\n created_at: string\n id: string\n label: string\n metadata: unknown\n organization_id: string\n position: number\n role: string\n source_id: string\n source_type: string\n target_id: string\n }[]\n };\n // ── conversation files (stricter access-conveying pair) ──\n conversation_file_add: {\n Args: {\n p_conversation_id: string\n p_file_id: string\n p_label?: string\n p_metadata?: unknown\n p_replace_metadata?: boolean\n }\n Returns: string\n };\n conversation_file_remove: {\n Args: { p_conversation_id: string; p_file_id: string }\n Returns: undefined\n };\n conversation_files: {\n Args: { p_conversation_id: string }\n Returns: {\n created_at: string\n file_id: string\n label: string\n metadata: unknown\n }[]\n };\n // ── agent resources (editor-gated containment authoring) ──\n agent_resource_add: {\n Args: {\n p_agent_id: string\n p_label?: string\n p_metadata?: unknown\n p_source_id: string\n p_source_type: string\n }\n Returns: string\n };\n agent_resource_remove: {\n Args: { p_agent_id: string; p_source_id: string; p_source_type: string }\n Returns: undefined\n };\n // ── categories ──\n cat_list: {\n Args: { p_dimension?: string }\n Returns: {\n color: string\n dimension: string\n icon: string\n id: string\n is_system: boolean\n metadata: unknown\n name: string\n organization_id: string\n parent_id: string\n position: number\n slug: string\n }[]\n };\n cat_create: {\n Args: {\n p_color?: string\n p_dimension: string\n p_icon?: string\n p_name: string\n p_org_id: string\n p_parent_id?: string\n p_slug?: string\n }\n Returns: string\n };\n cat_update: {\n Args: {\n p_category_id: string\n p_color?: string\n p_icon?: string\n p_name: string\n p_position?: number\n p_slug?: string\n }\n Returns: string\n };\n cat_reparent: {\n Args: { p_category_id: string; p_parent_id?: string }\n Returns: string\n };\n cat_delete: { Args: { p_category_id: string }; Returns: string };\n // ── favorites / recents ──\n ues_set: {\n Args: {\n p_entity_id: string\n p_entity_type: string\n p_is_favorite?: boolean\n p_is_hidden?: boolean\n p_is_pinned?: boolean\n }\n Returns: undefined\n };\n ues_list: {\n Args: { p_kind?: string }\n Returns: {\n entity_id: string\n entity_type: string\n is_favorite: boolean\n is_hidden: boolean\n is_pinned: boolean\n last_viewed_at: string\n updated_at: string\n }[]\n };\n ues_get_bulk: {\n Args: { p_entity_ids: string[]; p_entity_type: string }\n Returns: {\n entity_id: string\n is_favorite: boolean\n is_hidden: boolean\n is_pinned: boolean\n last_viewed_at: string\n }[]\n };\n ues_touch: {\n Args: { p_entity_id: string; p_entity_type: string }\n Returns: undefined\n };\n // ── candidates ──\n reference_search_candidates: {\n Args: {\n p_ids?: string[]\n p_limit?: number\n p_mine?: boolean\n p_offset?: number\n p_order?: string\n p_organization_id?: string\n p_search?: string\n p_show_system_files?: boolean\n p_token: string\n }\n Returns: {\n id: string\n title: string\n updated_at: string\n }[]\n };\n // ── entity rows (the generic create-a-new-one door) ──\n entity_row_create: {\n Args: { p_organization_id: string; p_title: string; p_token: string }\n Returns: unknown\n };\n entity_row_rename: {\n Args: { p_id: string; p_title: string; p_token: string }\n Returns: unknown\n };\n // ── comments (threaded comment on any entity, W6) ──\n cmt_list: {\n Args: { p_entity_id: string; p_entity_type: string }\n Returns: {\n anchor: unknown\n author_agent_id: string\n author_agent_name: string\n author_avatar_url: string\n author_display_name: string\n author_email: string\n body: string\n client_request_id: string\n created_at: string\n created_by: string\n created_by_tier: string\n edited_at: string\n entity_id: string\n entity_type: string\n id: string\n organization_id: string\n parent_id: string\n resolved_at: string\n resolved_by: string\n suggested_text: string\n updated_at: string\n version: number\n }[]\n };\n cmt_add: {\n Args: {\n p_anchor?: unknown\n p_body: string\n p_client_request_id?: string\n p_entity_id: string\n p_entity_type: string\n p_org_id?: string\n p_parent_id?: string\n p_suggested_text?: string\n }\n Returns: string\n };\n cmt_edit: {\n Args: { p_body: string; p_expected_version?: number; p_id: string }\n Returns: number\n };\n cmt_delete: { Args: { p_id: string }; Returns: undefined };\n}\n\n/** The name of any demanded RPC — the only strings the dataSource port accepts. */\nexport type DemandedRpcName = keyof DemandedRpcSignatures;\n\n/** Every demanded RPC name, for iteration (the schema probe walks this). */\nexport const DEMANDED_RPC_NAMES: readonly DemandedRpcName[] = [\n \"assoc_add\",\n \"assoc_remove\",\n \"assoc_set_targets\",\n \"assoc_remove_for_entity\",\n \"assoc_for_entity\",\n \"assoc_for_targets\",\n \"assoc_for_sources\",\n \"assoc_members_visible\",\n \"conversation_file_add\",\n \"conversation_file_remove\",\n \"conversation_files\",\n \"agent_resource_add\",\n \"agent_resource_remove\",\n \"cat_list\",\n \"cat_create\",\n \"cat_update\",\n \"cat_reparent\",\n \"cat_delete\",\n \"ues_set\",\n \"ues_list\",\n \"ues_get_bulk\",\n \"ues_touch\",\n \"reference_search_candidates\",\n \"entity_row_create\",\n \"entity_row_rename\",\n \"cmt_list\",\n \"cmt_add\",\n \"cmt_edit\",\n \"cmt_delete\",\n];\n\n/** Args type for one demanded RPC. */\nexport type DemandedRpcArgs<N extends DemandedRpcName> =\n DemandedRpcSignatures[N][\"Args\"];\n\n/** Returns type for one demanded RPC. */\nexport type DemandedRpcReturns<N extends DemandedRpcName> =\n DemandedRpcSignatures[N][\"Returns\"];\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2BO,IAAM,2BAA2B;AAAA,EACtC;AAAA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAKO,SAAS,wBACd,OACgC;AAChC,SACE,OAAO,UAAU,YAChB,yBAA+C,SAAS,KAAK;AAElE;;;ACNO,SAAS,UAAU,SAAyD;AACjF,QAAM,IAAI,QAAQ;AAClB,SAAO,KAAK,EAAE,WAAW,iBAAiB,OAAO,EAAE,aAAa,WAAW,EAAE,WAAW;AAC1F;;;AC4PO,IAAM,qBAAiD;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":[]}
@@ -1782,6 +1782,7 @@ var ASSOCIATION_PAIRS = /* @__PURE__ */ new Set([
1782
1782
  "record>hr_legal_hold",
1783
1783
  "record>hr_location",
1784
1784
  "record>hr_pay_group",
1785
+ "record>hr_pay_period",
1785
1786
  "record>hr_posting",
1786
1787
  "record>hr_record_class",
1787
1788
  "record>hr_requisition",
@@ -6234,7 +6235,11 @@ function CommentBody({ body, className }) {
6234
6235
  var import_format = require("@ai-matrx/kit/format");
6235
6236
  var import_jsx_runtime20 = require("react/jsx-runtime");
6236
6237
  var AUTHOR_DOOR_TOKEN = "user";
6238
+ var SYSTEM_AUTHOR_NAME = "AI Matrx";
6237
6239
  function resolveAuthor(comment, authorDisplay) {
6240
+ if (comment.authorSystem) {
6241
+ return { name: SYSTEM_AUTHOR_NAME, avatarUrl: null, userId: null, isAgent: false, isSystem: true };
6242
+ }
6238
6243
  if (comment.authorAgent) {
6239
6244
  return {
6240
6245
  name: comment.authorAgent.name ?? "Agent",
@@ -6384,7 +6389,7 @@ function CommentItem({
6384
6389
  const [deleting, setDeleting] = (0, import_react26.useState)(false);
6385
6390
  const author = resolveAuthor(comment, authorDisplay);
6386
6391
  const isOwn = thread.currentUserId !== null && comment.createdBy === thread.currentUserId;
6387
- const canEdit = isOwn && !author.isAgent;
6392
+ const canEdit = isOwn && !author.isAgent && !author.isSystem;
6388
6393
  const partLabel = partLabelOf(comment);
6389
6394
  const edited = comment.updatedAt !== comment.createdAt;
6390
6395
  const replies = childrenOf.get(comment.id) ?? [];