@mulmoclaude/core 0.2.7 → 0.2.9

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.
Files changed (106) hide show
  1. package/assets/skills-preset/mc-manage-automations/SKILL.md +1 -1
  2. package/dist/feeds/server/index.d.ts +1 -0
  3. package/dist/feeds/server/index.js +37 -4
  4. package/dist/feeds/server/index.js.map +1 -1
  5. package/dist/feeds/server/scheduledRefresh.d.ts +21 -0
  6. package/package.json +1 -1
  7. package/dist/collection/core/actionVisible.d.ts +0 -34
  8. package/dist/collection/core/calendarGrid.d.ts +0 -120
  9. package/dist/collection/core/deriveAll.d.ts +0 -38
  10. package/dist/collection/core/derivedFormula.d.ts +0 -18
  11. package/dist/collection/core/draft.d.ts +0 -18
  12. package/dist/collection/core/enumColors.d.ts +0 -33
  13. package/dist/collection/core/errorMessage.d.ts +0 -4
  14. package/dist/collection/core/itemLabel.d.ts +0 -12
  15. package/dist/collection/core/presentCollection.d.ts +0 -13
  16. package/dist/collection/core/promptSafety.d.ts +0 -1
  17. package/dist/collection/core/schema.d.ts +0 -382
  18. package/dist/collection/core/shortHexId.d.ts +0 -8
  19. package/dist/collection/core/sortItems.d.ts +0 -29
  20. package/dist/collection/core/uiTypes.d.ts +0 -106
  21. package/dist/collection/index.cjs +0 -794
  22. package/dist/collection/index.cjs.map +0 -1
  23. package/dist/collection/index.d.ts +0 -14
  24. package/dist/collection/paths.cjs +0 -44
  25. package/dist/collection/paths.cjs.map +0 -1
  26. package/dist/collection/server/atomic.d.ts +0 -1
  27. package/dist/collection/server/delete.d.ts +0 -38
  28. package/dist/collection/server/derive.d.ts +0 -8
  29. package/dist/collection/server/discoveredCollection.d.ts +0 -18
  30. package/dist/collection/server/discovery.d.ts +0 -239
  31. package/dist/collection/server/host.d.ts +0 -77
  32. package/dist/collection/server/index.cjs +0 -51
  33. package/dist/collection/server/io.d.ts +0 -120
  34. package/dist/collection/server/paths.d.ts +0 -52
  35. package/dist/collection/server/spawn.d.ts +0 -55
  36. package/dist/collection/server/util.d.ts +0 -3
  37. package/dist/collection/server/validate.d.ts +0 -19
  38. package/dist/collection/server/views.d.ts +0 -20
  39. package/dist/collection-watchers/config.d.ts +0 -49
  40. package/dist/collection-watchers/index.cjs +0 -553
  41. package/dist/collection-watchers/index.cjs.map +0 -1
  42. package/dist/collection-watchers/index.d.ts +0 -3
  43. package/dist/collection-watchers/reconciler.d.ts +0 -33
  44. package/dist/collection-watchers/watcher.d.ts +0 -34
  45. package/dist/deriveAll-VRWrs3SF.cjs +0 -413
  46. package/dist/deriveAll-VRWrs3SF.cjs.map +0 -1
  47. package/dist/feeds/index.cjs +0 -8
  48. package/dist/feeds/index.d.ts +0 -1
  49. package/dist/feeds/ingestTypes.d.ts +0 -57
  50. package/dist/feeds/paths.cjs +0 -48
  51. package/dist/feeds/paths.cjs.map +0 -1
  52. package/dist/feeds/paths.d.ts +0 -22
  53. package/dist/feeds/server/fetch/httpClient.d.ts +0 -8
  54. package/dist/feeds/server/fetch/rssParser.d.ts +0 -12
  55. package/dist/feeds/server/index.cjs +0 -804
  56. package/dist/feeds/server/index.cjs.map +0 -1
  57. package/dist/feeds/server/pathResolver.d.ts +0 -6
  58. package/dist/feeds/server/projectItem.d.ts +0 -8
  59. package/dist/feeds/server/refreshResult.d.ts +0 -17
  60. package/dist/feeds/server/retrievers/httpJson.d.ts +0 -3
  61. package/dist/feeds/server/retrievers/index.d.ts +0 -12
  62. package/dist/feeds/server/retrievers/registerAll.d.ts +0 -0
  63. package/dist/feeds/server/retrievers/rss.d.ts +0 -3
  64. package/dist/file-change/index.cjs +0 -72
  65. package/dist/file-change/index.cjs.map +0 -1
  66. package/dist/file-change/index.d.ts +0 -43
  67. package/dist/ingestTypes-DDOVhOYC.cjs +0 -32
  68. package/dist/ingestTypes-DDOVhOYC.cjs.map +0 -1
  69. package/dist/notifier/engine.d.ts +0 -72
  70. package/dist/notifier/index.cjs +0 -21
  71. package/dist/notifier/index.d.ts +0 -3
  72. package/dist/notifier/store.d.ts +0 -18
  73. package/dist/notifier/types.d.ts +0 -118
  74. package/dist/notifier/validate.d.ts +0 -17
  75. package/dist/notifier-bS8IEeLA.cjs +0 -577
  76. package/dist/notifier-bS8IEeLA.cjs.map +0 -1
  77. package/dist/rolldown-runtime-D6vf50IK.cjs +0 -28
  78. package/dist/scheduler/adapter.d.ts +0 -48
  79. package/dist/scheduler/index.cjs +0 -352
  80. package/dist/scheduler/index.cjs.map +0 -1
  81. package/dist/scheduler/index.d.ts +0 -2
  82. package/dist/scheduler/task-manager.d.ts +0 -51
  83. package/dist/server-Db-x7OXz.cjs +0 -1993
  84. package/dist/server-Db-x7OXz.cjs.map +0 -1
  85. package/dist/skill-bridge/index.cjs +0 -88
  86. package/dist/skill-bridge/index.cjs.map +0 -1
  87. package/dist/skill-bridge/index.d.ts +0 -30
  88. package/dist/whisper/client.cjs +0 -241
  89. package/dist/whisper/client.cjs.map +0 -1
  90. package/dist/whisper/client.d.ts +0 -35
  91. package/dist/whisper/ffmpeg.d.ts +0 -6
  92. package/dist/whisper/index.cjs +0 -433
  93. package/dist/whisper/index.cjs.map +0 -1
  94. package/dist/whisper/index.d.ts +0 -5
  95. package/dist/whisper/internal.d.ts +0 -11
  96. package/dist/whisper/models.d.ts +0 -49
  97. package/dist/whisper/sidecar.d.ts +0 -8
  98. package/dist/whisper/whisper.d.ts +0 -28
  99. package/dist/workspace-setup/assets.d.ts +0 -10
  100. package/dist/workspace-setup/index.d.ts +0 -3
  101. package/dist/workspace-setup/index.js +0 -560
  102. package/dist/workspace-setup/index.js.map +0 -1
  103. package/dist/workspace-setup/slug.d.ts +0 -6
  104. package/dist/workspace-setup/slug.js +0 -13
  105. package/dist/workspace-setup/slug.js.map +0 -1
  106. package/dist/workspace-setup/sync.d.ts +0 -94
@@ -1,38 +0,0 @@
1
- import { FormulaContext } from './derivedFormula';
2
- /** Minimal field shape the derive loop needs — accepts both the client
3
- * FieldSpec and the server CollectionFieldSpec. */
4
- export interface DerivableFieldSpec {
5
- type: string;
6
- /** When type === "ref": slug of the target collection. */
7
- to?: string;
8
- /** When type === "derived": formula evaluated against the record. */
9
- formula?: string;
10
- }
11
- /** Minimal schema shape: just the ordered field map. */
12
- export interface DerivableSchema {
13
- fields: Record<string, DerivableFieldSpec>;
14
- }
15
- export type DerivableRecord = Record<string, unknown>;
16
- /** Per-target-collection cache of loaded referenced records:
17
- * target collection slug → item slug → full record. Mirrors the
18
- * client's `RefRecordCache` / the server's enrichment loader. */
19
- export type DeriveRefRecords = Record<string, Record<string, DerivableRecord>>;
20
- /** Map each `ref` field's stored slug to its loaded target record (or
21
- * null when dangling / not loaded), keyed by the LOCAL field name —
22
- * the shape `evaluateDerived` reads for `<field>.<col>` derefs. */
23
- export declare function resolveRowRefs(schema: DerivableSchema, record: DerivableRecord, refRecords: DeriveRefRecords): NonNullable<FormulaContext["refs"]>;
24
- /** Evaluate every `derived` field against `base`, saturating so a
25
- * derived field can read another derived field computed in an earlier
26
- * pass (`subtotal → tax → total` converges in ≤ field-count passes).
27
- * Cycles can't loop forever — passes are bounded by the number of
28
- * derived fields and the loop breaks as soon as a pass changes
29
- * nothing. Failed formulas stay ABSENT (the UI renders them as
30
- * em-dash). Returns a copy; `base` is never mutated.
31
- *
32
- * Derived keys already present in `base` are stripped before
33
- * evaluation: computed output is host-truth, never persisted-input
34
- * fallback. A record JSON can carry a stale (or forged) derived value
35
- * — raw Write/Edit, legacy data — and without the strip, a failing
36
- * formula would silently surface that value as if the host computed
37
- * it. */
38
- export declare function deriveAll(schema: DerivableSchema, base: DerivableRecord, refRecords: DeriveRefRecords): DerivableRecord;
@@ -1,18 +0,0 @@
1
- export interface FormulaContext {
2
- /** The record being evaluated. For derived fields in the form,
3
- * this is the live draft (text + table both converted via the
4
- * same `draftToRecord` pipeline). For the main table cell,
5
- * this is the persisted item. */
6
- record: Record<string, unknown>;
7
- /** Resolved ref-target records for THIS row, keyed by the local
8
- * `ref` field name. The caller (which has the schema + the linked
9
- * collection's items loaded) maps each ref field's stored slug to
10
- * the full target record and passes it here, so a `<field>.<col>`
11
- * formula can read a numeric column off the referenced record
12
- * (e.g. `shares * ticker.price`). A missing key or `null` value
13
- * (unknown field / dangling slug) makes that deref evaluate to
14
- * NaN → the whole formula returns `null` → em-dash, consistent
15
- * with every other failure mode. Absent ⇒ no refs available. */
16
- refs?: Record<string, Record<string, unknown> | null>;
17
- }
18
- export declare function evaluateDerived(formula: string, ctx: FormulaContext): number | null;
@@ -1,18 +0,0 @@
1
- import { CollectionFieldSpec as FieldSpec, CollectionItem, CollectionSchema } from './schema';
2
- import { EditState, TableRowDraft } from './uiTypes';
3
- /** A fresh, empty row draft for a `table` field's sub-schema. */
4
- export declare function emptyRow(subFields: Record<string, FieldSpec>): TableRowDraft;
5
- /** Build a row draft from an existing persisted row. */
6
- export declare function rowFromItem(item: Record<string, unknown>, subFields: Record<string, FieldSpec>): TableRowDraft;
7
- /** Convert a full edit draft to the record to persist. */
8
- export declare function draftToRecord(state: EditState, schema: CollectionSchema): CollectionItem;
9
- /** Normalise a raw inline-edit input (table-cell checkbox/select) to its
10
- * persisted form. Mirrors `draftToRecord`'s boolean strictness; an empty
11
- * enum selection (the placeholder option) clears the field via `undefined`. */
12
- export declare function coerceInlineValue(field: FieldSpec, raw: boolean | string): unknown;
13
- /** Build the full record to PUT for a single-cell inline edit, without
14
- * mutating `item`. A `undefined` value omits the key (enum cleared),
15
- * matching `draftToRecord`'s omission semantics. */
16
- export declare function buildUpdatedRecord(item: CollectionItem, key: string, value: unknown): CollectionItem;
17
- /** Human-readable label of the first missing required field, or null. */
18
- export declare function firstMissingRequiredField(draft: EditState, schema: CollectionSchema): string | null;
@@ -1,33 +0,0 @@
1
- import { CollectionSchema } from './schema';
2
- export interface EnumColorClasses {
3
- /** Stat-card style: border + fill + text + hover. */
4
- card: string;
5
- /** Small status dot (kanban column header). */
6
- dot: string;
7
- /** Pill / badge / inline `<select>` fill + text (no border width). */
8
- badge: string;
9
- /** Border colour, paired with a `border` width class by the caller. */
10
- border: string;
11
- }
12
- /** Neutral styling for the empty / Uncategorized bucket — never a palette
13
- * colour, so an unset or unknown value reads grey across every surface. */
14
- export declare const ENUM_NEUTRAL: EnumColorClasses;
15
- /** The urgent notification colour (red), matching the bell's `urgent`
16
- * severity. The first value a schema's `notifyWhen` flags reads this. */
17
- export declare const ENUM_ALERT: EnumColorClasses;
18
- /** The nudge notification colour (amber), matching the bell's `nudge`
19
- * severity. Flagged `notifyWhen` values after the first read this. */
20
- export declare const ENUM_NUDGE: EnumColorClasses;
21
- /** Classes for the enum value at `index` in its field's `values` array. A
22
- * negative index (value unset or not among the declared values) reads
23
- * neutral. */
24
- export declare function enumColorClasses(index: number): EnumColorClasses;
25
- /** Index of `value` within an enum field's declared `values`, or -1 when the
26
- * value is empty / unknown (→ neutral). */
27
- export declare function enumValueIndex(values: readonly string[] | undefined, value: unknown): number;
28
- /** Resolve a value's colour for enum field `fieldKey`:
29
- * - Notification enum (`notifyWhen` targets it): the first flagged value (in
30
- * `notifyWhen.in` order, the most urgent) reads notification red, the rest
31
- * amber, and every non-flagged value neutral grey.
32
- * - Any other enum: the standard palette by the value's declared index. */
33
- export declare function resolveEnumColor(schema: CollectionSchema, fieldKey: string, value: unknown): EnumColorClasses;
@@ -1,4 +0,0 @@
1
- /** Normalise an unknown thrown value to a display string. The view layer's host
2
- * capabilities already return normalised `{ ok: false, error }` results, so this
3
- * only backs the defensive `catch` around an unexpected throw. */
4
- export declare function errorMessage(err: unknown): string;
@@ -1,12 +0,0 @@
1
- import { CollectionItem, CollectionSchema } from './schema';
2
- /** Which field labels a record: the schema's explicit `displayField`, else the
3
- * first non-primary text-like field (so a collection without a displayField
4
- * shows e.g. the title rather than the opaque primaryKey), else null → the
5
- * caller falls back to the primary-key value. */
6
- export declare function labelFieldFor(schema: CollectionSchema): string | null;
7
- /** A record's primary-key value as a string. */
8
- export declare function itemIdOf(item: CollectionItem, schema: CollectionSchema): string;
9
- /** A record's display label: the resolved `labelField` value, else the
10
- * primary key. Pass the result of `labelFieldFor(schema)` as `labelField`
11
- * (compute it once per render rather than per item). */
12
- export declare function itemLabelOf(item: CollectionItem, schema: CollectionSchema, labelField: string | null): string;
@@ -1,13 +0,0 @@
1
- import { ToolContext, ToolDefinition, ToolResult } from 'gui-chat-protocol';
2
- export declare const TOOL_NAME = "presentCollection";
3
- /** Render payload carried in the tool result's `data` field; the View mounts
4
- * off these. Same shape as the tool args. */
5
- export interface PresentCollectionData {
6
- /** Slug of the collection to display (e.g. "clients", "invoices"). */
7
- collectionSlug: string;
8
- /** Optional primary-key value of a single item to open on mount. */
9
- itemId?: string;
10
- }
11
- export type PresentCollectionArgs = PresentCollectionData;
12
- export declare const TOOL_DEFINITION: ToolDefinition;
13
- export declare const executePresentCollection: (_context: ToolContext, args: PresentCollectionArgs) => Promise<ToolResult<PresentCollectionData, PresentCollectionData>>;
@@ -1 +0,0 @@
1
- export declare function defangForPrompt(value: string): string;
@@ -1,382 +0,0 @@
1
- /** Minimal "this collection is a feed" descriptor carried on the schema.
2
- * Deliberately narrow — the canonical collection contract stays
3
- * independent of the host's feeds subsystem. The host's richer retrieval
4
- * spec (`IngestSpec` in `server/workspace/feeds/ingestTypes.ts`)
5
- * `extends CollectionIngest`, so feed code reads the extra fields by
6
- * typing feed schemas with that subtype; collection rendering only needs
7
- * these three + the presence check. */
8
- export interface CollectionIngest {
9
- kind: string;
10
- schedule: string;
11
- /** Optional time-of-day anchor for `schedule: "daily"` — the hour (0–23) to
12
- * refresh around (the host ticks hourly, so the run lands within that hour).
13
- * Ignored for non-daily schedules. Absent ⇒ elapsed-based daily ("≥24 h since
14
- * the last run"). NOTE: **UTC**, not local — compared via `getUTCHours()` for
15
- * an unambiguous, DST-free check (matching the rest of the scheduler), so
16
- * convert local times before writing (e.g. 07:00 JST → `atHour: 22`). */
17
- atHour?: number;
18
- /** Declarative retrievers (`rss`/`atom`/`http-json`) only — the host fetches
19
- * this URL on the schedule. Absent for `kind: "agent"`, where the agent owns
20
- * retrieval. */
21
- url?: string;
22
- /** `kind: "agent"` only: role id the scheduled hidden worker runs in. */
23
- role?: string;
24
- /** `kind: "agent"` only: skill-relative template path (under `templates/`)
25
- * whose prose tells the worker how to refresh the records. */
26
- template?: string;
27
- }
28
- /** Declarative retriever kinds a Feed's `ingest.kind` may declare. The host's
29
- * feeds engine dispatches on these; they live here (with the schema contract)
30
- * so the schema validator can enforce them. The host re-exports these from
31
- * `server/workspace/feeds/ingestTypes.ts`. */
32
- export declare const INGEST_KINDS: readonly ["rss", "atom", "http-json"];
33
- export type IngestKind = (typeof INGEST_KINDS)[number];
34
- /** The agent-performed ingest kind. Instead of a declarative fetch, the host
35
- * dispatches a hidden background chat (origin `system`) in `ingest.role`,
36
- * seeded with `ingest.template` + a summary of every record, on the
37
- * `ingest.schedule` cadence; the worker edits records via the collections io
38
- * layer. Kept separate from {@link INGEST_KINDS} (which the declarative
39
- * retriever registry keys on) so the schema validator can model `ingest` as a
40
- * discriminated union without the feeds engine gaining an "agent" retriever. */
41
- export declare const AGENT_INGEST_KIND: "agent";
42
- export type AgentIngestKind = typeof AGENT_INGEST_KIND;
43
- /** Refresh cadences a Feed's `ingest.schedule` may declare. */
44
- export declare const FEED_SCHEDULES: readonly ["hourly", "daily", "weekly", "on-demand"];
45
- export type FeedSchedule = (typeof FEED_SCHEDULES)[number];
46
- export type CollectionFieldType = "string" | "text" | "email" | "number" | "date" | "datetime" | "boolean" | "markdown" | "ref" | "money" | "enum" | "table" | "derived" | "embed" | "image" | "file" | "toggle";
47
- export type CollectionSource = "user" | "project" | "feed";
48
- /** Recurrence unit for a `spawn.every` advance. */
49
- export type CollectionRecurUnit = "day" | "week" | "month" | "year";
50
- /** How a `spawn` advances the source item's `triggerField` date to
51
- * produce the successor's. All arithmetic is done on the civil
52
- * (year, month, day) triple — never by adding milliseconds — so month
53
- * lengths and leap years are handled correctly. */
54
- export interface CollectionEvery {
55
- unit: CollectionRecurUnit;
56
- /** Number of `unit`s to advance (≥ 1). `interval: 3` + `unit: "month"`
57
- * = quarterly; `interval: 1` + `unit: "year"` = annual. */
58
- interval: number;
59
- /** Day-of-month anchor for `month`/`year` units. The CANONICAL day —
60
- * read from the rule, never re-derived from the prior concrete date,
61
- * so "31st of every month" yields 31 → 28/29 → 31 → 30 … with no
62
- * drift (it is clamped per-month at compute time, not stored
63
- * clamped). `"last"` always means the last day of the target month.
64
- * Omitted ⇒ preserve the source date's day (safe for days ≤ 28).
65
- * Ignored for `day`/`week` units. */
66
- dayOfMonth?: number | "last";
67
- }
68
- /** Field-driven recurrence: the advance interval is selected PER RECORD by
69
- * the value of an `enum` field (`fromField`), looked up in `map`. Lets one
70
- * collection mix daily / weekly / monthly obligations in a single list — the
71
- * host reads `record[fromField]`, finds the matching `CollectionEvery`, and
72
- * advances by it. `fromField` must point at a top-level `enum` field whose
73
- * `values` the `map` keys exactly cover (validated at discovery), and must
74
- * itself be carried/`set` onto the successor so the chain keeps recurring. */
75
- export interface CollectionEveryFieldDriven {
76
- /** Top-level `enum` field whose value selects the interval. */
77
- fromField: string;
78
- /** Interval per enum value. Keys exactly cover `fromField`'s `values`;
79
- * each value is a literal {@link CollectionEvery}. */
80
- map: Record<string, CollectionEvery>;
81
- }
82
- /** The `every` of a `spawn`: either a single literal interval applied to
83
- * every record, or a per-record interval selected by an `enum` field. The
84
- * literal arm is what `advanceTriggerDate` consumes — the field-driven arm
85
- * is resolved down to one of its `map` values before the date math runs. */
86
- export type CollectionSpawnEvery = CollectionEvery | CollectionEveryFieldDriven;
87
- /** Narrowing guard: true when `every` is the field-driven arm. */
88
- export declare function isFieldDrivenEvery(every: CollectionSpawnEvery): every is CollectionEveryFieldDriven;
89
- /** Host-driven recurrence: when a record satisfies `when`, the host
90
- * creates the next record with a forward-advanced `triggerField` date.
91
- * The successor's id and contents are a pure function of (source
92
- * record, this rule); creation is create-if-absent, so the mechanism
93
- * stays convergent — observing the predicate N times writes one
94
- * successor. Requires the schema to declare `triggerField`. */
95
- export interface CollectionSpawn {
96
- /** Predicate that fires the spawn (a `CollectionWhen`). Defaults to
97
- * "`completionField` value ∈ `completionDoneValues`" (i.e. spawn the
98
- * next instance when this one is done). */
99
- when?: CollectionWhen;
100
- /** How to advance `triggerField` from the source to the successor —
101
- * either a single literal interval or a per-record, field-driven map. */
102
- every: CollectionSpawnEvery;
103
- /** Record fields copied verbatim onto the successor. Fields not listed
104
- * here, not in `set`, and not the trigger / primary keys start
105
- * blank. */
106
- carry?: string[];
107
- /** Fields forced to fixed values on the successor (typically resetting
108
- * the status field to its pending value). */
109
- set?: Record<string, unknown>;
110
- }
111
- /** The kind of work an action kicks off. v1 ships only `"chat"` —
112
- * start a new chat in a role with a templated seed prompt. The enum
113
- * reserves room for a future `"mutate"` (status transitions) without
114
- * another schema-shape change. */
115
- export type CollectionActionKind = "chat";
116
- /** Optional visibility predicate: the target (an action button or a
117
- * field) renders only when the open record's `field` (stringified) is
118
- * one of `in`. Generic and domain-free — the host evaluates it against
119
- * the record with no knowledge of what the field means. Absent ⇒
120
- * always shown. */
121
- export interface CollectionWhen {
122
- /** Top-level record field key whose value gates visibility. */
123
- field: string;
124
- /** Allowed values; the target shows when `String(record[field])` is
125
- * one of these. Non-empty. */
126
- in: string[];
127
- }
128
- /** @deprecated Name retained for back-compat; use {@link CollectionWhen}.
129
- * Both actions and fields share the same predicate shape. */
130
- export type CollectionActionWhen = CollectionWhen;
131
- /** What a custom view's capability token is allowed to do against the
132
- * collection's data endpoint. `read` returns enriched records (getItems
133
- * semantics); `write` validates-and-stores rows (putItems semantics).
134
- * There is deliberately no `delete` — a view can never do more than the
135
- * agent's own `manageCollection` tool. */
136
- export type CollectionViewCapability = "read" | "write";
137
- /** A custom (LLM-authored) HTML view for a collection. The host renders
138
- * `file` in a sandboxed iframe over the collection's records; the view
139
- * reaches its data only through a slug- and capability-scoped token (see
140
- * `server/api/auth/viewToken.ts`). Pure data — the host holds no
141
- * view-specific code; meaning lives in the HTML file + this registration. */
142
- export interface CollectionCustomView {
143
- /** Stable id; the view-mode selector key (`custom:<id>`) and the
144
- * capability-token clamp key. Must be a valid slug. */
145
- id: string;
146
- /** Button label in the view-mode selector (author-authored, like field
147
- * labels — not run through i18n). */
148
- label: string;
149
- /** Optional Material-icon name for the selector button. */
150
- icon?: string;
151
- /** Skill-relative path to the HTML file under `views/` (e.g.
152
- * `views/year.html`). Path-safe, must end in `.html`. */
153
- file: string;
154
- /** What the view may do with the data endpoint. Defaults to `["read"]`
155
- * (least privilege); declare `["read","write"]` only for views that
156
- * edit records. The mint endpoint clamps any requested caps to this. */
157
- capabilities?: CollectionViewCapability[];
158
- }
159
- /** A schema-declared, per-record action rendered as a button in the
160
- * read-only detail view. Pure UI/behaviour directive — never stored,
161
- * never validated against record data. All domain specifics (label,
162
- * role, template) live here in the schema / skill folder, so the host
163
- * stays generic. */
164
- export interface CollectionAction {
165
- /** Stable id (used in the dispatch route + testids). */
166
- id: string;
167
- /** Button text (English, like field labels). */
168
- label: string;
169
- /** Material-icon name shown on the button. */
170
- icon?: string;
171
- /** What the action does. v1: `"chat"`. */
172
- kind: CollectionActionKind;
173
- /** `kind: "chat"`: the role id the new chat runs in. */
174
- role: string;
175
- /** `kind: "chat"`: skill-relative path to the template file whose
176
- * text becomes the seed prompt body (e.g. `templates/invoice.md`). */
177
- template: string;
178
- /** Optional visibility predicate; the button renders only when the
179
- * open record matches (see CollectionWhen). Absent ⇒ always
180
- * shown. */
181
- when?: CollectionWhen;
182
- }
183
- export interface CollectionFieldSpec {
184
- type: CollectionFieldType;
185
- label: string;
186
- /** True for the field whose value is the record's filename (no
187
- * separate auto-id). Exactly one field per schema may set this. */
188
- primary?: boolean;
189
- required?: boolean;
190
- /** When `type === "ref"` or `type === "embed"`: the slug of the
191
- * target collection. For `ref` the record stores the target
192
- * item's primary-key slug and the host renders a clickable link
193
- * + dropdown picker. For `embed` the host pulls a *fixed* record
194
- * (see `id`) from the target and renders its fields read-only in
195
- * the detail view. Required for both; ignored on every other
196
- * type. */
197
- to?: string;
198
- /** When `type === "embed"`: the primary-key value of the fixed
199
- * record to pull from the `to` collection (e.g. `me` for the
200
- * singleton mc-profile). Nothing is stored on this record — the
201
- * embed is a display-only directive resolved at render time, so
202
- * it never appears in the list table or the edit form. Required
203
- * when type is `embed`; ignored on every other type. */
204
- id?: string;
205
- /** When `type === "money"` (or `type === "derived"` with
206
- * `display: "money"`): a literal ISO 4217 currency code passed to
207
- * `Intl.NumberFormat` for display — fixed for every record. The
208
- * stored value is always a plain decimal number; currency is
209
- * presentation only. Mutually substitutable with `currencyField`:
210
- * a money field must declare at least one of the two. */
211
- currency?: string;
212
- /** When `type === "money"` (or `type === "derived"` with
213
- * `display: "money"`): the name of a sibling record field whose
214
- * value holds the ISO 4217 code, letting currency vary per record
215
- * (e.g. an invoice's `currency` enum). The renderer reads
216
- * `record[currencyField]` and falls back to the literal `currency`
217
- * (then "USD") when the field is absent or empty. Resolved against
218
- * the top-level record even for money sub-fields inside a table. */
219
- currencyField?: string;
220
- /** When `type === "enum"`: the closed set of allowed string
221
- * values. The form renders a `<select>` populated from this
222
- * list; storage is a plain string. Required when type is
223
- * `enum`; ignored on every other type. */
224
- values?: readonly string[];
225
- /** When `type === "table"`: the sub-schema for each row (a flat
226
- * record of non-table / non-derived field specs). Required when
227
- * type is `table`. v0 disallows nested tables and derived
228
- * columns to keep the editor + evaluator simple. */
229
- of?: Record<string, CollectionFieldSpec>;
230
- /** When `type === "derived"`: a tiny expression evaluated against
231
- * the record. Supports `+ - * /`, parens, identifier refs to
232
- * top-level fields, `sum(tableField[].col)`, and
233
- * `sum(tableField[].col * tableField[].col)`. See
234
- * `src/utils/collections/derivedFormula.ts`. Required when type
235
- * is `derived`. */
236
- formula?: string;
237
- /** When `type === "derived"`: an inner field type the computed
238
- * value should be rendered as (e.g. `"money"` so $1,234.56 is
239
- * formatted). Defaults to `"number"`. */
240
- display?: CollectionFieldType;
241
- /** Optional visibility predicate: this field renders only when the
242
- * record matches (e.g. hide a `rating` field until `visited` is
243
- * `true` via `{ field: "visited", in: ["true"] }`). Applies to the
244
- * list cell (blank when hidden), the edit form (hidden live as the
245
- * gating field changes), and the detail view. Purely presentational
246
- * — a hidden field's stored value is never cleared. `when.field`
247
- * must name another top-level field. Absent ⇒ always shown. Only
248
- * honoured on top-level fields, not inside a `table`'s `of`. */
249
- when?: CollectionWhen;
250
- /** When `type === "toggle"`: the name of the top-level `enum` field this
251
- * checkbox projects. The toggle stores nothing itself — it reads and
252
- * writes this field. Required when type is `toggle`; ignored otherwise.
253
- * Must name a real `enum` field. */
254
- field?: string;
255
- /** When `type === "toggle"`: the enum value that means "checked". The
256
- * box is checked when the projected `field` equals this; checking writes
257
- * it. Required when type is `toggle`; must be one of the enum's `values`. */
258
- onValue?: string;
259
- /** When `type === "toggle"`: the enum value written when the box is
260
- * unchecked. Required when type is `toggle`; must be one of the enum's
261
- * `values`. */
262
- offValue?: string;
263
- }
264
- export interface CollectionSchema {
265
- /** Human-facing collection name (sidebar, header). */
266
- title: string;
267
- /** Material-icon name shown next to the title. */
268
- icon: string;
269
- /** Workspace-relative folder holding one-JSON-per-record. Validated
270
- * to live under the workspace root at load time. */
271
- dataPath: string;
272
- /** Field name whose value doubles as the record's filename. */
273
- primaryKey: string;
274
- /** When set, the collection is a singleton: at most one record,
275
- * whose primary key is fixed to this value (e.g. `me` for the
276
- * business profile). The host pre-fills + locks the create form's
277
- * primary key and hides Add once the record exists. */
278
- singleton?: string;
279
- /** Ordered map: insertion order = column order in the table view. */
280
- fields: Record<string, CollectionFieldSpec>;
281
- /** Optional per-record actions rendered as buttons in the detail
282
- * view (e.g. "Generate PDF"). Order = button order. */
283
- actions?: CollectionAction[];
284
- /** Optional collection-level actions rendered as buttons in the
285
- * collection header (e.g. "Extend the course"). Unlike `actions`,
286
- * these carry no record context: the seed prompt injects a compact
287
- * progress summary of every record instead. The `when` predicate is
288
- * not evaluated (there is no record to gate on). Order = button order. */
289
- collectionActions?: CollectionAction[];
290
- /** Name of the field whose value marks an item as "done". When set,
291
- * a notification fires on item create (unless the item is born done)
292
- * and clears when the field's value transitions into
293
- * `completionDoneValues`. Must name a real field in `fields`. */
294
- completionField?: string;
295
- /** The set of values for `completionField` that count as "done"
296
- * (e.g. `["Done"]` for a todo status field, `["paid"]` for an
297
- * invoice). Non-empty. Compared as strings. */
298
- completionDoneValues?: readonly string[];
299
- /** Name of the field whose value is shown as the human-readable
300
- * label in a completion notification's title (e.g. a `name` field,
301
- * so the bell reads `Contacts: Jane Doe` instead of the opaque
302
- * primaryKey). Must name a real field in `fields`. When unset — or
303
- * when the record's value for it is empty — the title falls back to
304
- * the record's primaryKey value. Display-only; never stored. */
305
- displayField?: string;
306
- /** Name of a `date` field that gates this item's completion
307
- * notification: the bell is suppressed until the clock reaches that
308
- * date (compared at day-granularity in the server's local timezone),
309
- * instead of firing on create. Requires `completionField` /
310
- * `completionDoneValues` (the bell still clears via the done value).
311
- * Must name a real `date` field. Absent ⇒ fire on create, as before. */
312
- triggerField?: string;
313
- /** Lead time in whole days: fire the bell this many days BEFORE
314
- * `triggerField` (so `10` shows the reminder 10 days early). The lead
315
- * is applied at fire time, not stored, so it composes with `spawn` —
316
- * every recurred cycle fires the same number of days before its own
317
- * trigger. Non-negative integer; requires `triggerField`. Default 0
318
- * (fire on the trigger date). */
319
- triggerLeadDays?: number;
320
- /** Host-driven recurrence. When set, requires `triggerField`. See
321
- * {@link CollectionSpawn}. */
322
- spawn?: CollectionSpawn;
323
- /** Name of a `date` field that anchors the optional calendar view: a
324
- * month grid where each record lands on the day cell matching this
325
- * field's value. When unset, the calendar toggle still appears if the
326
- * schema has any `date` field (the first one, in declaration order, is
327
- * used by default and is switchable in-view). Set this to pin a specific
328
- * anchor. Must name a real `date` field. */
329
- calendarField?: string;
330
- /** Name of a second `date` field marking the END of a multi-day span on
331
- * the calendar: the record renders from `calendarField` through this
332
- * date inclusive. Requires `calendarField`. Must name a real `date`
333
- * field. Absent ⇒ single-day placement. */
334
- calendarEndField?: string;
335
- /** Name of a string field holding a free-form time or time-range
336
- * (e.g. "14:00-17:00", "17:00-", "16:30") that places records on the
337
- * calendar's day (time-allocation) view. Consulted only when the calendar
338
- * date fields are date-only. Requires `calendarField`. */
339
- calendarTimeField?: string;
340
- /** Name of an `enum` field that groups records into columns on the
341
- * optional Kanban board: each record lands in the column matching its
342
- * value, with empty/unknown values collected in an "Uncategorized"
343
- * column. When unset, the Kanban toggle still appears if the schema has
344
- * any `enum` field (the first one, in declaration order, is used by
345
- * default and is switchable in-view). Set this to pin a specific group
346
- * field. Must name a real `enum` field. */
347
- kanbanField?: string;
348
- /** Optional custom (LLM-authored) HTML views, each rendered in a
349
- * sandboxed iframe over the records. Absent ⇒ only the built-in
350
- * field-derived views (table / calendar / kanban / dashboard). See
351
- * {@link CollectionCustomView}. */
352
- views?: CollectionCustomView[];
353
- /** Optional predicate that gates the completion bell: when set, the bell
354
- * fires only for records whose `String(record[notifyWhen.field])` is one
355
- * of `notifyWhen.in` (e.g. notify only `high`/`urgent` priority todos).
356
- * Reuses the `when` predicate shape. Requires `completionField` — it
357
- * narrows that bell rather than introducing a second one. The bell still
358
- * clears on done / delete / when the predicate stops matching. Absent ⇒
359
- * notify for every open record (the prior behaviour). `notifyWhen.field`
360
- * must name a real top-level field. */
361
- notifyWhen?: CollectionWhen;
362
- /** Optional scheduled-retrieval config. When present, the host refreshes
363
- * this collection on `ingest.schedule`. Two flavours: a declarative Feed
364
- * (`kind: rss/atom/http-json`) periodically fetches `ingest.url`, maps the
365
- * response into records, and upserts them by `primaryKey` — only feeds
366
- * discovered from the `<workspace>/feeds/` registry carry this. Or
367
- * `kind: "agent"`, valid on any (incl. skill-backed) collection: the host
368
- * dispatches a hidden background worker in `ingest.role` seeded with
369
- * `ingest.template`, and the worker edits the records itself. The host's
370
- * feeds subsystem narrows this to its richer `IngestSpec`. */
371
- ingest?: CollectionIngest;
372
- }
373
- export interface CollectionSummary {
374
- slug: string;
375
- title: string;
376
- icon: string;
377
- source: CollectionSource;
378
- }
379
- export interface CollectionDetail extends CollectionSummary {
380
- schema: CollectionSchema;
381
- }
382
- export type CollectionItem = Record<string, unknown>;
@@ -1,8 +0,0 @@
1
- /**
2
- * 8-char hex id — short, slug-safe, and editable. Produces the same id *shape*
3
- * as the server's `generateItemId()` (8 hex chars) so a UI-created collection
4
- * record looks like one the server would have generated for a form submitted
5
- * with a blank primary key. The source of randomness differs (UUID-derived here
6
- * vs `randomBytes` on the server); only the shape is intentionally shared.
7
- */
8
- export declare function shortHexId(): string;
@@ -1,29 +0,0 @@
1
- import { CollectionItem, CollectionFieldSpec } from './schema';
2
- export type SortDirection = "asc" | "desc";
3
- export interface SortState {
4
- /** Field key of the single active sort column. */
5
- field: string;
6
- direction: SortDirection;
7
- }
8
- /** A row's comparable value for the active field. Exactly one of `num` /
9
- * `str` is set when not empty; `empty` rows always sort last. */
10
- export interface SortValue {
11
- empty: boolean;
12
- num?: number;
13
- str?: string;
14
- }
15
- export declare function isSortableField(field: CollectionFieldSpec): boolean;
16
- /** Cycle one column's state: none → asc → desc → none. */
17
- export declare function nextSortDirection(current: SortDirection | null): SortDirection | null;
18
- export declare function numericSortValue(raw: unknown): SortValue;
19
- export declare function stringSortValue(raw: unknown): SortValue;
20
- export declare function dateSortValue(raw: unknown): SortValue;
21
- /** Enum sorts by the value's index in the declared `values` list. A value
22
- * outside the list (or unset) is treated as empty → last. */
23
- export declare function enumSortValue(values: readonly string[] | undefined, raw: unknown): SortValue;
24
- /** Boolean / toggle: false < true, never empty (unset reads as false). */
25
- export declare function boolSortValue(checked: boolean): SortValue;
26
- export declare function compareSortValues(left: SortValue, right: SortValue): number;
27
- /** Stable sort of `items` by `valueOf`. Empties always last; ties hold
28
- * source order. Returns a new array (does not mutate `items`). */
29
- export declare function sortItems(items: readonly CollectionItem[], direction: SortDirection, valueOf: (item: CollectionItem) => SortValue): CollectionItem[];