@yaks/blob 0.0.0-stage → 0.2.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +946 -2
  3. package/_dist/accepts.d.ts +38 -0
  4. package/_dist/accepts.d.ts.map +1 -0
  5. package/_dist/artifact.d.ts +29 -0
  6. package/_dist/artifact.d.ts.map +1 -0
  7. package/_dist/attachment.d.ts +53 -0
  8. package/_dist/attachment.d.ts.map +1 -0
  9. package/_dist/backend.d.ts +20 -0
  10. package/_dist/backend.d.ts.map +1 -0
  11. package/_dist/broken.d.ts +24 -0
  12. package/_dist/broken.d.ts.map +1 -0
  13. package/_dist/browser.d.ts +27 -0
  14. package/_dist/browser.d.ts.map +1 -0
  15. package/_dist/compare.d.ts +4 -0
  16. package/_dist/compare.d.ts.map +1 -0
  17. package/_dist/content_type.d.ts +20 -0
  18. package/_dist/content_type.d.ts.map +1 -0
  19. package/_dist/graph.d.ts +13 -0
  20. package/_dist/graph.d.ts.map +1 -0
  21. package/_dist/hydrate.d.ts +36 -0
  22. package/_dist/hydrate.d.ts.map +1 -0
  23. package/_dist/identify.d.ts +7 -0
  24. package/_dist/identify.d.ts.map +1 -0
  25. package/_dist/image.d.ts +37 -0
  26. package/_dist/image.d.ts.map +1 -0
  27. package/_dist/keywords.d.ts +10 -0
  28. package/_dist/keywords.d.ts.map +1 -0
  29. package/_dist/mime.d.ts +2 -0
  30. package/_dist/mime.d.ts.map +1 -0
  31. package/_dist/mod.d.ts +97 -0
  32. package/_dist/mod.d.ts.map +1 -0
  33. package/_dist/object-put.d.ts +2 -0
  34. package/_dist/object-put.d.ts.map +1 -0
  35. package/_dist/object.d.ts +175 -0
  36. package/_dist/object.d.ts.map +1 -0
  37. package/_dist/parts.d.ts +91 -0
  38. package/_dist/parts.d.ts.map +1 -0
  39. package/_dist/plugin.d.ts +38 -0
  40. package/_dist/plugin.d.ts.map +1 -0
  41. package/_dist/png.d.ts +14 -0
  42. package/_dist/png.d.ts.map +1 -0
  43. package/_dist/props.d.ts +20 -0
  44. package/_dist/props.d.ts.map +1 -0
  45. package/_dist/representation.d.ts +17 -0
  46. package/_dist/representation.d.ts.map +1 -0
  47. package/_dist/representation_rules.d.ts +3 -0
  48. package/_dist/representation_rules.d.ts.map +1 -0
  49. package/_dist/routes.d.ts +65 -0
  50. package/_dist/routes.d.ts.map +1 -0
  51. package/_dist/serve.d.ts +29 -0
  52. package/_dist/serve.d.ts.map +1 -0
  53. package/_dist/sha256.d.ts +26 -0
  54. package/_dist/sha256.d.ts.map +1 -0
  55. package/_dist/sqlite.d.ts +57 -0
  56. package/_dist/sqlite.d.ts.map +1 -0
  57. package/_dist/store.d.ts +41 -0
  58. package/_dist/store.d.ts.map +1 -0
  59. package/_dist/stream.d.ts +91 -0
  60. package/_dist/stream.d.ts.map +1 -0
  61. package/_dist/upload.d.ts +114 -0
  62. package/_dist/upload.d.ts.map +1 -0
  63. package/_dist/value.d.ts +62 -0
  64. package/_dist/value.d.ts.map +1 -0
  65. package/_dist/vocab.d.ts +13 -0
  66. package/_dist/vocab.d.ts.map +1 -0
  67. package/accepts.js +76 -0
  68. package/accepts.js.map +1 -0
  69. package/accepts.ts +95 -0
  70. package/artifact.js +50 -0
  71. package/artifact.js.map +1 -0
  72. package/artifact.ts +93 -0
  73. package/attachment.js +190 -0
  74. package/attachment.js.map +1 -0
  75. package/attachment.ts +201 -0
  76. package/backend.js +37 -0
  77. package/backend.js.map +1 -0
  78. package/backend.ts +44 -0
  79. package/broken.js +278 -0
  80. package/broken.js.map +1 -0
  81. package/broken.ts +217 -0
  82. package/browser.js +124 -0
  83. package/browser.js.map +1 -0
  84. package/browser.ts +179 -0
  85. package/compare.js +82 -0
  86. package/compare.js.map +1 -0
  87. package/compare.ts +90 -0
  88. package/content_type.js +43 -0
  89. package/content_type.js.map +1 -0
  90. package/content_type.ts +58 -0
  91. package/deno.json +1 -0
  92. package/fixed.js +53 -0
  93. package/fixed.js.map +1 -0
  94. package/fixed.ts +61 -0
  95. package/graph.js +15 -0
  96. package/graph.js.map +1 -0
  97. package/graph.ts +22 -0
  98. package/hydrate.js +69 -0
  99. package/hydrate.js.map +1 -0
  100. package/hydrate.ts +72 -0
  101. package/identify.js +38 -0
  102. package/identify.js.map +1 -0
  103. package/identify.ts +50 -0
  104. package/image.js +111 -0
  105. package/image.js.map +1 -0
  106. package/image.ts +120 -0
  107. package/keywords.js +28 -0
  108. package/keywords.js.map +1 -0
  109. package/keywords.ts +28 -0
  110. package/meta/blob.vocab.json +17 -0
  111. package/mime.js +72 -0
  112. package/mime.js.map +1 -0
  113. package/mime.ts +73 -0
  114. package/mod.js +97 -0
  115. package/mod.js.map +1 -0
  116. package/mod.ts +115 -0
  117. package/object-put.js +90 -0
  118. package/object-put.js.map +1 -0
  119. package/object-put.ts +114 -0
  120. package/object.js +369 -0
  121. package/object.js.map +1 -0
  122. package/object.ts +592 -0
  123. package/package.json +84 -4
  124. package/parts.js +354 -0
  125. package/parts.js.map +1 -0
  126. package/parts.ts +423 -0
  127. package/plugin.js +158 -0
  128. package/plugin.js.map +1 -0
  129. package/plugin.ts +184 -0
  130. package/png.js +74 -0
  131. package/png.js.map +1 -0
  132. package/png.ts +58 -0
  133. package/props.js +32 -0
  134. package/props.js.map +1 -0
  135. package/props.ts +47 -0
  136. package/purge.js +65 -0
  137. package/purge.js.map +1 -0
  138. package/purge.ts +72 -0
  139. package/representation.js +34 -0
  140. package/representation.js.map +1 -0
  141. package/representation.ts +44 -0
  142. package/representation_rules.js +44 -0
  143. package/representation_rules.js.map +1 -0
  144. package/representation_rules.ts +57 -0
  145. package/routes.js +454 -0
  146. package/routes.js.map +1 -0
  147. package/routes.ts +575 -0
  148. package/serve.js +196 -0
  149. package/serve.js.map +1 -0
  150. package/serve.ts +242 -0
  151. package/sha256.js +185 -0
  152. package/sha256.js.map +1 -0
  153. package/sha256.ts +210 -0
  154. package/sqlite.js +201 -0
  155. package/sqlite.js.map +1 -0
  156. package/sqlite.ts +250 -0
  157. package/store.js +40 -0
  158. package/store.js.map +1 -0
  159. package/store.ts +93 -0
  160. package/stream.js +203 -0
  161. package/stream.js.map +1 -0
  162. package/stream.ts +256 -0
  163. package/upload.js +256 -0
  164. package/upload.js.map +1 -0
  165. package/upload.ts +404 -0
  166. package/value.js +234 -0
  167. package/value.js.map +1 -0
  168. package/value.ts +281 -0
  169. package/vocab.js +27 -0
  170. package/vocab.js.map +1 -0
  171. package/vocab.json +123 -0
  172. package/vocab.ts +32 -0
package/value.js ADDED
@@ -0,0 +1,234 @@
1
+ // Two tools that read a long text value in bounded pieces, through a reader the
2
+ // caller supplies. They exist because a model asked for a 200 KB body would
3
+ // otherwise get all of it: `graph_value_read` returns a slice and
4
+ // `graph_value_search` returns matching excerpts, both capped.
5
+ //
6
+ // A model reads each answer as text: a first line saying plainly where the
7
+ // piece lies, then the piece itself. Said as JSON, the piece would be a string
8
+ // with every quote and line break in it escaped, and a value that is itself
9
+ // JSON (a large tool result kept whole, @yaks/context) escaped a second time,
10
+ // which a model can barely read. Code reads the same pieces as data:
11
+ // `valueRange` and `valueSearch`.
12
+ //
13
+ // The reader is the caller's own authorized entity reader, so these tools add
14
+ // no access of their own: they never take a filesystem path or a raw blob
15
+ // address, and they read a graph property by name like any other tool. An
16
+ // optional `revision` is the SHA-256 of the text the caller last saw, so a
17
+ // value that changed underneath fails instead of returning a mix of two
18
+ // versions.
19
+ //
20
+ // Neither tool exposes a raw blob address, and neither bypasses graph access
21
+ // control.
22
+ import { CallError } from "@yaks/tools/errors";
23
+ import { address } from "./store.js";
24
+ export const VALUE_LIMIT = 8192;
25
+ const chars = (s)=>Array.from(s);
26
+ const integer = (v, fallback, max)=>{
27
+ const n = v == null ? fallback : v;
28
+ if (typeof n != 'number' || !Number.isSafeInteger(n) || n < 0 || n > max) {
29
+ throw new CallError('range', 'Invalid range: expected integer from 0 to ' + max);
30
+ }
31
+ return n;
32
+ };
33
+ /**
34
+ * Why a revision passed is not the value's: a hash of changed text shares
35
+ * almost none of its digits with the old one, so one a few digits off is the
36
+ * current revision copied wrong, and anything else is text that changed since,
37
+ * or a revision copied far wrong. Either way the refusal names the current
38
+ * revision, which is the next call that reads.
39
+ *
40
+ * ```ts
41
+ * import { equal } from '@yaks/testing'
42
+ * import { address } from './store.ts'
43
+ * import { stale } from './value.ts'
44
+ *
45
+ * let now = address('text'), was = address('text, before')
46
+ * let typo = now.slice(0, 9) + (now[9] == '0' ? '1' : '0') + now.slice(10)
47
+ * equal(stale(typo, now), `revision ${typo} is ${now} copied wrong: pass ${now}`)
48
+ * equal(stale(was, now).startsWith(`revision ${was} is not this value's`), true)
49
+ * ```
50
+ */ export const stale = (passed, revision)=>{
51
+ const off = [
52
+ ...revision
53
+ ].filter((c, i)=>c != passed[i]).length;
54
+ return passed.length == revision.length && off <= 4 ? `revision ${passed} is ${revision} copied wrong: pass ${revision}` : `revision ${passed} is not this value's, which is ${revision}: the ` + 'text changed since the read that gave it, or the revision was copied ' + `wrong. Pass ${revision} to read the text as it is now; an offset ` + 'from an older read may have moved';
55
+ };
56
+ const properties = {
57
+ entity: {
58
+ type: 'string'
59
+ },
60
+ component: {
61
+ type: 'string'
62
+ },
63
+ property: {
64
+ type: 'string'
65
+ },
66
+ revision: {
67
+ type: 'string',
68
+ description: 'The revision an earlier read returned, copied exactly; if the text changed since, the read is refused, naming the current revision'
69
+ },
70
+ start: {
71
+ type: 'integer',
72
+ minimum: 0
73
+ }
74
+ };
75
+ const load = async (read, args)=>{
76
+ for (const key of [
77
+ 'entity',
78
+ 'component',
79
+ 'property'
80
+ ]){
81
+ if (typeof args[key] != 'string' || !args[key] || args[key].length > 1024) throw new CallError('address', 'Invalid value address');
82
+ }
83
+ const row = await read(args.entity);
84
+ const component = row && Object.hasOwn(row, args.component) ? row[args.component] : undefined;
85
+ const value = component && Object.hasOwn(component, args.property) ? component[args.property] : undefined;
86
+ if (typeof value != 'string') {
87
+ throw new CallError('value', 'Value unavailable or not text');
88
+ }
89
+ const revision = address(value);
90
+ if (args.revision != null && args.revision !== revision) {
91
+ throw new CallError('revision', stale(String(args.revision), revision));
92
+ }
93
+ return {
94
+ revision,
95
+ text: chars(value)
96
+ };
97
+ };
98
+ /** A range of a text value, read through `read`: `count` code points (2048, at
99
+ * most {@link VALUE_LIMIT}) from `start` (0), refused when `revision` is passed
100
+ * and the text is no longer that. */ export const valueRange = (read)=>async (args)=>{
101
+ const { text, revision } = await load(read, args);
102
+ const start = integer(args.start, 0, text.length);
103
+ const count = integer(args.count, 2048, VALUE_LIMIT);
104
+ if (!count) throw new CallError('count', 'count must be positive');
105
+ const end = Math.min(text.length, start + count);
106
+ return {
107
+ revision,
108
+ start,
109
+ end,
110
+ total: text.length,
111
+ next: end < text.length ? end : null,
112
+ text: text.slice(start, end).join('')
113
+ };
114
+ };
115
+ /** The literal, case-sensitive matches of `query` in a text value, read
116
+ * through `read`: from `start` (0), at most `limit` (10, at most 20). */ export const valueSearch = (read)=>async (args)=>{
117
+ const { text: points, revision } = await load(read, args);
118
+ if (typeof args.query != 'string' || !args.query.length || args.query.length > 256) {
119
+ throw new CallError('query', 'query must contain 1..256 UTF-16 code units');
120
+ }
121
+ const start = integer(args.start, 0, points.length);
122
+ const limit = integer(args.limit, 10, 20);
123
+ if (!limit) throw new CallError('limit', 'limit must be positive');
124
+ const text = points.slice(start).join('');
125
+ const matches = [];
126
+ let pos = 0, offset = start, consumed = 0;
127
+ while(matches.length < limit){
128
+ const at = text.indexOf(args.query, pos);
129
+ if (at < 0) break;
130
+ offset += chars(text.slice(consumed, at)).length;
131
+ matches.push({
132
+ offset,
133
+ text: points.slice(Math.max(start, offset - 40), offset + 40).join('')
134
+ });
135
+ consumed = at;
136
+ pos = at + args.query.length;
137
+ }
138
+ return {
139
+ revision,
140
+ matches,
141
+ next: matches.length == limit ? offset + chars(args.query).length : null
142
+ };
143
+ };
144
+ // A range as a model reads it: where it lies, then the text as stored.
145
+ const said = (r)=>`[Code points ${r.start} to ${r.end} of ${r.total}, revision ` + `${r.revision}; ${r.next == null ? 'the end' : `next start=${r.next}`}.]\n` + r.text;
146
+ // How many matches a search found, as a sentence starts.
147
+ const counted = (n)=>!n ? 'No match' : n == 1 ? '1 match' : `${n} matches`;
148
+ // A search as a model reads it: what it looked for and where it goes on, then
149
+ // a line for each match, its excerpt's line breaks and indents one space.
150
+ const found = (query, from, s)=>[
151
+ `[${counted(s.matches.length)} for ${JSON.stringify(query)}` + `${from ? ` from code point ${from}` : ''}, revision ${s.revision}; ` + `${s.next == null ? 'no more' : `more from start=${s.next}`}.]`,
152
+ ...s.matches.map((m)=>`at ${m.offset}: ${m.text.replace(/\s+/g, ' ').trim()}`)
153
+ ].join('\n');
154
+ /** The two tools, built over a reader. Pass the same authorized reader the
155
+ * application's other graph tools use. Each answers a model in text: a line
156
+ * saying where its piece lies, then the piece.
157
+ *
158
+ * ```ts
159
+ * import { equal } from '@yaks/testing'
160
+ * import { address } from './store.ts'
161
+ * import { valueTools } from './value.ts'
162
+ *
163
+ * let body = '[\n {\n "title": "Mossvale"\n }\n]'
164
+ * let [read, search] = valueTools(async (eid) =>
165
+ * eid == 'p1' ? { entity: { eid }, post: { body } } : undefined
166
+ * )
167
+ * let at = { entity: 'p1', component: 'post', property: 'body' }
168
+ * let revision = address(body)
169
+ * equal(
170
+ * await read.run({ ...at, start: 4, count: 26 }),
171
+ * `[Code points 4 to 30 of 35, revision ${revision}; next start=30.]\n` +
172
+ * '{\n "title": "Mossvale"\n',
173
+ * )
174
+ * equal(
175
+ * await search.run({ ...at, query: 'Moss', start: 2 }),
176
+ * `[1 match for "Moss" from code point 2, revision ${revision}; no more.]\n` +
177
+ * 'at 20: { "title": "Mossvale" } ]',
178
+ * )
179
+ * ```
180
+ */ export const valueTools = (read)=>{
181
+ const range = valueRange(read);
182
+ const search = valueSearch(read);
183
+ return [
184
+ {
185
+ name: 'graph_value_read',
186
+ description: 'Read a bounded range of any authorized graph text property, including blob-backed text. Zero-based Unicode code-point offsets; max 8192 characters. Answers a first line saying the range, total size, revision and next start, then the text itself, as stored. Does not read filesystem paths.',
187
+ parameters: {
188
+ type: 'object',
189
+ properties: {
190
+ ...properties,
191
+ count: {
192
+ type: 'integer',
193
+ minimum: 1,
194
+ maximum: VALUE_LIMIT
195
+ }
196
+ },
197
+ required: [
198
+ 'entity',
199
+ 'component',
200
+ 'property'
201
+ ]
202
+ },
203
+ run: async (args)=>said(await range(args))
204
+ },
205
+ {
206
+ name: 'graph_value_search',
207
+ description: 'Literal case-sensitive search over an authorized graph text property. Answers a first line saying the revision and where to search on, then a line per match: its zero-based Unicode code-point offset and the text around it, line breaks shown as spaces. At most 20 matches. No regex execution.',
208
+ parameters: {
209
+ type: 'object',
210
+ properties: {
211
+ ...properties,
212
+ query: {
213
+ type: 'string',
214
+ minLength: 1,
215
+ maxLength: 256
216
+ },
217
+ limit: {
218
+ type: 'integer',
219
+ minimum: 1,
220
+ maximum: 20
221
+ }
222
+ },
223
+ required: [
224
+ 'entity',
225
+ 'component',
226
+ 'property',
227
+ 'query'
228
+ ]
229
+ },
230
+ run: async (args)=>found(String(args.query), typeof args.start == 'number' ? args.start : 0, await search(args))
231
+ }
232
+ ];
233
+ };
234
+ //# sourceMappingURL=value.js.map
package/value.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.js","sources":["./value.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,4EAA4E;AAC5E,kEAAkE;AAClE,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,qEAAqE;AACrE,kCAAkC;AAClC,EAAE;AACF,8EAA8E;AAC9E,0EAA0E;AAC1E,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,YAAY;AACZ,EAAE;AACF,6EAA6E;AAC7E,WAAW;AAGX,SAAS,SAAS,kCAAuC;AACzD,SAAS,OAAO,qBAAoB;AAEpC,OAAO,MAAM,c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281 @@
1
+ // Two tools that read a long text value in bounded pieces, through a reader the
2
+ // caller supplies. They exist because a model asked for a 200 KB body would
3
+ // otherwise get all of it: `graph_value_read` returns a slice and
4
+ // `graph_value_search` returns matching excerpts, both capped.
5
+ //
6
+ // A model reads each answer as text: a first line saying plainly where the
7
+ // piece lies, then the piece itself. Said as JSON, the piece would be a string
8
+ // with every quote and line break in it escaped, and a value that is itself
9
+ // JSON (a large tool result kept whole, @yaks/context) escaped a second time,
10
+ // which a model can barely read. Code reads the same pieces as data:
11
+ // `valueRange` and `valueSearch`.
12
+ //
13
+ // The reader is the caller's own authorized entity reader, so these tools add
14
+ // no access of their own: they never take a filesystem path or a raw blob
15
+ // address, and they read a graph property by name like any other tool. An
16
+ // optional `revision` is the SHA-256 of the text the caller last saw, so a
17
+ // value that changed underneath fails instead of returning a mix of two
18
+ // versions.
19
+ //
20
+ // Neither tool exposes a raw blob address, and neither bypasses graph access
21
+ // control.
22
+
23
+ import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
24
+ import { CallError } from '@yaks/tools/errors'
25
+ import { address } from './store.js'
26
+
27
+ export const VALUE_LIMIT = 8192
28
+ const chars = (s: string) => Array.from(s)
29
+ const integer = (v: unknown, fallback: number, max: number) => {
30
+ const n = v == null ? fallback : v
31
+ if (typeof n != 'number' || !Number.isSafeInteger(n) || n < 0 || n > max) {
32
+ throw new CallError(
33
+ 'range',
34
+ 'Invalid range: expected integer from 0 to ' + max,
35
+ )
36
+ }
37
+ return n
38
+ }
39
+
40
+ /**
41
+ * Why a revision passed is not the value's: a hash of changed text shares
42
+ * almost none of its digits with the old one, so one a few digits off is the
43
+ * current revision copied wrong, and anything else is text that changed since,
44
+ * or a revision copied far wrong. Either way the refusal names the current
45
+ * revision, which is the next call that reads.
46
+ *
47
+ * ```ts
48
+ * import { equal } from '@yaks/testing'
49
+ * import { address } from './store.ts'
50
+ * import { stale } from './value.ts'
51
+ *
52
+ * let now = address('text'), was = address('text, before')
53
+ * let typo = now.slice(0, 9) + (now[9] == '0' ? '1' : '0') + now.slice(10)
54
+ * equal(stale(typo, now), `revision ${typo} is ${now} copied wrong: pass ${now}`)
55
+ * equal(stale(was, now).startsWith(`revision ${was} is not this value's`), true)
56
+ * ```
57
+ */
58
+ export const stale = (passed: string, revision: string): string => {
59
+ const off = [...revision].filter((c, i) => c != passed[i]).length
60
+ return passed.length == revision.length && off <= 4
61
+ ? `revision ${passed} is ${revision} copied wrong: pass ${revision}`
62
+ : `revision ${passed} is not this value's, which is ${revision}: the ` +
63
+ 'text changed since the read that gave it, or the revision was copied ' +
64
+ `wrong. Pass ${revision} to read the text as it is now; an offset ` +
65
+ 'from an older read may have moved'
66
+ }
67
+
68
+ /** A provider-neutral tool declaration: JSON Schema arguments in, text out. */
69
+ export type ValueTool = {
70
+ name: string
71
+ description: string
72
+ parameters: Record<string, unknown>
73
+ run: (args: Record<string, unknown>) => Promise<string>
74
+ }
75
+
76
+ /** The reader every read goes through: the application's own authorized
77
+ * entity reader. */
78
+ export type ValueReader = (entity: string) => Promise<Bundle | undefined>
79
+
80
+ /** A range of a text value: its code points `start` to `end` of `total`, where
81
+ * the next range starts (null at the end), and the `revision` it was read at. */
82
+ export type ValueRange = {
83
+ revision: string
84
+ start: number
85
+ end: number
86
+ total: number
87
+ next: number | null
88
+ text: string
89
+ }
90
+
91
+ /** What a search of a text value found: each match's offset and the text
92
+ * around it, the `revision` it searched, and where a search goes on from (null
93
+ * once it found fewer matches than it was allowed). */
94
+ export type ValueSearch = {
95
+ revision: string
96
+ matches: { offset: number; text: string }[]
97
+ next: number | null
98
+ }
99
+
100
+ const properties = {
101
+ entity: { type: 'string' },
102
+ component: { type: 'string' },
103
+ property: { type: 'string' },
104
+ revision: {
105
+ type: 'string',
106
+ description:
107
+ 'The revision an earlier read returned, copied exactly; if the text changed since, the read is refused, naming the current revision',
108
+ },
109
+ start: { type: 'integer', minimum: 0 },
110
+ }
111
+
112
+ const load = async (read: ValueReader, args: Record<string, unknown>) => {
113
+ for (const key of ['entity', 'component', 'property']) {
114
+ if (
115
+ typeof args[key] != 'string' || !args[key] ||
116
+ (args[key] as string).length > 1024
117
+ ) throw new CallError('address', 'Invalid value address')
118
+ }
119
+ const row = await read(args.entity as string)
120
+ const component = row && Object.hasOwn(row, args.component as string)
121
+ ? row[args.component as string] as Comp
122
+ : undefined
123
+ const value = component && Object.hasOwn(component, args.property as string)
124
+ ? component[args.property as string]
125
+ : undefined
126
+ if (typeof value != 'string') {
127
+ throw new CallError('value', 'Value unavailable or not text')
128
+ }
129
+ const revision = address(value)
130
+ if (args.revision != null && args.revision !== revision) {
131
+ throw new CallError('revision', stale(String(args.revision), revision))
132
+ }
133
+ return { revision, text: chars(value) }
134
+ }
135
+
136
+ /** A range of a text value, read through `read`: `count` code points (2048, at
137
+ * most {@link VALUE_LIMIT}) from `start` (0), refused when `revision` is passed
138
+ * and the text is no longer that. */
139
+ export const valueRange =
140
+ (read: ValueReader) =>
141
+ async (args: Record<string, unknown>): Promise<ValueRange> => {
142
+ const { text, revision } = await load(read, args)
143
+ const start = integer(args.start, 0, text.length)
144
+ const count = integer(args.count, 2048, VALUE_LIMIT)
145
+ if (!count) throw new CallError('count', 'count must be positive')
146
+ const end = Math.min(text.length, start + count)
147
+ return {
148
+ revision,
149
+ start,
150
+ end,
151
+ total: text.length,
152
+ next: end < text.length ? end : null,
153
+ text: text.slice(start, end).join(''),
154
+ }
155
+ }
156
+
157
+ /** The literal, case-sensitive matches of `query` in a text value, read
158
+ * through `read`: from `start` (0), at most `limit` (10, at most 20). */
159
+ export const valueSearch =
160
+ (read: ValueReader) =>
161
+ async (args: Record<string, unknown>): Promise<ValueSearch> => {
162
+ const { text: points, revision } = await load(read, args)
163
+ if (
164
+ typeof args.query != 'string' || !args.query.length ||
165
+ args.query.length > 256
166
+ ) {
167
+ throw new CallError(
168
+ 'query',
169
+ 'query must contain 1..256 UTF-16 code units',
170
+ )
171
+ }
172
+ const start = integer(args.start, 0, points.length)
173
+ const limit = integer(args.limit, 10, 20)
174
+ if (!limit) throw new CallError('limit', 'limit must be positive')
175
+ const text = points.slice(start).join('')
176
+ const matches: { offset: number; text: string }[] = []
177
+ let pos = 0, offset = start, consumed = 0
178
+ while (matches.length < limit) {
179
+ const at = text.indexOf(args.query, pos)
180
+ if (at < 0) break
181
+ offset += chars(text.slice(consumed, at)).length
182
+ matches.push({
183
+ offset,
184
+ text: points.slice(Math.max(start, offset - 40), offset + 40).join(''),
185
+ })
186
+ consumed = at
187
+ pos = at + args.query.length
188
+ }
189
+ return {
190
+ revision,
191
+ matches,
192
+ next: matches.length == limit ? offset + chars(args.query).length : null,
193
+ }
194
+ }
195
+
196
+ // A range as a model reads it: where it lies, then the text as stored.
197
+ const said = (r: ValueRange): string =>
198
+ `[Code points ${r.start} to ${r.end} of ${r.total}, revision ` +
199
+ `${r.revision}; ${r.next == null ? 'the end' : `next start=${r.next}`}.]\n` +
200
+ r.text
201
+
202
+ // How many matches a search found, as a sentence starts.
203
+ const counted = (n: number) =>
204
+ !n ? 'No match' : n == 1 ? '1 match' : `${n} matches`
205
+
206
+ // A search as a model reads it: what it looked for and where it goes on, then
207
+ // a line for each match, its excerpt's line breaks and indents one space.
208
+ const found = (query: string, from: number, s: ValueSearch): string =>
209
+ [
210
+ `[${counted(s.matches.length)} for ${JSON.stringify(query)}` +
211
+ `${from ? ` from code point ${from}` : ''}, revision ${s.revision}; ` +
212
+ `${s.next == null ? 'no more' : `more from start=${s.next}`}.]`,
213
+ ...s.matches.map((m) =>
214
+ `at ${m.offset}: ${m.text.replace(/\s+/g, ' ').trim()}`
215
+ ),
216
+ ].join('\n')
217
+
218
+ /** The two tools, built over a reader. Pass the same authorized reader the
219
+ * application's other graph tools use. Each answers a model in text: a line
220
+ * saying where its piece lies, then the piece.
221
+ *
222
+ * ```ts
223
+ * import { equal } from '@yaks/testing'
224
+ * import { address } from './store.ts'
225
+ * import { valueTools } from './value.ts'
226
+ *
227
+ * let body = '[\n {\n "title": "Mossvale"\n }\n]'
228
+ * let [read, search] = valueTools(async (eid) =>
229
+ * eid == 'p1' ? { entity: { eid }, post: { body } } : undefined
230
+ * )
231
+ * let at = { entity: 'p1', component: 'post', property: 'body' }
232
+ * let revision = address(body)
233
+ * equal(
234
+ * await read.run({ ...at, start: 4, count: 26 }),
235
+ * `[Code points 4 to 30 of 35, revision ${revision}; next start=30.]\n` +
236
+ * '{\n "title": "Mossvale"\n',
237
+ * )
238
+ * equal(
239
+ * await search.run({ ...at, query: 'Moss', start: 2 }),
240
+ * `[1 match for "Moss" from code point 2, revision ${revision}; no more.]\n` +
241
+ * 'at 20: { "title": "Mossvale" } ]',
242
+ * )
243
+ * ```
244
+ */
245
+ export const valueTools = (read: ValueReader): ValueTool[] => {
246
+ const range = valueRange(read)
247
+ const search = valueSearch(read)
248
+ return [{
249
+ name: 'graph_value_read',
250
+ description:
251
+ 'Read a bounded range of any authorized graph text property, including blob-backed text. Zero-based Unicode code-point offsets; max 8192 characters. Answers a first line saying the range, total size, revision and next start, then the text itself, as stored. Does not read filesystem paths.',
252
+ parameters: {
253
+ type: 'object',
254
+ properties: {
255
+ ...properties,
256
+ count: { type: 'integer', minimum: 1, maximum: VALUE_LIMIT },
257
+ },
258
+ required: ['entity', 'component', 'property'],
259
+ },
260
+ run: async (args) => said(await range(args)),
261
+ }, {
262
+ name: 'graph_value_search',
263
+ description:
264
+ 'Literal case-sensitive search over an authorized graph text property. Answers a first line saying the revision and where to search on, then a line per match: its zero-based Unicode code-point offset and the text around it, line breaks shown as spaces. At most 20 matches. No regex execution.',
265
+ parameters: {
266
+ type: 'object',
267
+ properties: {
268
+ ...properties,
269
+ query: { type: 'string', minLength: 1, maxLength: 256 },
270
+ limit: { type: 'integer', minimum: 1, maximum: 20 },
271
+ },
272
+ required: ['entity', 'component', 'property', 'query'],
273
+ },
274
+ run: async (args) =>
275
+ found(
276
+ String(args.query),
277
+ typeof args.start == 'number' ? args.start : 0,
278
+ await search(args),
279
+ ),
280
+ }]
281
+ }
package/vocab.js ADDED
@@ -0,0 +1,27 @@
1
+ // The schema declarations, and only those: the module a server imports from
2
+ // `@yaks/blob/vocab`. It reaches no storage and no runtime, so a browser tab
3
+ // loading this vocabulary loads nothing else.
4
+ //
5
+ // The `store` keyword is the whole of what this package contributes to a
6
+ // vocabulary: a text property marked with it keeps its value's hash, and the
7
+ // value itself lives wherever the configured store puts it. `derived` is the
8
+ // read back — the SQL that resolves the row's hash to the text — which is part
9
+ // of what the keyword means rather than a rule about how a write is applied.
10
+ import { artifactDoc } from "./artifact.js";
11
+ import { blobKeywords } from "./keywords.js";
12
+ import { blobRead } from "./sqlite.js";
13
+ import manifest from './package.json' with {
14
+ type: 'json'
15
+ };
16
+ export { artifactDoc, blobKeywords, blobRead };
17
+ /** What this package is: its manifest's description, the one place it is
18
+ * written, which a host stamps on each document here. */ export let description = manifest.description;
19
+ /** Every document this plugin declares. */ export let docs = [
20
+ artifactDoc
21
+ ];
22
+ /** The JSON Schema keywords those documents use. */ export let keywords = [
23
+ blobKeywords
24
+ ];
25
+ /** Every body property this vocabulary marks `store: blob`, read back as
26
+ * text. */ export let derived = (vocab)=>blobRead(vocab);
27
+ //# sourceMappingURL=vocab.js.map
package/vocab.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8CAA8C;AAC9C,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAI7E,SAAS,WAAW,wBAAuB;AAC3C,SAAS,YAAY,wBAAuB;AAC5C,SAAS,QAAQ,sBAAqB;AACtC,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,SAAS,WAAW,EAAE,YAAY,EAAE,QAAQ,GAAE;AAE9C;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAY,CAAA;AAE3C,kDAAkD,GAClD,OAAO,IAAI,WAAuB;EAAC;CAAa,CAAA;AAEhD;SACS,GACT,OAAO,IAAI,UAAU,CAAC,QAA0B,SAAS,OAAM"}
package/vocab.json ADDED
@@ -0,0 +1,123 @@
1
+ {
2
+ "$id": "urn:uuid:a1825b9a-12b5-45f5-a031-66024df3d868",
3
+ "$vocabulary": {
4
+ "https://yak.sh/vocab/core": true
5
+ },
6
+ "title": "artifact",
7
+ "$defs": {
8
+ "artifact": {
9
+ "$id": "urn:uuid:a8ff0ffa-d707-47dc-b9d9-11c614788afd",
10
+ "component": true,
11
+ "type": "object",
12
+ "description": "Bytes stored in the configured blob store: their SHA-256 address, media type and size.",
13
+ "properties": {
14
+ "size": {
15
+ "$id": "urn:uuid:b9e6c8cb-1677-48fe-a9c5-3b5a49f53d27",
16
+ "type": "number"
17
+ },
18
+ "address": {
19
+ "$id": "urn:uuid:535a5bce-2f4b-459f-9456-002fdd755b03",
20
+ "type": "string",
21
+ "address": true
22
+ },
23
+ "media_type": {
24
+ "$id": "urn:uuid:b7e5faa4-d3e8-45ef-9e3b-76a5b89397a0",
25
+ "type": "string"
26
+ }
27
+ }
28
+ },
29
+ "representation": {
30
+ "$id": "urn:uuid:6ba79db6-37ab-405c-bd39-781be6cb7ec7",
31
+ "component": true,
32
+ "journal": false,
33
+ "wire": false,
34
+ "type": "object",
35
+ "description": "Immutable HTTP headers for one use of content-addressed bytes.",
36
+ "required": ["scope", "address", "media_type"],
37
+ "properties": {
38
+ "scope": {
39
+ "$id": "urn:uuid:5c678473-92a2-406b-bb4d-583bb0e5bdaf",
40
+ "type": "string",
41
+ "stamped": true
42
+ },
43
+ "address": {
44
+ "$id": "urn:uuid:7d0273ae-2074-40d8-9150-0966def25298",
45
+ "type": "string",
46
+ "stamped": true,
47
+ "address": true
48
+ },
49
+ "media_type": {
50
+ "$id": "urn:uuid:ef76901d-ae84-4975-b570-85c7c1e4ef01",
51
+ "type": "string",
52
+ "stamped": true
53
+ },
54
+ "name": {
55
+ "$id": "urn:uuid:dee98d0f-1e17-436c-bd28-17dcbe6636aa",
56
+ "type": "string",
57
+ "stamped": true
58
+ }
59
+ }
60
+ },
61
+ "attachment": {
62
+ "$id": "urn:uuid:6ae7005c-d65e-40eb-b7aa-411f2d844a90",
63
+ "component": true,
64
+ "type": "object",
65
+ "description": "A file attached to a session entry: the artifact entity holding its bytes, and the model call that produced it.",
66
+ "properties": {
67
+ "message": {
68
+ "$id": "urn:uuid:f700554f-1fca-4be8-84f6-477cbf615553",
69
+ "type": "string",
70
+ "ref": "entity",
71
+ "death": "keep",
72
+ "description": "The message this file came with."
73
+ },
74
+ "artifact": {
75
+ "$id": "urn:uuid:b287b8ea-854a-46f3-8cf3-3c5cc86bbff6",
76
+ "type": "string",
77
+ "ref": "artifact",
78
+ "death": "keep"
79
+ },
80
+ "media_type": {
81
+ "$id": "urn:uuid:577f281c-8e80-45e7-a2f1-1eae0c96ecbe",
82
+ "type": "string"
83
+ },
84
+ "name": {
85
+ "$id": "urn:uuid:d809c048-949d-44cd-9d36-7c59998f10a1",
86
+ "type": "string"
87
+ },
88
+ "audience": {
89
+ "$id": "urn:uuid:93a34607-6c5f-4d32-9532-079445e32ccb",
90
+ "type": "string",
91
+ "enum": [
92
+ "user",
93
+ "model"
94
+ ]
95
+ },
96
+ "revision": {
97
+ "$id": "urn:uuid:708b2eb7-cd14-4a84-ad96-3a34f2c28d45",
98
+ "type": "string"
99
+ },
100
+ "call": {
101
+ "$id": "urn:uuid:30df12d9-376b-44a9-b68a-56b4f2f7a847",
102
+ "type": "string"
103
+ },
104
+ "revised_prompt": {
105
+ "$id": "urn:uuid:28ff9c0a-360f-4084-a4fa-dc1784739569",
106
+ "type": "string"
107
+ },
108
+ "text": {
109
+ "$id": "urn:uuid:bebb7f45-ac21-4a78-a7b6-e70f5116f7b4",
110
+ "type": "string",
111
+ "store": "blob",
112
+ "description": "The words read from the file for a model that cannot read it as it is: a document's text, a picture's contents described. Absent until something reads them."
113
+ }
114
+ }
115
+ }
116
+ },
117
+ "kinds": {
118
+ "attachment": {
119
+ "$id": "urn:uuid:6ae7005c-d65e-40eb-b7aa-411f2d844a90",
120
+ "description": "A file attached to a session entry: the artifact entity holding its bytes, and the model call that produced it."
121
+ }
122
+ }
123
+ }