@fungi.computer/knapsack 0.1.0 → 0.2.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/README.md +37 -4
- package/dist/files-patch.d.ts +16 -2
- package/dist/files-patch.js +8 -1
- package/dist/files-read.d.ts +108 -3
- package/dist/files-read.js +77 -7
- package/dist/files-search.d.ts +14 -0
- package/dist/files-search.js +52 -0
- package/dist/files.d.ts +40 -46
- package/dist/files.js +171 -85
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/ui/browser.d.ts +44 -0
- package/dist/ui/browser.js +171 -0
- package/dist/ui/effect.d.ts +106 -0
- package/dist/ui/effect.js +208 -0
- package/dist/ui/host.d.ts +9 -0
- package/dist/ui/host.js +158 -0
- package/dist/ui/sessions.d.ts +32 -0
- package/dist/ui/sessions.js +172 -0
- package/dist/ui/wire.d.ts +290 -0
- package/dist/ui/wire.js +136 -0
- package/dist/ui-browser.d.ts +6 -0
- package/dist/ui-browser.js +6 -0
- package/dist/ui.d.ts +29 -0
- package/dist/ui.js +35 -0
- package/docs/api/README.md +1 -0
- package/docs/api/files-patch.md +39 -43
- package/docs/api/files-read.md +263 -27
- package/docs/api/index.md +207 -107
- package/docs/api/ui-browser.md +94 -0
- package/package.json +16 -5
package/docs/api/files-read.md
CHANGED
|
@@ -20,10 +20,31 @@ Maximum UTF-8 byte length of a Files text page.
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
+
### maximumImageBytes
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
const maximumImageBytes: number;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Maximum byte length of an image the read tool returns; a host refuses an image
|
|
30
|
+
it cannot bring within it.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
### imageSniffBytes
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const imageSniffBytes: 12 = 12;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Bytes needed at the start of a file to recognise a supported image.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
23
44
|
### pathSchema
|
|
24
45
|
|
|
25
46
|
```ts
|
|
26
|
-
const pathSchema: ZodString
|
|
47
|
+
const pathSchema: ZodLazy<ZodString>;
|
|
27
48
|
```
|
|
28
49
|
|
|
29
50
|
Nonempty file path bounded to 4,096 characters, without null bytes.
|
|
@@ -33,13 +54,15 @@ Nonempty file path bounded to 4,096 characters, without null bytes.
|
|
|
33
54
|
### readInputSchema
|
|
34
55
|
|
|
35
56
|
```ts
|
|
36
|
-
const readInputSchema:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
const readInputSchema: ZodLazy<
|
|
58
|
+
ZodObject<
|
|
59
|
+
{
|
|
60
|
+
path: ZodLazy<ZodString>;
|
|
61
|
+
offset: ZodDefault<ZodNumber>;
|
|
62
|
+
limit: ZodDefault<ZodNumber>;
|
|
63
|
+
},
|
|
64
|
+
$strict
|
|
65
|
+
>
|
|
43
66
|
>;
|
|
44
67
|
```
|
|
45
68
|
|
|
@@ -47,34 +70,214 @@ Canonical bounded Files read request and result, shared with display consumers.
|
|
|
47
70
|
|
|
48
71
|
---
|
|
49
72
|
|
|
50
|
-
###
|
|
73
|
+
### readImageMimeType
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const readImageMimeType: ZodEnum<{
|
|
77
|
+
image/png: "image/png";
|
|
78
|
+
image/jpeg: "image/jpeg";
|
|
79
|
+
image/gif: "image/gif";
|
|
80
|
+
image/webp: "image/webp";
|
|
81
|
+
}>;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The image types a Files read can return.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### readImageOutputSchema
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
const readImageOutputSchema: ZodLazy<ZodObject<{
|
|
92
|
+
path: ZodLazy<ZodString>;
|
|
93
|
+
image: ZodObject<{
|
|
94
|
+
mimeType: ZodEnum<{
|
|
95
|
+
image/png: "image/png";
|
|
96
|
+
image/jpeg: "image/jpeg";
|
|
97
|
+
image/gif: "image/gif";
|
|
98
|
+
image/webp: "image/webp";
|
|
99
|
+
}>;
|
|
100
|
+
data: ZodBase64;
|
|
101
|
+
bytes: ZodNumber;
|
|
102
|
+
}, $strict>;
|
|
103
|
+
file: ZodExactOptional<ZodLazy<ZodObject<{
|
|
104
|
+
computerId: ZodString;
|
|
105
|
+
path: ZodLazy<ZodString>;
|
|
106
|
+
}, $strict>>>;
|
|
107
|
+
}, $strict>>;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Whole png, jpeg, gif or webp file, at most `maximumImageBytes`, as base64.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### readTextOutputSchema
|
|
51
115
|
|
|
52
116
|
```ts
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
117
|
+
const readTextOutputSchema: ZodLazy<
|
|
118
|
+
ZodObject<
|
|
119
|
+
{
|
|
120
|
+
path: ZodLazy<ZodString>;
|
|
121
|
+
content: ZodString;
|
|
122
|
+
offset: ZodNumber;
|
|
123
|
+
nextOffset: ZodNullable<ZodNumber>;
|
|
124
|
+
truncated: ZodBoolean;
|
|
125
|
+
file: ZodExactOptional<
|
|
126
|
+
ZodLazy<
|
|
127
|
+
ZodObject<
|
|
128
|
+
{
|
|
129
|
+
computerId: ZodString;
|
|
130
|
+
path: ZodLazy<ZodString>;
|
|
131
|
+
},
|
|
132
|
+
$strict
|
|
133
|
+
>
|
|
134
|
+
>
|
|
135
|
+
>;
|
|
136
|
+
},
|
|
137
|
+
$strict
|
|
138
|
+
>
|
|
71
139
|
>;
|
|
72
140
|
```
|
|
73
141
|
|
|
74
142
|
Bounded text page, continuation offset and optional hosted file identity.
|
|
75
143
|
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### readImageCaptionSchema
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
const readImageCaptionSchema: ZodLazy<ZodObject<{
|
|
150
|
+
path: ZodLazy<ZodString>;
|
|
151
|
+
image: ZodObject<{
|
|
152
|
+
ref: ZodString;
|
|
153
|
+
mimeType: ZodEnum<{
|
|
154
|
+
image/png: "image/png";
|
|
155
|
+
image/jpeg: "image/jpeg";
|
|
156
|
+
image/gif: "image/gif";
|
|
157
|
+
image/webp: "image/webp";
|
|
158
|
+
}>;
|
|
159
|
+
bytes: ZodNumber;
|
|
160
|
+
}, $strict>;
|
|
161
|
+
}, $strict>>;
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
What guest code and MCP callers see: an image never travels as base64 in the
|
|
165
|
+
value. It is pushed through the execution's image collector and the value is
|
|
166
|
+
only this caption.
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
### readGuestOutputSchema
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
const readGuestOutputSchema: ZodLazy<ZodUnion<readonly [ZodLazy<ZodObject<{
|
|
174
|
+
path: ZodLazy<ZodString>;
|
|
175
|
+
content: ZodString;
|
|
176
|
+
offset: ZodNumber;
|
|
177
|
+
nextOffset: ZodNullable<ZodNumber>;
|
|
178
|
+
truncated: ZodBoolean;
|
|
179
|
+
file: ZodExactOptional<ZodLazy<ZodObject<{
|
|
180
|
+
computerId: ZodString;
|
|
181
|
+
path: ZodLazy<...>;
|
|
182
|
+
}, $strict>>>;
|
|
183
|
+
}, $strict>>, ZodLazy<ZodObject<{
|
|
184
|
+
path: ZodLazy<ZodString>;
|
|
185
|
+
image: ZodObject<{
|
|
186
|
+
ref: ZodString;
|
|
187
|
+
mimeType: ZodEnum<{
|
|
188
|
+
image/png: "image/png";
|
|
189
|
+
image/jpeg: "image/jpeg";
|
|
190
|
+
image/gif: "image/gif";
|
|
191
|
+
image/webp: "image/webp";
|
|
192
|
+
}>;
|
|
193
|
+
bytes: ZodNumber;
|
|
194
|
+
}, $strict>;
|
|
195
|
+
}, $strict>>]>>;
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Text page or image caption returned to guest code.
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
### readOutputSchema
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
const readOutputSchema: ZodLazy<ZodUnion<readonly [ZodLazy<ZodObject<{
|
|
206
|
+
path: ZodLazy<ZodString>;
|
|
207
|
+
content: ZodString;
|
|
208
|
+
offset: ZodNumber;
|
|
209
|
+
nextOffset: ZodNullable<ZodNumber>;
|
|
210
|
+
truncated: ZodBoolean;
|
|
211
|
+
file: ZodExactOptional<ZodLazy<ZodObject<{
|
|
212
|
+
computerId: ZodString;
|
|
213
|
+
path: ZodLazy<...>;
|
|
214
|
+
}, $strict>>>;
|
|
215
|
+
}, $strict>>, ZodLazy<ZodObject<{
|
|
216
|
+
path: ZodLazy<ZodString>;
|
|
217
|
+
image: ZodObject<{
|
|
218
|
+
mimeType: ZodEnum<{
|
|
219
|
+
image/png: "image/png";
|
|
220
|
+
image/jpeg: "image/jpeg";
|
|
221
|
+
image/gif: "image/gif";
|
|
222
|
+
image/webp: "image/webp";
|
|
223
|
+
}>;
|
|
224
|
+
data: ZodBase64;
|
|
225
|
+
bytes: ZodNumber;
|
|
226
|
+
}, $strict>;
|
|
227
|
+
file: ZodExactOptional<ZodLazy<ZodObject<{
|
|
228
|
+
computerId: ZodString;
|
|
229
|
+
path: ZodLazy<...>;
|
|
230
|
+
}, $strict>>>;
|
|
231
|
+
}, $strict>>]>>;
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
A bounded text page or a whole image; images are only read from offset 0.
|
|
235
|
+
|
|
76
236
|
## Functions
|
|
77
237
|
|
|
238
|
+
### sniffImageMimeType()
|
|
239
|
+
|
|
240
|
+
```ts
|
|
241
|
+
function sniffImageMimeType(head): string | undefined;
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Identify png, jpeg, gif or webp by their full magic bytes; `undefined` means not
|
|
245
|
+
a supported image.
|
|
246
|
+
|
|
247
|
+
#### Parameters
|
|
248
|
+
|
|
249
|
+
| Parameter | Type |
|
|
250
|
+
| --------- | ------------ |
|
|
251
|
+
| `head` | `Uint8Array` |
|
|
252
|
+
|
|
253
|
+
#### Returns
|
|
254
|
+
|
|
255
|
+
`string` \| `undefined`
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### imageTooLargeMessage()
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
function imageTooLargeMessage(path, size, limit): string;
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Message for an image above a host's read cap, shared by every Files host.
|
|
266
|
+
|
|
267
|
+
#### Parameters
|
|
268
|
+
|
|
269
|
+
| Parameter | Type |
|
|
270
|
+
| --------- | -------- |
|
|
271
|
+
| `path` | `string` |
|
|
272
|
+
| `size` | `number` |
|
|
273
|
+
| `limit` | `number` |
|
|
274
|
+
|
|
275
|
+
#### Returns
|
|
276
|
+
|
|
277
|
+
`string`
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
78
281
|
### boundedTextSchema()
|
|
79
282
|
|
|
80
283
|
```ts
|
|
@@ -92,3 +295,36 @@ Validate text against a minimum character length and the Files UTF-8 byte limit.
|
|
|
92
295
|
#### Returns
|
|
93
296
|
|
|
94
297
|
`ZodString`
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
### imageReadResult()
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
function imageReadResult(path, mimeType, bytes): object;
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
Build the image read result for a recognised image's complete bytes.
|
|
308
|
+
|
|
309
|
+
#### Parameters
|
|
310
|
+
|
|
311
|
+
| Parameter | Type |
|
|
312
|
+
| ---------- | ------------ |
|
|
313
|
+
| `path` | `string` |
|
|
314
|
+
| `mimeType` | `string` |
|
|
315
|
+
| `bytes` | `Uint8Array` |
|
|
316
|
+
|
|
317
|
+
#### Returns
|
|
318
|
+
|
|
319
|
+
`object`
|
|
320
|
+
|
|
321
|
+
| Name | Type | Default value |
|
|
322
|
+
| ----------------- | ------------------------------------------------------------------ | ------------------- |
|
|
323
|
+
| `path` | `string` | `pathSchema` |
|
|
324
|
+
| `image` | `object` | - |
|
|
325
|
+
| `image.mimeType` | `"image/png"` \| `"image/jpeg"` \| `"image/gif"` \| `"image/webp"` | `readImageMimeType` |
|
|
326
|
+
| `image.data` | `string` | - |
|
|
327
|
+
| `image.bytes` | `number` | - |
|
|
328
|
+
| `file?` | `object` | - |
|
|
329
|
+
| `file.computerId` | `string` | - |
|
|
330
|
+
| `file.path` | `string` | - |
|