@mulmoclaude/core 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/helps/collection-skills.md +102 -1
- package/assets/helps/custom-view.md +34 -0
- package/assets/helps/error-recovery.md +36 -0
- package/assets/helps/mulmoscript.md +2 -0
- package/dist/collection/core/queryZ.d.ts +90 -0
- package/dist/collection/core/schema.d.ts +14 -1
- package/dist/collection/core/schemaZ.d.ts +18 -1
- package/dist/collection/index.cjs +3 -2
- package/dist/collection/index.cjs.map +1 -1
- package/dist/collection/index.d.ts +1 -0
- package/dist/collection/index.js +3 -3
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/registry/server/index.cjs +12 -4
- package/dist/collection/registry/server/index.cjs.map +1 -1
- package/dist/collection/registry/server/index.js +12 -4
- package/dist/collection/registry/server/index.js.map +1 -1
- package/dist/collection/server/csvQuery.d.ts +19 -0
- package/dist/collection/server/csvStore.d.ts +49 -0
- package/dist/collection/server/discoveredCollection.d.ts +9 -1
- package/dist/collection/server/discovery.d.ts +7 -3
- package/dist/collection/server/index.cjs +15 -2
- package/dist/collection/server/index.d.ts +5 -0
- package/dist/collection/server/index.js +3 -3
- package/dist/collection/server/manageTool.d.ts +4 -0
- package/dist/collection/server/store.d.ts +31 -0
- package/dist/collection-watchers/index.cjs +104 -3
- package/dist/collection-watchers/index.cjs.map +1 -1
- package/dist/collection-watchers/index.js +102 -3
- package/dist/collection-watchers/index.js.map +1 -1
- package/dist/feeds/index.cjs +2 -2
- package/dist/feeds/index.js +2 -2
- package/dist/feeds/server/index.cjs +3 -3
- package/dist/feeds/server/index.js +3 -3
- package/dist/google/auth.d.ts +8 -2
- package/dist/google/calendar.d.ts +44 -0
- package/dist/google/index.cjs +86 -9
- package/dist/google/index.cjs.map +1 -1
- package/dist/google/index.d.ts +2 -2
- package/dist/google/index.js +82 -10
- package/dist/google/index.js.map +1 -1
- package/dist/{ingestTypes-DEjpiZGM.js → ingestTypes-B-dXxUF9.js} +2 -2
- package/dist/{ingestTypes-DEjpiZGM.js.map → ingestTypes-B-dXxUF9.js.map} +1 -1
- package/dist/{ingestTypes-Dh5lniBL.cjs → ingestTypes-Cev9q77C.cjs} +2 -2
- package/dist/{ingestTypes-Dh5lniBL.cjs.map → ingestTypes-Cev9q77C.cjs.map} +1 -1
- package/dist/{promptSafety-DN5V__Ku.cjs → promptSafety-DRd15gQ6.cjs} +15 -1
- package/dist/promptSafety-DRd15gQ6.cjs.map +1 -0
- package/dist/{promptSafety-DyG3EuC7.js → promptSafety-rDWA9_JS.js} +10 -2
- package/dist/promptSafety-rDWA9_JS.js.map +1 -0
- package/dist/{server-Bd8l1bhv.js → server--FgDORd3.js} +678 -79
- package/dist/server--FgDORd3.js.map +1 -0
- package/dist/{server-Bh-DPK-H.cjs → server-Q7ld-FlZ.cjs} +754 -76
- package/dist/server-Q7ld-FlZ.cjs.map +1 -0
- package/package.json +3 -1
- package/dist/promptSafety-DN5V__Ku.cjs.map +0 -1
- package/dist/promptSafety-DyG3EuC7.js.map +0 -1
- package/dist/server-Bd8l1bhv.js.map +0 -1
- package/dist/server-Bh-DPK-H.cjs.map +0 -1
|
@@ -126,7 +126,8 @@ skipped, never crashes the host):
|
|
|
126
126
|
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
127
127
|
| `title` | Human name shown in the sidebar / header. Required. |
|
|
128
128
|
| `icon` | A **Material Symbols** name (`receipt_long`, `people`, `schedule`, `menu_book`). Required. |
|
|
129
|
-
| `dataPath` | Workspace-relative records folder, e.g. `data/recipes/items`. Must stay under the workspace. Required.
|
|
129
|
+
| `dataPath` | Workspace-relative records folder, e.g. `data/recipes/items`. Must stay under the workspace. Required — unless `dataSource` is set (declare exactly ONE of the two). |
|
|
130
|
+
| `dataSource` | Optional. `{ "type": "csv", "path": "data/students.csv" }` — the records ARE the rows of an external data file (workspace-relative, containment-checked like `dataPath`). Makes the collection **read-only** in every UI/tool write path; see "External data (CSV) collections" below. Mutually exclusive with `dataPath`, `singleton`, `ingest`, `spawn`, and `mutate` actions. |
|
|
130
131
|
| `primaryKey` | The field name whose value is the filename. That field MUST set `primary: true`. The value must be a valid record id (see the **Records** section's id-charset rule). Required. |
|
|
131
132
|
| `singleton` | Optional. When set, at most one record exists, pinned to this exact id (e.g. `me`). Host pre-fills + locks the create form and hides Add once it exists. |
|
|
132
133
|
| `fields` | Ordered map of field-name → field spec. **Insertion order = column order** in the table. Required. |
|
|
@@ -905,6 +906,106 @@ directly:
|
|
|
905
906
|
(This safety net applies after `putItems` batches too, but direct writes are
|
|
906
907
|
where it earns its keep.)
|
|
907
908
|
|
|
909
|
+
## External data (CSV) collections — `dataSource`
|
|
910
|
+
|
|
911
|
+
When the user has a data file they want to "manage" / "visualize" / "見たい"
|
|
912
|
+
(a student roster, an HR export, a product list — the BI use case), do NOT
|
|
913
|
+
import the rows into record files. Define a collection **on top of** the file
|
|
914
|
+
with `dataSource` — the file stays the single source of truth and the whole
|
|
915
|
+
collection UI (table, kanban, calendar, custom views, remote views) works over
|
|
916
|
+
its rows via the host's DuckDB-backed CSV store.
|
|
917
|
+
|
|
918
|
+
**The schema-inference recipe** (user: "この CSV を管理したい" / "make this CSV a
|
|
919
|
+
collection"):
|
|
920
|
+
|
|
921
|
+
1. **Inspect the file** — Read the first ~30 lines. Note the header row
|
|
922
|
+
(column names), each column's apparent type, and which column uniquely
|
|
923
|
+
identifies a row.
|
|
924
|
+
2. **Pick the key column** — set `primaryKey` to that column's name and flag
|
|
925
|
+
its field `primary: true`. Prefer an ID-ish column (student number, SKU,
|
|
926
|
+
email) over a name. Check for duplicates if unsure — duplicated key values
|
|
927
|
+
don't error, but the LAST row silently wins.
|
|
928
|
+
**Declare the key field as `type: "string"` even when the column is
|
|
929
|
+
numeric** (a row number, an integer ID): record ids are strings, and the
|
|
930
|
+
store overwrites the key field's value with the id — a `number`-typed key
|
|
931
|
+
would just hold a string anyway. Consequence to keep in mind: sorting by
|
|
932
|
+
the key column is lexicographic ("10" before "2"); if numeric ordering
|
|
933
|
+
matters to the user, sort by another column.
|
|
934
|
+
3. **Declare `fields` matching the column names** — field name = CSV column
|
|
935
|
+
name, verbatim (Japanese column names are fine). Only declared fields
|
|
936
|
+
render as table columns; extra CSV columns still ride along in the record
|
|
937
|
+
detail. Use `number` / `date` / `enum` (when a column has a small closed
|
|
938
|
+
value set) / `string` for the rest — DuckDB sniffs the raw types, the
|
|
939
|
+
field spec controls rendering.
|
|
940
|
+
4. **Set `displayField`** to the most human-readable column (a name). This
|
|
941
|
+
matters extra here: a key value that isn't a safe record id (Japanese
|
|
942
|
+
text, spaces) is hex-encoded into the record's address, and
|
|
943
|
+
`displayField` is what keeps lists and notifications readable.
|
|
944
|
+
5. **Write the schema** with `dataSource` instead of `dataPath`, plus a
|
|
945
|
+
normal `SKILL.md`, under `data/skills/<slug>/` — same create flow as any
|
|
946
|
+
collection. In the SKILL body, point aggregation questions at
|
|
947
|
+
`manageCollection` `queryItems` (see below) — NOT at python/pandas and
|
|
948
|
+
NOT at `getItems`; SKILL.md text outlives help updates, so a wrong
|
|
949
|
+
steer here misroutes every future session on this collection.
|
|
950
|
+
|
|
951
|
+
Semantics to remember (and to tell the user):
|
|
952
|
+
|
|
953
|
+
- **Read-only** — no Add/Edit/Delete in the UI, `putItems` refuses, HTTP
|
|
954
|
+
writes answer 405. To change the data, **edit or replace the file itself**
|
|
955
|
+
(you can do that with the normal file tools when asked); open views refresh
|
|
956
|
+
automatically via a file watcher.
|
|
957
|
+
- **Encoding** — Shift_JIS / CP932 and UTF-16 files work as-is; the host
|
|
958
|
+
decodes to a cache copy and never rewrites the user's file. Don't convert
|
|
959
|
+
the file to UTF-8 "to be safe" — an Excel re-export would just undo it.
|
|
960
|
+
- **Row cap** — `getItems` / the UI list stops at 5,000 rows (a warn is
|
|
961
|
+
logged). Fine for browsing — but NEVER compute an aggregate from
|
|
962
|
+
`getItems` output on a large file (a capped scan gives a silently wrong
|
|
963
|
+
number). Use `queryItems` instead.
|
|
964
|
+
- **Aggregation — `manageCollection` `queryItems`** (dataSource collections
|
|
965
|
+
only): a structured query over the WHOLE file (uncapped scan, DuckDB
|
|
966
|
+
underneath). Answer counts / sums / averages / group-bys with it —
|
|
967
|
+
don't shell out to python/pandas for questions it covers. Shape:
|
|
968
|
+
|
|
969
|
+
```json
|
|
970
|
+
{
|
|
971
|
+
"groupBy": ["Category"],
|
|
972
|
+
"aggregates": { "total": { "op": "sum", "column": "Price" }, "n": { "op": "count" } },
|
|
973
|
+
"where": [{ "field": "Availability", "op": "eq", "value": "in_stock" }],
|
|
974
|
+
"orderBy": [{ "field": "total", "dir": "desc" }],
|
|
975
|
+
"limit": 100
|
|
976
|
+
}
|
|
977
|
+
```
|
|
978
|
+
|
|
979
|
+
Ops: `count` (column optional) / `sum` / `avg` / `min` / `max`; `where`
|
|
980
|
+
ops are the familiar `eq/ne/in/gt/gte/lt/lte/contains`; `orderBy` sorts
|
|
981
|
+
by a groupBy column or an aggregate alias; result rows are clamped
|
|
982
|
+
(default 1,000). At least one of `groupBy`/`aggregates` is required.
|
|
983
|
+
`sum`/`avg` skip non-numeric cells. A custom view can run the same
|
|
984
|
+
query shape via `POST <dataUrl>/query` with its read token — see
|
|
985
|
+
`config/helps/custom-view.md` — which is how dataSource dashboards
|
|
986
|
+
chart live data.
|
|
987
|
+
- **Not registry material** — dataSource collections can't be imported from
|
|
988
|
+
or contributed to a registry (the data file is machine-local).
|
|
989
|
+
|
|
990
|
+
Minimal example (Japanese roster, Shift_JIS file dropped at
|
|
991
|
+
`data/students.csv`):
|
|
992
|
+
|
|
993
|
+
```json
|
|
994
|
+
{
|
|
995
|
+
"title": "生徒名簿",
|
|
996
|
+
"icon": "school",
|
|
997
|
+
"dataSource": { "type": "csv", "path": "data/students.csv" },
|
|
998
|
+
"primaryKey": "学籍番号",
|
|
999
|
+
"displayField": "氏名",
|
|
1000
|
+
"fields": {
|
|
1001
|
+
"学籍番号": { "type": "string", "label": "学籍番号", "primary": true },
|
|
1002
|
+
"氏名": { "type": "string", "label": "氏名" },
|
|
1003
|
+
"学年": { "type": "enum", "label": "学年", "values": ["1", "2", "3"] },
|
|
1004
|
+
"入学日": { "type": "date", "label": "入学日" }
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
```
|
|
1008
|
+
|
|
908
1009
|
## End-to-end: creating a new collection skill
|
|
909
1010
|
|
|
910
1011
|
1. Pick a `<slug>` (lowercase-hyphen, no `mc-` prefix) and a `dataPath`
|
|
@@ -101,6 +101,40 @@ toggles, embeds) — the same numbers the user sees elsewhere.
|
|
|
101
101
|
/ shows one record at a time. Combinable with `fields`.
|
|
102
102
|
- The primary key is always returned regardless of `fields`.
|
|
103
103
|
|
|
104
|
+
### Aggregation queries (dataSource/CSV collections; `read` capability)
|
|
105
|
+
|
|
106
|
+
On a collection backed by an external CSV (`dataSource` in its schema), a
|
|
107
|
+
view can run structured aggregations over the WHOLE file — the honest way
|
|
108
|
+
to chart big data (the record read above is row-capped at 5,000; an
|
|
109
|
+
aggregate computed from it would be silently wrong):
|
|
110
|
+
|
|
111
|
+
```js
|
|
112
|
+
const res = await fetch(dataUrl + "/query", {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: { Authorization: "Bearer " + token, "Content-Type": "application/json" },
|
|
115
|
+
body: JSON.stringify({
|
|
116
|
+
query: {
|
|
117
|
+
groupBy: ["Category"],
|
|
118
|
+
aggregates: { total: { op: "sum", column: "Price" }, n: { op: "count" } },
|
|
119
|
+
where: [{ field: "Availability", op: "eq", value: "in_stock" }],
|
|
120
|
+
orderBy: [{ field: "total", dir: "desc" }],
|
|
121
|
+
limit: 100,
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
const { rows } = await res.json(); // [{ Category, total, n }, ...] — chart these
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
- Ops: `count` (column optional) / `sum` / `avg` / `min` / `max`; `where`
|
|
129
|
+
ops: `eq/ne/in/gt/gte/lt/lte/contains`; at least one of
|
|
130
|
+
`groupBy`/`aggregates`; `orderBy` sorts by a groupBy column or an
|
|
131
|
+
aggregate alias; result rows clamp at 1,000 by default.
|
|
132
|
+
- Structured JSON only — there is **no SQL surface**, by design.
|
|
133
|
+
- A file-backed (non-dataSource) collection answers 400 ("file-backed") —
|
|
134
|
+
compute from the record read instead there.
|
|
135
|
+
- Combine with `onChange` (below) to re-run the query when the CSV is
|
|
136
|
+
replaced — that's a live dashboard.
|
|
137
|
+
|
|
104
138
|
### Writing records (only with the `write` capability)
|
|
105
139
|
|
|
106
140
|
```js
|
|
@@ -183,6 +183,36 @@ plugin via the `/skills` UI to refresh both the tgz and the ledger.
|
|
|
183
183
|
A version skew on a peer dep means the plugin was built against an
|
|
184
184
|
older host — bump the plugin via the Discover tab's update flow.
|
|
185
185
|
|
|
186
|
+
## dataSource (CSV) collection reads fail — "DuckDB is unavailable on this host"
|
|
187
|
+
|
|
188
|
+
A collection whose schema declares `dataSource` (external CSV) reads its rows
|
|
189
|
+
through `@duckdb/node-api`, a NATIVE module with per-platform prebuilt
|
|
190
|
+
bindings. When the binding is missing or fails to load, ONLY dataSource
|
|
191
|
+
collections break (every file-backed collection keeps working) and reads
|
|
192
|
+
fail with `DuckDB is unavailable on this host (@duckdb/node-api failed to
|
|
193
|
+
load: …)`.
|
|
194
|
+
|
|
195
|
+
Diagnosis + fixes, in order:
|
|
196
|
+
|
|
197
|
+
1. **Reinstall dependencies** — `yarn install` at the app root. The usual
|
|
198
|
+
cause is an install that skipped the platform package
|
|
199
|
+
(`@duckdb/node-bindings-<platform>-<arch>`), e.g. after copying
|
|
200
|
+
`node_modules` between machines or architectures (an arm64 → x64 Docker
|
|
201
|
+
volume mount does exactly this).
|
|
202
|
+
2. **Check the platform is supported** — `ls node_modules/@duckdb/ | cat`.
|
|
203
|
+
You should see a `node-bindings-<your platform>` package. If DuckDB ships
|
|
204
|
+
no prebuilt binding for the host (rare: musl/alpine, exotic arch), there
|
|
205
|
+
is no local fix — tell the user dataSource collections need a supported
|
|
206
|
+
platform (glibc Linux x64/arm64, macOS, Windows) and that their other
|
|
207
|
+
collections are unaffected.
|
|
208
|
+
3. **Docker**: make sure the image installs dependencies INSIDE the
|
|
209
|
+
container (matching libc/arch) rather than bind-mounting a host
|
|
210
|
+
`node_modules`.
|
|
211
|
+
|
|
212
|
+
Related, not an error: a dataSource CSV in Shift_JIS / UTF-16 is decoded
|
|
213
|
+
automatically to a cache copy under the OS temp dir — never "fix" the
|
|
214
|
+
user's file by re-encoding it.
|
|
215
|
+
|
|
186
216
|
## Fallback
|
|
187
217
|
|
|
188
218
|
If none of the above matches the failing tool output:
|
|
@@ -308,6 +338,7 @@ shipped builders produce, and asserts `handlePermission` comes back over the MCP
|
|
|
308
338
|
- **"multiple client_secret_*.json files found"**.
|
|
309
339
|
- **"Google Calendar API: HTTP 403"** with a hint about enabling the API.
|
|
310
340
|
- **"could not obtain a Google access token"** (grant revoked).
|
|
341
|
+
- `calendarListCalendars` / non-primary calendar lookups fail with **HTTP 401/403 / insufficient scope**, or the list comes back empty even though the user has other calendars.
|
|
311
342
|
|
|
312
343
|
### Cause
|
|
313
344
|
|
|
@@ -328,6 +359,11 @@ Two ways the link can be minted, and the tool picks automatically:
|
|
|
328
359
|
- **Not linked / grant revoked** — ask the user to link (or re-link) the account from this app's
|
|
329
360
|
settings, then retry. Do NOT tell them to create a Google Cloud project, and do NOT try to
|
|
330
361
|
create or edit the token file yourself.
|
|
362
|
+
- **Calendar-list / non-primary lookup fails with insufficient scope (or lists nothing)** — the
|
|
363
|
+
account was linked before the calendar-list read scope (`calendar.calendarlist.readonly`) was
|
|
364
|
+
added, so the stored grant predates it. Ask the user to re-link from settings to add the scope,
|
|
365
|
+
then retry. Reading events on a non-primary calendar by id needs no re-link once the calendar
|
|
366
|
+
list is visible.
|
|
331
367
|
- **Sign-in service unreachable / HTTP error** — the broker is down or the network is blocked.
|
|
332
368
|
It is only needed to link and to renew an expired access token; ask the user to retry shortly.
|
|
333
369
|
(A user with their own `~/.secrets/client_secret_*.json` never depends on it.)
|
|
@@ -126,6 +126,8 @@ Embed an existing image.
|
|
|
126
126
|
|
|
127
127
|
Source kinds: `url`, `base64`, `path`
|
|
128
128
|
|
|
129
|
+
**Where relative `path` sources resolve from:** the script file's own directory — `<workspace>/artifacts/stories/` — NOT the workspace root. So a workspace file such as `data/photo.png` must be written as `../../data/photo.png`, or (preferred, keeps the script portable) copied next to the script, e.g. to `artifacts/stories/assets/photo.png` and referenced as `assets/photo.png`. This applies to every media source of kind `path` (`image`, `movie`, `pdf`, `svg`, mermaid `code`).
|
|
130
|
+
|
|
129
131
|
### `chart`
|
|
130
132
|
Render a chart from data.
|
|
131
133
|
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Hard ceiling on returned rows; `limit` clamps below it. A group-by on
|
|
3
|
+
* a near-unique column would otherwise return one row per source row —
|
|
4
|
+
* the exact materialization the aggregate path exists to avoid. */
|
|
5
|
+
export declare const MAX_QUERY_ROWS = 10000;
|
|
6
|
+
/** Default row cap when the query declares no `limit`. */
|
|
7
|
+
export declare const DEFAULT_QUERY_ROWS = 1000;
|
|
8
|
+
/** Cap on aggregate expressions per query — a record shape has no
|
|
9
|
+
* intrinsic size limit, and thousands of expressions would make one
|
|
10
|
+
* full-file scan arbitrarily wide. */
|
|
11
|
+
export declare const MAX_QUERY_AGGREGATES = 32;
|
|
12
|
+
/** One aggregate column: `count` (rows; `column` optional to count
|
|
13
|
+
* non-null cells) or `sum`/`avg`/`min`/`max` over a named CSV column. */
|
|
14
|
+
export declare const QueryAggregateZ: z.ZodObject<{
|
|
15
|
+
op: z.ZodEnum<{
|
|
16
|
+
sum: "sum";
|
|
17
|
+
count: "count";
|
|
18
|
+
avg: "avg";
|
|
19
|
+
min: "min";
|
|
20
|
+
max: "max";
|
|
21
|
+
}>;
|
|
22
|
+
column: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
/** One filter condition. Same op vocabulary as the schema-level `where`
|
|
25
|
+
* (`core/where.ts`) so authors learn one set; values may be typed
|
|
26
|
+
* (number / boolean) since CSV columns are. `in` requires an array
|
|
27
|
+
* value, every other op a scalar. */
|
|
28
|
+
export declare const QueryWhereZ: z.ZodObject<{
|
|
29
|
+
field: z.ZodString;
|
|
30
|
+
op: z.ZodEnum<{
|
|
31
|
+
in: "in";
|
|
32
|
+
eq: "eq";
|
|
33
|
+
ne: "ne";
|
|
34
|
+
gt: "gt";
|
|
35
|
+
gte: "gte";
|
|
36
|
+
lt: "lt";
|
|
37
|
+
lte: "lte";
|
|
38
|
+
contains: "contains";
|
|
39
|
+
}>;
|
|
40
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export declare const QueryOrderZ: z.ZodObject<{
|
|
43
|
+
field: z.ZodString;
|
|
44
|
+
dir: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
asc: "asc";
|
|
46
|
+
desc: "desc";
|
|
47
|
+
}>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
/** The whole query. At least one of `groupBy` / `aggregates` must be
|
|
50
|
+
* present: bare `groupBy` is a DISTINCT listing, bare `aggregates` a
|
|
51
|
+
* whole-file scalar row, together a grouped aggregation. */
|
|
52
|
+
export declare const CollectionQueryZ: z.ZodObject<{
|
|
53
|
+
groupBy: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
aggregates: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
55
|
+
op: z.ZodEnum<{
|
|
56
|
+
sum: "sum";
|
|
57
|
+
count: "count";
|
|
58
|
+
avg: "avg";
|
|
59
|
+
min: "min";
|
|
60
|
+
max: "max";
|
|
61
|
+
}>;
|
|
62
|
+
column: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>>>;
|
|
64
|
+
where: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
65
|
+
field: z.ZodString;
|
|
66
|
+
op: z.ZodEnum<{
|
|
67
|
+
in: "in";
|
|
68
|
+
eq: "eq";
|
|
69
|
+
ne: "ne";
|
|
70
|
+
gt: "gt";
|
|
71
|
+
gte: "gte";
|
|
72
|
+
lt: "lt";
|
|
73
|
+
lte: "lte";
|
|
74
|
+
contains: "contains";
|
|
75
|
+
}>;
|
|
76
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>]>;
|
|
77
|
+
}, z.core.$strip>>>;
|
|
78
|
+
orderBy: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
79
|
+
field: z.ZodString;
|
|
80
|
+
dir: z.ZodOptional<z.ZodEnum<{
|
|
81
|
+
asc: "asc";
|
|
82
|
+
desc: "desc";
|
|
83
|
+
}>>;
|
|
84
|
+
}, z.core.$strip>>>;
|
|
85
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
export type CollectionQueryAggregate = z.infer<typeof QueryAggregateZ>;
|
|
88
|
+
export type CollectionQueryWhere = z.infer<typeof QueryWhereZ>;
|
|
89
|
+
export type CollectionQueryOrder = z.infer<typeof QueryOrderZ>;
|
|
90
|
+
export type CollectionQuery = z.infer<typeof CollectionQueryZ>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { ActionSpecZ, CollectionSchemaZ, CustomViewZ, DynamicIconRuleZ, DynamicIconSourceZ, DynamicIconSpecZ, EveryFieldDrivenZ, EveryLiteralZ, EveryZ, FieldSpecZ, IngestZ, SpawnZ, SubFieldSpecZ, WhenZ } from './schemaZ';
|
|
2
|
+
import { ActionSpecZ, CollectionSchemaZ, CustomViewZ, DataSourceZ, DynamicIconRuleZ, DynamicIconSourceZ, DynamicIconSpecZ, EveryFieldDrivenZ, EveryLiteralZ, EveryZ, FieldSpecZ, IngestZ, SpawnZ, SubFieldSpecZ, WhenZ } from './schemaZ';
|
|
3
3
|
/** Minimal "this collection is a feed" descriptor carried on the schema.
|
|
4
4
|
* Deliberately narrow — the canonical collection contract stays
|
|
5
5
|
* independent of the host's feeds subsystem. The host's richer retrieval
|
|
@@ -138,14 +138,27 @@ export type DynamicIconSpec = z.infer<typeof DynamicIconSpecZ>;
|
|
|
138
138
|
* union on `kind` (declarative retrievers | agent worker). The feeds
|
|
139
139
|
* subsystem's `IngestSpec` is the same union under its historical name. */
|
|
140
140
|
export type CollectionIngestSpec = z.infer<typeof IngestZ>;
|
|
141
|
+
/** The `dataSource` block: this collection's records are the rows of an
|
|
142
|
+
* external read-only data file (v1: CSV). See `DataSourceZ`. */
|
|
143
|
+
export type CollectionDataSource = z.infer<typeof DataSourceZ>;
|
|
141
144
|
/** The whole `schema.json` contract. Key-level docs live on
|
|
142
145
|
* `CollectionSchemaZ` in `./schemaZ`. */
|
|
143
146
|
export type CollectionSchema = z.infer<typeof CollectionSchemaZ>;
|
|
147
|
+
/** True when `schema` declares an external `dataSource` — i.e. the
|
|
148
|
+
* collection is READ-ONLY through every UI/tool write path (updates
|
|
149
|
+
* happen by editing/replacing the data file itself). Isomorphic: both
|
|
150
|
+
* the server write guards and the client's control hiding key off this
|
|
151
|
+
* one predicate. */
|
|
152
|
+
export declare function isReadOnlySchema(schema: Pick<CollectionSchema, "dataSource">): boolean;
|
|
144
153
|
export interface CollectionSummary {
|
|
145
154
|
slug: string;
|
|
146
155
|
title: string;
|
|
147
156
|
icon: string;
|
|
148
157
|
source: CollectionSource;
|
|
158
|
+
/** Present (true) when the collection is backed by an external
|
|
159
|
+
* `dataSource` and therefore read-only in every UI/tool write path.
|
|
160
|
+
* Absent-when-writable, matching the other optional summary flags. */
|
|
161
|
+
readonly?: true;
|
|
149
162
|
/** Slugs of the source collection(s) a `dynamicIcon` icon was computed
|
|
150
163
|
* from — present only when `schema.dynamicIcon` is set. Lets a client
|
|
151
164
|
* know which collection change-channel(s) to watch for a live icon
|
|
@@ -608,10 +608,27 @@ export declare const DynamicIconSpecZ: z.ZodObject<{
|
|
|
608
608
|
}, z.core.$strip>>;
|
|
609
609
|
fallback: z.ZodOptional<z.ZodString>;
|
|
610
610
|
}, z.core.$strip>;
|
|
611
|
+
/** External-data collection: the records ARE the rows of a user-supplied
|
|
612
|
+
* data file (v1: CSV), queried through DuckDB — never copied into
|
|
613
|
+
* `<dataDir>/<id>.json` files. Declaring `dataSource` makes the collection
|
|
614
|
+
* **read-only** in every UI/tool write path; updates happen by replacing /
|
|
615
|
+
* editing the file itself (file-watch republishes the views). `path` is
|
|
616
|
+
* workspace-relative and containment-checked exactly like `dataPath`. The
|
|
617
|
+
* row-id column is the schema's existing `primaryKey` — there is
|
|
618
|
+
* deliberately no second key concept here.
|
|
619
|
+
* See plans/feat-collection-csv-duckdb-source.md. */
|
|
620
|
+
export declare const DataSourceZ: z.ZodObject<{
|
|
621
|
+
type: z.ZodLiteral<"csv">;
|
|
622
|
+
path: z.ZodString;
|
|
623
|
+
}, z.core.$strip>;
|
|
611
624
|
export declare const CollectionSchemaZ: z.ZodObject<{
|
|
612
625
|
title: z.ZodString;
|
|
613
626
|
icon: z.ZodString;
|
|
614
|
-
dataPath: z.ZodString
|
|
627
|
+
dataPath: z.ZodOptional<z.ZodString>;
|
|
628
|
+
dataSource: z.ZodOptional<z.ZodObject<{
|
|
629
|
+
type: z.ZodLiteral<"csv">;
|
|
630
|
+
path: z.ZodString;
|
|
631
|
+
}, z.core.$strip>>;
|
|
615
632
|
primaryKey: z.ZodString;
|
|
616
633
|
singleton: z.ZodOptional<z.ZodString>;
|
|
617
634
|
fields: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_promptSafety = require("../promptSafety-
|
|
2
|
+
const require_promptSafety = require("../promptSafety-DRd15gQ6.cjs");
|
|
3
3
|
const require_errorMessage = require("../errorMessage--LvXe_Jx.cjs");
|
|
4
4
|
//#region src/collection/core/presentCollection.ts
|
|
5
5
|
var TOOL_NAME = "presentCollection";
|
|
@@ -38,7 +38,7 @@ var executePresentCollection = async (_context, args) => {
|
|
|
38
38
|
message: `Presented collection ${itemId ? `${collectionSlug} / ${itemId}` : collectionSlug}`,
|
|
39
39
|
data,
|
|
40
40
|
jsonData: data,
|
|
41
|
-
instructions: "The collection has been presented to the user as an interactive card. They can browse
|
|
41
|
+
instructions: "The collection has been presented to the user as an interactive card. They can browse and open records directly; on a writable collection they can also edit, create, and delete (a read-only dataSource collection shows no edit controls — its records change by editing the backing data file). No further action is needed unless they ask."
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
//#endregion
|
|
@@ -478,6 +478,7 @@ exports.fieldVisible = require_promptSafety.fieldVisible;
|
|
|
478
478
|
exports.firstDateField = require_promptSafety.firstDateField;
|
|
479
479
|
exports.firstMissingRequiredField = firstMissingRequiredField;
|
|
480
480
|
exports.isFieldDrivenEvery = require_promptSafety.isFieldDrivenEvery;
|
|
481
|
+
exports.isReadOnlySchema = require_promptSafety.isReadOnlySchema;
|
|
481
482
|
exports.isSafeRecordId = require_promptSafety.isSafeRecordId;
|
|
482
483
|
exports.isSafeSlug = require_promptSafety.isSafeSlug;
|
|
483
484
|
exports.isSortableField = isSortableField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/collection/core/presentCollection.ts","../../src/collection/core/enumColors.ts","../../src/collection/core/draft.ts","../../src/collection/core/sortItems.ts","../../src/collection/core/itemLabel.ts","../../src/collection/core/shortHexId.ts"],"sourcesContent":["// presentCollection tool — definition + pure server-side executor.\n//\n// Isomorphic (no Vue, no Node): bundled to the browser as the plugin's\n// `execute`, and run server-side via the host's plugin dispatch route. The\n// executor only validates + echoes the addressing; the live schema + items\n// are fetched client-side by the View through the host's /api/collections\n// routes, so a bad slug surfaces as the View's \"not found\" state.\n\nimport type { ToolContext, ToolDefinition, ToolResult } from \"gui-chat-protocol\";\n\nexport const TOOL_NAME = \"presentCollection\";\n\n/** Render payload carried in the tool result's `data` field; the View mounts\n * off these. Same shape as the tool args. */\nexport interface PresentCollectionData {\n /** Slug of the collection to display (e.g. \"clients\", \"invoices\"). */\n collectionSlug: string;\n /** Optional primary-key value of a single item to open on mount. */\n itemId?: string;\n}\n\nexport type PresentCollectionArgs = PresentCollectionData;\n\nexport const TOOL_DEFINITION: ToolDefinition = {\n type: \"function\",\n name: TOOL_NAME,\n description:\n \"Display a schema-driven collection inline in the chat as an interactive, editable card. Shows the collection's list of records. Pass `itemId` to open one specific record on mount.\",\n parameters: {\n type: \"object\",\n properties: {\n collectionSlug: {\n type: \"string\",\n description: \"The slug of the collection to display (e.g. 'clients', 'invoices', 'contacts').\",\n },\n itemId: {\n type: \"string\",\n description: \"Optional primary-key value of a single record to open in detail view on mount. Omit to show the full list.\",\n },\n },\n required: [\"collectionSlug\"],\n },\n prompt: `After making changes to schema-driven collections, use ${TOOL_NAME} to present either the collection or the item`,\n};\n\nexport const executePresentCollection = async (\n _context: ToolContext,\n args: PresentCollectionArgs,\n): Promise<ToolResult<PresentCollectionData, PresentCollectionData>> => {\n const collectionSlug = typeof args?.collectionSlug === \"string\" ? args.collectionSlug.trim() : \"\";\n if (!collectionSlug) {\n return {\n message: \"presentCollection error: collectionSlug is required\",\n instructions: \"Tell the user you couldn't display the collection because no collection was specified, and ask which collection they mean.\",\n };\n }\n const itemId = typeof args.itemId === \"string\" && args.itemId.trim().length > 0 ? args.itemId.trim() : undefined;\n const data: PresentCollectionData = itemId ? { collectionSlug, itemId } : { collectionSlug };\n const target = itemId ? `${collectionSlug} / ${itemId}` : collectionSlug;\n return {\n message: `Presented collection ${target}`,\n // `data` is the view's source (also the host's render-eligibility signal);\n // `jsonData` is what the LLM sees. Same payload, two audiences.\n data,\n jsonData: data,\n instructions:\n \"The collection has been presented to the user as an interactive card. They can browse, open, edit, create, and delete records directly. No further action is needed unless they ask.\",\n };\n};\n","// A standard, ordered colour palette for `enum` field values, shared by every\n// collection surface (list, calendar, kanban). Each value in an\n// enum's `values` array is assigned the palette entry at its index — cycling\n// when an enum declares more values than the palette holds — so colouring is\n// automatic and consistent without any per-value schema config.\n//\n// Tailwind only detects class names that appear as complete string literals,\n// so every surface's classes are spelled out per colour below rather than\n// built from a colour name at runtime.\n//\n// One enum is special: the field a schema's `notifyWhen` targets (the\n// \"notification enum\"). Its flagged values read the notification severity\n// colours — the first flagged value (most urgent) red, the rest amber — and\n// every other value reads neutral grey, mirroring the notification bell\n// (red = urgent, amber = nudge) rather than the rotating palette.\n// `resolveEnumColor` encapsulates that rule.\n\nimport type { CollectionSchema } from \"./schema\";\n\nexport interface EnumColorClasses {\n /** Stat-card style: border + fill + text + hover. */\n card: string;\n /** Small status dot (kanban column header). */\n dot: string;\n /** Pill / badge / inline `<select>` fill + text (no border width). */\n badge: string;\n /** Border colour, paired with a `border` width class by the caller. */\n border: string;\n}\n\n// The palette deliberately EXCLUDES the warm warning band (red / orange /\n// amber): those are reserved for the notification-enum severity colours\n// (`ENUM_ALERT` red, `ENUM_NUDGE` amber), so a normal enum value can never\n// draw a colour that reads like a notification. Eight well-separated cool /\n// green / magenta hues keep enough variety for wide enums.\nconst PALETTE: readonly EnumColorClasses[] = [\n {\n card: \"border-indigo-200 bg-indigo-50 text-indigo-600 hover:bg-indigo-100\",\n dot: \"bg-indigo-500\",\n badge: \"bg-indigo-100 text-indigo-700\",\n border: \"border-indigo-200\",\n },\n { card: \"border-sky-200 bg-sky-50 text-sky-600 hover:bg-sky-100\", dot: \"bg-sky-500\", badge: \"bg-sky-100 text-sky-700\", border: \"border-sky-200\" },\n { card: \"border-cyan-200 bg-cyan-50 text-cyan-600 hover:bg-cyan-100\", dot: \"bg-cyan-500\", badge: \"bg-cyan-100 text-cyan-700\", border: \"border-cyan-200\" },\n { card: \"border-teal-200 bg-teal-50 text-teal-600 hover:bg-teal-100\", dot: \"bg-teal-500\", badge: \"bg-teal-100 text-teal-700\", border: \"border-teal-200\" },\n {\n card: \"border-emerald-200 bg-emerald-50 text-emerald-600 hover:bg-emerald-100\",\n dot: \"bg-emerald-500\",\n badge: \"bg-emerald-100 text-emerald-700\",\n border: \"border-emerald-200\",\n },\n { card: \"border-lime-200 bg-lime-50 text-lime-600 hover:bg-lime-100\", dot: \"bg-lime-500\", badge: \"bg-lime-100 text-lime-700\", border: \"border-lime-200\" },\n {\n card: \"border-violet-200 bg-violet-50 text-violet-600 hover:bg-violet-100\",\n dot: \"bg-violet-500\",\n badge: \"bg-violet-100 text-violet-700\",\n border: \"border-violet-200\",\n },\n {\n card: \"border-fuchsia-200 bg-fuchsia-50 text-fuchsia-600 hover:bg-fuchsia-100\",\n dot: \"bg-fuchsia-500\",\n badge: \"bg-fuchsia-100 text-fuchsia-700\",\n border: \"border-fuchsia-200\",\n },\n];\n\n/** Neutral styling for the empty / Uncategorized bucket — never a palette\n * colour, so an unset or unknown value reads grey across every surface. */\nexport const ENUM_NEUTRAL: EnumColorClasses = {\n card: \"border-slate-200 bg-slate-50 text-slate-500 hover:bg-slate-100\",\n dot: \"bg-slate-300\",\n badge: \"bg-slate-100 text-slate-500\",\n border: \"border-slate-200\",\n};\n\n/** The urgent notification colour (red), matching the bell's `urgent`\n * severity. The first value a schema's `notifyWhen` flags reads this. */\nexport const ENUM_ALERT: EnumColorClasses = {\n card: \"border-red-200 bg-red-50 text-red-600 hover:bg-red-100\",\n dot: \"bg-red-500\",\n badge: \"bg-red-100 text-red-700\",\n border: \"border-red-200\",\n};\n\n/** The nudge notification colour (amber), matching the bell's `nudge`\n * severity. Flagged `notifyWhen` values after the first read this. */\nexport const ENUM_NUDGE: EnumColorClasses = {\n card: \"border-amber-200 bg-amber-50 text-amber-600 hover:bg-amber-100\",\n dot: \"bg-amber-500\",\n badge: \"bg-amber-100 text-amber-700\",\n border: \"border-amber-200\",\n};\n\n/** Classes for the enum value at `index` in its field's `values` array. A\n * negative index (value unset or not among the declared values) reads\n * neutral. */\nexport function enumColorClasses(index: number): EnumColorClasses {\n if (index < 0) return ENUM_NEUTRAL;\n return PALETTE[index % PALETTE.length] ?? ENUM_NEUTRAL;\n}\n\n/** Index of `value` within an enum field's declared `values`, or -1 when the\n * value is empty / unknown (→ neutral). */\nexport function enumValueIndex(values: readonly string[] | undefined, value: unknown): number {\n if (value === undefined || value === null || value === \"\") return -1;\n return values?.indexOf(String(value)) ?? -1;\n}\n\n/** The flagged values when `fieldKey` is the schema's `notifyWhen` target (the\n * \"notification enum\"); undefined for every other field. */\nfunction notifyValuesFor(schema: CollectionSchema, fieldKey: string): readonly string[] | undefined {\n const spec = schema.notifyWhen;\n return spec && spec.field === fieldKey ? spec.in : undefined;\n}\n\n/** Resolve a value's colour for enum field `fieldKey`:\n * - Notification enum (`notifyWhen` targets it): the first flagged value (in\n * `notifyWhen.in` order, the most urgent) reads notification red, the rest\n * amber, and every non-flagged value neutral grey.\n * - Any other enum: the standard palette by the value's declared index. */\nexport function resolveEnumColor(schema: CollectionSchema, fieldKey: string, value: unknown): EnumColorClasses {\n const notifyValues = notifyValuesFor(schema, fieldKey);\n if (notifyValues) {\n const str = value === undefined || value === null ? \"\" : String(value);\n const rank = notifyValues.indexOf(str);\n if (rank < 0) return ENUM_NEUTRAL;\n return rank === 0 ? ENUM_ALERT : ENUM_NUDGE;\n }\n const spec = schema.fields[fieldKey];\n return enumColorClasses(enumValueIndex(spec?.type === \"enum\" ? spec.values : undefined, value));\n}\n","// Pure edit-draft logic for the collection record form, extracted from\n// CollectionView.vue so the parent (build draft / save / validate) and\n// the extracted CollectionRecordPanel (per-row table mutators) share one\n// implementation. No Vue, no I/O — every function maps a draft + schema\n// to a value, so the omission/validation semantics are unit-testable.\n\nimport { fieldVisible } from \"./actionVisible\";\nimport { COMPUTED_TYPES } from \"./schema\";\nimport type { CollectionFieldSpec as FieldSpec, CollectionFieldType as FieldType, CollectionItem, CollectionSchema } from \"./schema\";\nimport type { EditState, TableRowDraft } from \"./uiTypes\";\n\n/** A fresh, empty row draft for a `table` field's sub-schema. */\nexport function emptyRow(subFields: Record<string, FieldSpec>): TableRowDraft {\n const text: Record<string, string> = {};\n const bool: Record<string, boolean> = {};\n const boolOriginallyPresent: Record<string, boolean> = {};\n const boolTouched: Record<string, boolean> = {};\n for (const [subKey, subField] of Object.entries(subFields)) {\n if (subField.type === \"boolean\") {\n bool[subKey] = false;\n boolOriginallyPresent[subKey] = false; // brand-new row\n boolTouched[subKey] = false;\n } else {\n text[subKey] = \"\";\n }\n }\n return { text, bool, boolOriginallyPresent, boolTouched };\n}\n\n/** Build a row draft from an existing persisted row. */\nexport function rowFromItem(item: Record<string, unknown>, subFields: Record<string, FieldSpec>): TableRowDraft {\n const text: Record<string, string> = {};\n const bool: Record<string, boolean> = {};\n const boolOriginallyPresent: Record<string, boolean> = {};\n const boolTouched: Record<string, boolean> = {};\n for (const [subKey, subField] of Object.entries(subFields)) {\n const raw = item[subKey];\n if (subField.type === \"boolean\") {\n bool[subKey] = raw === true;\n // `typeof raw === \"boolean\"` so an existing explicit `false` is\n // recorded as present and round-trips on a no-op save.\n boolOriginallyPresent[subKey] = typeof raw === \"boolean\";\n boolTouched[subKey] = false;\n } else {\n text[subKey] = raw === undefined || raw === null ? \"\" : String(raw);\n }\n }\n return { text, bool, boolOriginallyPresent, boolTouched };\n}\n\n/** Decide whether a boolean field's draft value should be emitted (vs.\n * omitted so a downstream default applies). */\nfunction shouldEmitBoolean(state: EditState, key: string, field: FieldSpec): boolean {\n return Boolean(state.boolOriginallyPresent[key] || state.boolTouched[key] || field.required);\n}\n\n/** Convert a scalar draft slot to its persisted form. `undefined` = omit. */\nfunction scalarDraftToValue(raw: string | undefined, fieldType: FieldType): unknown {\n if (raw === undefined || raw === \"\") return undefined;\n if (fieldType === \"number\" || fieldType === \"money\") {\n const num = Number(raw);\n return Number.isFinite(num) ? num : raw;\n }\n return raw;\n}\n\n/** Convert one table row draft to its persisted record. */\nfunction rowDraftToRecord(rowDraft: TableRowDraft, subFields: Record<string, FieldSpec>): Record<string, unknown> {\n const row: Record<string, unknown> = {};\n for (const [subKey, subField] of Object.entries(subFields)) {\n if (subField.type === \"boolean\") {\n const value = rowDraft.bool[subKey] === true;\n if (rowDraft.boolOriginallyPresent[subKey] || rowDraft.boolTouched[subKey] || value || subField.required) row[subKey] = value;\n continue;\n }\n const value = scalarDraftToValue(rowDraft.text[subKey], subField.type);\n if (value !== undefined) row[subKey] = value;\n }\n return row;\n}\n\n/** Convert a full edit draft to the record to persist. */\nexport function draftToRecord(state: EditState, schema: CollectionSchema): CollectionItem {\n const record: CollectionItem = {};\n for (const [key, field] of Object.entries(schema.fields)) {\n if (COMPUTED_TYPES.has(field.type)) continue; // never persisted (toggle projects an enum field)\n if (field.type === \"boolean\") {\n if (shouldEmitBoolean(state, key, field)) record[key] = state.bool[key] === true;\n continue;\n }\n if (field.type === \"table\" && field.of) {\n const subFields = field.of;\n record[key] = (state.table[key] ?? []).map((rowDraft) => rowDraftToRecord(rowDraft, subFields));\n continue;\n }\n const value = scalarDraftToValue(state.text[key], field.type);\n if (value !== undefined) record[key] = value;\n }\n return record;\n}\n\n/** Normalise a raw inline-edit input (table-cell checkbox/select) to its\n * persisted form. Mirrors `draftToRecord`'s boolean strictness; an empty\n * enum selection (the placeholder option) clears the field via `undefined`. */\nexport function coerceInlineValue(field: FieldSpec, raw: boolean | string): unknown {\n if (field.type === \"boolean\") return raw === true;\n return raw === \"\" ? undefined : raw;\n}\n\n/** Build the full record to PUT for a single-cell inline edit, without\n * mutating `item`. A `undefined` value omits the key (enum cleared),\n * matching `draftToRecord`'s omission semantics. */\nexport function buildUpdatedRecord(item: CollectionItem, key: string, value: unknown): CollectionItem {\n if (value === undefined) {\n const { [key]: __omit, ...rest } = item;\n return rest;\n }\n return { ...item, [key]: value };\n}\n\n/** Empty for required-field validation — NOT a truthiness check (a\n * numeric `0` is a filled value). */\nfunction isMissingDraftValue(value: unknown): boolean {\n return value === undefined || value === null || value === \"\";\n}\n\n/** Label of the first required table sub-field empty in any row, else null. */\nfunction firstMissingTableSubField(field: FieldSpec, rows: TableRowDraft[] | undefined): string | null {\n if (field.type !== \"table\" || !rows) return null;\n for (let rowIdx = 0; rowIdx < rows.length; rowIdx++) {\n const row = rows[rowIdx];\n for (const [subKey, subField] of Object.entries(field.of)) {\n if (!subField.required || subField.type === \"boolean\") continue;\n if (isMissingDraftValue(row.text[subKey])) return `${field.label} #${rowIdx + 1}: ${subField.label}`;\n }\n }\n return null;\n}\n\n/** Field types the required check never flags: booleans always hold a\n * value, and the computed/projected kinds (COMPUTED_TYPES — the shared\n * set, so a future computed type can't drift past this check) have no\n * draft input at all. */\nconst NEVER_MISSING_TYPES: ReadonlySet<FieldType> = new Set<FieldType>([\"boolean\", ...COMPUTED_TYPES]);\n\nfunction validateOneField(key: string, field: FieldSpec, draft: EditState, record: CollectionItem): string | null {\n // A `when`-hidden field has no input the user can fill — never missing.\n if (!fieldVisible(field, record)) return null;\n if (field.type === \"table\" && field.of) {\n const rows = draft.table[key];\n if (field.required && (!rows || rows.length === 0)) return field.label;\n return firstMissingTableSubField(field, rows);\n }\n if (!field.required) return null;\n if (draft.mode === \"create\" && field.primary === true) return null; // server auto-generates id\n if (NEVER_MISSING_TYPES.has(field.type)) return null;\n return isMissingDraftValue(draft.text[key]) ? field.label : null;\n}\n\n/** Human-readable label of the first missing required field, or null. */\nexport function firstMissingRequiredField(draft: EditState, schema: CollectionSchema): string | null {\n const record = draftToRecord(draft, schema);\n for (const [key, field] of Object.entries(schema.fields)) {\n const missing = validateOneField(key, field, draft, record);\n if (missing) return missing;\n }\n return null;\n}\n","// Sorting for the collection list table. The header sort toggle (next to\n// each field title) cycles a single active column through none → asc →\n// desc → none; this module turns that state plus a per-field value\n// extractor into an ordered copy of the rows.\n//\n// Two invariants the comparator guarantees:\n// 1. Rows with an empty/missing value for the sorted field always sink\n// to the bottom, regardless of direction.\n// 2. Ties (and the empty group) keep their original order — the sort is\n// stable via the captured source index.\n//\n// Field-type → comparable mapping (see `isSortableField`):\n// string/text/email → string · number/money → numeric ·\n// date/datetime → epoch-ms · enum → declared-index · boolean/toggle →\n// false<true · ref → display label · derived → its display type.\n// markdown/table/image/file/embed get no sort button.\n\nimport type { CollectionItem, CollectionFieldSpec, CollectionFieldType } from \"./schema\";\n\nexport type SortDirection = \"asc\" | \"desc\";\n\nexport interface SortState {\n /** Field key of the single active sort column. */\n field: string;\n direction: SortDirection;\n}\n\n/** A row's comparable value for the active field. Exactly one of `num` /\n * `str` is set when not empty; `empty` rows always sort last. */\nexport interface SortValue {\n empty: boolean;\n num?: number;\n str?: string;\n}\n\nconst EMPTY: SortValue = { empty: true };\n\n/** Field types that render no value text in the table, so offer no sort. */\nconst NON_SORTABLE: ReadonlySet<CollectionFieldType> = new Set<CollectionFieldType>([\"markdown\", \"table\", \"image\", \"file\", \"embed\", \"backlinks\", \"rollup\"]);\n\nexport function isSortableField(field: CollectionFieldSpec): boolean {\n return !NON_SORTABLE.has(field.type);\n}\n\n/** Cycle one column's state: none → asc → desc → none. */\nexport function nextSortDirection(current: SortDirection | null): SortDirection | null {\n if (current === null) return \"asc\";\n if (current === \"asc\") return \"desc\";\n return null;\n}\n\n// ── SortValue constructors (one per comparable kind) ────────────────\n\nexport function numericSortValue(raw: unknown): SortValue {\n if (raw == null || raw === \"\") return EMPTY;\n const num = typeof raw === \"number\" ? raw : Number(raw);\n return Number.isFinite(num) ? { empty: false, num } : EMPTY;\n}\n\nexport function stringSortValue(raw: unknown): SortValue {\n if (raw == null) return EMPTY;\n const str = String(raw);\n return str.trim() === \"\" ? EMPTY : { empty: false, str };\n}\n\nexport function dateSortValue(raw: unknown): SortValue {\n if (raw == null || raw === \"\") return EMPTY;\n const epoch = Date.parse(String(raw));\n // Unparseable dates fall back to a lexical compare rather than vanishing.\n return Number.isNaN(epoch) ? stringSortValue(raw) : { empty: false, num: epoch };\n}\n\n/** Enum sorts by the value's index in the declared `values` list. A value\n * outside the list (or unset) is treated as empty → last. */\nexport function enumSortValue(values: readonly string[] | undefined, raw: unknown): SortValue {\n if (raw == null || raw === \"\") return EMPTY;\n const idx = values ? values.indexOf(String(raw)) : -1;\n return idx < 0 ? EMPTY : { empty: false, num: idx };\n}\n\n/** Boolean / toggle: false < true, never empty (unset reads as false). */\nexport function boolSortValue(checked: boolean): SortValue {\n return { empty: false, num: checked ? 1 : 0 };\n}\n\n// ── Comparator + driver ─────────────────────────────────────────────\n\nexport function compareSortValues(left: SortValue, right: SortValue): number {\n if (left.num !== undefined && right.num !== undefined) return left.num - right.num;\n const leftStr = left.str ?? String(left.num ?? \"\");\n const rightStr = right.str ?? String(right.num ?? \"\");\n return leftStr.localeCompare(rightStr);\n}\n\n/** Stable sort of `items` by `valueOf`. Empties always last; ties hold\n * source order. Returns a new array (does not mutate `items`). */\nexport function sortItems(items: readonly CollectionItem[], direction: SortDirection, valueOf: (item: CollectionItem) => SortValue): CollectionItem[] {\n const dir = direction === \"asc\" ? 1 : -1;\n return items\n .map((item, index) => ({ item, index, sv: valueOf(item) }))\n .sort((left, right) => {\n if (left.sv.empty || right.sv.empty) {\n if (left.sv.empty && right.sv.empty) return left.index - right.index;\n return left.sv.empty ? 1 : -1;\n }\n const base = compareSortValues(left.sv, right.sv);\n return base !== 0 ? base * dir : left.index - right.index;\n })\n .map((decorated) => decorated.item);\n}\n","// Shared chip/label resolution for the collection calendar surfaces (month\n// grid + day view), so both label a record identically. Pure, type-only\n// dependency on the schema shape.\n\nimport type { CollectionItem, CollectionSchema } from \"./schema\";\n\n// Text-like field types that make a sensible human-readable label.\nconst LABEL_FIELD_TYPES = new Set([\"string\", \"text\", \"markdown\", \"email\"]);\n\n/** Which field labels a record: the schema's explicit `displayField`, else the\n * first non-primary text-like field (so a collection without a displayField\n * shows e.g. the title rather than the opaque primaryKey), else null → the\n * caller falls back to the primary-key value. */\nexport function labelFieldFor(schema: CollectionSchema): string | null {\n if (schema.displayField) return schema.displayField;\n for (const [key, spec] of Object.entries(schema.fields)) {\n if (key !== schema.primaryKey && LABEL_FIELD_TYPES.has(spec.type)) return key;\n }\n return null;\n}\n\n/** A record's primary-key value as a string. */\nexport function itemIdOf(item: CollectionItem, schema: CollectionSchema): string {\n return String(item[schema.primaryKey] ?? \"\");\n}\n\n/** A record's display label: the resolved `labelField` value, else the\n * primary key. Pass the result of `labelFieldFor(schema)` as `labelField`\n * (compute it once per render rather than per item). */\nexport function itemLabelOf(item: CollectionItem, schema: CollectionSchema, labelField: string | null): string {\n if (labelField) {\n const value = item[labelField];\n // Accept any primitive (string / number / boolean) so a numeric or boolean\n // display field still labels the record; objects/arrays fall through to the\n // id rather than rendering as \"[object Object]\".\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n const text = String(value);\n if (text.length > 0) return text;\n }\n }\n return itemIdOf(item, schema);\n}\n","/**\n * 8-char hex id — short, slug-safe, and editable. Produces the same id *shape*\n * as the server's `generateItemId()` (8 hex chars) so a UI-created collection\n * record looks like one the server would have generated for a form submitted\n * with a blank primary key. The source of randomness differs (UUID-derived here\n * vs `randomBytes` on the server); only the shape is intentionally shared.\n */\nexport function shortHexId(): string {\n return crypto.randomUUID().replace(/-/g, \"\").slice(0, 8);\n}\n"],"mappings":";;;;AAUA,IAAa,YAAY;AAazB,IAAa,kBAAkC;CAC7C,MAAM;CACN,MAAM;CACN,aACE;CACF,YAAY;EACV,MAAM;EACN,YAAY;GACV,gBAAgB;IACd,MAAM;IACN,aAAa;GACf;GACA,QAAQ;IACN,MAAM;IACN,aAAa;GACf;EACF;EACA,UAAU,CAAC,gBAAgB;CAC7B;CACA,QAAQ,0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CAAC,CAC1D,MAAM,MAAM,UAAU;EACrB,IAAI,KAAK,GAAG,SAAS,MAAM,GAAG,OAAO;GACnC,IAAI,KAAK,GAAG,SAAS,MAAM,GAAG,OAAO,OAAO,KAAK,QAAQ,MAAM;GAC/D,OAAO,KAAK,GAAG,QAAQ,IAAI;EAC7B;EACA,MAAM,OAAO,kBAAkB,KAAK,IAAI,MAAM,EAAE;EAChD,OAAO,SAAS,IAAI,OAAO,MAAM,KAAK,QAAQ,MAAM;CACtD,CAAC,CAAC,CACD,KAAK,cAAc,UAAU,IAAI;AACtC;;;ACtGA,IAAM,oCAAoB,IAAI,IAAI;CAAC;CAAU;CAAQ;CAAY;AAAO,CAAC;;;;;AAMzE,SAAgB,cAAc,QAAyC;CACrE,IAAI,OAAO,cAAc,OAAO,OAAO;CACvC,KAAK,MAAM,CAAC,KAAK,SAAS,OAAO,QAAQ,OAAO,MAAM,GACpD,IAAI,QAAQ,OAAO,cAAc,kBAAkB,IAAI,KAAK,IAAI,GAAG,OAAO;CAE5E,OAAO;AACT;;AAGA,SAAgB,SAAS,MAAsB,QAAkC;CAC/E,OAAO,OAAO,KAAK,OAAO,eAAe,EAAE;AAC7C;;;;AAKA,SAAgB,YAAY,MAAsB,QAA0B,YAAmC;CAC7G,IAAI,YAAY;EACd,MAAM,QAAQ,KAAK;EAInB,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW;GACxF,MAAM,OAAO,OAAO,KAAK;GACzB,IAAI,KAAK,SAAS,GAAG,OAAO;EAC9B;CACF;CACA,OAAO,SAAS,MAAM,MAAM;AAC9B;;;;;;;;;;AClCA,SAAgB,aAAqB;CACnC,OAAO,OAAO,WAAW,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AACzD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/collection/core/presentCollection.ts","../../src/collection/core/enumColors.ts","../../src/collection/core/draft.ts","../../src/collection/core/sortItems.ts","../../src/collection/core/itemLabel.ts","../../src/collection/core/shortHexId.ts"],"sourcesContent":["// presentCollection tool — definition + pure server-side executor.\n//\n// Isomorphic (no Vue, no Node): bundled to the browser as the plugin's\n// `execute`, and run server-side via the host's plugin dispatch route. The\n// executor only validates + echoes the addressing; the live schema + items\n// are fetched client-side by the View through the host's /api/collections\n// routes, so a bad slug surfaces as the View's \"not found\" state.\n\nimport type { ToolContext, ToolDefinition, ToolResult } from \"gui-chat-protocol\";\n\nexport const TOOL_NAME = \"presentCollection\";\n\n/** Render payload carried in the tool result's `data` field; the View mounts\n * off these. Same shape as the tool args. */\nexport interface PresentCollectionData {\n /** Slug of the collection to display (e.g. \"clients\", \"invoices\"). */\n collectionSlug: string;\n /** Optional primary-key value of a single item to open on mount. */\n itemId?: string;\n}\n\nexport type PresentCollectionArgs = PresentCollectionData;\n\nexport const TOOL_DEFINITION: ToolDefinition = {\n type: \"function\",\n name: TOOL_NAME,\n description:\n \"Display a schema-driven collection inline in the chat as an interactive, editable card. Shows the collection's list of records. Pass `itemId` to open one specific record on mount.\",\n parameters: {\n type: \"object\",\n properties: {\n collectionSlug: {\n type: \"string\",\n description: \"The slug of the collection to display (e.g. 'clients', 'invoices', 'contacts').\",\n },\n itemId: {\n type: \"string\",\n description: \"Optional primary-key value of a single record to open in detail view on mount. Omit to show the full list.\",\n },\n },\n required: [\"collectionSlug\"],\n },\n prompt: `After making changes to schema-driven collections, use ${TOOL_NAME} to present either the collection or the item`,\n};\n\nexport const executePresentCollection = async (\n _context: ToolContext,\n args: PresentCollectionArgs,\n): Promise<ToolResult<PresentCollectionData, PresentCollectionData>> => {\n const collectionSlug = typeof args?.collectionSlug === \"string\" ? args.collectionSlug.trim() : \"\";\n if (!collectionSlug) {\n return {\n message: \"presentCollection error: collectionSlug is required\",\n instructions: \"Tell the user you couldn't display the collection because no collection was specified, and ask which collection they mean.\",\n };\n }\n const itemId = typeof args.itemId === \"string\" && args.itemId.trim().length > 0 ? args.itemId.trim() : undefined;\n const data: PresentCollectionData = itemId ? { collectionSlug, itemId } : { collectionSlug };\n const target = itemId ? `${collectionSlug} / ${itemId}` : collectionSlug;\n return {\n message: `Presented collection ${target}`,\n // `data` is the view's source (also the host's render-eligibility signal);\n // `jsonData` is what the LLM sees. Same payload, two audiences.\n data,\n jsonData: data,\n // Phrased to stay correct for BOTH storage kinds without loading the\n // schema (this executor is deliberately pure/isomorphic): a writable\n // collection offers edit/create/delete in the card; a read-only\n // `dataSource` collection hides those and changes flow through its\n // data file instead.\n instructions:\n \"The collection has been presented to the user as an interactive card. They can browse and open records directly; on a writable collection they can also edit, create, and delete (a read-only dataSource collection shows no edit controls — its records change by editing the backing data file). No further action is needed unless they ask.\",\n };\n};\n","// A standard, ordered colour palette for `enum` field values, shared by every\n// collection surface (list, calendar, kanban). Each value in an\n// enum's `values` array is assigned the palette entry at its index — cycling\n// when an enum declares more values than the palette holds — so colouring is\n// automatic and consistent without any per-value schema config.\n//\n// Tailwind only detects class names that appear as complete string literals,\n// so every surface's classes are spelled out per colour below rather than\n// built from a colour name at runtime.\n//\n// One enum is special: the field a schema's `notifyWhen` targets (the\n// \"notification enum\"). Its flagged values read the notification severity\n// colours — the first flagged value (most urgent) red, the rest amber — and\n// every other value reads neutral grey, mirroring the notification bell\n// (red = urgent, amber = nudge) rather than the rotating palette.\n// `resolveEnumColor` encapsulates that rule.\n\nimport type { CollectionSchema } from \"./schema\";\n\nexport interface EnumColorClasses {\n /** Stat-card style: border + fill + text + hover. */\n card: string;\n /** Small status dot (kanban column header). */\n dot: string;\n /** Pill / badge / inline `<select>` fill + text (no border width). */\n badge: string;\n /** Border colour, paired with a `border` width class by the caller. */\n border: string;\n}\n\n// The palette deliberately EXCLUDES the warm warning band (red / orange /\n// amber): those are reserved for the notification-enum severity colours\n// (`ENUM_ALERT` red, `ENUM_NUDGE` amber), so a normal enum value can never\n// draw a colour that reads like a notification. Eight well-separated cool /\n// green / magenta hues keep enough variety for wide enums.\nconst PALETTE: readonly EnumColorClasses[] = [\n {\n card: \"border-indigo-200 bg-indigo-50 text-indigo-600 hover:bg-indigo-100\",\n dot: \"bg-indigo-500\",\n badge: \"bg-indigo-100 text-indigo-700\",\n border: \"border-indigo-200\",\n },\n { card: \"border-sky-200 bg-sky-50 text-sky-600 hover:bg-sky-100\", dot: \"bg-sky-500\", badge: \"bg-sky-100 text-sky-700\", border: \"border-sky-200\" },\n { card: \"border-cyan-200 bg-cyan-50 text-cyan-600 hover:bg-cyan-100\", dot: \"bg-cyan-500\", badge: \"bg-cyan-100 text-cyan-700\", border: \"border-cyan-200\" },\n { card: \"border-teal-200 bg-teal-50 text-teal-600 hover:bg-teal-100\", dot: \"bg-teal-500\", badge: \"bg-teal-100 text-teal-700\", border: \"border-teal-200\" },\n {\n card: \"border-emerald-200 bg-emerald-50 text-emerald-600 hover:bg-emerald-100\",\n dot: \"bg-emerald-500\",\n badge: \"bg-emerald-100 text-emerald-700\",\n border: \"border-emerald-200\",\n },\n { card: \"border-lime-200 bg-lime-50 text-lime-600 hover:bg-lime-100\", dot: \"bg-lime-500\", badge: \"bg-lime-100 text-lime-700\", border: \"border-lime-200\" },\n {\n card: \"border-violet-200 bg-violet-50 text-violet-600 hover:bg-violet-100\",\n dot: \"bg-violet-500\",\n badge: \"bg-violet-100 text-violet-700\",\n border: \"border-violet-200\",\n },\n {\n card: \"border-fuchsia-200 bg-fuchsia-50 text-fuchsia-600 hover:bg-fuchsia-100\",\n dot: \"bg-fuchsia-500\",\n badge: \"bg-fuchsia-100 text-fuchsia-700\",\n border: \"border-fuchsia-200\",\n },\n];\n\n/** Neutral styling for the empty / Uncategorized bucket — never a palette\n * colour, so an unset or unknown value reads grey across every surface. */\nexport const ENUM_NEUTRAL: EnumColorClasses = {\n card: \"border-slate-200 bg-slate-50 text-slate-500 hover:bg-slate-100\",\n dot: \"bg-slate-300\",\n badge: \"bg-slate-100 text-slate-500\",\n border: \"border-slate-200\",\n};\n\n/** The urgent notification colour (red), matching the bell's `urgent`\n * severity. The first value a schema's `notifyWhen` flags reads this. */\nexport const ENUM_ALERT: EnumColorClasses = {\n card: \"border-red-200 bg-red-50 text-red-600 hover:bg-red-100\",\n dot: \"bg-red-500\",\n badge: \"bg-red-100 text-red-700\",\n border: \"border-red-200\",\n};\n\n/** The nudge notification colour (amber), matching the bell's `nudge`\n * severity. Flagged `notifyWhen` values after the first read this. */\nexport const ENUM_NUDGE: EnumColorClasses = {\n card: \"border-amber-200 bg-amber-50 text-amber-600 hover:bg-amber-100\",\n dot: \"bg-amber-500\",\n badge: \"bg-amber-100 text-amber-700\",\n border: \"border-amber-200\",\n};\n\n/** Classes for the enum value at `index` in its field's `values` array. A\n * negative index (value unset or not among the declared values) reads\n * neutral. */\nexport function enumColorClasses(index: number): EnumColorClasses {\n if (index < 0) return ENUM_NEUTRAL;\n return PALETTE[index % PALETTE.length] ?? ENUM_NEUTRAL;\n}\n\n/** Index of `value` within an enum field's declared `values`, or -1 when the\n * value is empty / unknown (→ neutral). */\nexport function enumValueIndex(values: readonly string[] | undefined, value: unknown): number {\n if (value === undefined || value === null || value === \"\") return -1;\n return values?.indexOf(String(value)) ?? -1;\n}\n\n/** The flagged values when `fieldKey` is the schema's `notifyWhen` target (the\n * \"notification enum\"); undefined for every other field. */\nfunction notifyValuesFor(schema: CollectionSchema, fieldKey: string): readonly string[] | undefined {\n const spec = schema.notifyWhen;\n return spec && spec.field === fieldKey ? spec.in : undefined;\n}\n\n/** Resolve a value's colour for enum field `fieldKey`:\n * - Notification enum (`notifyWhen` targets it): the first flagged value (in\n * `notifyWhen.in` order, the most urgent) reads notification red, the rest\n * amber, and every non-flagged value neutral grey.\n * - Any other enum: the standard palette by the value's declared index. */\nexport function resolveEnumColor(schema: CollectionSchema, fieldKey: string, value: unknown): EnumColorClasses {\n const notifyValues = notifyValuesFor(schema, fieldKey);\n if (notifyValues) {\n const str = value === undefined || value === null ? \"\" : String(value);\n const rank = notifyValues.indexOf(str);\n if (rank < 0) return ENUM_NEUTRAL;\n return rank === 0 ? ENUM_ALERT : ENUM_NUDGE;\n }\n const spec = schema.fields[fieldKey];\n return enumColorClasses(enumValueIndex(spec?.type === \"enum\" ? spec.values : undefined, value));\n}\n","// Pure edit-draft logic for the collection record form, extracted from\n// CollectionView.vue so the parent (build draft / save / validate) and\n// the extracted CollectionRecordPanel (per-row table mutators) share one\n// implementation. No Vue, no I/O — every function maps a draft + schema\n// to a value, so the omission/validation semantics are unit-testable.\n\nimport { fieldVisible } from \"./actionVisible\";\nimport { COMPUTED_TYPES } from \"./schema\";\nimport type { CollectionFieldSpec as FieldSpec, CollectionFieldType as FieldType, CollectionItem, CollectionSchema } from \"./schema\";\nimport type { EditState, TableRowDraft } from \"./uiTypes\";\n\n/** A fresh, empty row draft for a `table` field's sub-schema. */\nexport function emptyRow(subFields: Record<string, FieldSpec>): TableRowDraft {\n const text: Record<string, string> = {};\n const bool: Record<string, boolean> = {};\n const boolOriginallyPresent: Record<string, boolean> = {};\n const boolTouched: Record<string, boolean> = {};\n for (const [subKey, subField] of Object.entries(subFields)) {\n if (subField.type === \"boolean\") {\n bool[subKey] = false;\n boolOriginallyPresent[subKey] = false; // brand-new row\n boolTouched[subKey] = false;\n } else {\n text[subKey] = \"\";\n }\n }\n return { text, bool, boolOriginallyPresent, boolTouched };\n}\n\n/** Build a row draft from an existing persisted row. */\nexport function rowFromItem(item: Record<string, unknown>, subFields: Record<string, FieldSpec>): TableRowDraft {\n const text: Record<string, string> = {};\n const bool: Record<string, boolean> = {};\n const boolOriginallyPresent: Record<string, boolean> = {};\n const boolTouched: Record<string, boolean> = {};\n for (const [subKey, subField] of Object.entries(subFields)) {\n const raw = item[subKey];\n if (subField.type === \"boolean\") {\n bool[subKey] = raw === true;\n // `typeof raw === \"boolean\"` so an existing explicit `false` is\n // recorded as present and round-trips on a no-op save.\n boolOriginallyPresent[subKey] = typeof raw === \"boolean\";\n boolTouched[subKey] = false;\n } else {\n text[subKey] = raw === undefined || raw === null ? \"\" : String(raw);\n }\n }\n return { text, bool, boolOriginallyPresent, boolTouched };\n}\n\n/** Decide whether a boolean field's draft value should be emitted (vs.\n * omitted so a downstream default applies). */\nfunction shouldEmitBoolean(state: EditState, key: string, field: FieldSpec): boolean {\n return Boolean(state.boolOriginallyPresent[key] || state.boolTouched[key] || field.required);\n}\n\n/** Convert a scalar draft slot to its persisted form. `undefined` = omit. */\nfunction scalarDraftToValue(raw: string | undefined, fieldType: FieldType): unknown {\n if (raw === undefined || raw === \"\") return undefined;\n if (fieldType === \"number\" || fieldType === \"money\") {\n const num = Number(raw);\n return Number.isFinite(num) ? num : raw;\n }\n return raw;\n}\n\n/** Convert one table row draft to its persisted record. */\nfunction rowDraftToRecord(rowDraft: TableRowDraft, subFields: Record<string, FieldSpec>): Record<string, unknown> {\n const row: Record<string, unknown> = {};\n for (const [subKey, subField] of Object.entries(subFields)) {\n if (subField.type === \"boolean\") {\n const value = rowDraft.bool[subKey] === true;\n if (rowDraft.boolOriginallyPresent[subKey] || rowDraft.boolTouched[subKey] || value || subField.required) row[subKey] = value;\n continue;\n }\n const value = scalarDraftToValue(rowDraft.text[subKey], subField.type);\n if (value !== undefined) row[subKey] = value;\n }\n return row;\n}\n\n/** Convert a full edit draft to the record to persist. */\nexport function draftToRecord(state: EditState, schema: CollectionSchema): CollectionItem {\n const record: CollectionItem = {};\n for (const [key, field] of Object.entries(schema.fields)) {\n if (COMPUTED_TYPES.has(field.type)) continue; // never persisted (toggle projects an enum field)\n if (field.type === \"boolean\") {\n if (shouldEmitBoolean(state, key, field)) record[key] = state.bool[key] === true;\n continue;\n }\n if (field.type === \"table\" && field.of) {\n const subFields = field.of;\n record[key] = (state.table[key] ?? []).map((rowDraft) => rowDraftToRecord(rowDraft, subFields));\n continue;\n }\n const value = scalarDraftToValue(state.text[key], field.type);\n if (value !== undefined) record[key] = value;\n }\n return record;\n}\n\n/** Normalise a raw inline-edit input (table-cell checkbox/select) to its\n * persisted form. Mirrors `draftToRecord`'s boolean strictness; an empty\n * enum selection (the placeholder option) clears the field via `undefined`. */\nexport function coerceInlineValue(field: FieldSpec, raw: boolean | string): unknown {\n if (field.type === \"boolean\") return raw === true;\n return raw === \"\" ? undefined : raw;\n}\n\n/** Build the full record to PUT for a single-cell inline edit, without\n * mutating `item`. A `undefined` value omits the key (enum cleared),\n * matching `draftToRecord`'s omission semantics. */\nexport function buildUpdatedRecord(item: CollectionItem, key: string, value: unknown): CollectionItem {\n if (value === undefined) {\n const { [key]: __omit, ...rest } = item;\n return rest;\n }\n return { ...item, [key]: value };\n}\n\n/** Empty for required-field validation — NOT a truthiness check (a\n * numeric `0` is a filled value). */\nfunction isMissingDraftValue(value: unknown): boolean {\n return value === undefined || value === null || value === \"\";\n}\n\n/** Label of the first required table sub-field empty in any row, else null. */\nfunction firstMissingTableSubField(field: FieldSpec, rows: TableRowDraft[] | undefined): string | null {\n if (field.type !== \"table\" || !rows) return null;\n for (let rowIdx = 0; rowIdx < rows.length; rowIdx++) {\n const row = rows[rowIdx];\n for (const [subKey, subField] of Object.entries(field.of)) {\n if (!subField.required || subField.type === \"boolean\") continue;\n if (isMissingDraftValue(row.text[subKey])) return `${field.label} #${rowIdx + 1}: ${subField.label}`;\n }\n }\n return null;\n}\n\n/** Field types the required check never flags: booleans always hold a\n * value, and the computed/projected kinds (COMPUTED_TYPES — the shared\n * set, so a future computed type can't drift past this check) have no\n * draft input at all. */\nconst NEVER_MISSING_TYPES: ReadonlySet<FieldType> = new Set<FieldType>([\"boolean\", ...COMPUTED_TYPES]);\n\nfunction validateOneField(key: string, field: FieldSpec, draft: EditState, record: CollectionItem): string | null {\n // A `when`-hidden field has no input the user can fill — never missing.\n if (!fieldVisible(field, record)) return null;\n if (field.type === \"table\" && field.of) {\n const rows = draft.table[key];\n if (field.required && (!rows || rows.length === 0)) return field.label;\n return firstMissingTableSubField(field, rows);\n }\n if (!field.required) return null;\n if (draft.mode === \"create\" && field.primary === true) return null; // server auto-generates id\n if (NEVER_MISSING_TYPES.has(field.type)) return null;\n return isMissingDraftValue(draft.text[key]) ? field.label : null;\n}\n\n/** Human-readable label of the first missing required field, or null. */\nexport function firstMissingRequiredField(draft: EditState, schema: CollectionSchema): string | null {\n const record = draftToRecord(draft, schema);\n for (const [key, field] of Object.entries(schema.fields)) {\n const missing = validateOneField(key, field, draft, record);\n if (missing) return missing;\n }\n return null;\n}\n","// Sorting for the collection list table. The header sort toggle (next to\n// each field title) cycles a single active column through none → asc →\n// desc → none; this module turns that state plus a per-field value\n// extractor into an ordered copy of the rows.\n//\n// Two invariants the comparator guarantees:\n// 1. Rows with an empty/missing value for the sorted field always sink\n// to the bottom, regardless of direction.\n// 2. Ties (and the empty group) keep their original order — the sort is\n// stable via the captured source index.\n//\n// Field-type → comparable mapping (see `isSortableField`):\n// string/text/email → string · number/money → numeric ·\n// date/datetime → epoch-ms · enum → declared-index · boolean/toggle →\n// false<true · ref → display label · derived → its display type.\n// markdown/table/image/file/embed get no sort button.\n\nimport type { CollectionItem, CollectionFieldSpec, CollectionFieldType } from \"./schema\";\n\nexport type SortDirection = \"asc\" | \"desc\";\n\nexport interface SortState {\n /** Field key of the single active sort column. */\n field: string;\n direction: SortDirection;\n}\n\n/** A row's comparable value for the active field. Exactly one of `num` /\n * `str` is set when not empty; `empty` rows always sort last. */\nexport interface SortValue {\n empty: boolean;\n num?: number;\n str?: string;\n}\n\nconst EMPTY: SortValue = { empty: true };\n\n/** Field types that render no value text in the table, so offer no sort. */\nconst NON_SORTABLE: ReadonlySet<CollectionFieldType> = new Set<CollectionFieldType>([\"markdown\", \"table\", \"image\", \"file\", \"embed\", \"backlinks\", \"rollup\"]);\n\nexport function isSortableField(field: CollectionFieldSpec): boolean {\n return !NON_SORTABLE.has(field.type);\n}\n\n/** Cycle one column's state: none → asc → desc → none. */\nexport function nextSortDirection(current: SortDirection | null): SortDirection | null {\n if (current === null) return \"asc\";\n if (current === \"asc\") return \"desc\";\n return null;\n}\n\n// ── SortValue constructors (one per comparable kind) ────────────────\n\nexport function numericSortValue(raw: unknown): SortValue {\n if (raw == null || raw === \"\") return EMPTY;\n const num = typeof raw === \"number\" ? raw : Number(raw);\n return Number.isFinite(num) ? { empty: false, num } : EMPTY;\n}\n\nexport function stringSortValue(raw: unknown): SortValue {\n if (raw == null) return EMPTY;\n const str = String(raw);\n return str.trim() === \"\" ? EMPTY : { empty: false, str };\n}\n\nexport function dateSortValue(raw: unknown): SortValue {\n if (raw == null || raw === \"\") return EMPTY;\n const epoch = Date.parse(String(raw));\n // Unparseable dates fall back to a lexical compare rather than vanishing.\n return Number.isNaN(epoch) ? stringSortValue(raw) : { empty: false, num: epoch };\n}\n\n/** Enum sorts by the value's index in the declared `values` list. A value\n * outside the list (or unset) is treated as empty → last. */\nexport function enumSortValue(values: readonly string[] | undefined, raw: unknown): SortValue {\n if (raw == null || raw === \"\") return EMPTY;\n const idx = values ? values.indexOf(String(raw)) : -1;\n return idx < 0 ? EMPTY : { empty: false, num: idx };\n}\n\n/** Boolean / toggle: false < true, never empty (unset reads as false). */\nexport function boolSortValue(checked: boolean): SortValue {\n return { empty: false, num: checked ? 1 : 0 };\n}\n\n// ── Comparator + driver ─────────────────────────────────────────────\n\nexport function compareSortValues(left: SortValue, right: SortValue): number {\n if (left.num !== undefined && right.num !== undefined) return left.num - right.num;\n const leftStr = left.str ?? String(left.num ?? \"\");\n const rightStr = right.str ?? String(right.num ?? \"\");\n return leftStr.localeCompare(rightStr);\n}\n\n/** Stable sort of `items` by `valueOf`. Empties always last; ties hold\n * source order. Returns a new array (does not mutate `items`). */\nexport function sortItems(items: readonly CollectionItem[], direction: SortDirection, valueOf: (item: CollectionItem) => SortValue): CollectionItem[] {\n const dir = direction === \"asc\" ? 1 : -1;\n return items\n .map((item, index) => ({ item, index, sv: valueOf(item) }))\n .sort((left, right) => {\n if (left.sv.empty || right.sv.empty) {\n if (left.sv.empty && right.sv.empty) return left.index - right.index;\n return left.sv.empty ? 1 : -1;\n }\n const base = compareSortValues(left.sv, right.sv);\n return base !== 0 ? base * dir : left.index - right.index;\n })\n .map((decorated) => decorated.item);\n}\n","// Shared chip/label resolution for the collection calendar surfaces (month\n// grid + day view), so both label a record identically. Pure, type-only\n// dependency on the schema shape.\n\nimport type { CollectionItem, CollectionSchema } from \"./schema\";\n\n// Text-like field types that make a sensible human-readable label.\nconst LABEL_FIELD_TYPES = new Set([\"string\", \"text\", \"markdown\", \"email\"]);\n\n/** Which field labels a record: the schema's explicit `displayField`, else the\n * first non-primary text-like field (so a collection without a displayField\n * shows e.g. the title rather than the opaque primaryKey), else null → the\n * caller falls back to the primary-key value. */\nexport function labelFieldFor(schema: CollectionSchema): string | null {\n if (schema.displayField) return schema.displayField;\n for (const [key, spec] of Object.entries(schema.fields)) {\n if (key !== schema.primaryKey && LABEL_FIELD_TYPES.has(spec.type)) return key;\n }\n return null;\n}\n\n/** A record's primary-key value as a string. */\nexport function itemIdOf(item: CollectionItem, schema: CollectionSchema): string {\n return String(item[schema.primaryKey] ?? \"\");\n}\n\n/** A record's display label: the resolved `labelField` value, else the\n * primary key. Pass the result of `labelFieldFor(schema)` as `labelField`\n * (compute it once per render rather than per item). */\nexport function itemLabelOf(item: CollectionItem, schema: CollectionSchema, labelField: string | null): string {\n if (labelField) {\n const value = item[labelField];\n // Accept any primitive (string / number / boolean) so a numeric or boolean\n // display field still labels the record; objects/arrays fall through to the\n // id rather than rendering as \"[object Object]\".\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n const text = String(value);\n if (text.length > 0) return text;\n }\n }\n return itemIdOf(item, schema);\n}\n","/**\n * 8-char hex id — short, slug-safe, and editable. Produces the same id *shape*\n * as the server's `generateItemId()` (8 hex chars) so a UI-created collection\n * record looks like one the server would have generated for a form submitted\n * with a blank primary key. The source of randomness differs (UUID-derived here\n * vs `randomBytes` on the server); only the shape is intentionally shared.\n */\nexport function shortHexId(): string {\n return crypto.randomUUID().replace(/-/g, \"\").slice(0, 8);\n}\n"],"mappings":";;;;AAUA,IAAa,YAAY;AAazB,IAAa,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AqB;CACnC,OAAO,OAAO,WAAW,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AACzD"}
|
package/dist/collection/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as whenMatches, B as isFieldDrivenEvery, C as backlinkRows, D as actionVisible, E as rollupValue, F as AGENT_INGEST_KIND, I as COMPUTED_TYPES, L as FEED_SCHEDULES, M as SAFE_SLUG_PATTERN, N as isSafeRecordId, O as agentActionRunKey, P as isSafeSlug, R as INGEST_KINDS, S as matchesWhere, T as projectBacklinkRow, _ as resolveRowRefs, a as buildMonthGrid, b as resolveIcon, c as daySlice, d as parseIsoDateTime, f as parseTimeRange, g as deriveAll, h as ymdKey, i as bucketRecords, j as SAFE_RECORD_ID_PATTERN, k as fieldVisible, l as monthAnchorDate, m as spanCoversDay, n as MINUTES_PER_DAY, o as compareYmd, p as recordSpan, r as assignLanes, s as dateOf, t as defangForPrompt, u as parseIsoDate, v as evaluateDerived, w as coerceNumeric, x as selectDynamicRecord, y as firstDateField, z as embedTargetId } from "../promptSafety-
|
|
1
|
+
import { A as whenMatches, B as isFieldDrivenEvery, C as backlinkRows, D as actionVisible, E as rollupValue, F as AGENT_INGEST_KIND, I as COMPUTED_TYPES, L as FEED_SCHEDULES, M as SAFE_SLUG_PATTERN, N as isSafeRecordId, O as agentActionRunKey, P as isSafeSlug, R as INGEST_KINDS, S as matchesWhere, T as projectBacklinkRow, V as isReadOnlySchema, _ as resolveRowRefs, a as buildMonthGrid, b as resolveIcon, c as daySlice, d as parseIsoDateTime, f as parseTimeRange, g as deriveAll, h as ymdKey, i as bucketRecords, j as SAFE_RECORD_ID_PATTERN, k as fieldVisible, l as monthAnchorDate, m as spanCoversDay, n as MINUTES_PER_DAY, o as compareYmd, p as recordSpan, r as assignLanes, s as dateOf, t as defangForPrompt, u as parseIsoDate, v as evaluateDerived, w as coerceNumeric, x as selectDynamicRecord, y as firstDateField, z as embedTargetId } from "../promptSafety-rDWA9_JS.js";
|
|
2
2
|
import { t as errorMessage } from "../errorMessage-DIdhheHk.js";
|
|
3
3
|
//#region src/collection/core/presentCollection.ts
|
|
4
4
|
var TOOL_NAME = "presentCollection";
|
|
@@ -37,7 +37,7 @@ var executePresentCollection = async (_context, args) => {
|
|
|
37
37
|
message: `Presented collection ${itemId ? `${collectionSlug} / ${itemId}` : collectionSlug}`,
|
|
38
38
|
data,
|
|
39
39
|
jsonData: data,
|
|
40
|
-
instructions: "The collection has been presented to the user as an interactive card. They can browse
|
|
40
|
+
instructions: "The collection has been presented to the user as an interactive card. They can browse and open records directly; on a writable collection they can also edit, create, and delete (a read-only dataSource collection shows no edit controls — its records change by editing the backing data file). No further action is needed unless they ask."
|
|
41
41
|
};
|
|
42
42
|
};
|
|
43
43
|
//#endregion
|
|
@@ -435,6 +435,6 @@ function shortHexId() {
|
|
|
435
435
|
return crypto.randomUUID().replace(/-/g, "").slice(0, 8);
|
|
436
436
|
}
|
|
437
437
|
//#endregion
|
|
438
|
-
export { AGENT_INGEST_KIND, COMPUTED_TYPES, ENUM_ALERT, ENUM_NEUTRAL, ENUM_NUDGE, FEED_SCHEDULES, INGEST_KINDS, MINUTES_PER_DAY, SAFE_RECORD_ID_PATTERN, SAFE_SLUG_PATTERN, TOOL_DEFINITION, TOOL_NAME, actionVisible, agentActionRunKey, assignLanes, backlinkRows, boolSortValue, bucketRecords, buildMonthGrid, buildUpdatedRecord, coerceInlineValue, coerceNumeric, compareSortValues, compareYmd, dateOf, dateSortValue, daySlice, defangForPrompt, deriveAll, draftToRecord, embedTargetId, emptyRow, enumColorClasses, enumSortValue, enumValueIndex, errorMessage, evaluateDerived, executePresentCollection, fieldVisible, firstDateField, firstMissingRequiredField, isFieldDrivenEvery, isSafeRecordId, isSafeSlug, isSortableField, itemIdOf, itemLabelOf, labelFieldFor, matchesWhere, monthAnchorDate, nextSortDirection, numericSortValue, parseIsoDate, parseIsoDateTime, parseTimeRange, projectBacklinkRow, recordSpan, resolveEnumColor, resolveIcon, resolveRowRefs, rollupValue, rowFromItem, selectDynamicRecord, shortHexId, sortItems, spanCoversDay, stringSortValue, whenMatches, ymdKey };
|
|
438
|
+
export { AGENT_INGEST_KIND, COMPUTED_TYPES, ENUM_ALERT, ENUM_NEUTRAL, ENUM_NUDGE, FEED_SCHEDULES, INGEST_KINDS, MINUTES_PER_DAY, SAFE_RECORD_ID_PATTERN, SAFE_SLUG_PATTERN, TOOL_DEFINITION, TOOL_NAME, actionVisible, agentActionRunKey, assignLanes, backlinkRows, boolSortValue, bucketRecords, buildMonthGrid, buildUpdatedRecord, coerceInlineValue, coerceNumeric, compareSortValues, compareYmd, dateOf, dateSortValue, daySlice, defangForPrompt, deriveAll, draftToRecord, embedTargetId, emptyRow, enumColorClasses, enumSortValue, enumValueIndex, errorMessage, evaluateDerived, executePresentCollection, fieldVisible, firstDateField, firstMissingRequiredField, isFieldDrivenEvery, isReadOnlySchema, isSafeRecordId, isSafeSlug, isSortableField, itemIdOf, itemLabelOf, labelFieldFor, matchesWhere, monthAnchorDate, nextSortDirection, numericSortValue, parseIsoDate, parseIsoDateTime, parseTimeRange, projectBacklinkRow, recordSpan, resolveEnumColor, resolveIcon, resolveRowRefs, rollupValue, rowFromItem, selectDynamicRecord, shortHexId, sortItems, spanCoversDay, stringSortValue, whenMatches, ymdKey };
|
|
439
439
|
|
|
440
440
|
//# sourceMappingURL=index.js.map
|