@mulmoclaude/collection-plugin 0.5.2 → 0.5.3
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/core/schema.d.ts +24 -2
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.js +2 -2
- package/dist/{schema-LrmrgW12.cjs → schema-5P5ZJPrY.cjs} +11 -1
- package/dist/schema-5P5ZJPrY.cjs.map +1 -0
- package/dist/{schema-DyfSfVzh.js → schema-BcnitlL8.js} +6 -2
- package/dist/schema-BcnitlL8.js.map +1 -0
- package/dist/server/discovery.d.ts +14 -2
- package/dist/server/discovery.d.ts.map +1 -1
- package/dist/server/spawn.d.ts +8 -1
- package/dist/server/spawn.d.ts.map +1 -1
- package/dist/server.cjs +85 -9
- package/dist/server.cjs.map +1 -1
- package/dist/server.js +85 -10
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/schema-DyfSfVzh.js.map +0 -1
- package/dist/schema-LrmrgW12.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mulmoclaude/collection-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Schema-driven Collections plugin (presentCollection) — shared gui-chat-protocol plugin for MulmoClaude and MulmoTerminal. This entry is the isomorphic collection engine (derive / formula / visibility); Vue surfaces land in ./vue.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-DyfSfVzh.js","names":[],"sources":["../src/core/schema.ts"],"sourcesContent":["// Schema-driven collection types. A \"collection\" is a skill (under\n// .claude/skills/<slug>/) that also ships a sibling `schema.json`.\n// The host's <CollectionView> reads the schema + records and renders\n// a table/form; Claude reads SKILL.md and CRUDs the records as JSON\n// files.\n//\n// Field types for v0 — keep this list narrow and grow it only when a\n// real collection needs the new type. v0 supports flat records only;\n// nested tables / cross-collection refs / derived fields / actions are\n// deferred to follow-ups (see plans/done/feat-skill-driven-apps.md and\n// plans/done/feat-skill-driven-apps-worklog.md — historical names predate\n// the rename).\n\n/** Minimal \"this collection is a feed\" descriptor carried on the schema.\n * Deliberately narrow — the canonical collection contract stays\n * independent of the host's feeds subsystem. The host's richer retrieval\n * spec (`IngestSpec` in `server/workspace/feeds/ingestTypes.ts`)\n * `extends CollectionIngest`, so feed code reads the extra fields by\n * typing feed schemas with that subtype; collection rendering only needs\n * these three + the presence check. */\nexport interface CollectionIngest {\n kind: string;\n url: string;\n schedule: string;\n}\n\n/** Retriever kinds a Feed's `ingest.kind` may declare. The host's feeds engine\n * dispatches on these; they live here (with the schema contract) so the schema\n * validator can enforce them. The host re-exports these from\n * `server/workspace/feeds/ingestTypes.ts`. */\nexport const INGEST_KINDS = [\"rss\", \"atom\", \"http-json\"] as const;\nexport type IngestKind = (typeof INGEST_KINDS)[number];\n\n/** Refresh cadences a Feed's `ingest.schedule` may declare. */\nexport const FEED_SCHEDULES = [\"hourly\", \"daily\", \"weekly\", \"on-demand\"] as const;\nexport type FeedSchedule = (typeof FEED_SCHEDULES)[number];\n\nexport type CollectionFieldType =\n | \"string\"\n | \"text\"\n | \"email\"\n | \"number\"\n | \"date\"\n | \"datetime\"\n | \"boolean\"\n | \"markdown\"\n | \"ref\"\n | \"money\"\n | \"enum\"\n | \"table\"\n | \"derived\"\n | \"embed\"\n // Holds a workspace-relative image path (e.g. a `data/attachments/...`\n // upload); rendered as an <img> in the detail view (not the list table —\n // a per-row fetch is too expensive at scale). Stored and edited as a\n // plain string.\n | \"image\"\n // Holds a workspace-relative file path as a plain string (e.g. an\n // `artifacts/html/<name>.html` app). Rendered as a clickable link in\n // both the list table and the detail view: HTML / SVG artifacts open\n // their rendered form in a new tab; any other path opens in the File\n // Explorer. Stored and edited as a plain string, like `image`.\n | \"file\"\n // A checkbox that is a pure PROJECTION of an `enum` field — it stores\n // nothing of its own. Checked when the enum equals `onValue`; toggling\n // writes `onValue` / `offValue` back to that enum field. Lets a \"done\"\n // checkbox front a kanban `status` field with the enum as the single\n // source of truth (no separate stored boolean to keep in sync).\n | \"toggle\";\n\n// \"feed\" collections live in the non-skill `<workspace>/feeds/` registry\n// and carry an `ingest` block; they reuse the same storage + rendering\n// as skill-backed collections but are never loaded into the agent prompt.\nexport type CollectionSource = \"user\" | \"project\" | \"feed\";\n\n/** Recurrence unit for a `spawn.every` advance. */\nexport type CollectionRecurUnit = \"day\" | \"week\" | \"month\" | \"year\";\n\n/** How a `spawn` advances the source item's `triggerField` date to\n * produce the successor's. All arithmetic is done on the civil\n * (year, month, day) triple — never by adding milliseconds — so month\n * lengths and leap years are handled correctly. */\nexport interface CollectionEvery {\n unit: CollectionRecurUnit;\n /** Number of `unit`s to advance (≥ 1). `interval: 3` + `unit: \"month\"`\n * = quarterly; `interval: 1` + `unit: \"year\"` = annual. */\n interval: number;\n /** Day-of-month anchor for `month`/`year` units. The CANONICAL day —\n * read from the rule, never re-derived from the prior concrete date,\n * so \"31st of every month\" yields 31 → 28/29 → 31 → 30 … with no\n * drift (it is clamped per-month at compute time, not stored\n * clamped). `\"last\"` always means the last day of the target month.\n * Omitted ⇒ preserve the source date's day (safe for days ≤ 28).\n * Ignored for `day`/`week` units. */\n dayOfMonth?: number | \"last\";\n}\n\n/** Host-driven recurrence: when a record satisfies `when`, the host\n * creates the next record with a forward-advanced `triggerField` date.\n * The successor's id and contents are a pure function of (source\n * record, this rule); creation is create-if-absent, so the mechanism\n * stays convergent — observing the predicate N times writes one\n * successor. Requires the schema to declare `triggerField`. */\nexport interface CollectionSpawn {\n /** Predicate that fires the spawn (a `CollectionWhen`). Defaults to\n * \"`completionField` value ∈ `completionDoneValues`\" (i.e. spawn the\n * next instance when this one is done). */\n when?: CollectionWhen;\n /** How to advance `triggerField` from the source to the successor. */\n every: CollectionEvery;\n /** Record fields copied verbatim onto the successor. Fields not listed\n * here, not in `set`, and not the trigger / primary keys start\n * blank. */\n carry?: string[];\n /** Fields forced to fixed values on the successor (typically resetting\n * the status field to its pending value). */\n set?: Record<string, unknown>;\n}\n\n/** The kind of work an action kicks off. v1 ships only `\"chat\"` —\n * start a new chat in a role with a templated seed prompt. The enum\n * reserves room for a future `\"mutate\"` (status transitions) without\n * another schema-shape change. */\nexport type CollectionActionKind = \"chat\";\n\n/** Optional visibility predicate: the target (an action button or a\n * field) renders only when the open record's `field` (stringified) is\n * one of `in`. Generic and domain-free — the host evaluates it against\n * the record with no knowledge of what the field means. Absent ⇒\n * always shown. */\nexport interface CollectionWhen {\n /** Top-level record field key whose value gates visibility. */\n field: string;\n /** Allowed values; the target shows when `String(record[field])` is\n * one of these. Non-empty. */\n in: string[];\n}\n\n/** @deprecated Name retained for back-compat; use {@link CollectionWhen}.\n * Both actions and fields share the same predicate shape. */\nexport type CollectionActionWhen = CollectionWhen;\n\n/** What a custom view's capability token is allowed to do against the\n * collection's data endpoint. `read` returns enriched records (getItems\n * semantics); `write` validates-and-stores rows (putItems semantics).\n * There is deliberately no `delete` — a view can never do more than the\n * agent's own `manageCollection` tool. */\nexport type CollectionViewCapability = \"read\" | \"write\";\n\n/** A custom (LLM-authored) HTML view for a collection. The host renders\n * `file` in a sandboxed iframe over the collection's records; the view\n * reaches its data only through a slug- and capability-scoped token (see\n * `server/api/auth/viewToken.ts`). Pure data — the host holds no\n * view-specific code; meaning lives in the HTML file + this registration. */\nexport interface CollectionCustomView {\n /** Stable id; the view-mode selector key (`custom:<id>`) and the\n * capability-token clamp key. Must be a valid slug. */\n id: string;\n /** Button label in the view-mode selector (author-authored, like field\n * labels — not run through i18n). */\n label: string;\n /** Optional Material-icon name for the selector button. */\n icon?: string;\n /** Skill-relative path to the HTML file under `views/` (e.g.\n * `views/year.html`). Path-safe, must end in `.html`. */\n file: string;\n /** What the view may do with the data endpoint. Defaults to `[\"read\"]`\n * (least privilege); declare `[\"read\",\"write\"]` only for views that\n * edit records. The mint endpoint clamps any requested caps to this. */\n capabilities?: CollectionViewCapability[];\n}\n\n/** A schema-declared, per-record action rendered as a button in the\n * read-only detail view. Pure UI/behaviour directive — never stored,\n * never validated against record data. All domain specifics (label,\n * role, template) live here in the schema / skill folder, so the host\n * stays generic. */\nexport interface CollectionAction {\n /** Stable id (used in the dispatch route + testids). */\n id: string;\n /** Button text (English, like field labels). */\n label: string;\n /** Material-icon name shown on the button. */\n icon?: string;\n /** What the action does. v1: `\"chat\"`. */\n kind: CollectionActionKind;\n /** `kind: \"chat\"`: the role id the new chat runs in. */\n role: string;\n /** `kind: \"chat\"`: skill-relative path to the template file whose\n * text becomes the seed prompt body (e.g. `templates/invoice.md`). */\n template: string;\n /** Optional visibility predicate; the button renders only when the\n * open record matches (see CollectionWhen). Absent ⇒ always\n * shown. */\n when?: CollectionWhen;\n}\n\nexport interface CollectionFieldSpec {\n type: CollectionFieldType;\n label: string;\n /** True for the field whose value is the record's filename (no\n * separate auto-id). Exactly one field per schema may set this. */\n primary?: boolean;\n required?: boolean;\n /** When `type === \"ref\"` or `type === \"embed\"`: the slug of the\n * target collection. For `ref` the record stores the target\n * item's primary-key slug and the host renders a clickable link\n * + dropdown picker. For `embed` the host pulls a *fixed* record\n * (see `id`) from the target and renders its fields read-only in\n * the detail view. Required for both; ignored on every other\n * type. */\n to?: string;\n /** When `type === \"embed\"`: the primary-key value of the fixed\n * record to pull from the `to` collection (e.g. `me` for the\n * singleton mc-profile). Nothing is stored on this record — the\n * embed is a display-only directive resolved at render time, so\n * it never appears in the list table or the edit form. Required\n * when type is `embed`; ignored on every other type. */\n id?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): a literal ISO 4217 currency code passed to\n * `Intl.NumberFormat` for display — fixed for every record. The\n * stored value is always a plain decimal number; currency is\n * presentation only. Mutually substitutable with `currencyField`:\n * a money field must declare at least one of the two. */\n currency?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): the name of a sibling record field whose\n * value holds the ISO 4217 code, letting currency vary per record\n * (e.g. an invoice's `currency` enum). The renderer reads\n * `record[currencyField]` and falls back to the literal `currency`\n * (then \"USD\") when the field is absent or empty. Resolved against\n * the top-level record even for money sub-fields inside a table. */\n currencyField?: string;\n /** When `type === \"enum\"`: the closed set of allowed string\n * values. The form renders a `<select>` populated from this\n * list; storage is a plain string. Required when type is\n * `enum`; ignored on every other type. */\n values?: readonly string[];\n /** When `type === \"table\"`: the sub-schema for each row (a flat\n * record of non-table / non-derived field specs). Required when\n * type is `table`. v0 disallows nested tables and derived\n * columns to keep the editor + evaluator simple. */\n of?: Record<string, CollectionFieldSpec>;\n /** When `type === \"derived\"`: a tiny expression evaluated against\n * the record. Supports `+ - * /`, parens, identifier refs to\n * top-level fields, `sum(tableField[].col)`, and\n * `sum(tableField[].col * tableField[].col)`. See\n * `src/utils/collections/derivedFormula.ts`. Required when type\n * is `derived`. */\n formula?: string;\n /** When `type === \"derived\"`: an inner field type the computed\n * value should be rendered as (e.g. `\"money\"` so $1,234.56 is\n * formatted). Defaults to `\"number\"`. */\n display?: CollectionFieldType;\n /** Optional visibility predicate: this field renders only when the\n * record matches (e.g. hide a `rating` field until `visited` is\n * `true` via `{ field: \"visited\", in: [\"true\"] }`). Applies to the\n * list cell (blank when hidden), the edit form (hidden live as the\n * gating field changes), and the detail view. Purely presentational\n * — a hidden field's stored value is never cleared. `when.field`\n * must name another top-level field. Absent ⇒ always shown. Only\n * honoured on top-level fields, not inside a `table`'s `of`. */\n when?: CollectionWhen;\n /** When `type === \"toggle\"`: the name of the top-level `enum` field this\n * checkbox projects. The toggle stores nothing itself — it reads and\n * writes this field. Required when type is `toggle`; ignored otherwise.\n * Must name a real `enum` field. */\n field?: string;\n /** When `type === \"toggle\"`: the enum value that means \"checked\". The\n * box is checked when the projected `field` equals this; checking writes\n * it. Required when type is `toggle`; must be one of the enum's `values`. */\n onValue?: string;\n /** When `type === \"toggle\"`: the enum value written when the box is\n * unchecked. Required when type is `toggle`; must be one of the enum's\n * `values`. */\n offValue?: string;\n}\n\nexport interface CollectionSchema {\n /** Human-facing collection name (sidebar, header). */\n title: string;\n /** Material-icon name shown next to the title. */\n icon: string;\n /** Workspace-relative folder holding one-JSON-per-record. Validated\n * to live under the workspace root at load time. */\n dataPath: string;\n /** Field name whose value doubles as the record's filename. */\n primaryKey: string;\n /** When set, the collection is a singleton: at most one record,\n * whose primary key is fixed to this value (e.g. `me` for the\n * business profile). The host pre-fills + locks the create form's\n * primary key and hides Add once the record exists. */\n singleton?: string;\n /** Ordered map: insertion order = column order in the table view. */\n fields: Record<string, CollectionFieldSpec>;\n /** Optional per-record actions rendered as buttons in the detail\n * view (e.g. \"Generate PDF\"). Order = button order. */\n actions?: CollectionAction[];\n /** Optional collection-level actions rendered as buttons in the\n * collection header (e.g. \"Extend the course\"). Unlike `actions`,\n * these carry no record context: the seed prompt injects a compact\n * progress summary of every record instead. The `when` predicate is\n * not evaluated (there is no record to gate on). Order = button order. */\n collectionActions?: CollectionAction[];\n /** Name of the field whose value marks an item as \"done\". When set,\n * a notification fires on item create (unless the item is born done)\n * and clears when the field's value transitions into\n * `completionDoneValues`. Must name a real field in `fields`. */\n completionField?: string;\n /** The set of values for `completionField` that count as \"done\"\n * (e.g. `[\"Done\"]` for a todo status field, `[\"paid\"]` for an\n * invoice). Non-empty. Compared as strings. */\n completionDoneValues?: readonly string[];\n /** Name of the field whose value is shown as the human-readable\n * label in a completion notification's title (e.g. a `name` field,\n * so the bell reads `Contacts: Jane Doe` instead of the opaque\n * primaryKey). Must name a real field in `fields`. When unset — or\n * when the record's value for it is empty — the title falls back to\n * the record's primaryKey value. Display-only; never stored. */\n displayField?: string;\n /** Name of a `date` field that gates this item's completion\n * notification: the bell is suppressed until the clock reaches that\n * date (compared at day-granularity in the server's local timezone),\n * instead of firing on create. Requires `completionField` /\n * `completionDoneValues` (the bell still clears via the done value).\n * Must name a real `date` field. Absent ⇒ fire on create, as before. */\n triggerField?: string;\n /** Lead time in whole days: fire the bell this many days BEFORE\n * `triggerField` (so `10` shows the reminder 10 days early). The lead\n * is applied at fire time, not stored, so it composes with `spawn` —\n * every recurred cycle fires the same number of days before its own\n * trigger. Non-negative integer; requires `triggerField`. Default 0\n * (fire on the trigger date). */\n triggerLeadDays?: number;\n /** Host-driven recurrence. When set, requires `triggerField`. See\n * {@link CollectionSpawn}. */\n spawn?: CollectionSpawn;\n /** Name of a `date` field that anchors the optional calendar view: a\n * month grid where each record lands on the day cell matching this\n * field's value. When unset, the calendar toggle still appears if the\n * schema has any `date` field (the first one, in declaration order, is\n * used by default and is switchable in-view). Set this to pin a specific\n * anchor. Must name a real `date` field. */\n calendarField?: string;\n /** Name of a second `date` field marking the END of a multi-day span on\n * the calendar: the record renders from `calendarField` through this\n * date inclusive. Requires `calendarField`. Must name a real `date`\n * field. Absent ⇒ single-day placement. */\n calendarEndField?: string;\n /** Name of a string field holding a free-form time or time-range\n * (e.g. \"14:00-17:00\", \"17:00-\", \"16:30\") that places records on the\n * calendar's day (time-allocation) view. Consulted only when the calendar\n * date fields are date-only. Requires `calendarField`. */\n calendarTimeField?: string;\n /** Name of an `enum` field that groups records into columns on the\n * optional Kanban board: each record lands in the column matching its\n * value, with empty/unknown values collected in an \"Uncategorized\"\n * column. When unset, the Kanban toggle still appears if the schema has\n * any `enum` field (the first one, in declaration order, is used by\n * default and is switchable in-view). Set this to pin a specific group\n * field. Must name a real `enum` field. */\n kanbanField?: string;\n /** Optional custom (LLM-authored) HTML views, each rendered in a\n * sandboxed iframe over the records. Absent ⇒ only the built-in\n * field-derived views (table / calendar / kanban / dashboard). See\n * {@link CollectionCustomView}. */\n views?: CollectionCustomView[];\n /** Optional predicate that gates the completion bell: when set, the bell\n * fires only for records whose `String(record[notifyWhen.field])` is one\n * of `notifyWhen.in` (e.g. notify only `high`/`urgent` priority todos).\n * Reuses the `when` predicate shape. Requires `completionField` — it\n * narrows that bell rather than introducing a second one. The bell still\n * clears on done / delete / when the predicate stops matching. Absent ⇒\n * notify for every open record (the prior behaviour). `notifyWhen.field`\n * must name a real top-level field. */\n notifyWhen?: CollectionWhen;\n /** Optional declarative retrieval config. When present, this collection\n * is a \"Feed\": the host periodically fetches `ingest.url`, maps the\n * response into records, and upserts them by `primaryKey`. Only feeds\n * discovered from the `<workspace>/feeds/` registry carry this; skill\n * collections omit it. The host's feeds subsystem narrows this to its\n * richer `IngestSpec` (which `extends CollectionIngest`). */\n ingest?: CollectionIngest;\n}\n\nexport interface CollectionSummary {\n slug: string;\n title: string;\n icon: string;\n source: CollectionSource;\n}\n\nexport interface CollectionDetail extends CollectionSummary {\n schema: CollectionSchema;\n}\n\nexport type CollectionItem = Record<string, unknown>;\n"],"mappings":";;;;;AA8BA,IAAa,eAAe;CAAC;CAAO;CAAQ;AAAW;;AAIvD,IAAa,iBAAiB;CAAC;CAAU;CAAS;CAAU;AAAW"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-LrmrgW12.cjs","names":[],"sources":["../src/core/schema.ts"],"sourcesContent":["// Schema-driven collection types. A \"collection\" is a skill (under\n// .claude/skills/<slug>/) that also ships a sibling `schema.json`.\n// The host's <CollectionView> reads the schema + records and renders\n// a table/form; Claude reads SKILL.md and CRUDs the records as JSON\n// files.\n//\n// Field types for v0 — keep this list narrow and grow it only when a\n// real collection needs the new type. v0 supports flat records only;\n// nested tables / cross-collection refs / derived fields / actions are\n// deferred to follow-ups (see plans/done/feat-skill-driven-apps.md and\n// plans/done/feat-skill-driven-apps-worklog.md — historical names predate\n// the rename).\n\n/** Minimal \"this collection is a feed\" descriptor carried on the schema.\n * Deliberately narrow — the canonical collection contract stays\n * independent of the host's feeds subsystem. The host's richer retrieval\n * spec (`IngestSpec` in `server/workspace/feeds/ingestTypes.ts`)\n * `extends CollectionIngest`, so feed code reads the extra fields by\n * typing feed schemas with that subtype; collection rendering only needs\n * these three + the presence check. */\nexport interface CollectionIngest {\n kind: string;\n url: string;\n schedule: string;\n}\n\n/** Retriever kinds a Feed's `ingest.kind` may declare. The host's feeds engine\n * dispatches on these; they live here (with the schema contract) so the schema\n * validator can enforce them. The host re-exports these from\n * `server/workspace/feeds/ingestTypes.ts`. */\nexport const INGEST_KINDS = [\"rss\", \"atom\", \"http-json\"] as const;\nexport type IngestKind = (typeof INGEST_KINDS)[number];\n\n/** Refresh cadences a Feed's `ingest.schedule` may declare. */\nexport const FEED_SCHEDULES = [\"hourly\", \"daily\", \"weekly\", \"on-demand\"] as const;\nexport type FeedSchedule = (typeof FEED_SCHEDULES)[number];\n\nexport type CollectionFieldType =\n | \"string\"\n | \"text\"\n | \"email\"\n | \"number\"\n | \"date\"\n | \"datetime\"\n | \"boolean\"\n | \"markdown\"\n | \"ref\"\n | \"money\"\n | \"enum\"\n | \"table\"\n | \"derived\"\n | \"embed\"\n // Holds a workspace-relative image path (e.g. a `data/attachments/...`\n // upload); rendered as an <img> in the detail view (not the list table —\n // a per-row fetch is too expensive at scale). Stored and edited as a\n // plain string.\n | \"image\"\n // Holds a workspace-relative file path as a plain string (e.g. an\n // `artifacts/html/<name>.html` app). Rendered as a clickable link in\n // both the list table and the detail view: HTML / SVG artifacts open\n // their rendered form in a new tab; any other path opens in the File\n // Explorer. Stored and edited as a plain string, like `image`.\n | \"file\"\n // A checkbox that is a pure PROJECTION of an `enum` field — it stores\n // nothing of its own. Checked when the enum equals `onValue`; toggling\n // writes `onValue` / `offValue` back to that enum field. Lets a \"done\"\n // checkbox front a kanban `status` field with the enum as the single\n // source of truth (no separate stored boolean to keep in sync).\n | \"toggle\";\n\n// \"feed\" collections live in the non-skill `<workspace>/feeds/` registry\n// and carry an `ingest` block; they reuse the same storage + rendering\n// as skill-backed collections but are never loaded into the agent prompt.\nexport type CollectionSource = \"user\" | \"project\" | \"feed\";\n\n/** Recurrence unit for a `spawn.every` advance. */\nexport type CollectionRecurUnit = \"day\" | \"week\" | \"month\" | \"year\";\n\n/** How a `spawn` advances the source item's `triggerField` date to\n * produce the successor's. All arithmetic is done on the civil\n * (year, month, day) triple — never by adding milliseconds — so month\n * lengths and leap years are handled correctly. */\nexport interface CollectionEvery {\n unit: CollectionRecurUnit;\n /** Number of `unit`s to advance (≥ 1). `interval: 3` + `unit: \"month\"`\n * = quarterly; `interval: 1` + `unit: \"year\"` = annual. */\n interval: number;\n /** Day-of-month anchor for `month`/`year` units. The CANONICAL day —\n * read from the rule, never re-derived from the prior concrete date,\n * so \"31st of every month\" yields 31 → 28/29 → 31 → 30 … with no\n * drift (it is clamped per-month at compute time, not stored\n * clamped). `\"last\"` always means the last day of the target month.\n * Omitted ⇒ preserve the source date's day (safe for days ≤ 28).\n * Ignored for `day`/`week` units. */\n dayOfMonth?: number | \"last\";\n}\n\n/** Host-driven recurrence: when a record satisfies `when`, the host\n * creates the next record with a forward-advanced `triggerField` date.\n * The successor's id and contents are a pure function of (source\n * record, this rule); creation is create-if-absent, so the mechanism\n * stays convergent — observing the predicate N times writes one\n * successor. Requires the schema to declare `triggerField`. */\nexport interface CollectionSpawn {\n /** Predicate that fires the spawn (a `CollectionWhen`). Defaults to\n * \"`completionField` value ∈ `completionDoneValues`\" (i.e. spawn the\n * next instance when this one is done). */\n when?: CollectionWhen;\n /** How to advance `triggerField` from the source to the successor. */\n every: CollectionEvery;\n /** Record fields copied verbatim onto the successor. Fields not listed\n * here, not in `set`, and not the trigger / primary keys start\n * blank. */\n carry?: string[];\n /** Fields forced to fixed values on the successor (typically resetting\n * the status field to its pending value). */\n set?: Record<string, unknown>;\n}\n\n/** The kind of work an action kicks off. v1 ships only `\"chat\"` —\n * start a new chat in a role with a templated seed prompt. The enum\n * reserves room for a future `\"mutate\"` (status transitions) without\n * another schema-shape change. */\nexport type CollectionActionKind = \"chat\";\n\n/** Optional visibility predicate: the target (an action button or a\n * field) renders only when the open record's `field` (stringified) is\n * one of `in`. Generic and domain-free — the host evaluates it against\n * the record with no knowledge of what the field means. Absent ⇒\n * always shown. */\nexport interface CollectionWhen {\n /** Top-level record field key whose value gates visibility. */\n field: string;\n /** Allowed values; the target shows when `String(record[field])` is\n * one of these. Non-empty. */\n in: string[];\n}\n\n/** @deprecated Name retained for back-compat; use {@link CollectionWhen}.\n * Both actions and fields share the same predicate shape. */\nexport type CollectionActionWhen = CollectionWhen;\n\n/** What a custom view's capability token is allowed to do against the\n * collection's data endpoint. `read` returns enriched records (getItems\n * semantics); `write` validates-and-stores rows (putItems semantics).\n * There is deliberately no `delete` — a view can never do more than the\n * agent's own `manageCollection` tool. */\nexport type CollectionViewCapability = \"read\" | \"write\";\n\n/** A custom (LLM-authored) HTML view for a collection. The host renders\n * `file` in a sandboxed iframe over the collection's records; the view\n * reaches its data only through a slug- and capability-scoped token (see\n * `server/api/auth/viewToken.ts`). Pure data — the host holds no\n * view-specific code; meaning lives in the HTML file + this registration. */\nexport interface CollectionCustomView {\n /** Stable id; the view-mode selector key (`custom:<id>`) and the\n * capability-token clamp key. Must be a valid slug. */\n id: string;\n /** Button label in the view-mode selector (author-authored, like field\n * labels — not run through i18n). */\n label: string;\n /** Optional Material-icon name for the selector button. */\n icon?: string;\n /** Skill-relative path to the HTML file under `views/` (e.g.\n * `views/year.html`). Path-safe, must end in `.html`. */\n file: string;\n /** What the view may do with the data endpoint. Defaults to `[\"read\"]`\n * (least privilege); declare `[\"read\",\"write\"]` only for views that\n * edit records. The mint endpoint clamps any requested caps to this. */\n capabilities?: CollectionViewCapability[];\n}\n\n/** A schema-declared, per-record action rendered as a button in the\n * read-only detail view. Pure UI/behaviour directive — never stored,\n * never validated against record data. All domain specifics (label,\n * role, template) live here in the schema / skill folder, so the host\n * stays generic. */\nexport interface CollectionAction {\n /** Stable id (used in the dispatch route + testids). */\n id: string;\n /** Button text (English, like field labels). */\n label: string;\n /** Material-icon name shown on the button. */\n icon?: string;\n /** What the action does. v1: `\"chat\"`. */\n kind: CollectionActionKind;\n /** `kind: \"chat\"`: the role id the new chat runs in. */\n role: string;\n /** `kind: \"chat\"`: skill-relative path to the template file whose\n * text becomes the seed prompt body (e.g. `templates/invoice.md`). */\n template: string;\n /** Optional visibility predicate; the button renders only when the\n * open record matches (see CollectionWhen). Absent ⇒ always\n * shown. */\n when?: CollectionWhen;\n}\n\nexport interface CollectionFieldSpec {\n type: CollectionFieldType;\n label: string;\n /** True for the field whose value is the record's filename (no\n * separate auto-id). Exactly one field per schema may set this. */\n primary?: boolean;\n required?: boolean;\n /** When `type === \"ref\"` or `type === \"embed\"`: the slug of the\n * target collection. For `ref` the record stores the target\n * item's primary-key slug and the host renders a clickable link\n * + dropdown picker. For `embed` the host pulls a *fixed* record\n * (see `id`) from the target and renders its fields read-only in\n * the detail view. Required for both; ignored on every other\n * type. */\n to?: string;\n /** When `type === \"embed\"`: the primary-key value of the fixed\n * record to pull from the `to` collection (e.g. `me` for the\n * singleton mc-profile). Nothing is stored on this record — the\n * embed is a display-only directive resolved at render time, so\n * it never appears in the list table or the edit form. Required\n * when type is `embed`; ignored on every other type. */\n id?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): a literal ISO 4217 currency code passed to\n * `Intl.NumberFormat` for display — fixed for every record. The\n * stored value is always a plain decimal number; currency is\n * presentation only. Mutually substitutable with `currencyField`:\n * a money field must declare at least one of the two. */\n currency?: string;\n /** When `type === \"money\"` (or `type === \"derived\"` with\n * `display: \"money\"`): the name of a sibling record field whose\n * value holds the ISO 4217 code, letting currency vary per record\n * (e.g. an invoice's `currency` enum). The renderer reads\n * `record[currencyField]` and falls back to the literal `currency`\n * (then \"USD\") when the field is absent or empty. Resolved against\n * the top-level record even for money sub-fields inside a table. */\n currencyField?: string;\n /** When `type === \"enum\"`: the closed set of allowed string\n * values. The form renders a `<select>` populated from this\n * list; storage is a plain string. Required when type is\n * `enum`; ignored on every other type. */\n values?: readonly string[];\n /** When `type === \"table\"`: the sub-schema for each row (a flat\n * record of non-table / non-derived field specs). Required when\n * type is `table`. v0 disallows nested tables and derived\n * columns to keep the editor + evaluator simple. */\n of?: Record<string, CollectionFieldSpec>;\n /** When `type === \"derived\"`: a tiny expression evaluated against\n * the record. Supports `+ - * /`, parens, identifier refs to\n * top-level fields, `sum(tableField[].col)`, and\n * `sum(tableField[].col * tableField[].col)`. See\n * `src/utils/collections/derivedFormula.ts`. Required when type\n * is `derived`. */\n formula?: string;\n /** When `type === \"derived\"`: an inner field type the computed\n * value should be rendered as (e.g. `\"money\"` so $1,234.56 is\n * formatted). Defaults to `\"number\"`. */\n display?: CollectionFieldType;\n /** Optional visibility predicate: this field renders only when the\n * record matches (e.g. hide a `rating` field until `visited` is\n * `true` via `{ field: \"visited\", in: [\"true\"] }`). Applies to the\n * list cell (blank when hidden), the edit form (hidden live as the\n * gating field changes), and the detail view. Purely presentational\n * — a hidden field's stored value is never cleared. `when.field`\n * must name another top-level field. Absent ⇒ always shown. Only\n * honoured on top-level fields, not inside a `table`'s `of`. */\n when?: CollectionWhen;\n /** When `type === \"toggle\"`: the name of the top-level `enum` field this\n * checkbox projects. The toggle stores nothing itself — it reads and\n * writes this field. Required when type is `toggle`; ignored otherwise.\n * Must name a real `enum` field. */\n field?: string;\n /** When `type === \"toggle\"`: the enum value that means \"checked\". The\n * box is checked when the projected `field` equals this; checking writes\n * it. Required when type is `toggle`; must be one of the enum's `values`. */\n onValue?: string;\n /** When `type === \"toggle\"`: the enum value written when the box is\n * unchecked. Required when type is `toggle`; must be one of the enum's\n * `values`. */\n offValue?: string;\n}\n\nexport interface CollectionSchema {\n /** Human-facing collection name (sidebar, header). */\n title: string;\n /** Material-icon name shown next to the title. */\n icon: string;\n /** Workspace-relative folder holding one-JSON-per-record. Validated\n * to live under the workspace root at load time. */\n dataPath: string;\n /** Field name whose value doubles as the record's filename. */\n primaryKey: string;\n /** When set, the collection is a singleton: at most one record,\n * whose primary key is fixed to this value (e.g. `me` for the\n * business profile). The host pre-fills + locks the create form's\n * primary key and hides Add once the record exists. */\n singleton?: string;\n /** Ordered map: insertion order = column order in the table view. */\n fields: Record<string, CollectionFieldSpec>;\n /** Optional per-record actions rendered as buttons in the detail\n * view (e.g. \"Generate PDF\"). Order = button order. */\n actions?: CollectionAction[];\n /** Optional collection-level actions rendered as buttons in the\n * collection header (e.g. \"Extend the course\"). Unlike `actions`,\n * these carry no record context: the seed prompt injects a compact\n * progress summary of every record instead. The `when` predicate is\n * not evaluated (there is no record to gate on). Order = button order. */\n collectionActions?: CollectionAction[];\n /** Name of the field whose value marks an item as \"done\". When set,\n * a notification fires on item create (unless the item is born done)\n * and clears when the field's value transitions into\n * `completionDoneValues`. Must name a real field in `fields`. */\n completionField?: string;\n /** The set of values for `completionField` that count as \"done\"\n * (e.g. `[\"Done\"]` for a todo status field, `[\"paid\"]` for an\n * invoice). Non-empty. Compared as strings. */\n completionDoneValues?: readonly string[];\n /** Name of the field whose value is shown as the human-readable\n * label in a completion notification's title (e.g. a `name` field,\n * so the bell reads `Contacts: Jane Doe` instead of the opaque\n * primaryKey). Must name a real field in `fields`. When unset — or\n * when the record's value for it is empty — the title falls back to\n * the record's primaryKey value. Display-only; never stored. */\n displayField?: string;\n /** Name of a `date` field that gates this item's completion\n * notification: the bell is suppressed until the clock reaches that\n * date (compared at day-granularity in the server's local timezone),\n * instead of firing on create. Requires `completionField` /\n * `completionDoneValues` (the bell still clears via the done value).\n * Must name a real `date` field. Absent ⇒ fire on create, as before. */\n triggerField?: string;\n /** Lead time in whole days: fire the bell this many days BEFORE\n * `triggerField` (so `10` shows the reminder 10 days early). The lead\n * is applied at fire time, not stored, so it composes with `spawn` —\n * every recurred cycle fires the same number of days before its own\n * trigger. Non-negative integer; requires `triggerField`. Default 0\n * (fire on the trigger date). */\n triggerLeadDays?: number;\n /** Host-driven recurrence. When set, requires `triggerField`. See\n * {@link CollectionSpawn}. */\n spawn?: CollectionSpawn;\n /** Name of a `date` field that anchors the optional calendar view: a\n * month grid where each record lands on the day cell matching this\n * field's value. When unset, the calendar toggle still appears if the\n * schema has any `date` field (the first one, in declaration order, is\n * used by default and is switchable in-view). Set this to pin a specific\n * anchor. Must name a real `date` field. */\n calendarField?: string;\n /** Name of a second `date` field marking the END of a multi-day span on\n * the calendar: the record renders from `calendarField` through this\n * date inclusive. Requires `calendarField`. Must name a real `date`\n * field. Absent ⇒ single-day placement. */\n calendarEndField?: string;\n /** Name of a string field holding a free-form time or time-range\n * (e.g. \"14:00-17:00\", \"17:00-\", \"16:30\") that places records on the\n * calendar's day (time-allocation) view. Consulted only when the calendar\n * date fields are date-only. Requires `calendarField`. */\n calendarTimeField?: string;\n /** Name of an `enum` field that groups records into columns on the\n * optional Kanban board: each record lands in the column matching its\n * value, with empty/unknown values collected in an \"Uncategorized\"\n * column. When unset, the Kanban toggle still appears if the schema has\n * any `enum` field (the first one, in declaration order, is used by\n * default and is switchable in-view). Set this to pin a specific group\n * field. Must name a real `enum` field. */\n kanbanField?: string;\n /** Optional custom (LLM-authored) HTML views, each rendered in a\n * sandboxed iframe over the records. Absent ⇒ only the built-in\n * field-derived views (table / calendar / kanban / dashboard). See\n * {@link CollectionCustomView}. */\n views?: CollectionCustomView[];\n /** Optional predicate that gates the completion bell: when set, the bell\n * fires only for records whose `String(record[notifyWhen.field])` is one\n * of `notifyWhen.in` (e.g. notify only `high`/`urgent` priority todos).\n * Reuses the `when` predicate shape. Requires `completionField` — it\n * narrows that bell rather than introducing a second one. The bell still\n * clears on done / delete / when the predicate stops matching. Absent ⇒\n * notify for every open record (the prior behaviour). `notifyWhen.field`\n * must name a real top-level field. */\n notifyWhen?: CollectionWhen;\n /** Optional declarative retrieval config. When present, this collection\n * is a \"Feed\": the host periodically fetches `ingest.url`, maps the\n * response into records, and upserts them by `primaryKey`. Only feeds\n * discovered from the `<workspace>/feeds/` registry carry this; skill\n * collections omit it. The host's feeds subsystem narrows this to its\n * richer `IngestSpec` (which `extends CollectionIngest`). */\n ingest?: CollectionIngest;\n}\n\nexport interface CollectionSummary {\n slug: string;\n title: string;\n icon: string;\n source: CollectionSource;\n}\n\nexport interface CollectionDetail extends CollectionSummary {\n schema: CollectionSchema;\n}\n\nexport type CollectionItem = Record<string, unknown>;\n"],"mappings":";;;;;AA8BA,IAAa,eAAe;CAAC;CAAO;CAAQ;AAAW;;AAIvD,IAAa,iBAAiB;CAAC;CAAU;CAAS;CAAU;AAAW"}
|