@agentshouse/mdruntime-adapter 0.1.0-c51fa73c21cdb → 0.1.0-c543f40f7ffb2
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/AGENTS.md +62 -47
- package/dist/actions.d.ts +1 -16
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +20 -49
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +83 -91
- package/dist/digest.d.ts +1 -1
- package/dist/digest.d.ts.map +1 -1
- package/dist/digest.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/part.d.ts +3 -1
- package/dist/part.d.ts.map +1 -1
- package/dist/part.js +10 -5
- package/dist/read.d.ts +16 -3
- package/dist/read.d.ts.map +1 -1
- package/dist/read.js +87 -52
- package/dist/referrer.d.ts +6 -1
- package/dist/referrer.d.ts.map +1 -1
- package/dist/referrer.js +6 -8
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +33 -1
- package/dist/site.d.ts.map +1 -1
- package/dist/site.js +36 -36
- package/dist/stream.d.ts +1 -0
- package/dist/stream.d.ts.map +1 -1
- package/dist/stream.js +16 -1
- package/dist/transport.d.ts +10 -9
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +1 -1
- package/dist/upload.d.ts +12 -0
- package/dist/upload.d.ts.map +1 -0
- package/dist/upload.js +52 -0
- package/package.json +2 -2
- package/dist/handed.d.ts +0 -15
- package/dist/handed.d.ts.map +0 -1
- package/dist/handed.js +0 -45
package/AGENTS.md
CHANGED
|
@@ -59,15 +59,19 @@ media type: Save keeps the bytes in its Pending Change, offline too, and accepta
|
|
|
59
59
|
the record the Provider's revision. Move or remove one as a Document, a pending one too,
|
|
60
60
|
its bytes following; once its Pending Change has gone to the Provider, Save refuses that
|
|
61
61
|
as `unknown-revision` until it is accepted. `binaryFile.read(room, path, revision?)`
|
|
62
|
-
answers a pending record's saved bytes, or
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
answers a pending record's saved bytes, or an accepted one's or a History revision's, a
|
|
63
|
+
removed file's last included: the first read asks the Provider and the browser keeps the
|
|
64
|
+
bytes, and every later read of that revision, offline too, answers them from the browser.
|
|
65
|
+
Text may name a file by its `fileRef`; read it with
|
|
66
|
+
`binaryFile.readReference({ fileRef, referrer })`, the `referrer` `{ room, path }` of the
|
|
67
|
+
document whose text names it, kept the same way. Both
|
|
68
|
+
answer `{ kind: 'binary', stream, byteLength, mediaType }`, the bytes a `ReadableStream`
|
|
69
|
+
of parts of at most a mebibyte, or a refusal or failure; read the stream to its end, or
|
|
70
|
+
take it whole with `new Response(stream).blob()` where a screen needs one `Blob`.
|
|
68
71
|
|
|
69
72
|
Rooms, Query, Search, Observe, Types, Room Draft, Save, and Reached never touch the
|
|
70
|
-
network; History,
|
|
73
|
+
network; History, a binary file read the browser does not keep yet and Call go to the
|
|
74
|
+
Provider through the Adapter.
|
|
71
75
|
Call takes the Action names the Adapter declares, any other answering `undeclared`. A Call
|
|
72
76
|
result whose effect the Provider places in a Room carries `at`, that Room and Room
|
|
73
77
|
Version: `reached(room, roomVersion)` answers whether the Room's confirmed state has
|
|
@@ -122,36 +126,38 @@ draw it as loading and observe the query to hear the complete answer. A query is
|
|
|
122
126
|
- **Relations.** Within one Room, `hop: { field, types, where, pathPrefix }` keeps Documents
|
|
123
127
|
whose reference at pointer `field`, at any depth, points to a matching Document, and
|
|
124
128
|
`backlinks` with the same keys those a matching Document references, each once. A body
|
|
125
|
-
link
|
|
126
|
-
|
|
127
|
-
`
|
|
128
|
-
locked.
|
|
129
|
+
link or a `cross_room` reference may name another Room's `/rooms/<handle>/<path>`:
|
|
130
|
+
`resolve(room, path, destination)` answers its `document`, the `deleted` one's last
|
|
131
|
+
`revision`, or `unreadable` where the App does not bind it or it is locked.
|
|
129
132
|
- **Parts.** A Document query must `select`: `'all'`, or `fields`, `sections`,
|
|
130
|
-
`preamble`, `markdown`, `backlinks`, `change` and `
|
|
133
|
+
`preamble`, `markdown`, `backlinks`, `change`, `fileId` and `revision`, where `fields` is `'all'`
|
|
131
134
|
or a list of pointers and `sections` `'all'` or a list of names. Selected pointers
|
|
132
135
|
return the frontmatter holding only them, nested as written. A backlink names the
|
|
133
136
|
referring Path, MD Type and the pointer it came from as `field`. Room and Path always
|
|
134
137
|
return; a Markdown Document also returns its MD Type, and at most its first 1,000
|
|
135
138
|
backlinks: a query on the referring field reads the rest. A non-Markdown Document
|
|
136
|
-
returns only Room, Path and a selected `fileId
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
returns only Room, Path and a selected `fileId` and `revision`, a binary Path entry its `binaryFile`
|
|
140
|
+
record too, and a YAML file under `settings/` its text as a selected `markdown`, kept
|
|
141
|
+
out of Search. An unselected part is absent. Select only what a screen shows: a list
|
|
142
|
+
that selects the Markdown hears every edit of it.
|
|
143
|
+
- **Change, file ID and revision.** `change` is `{ author, time }` of the Document's head revision
|
|
140
144
|
as the Provider last delivered it: `author` is `{ kind: 'user' | 'site' | 'inbox', id, name }`, or
|
|
141
145
|
`null` for a write the Provider made itself, and `time` its ISO 8601 change time, or the
|
|
142
146
|
whole change `null` where it delivered no time, as at a Site. `fileId` is the Provider's
|
|
143
147
|
Stable File ID of the file at the Path, or `null`. An unsent edit keeps both, an unsent
|
|
144
148
|
move keeps the change and carries the file ID to the new Path, so a file ID that leaves
|
|
145
149
|
one Path for another is the same file moved, and an unsent creation has neither until it
|
|
146
|
-
is Accepted.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
`
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
is Accepted. `revision` is the Provider's head revision, `null` for an unsent creation or edit,
|
|
151
|
+
and moves with an unsent move. A Room's last change is its Document with the latest `time`.
|
|
152
|
+
- **Order and groups.** `orderBy` sorts by `room`, `path`, `type`, `folder` or `{ field }`: missing
|
|
153
|
+
and null first, last with `nulls: 'last'`, then numbers and booleans, then text by `locale` or
|
|
154
|
+
code point with `stringSort: 'lexical'`, then lists item by item; ties end with Room, then Path.
|
|
155
|
+
`groupBy` by `room`, `type`, `folder` or `{ field }` answers `{ groups: [{ key, count }] }`,
|
|
156
|
+
counted over every match and ordered by `count` or a key. A sort or group takes only a
|
|
157
|
+
single-value pointer. `limit`, at most 1,000 whatever a query names, bounds the Documents or the
|
|
158
|
+
groups, and a result it cuts short names `next`: the same query with it as `after` reads the next
|
|
159
|
+
window, in the same order, ties included. `total: true` adds `total`, every match's count. An
|
|
160
|
+
observed window hears rows entering, leaving or changing, and `next`, `total`.
|
|
155
161
|
- **Results and errors.** A result carries no Room Version: read freshness from Rooms and
|
|
156
162
|
Sync Status. `coverage` names each Room read as `{ room, generation, current }`,
|
|
157
163
|
`current` false while a newer copy of that Room is being fetched, and the queued changes
|
|
@@ -161,28 +167,36 @@ draw it as loading and observe the query to hear the complete answer. A query is
|
|
|
161
167
|
## Local Search rules
|
|
162
168
|
|
|
163
169
|
`search({ text, documents, collection, conversations, limit, after, total })` answers
|
|
164
|
-
once, by words, from
|
|
170
|
+
once, by words, from the full-text index the browser keeps with its local state, so it
|
|
171
|
+
answers at once after a reload. There is no observed search.
|
|
165
172
|
|
|
166
|
-
- **Declaration.** Only an App whose release declares Local Search searches
|
|
167
|
-
|
|
168
|
-
`
|
|
173
|
+
- **Declaration.** Only an App whose release declares Local Search searches; any other
|
|
174
|
+
App's `search` answers the never retryable `undeclared` refusal `search-undeclared`, its
|
|
175
|
+
`fields` naming `local_search`.
|
|
169
176
|
- **What is found.** A Document by its field values, its sections' headings and text, its
|
|
170
177
|
preamble and its Path, and a message by its text, never a frontmatter key, a Room Draft,
|
|
171
|
-
a chat draft or a running turn's parts
|
|
172
|
-
|
|
178
|
+
a chat draft or a running turn's parts. Any word found ranks a hit, more found rank it
|
|
179
|
+
higher, and adjacent words higher still; case and the marks of Latin, Greek and
|
|
180
|
+
Cyrillic letters fold, English word forms stem, the last word also matches as the start
|
|
181
|
+
of a word unless the text ends with a space, and Chinese, Japanese, Korean and Thai text
|
|
182
|
+
matches by character pairs. There is no typo tolerance and no operator syntax.
|
|
173
183
|
- **Narrowing.** `documents` is a Local Query filter, and `collection: true` leaves out
|
|
174
184
|
what each Room's `typedSelection` roots hold; `conversations` names conversations. All
|
|
175
185
|
apply before `limit`, which bounds each list, at most 1,000 whatever a search names. A
|
|
176
186
|
complete answer it cuts short names `next`, which `after` takes for the next window of
|
|
177
|
-
both lists. `total: true` adds `total`, each list's count.
|
|
187
|
+
both lists. `total: true` adds `total`, each list's count. A word in very many Documents
|
|
188
|
+
ranks among a bounded set of them, the Documents of a rarer word of the search always
|
|
189
|
+
among them.
|
|
178
190
|
- **Results.** `{ documents, messages, coverage }`, or the same with `pending` naming each
|
|
179
|
-
Room
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
191
|
+
Room the search still waits for: show its hits, ask again, and never read pending as no
|
|
192
|
+
hits. `coverage` names the Rooms and conversations searched. Each list is ranked by
|
|
193
|
+
`score`, comparable only within it; ties come by `room`, then `path`, or by
|
|
194
|
+
`conversation`, then `identity`. A Document hit names its `room`, `path` and `type`, a
|
|
195
|
+
message hit its `conversation` and `identity`; `matches` maps each word of the search
|
|
196
|
+
to the parts it was found in: `fields`, `sections`, `preamble`, `path` or `text`. A hit
|
|
197
|
+
whose words were found carries `snippet: { part, text, at }`: the part's text around
|
|
198
|
+
the first word found, at most 80 characters on either side, and `at` that word's start
|
|
199
|
+
and end in `text`. Mark the words you show. A bad filter fails as a query does.
|
|
186
200
|
|
|
187
201
|
## Room Draft, Save, and outcome rules
|
|
188
202
|
|
|
@@ -229,9 +243,9 @@ queue and returns no Room Draft.
|
|
|
229
243
|
While writes are halted, Save succeeds, its Change Batch waits unsent and the queue is
|
|
230
244
|
submitted in order once writes reopen; an Action is never held, and one the halt refuses
|
|
231
245
|
returns that refusal: show the Provider as read-only instead of retrying.
|
|
232
|
-
`observe('readiness')` tells whether
|
|
233
|
-
|
|
234
|
-
|
|
246
|
+
`observe('readiness')` tells whether code and bound Rooms are held locally (`ready`), each
|
|
247
|
+
Room's state, each refused Room's file and rule, the persistence answer, a paused `capacity`
|
|
248
|
+
cause `retry()` resumes, and the `installation`'s Rooms, parts, bytes, `received`, `step` and `paused`.
|
|
235
249
|
|
|
236
250
|
## Content safety and launch promises
|
|
237
251
|
|
|
@@ -297,8 +311,9 @@ Mix `ChatMessageList` (`components` takes your `UserMessage` and `AssistantMessa
|
|
|
297
311
|
`ChatInput` and `ChatQuestionCard` with your own design inside a `ChatProvider`, or
|
|
298
312
|
compose assistant-ui's primitives there; `useChat()` gives `send`, the conversations, the
|
|
299
313
|
Agents, questions to `answer`, `options` to `choose`, `commands`, the queue to `edit` or
|
|
300
|
-
`unqueue`, `stop`, `kill`
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
314
|
+
`unqueue`, `stop`, `kill`, `renew`, which starts a new chat with the same Agent in place
|
|
315
|
+
of a conversation whose session could not resume, and outcomes; never replace its
|
|
316
|
+
messages, sending or store. It shows a conversation's latest 50 messages, and
|
|
317
|
+
assistant-ui's `loadEarlier()` the 50 before, which `ChatMessageList` calls as the reader
|
|
318
|
+
scrolls back. A secret question is never answered here; typed answers live in the
|
|
319
|
+
Presentation State members named `typed:…`: leave them. `Markdown` draws Markdown safely.
|
package/dist/actions.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export type AppInputs = {
|
|
|
19
19
|
};
|
|
20
20
|
readonly 'conversation.create': Operated & {
|
|
21
21
|
readonly agent_id: string;
|
|
22
|
+
readonly replaces?: string;
|
|
22
23
|
};
|
|
23
24
|
readonly 'conversation.delete': ConversationControl;
|
|
24
25
|
readonly 'conversation.history': ConversationHistoryRequest;
|
|
@@ -45,22 +46,6 @@ export type AppAnswerAdditions = {
|
|
|
45
46
|
readonly 'conversation.send': {
|
|
46
47
|
readonly turn: string;
|
|
47
48
|
};
|
|
48
|
-
readonly 'record.list': {
|
|
49
|
-
readonly attachments: readonly {
|
|
50
|
-
readonly referrer: {
|
|
51
|
-
readonly room_ref: string;
|
|
52
|
-
readonly record: string;
|
|
53
|
-
};
|
|
54
|
-
}[];
|
|
55
|
-
readonly records: readonly {
|
|
56
|
-
readonly attachments: readonly {
|
|
57
|
-
readonly referrer: {
|
|
58
|
-
readonly room_ref: string;
|
|
59
|
-
readonly record: string;
|
|
60
|
-
};
|
|
61
|
-
}[];
|
|
62
|
-
}[];
|
|
63
|
-
};
|
|
64
49
|
};
|
|
65
50
|
export declare const HOUSE_APP_ACTS: Readonly<Record<string, string>>;
|
|
66
51
|
export declare const SITE_SUBMIT = "submit";
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAE1B,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACrB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"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"}
|
package/dist/actions.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { changeBatchIdentity, } from '@agentshouse/mdruntime';
|
|
2
2
|
import { doorRefusal } from './refusal.js';
|
|
3
|
+
import { finishedUpload, houseUpload } from './upload.js';
|
|
3
4
|
const HISTORY_PAGE = 100;
|
|
4
5
|
const HISTORY_CONVERSATIONS = 64;
|
|
5
6
|
const TRIGGER_ROOMS = 100;
|
|
@@ -37,10 +38,13 @@ const APP_ACTS = {
|
|
|
37
38
|
'feature.list': mapped('apps/features/read'),
|
|
38
39
|
'holder.list': mapped('apps/holders'),
|
|
39
40
|
'holder.ring': mapped('apps/ring'),
|
|
41
|
+
'inboxChat.assign': mapped('chats/assign'),
|
|
42
|
+
'inboxChat.return': mapped('chats/return'),
|
|
43
|
+
'inboxChat.takeControl': mapped('chats/take-control'),
|
|
40
44
|
'member.list': mapped('rooms/members'),
|
|
41
45
|
'message.send': mapped('apps/messages/send'),
|
|
42
46
|
'processing.read': mapped('rooms/settings/processing/read'),
|
|
43
|
-
'record.list':
|
|
47
|
+
'record.list': mapped('records/read'),
|
|
44
48
|
'relay.read': mapped('apps/relay'),
|
|
45
49
|
'routine.list': mapped('routines/access'),
|
|
46
50
|
'routineAccess.list': mapped('routines/granted'),
|
|
@@ -106,7 +110,12 @@ function unimplemented(name) {
|
|
|
106
110
|
return { kind: 'rejected', code: 'action-unimplemented', fields: { name }, retryable: false };
|
|
107
111
|
}
|
|
108
112
|
function createBody(input) {
|
|
109
|
-
|
|
113
|
+
const replaces = text(input, 'replaces');
|
|
114
|
+
return {
|
|
115
|
+
agent_id: text(input, 'agent_id'),
|
|
116
|
+
operation_id: operationId(input),
|
|
117
|
+
...(replaces === undefined ? {} : { replaces }),
|
|
118
|
+
};
|
|
110
119
|
}
|
|
111
120
|
function controlBody(input) {
|
|
112
121
|
return { conversation_id: text(input, 'conversation'), operation_id: operationId(input) };
|
|
@@ -154,32 +163,6 @@ export function actionOutcome(answer, name) {
|
|
|
154
163
|
return { kind: 'transport-uncertainty' };
|
|
155
164
|
return { kind: 'action', result: answer.body };
|
|
156
165
|
}
|
|
157
|
-
function referredRecord(view, roomRef) {
|
|
158
|
-
const held = record(view);
|
|
159
|
-
if (roomRef === undefined || typeof held.record !== 'string' || !Array.isArray(held.attachments))
|
|
160
|
-
return view;
|
|
161
|
-
const referrer = {
|
|
162
|
-
room_ref: roomRef,
|
|
163
|
-
record: held.record,
|
|
164
|
-
};
|
|
165
|
-
return {
|
|
166
|
-
...held,
|
|
167
|
-
attachments: held.attachments.map((attachment) => ({ ...record(attachment), referrer })),
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
async function recordsAction(transport, route, input, name) {
|
|
171
|
-
const outcome = actionOutcome(await transport.door(route, input), name);
|
|
172
|
-
if (outcome.kind !== 'action')
|
|
173
|
-
return outcome;
|
|
174
|
-
const roomRef = text(input, 'room_ref');
|
|
175
|
-
const read = record(outcome.result);
|
|
176
|
-
return {
|
|
177
|
-
...outcome,
|
|
178
|
-
result: Array.isArray(read.records)
|
|
179
|
-
? { ...read, records: read.records.map((view) => referredRecord(view, roomRef)) }
|
|
180
|
-
: referredRecord(outcome.result, roomRef),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
166
|
async function carry(transport, route, name, input) {
|
|
184
167
|
return actionOutcome(await transport.door(route, input), name);
|
|
185
168
|
}
|
|
@@ -217,14 +200,6 @@ function attachBody(input) {
|
|
|
217
200
|
media_type: mediaType !== undefined && mediaType.length > 0 ? mediaType : OCTET_STREAM,
|
|
218
201
|
};
|
|
219
202
|
}
|
|
220
|
-
function uploadGrant(answer) {
|
|
221
|
-
const upload = record(record(answer).upload);
|
|
222
|
-
if (upload.method !== 'POST')
|
|
223
|
-
return null;
|
|
224
|
-
if (typeof upload.operation !== 'string' || typeof upload.url !== 'string')
|
|
225
|
-
return null;
|
|
226
|
-
return { operation: upload.operation, url: upload.url };
|
|
227
|
-
}
|
|
228
203
|
async function attachAction(transport, route, input, name) {
|
|
229
204
|
const body = attachBody(input);
|
|
230
205
|
const blob = record(input).blob;
|
|
@@ -233,20 +208,16 @@ async function attachAction(transport, route, input, name) {
|
|
|
233
208
|
const outcome = actionOutcome(await transport.door(route, body), name);
|
|
234
209
|
if (outcome.kind !== 'action')
|
|
235
210
|
return outcome;
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
211
|
+
const upload = houseUpload(record(outcome.result).upload);
|
|
212
|
+
if (upload === null)
|
|
238
213
|
return { kind: 'transport-uncertainty' };
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
const refusal = doorRefusal(sent.body);
|
|
247
|
-
return refusal === null ? { kind: 'transport-uncertainty' } : { kind: 'rejected', ...refusal };
|
|
248
|
-
}
|
|
249
|
-
const path = text(sent.body, 'path');
|
|
214
|
+
const finished = await finishedUpload(transport, upload, blob);
|
|
215
|
+
if (finished === null)
|
|
216
|
+
return { kind: 'transport-uncertainty' };
|
|
217
|
+
const settled = actionOutcome(finished, name);
|
|
218
|
+
if (settled.kind !== 'action')
|
|
219
|
+
return settled;
|
|
220
|
+
const path = text(settled.result, 'path');
|
|
250
221
|
if (path === undefined)
|
|
251
222
|
return { kind: 'transport-uncertainty' };
|
|
252
223
|
const result = { path };
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EACP,aAAa,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,OAAO,EACP,aAAa,EAmBd,MAAM,wBAAwB,CAAC;AA0ChC,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACpB,MAAM,gBAAgB,CAAC;AA2BxB,MAAM,MAAM,yBAAyB,GACjC;IACE,SAAS,EAAE,cAAc,CAAC;IAC1B,SAAS,IAAI,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC,GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA8ErD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAmpBpF"}
|