{"version":3,"sources":["/Users/shyun/comcom/ain-enterprise/ain-adk/dist/cjs/chunk-BSMUW4LI.cjs","../../src/types/document.ts"],"names":["DocumentFormat","DocumentSource"],"mappings":"AAAA;ACOO,IAAK,eAAA,kBAAL,CAAA,CAAKA,eAAAA,EAAAA,GAAL;AACN,EAAAA,eAAAA,CAAA,UAAA,EAAA,EAAW,UAAA;AADA,EAAA,OAAAA,eAAAA;AAAA,CAAA,CAAA,CAAA,eAAA,GAAA,CAAA,CAAA,CAAA;AAUL,IAAK,eAAA,kBAAL,CAAA,CAAKC,eAAAA,EAAAA,GAAL;AACN,EAAAA,eAAAA,CAAA,UAAA,EAAA,EAAW,UAAA;AACX,EAAAA,eAAAA,CAAA,OAAA,EAAA,EAAQ,OAAA;AACR,EAAAA,eAAAA,CAAA,QAAA,EAAA,EAAS,QAAA;AAHE,EAAA,OAAAA,eAAAA;AAAA,CAAA,CAAA,CAAA,eAAA,GAAA,CAAA,CAAA,CAAA;ADNZ;AACA;AACE;AACA;AACF,iFAAC","file":"/Users/shyun/comcom/ain-enterprise/ain-adk/dist/cjs/chunk-BSMUW4LI.cjs","sourcesContent":[null,"import type { ListOptions } from \"./list.js\";\nimport type { WorkflowRenderedBlock } from \"./memory.js\";\n\n/**\n * Storage/render format of a document body.\n * Currently only markdown is supported.\n */\nexport enum DocumentFormat {\n\tMARKDOWN = \"MARKDOWN\",\n}\n\n/**\n * Origin of a document.\n * - WORKFLOW: produced by a user workflow execution\n * - QUERY: produced by a standard query response\n * - MANUAL: created directly by a human\n */\nexport enum DocumentSource {\n\tWORKFLOW = \"WORKFLOW\",\n\tQUERY = \"QUERY\",\n\tMANUAL = \"MANUAL\",\n}\n\n/**\n * A resolved result fragment produced by a workflow/query execution.\n *\n * This is the same shape a workflow already produces (markdown + structured\n * render blocks); it fills a single {@link DocumentSlot}.\n */\nexport interface DocumentFragment {\n\t/** Rendered markdown for this fragment. */\n\tcontent: string;\n\t/** Structured render artifacts (tables/graphs) for rich rendering. */\n\tblocks?: WorkflowRenderedBlock[];\n\t/** What produced this fragment. */\n\tsource:\n\t\t| { type: \"WORKFLOW\"; workflowId: string }\n\t\t| { type: \"QUERY\"; query: string };\n\t/** ISO timestamp when the fragment was resolved. */\n\tresolvedAt: string;\n}\n\nexport type DocumentSlotStatus = \"empty\" | \"running\" | \"resolved\" | \"failed\";\n\n/**\n * A placeholder within a document body, addressed by a `{{slot:slotId}}` token\n * in {@link Document.content}. Filled on demand by a bound workflow/query.\n */\nexport interface DocumentSlot {\n\t/** Matches the `{{slot:slotId}}` token in the document content. */\n\tslotId: string;\n\t/** Human-readable label for the slot. */\n\tlabel?: string;\n\t/** Fill lifecycle status. */\n\tstatus: DocumentSlotStatus;\n\t/**\n\t * Pre-declared source that fills this slot. A fill request may override\n\t * the workflow/variables explicitly.\n\t */\n\tbinding?:\n\t\t| {\n\t\t\t\ttype: \"WORKFLOW\";\n\t\t\t\tworkflowId: string;\n\t\t\t\texecutionVariables?: Record<string, string>;\n\t\t  }\n\t\t| { type: \"QUERY\"; query: string };\n\t/** Resolved result once filled. */\n\tfragment?: DocumentFragment;\n\t/** Error message when `status === \"failed\"`. */\n\terror?: string;\n}\n\n/**\n * One-shot automatic slot refresh for a document.\n * e.g. a logbook is refreshed once, the morning after its date.\n */\nexport interface DocumentAutoRefresh {\n\t/** Scheduled execution time (epoch ms). */\n\trunAt: number;\n\t/** When false the refresh is cancelled (opt-out). */\n\tactive: boolean;\n\t/** Target slots. Defaults to every slot with a binding. */\n\tslotIds?: string[];\n\t/** Slots already refreshed successfully (accumulated atomically). */\n\tdoneSlotIds?: string[];\n\t/** Set when every target slot is done; a completed job never re-runs. */\n\tcompletedAt?: number;\n}\n\n/**\n * A first-class, mutable document.\n *\n * Documents hold the canonical result of a workflow/query as markdown and are\n * referenced from threads (rather than embedded), so manual edits are always\n * reflected wherever the document is rendered.\n *\n * - `content` is the canonical markdown (the edit target). It may contain\n *   `{{slot:slotId}}` tokens that are substituted with the resolved fragment\n *   of the matching {@link DocumentSlot}.\n * - `blocks` are the structured render artifacts captured at creation time and\n *   are read-only metadata. After a manual edit (`editedManually = true`) they\n *   may no longer be in sync with `content`.\n */\n/** AI-generated advice derived from a document's rendered content. */\nexport interface DocumentAdvice {\n\t/** Generated advice text (plain prose / light markdown). */\n\tcontent: string;\n\t/** ISO timestamp when generated. */\n\tgeneratedAt: string;\n}\n\nexport interface Document {\n\tdocumentId: string;\n\tuserId: string;\n\ttitle: string;\n\t/** Body format. Defaults to MARKDOWN. */\n\tformat: DocumentFormat;\n\t/** Canonical markdown body — the display and edit target. */\n\tcontent: string;\n\t/** Structured render artifacts captured at creation (read-only metadata). */\n\tblocks?: WorkflowRenderedBlock[];\n\t/** Cached AI advice generated from the rendered content. */\n\tadvice?: DocumentAdvice;\n\t/** Placeholder slots referenced by `{{slot:slotId}}` tokens in `content`. */\n\tslots?: DocumentSlot[];\n\t/** One-shot automatic slot refresh (null = explicitly cleared). */\n\tautoRefresh?: DocumentAutoRefresh | null;\n\t/**\n\t * Faceted grouping dimensions, e.g.\n\t * `{ category: \"logbook\", workplaceId: \"123\", month: \"2026-06\" }`.\n\t *\n\t * The hierarchy/nesting order is NOT encoded here — it is decided at query\n\t * or render time by choosing an order of label keys. This keeps grouping\n\t * extensible to any number of levels without schema changes.\n\t */\n\tlabels?: Record<string, string>;\n\t/** Where this document came from. */\n\tsource: DocumentSource;\n\t/** Source workflow when `source === WORKFLOW`. */\n\tworkflowId?: string;\n\t/** Thread this document was created in (back-reference). */\n\tthreadId?: string;\n\t/** Incremented on every update. Starts at 1. */\n\tversion: number;\n\t/** True once a human has edited `content`; `blocks` may then be stale. */\n\teditedManually?: boolean;\n\t/**\n\t * Soft delete: hidden documents are excluded from every read path\n\t * (get/list/count/auto-refresh) — effectively deleted for users.\n\t * Physical deletion and restore are admin-tool operations, done directly\n\t * against storage, not through this API.\n\t */\n\thidden?: boolean;\n\t/** ISO timestamp of creation. */\n\tcreatedAt: string;\n\t/** ISO timestamp of the last update. */\n\tupdatedAt: string;\n}\n\n/**\n * Optional filters for listing documents.\n *\n * `labels` is a subset match: every provided key must match the document's\n * corresponding label. A string value matches exactly; a string[] value\n * matches if the document's label is any of the array (`$in`).\n */\nexport type DocumentFilter = {\n\tworkflowId?: string;\n\tthreadId?: string;\n\tsource?: DocumentSource;\n\tlabels?: Record<string, string | string[]>;\n\t/**\n\t * Inclusive range over `labels.date` (YYYY-MM-DD strings — lexicographic\n\t * order equals chronological order, so bounds like `2026-02-31` are safe).\n\t */\n\tdateFrom?: string;\n\tdateTo?: string;\n};\n\n/** One (userId, filter) scope; a list query is the union (OR) of its sets. */\nexport type DocumentFilterSet = {\n\tuserId?: string;\n\tfilter?: DocumentFilter;\n};\n\nexport type DocumentListOptions = ListOptions & {\n\t/** Omit heavy fields (`slots`) from returned documents. */\n\tsummary?: boolean;\n};\n\n/** List-view shape returned by `view=summary` — `slots` omitted. */\nexport type DocumentSummary = Omit<Document, \"slots\">;\n"]}