@agentshouse/mdruntime 0.1.0-c0bed82db8d73 → 0.1.0-c0c1e81da9166

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 (174) hide show
  1. package/README.md +3 -2
  2. package/dist/adapter.d.ts +101 -71
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +4 -10
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +35 -46
  7. package/dist/bootstrap.d.ts +16 -15
  8. package/dist/bootstrap.d.ts.map +1 -1
  9. package/dist/bootstrap.js +273 -131
  10. package/dist/chain.d.ts +2 -1
  11. package/dist/chain.d.ts.map +1 -1
  12. package/dist/change.d.ts +1 -0
  13. package/dist/change.d.ts.map +1 -1
  14. package/dist/chat-types.d.ts +3 -0
  15. package/dist/chat-types.d.ts.map +1 -0
  16. package/dist/chat-types.js +2 -0
  17. package/dist/client.d.ts +15 -9
  18. package/dist/client.d.ts.map +1 -1
  19. package/dist/client.js +54 -6
  20. package/dist/collection.d.ts +7 -4
  21. package/dist/collection.d.ts.map +1 -1
  22. package/dist/collection.js +24 -19
  23. package/dist/compile.d.ts +6 -6
  24. package/dist/compile.d.ts.map +1 -1
  25. package/dist/compile.js +278 -282
  26. package/dist/connection.d.ts +16 -11
  27. package/dist/connection.d.ts.map +1 -1
  28. package/dist/connection.js +2312 -1988
  29. package/dist/context.d.ts +2 -0
  30. package/dist/context.d.ts.map +1 -0
  31. package/dist/context.js +7 -0
  32. package/dist/conversation-row.d.ts +33 -0
  33. package/dist/conversation-row.d.ts.map +1 -0
  34. package/dist/conversation-row.js +47 -0
  35. package/dist/conversation.d.ts +27 -18
  36. package/dist/conversation.d.ts.map +1 -1
  37. package/dist/conversation.js +489 -260
  38. package/dist/durability.d.ts +6 -1
  39. package/dist/durability.d.ts.map +1 -1
  40. package/dist/entry.d.ts +3 -2
  41. package/dist/entry.d.ts.map +1 -1
  42. package/dist/entry.js +18 -8
  43. package/dist/figures.d.ts +48 -0
  44. package/dist/figures.d.ts.map +1 -0
  45. package/dist/figures.js +197 -0
  46. package/dist/file.d.ts +2 -11
  47. package/dist/file.d.ts.map +1 -1
  48. package/dist/file.js +6 -4
  49. package/dist/host.d.ts +3 -7
  50. package/dist/host.d.ts.map +1 -1
  51. package/dist/host.js +26 -29
  52. package/dist/identity.d.ts +0 -1
  53. package/dist/identity.d.ts.map +1 -1
  54. package/dist/identity.js +0 -3
  55. package/dist/index.d.ts +16 -9
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +6 -1
  58. package/dist/job.d.ts +33 -0
  59. package/dist/job.d.ts.map +1 -0
  60. package/dist/job.js +54 -0
  61. package/dist/live.d.ts +5 -4
  62. package/dist/live.d.ts.map +1 -1
  63. package/dist/live.js +62 -20
  64. package/dist/media.d.ts +8 -0
  65. package/dist/media.d.ts.map +1 -0
  66. package/dist/media.js +218 -0
  67. package/dist/memory.d.ts +13 -6
  68. package/dist/memory.d.ts.map +1 -1
  69. package/dist/memory.js +218 -91
  70. package/dist/messages.d.ts +27 -3
  71. package/dist/messages.d.ts.map +1 -1
  72. package/dist/messages.js +97 -19
  73. package/dist/model.d.ts +8 -10
  74. package/dist/model.d.ts.map +1 -1
  75. package/dist/model.js +6 -18
  76. package/dist/observation.d.ts +3 -2
  77. package/dist/observation.d.ts.map +1 -1
  78. package/dist/observation.js +8 -3
  79. package/dist/outcome.d.ts +13 -5
  80. package/dist/outcome.d.ts.map +1 -1
  81. package/dist/outcome.js +16 -2
  82. package/dist/overlay.d.ts +1 -0
  83. package/dist/overlay.d.ts.map +1 -1
  84. package/dist/overlay.js +11 -0
  85. package/dist/parts.d.ts +59 -0
  86. package/dist/parts.d.ts.map +1 -0
  87. package/dist/parts.js +118 -0
  88. package/dist/paths.d.ts +1 -0
  89. package/dist/paths.d.ts.map +1 -1
  90. package/dist/paths.js +4 -0
  91. package/dist/query.d.ts +18 -207
  92. package/dist/query.d.ts.map +1 -1
  93. package/dist/query.js +3 -505
  94. package/dist/questions.d.ts +32 -0
  95. package/dist/questions.d.ts.map +1 -0
  96. package/dist/questions.js +118 -0
  97. package/dist/reach.d.ts +18 -11
  98. package/dist/reach.d.ts.map +1 -1
  99. package/dist/reach.js +201 -126
  100. package/dist/react.d.ts +3 -1
  101. package/dist/react.d.ts.map +1 -1
  102. package/dist/read.d.ts +7 -0
  103. package/dist/read.d.ts.map +1 -0
  104. package/dist/read.js +17 -0
  105. package/dist/readiness.d.ts +3 -17
  106. package/dist/readiness.d.ts.map +1 -1
  107. package/dist/readiness.js +4 -10
  108. package/dist/recovery.d.ts +1 -0
  109. package/dist/recovery.d.ts.map +1 -1
  110. package/dist/recovery.js +35 -1
  111. package/dist/refresh.d.ts +7 -5
  112. package/dist/refresh.d.ts.map +1 -1
  113. package/dist/refresh.js +34 -10
  114. package/dist/replica.d.ts +10 -9
  115. package/dist/replica.d.ts.map +1 -1
  116. package/dist/replica.js +53 -21
  117. package/dist/room-draft.d.ts +21 -5
  118. package/dist/room-draft.d.ts.map +1 -1
  119. package/dist/room-draft.js +98 -51
  120. package/dist/rows.d.ts +18 -16
  121. package/dist/rows.d.ts.map +1 -1
  122. package/dist/rows.js +45 -153
  123. package/dist/save.d.ts +2 -0
  124. package/dist/save.d.ts.map +1 -1
  125. package/dist/save.js +22 -13
  126. package/dist/search.d.ts +12 -63
  127. package/dist/search.d.ts.map +1 -1
  128. package/dist/search.js +9 -52
  129. package/dist/shared.d.ts +0 -1
  130. package/dist/shared.d.ts.map +1 -1
  131. package/dist/shared.js +0 -10
  132. package/dist/source.d.ts +61 -0
  133. package/dist/source.d.ts.map +1 -0
  134. package/dist/source.js +81 -0
  135. package/dist/status.d.ts +4 -5
  136. package/dist/status.d.ts.map +1 -1
  137. package/dist/status.js +3 -7
  138. package/dist/store.d.ts +104 -62
  139. package/dist/store.d.ts.map +1 -1
  140. package/dist/store.js +159 -161
  141. package/dist/stored.d.ts +66 -55
  142. package/dist/stored.d.ts.map +1 -1
  143. package/dist/stored.js +343 -273
  144. package/dist/tables.d.ts +110 -65
  145. package/dist/tables.d.ts.map +1 -1
  146. package/dist/tables.js +188 -99
  147. package/dist/tallies.d.ts +18 -0
  148. package/dist/tallies.d.ts.map +1 -0
  149. package/dist/tallies.js +129 -0
  150. package/dist/transfer.d.ts +0 -5
  151. package/dist/transfer.d.ts.map +1 -1
  152. package/dist/validation.d.ts +3 -4
  153. package/dist/validation.d.ts.map +1 -1
  154. package/dist/validation.js +42 -100
  155. package/dist/windows.d.ts +1 -12
  156. package/dist/windows.d.ts.map +1 -1
  157. package/dist/windows.js +2 -75
  158. package/dist/wire.d.ts +18 -8
  159. package/dist/wire.d.ts.map +1 -1
  160. package/dist/wire.js +6 -2
  161. package/package.json +2 -3
  162. package/AGENTS.md +0 -312
  163. package/dist/fence.d.ts +0 -6
  164. package/dist/fence.d.ts.map +0 -1
  165. package/dist/fence.js +0 -10
  166. package/dist/fulltext.d.ts +0 -27
  167. package/dist/fulltext.d.ts.map +0 -1
  168. package/dist/fulltext.js +0 -368
  169. package/dist/reads.d.ts +0 -11
  170. package/dist/reads.d.ts.map +0 -1
  171. package/dist/reads.js +0 -100
  172. package/dist/words.d.ts +0 -19
  173. package/dist/words.d.ts.map +0 -1
  174. package/dist/words.js +0 -150
package/dist/client.js CHANGED
@@ -1,8 +1,25 @@
1
+ import { shownBy } from './media.js';
1
2
  import { observed } from './observation.js';
2
3
  import { runtimeError } from './failure.js';
3
4
  import { answer, AUTHORIZATION_ENDED, PORT_CLOSED, } from './wire.js';
4
5
  // React renders an arrived value in a later task and opens what that render observes as it commits, so this many frames opening nothing mean the page drew what it observes.
5
6
  const SETTLED_FRAMES = 2;
7
+ // A browser reads a download's address only after the click that hands it returns, so a copy's address is released a minute later.
8
+ const HANDED_COPY_MS = 60_000;
9
+ const PAGE = /\.html?$/iu;
10
+ const STARTED = { kind: 'started' };
11
+ const BLOCKED = {
12
+ kind: 'blocked',
13
+ code: 'popup-blocked',
14
+ fields: {},
15
+ retryable: true,
16
+ };
17
+ function handed(url, name) {
18
+ const anchor = document.createElement('a');
19
+ anchor.href = url;
20
+ anchor.download = name;
21
+ anchor.click();
22
+ }
6
23
  function refused(refusal) {
7
24
  return runtimeError(refusal.code, refusal.code, refusal.retryable);
8
25
  }
@@ -156,6 +173,34 @@ export function connectMdRuntime(port) {
156
173
  }, { highWaterMark: 0 });
157
174
  return { kind: 'binary', stream, byteLength, mediaType };
158
175
  }
176
+ async function download(room, path, revision) {
177
+ const tab = PAGE.test(path) ? globalThis.open('', '_blank') : null;
178
+ const linked = await ask('binaryFile.link', [room, path, revision]);
179
+ if (linked.kind === 'link' && PAGE.test(linked.name)) {
180
+ const away = tab ?? globalThis.open('', '_blank');
181
+ if (away === null)
182
+ return BLOCKED;
183
+ away.location.replace(linked.url);
184
+ return STARTED;
185
+ }
186
+ tab?.close();
187
+ if (linked.kind === 'link') {
188
+ handed(linked.url, linked.name);
189
+ return STARTED;
190
+ }
191
+ if (linked.kind !== 'absent')
192
+ return linked;
193
+ const read = streamed(await ask('binaryFile.read', [room, path, revision]));
194
+ if (read.kind !== 'binary')
195
+ return read;
196
+ const copy = await new Response(read.stream, {
197
+ headers: { 'content-type': read.mediaType },
198
+ }).blob();
199
+ const url = URL.createObjectURL(copy);
200
+ handed(url, path.slice(path.lastIndexOf('/') + 1));
201
+ setTimeout(() => URL.revokeObjectURL(url), HANDED_COPY_MS);
202
+ return STARTED;
203
+ }
159
204
  function settled() {
160
205
  if (settling !== null)
161
206
  return settling;
@@ -185,7 +230,8 @@ export function connectMdRuntime(port) {
185
230
  });
186
231
  return settling;
187
232
  }
188
- return {
233
+ const show = (room, path, revision) => ask('binaryFile.show', [room, path, revision]).then((shown) => streamed(shown));
234
+ return shownBy(show, {
189
235
  rooms: () => ask('rooms', []),
190
236
  query: ((query) => ask('query', [query])),
191
237
  search: (request) => ask('search', [request]),
@@ -208,11 +254,9 @@ export function connectMdRuntime(port) {
208
254
  read: (conversation, options) => ask('conversation.read', [conversation, options]),
209
255
  create: (input) => ask('conversation.create', [input]),
210
256
  send: (conversation, operation, draft) => ask('conversation.send', [conversation, operation, draft]),
211
- attach: (room, file) => ask('conversation.attach', [room, file]),
212
257
  answer: (conversation, answer) => ask('conversation.answer', [conversation, answer]),
213
258
  interrupt: (conversation) => ask('conversation.interrupt', [conversation]),
214
259
  kill: (conversation) => ask('conversation.kill', [conversation]),
215
- cancel: (conversation, turn) => ask('conversation.cancel', [conversation, turn]),
216
260
  delete: (conversation) => ask('conversation.delete', [conversation]),
217
261
  },
218
262
  chatDraft: {
@@ -223,8 +267,9 @@ export function connectMdRuntime(port) {
223
267
  history: (locator, path, query) => ask('history', [locator, path, query]),
224
268
  resolve: (room, path, destination) => ask('resolve', [room, path, destination]),
225
269
  binaryFile: {
226
- read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then(streamed),
227
- link: (room, path, revision) => ask('binaryFile.link', [room, path, revision]),
270
+ read: (room, path, revision) => ask('binaryFile.read', [room, path, revision]).then((read) => streamed(read)),
271
+ attach: (room, file) => ask('binaryFile.attach', [room, file]),
272
+ download,
228
273
  },
229
274
  call: (name, input) => ask('call', [name, input]),
230
275
  reached: (locator, roomVersion, path) => ask('reached', [locator, roomVersion, path]),
@@ -232,10 +277,12 @@ export function connectMdRuntime(port) {
232
277
  persistence: () => ask('persistence', []),
233
278
  retry: () => ask('retry', []),
234
279
  cleanUp: () => ask('cleanUp', []),
280
+ unsent: () => ask('unsent', []),
281
+ reset: () => ask('reset', []),
235
282
  observe: ((topic, ...input) => watch(topic, input)),
236
283
  reauthorize: () => ask('reauthorize', []),
237
284
  settled,
238
- };
285
+ });
239
286
  }
240
287
  const turns = new WeakMap();
241
288
  export function inTurn(client, work) {
@@ -245,4 +292,5 @@ export function inTurn(client, work) {
245
292
  }
246
293
  export { chainedWindows } from './chain.js';
247
294
  export { roomDraftRevision } from './identity.js';
295
+ export { defineRoomMedia, ROOM_MEDIA } from './media.js';
248
296
  export { unanswered } from './wire.js';
@@ -1,8 +1,6 @@
1
- import { type Document } from '@agentshouse/mdmodel';
1
+ import { type Document, type TypedPath } from '@agentshouse/mdmodel';
2
2
  import type { ModelState } from './model.js';
3
3
  import type { MdModelIdentity } from './adapter.js';
4
- import { type Paths } from './shared.js';
5
- import type { Refused } from './transfer.js';
6
4
  export declare const MD_MODEL: MdModelIdentity;
7
5
  export type Collection = {
8
6
  text: Readonly<Record<string, string>>;
@@ -15,12 +13,17 @@ export type Composition = {
15
13
  roots: readonly string[];
16
14
  model: ModelState;
17
15
  } | null;
16
+ typedPaths: readonly TypedPath[];
18
17
  };
18
+ export type Composed = {
19
+ readonly composition: Composition;
20
+ readonly fingerprint: string;
21
+ };
22
+ export declare function composedOf(composition: Composition): Composed;
19
23
  export declare function selected(composition: Composition, path: string): boolean;
20
24
  export declare function governing(composition: Composition, path: string): ModelState;
21
25
  export declare function collectionOf(text: Readonly<Record<string, string>>, composition: Composition): Collection;
22
26
  export declare function documentsOf(collection: Collection): Generator<number, Iterable<readonly [string, Document]>, void>;
23
- export declare function unreadable(text: Paths<string>, paths?: Iterable<string> | null): Generator<number, Refused | null, void>;
24
27
  export declare function validRoot(root: unknown): root is string;
25
28
  export declare function available(composition: Composition): boolean;
26
29
  //# sourceMappingURL=collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAsB,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAEhG,MAAM,MAAM,UAAU,GAAG;I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,EAAE,UAAU,GACrB,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,CAQhE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,MAAM,CAEvD;AAED,wBAAgB,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAE3D"}
@@ -1,8 +1,29 @@
1
1
  import { parse, VERSION } from '@agentshouse/mdmodel';
2
2
  import { beneath, normalize } from './paths.js';
3
- import { keysIn, sortedKeys } from './shared.js';
4
- import { ROW_WEIGHT } from './turn.js';
3
+ import { hashed } from './observation.js';
4
+ import { sortedKeys } from './shared.js';
5
5
  export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
6
+ const typesPrinted = new WeakMap();
7
+ function typesPrint(model) {
8
+ if (model.status === 'unavailable')
9
+ return '';
10
+ let print = typesPrinted.get(model.types);
11
+ if (print === undefined) {
12
+ print = hashed(JSON.stringify(model.types)).toString(36);
13
+ typesPrinted.set(model.types, print);
14
+ }
15
+ return print;
16
+ }
17
+ export function composedOf(composition) {
18
+ const { model, selection } = composition;
19
+ return {
20
+ composition,
21
+ fingerprint: JSON.stringify([
22
+ typesPrint(model),
23
+ selection === null ? null : [selection.roots, typesPrint(selection.model)],
24
+ ]),
25
+ };
26
+ }
6
27
  export function selected(composition, path) {
7
28
  return (composition.selection !== null &&
8
29
  composition.selection.roots.some((root) => beneath(root, path)));
@@ -39,25 +60,9 @@ export function* documentsOf(collection) {
39
60
  }
40
61
  })();
41
62
  }
42
- export function* unreadable(text, paths = null) {
43
- const named = paths ?? (yield* keysIn(text));
44
- let least = null;
45
- for (const path of named) {
46
- const content = Object.hasOwn(text, path) ? text[path] : undefined;
47
- if (content === undefined)
48
- continue;
49
- const read = parse(content, path);
50
- if (!read.ok && (least === null || path < least.path)) {
51
- least = { path, refused: { kind: 'refused', refusal: read.refusal } };
52
- }
53
- yield ROW_WEIGHT + content.length;
54
- }
55
- return least?.refused ?? null;
56
- }
57
63
  export function validRoot(root) {
58
64
  return typeof root === 'string' && normalize(root) === root;
59
65
  }
60
66
  export function available(composition) {
61
- return (composition.model.status !== 'unavailable' &&
62
- (composition.selection === null || composition.selection.model.status !== 'unavailable'));
67
+ return composition.model.status !== 'unavailable';
63
68
  }
package/dist/compile.d.ts CHANGED
@@ -1,16 +1,16 @@
1
+ import { sql } from '@agentshouse/mdmodel';
1
2
  import type { Plan, QueryRows } from './query.js';
2
- import type { Connection, Value } from './tables.js';
3
+ import type { Connection } from './tables.js';
3
4
  export type QueryRoom = {
4
5
  readonly locator: string;
5
6
  readonly key: number;
6
7
  };
7
- export type Fragment = {
8
- readonly sql: string;
9
- readonly bind: readonly Value[];
10
- };
8
+ type Fragment = sql.Fragment;
9
+ export declare const VISIBLE: (alias: string) => string;
10
+ export declare function within(alias: string, path: string): Fragment;
11
11
  export type QueryAnswer = QueryRows & {
12
12
  readonly more?: string;
13
13
  };
14
- export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
15
14
  export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
15
+ export {};
16
16
  //# sourceMappingURL=compile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAOV,IAAI,EAGJ,SAAS,EAIV,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAU1D,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,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