@agentshouse/mdruntime 0.1.0-alpha.7 → 0.1.0-alpha.9
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/adapter.d.ts +107 -16
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js.map +1 -1
- package/dist/bootstrap.d.ts +6 -1
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +14 -6
- package/dist/bootstrap.js.map +1 -1
- package/dist/change.d.ts +1 -0
- package/dist/change.d.ts.map +1 -1
- package/dist/change.js.map +1 -1
- package/dist/client.d.ts +63 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +227 -0
- package/dist/client.js.map +1 -0
- package/dist/collection.d.ts +19 -4
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +88 -25
- package/dist/collection.js.map +1 -1
- package/dist/connection.d.ts +37 -9
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +818 -274
- package/dist/connection.js.map +1 -1
- package/dist/conversation.d.ts +57 -0
- package/dist/conversation.d.ts.map +1 -0
- package/dist/conversation.js +401 -0
- package/dist/conversation.js.map +1 -0
- package/dist/durability.d.ts +8 -3
- package/dist/durability.d.ts.map +1 -1
- package/dist/durability.js +5 -59
- package/dist/durability.js.map +1 -1
- package/dist/file.d.ts +20 -0
- package/dist/file.d.ts.map +1 -0
- package/dist/file.js +149 -0
- package/dist/file.js.map +1 -0
- package/dist/host.d.ts +9 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +200 -0
- package/dist/host.js.map +1 -0
- package/dist/identity.d.ts +2 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +16 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +16 -2
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +196 -15
- package/dist/memory.js.map +1 -1
- package/dist/model.d.ts +70 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +28 -0
- package/dist/model.js.map +1 -0
- package/dist/outcome.d.ts +16 -9
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +10 -0
- package/dist/outcome.js.map +1 -1
- package/dist/query.d.ts +13 -0
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +18 -0
- package/dist/query.js.map +1 -0
- package/dist/refresh.d.ts +2 -1
- package/dist/refresh.d.ts.map +1 -1
- package/dist/refresh.js +6 -4
- package/dist/refresh.js.map +1 -1
- package/dist/replica.d.ts +5 -2
- package/dist/replica.d.ts.map +1 -1
- package/dist/replica.js +23 -6
- package/dist/replica.js.map +1 -1
- package/dist/save.d.ts +6 -1
- package/dist/save.d.ts.map +1 -1
- package/dist/save.js +52 -11
- package/dist/save.js.map +1 -1
- package/dist/status.d.ts +11 -2
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +5 -4
- package/dist/status.js.map +1 -1
- package/dist/store.d.ts +38 -4
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +64 -7
- package/dist/store.js.map +1 -1
- package/dist/wire.d.ts +63 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +139 -0
- package/dist/wire.js.map +1 -0
- package/package.json +10 -2
package/dist/client.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { answer, AUTHORIZATION_ENDED, carried, envelope, PROTOCOL_MISMATCH } from './wire.js';
|
|
2
|
+
export function connectMdRuntime(port) {
|
|
3
|
+
let sequence = 0;
|
|
4
|
+
let refusal = null;
|
|
5
|
+
let ended = false;
|
|
6
|
+
const calls = new Map();
|
|
7
|
+
const acks = new Map();
|
|
8
|
+
const listeners = new Map();
|
|
9
|
+
const send = (message)=>{
|
|
10
|
+
port.postMessage(envelope(message));
|
|
11
|
+
};
|
|
12
|
+
function refuse(reported) {
|
|
13
|
+
refusal = reported;
|
|
14
|
+
for (const waiting of acks.values())waiting.settle();
|
|
15
|
+
acks.clear();
|
|
16
|
+
const failure = new Error(reported.reason);
|
|
17
|
+
for (const waiting of calls.values())waiting.fail(failure);
|
|
18
|
+
calls.clear();
|
|
19
|
+
for (const listener of listeners.values()){
|
|
20
|
+
if (listener.topic === 'connection-refusal') listener.notify(reported);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function end() {
|
|
24
|
+
ended = true;
|
|
25
|
+
const failure = new Error(AUTHORIZATION_ENDED);
|
|
26
|
+
for (const waiting of acks.values())waiting.fail(failure);
|
|
27
|
+
acks.clear();
|
|
28
|
+
for (const waiting of calls.values())waiting.fail(failure);
|
|
29
|
+
calls.clear();
|
|
30
|
+
listeners.clear();
|
|
31
|
+
}
|
|
32
|
+
port.addEventListener('message', (event)=>{
|
|
33
|
+
const wire = carried(event.data);
|
|
34
|
+
if (wire === null) return;
|
|
35
|
+
if (!wire.matching) {
|
|
36
|
+
refuse(PROTOCOL_MISMATCH);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const message = answer(wire.message);
|
|
40
|
+
if (message === null) return;
|
|
41
|
+
if (message.kind === 'refusal') {
|
|
42
|
+
refuse(message.refusal);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (message.kind === 'ended') {
|
|
46
|
+
end();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (message.kind === 'event') {
|
|
50
|
+
listeners.get(message.id)?.notify(message.value);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const subscribing = acks.get(message.id);
|
|
54
|
+
if (subscribing !== undefined) {
|
|
55
|
+
acks.delete(message.id);
|
|
56
|
+
if (message.kind === 'failure') {
|
|
57
|
+
listeners.delete(message.id);
|
|
58
|
+
subscribing.fail(new Error(message.message));
|
|
59
|
+
} else subscribing.settle();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const waiting = calls.get(message.id);
|
|
63
|
+
if (waiting === undefined) return;
|
|
64
|
+
calls.delete(message.id);
|
|
65
|
+
if (message.kind === 'failure') waiting.fail(new Error(message.message));
|
|
66
|
+
else waiting.settle(message.value);
|
|
67
|
+
});
|
|
68
|
+
port.start();
|
|
69
|
+
send({
|
|
70
|
+
kind: 'hello'
|
|
71
|
+
});
|
|
72
|
+
function ask(member, input) {
|
|
73
|
+
if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));
|
|
74
|
+
if (refusal !== null) return Promise.reject(new Error(refusal.reason));
|
|
75
|
+
const id = sequence += 1;
|
|
76
|
+
return new Promise((settle, fail)=>{
|
|
77
|
+
calls.set(id, {
|
|
78
|
+
settle: settle,
|
|
79
|
+
fail
|
|
80
|
+
});
|
|
81
|
+
send({
|
|
82
|
+
kind: 'call',
|
|
83
|
+
id,
|
|
84
|
+
member,
|
|
85
|
+
input
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function watch(topic, input, notify) {
|
|
90
|
+
if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));
|
|
91
|
+
const id = sequence += 1;
|
|
92
|
+
listeners.set(id, {
|
|
93
|
+
topic,
|
|
94
|
+
notify
|
|
95
|
+
});
|
|
96
|
+
const end = ()=>{
|
|
97
|
+
if (!listeners.delete(id)) return;
|
|
98
|
+
if (refusal === null) send({
|
|
99
|
+
kind: 'stop',
|
|
100
|
+
id
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
if (refusal !== null) {
|
|
104
|
+
if (topic === 'connection-refusal') notify(refusal);
|
|
105
|
+
return Promise.resolve(end);
|
|
106
|
+
}
|
|
107
|
+
return new Promise((settle, fail)=>{
|
|
108
|
+
acks.set(id, {
|
|
109
|
+
settle: ()=>settle(end),
|
|
110
|
+
fail
|
|
111
|
+
});
|
|
112
|
+
send({
|
|
113
|
+
kind: 'observe',
|
|
114
|
+
id,
|
|
115
|
+
topic,
|
|
116
|
+
input
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
rooms: ()=>ask('rooms', []),
|
|
122
|
+
query: (options)=>ask('query', [
|
|
123
|
+
options
|
|
124
|
+
]),
|
|
125
|
+
types: (locator)=>ask('types', [
|
|
126
|
+
locator
|
|
127
|
+
]),
|
|
128
|
+
syncStatus: ()=>ask('syncStatus', []),
|
|
129
|
+
draft: {
|
|
130
|
+
list: ()=>ask('draft.list', []),
|
|
131
|
+
read: (locator, path)=>ask('draft.read', [
|
|
132
|
+
locator,
|
|
133
|
+
path
|
|
134
|
+
]),
|
|
135
|
+
replace: (locator, path, content)=>ask('draft.replace', [
|
|
136
|
+
locator,
|
|
137
|
+
path,
|
|
138
|
+
content
|
|
139
|
+
]),
|
|
140
|
+
discard: (locator, path)=>ask('draft.discard', [
|
|
141
|
+
locator,
|
|
142
|
+
path
|
|
143
|
+
])
|
|
144
|
+
},
|
|
145
|
+
save: (locator, changes, replacing)=>ask('save', [
|
|
146
|
+
locator,
|
|
147
|
+
changes,
|
|
148
|
+
replacing
|
|
149
|
+
]),
|
|
150
|
+
outcome: (identifier)=>ask('outcome', [
|
|
151
|
+
identifier
|
|
152
|
+
]),
|
|
153
|
+
queue: {
|
|
154
|
+
discard: (locator, identifier)=>ask('queue.discard', [
|
|
155
|
+
locator,
|
|
156
|
+
identifier
|
|
157
|
+
])
|
|
158
|
+
},
|
|
159
|
+
presentation: {
|
|
160
|
+
read: ()=>ask('presentation.read', []),
|
|
161
|
+
write: (value)=>ask('presentation.write', [
|
|
162
|
+
value
|
|
163
|
+
])
|
|
164
|
+
},
|
|
165
|
+
conversation: {
|
|
166
|
+
list: ()=>ask('conversation.list', []),
|
|
167
|
+
read: (conversation)=>ask('conversation.read', [
|
|
168
|
+
conversation
|
|
169
|
+
]),
|
|
170
|
+
older: (conversation)=>ask('conversation.older', [
|
|
171
|
+
conversation
|
|
172
|
+
]),
|
|
173
|
+
compose: (conversation, instruction)=>ask('conversation.compose', [
|
|
174
|
+
conversation,
|
|
175
|
+
instruction
|
|
176
|
+
]),
|
|
177
|
+
discard: (conversation)=>ask('conversation.discard', [
|
|
178
|
+
conversation
|
|
179
|
+
]),
|
|
180
|
+
create: (input)=>ask('conversation.create', [
|
|
181
|
+
input
|
|
182
|
+
]),
|
|
183
|
+
send: (conversation)=>ask('conversation.send', [
|
|
184
|
+
conversation
|
|
185
|
+
]),
|
|
186
|
+
answer: (conversation, answer)=>ask('conversation.answer', [
|
|
187
|
+
conversation,
|
|
188
|
+
answer
|
|
189
|
+
]),
|
|
190
|
+
interrupt: (conversation)=>ask('conversation.interrupt', [
|
|
191
|
+
conversation
|
|
192
|
+
]),
|
|
193
|
+
kill: (conversation)=>ask('conversation.kill', [
|
|
194
|
+
conversation
|
|
195
|
+
]),
|
|
196
|
+
cancel: (conversation, turn)=>ask('conversation.cancel', [
|
|
197
|
+
conversation,
|
|
198
|
+
turn
|
|
199
|
+
]),
|
|
200
|
+
delete: (conversation)=>ask('conversation.delete', [
|
|
201
|
+
conversation
|
|
202
|
+
])
|
|
203
|
+
},
|
|
204
|
+
history: (locator, path, query)=>ask('history', [
|
|
205
|
+
locator,
|
|
206
|
+
path,
|
|
207
|
+
query
|
|
208
|
+
]),
|
|
209
|
+
call: (name, input)=>ask('call', [
|
|
210
|
+
name,
|
|
211
|
+
input
|
|
212
|
+
]),
|
|
213
|
+
log: ()=>ask('log', []),
|
|
214
|
+
storageLoss: ()=>ask('storageLoss', []),
|
|
215
|
+
persistence: ()=>ask('persistence', []),
|
|
216
|
+
observe (topic, second, third) {
|
|
217
|
+
const positional = topic === 'query' || topic === 'queue' || topic === 'conversation';
|
|
218
|
+
const notify = positional ? third : second;
|
|
219
|
+
return watch(topic, positional ? [
|
|
220
|
+
second
|
|
221
|
+
] : [], notify);
|
|
222
|
+
},
|
|
223
|
+
reauthorize: ()=>ask('reauthorize', [])
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/client.ts"],"sourcesContent":["import type { QueryOptions, QueryResult } from '@agentshouse/query';\nimport type { Change } from './change.js';\nimport type {\n AppRoom,\n ConnectionRefusal,\n DraftEntry,\n HistoryQuery,\n RoomTypes,\n SaveResult,\n} from './connection.js';\nimport type { HistoryResult } from './adapter.js';\nimport type { ConversationEntry, ConversationView, UnsentInstruction } from './conversation.js';\nimport type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';\nimport type { SyncStatus } from './status.js';\nimport {\n answer,\n AUTHORIZATION_ENDED,\n carried,\n envelope,\n PROTOCOL_MISMATCH,\n type RuntimePort,\n type WireMember,\n type WireRequest,\n type WireTopic,\n} from './wire.js';\n\nexport type MdRuntimeClient = {\n rooms(): Promise<readonly AppRoom[]>;\n query(options?: QueryOptions): Promise<QueryResult>;\n types(locator: string): Promise<RoomTypes>;\n syncStatus(): Promise<SyncStatus>;\n draft: {\n list(): Promise<readonly DraftEntry[]>;\n read(locator: string, path: string): Promise<unknown>;\n replace(locator: string, path: string, content: unknown): Promise<void>;\n discard(locator: string, path: string): Promise<void>;\n };\n save(locator: string, changes: readonly Change[], replacing?: string): Promise<SaveResult>;\n outcome(identifier: string): Promise<SubmissionOutcome | null>;\n queue: { discard(locator: string, identifier: string): Promise<void> };\n presentation: {\n read(): Promise<unknown>;\n write(value: unknown): Promise<void>;\n };\n conversation: {\n list(): Promise<readonly ConversationEntry[]>;\n read(conversation: string): Promise<ConversationView>;\n older(conversation: string): Promise<CallResult | null>;\n compose(conversation: string, instruction: UnsentInstruction): Promise<void>;\n discard(conversation: string): Promise<void>;\n create(input: unknown): Promise<CallResult>;\n send(conversation: string): Promise<CallResult>;\n answer(conversation: string, answer: unknown): Promise<CallResult>;\n interrupt(conversation: string): Promise<CallResult>;\n kill(conversation: string): Promise<CallResult>;\n cancel(conversation: string, turn: string): Promise<CallResult>;\n delete(conversation: string): Promise<CallResult>;\n };\n history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;\n call(name: string, input: unknown): Promise<CallResult>;\n log(): Promise<string>;\n storageLoss(): Promise<string | null>;\n persistence(): Promise<boolean>;\n observe: {\n (topic: 'rooms', listener: (rooms: readonly AppRoom[]) => void): Promise<() => void>;\n (\n topic: 'connection-refusal',\n listener: (refusal: ConnectionRefusal | null) => void,\n ): Promise<() => void>;\n (topic: 'storage-loss', listener: (statement: string | null) => void): Promise<() => void>;\n (topic: 'sync-status', listener: (status: SyncStatus) => void): Promise<() => void>;\n (\n topic: 'query',\n query: QueryOptions,\n listener: (result: QueryResult) => void,\n ): Promise<() => void>;\n (\n topic: 'queue',\n locator: string,\n listener: (entries: readonly QueueEntry[]) => void,\n ): Promise<() => void>;\n (topic: 'drafts', listener: (drafts: readonly DraftEntry[]) => void): Promise<() => void>;\n (topic: 'presentation', listener: (value: unknown) => void): Promise<() => void>;\n (\n topic: 'conversation',\n conversation: string,\n listener: (view: ConversationView) => void,\n ): Promise<() => void>;\n };\n reauthorize(): Promise<void>;\n};\n\nexport function connectMdRuntime(port: RuntimePort): MdRuntimeClient {\n let sequence = 0;\n let refusal: ConnectionRefusal | null = null;\n let ended = false;\n const calls = new Map<\n number,\n { settle: (value: unknown) => void; fail: (error: Error) => void }\n >();\n const acks = new Map<number, { settle: () => void; fail: (error: Error) => void }>();\n const listeners = new Map<number, { topic: WireTopic; notify: (value: unknown) => void }>();\n\n const send = (message: WireRequest) => {\n port.postMessage(envelope(message));\n };\n\n function refuse(reported: ConnectionRefusal) {\n refusal = reported;\n for (const waiting of acks.values()) waiting.settle();\n acks.clear();\n const failure = new Error(reported.reason);\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n for (const listener of listeners.values()) {\n if (listener.topic === 'connection-refusal') listener.notify(reported);\n }\n }\n\n function end() {\n ended = true;\n const failure = new Error(AUTHORIZATION_ENDED);\n for (const waiting of acks.values()) waiting.fail(failure);\n acks.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n listeners.clear();\n }\n\n port.addEventListener('message', (event) => {\n const wire = carried(event.data);\n if (wire === null) return;\n if (!wire.matching) {\n refuse(PROTOCOL_MISMATCH);\n return;\n }\n const message = answer(wire.message);\n if (message === null) return;\n if (message.kind === 'refusal') {\n refuse(message.refusal);\n return;\n }\n if (message.kind === 'ended') {\n end();\n return;\n }\n if (message.kind === 'event') {\n listeners.get(message.id)?.notify(message.value);\n return;\n }\n const subscribing = acks.get(message.id);\n if (subscribing !== undefined) {\n acks.delete(message.id);\n if (message.kind === 'failure') {\n listeners.delete(message.id);\n subscribing.fail(new Error(message.message));\n } else subscribing.settle();\n return;\n }\n const waiting = calls.get(message.id);\n if (waiting === undefined) return;\n calls.delete(message.id);\n if (message.kind === 'failure') waiting.fail(new Error(message.message));\n else waiting.settle(message.value);\n });\n port.start();\n send({ kind: 'hello' });\n\n function ask<T>(member: WireMember, input: readonly unknown[]): Promise<T> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n if (refusal !== null) return Promise.reject(new Error(refusal.reason));\n const id = (sequence += 1);\n return new Promise<T>((settle, fail) => {\n calls.set(id, { settle: settle as (value: unknown) => void, fail });\n send({ kind: 'call', id, member, input });\n });\n }\n\n function watch(\n topic: WireTopic,\n input: readonly unknown[],\n notify: (value: unknown) => void,\n ): Promise<() => void> {\n if (ended) return Promise.reject(new Error(AUTHORIZATION_ENDED));\n const id = (sequence += 1);\n listeners.set(id, { topic, notify });\n const end = () => {\n if (!listeners.delete(id)) return;\n if (refusal === null) send({ kind: 'stop', id });\n };\n if (refusal !== null) {\n if (topic === 'connection-refusal') notify(refusal);\n return Promise.resolve(end);\n }\n return new Promise<() => void>((settle, fail) => {\n acks.set(id, { settle: () => settle(end), fail });\n send({ kind: 'observe', id, topic, input });\n });\n }\n\n return {\n rooms: () => ask<readonly AppRoom[]>('rooms', []),\n query: (options?: QueryOptions) => ask<QueryResult>('query', [options]),\n types: (locator: string) => ask<RoomTypes>('types', [locator]),\n syncStatus: () => ask<SyncStatus>('syncStatus', []),\n draft: {\n list: () => ask<readonly DraftEntry[]>('draft.list', []),\n read: (locator: string, path: string) => ask<unknown>('draft.read', [locator, path]),\n replace: (locator: string, path: string, content: unknown) =>\n ask<void>('draft.replace', [locator, path, content]),\n discard: (locator: string, path: string) => ask<void>('draft.discard', [locator, path]),\n },\n save: (locator: string, changes: readonly Change[], replacing?: string) =>\n ask<SaveResult>('save', [locator, changes, replacing]),\n outcome: (identifier: string) => ask<SubmissionOutcome | null>('outcome', [identifier]),\n queue: {\n discard: (locator: string, identifier: string) =>\n ask<void>('queue.discard', [locator, identifier]),\n },\n presentation: {\n read: () => ask<unknown>('presentation.read', []),\n write: (value: unknown) => ask<void>('presentation.write', [value]),\n },\n conversation: {\n list: () => ask<readonly ConversationEntry[]>('conversation.list', []),\n read: (conversation: string) => ask<ConversationView>('conversation.read', [conversation]),\n older: (conversation: string) => ask<CallResult | null>('conversation.older', [conversation]),\n compose: (conversation: string, instruction: UnsentInstruction) =>\n ask<void>('conversation.compose', [conversation, instruction]),\n discard: (conversation: string) => ask<void>('conversation.discard', [conversation]),\n create: (input: unknown) => ask<CallResult>('conversation.create', [input]),\n send: (conversation: string) => ask<CallResult>('conversation.send', [conversation]),\n answer: (conversation: string, answer: unknown) =>\n ask<CallResult>('conversation.answer', [conversation, answer]),\n interrupt: (conversation: string) =>\n ask<CallResult>('conversation.interrupt', [conversation]),\n kill: (conversation: string) => ask<CallResult>('conversation.kill', [conversation]),\n cancel: (conversation: string, turn: string) =>\n ask<CallResult>('conversation.cancel', [conversation, turn]),\n delete: (conversation: string) => ask<CallResult>('conversation.delete', [conversation]),\n },\n history: (locator: string, path: string, query?: HistoryQuery) =>\n ask<HistoryResult>('history', [locator, path, query]),\n call: (name: string, input: unknown) => ask<CallResult>('call', [name, input]),\n log: () => ask<string>('log', []),\n storageLoss: () => ask<string | null>('storageLoss', []),\n persistence: () => ask<boolean>('persistence', []),\n observe(\n topic: WireTopic,\n second: QueryOptions | string | ((value: never) => void),\n third?: (value: never) => void,\n ) {\n const positional = topic === 'query' || topic === 'queue' || topic === 'conversation';\n const notify = (positional ? third : second) as (value: unknown) => void;\n return watch(topic, positional ? [second] : [], notify);\n },\n reauthorize: () => ask<void>('reauthorize', []),\n };\n}\n\nexport type { RuntimePort } from './wire.js';\n"],"names":["answer","AUTHORIZATION_ENDED","carried","envelope","PROTOCOL_MISMATCH","connectMdRuntime","port","sequence","refusal","ended","calls","Map","acks","listeners","send","message","postMessage","refuse","reported","waiting","values","settle","clear","failure","Error","reason","fail","listener","topic","notify","end","addEventListener","event","wire","data","matching","kind","get","id","value","subscribing","undefined","delete","start","ask","member","input","Promise","reject","set","watch","resolve","rooms","query","options","types","locator","syncStatus","draft","list","read","path","replace","content","discard","save","changes","replacing","outcome","identifier","queue","presentation","write","conversation","older","compose","instruction","create","interrupt","kill","cancel","turn","history","call","name","log","storageLoss","persistence","observe","second","third","positional","reauthorize"],"mappings":"AAcA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,iBAAiB,QAKZ,YAAY;AAoEnB,OAAO,SAASC,iBAAiBC,IAAiB;IAChD,IAAIC,WAAW;IACf,IAAIC,UAAoC;IACxC,IAAIC,QAAQ;IACZ,MAAMC,QAAQ,IAAIC;IAIlB,MAAMC,OAAO,IAAID;IACjB,MAAME,YAAY,IAAIF;IAEtB,MAAMG,OAAO,CAACC;QACZT,KAAKU,WAAW,CAACb,SAASY;IAC5B;IAEA,SAASE,OAAOC,QAA2B;QACzCV,UAAUU;QACV,KAAK,MAAMC,WAAWP,KAAKQ,MAAM,GAAID,QAAQE,MAAM;QACnDT,KAAKU,KAAK;QACV,MAAMC,UAAU,IAAIC,MAAMN,SAASO,MAAM;QACzC,KAAK,MAAMN,WAAWT,MAAMU,MAAM,GAAID,QAAQO,IAAI,CAACH;QACnDb,MAAMY,KAAK;QACX,KAAK,MAAMK,YAAYd,UAAUO,MAAM,GAAI;YACzC,IAAIO,SAASC,KAAK,KAAK,sBAAsBD,SAAS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oBAACE;iBAAM;YAC1EhC,MAAM,CAAC2D,eAAyB7B,IAAgB,qBAAqB;oBAAC6B;iBAAa;YACnFzE,QAAQ,CAACyE,cAAsBzE,SAC7B4C,IAAgB,uBAAuB;oBAAC6B;oBAAczE;iBAAO;YAC/D8E,WAAW,CAACL,eACV7B,IAAgB,0BAA0B;oBAAC6B;iBAAa;YAC1DM,MAAM,CAACN,eAAyB7B,IAAgB,qBAAqB;oBAAC6B;iBAAa;YACnFO,QAAQ,CAACP,cAAsBQ,OAC7BrC,IAAgB,uBAAuB;oBAAC6B;oBAAcQ;iBAAK;YAC7DvC,QAAQ,CAAC+B,eAAyB7B,IAAgB,uBAAuB;oBAAC6B;iBAAa;QACzF;QACAS,SAAS,CAAC1B,SAAiBK,MAAcR,QACvCT,IAAmB,WAAW;gBAACY;gBAASK;gBAAMR;aAAM;QACtD8B,MAAM,CAACC,MAActC,QAAmBF,IAAgB,QAAQ;gBAACwC;gBAAMtC;aAAM;QAC7EuC,KAAK,IAAMzC,IAAY,OAAO,EAAE;QAChC0C,aAAa,IAAM1C,IAAmB,eAAe,EAAE;QACvD2C,aAAa,IAAM3C,IAAa,eAAe,EAAE;QACjD4C,SACE5D,KAAgB,EAChB6D,MAAwD,EACxDC,KAA8B;YAE9B,MAAMC,aAAa/D,UAAU,WAAWA,UAAU,WAAWA,UAAU;YACvE,MAAMC,SAAU8D,aAAaD,QAAQD;YACrC,OAAOvC,MAAMtB,OAAO+D,aAAa;gBAACF;aAAO,GAAG,EAAE,EAAE5D;QAClD;QACA+D,aAAa,IAAMhD,IAAU,eAAe,EAAE;IAChD;AACF"}
|
package/dist/collection.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type Document } from '@agentshouse/mdmodel';
|
|
1
|
+
import { type Document, type Validation } from '@agentshouse/mdmodel';
|
|
2
2
|
import type { Selector } from '@agentshouse/query';
|
|
3
|
+
import type { AttachedModelBinding, ModelState } from './model.js';
|
|
3
4
|
import type { MdModelIdentity } from './adapter.js';
|
|
4
5
|
export declare const MD_MODEL: MdModelIdentity;
|
|
5
6
|
export declare const PRESENTED: Selector;
|
|
@@ -11,8 +12,22 @@ export type MdType = {
|
|
|
11
12
|
};
|
|
12
13
|
export type Collection = {
|
|
13
14
|
documents: Readonly<Record<string, Document>>;
|
|
14
|
-
|
|
15
|
+
composition: Composition;
|
|
16
|
+
};
|
|
17
|
+
export type Composition = {
|
|
18
|
+
collectionRoot: string;
|
|
19
|
+
model: ModelState;
|
|
20
|
+
selection: {
|
|
21
|
+
roots: readonly string[];
|
|
22
|
+
model: ModelState;
|
|
23
|
+
} | null;
|
|
24
|
+
};
|
|
25
|
+
export declare function governing(composition: Composition, path: string): ModelState;
|
|
26
|
+
export declare function typesAt(composition: Composition, path: string): readonly MdType[];
|
|
27
|
+
export declare function parseCollection(text: Readonly<Record<string, string>>, composition: Composition): Collection;
|
|
28
|
+
export declare function readCollection(text: Readonly<Record<string, string>>, composition: Composition): Collection | null;
|
|
29
|
+
export declare function validRoot(root: unknown): root is string;
|
|
30
|
+
export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition, binding: AttachedModelBinding | null): Validation & {
|
|
31
|
+
source?: 'content' | 'model';
|
|
15
32
|
};
|
|
16
|
-
export declare function parseCollection(text: Readonly<Record<string, string>>): Collection;
|
|
17
|
-
export declare function readCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[]): Collection | null;
|
|
18
33
|
//# sourceMappingURL=collection.d.ts.map
|
package/dist/collection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,QAAQ,EAAE,KAA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EAAE,WAAW,GACvB,UAAU,CAOZ;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtC,WAAW,EAAE,WAAW,GACvB,UAAU,GAAG,IAAI,CAenB;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAEvD;AAyCD,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACtC,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,oBAAoB,GAAG,IAAI,GACnC,UAAU,GAAG;IAAE,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAA;CAAE,CA4C/C"}
|
package/dist/collection.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { parse, validate, VERSION } from '@agentshouse/mdmodel';
|
|
2
|
-
|
|
3
|
-
const DEFINITION = 'definition';
|
|
2
|
+
import { beneath, normalize } from './paths.js';
|
|
4
3
|
export const MD_MODEL = {
|
|
5
4
|
identity: '@agentshouse/mdmodel',
|
|
6
5
|
version: VERSION
|
|
@@ -10,43 +9,107 @@ export const PRESENTED = {
|
|
|
10
9
|
$regex: '\\.md$'
|
|
11
10
|
}
|
|
12
11
|
};
|
|
13
|
-
function
|
|
14
|
-
return
|
|
12
|
+
function selected(composition, path) {
|
|
13
|
+
return composition.selection !== null && composition.selection.roots.some((root)=>beneath(root, path));
|
|
15
14
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
15
|
+
export function governing(composition, path) {
|
|
16
|
+
return composition.selection !== null && selected(composition, path) ? composition.selection.model : composition.model;
|
|
18
17
|
}
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
path,
|
|
23
|
-
fields: declaredIn(document, 'fields'),
|
|
24
|
-
sections: declaredIn(document, 'sections')
|
|
25
|
-
};
|
|
18
|
+
export function typesAt(composition, path) {
|
|
19
|
+
const model = governing(composition, path);
|
|
20
|
+
return model.status === 'unavailable' ? [] : model.types;
|
|
26
21
|
}
|
|
27
|
-
export function parseCollection(text) {
|
|
22
|
+
export function parseCollection(text, composition) {
|
|
28
23
|
const documents = {};
|
|
29
24
|
for (const path of Object.keys(text).sort()){
|
|
30
25
|
const parsed = parse(text[path], path);
|
|
31
26
|
if (parsed.ok) documents[path] = parsed.document;
|
|
32
27
|
}
|
|
33
|
-
const types = [];
|
|
34
|
-
for (const [path, document] of Object.entries(documents)){
|
|
35
|
-
if (!isMarkdown(path) || document.type !== DEFINITION) continue;
|
|
36
|
-
types.push(mdType(path, document));
|
|
37
|
-
}
|
|
38
28
|
return {
|
|
39
29
|
documents,
|
|
40
|
-
|
|
30
|
+
composition
|
|
41
31
|
};
|
|
42
32
|
}
|
|
43
|
-
export function readCollection(text,
|
|
44
|
-
|
|
33
|
+
export function readCollection(text, composition) {
|
|
34
|
+
if (!validRoot(composition.collectionRoot)) return null;
|
|
35
|
+
const collection = parseCollection(text, composition);
|
|
45
36
|
if (Object.keys(collection.documents).length !== Object.keys(text).length) return null;
|
|
46
|
-
if (
|
|
47
|
-
binaryTargets
|
|
48
|
-
}).verdict === 'refuse') return null;
|
|
37
|
+
if (Object.entries(collection.documents).some(([path, document])=>!member(path, composition.collectionRoot) && !selected(composition, path) && document.type !== undefined && document.type !== 'any')) return null;
|
|
49
38
|
return collection;
|
|
50
39
|
}
|
|
40
|
+
export function validRoot(root) {
|
|
41
|
+
return typeof root === 'string' && normalize(root) === root;
|
|
42
|
+
}
|
|
43
|
+
function member(path, root) {
|
|
44
|
+
return root === '' || path.startsWith(`${root}/`);
|
|
45
|
+
}
|
|
46
|
+
function validateAgainst(documents, binaryTargets, prefix, model, binding) {
|
|
47
|
+
if (model.status === 'unavailable' || binding === null) {
|
|
48
|
+
const typed = Object.entries(documents).find(([, content])=>{
|
|
49
|
+
const parsed = parse(content);
|
|
50
|
+
return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
|
|
51
|
+
});
|
|
52
|
+
if (typed !== undefined) return {
|
|
53
|
+
verdict: 'refuse',
|
|
54
|
+
rule: 'model-unavailable',
|
|
55
|
+
file: `${prefix}${typed[0]}`,
|
|
56
|
+
version: VERSION
|
|
57
|
+
};
|
|
58
|
+
return validate(documents, {
|
|
59
|
+
binaryTargets
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const verdict = binding.validate({
|
|
63
|
+
model: model.snapshot,
|
|
64
|
+
documents,
|
|
65
|
+
binaryTargets
|
|
66
|
+
});
|
|
67
|
+
if (verdict.verdict === 'refuse' && verdict.source === 'model') return verdict;
|
|
68
|
+
if (verdict.verdict === 'accept') return verdict;
|
|
69
|
+
return {
|
|
70
|
+
...verdict,
|
|
71
|
+
file: `${prefix}${verdict.file}`,
|
|
72
|
+
...verdict.referrers === undefined ? {} : {
|
|
73
|
+
referrers: verdict.referrers.map((path)=>`${prefix}${path}`)
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export function validateCollection(text, binaryTargets, composition, binding) {
|
|
78
|
+
const prefix = composition.collectionRoot === '' ? '' : `${composition.collectionRoot}/`;
|
|
79
|
+
const collection = {};
|
|
80
|
+
const selection = {};
|
|
81
|
+
for (const [path, content] of Object.entries(text)){
|
|
82
|
+
if (member(path, composition.collectionRoot)) {
|
|
83
|
+
collection[path.slice(prefix.length)] = content;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (selected(composition, path)) {
|
|
87
|
+
selection[path] = content;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const parsed = parse(content, path);
|
|
91
|
+
if (!parsed.ok) return {
|
|
92
|
+
verdict: 'refuse',
|
|
93
|
+
...parsed.refusal
|
|
94
|
+
};
|
|
95
|
+
if (Object.hasOwn(parsed.document.fields, 'type') && parsed.document.fields.type !== 'any') {
|
|
96
|
+
return {
|
|
97
|
+
verdict: 'refuse',
|
|
98
|
+
rule: 'outside-collection-type',
|
|
99
|
+
file: path,
|
|
100
|
+
version: VERSION
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const verdicts = [
|
|
105
|
+
validateAgainst(collection, binaryTargets.filter((path)=>member(path, composition.collectionRoot)).map((path)=>path.slice(prefix.length)), prefix, composition.model, binding)
|
|
106
|
+
];
|
|
107
|
+
if (composition.selection !== null) {
|
|
108
|
+
verdicts.push(validateAgainst(selection, binaryTargets.filter((path)=>selected(composition, path)), '', composition.selection.model, binding));
|
|
109
|
+
}
|
|
110
|
+
const refusals = verdicts.filter((verdict)=>verdict.verdict === 'refuse');
|
|
111
|
+
if (refusals.length === 0) return verdicts[0];
|
|
112
|
+
return refusals.find((refusal)=>refusal.rule !== 'model-unavailable') ?? refusals[0];
|
|
113
|
+
}
|
|
51
114
|
|
|
52
115
|
//# sourceMappingURL=collection.js.map
|
package/dist/collection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/workspace/packages/mdruntime/src/collection.ts"],"sourcesContent":["import { parse, validate, VERSION, type Document } from '@agentshouse/mdmodel';\nimport type { Selector } from '@agentshouse/query';\nimport type { MdModelIdentity } from './adapter.js';\n\nconst MARKDOWN = '.md';\nconst DEFINITION = 'definition';\n\nexport const MD_MODEL: MdModelIdentity = { identity: '@agentshouse/mdmodel', version: VERSION };\n\nexport const PRESENTED: Selector = { path: { $regex: '\\\\.md$' } };\n\nexport type MdType = {\n name: string;\n path: string;\n fields: Readonly<Record<string, unknown>>;\n sections: Readonly<Record<string, unknown>>;\n};\n\nexport type Collection = {\n documents: Readonly<Record<string, Document>>;\n types: readonly MdType[];\n};\n\nfunction isMarkdown(path: string) {\n return path.endsWith(MARKDOWN);\n}\n\nfunction declaredIn(document: Document, part: 'fields' | 'sections') {\n return (document.fields[part] ?? {}) as Readonly<Record<string, unknown>>;\n}\n\nfunction mdType(path: string, document: Document): MdType {\n return {\n name: path.slice(path.lastIndexOf('/') + 1, -MARKDOWN.length),\n path,\n fields: declaredIn(document, 'fields'),\n sections: declaredIn(document, 'sections'),\n };\n}\n\nexport function parseCollection(text: Readonly<Record<string, string>>): Collection {\n const documents: Record<string, Document> = {};\n for (const path of Object.keys(text).sort()) {\n const parsed = parse(text[path], path);\n if (parsed.ok) documents[path] = parsed.document;\n }\n const types: MdType[] = [];\n for (const [path, document] of Object.entries(documents)) {\n if (!isMarkdown(path) || document.type !== DEFINITION) continue;\n types.push(mdType(path, document));\n }\n return { documents, types };\n}\n\nexport function readCollection(\n text: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n): Collection | null {\n const collection = parseCollection(text);\n if (Object.keys(collection.documents).length !== Object.keys(text).length) return null;\n if (validate(text, { binaryTargets }).verdict === 'refuse') return null;\n return collection;\n}\n"],"names":["parse","validate","VERSION","MARKDOWN","DEFINITION","MD_MODEL","identity","version","PRESENTED","path","$regex","isMarkdown","endsWith","declaredIn","document","part","fields","mdType","name","slice","lastIndexOf","length","sections","parseCollection","text","documents","Object","keys","sort","parsed","ok","types","entries","type","push","readCollection","binaryTargets","collection","verdict"],"mappings":"AAAA,SAASA,KAAK,EAAEC,QAAQ,EAAEC,OAAO,QAAuB,uBAAuB;AAI/E,MAAMC,WAAW;AACjB,MAAMC,aAAa;AAEnB,OAAO,MAAMC,WAA4B;IAAEC,UAAU;IAAwBC,SAASL;AAAQ,EAAE;AAEhG,OAAO,MAAMM,YAAsB;IAAEC,MAAM;QAAEC,QAAQ;IAAS;AAAE,EAAE;AAclE,SAASC,WAAWF,IAAY;IAC9B,OAAOA,KAAKG,QAAQ,CAACT;AACvB;AAEA,SAASU,WAAWC,QAAkB,EAAEC,IAA2B;IACjE,OAAQD,SAASE,MAAM,CAACD,KAAK,IAAI,CAAC;AACpC;AAEA,SAASE,OAAOR,IAAY,EAAEK,QAAkB;IAC9C,OAAO;QACLI,MAAMT,KAAKU,KAAK,CAACV,KAAKW,WAAW,CAAC,OAAO,GAAG,CAACjB,SAASkB,MAAM;QAC5DZ;QACAO,QAAQH,WAAWC,UAAU;QAC7BQ,UAAUT,WAAWC,UAAU;IACjC;AACF;AAEA,OAAO,SAASS,gBAAgBC,IAAsC;IACpE,MAAMC,YAAsC,CAAC;IAC7C,KAAK,MAAMhB,QAAQiB,OAAOC,IAAI,CAACH,MAAMI,IAAI,GAAI;QAC3C,MAAMC,SAAS7B,MAAMwB,IAAI,CAACf,KAAK,EAAEA;QACjC,IAAIoB,OAAOC,EAAE,EAAEL,SAAS,CAAChB,KAAK,GAAGoB,OAAOf,QAAQ;IAClD;IACA,MAAMiB,QAAkB,EAAE;IAC1B,KAAK,MAAM,CAACtB,MAAMK,SAAS,IAAIY,OAAOM,OAAO,CAACP,WAAY;QACxD,IAAI,CAACd,WAAWF,SAASK,SAASmB,IAAI,KAAK7B,YAAY;QACvD2B,MAAMG,IAAI,CAACjB,OAAOR,MAAMK;IAC1B;IACA,OAAO;QAAEW;QAAWM;IAAM;AAC5B;AAEA,OAAO,SAASI,eACdX,IAAsC,EACtCY,aAAgC;IAEhC,MAAMC,aAAad,gBAAgBC;IACnC,IAAIE,OAAOC,IAAI,CAACU,WAAWZ,SAAS,EAAEJ,MAAM,KAAKK,OAAOC,IAAI,CAACH,MAAMH,MAAM,EAAE,OAAO;IAClF,IAAIpB,SAASuB,MAAM;QAAEY;IAAc,GAAGE,OAAO,KAAK,UAAU,OAAO;IACnE,OAAOD;AACT"}
|
|
1
|
+
{"version":3,"sources":["/workspace/packages/mdruntime/src/collection.ts"],"sourcesContent":["import { parse, validate, VERSION, type Document, type Validation } from '@agentshouse/mdmodel';\nimport type { Selector } from '@agentshouse/query';\nimport { beneath, normalize } from './paths.js';\nimport type { AttachedModelBinding, ModelState } from './model.js';\nimport type { MdModelIdentity } from './adapter.js';\n\nexport const MD_MODEL: MdModelIdentity = { identity: '@agentshouse/mdmodel', version: VERSION };\n\nexport const PRESENTED: Selector = { path: { $regex: '\\\\.md$' } };\n\nexport type MdType = {\n name: string;\n path: string;\n fields: Readonly<Record<string, unknown>>;\n sections: Readonly<Record<string, unknown>>;\n};\n\nexport type Collection = {\n documents: Readonly<Record<string, Document>>;\n composition: Composition;\n};\n\nexport type Composition = {\n collectionRoot: string;\n model: ModelState;\n selection: { roots: readonly string[]; model: ModelState } | null;\n};\n\nfunction selected(composition: Composition, path: string): boolean {\n return (\n composition.selection !== null &&\n composition.selection.roots.some((root) => beneath(root, path))\n );\n}\n\nexport function governing(composition: Composition, path: string): ModelState {\n return composition.selection !== null && selected(composition, path)\n ? composition.selection.model\n : composition.model;\n}\n\nexport function typesAt(composition: Composition, path: string): readonly MdType[] {\n const model = governing(composition, path);\n return model.status === 'unavailable' ? [] : model.types;\n}\n\nexport function parseCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n): Collection {\n const documents: Record<string, Document> = {};\n for (const path of Object.keys(text).sort()) {\n const parsed = parse(text[path], path);\n if (parsed.ok) documents[path] = parsed.document;\n }\n return { documents, composition };\n}\n\nexport function readCollection(\n text: Readonly<Record<string, string>>,\n composition: Composition,\n): Collection | null {\n if (!validRoot(composition.collectionRoot)) return null;\n const collection = parseCollection(text, composition);\n if (Object.keys(collection.documents).length !== Object.keys(text).length) return null;\n if (\n Object.entries(collection.documents).some(\n ([path, document]) =>\n !member(path, composition.collectionRoot) &&\n !selected(composition, path) &&\n document.type !== undefined &&\n document.type !== 'any',\n )\n )\n return null;\n return collection;\n}\n\nexport function validRoot(root: unknown): root is string {\n return typeof root === 'string' && normalize(root) === root;\n}\n\nfunction member(path: string, root: string): boolean {\n return root === '' || path.startsWith(`${root}/`);\n}\n\ntype Refusal = Extract<Validation, { verdict: 'refuse' }> & { source?: 'content' | 'model' };\n\nfunction validateAgainst(\n documents: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n prefix: string,\n model: ModelState,\n binding: AttachedModelBinding | null,\n): Validation & { source?: 'content' | 'model' } {\n if (model.status === 'unavailable' || binding === null) {\n const typed = Object.entries(documents).find(([, content]) => {\n const parsed = parse(content);\n return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';\n });\n if (typed !== undefined)\n return {\n verdict: 'refuse',\n rule: 'model-unavailable',\n file: `${prefix}${typed[0]}`,\n version: VERSION,\n };\n return validate(documents, { binaryTargets });\n }\n const verdict = binding.validate({ model: model.snapshot, documents, binaryTargets });\n if (verdict.verdict === 'refuse' && verdict.source === 'model') return verdict;\n if (verdict.verdict === 'accept') return verdict;\n return {\n ...verdict,\n file: `${prefix}${verdict.file}`,\n ...(verdict.referrers === undefined\n ? {}\n : { referrers: verdict.referrers.map((path) => `${prefix}${path}`) }),\n };\n}\n\nexport function validateCollection(\n text: Readonly<Record<string, string>>,\n binaryTargets: readonly string[],\n composition: Composition,\n binding: AttachedModelBinding | null,\n): Validation & { source?: 'content' | 'model' } {\n const prefix = composition.collectionRoot === '' ? '' : `${composition.collectionRoot}/`;\n const collection: Record<string, string> = {};\n const selection: Record<string, string> = {};\n for (const [path, content] of Object.entries(text)) {\n if (member(path, composition.collectionRoot)) {\n collection[path.slice(prefix.length)] = content;\n continue;\n }\n if (selected(composition, path)) {\n selection[path] = content;\n continue;\n }\n const parsed = parse(content, path);\n if (!parsed.ok) return { verdict: 'refuse', ...parsed.refusal };\n if (Object.hasOwn(parsed.document.fields, 'type') && parsed.document.fields.type !== 'any') {\n return { verdict: 'refuse', rule: 'outside-collection-type', file: path, version: VERSION };\n }\n }\n const verdicts = [\n validateAgainst(\n collection,\n binaryTargets\n .filter((path) => member(path, composition.collectionRoot))\n .map((path) => path.slice(prefix.length)),\n prefix,\n composition.model,\n binding,\n ),\n ];\n if (composition.selection !== null) {\n verdicts.push(\n validateAgainst(\n selection,\n binaryTargets.filter((path) => selected(composition, path)),\n '',\n composition.selection.model,\n binding,\n ),\n );\n }\n const refusals = verdicts.filter((verdict): verdict is Refusal => verdict.verdict === 'refuse');\n if (refusals.length === 0) return verdicts[0];\n return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];\n}\n"],"names":["parse","validate","VERSION","beneath","normalize","MD_MODEL","identity","version","PRESENTED","path","$regex","selected","composition","selection","roots","some","root","governing","model","typesAt","status","types","parseCollection","text","documents","Object","keys","sort","parsed","ok","document","readCollection","validRoot","collectionRoot","collection","length","entries","member","type","undefined","startsWith","validateAgainst","binaryTargets","prefix","binding","typed","find","content","verdict","rule","file","snapshot","source","referrers","map","validateCollection","slice","refusal","hasOwn","fields","verdicts","filter","push","refusals"],"mappings":"AAAA,SAASA,KAAK,EAAEC,QAAQ,EAAEC,OAAO,QAAwC,uBAAuB;AAEhG,SAASC,OAAO,EAAEC,SAAS,QAAQ,aAAa;AAIhD,OAAO,MAAMC,WAA4B;IAAEC,UAAU;IAAwBC,SAASL;AAAQ,EAAE;AAEhG,OAAO,MAAMM,YAAsB;IAAEC,MAAM;QAAEC,QAAQ;IAAS;AAAE,EAAE;AAoBlE,SAASC,SAASC,WAAwB,EAAEH,IAAY;IACtD,OACEG,YAAYC,SAAS,KAAK,QAC1BD,YAAYC,SAAS,CAACC,KAAK,CAACC,IAAI,CAAC,CAACC,OAASb,QAAQa,MAAMP;AAE7D;AAEA,OAAO,SAASQ,UAAUL,WAAwB,EAAEH,IAAY;IAC9D,OAAOG,YAAYC,SAAS,KAAK,QAAQF,SAASC,aAAaH,QAC3DG,YAAYC,SAAS,CAACK,KAAK,GAC3BN,YAAYM,KAAK;AACvB;AAEA,OAAO,SAASC,QAAQP,WAAwB,EAAEH,IAAY;IAC5D,MAAMS,QAAQD,UAAUL,aAAaH;IACrC,OAAOS,MAAME,MAAM,KAAK,gBAAgB,EAAE,GAAGF,MAAMG,KAAK;AAC1D;AAEA,OAAO,SAASC,gBACdC,IAAsC,EACtCX,WAAwB;IAExB,MAAMY,YAAsC,CAAC;IAC7C,KAAK,MAAMf,QAAQgB,OAAOC,IAAI,CAACH,MAAMI,IAAI,GAAI;QAC3C,MAAMC,SAAS5B,MAAMuB,IAAI,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AAO6B,OAAO;QAAC;QAC9D,IAAIhC,OAAOiC,MAAM,CAAC9B,OAAOE,QAAQ,CAAC6B,MAAM,EAAE,WAAW/B,OAAOE,QAAQ,CAAC6B,MAAM,CAACrB,IAAI,KAAK,OAAO;YAC1F,OAAO;gBAAEU,SAAS;gBAAUC,MAAM;gBAA2BC,MAAMzC;gBAAMF,SAASL;YAAQ;QAC5F;IACF;IACA,MAAM0D,WAAW;QACfnB,gBACEP,YACAQ,cACGmB,MAAM,CAAC,CAACpD,OAAS4B,OAAO5B,MAAMG,YAAYqB,cAAc,GACxDqB,GAAG,CAAC,CAAC7C,OAASA,KAAK+C,KAAK,CAACb,OAAOR,MAAM,IACzCQ,QACA/B,YAAYM,KAAK,EACjB0B;KAEH;IACD,IAAIhC,YAAYC,SAAS,KAAK,MAAM;QAClC+C,SAASE,IAAI,CACXrB,gBACE5B,WACA6B,cAAcmB,MAAM,CAAC,CAACpD,OAASE,SAASC,aAAaH,QACrD,IACAG,YAAYC,SAAS,CAACK,KAAK,EAC3B0B;IAGN;IACA,MAAMmB,WAAWH,SAASC,MAAM,CAAC,CAACb,UAAgCA,QAAQA,OAAO,KAAK;IACtF,IAAIe,SAAS5B,MAAM,KAAK,GAAG,OAAOyB,QAAQ,CAAC,EAAE;IAC7C,OAAOG,SAASjB,IAAI,CAAC,CAACW,UAAYA,QAAQR,IAAI,KAAK,wBAAwBc,QAAQ,CAAC,EAAE;AACxF"}
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,25 +1,47 @@
|
|
|
1
|
+
import { type QueryBinding } from './query.js';
|
|
2
|
+
import { type AttachedModelBinding, type TypesResult } from './model.js';
|
|
1
3
|
import { type QueryOptions, type QueryResult } from '@agentshouse/query';
|
|
2
|
-
import { type
|
|
4
|
+
import { type Adapter, type Authorization, type HistoryResult, type ProviderRefusal } from './adapter.js';
|
|
5
|
+
import { type ConversationSurface, type ConversationView } from './conversation.js';
|
|
3
6
|
import type { Change } from './change.js';
|
|
4
|
-
import { type
|
|
5
|
-
import { type QueueEntry, type SubmissionOutcome } from './outcome.js';
|
|
7
|
+
import { type CallResult, type QueueEntry, type SubmissionOutcome } from './outcome.js';
|
|
6
8
|
import { type SaveRefusal } from './save.js';
|
|
7
9
|
import { type SyncStatus } from './status.js';
|
|
10
|
+
import { type RuntimeShell } from './durability.js';
|
|
11
|
+
export type AppTypedSelection = {
|
|
12
|
+
roots: readonly string[];
|
|
13
|
+
attachedModel: import('./model.js').ModelIdentity | null;
|
|
14
|
+
model: TypesResult;
|
|
15
|
+
};
|
|
8
16
|
export type AppRoom = {
|
|
17
|
+
collectionRoot: string;
|
|
9
18
|
name: string;
|
|
10
19
|
locator: string;
|
|
11
|
-
|
|
20
|
+
operations: import('./adapter.js').OperationScopes;
|
|
21
|
+
replica: import('./adapter.js').ReplicaAdmission;
|
|
22
|
+
attachedModel: import('./model.js').ModelIdentity | null;
|
|
23
|
+
model: TypesResult;
|
|
24
|
+
typedSelection: AppTypedSelection | null;
|
|
12
25
|
providerOwnedPaths: readonly string[];
|
|
13
26
|
roomVersion: string | null;
|
|
14
27
|
synchronizationAvailable: boolean;
|
|
28
|
+
refusal: ProviderRefusal | null;
|
|
29
|
+
};
|
|
30
|
+
export type RoomTypes = {
|
|
31
|
+
collection: TypesResult;
|
|
32
|
+
typedSelection: TypesResult | null;
|
|
15
33
|
};
|
|
16
|
-
export type ConnectionRefusalReason = 'no-matching-version' | 'missing-required-guarantee' | 'md-model-version-mismatch' | 'revoked-authorization';
|
|
34
|
+
export type ConnectionRefusalReason = 'no-matching-version' | 'missing-required-guarantee' | 'md-model-version-mismatch' | 'revoked-authorization' | 'client-host-protocol-mismatch';
|
|
17
35
|
export type ConnectionRefusal = {
|
|
18
36
|
reason: ConnectionRefusalReason;
|
|
19
37
|
reauthorizationOffered: boolean;
|
|
38
|
+
refusal: ProviderRefusal | null;
|
|
20
39
|
};
|
|
21
40
|
export type MdRuntimeOptions = {
|
|
22
41
|
adapter: Adapter;
|
|
42
|
+
shell: RuntimeShell;
|
|
43
|
+
modelBinding: AttachedModelBinding | null;
|
|
44
|
+
queryBinding: QueryBinding | null;
|
|
23
45
|
requiredGuarantees: readonly string[];
|
|
24
46
|
authorization?: Authorization;
|
|
25
47
|
discoveryIntervalMs?: number;
|
|
@@ -45,19 +67,22 @@ export type DraftSurface = {
|
|
|
45
67
|
export type QueueSurface = {
|
|
46
68
|
discard(locator: string, identifier: string): Promise<void>;
|
|
47
69
|
};
|
|
70
|
+
export type PresentationSurface = {
|
|
71
|
+
read(app: string): Promise<unknown>;
|
|
72
|
+
write(app: string, value: unknown): Promise<void>;
|
|
73
|
+
};
|
|
48
74
|
export type HistoryQuery = {
|
|
49
75
|
revision?: string;
|
|
50
76
|
pageToken?: string;
|
|
51
77
|
};
|
|
52
|
-
export type CallResult = ActionResult | {
|
|
53
|
-
kind: 'undeclared';
|
|
54
|
-
};
|
|
55
78
|
export type MdRuntime = {
|
|
56
79
|
rooms(): readonly AppRoom[];
|
|
57
80
|
query(options?: QueryOptions): QueryResult;
|
|
58
|
-
types(locator: string):
|
|
81
|
+
types(locator: string): RoomTypes;
|
|
59
82
|
syncStatus(): SyncStatus;
|
|
60
83
|
draft: DraftSurface;
|
|
84
|
+
conversation: ConversationSurface;
|
|
85
|
+
presentation: PresentationSurface;
|
|
61
86
|
save(locator: string, changes: readonly Change[], replacing?: string): Promise<SaveResult>;
|
|
62
87
|
outcome(identifier: string): SubmissionOutcome | null;
|
|
63
88
|
queue: QueueSurface;
|
|
@@ -65,6 +90,7 @@ export type MdRuntime = {
|
|
|
65
90
|
call(name: string, input: unknown): Promise<CallResult>;
|
|
66
91
|
log(): string;
|
|
67
92
|
storageLoss(): string | null;
|
|
93
|
+
persistence(): boolean;
|
|
68
94
|
observe: {
|
|
69
95
|
(topic: 'rooms', listener: (rooms: readonly AppRoom[]) => void): () => void;
|
|
70
96
|
(topic: 'connection-refusal', listener: (refusal: ConnectionRefusal | null) => void): () => void;
|
|
@@ -73,6 +99,8 @@ export type MdRuntime = {
|
|
|
73
99
|
(topic: 'query', query: QueryOptions, listener: (result: QueryResult) => void): () => void;
|
|
74
100
|
(topic: 'queue', locator: string, listener: (entries: readonly QueueEntry[]) => void): () => void;
|
|
75
101
|
(topic: 'drafts', listener: (drafts: readonly DraftEntry[]) => void): () => void;
|
|
102
|
+
(topic: 'presentation', app: string, listener: (value: unknown) => void): () => void;
|
|
103
|
+
(topic: 'conversation', conversation: string, listener: (view: ConversationView) => void): () => void;
|
|
76
104
|
};
|
|
77
105
|
reauthorize(): Promise<void>;
|
|
78
106
|
};
|
package/dist/connection.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,YAAY,EAAmB,MAAM,YAAY,CAAC;AAC1E,OAAO,EAKL,KAAK,oBAAoB,EAEzB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,WAAW,EAEjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAIL,KAAK,OAAO,EAEZ,KAAK,aAAa,EAGlB,KAAK,aAAa,EAKlB,KAAK,eAAe,EAErB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,MAAM,EAAe,MAAM,aAAa,CAAC;AAGvD,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,UAAU,EAEf,KAAK,iBAAiB,EACvB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AASzD,OAAO,EAQL,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,E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