@mossbear/protocol 0.1.0-alpha.53 → 0.1.0-alpha.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentGuidancePaths.d.ts +1 -1
- package/dist/agentGuidancePaths.js +1 -1
- package/dist/contextKinds.d.ts +93 -74
- package/dist/contextKinds.d.ts.map +1 -1
- package/dist/contextKinds.js +78 -52
- package/dist/contextKinds.js.map +1 -1
- package/dist/contextKinds.test.js +95 -95
- package/dist/contextKinds.test.js.map +1 -1
- package/dist/schemas.d.ts +1106 -33
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +318 -15
- package/dist/schemas.js.map +1 -1
- package/dist/schemas.test.js +107 -22
- package/dist/schemas.test.js.map +1 -1
- package/dist/types.d.ts +3 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/whatSyncs.d.ts +1 -1
- package/package.json +1 -1
|
@@ -79,7 +79,7 @@ export declare function isReservedStatePath(candidate: string): boolean;
|
|
|
79
79
|
* component), so a project item declaring one can never be delivered by
|
|
80
80
|
* `git clone` or `git merge` — which is the only way a project item is supposed
|
|
81
81
|
* to reach a working tree. The one thing left that could write it is
|
|
82
|
-
* `mossbear
|
|
82
|
+
* `mossbear promote`, and the write is not inert: git reads `.git/config` on the
|
|
83
83
|
* next `git status` and runs whatever `core.fsmonitor`, `core.hooksPath` or
|
|
84
84
|
* `core.pager` names, with no commit for anyone to review. A shared bundle is
|
|
85
85
|
* writable by every member of its workspace and by any agent holding a
|
|
@@ -143,7 +143,7 @@ export function isReservedStatePath(candidate) {
|
|
|
143
143
|
* component), so a project item declaring one can never be delivered by
|
|
144
144
|
* `git clone` or `git merge` — which is the only way a project item is supposed
|
|
145
145
|
* to reach a working tree. The one thing left that could write it is
|
|
146
|
-
* `mossbear
|
|
146
|
+
* `mossbear promote`, and the write is not inert: git reads `.git/config` on the
|
|
147
147
|
* next `git status` and runs whatever `core.fsmonitor`, `core.hooksPath` or
|
|
148
148
|
* `core.pager` names, with no commit for anyone to review. A shared bundle is
|
|
149
149
|
* writable by every member of its workspace and by any agent holding a
|
package/dist/contextKinds.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one table the context item-kind narrowings derive from.
|
|
3
3
|
*
|
|
4
|
-
* **Why this file exists.**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* mapping in the items route. Each narrowing had a reason and none of them
|
|
11
|
-
* derived from a shared source, so adding a fourth kind meant editing five
|
|
4
|
+
* **Why this file exists.** What an agent may *read* back
|
|
5
|
+
* (`ContextItemTypeSchema`), what it may *push* (`PushContentTypeSchema`) and
|
|
6
|
+
* what it may *capture* into the inbox (`InboxContentTypeSchema`) are three
|
|
7
|
+
* narrowings of the same question, plus a lossy kind → item-type mapping and a
|
|
8
|
+
* SQL inverse of it in the items route. Each narrowing had a reason and none of
|
|
9
|
+
* them derived from a shared source, so adding a fourth kind meant editing five
|
|
12
10
|
* places and nothing failed if you missed one.
|
|
13
11
|
*
|
|
14
12
|
* Now one row per kind answers all of it declaratively. A new kind is a new row
|
|
@@ -16,131 +14,152 @@
|
|
|
16
14
|
* silently omitted from a narrowing, because no narrowing has its own list any
|
|
17
15
|
* more.
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* separate, deliberate change to that row.
|
|
17
|
+
* `contextKinds.test.ts` pins each derived picklist against a hand-written copy
|
|
18
|
+
* of today's values, so a row edit that would change the wire fails there rather
|
|
19
|
+
* than in a client. Which kinds are pushable and capturable are product
|
|
20
|
+
* decisions this table records; changing one is a separate, deliberate change to
|
|
21
|
+
* that row.
|
|
25
22
|
*/
|
|
26
23
|
/**
|
|
27
|
-
* The
|
|
24
|
+
* The stored kinds that are addressable as context items on the wire.
|
|
28
25
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
26
|
+
* **Keyed on the `(role, format)` pair, and that is the load-bearing part.**
|
|
27
|
+
* A table keyed on `role` alone would quietly hand a
|
|
28
|
+
* **script** — `content` + `code` — both `pushable` and `capturable`, because
|
|
29
|
+
* nothing would separate it from a markdown document. It must not, and the pair
|
|
30
|
+
* is what stops it. This is the one place the two columns have to be read
|
|
31
|
+
* together; splitting a column does not by itself make every consumer
|
|
32
|
+
* single-column.
|
|
33
|
+
*
|
|
34
|
+
* Pairs *not* listed — `guidance`, `criteria`, `content` + `code`, and a row
|
|
35
|
+
* with no role at all — are still stored. They collapse onto
|
|
33
36
|
* {@link DEFAULT_CONTEXT_ITEM_TYPE} when serialized, and
|
|
34
|
-
* {@link
|
|
37
|
+
* {@link kindFilterForItemTypes} is what keeps SQL agreeing with that.
|
|
35
38
|
*
|
|
36
39
|
* Order is the wire order of the derived picklists and is load-bearing for the
|
|
37
40
|
* pin test; append rather than reorder.
|
|
38
41
|
*/
|
|
39
42
|
export declare const CONTEXT_CONTENT_KINDS: readonly [{
|
|
40
|
-
readonly
|
|
43
|
+
readonly itemType: "content";
|
|
44
|
+
readonly role: "content";
|
|
45
|
+
readonly format: "markdown";
|
|
41
46
|
readonly pushable: true;
|
|
42
47
|
readonly capturable: true;
|
|
43
48
|
}, {
|
|
44
|
-
readonly
|
|
45
|
-
readonly
|
|
46
|
-
readonly
|
|
47
|
-
}, {
|
|
48
|
-
readonly contentType: "asset";
|
|
49
|
+
readonly itemType: "asset";
|
|
50
|
+
readonly role: "content";
|
|
51
|
+
readonly format: "binary";
|
|
49
52
|
readonly pushable: true;
|
|
50
53
|
readonly capturable: true;
|
|
51
54
|
}];
|
|
52
55
|
/**
|
|
53
56
|
* The item type of a `guides` row.
|
|
54
57
|
*
|
|
55
|
-
* A guide is not a `
|
|
56
|
-
* why it is named here rather than added to the table above. It is readable as
|
|
58
|
+
* A guide is not a stored `(role, format)` pair at all — it is a different
|
|
59
|
+
* table — which is why it is named here rather than added to the table above. It is readable as
|
|
57
60
|
* an item and deliberately neither pushable nor capturable: `PushContentType`'s
|
|
58
61
|
* doc comment on `PushContentTypeSchema` explains why a create cannot honor it.
|
|
59
62
|
*/
|
|
60
63
|
export declare const GUIDE_ITEM_TYPE = "guide";
|
|
61
64
|
/**
|
|
62
|
-
* What an unlisted
|
|
65
|
+
* What an unlisted pair serializes as.
|
|
63
66
|
*
|
|
64
67
|
* The default arm exists so a stray row — one written before a kind was
|
|
65
68
|
* retired, or by a non-context surface — produces a schema-valid response
|
|
66
69
|
* instead of failing the read. It is what makes the mapping lossy, and so what
|
|
67
|
-
* forces {@link
|
|
70
|
+
* forces {@link kindFilterForItemTypes} to exist.
|
|
68
71
|
*/
|
|
69
|
-
export declare const DEFAULT_CONTEXT_ITEM_TYPE = "
|
|
70
|
-
/** `
|
|
71
|
-
export
|
|
72
|
+
export declare const DEFAULT_CONTEXT_ITEM_TYPE = "content";
|
|
73
|
+
/** A stored `(role, format)` pair, as the table and the filters pass it around. */
|
|
74
|
+
export type ContentKind = {
|
|
75
|
+
role: string | null;
|
|
76
|
+
format: string | null;
|
|
77
|
+
};
|
|
78
|
+
/** Item types a stored kind can serialize as, in wire order. */
|
|
79
|
+
export declare const CONTEXT_CONTENT_TYPES: ("content" | "asset")[];
|
|
72
80
|
/** Item types an agent may read back, in wire order. */
|
|
73
81
|
export declare const CONTEXT_ITEM_TYPES: string[];
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Everything `?types=` parses.
|
|
84
|
+
*
|
|
85
|
+
* The same list a read serializes, now that nothing is accepted under a
|
|
86
|
+
* retired name: `document` was mapped through for one release so a filter
|
|
87
|
+
* written against the old vocabulary returned a superset rather than an
|
|
88
|
+
* empty page, and that window closed with the release that moved the CLI's
|
|
89
|
+
* own vocabulary — the same shape `reference`'s retirement closed under (git
|
|
90
|
+
* history has that window's open and close).
|
|
91
|
+
*/
|
|
92
|
+
export declare const CONTEXT_ITEM_TYPE_FILTER_VALUES: string[];
|
|
93
|
+
/** Values a caller may create with, in wire order. */
|
|
94
|
+
export declare const PUSH_CONTENT_TYPES: ("content" | "asset")[];
|
|
95
|
+
/** Values the inbox may capture. */
|
|
96
|
+
export declare const INBOX_CONTENT_TYPES: ("content" | "asset")[];
|
|
78
97
|
/**
|
|
79
98
|
* Membership kinds in `bundle_items.item_type`.
|
|
80
99
|
*
|
|
81
100
|
* **A different axis from everything above, kept here because it is the other
|
|
82
101
|
* half of "what kind is this item".** `bundle_items.item_type` says which table
|
|
83
|
-
* `item_id` points at (`guides` or `guide_files`); it is not a narrowing of
|
|
84
|
-
*
|
|
102
|
+
* `item_id` points at (`guides` or `guide_files`); it is not a narrowing of the
|
|
103
|
+
* content kinds above, and a new *content* kind must not add a row here. The review
|
|
85
104
|
* that motivated this file counts it among the "five enums over one column"
|
|
86
105
|
* (§2.3) — that count is wrong, and the two axes are named separately below so
|
|
87
106
|
* a later reader does not merge them.
|
|
88
107
|
*/
|
|
89
108
|
export declare const BUNDLE_MEMBER_TYPES: readonly ["guide_file", "guide"];
|
|
90
109
|
/**
|
|
91
|
-
* The item type a stored
|
|
110
|
+
* The item type a stored kind serializes as.
|
|
92
111
|
*
|
|
93
|
-
* Anything unrecognized —
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
112
|
+
* Anything unrecognized — a guidance row, a rubric, a script, an `html` page, a
|
|
113
|
+
* row carrying no role at all — is a {@link DEFAULT_CONTEXT_ITEM_TYPE}, so a
|
|
114
|
+
* stray row never produces a schema-invalid response. That default is what
|
|
115
|
+
* makes this mapping non-injective: the pair cannot be recovered from an item's
|
|
116
|
+
* `type`, which is why filtering by type in SQL needs
|
|
117
|
+
* {@link kindFilterForItemTypes} rather than an inverted lookup.
|
|
98
118
|
*/
|
|
99
|
-
export declare function
|
|
119
|
+
export declare function itemTypeForKind(role: string | null, format: string | null): (typeof CONTEXT_ITEM_TYPES)[number];
|
|
100
120
|
/**
|
|
101
|
-
* How to select the rows whose
|
|
102
|
-
*
|
|
121
|
+
* How to select the rows whose kind serializes as one of `wantedItemTypes` —
|
|
122
|
+
* the inverse of {@link itemTypeForKind}, as data.
|
|
103
123
|
*
|
|
104
124
|
* **Data rather than SQL because `packages/` never imports from the dashboard**
|
|
105
125
|
* (`CLAUDE.md` → Boundary Rules). The caller builds the predicate with its own
|
|
106
|
-
* query builder; what it must not have to re-derive is *which*
|
|
107
|
-
*
|
|
126
|
+
* query builder; what it must not have to re-derive is *which* kinds belong in
|
|
127
|
+
* it, which is exactly the knowledge that drifted.
|
|
108
128
|
*
|
|
109
129
|
* The two variants are the whole contract, and the second one is why this
|
|
110
130
|
* returns a tagged shape instead of a bare array:
|
|
111
131
|
*
|
|
112
|
-
* - `{ kind: 'in' }` — match
|
|
113
|
-
* - `{ kind: 'inOrUnlisted' }` — match
|
|
114
|
-
*
|
|
132
|
+
* - `{ kind: 'in' }` — match a row whose pair is one of `kinds`.
|
|
133
|
+
* - `{ kind: 'inOrUnlisted' }` — match a row whose pair is one of `kinds`, **or**
|
|
134
|
+
* whose pair is none of `excluding`.
|
|
115
135
|
*
|
|
116
|
-
* **
|
|
117
|
-
*
|
|
118
|
-
* NULL
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
136
|
+
* **"None of `excluding`" has to be NULL-safe, and that is part of what the
|
|
137
|
+
* variant means rather than an extra the caller adds.** `role` and `format` are
|
|
138
|
+
* NULL on exactly the rows that carry no content — a tombstone — and in SQL a
|
|
139
|
+
* comparison against NULL is NULL, so a predicate written as a plain `!=` pair
|
|
140
|
+
* drops precisely the rows the serializer still calls `content` — the default
|
|
141
|
+
* kind. The route would then contradict itself about the same row, which is the
|
|
142
|
+
* defect this shape was introduced to prevent (Codex, PR #562, when the columns
|
|
143
|
+
* were one).
|
|
123
144
|
*
|
|
124
145
|
* `wantedItemTypes` values that are not item types at all (`guide`, or junk)
|
|
125
146
|
* simply match no kind; guides are not `guide_files` rows and are selected
|
|
126
147
|
* separately by their caller.
|
|
127
148
|
*/
|
|
128
|
-
|
|
129
|
-
* A `content_type` addressable through the context layer.
|
|
130
|
-
*
|
|
131
|
-
* Derived from {@link CONTEXT_CONTENT_KINDS} rather than restated, so the table
|
|
132
|
-
* above stays the one definition. `ContentTypeFilter` used to widen these to
|
|
133
|
-
* `string[]`, which threw the literals away at the boundary and left every
|
|
134
|
-
* consumer unable to prove a filter value was a real content type.
|
|
135
|
-
*/
|
|
136
|
-
export type ContextContentType = (typeof CONTEXT_CONTENT_TYPES)[number];
|
|
137
|
-
export type ContentTypeFilter = {
|
|
149
|
+
export type ContentKindFilter = {
|
|
138
150
|
kind: 'in';
|
|
139
|
-
|
|
151
|
+
kinds: ContentKind[];
|
|
140
152
|
} | {
|
|
141
153
|
kind: 'inOrUnlisted';
|
|
142
|
-
|
|
143
|
-
excluding:
|
|
154
|
+
kinds: ContentKind[];
|
|
155
|
+
excluding: ContentKind[];
|
|
144
156
|
};
|
|
145
|
-
|
|
157
|
+
/**
|
|
158
|
+
* An item type addressable through the context layer.
|
|
159
|
+
*
|
|
160
|
+
* Derived from {@link CONTEXT_CONTENT_TYPES} rather than restated, so the table
|
|
161
|
+
* above stays the one definition.
|
|
162
|
+
*/
|
|
163
|
+
export type ContextContentType = (typeof CONTEXT_CONTENT_TYPES)[number];
|
|
164
|
+
export declare function kindFilterForItemTypes(wantedItemTypes: Iterable<string>): ContentKindFilter;
|
|
146
165
|
//# sourceMappingURL=contextKinds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextKinds.d.ts","sourceRoot":"","sources":["../src/contextKinds.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"contextKinds.d.ts","sourceRoot":"","sources":["../src/contextKinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;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C,CAAA;AAEvE,wBAAgB,sBAAsB,CACpC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,GAChC,iBAAiB,CAgBnB"}
|
package/dist/contextKinds.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one table the context item-kind narrowings derive from.
|
|
3
3
|
*
|
|
4
|
-
* **Why this file exists.**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* mapping in the items route. Each narrowing had a reason and none of them
|
|
11
|
-
* derived from a shared source, so adding a fourth kind meant editing five
|
|
4
|
+
* **Why this file exists.** What an agent may *read* back
|
|
5
|
+
* (`ContextItemTypeSchema`), what it may *push* (`PushContentTypeSchema`) and
|
|
6
|
+
* what it may *capture* into the inbox (`InboxContentTypeSchema`) are three
|
|
7
|
+
* narrowings of the same question, plus a lossy kind → item-type mapping and a
|
|
8
|
+
* SQL inverse of it in the items route. Each narrowing had a reason and none of
|
|
9
|
+
* them derived from a shared source, so adding a fourth kind meant editing five
|
|
12
10
|
* places and nothing failed if you missed one.
|
|
13
11
|
*
|
|
14
12
|
* Now one row per kind answers all of it declaratively. A new kind is a new row
|
|
@@ -16,105 +14,133 @@
|
|
|
16
14
|
* silently omitted from a narrowing, because no narrowing has its own list any
|
|
17
15
|
* more.
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* separate, deliberate change to that row.
|
|
17
|
+
* `contextKinds.test.ts` pins each derived picklist against a hand-written copy
|
|
18
|
+
* of today's values, so a row edit that would change the wire fails there rather
|
|
19
|
+
* than in a client. Which kinds are pushable and capturable are product
|
|
20
|
+
* decisions this table records; changing one is a separate, deliberate change to
|
|
21
|
+
* that row.
|
|
25
22
|
*/
|
|
26
23
|
/**
|
|
27
|
-
* The
|
|
24
|
+
* The stored kinds that are addressable as context items on the wire.
|
|
28
25
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
26
|
+
* **Keyed on the `(role, format)` pair, and that is the load-bearing part.**
|
|
27
|
+
* A table keyed on `role` alone would quietly hand a
|
|
28
|
+
* **script** — `content` + `code` — both `pushable` and `capturable`, because
|
|
29
|
+
* nothing would separate it from a markdown document. It must not, and the pair
|
|
30
|
+
* is what stops it. This is the one place the two columns have to be read
|
|
31
|
+
* together; splitting a column does not by itself make every consumer
|
|
32
|
+
* single-column.
|
|
33
|
+
*
|
|
34
|
+
* Pairs *not* listed — `guidance`, `criteria`, `content` + `code`, and a row
|
|
35
|
+
* with no role at all — are still stored. They collapse onto
|
|
33
36
|
* {@link DEFAULT_CONTEXT_ITEM_TYPE} when serialized, and
|
|
34
|
-
* {@link
|
|
37
|
+
* {@link kindFilterForItemTypes} is what keeps SQL agreeing with that.
|
|
35
38
|
*
|
|
36
39
|
* Order is the wire order of the derived picklists and is load-bearing for the
|
|
37
40
|
* pin test; append rather than reorder.
|
|
38
41
|
*/
|
|
39
42
|
export const CONTEXT_CONTENT_KINDS = [
|
|
40
|
-
{
|
|
41
|
-
|
|
43
|
+
{
|
|
44
|
+
itemType: 'content',
|
|
45
|
+
role: 'content',
|
|
46
|
+
format: 'markdown',
|
|
47
|
+
pushable: true,
|
|
48
|
+
capturable: true,
|
|
49
|
+
},
|
|
42
50
|
// `capturable` ahead of the upload path it is for: the inbox schema has
|
|
43
51
|
// admitted `asset` since it was written, with image upload still to land.
|
|
44
52
|
// The flag records today's wire, which is the only thing this table is
|
|
45
53
|
// allowed to record.
|
|
46
|
-
{
|
|
54
|
+
{
|
|
55
|
+
itemType: 'asset',
|
|
56
|
+
role: 'content',
|
|
57
|
+
format: 'binary',
|
|
58
|
+
pushable: true,
|
|
59
|
+
capturable: true,
|
|
60
|
+
},
|
|
47
61
|
];
|
|
48
62
|
/**
|
|
49
63
|
* The item type of a `guides` row.
|
|
50
64
|
*
|
|
51
|
-
* A guide is not a `
|
|
52
|
-
* why it is named here rather than added to the table above. It is readable as
|
|
65
|
+
* A guide is not a stored `(role, format)` pair at all — it is a different
|
|
66
|
+
* table — which is why it is named here rather than added to the table above. It is readable as
|
|
53
67
|
* an item and deliberately neither pushable nor capturable: `PushContentType`'s
|
|
54
68
|
* doc comment on `PushContentTypeSchema` explains why a create cannot honor it.
|
|
55
69
|
*/
|
|
56
70
|
export const GUIDE_ITEM_TYPE = 'guide';
|
|
57
71
|
/**
|
|
58
|
-
* What an unlisted
|
|
72
|
+
* What an unlisted pair serializes as.
|
|
59
73
|
*
|
|
60
74
|
* The default arm exists so a stray row — one written before a kind was
|
|
61
75
|
* retired, or by a non-context surface — produces a schema-valid response
|
|
62
76
|
* instead of failing the read. It is what makes the mapping lossy, and so what
|
|
63
|
-
* forces {@link
|
|
77
|
+
* forces {@link kindFilterForItemTypes} to exist.
|
|
64
78
|
*/
|
|
65
|
-
export const DEFAULT_CONTEXT_ITEM_TYPE = '
|
|
79
|
+
export const DEFAULT_CONTEXT_ITEM_TYPE = 'content';
|
|
66
80
|
// `Extract` rather than a bare boolean `filter`, because a bare one widens.
|
|
67
81
|
// `k.pushable` does not narrow `k`, so the derived arrays would type as *every*
|
|
68
82
|
// content type and `InboxContentType` would silently admit `reference` at the
|
|
69
83
|
// type level while still rejecting it at runtime — a wire narrowing that no
|
|
70
84
|
// longer narrows anything a compiler can see. The predicate keeps each derived
|
|
71
85
|
// picklist as tight as the literal it replaced.
|
|
72
|
-
const kindsWhere = (flag) => CONTEXT_CONTENT_KINDS.filter((k) => k[flag]).map((k) => k.
|
|
73
|
-
/**
|
|
74
|
-
export const CONTEXT_CONTENT_TYPES = CONTEXT_CONTENT_KINDS.map((k) => k.
|
|
86
|
+
const kindsWhere = (flag) => CONTEXT_CONTENT_KINDS.filter((k) => k[flag]).map((k) => k.itemType);
|
|
87
|
+
/** Item types a stored kind can serialize as, in wire order. */
|
|
88
|
+
export const CONTEXT_CONTENT_TYPES = CONTEXT_CONTENT_KINDS.map((k) => k.itemType);
|
|
75
89
|
/** Item types an agent may read back, in wire order. */
|
|
76
90
|
export const CONTEXT_ITEM_TYPES = [GUIDE_ITEM_TYPE, ...CONTEXT_CONTENT_TYPES];
|
|
77
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Everything `?types=` parses.
|
|
93
|
+
*
|
|
94
|
+
* The same list a read serializes, now that nothing is accepted under a
|
|
95
|
+
* retired name: `document` was mapped through for one release so a filter
|
|
96
|
+
* written against the old vocabulary returned a superset rather than an
|
|
97
|
+
* empty page, and that window closed with the release that moved the CLI's
|
|
98
|
+
* own vocabulary — the same shape `reference`'s retirement closed under (git
|
|
99
|
+
* history has that window's open and close).
|
|
100
|
+
*/
|
|
101
|
+
export const CONTEXT_ITEM_TYPE_FILTER_VALUES = CONTEXT_ITEM_TYPES;
|
|
102
|
+
/** Values a caller may create with, in wire order. */
|
|
78
103
|
export const PUSH_CONTENT_TYPES = kindsWhere('pushable');
|
|
79
|
-
/**
|
|
104
|
+
/** Values the inbox may capture. */
|
|
80
105
|
export const INBOX_CONTENT_TYPES = kindsWhere('capturable');
|
|
81
106
|
/**
|
|
82
107
|
* Membership kinds in `bundle_items.item_type`.
|
|
83
108
|
*
|
|
84
109
|
* **A different axis from everything above, kept here because it is the other
|
|
85
110
|
* half of "what kind is this item".** `bundle_items.item_type` says which table
|
|
86
|
-
* `item_id` points at (`guides` or `guide_files`); it is not a narrowing of
|
|
87
|
-
*
|
|
111
|
+
* `item_id` points at (`guides` or `guide_files`); it is not a narrowing of the
|
|
112
|
+
* content kinds above, and a new *content* kind must not add a row here. The review
|
|
88
113
|
* that motivated this file counts it among the "five enums over one column"
|
|
89
114
|
* (§2.3) — that count is wrong, and the two axes are named separately below so
|
|
90
115
|
* a later reader does not merge them.
|
|
91
116
|
*/
|
|
92
117
|
export const BUNDLE_MEMBER_TYPES = ['guide_file', GUIDE_ITEM_TYPE];
|
|
93
118
|
/**
|
|
94
|
-
* The item type a stored
|
|
119
|
+
* The item type a stored kind serializes as.
|
|
95
120
|
*
|
|
96
|
-
* Anything unrecognized —
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
121
|
+
* Anything unrecognized — a guidance row, a rubric, a script, an `html` page, a
|
|
122
|
+
* row carrying no role at all — is a {@link DEFAULT_CONTEXT_ITEM_TYPE}, so a
|
|
123
|
+
* stray row never produces a schema-invalid response. That default is what
|
|
124
|
+
* makes this mapping non-injective: the pair cannot be recovered from an item's
|
|
125
|
+
* `type`, which is why filtering by type in SQL needs
|
|
126
|
+
* {@link kindFilterForItemTypes} rather than an inverted lookup.
|
|
101
127
|
*/
|
|
102
|
-
export function
|
|
103
|
-
const kind = CONTEXT_CONTENT_KINDS.find((k) => k.
|
|
104
|
-
return kind ? kind.
|
|
128
|
+
export function itemTypeForKind(role, format) {
|
|
129
|
+
const kind = CONTEXT_CONTENT_KINDS.find((k) => k.role === role && k.format === format);
|
|
130
|
+
return kind ? kind.itemType : DEFAULT_CONTEXT_ITEM_TYPE;
|
|
105
131
|
}
|
|
106
|
-
export function
|
|
132
|
+
export function kindFilterForItemTypes(wantedItemTypes) {
|
|
107
133
|
const wanted = new Set(wantedItemTypes);
|
|
108
|
-
const
|
|
134
|
+
const kinds = CONTEXT_CONTENT_KINDS.filter((k) => wanted.has(k.itemType)).map((k) => ({ role: k.role, format: k.format }));
|
|
109
135
|
if (!wanted.has(DEFAULT_CONTEXT_ITEM_TYPE))
|
|
110
|
-
return { kind: 'in',
|
|
136
|
+
return { kind: 'in', kinds };
|
|
111
137
|
return {
|
|
112
138
|
kind: 'inOrUnlisted',
|
|
113
|
-
|
|
114
|
-
// The listed kinds that are *not* the default — i.e. every
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
excluding:
|
|
139
|
+
kinds,
|
|
140
|
+
// The listed kinds that are *not* the default — i.e. every pair whose item
|
|
141
|
+
// type is something other than `content`. A row outside this set reads back
|
|
142
|
+
// as `content` by the default arm above, a tombstone's two NULLs included.
|
|
143
|
+
excluding: CONTEXT_CONTENT_KINDS.filter((k) => k.itemType !== DEFAULT_CONTEXT_ITEM_TYPE).map((k) => ({ role: k.role, format: k.format })),
|
|
118
144
|
};
|
|
119
145
|
}
|
|
120
146
|
//# sourceMappingURL=contextKinds.js.map
|
package/dist/contextKinds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextKinds.js","sourceRoot":"","sources":["../src/contextKinds.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"contextKinds.js","sourceRoot":"","sources":["../src/contextKinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;QACE,QAAQ,EAAE,SAAS;QACnB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;KACjB;IACD,wEAAwE;IACxE,0EAA0E;IAC1E,uEAAuE;IACvE,qBAAqB;IACrB;QACE,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,IAAI;QACd,UAAU,EAAE,IAAI;KACjB;CACO,CAAA;AAEV;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,SAAS,CAAA;AAOlD,4EAA4E;AAC5E,gFAAgF;AAChF,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,gDAAgD;AAChD,MAAM,UAAU,GAAG,CAA0C,IAAW,EAAE,EAAE,CAC1E,qBAAqB,CAAC,MAAM,CAC1B,CAAC,CAAC,EAAyD,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACtE,CAAC,GAAG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