@agentshouse/mdruntime 0.1.0-c967d1ca66fee → 0.1.0-c96e80d38e5f0

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 (175) hide show
  1. package/README.md +22 -9
  2. package/dist/adapter.d.ts +172 -49
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/attached-model.d.ts +5 -1
  5. package/dist/attached-model.d.ts.map +1 -1
  6. package/dist/attached-model.js +38 -4
  7. package/dist/attempt.d.ts +16 -0
  8. package/dist/attempt.d.ts.map +1 -0
  9. package/dist/attempt.js +70 -0
  10. package/dist/binary.d.ts +18 -0
  11. package/dist/binary.d.ts.map +1 -0
  12. package/dist/binary.js +8 -0
  13. package/dist/bootstrap.d.ts +27 -11
  14. package/dist/bootstrap.d.ts.map +1 -1
  15. package/dist/bootstrap.js +184 -84
  16. package/dist/chain.d.ts +11 -0
  17. package/dist/chain.d.ts.map +1 -0
  18. package/dist/chain.js +64 -0
  19. package/dist/change-set.d.ts +9 -14
  20. package/dist/change-set.d.ts.map +1 -1
  21. package/dist/change-set.js +11 -62
  22. package/dist/change.d.ts +41 -0
  23. package/dist/change.d.ts.map +1 -1
  24. package/dist/change.js +34 -0
  25. package/dist/client.d.ts +34 -15
  26. package/dist/client.d.ts.map +1 -1
  27. package/dist/client.js +104 -8
  28. package/dist/collection.d.ts +10 -7
  29. package/dist/collection.d.ts.map +1 -1
  30. package/dist/collection.js +38 -79
  31. package/dist/compile.d.ts +16 -0
  32. package/dist/compile.d.ts.map +1 -0
  33. package/dist/compile.js +789 -0
  34. package/dist/connection.d.ts +51 -17
  35. package/dist/connection.d.ts.map +1 -1
  36. package/dist/connection.js +3951 -907
  37. package/dist/conversation.d.ts +48 -19
  38. package/dist/conversation.d.ts.map +1 -1
  39. package/dist/conversation.js +726 -240
  40. package/dist/digest.d.ts +7 -0
  41. package/dist/digest.d.ts.map +1 -0
  42. package/dist/digest.js +113 -0
  43. package/dist/durability.d.ts +4 -1
  44. package/dist/durability.d.ts.map +1 -1
  45. package/dist/durability.js +5 -0
  46. package/dist/entry.d.ts +20 -0
  47. package/dist/entry.d.ts.map +1 -0
  48. package/dist/entry.js +152 -0
  49. package/dist/expectation.d.ts +21 -0
  50. package/dist/expectation.d.ts.map +1 -0
  51. package/dist/expectation.js +70 -0
  52. package/dist/fence.d.ts +6 -0
  53. package/dist/fence.d.ts.map +1 -0
  54. package/dist/fence.js +10 -0
  55. package/dist/file.d.ts +2 -19
  56. package/dist/file.d.ts.map +1 -1
  57. package/dist/file.js +7 -122
  58. package/dist/host.d.ts +12 -3
  59. package/dist/host.d.ts.map +1 -1
  60. package/dist/host.js +125 -18
  61. package/dist/identity.d.ts +3 -0
  62. package/dist/identity.d.ts.map +1 -1
  63. package/dist/identity.js +9 -0
  64. package/dist/index.d.ts +19 -9
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +9 -0
  67. package/dist/live.d.ts +22 -0
  68. package/dist/live.d.ts.map +1 -0
  69. package/dist/live.js +123 -0
  70. package/dist/media.d.ts +8 -0
  71. package/dist/media.d.ts.map +1 -0
  72. package/dist/media.js +218 -0
  73. package/dist/memory.d.ts +18 -7
  74. package/dist/memory.d.ts.map +1 -1
  75. package/dist/memory.js +231 -91
  76. package/dist/messages.d.ts +28 -0
  77. package/dist/messages.d.ts.map +1 -0
  78. package/dist/messages.js +89 -0
  79. package/dist/model.d.ts +9 -2
  80. package/dist/model.d.ts.map +1 -1
  81. package/dist/model.js +8 -2
  82. package/dist/name.d.ts +4 -0
  83. package/dist/name.d.ts.map +1 -0
  84. package/dist/name.js +122 -0
  85. package/dist/observation.d.ts +20 -2
  86. package/dist/observation.d.ts.map +1 -1
  87. package/dist/observation.js +113 -12
  88. package/dist/opened.d.ts +22 -0
  89. package/dist/opened.d.ts.map +1 -0
  90. package/dist/opened.js +107 -0
  91. package/dist/outcome.d.ts +52 -4
  92. package/dist/outcome.d.ts.map +1 -1
  93. package/dist/outcome.js +46 -0
  94. package/dist/overlay.d.ts +15 -5
  95. package/dist/overlay.d.ts.map +1 -1
  96. package/dist/overlay.js +129 -177
  97. package/dist/paths.d.ts +1 -0
  98. package/dist/paths.d.ts.map +1 -1
  99. package/dist/paths.js +4 -0
  100. package/dist/phrase.d.ts +3 -0
  101. package/dist/phrase.d.ts.map +1 -0
  102. package/dist/phrase.js +8 -0
  103. package/dist/query.d.ts +72 -4
  104. package/dist/query.d.ts.map +1 -1
  105. package/dist/query.js +67 -7
  106. package/dist/reach.d.ts +16 -2
  107. package/dist/reach.d.ts.map +1 -1
  108. package/dist/reach.js +222 -56
  109. package/dist/react.d.ts +11 -7
  110. package/dist/react.d.ts.map +1 -1
  111. package/dist/react.js +7 -17
  112. package/dist/readiness.d.ts +50 -0
  113. package/dist/readiness.d.ts.map +1 -0
  114. package/dist/readiness.js +27 -0
  115. package/dist/recovery.d.ts +26 -0
  116. package/dist/recovery.d.ts.map +1 -0
  117. package/dist/recovery.js +224 -0
  118. package/dist/refresh.d.ts +17 -14
  119. package/dist/refresh.d.ts.map +1 -1
  120. package/dist/refresh.js +155 -56
  121. package/dist/replica.d.ts +58 -33
  122. package/dist/replica.d.ts.map +1 -1
  123. package/dist/replica.js +310 -159
  124. package/dist/room-draft.d.ts +52 -5
  125. package/dist/room-draft.d.ts.map +1 -1
  126. package/dist/room-draft.js +261 -56
  127. package/dist/rows.d.ts +38 -35
  128. package/dist/rows.d.ts.map +1 -1
  129. package/dist/rows.js +178 -102
  130. package/dist/save.d.ts +70 -3
  131. package/dist/save.d.ts.map +1 -1
  132. package/dist/save.js +805 -147
  133. package/dist/search.d.ts +15 -55
  134. package/dist/search.d.ts.map +1 -1
  135. package/dist/search.js +10 -121
  136. package/dist/seed.d.ts +16 -0
  137. package/dist/seed.d.ts.map +1 -0
  138. package/dist/seed.js +75 -0
  139. package/dist/shared.d.ts +15 -0
  140. package/dist/shared.d.ts.map +1 -0
  141. package/dist/shared.js +421 -0
  142. package/dist/status.d.ts +5 -0
  143. package/dist/status.d.ts.map +1 -1
  144. package/dist/status.js +3 -1
  145. package/dist/store.d.ts +116 -80
  146. package/dist/store.d.ts.map +1 -1
  147. package/dist/store.js +355 -461
  148. package/dist/stored.d.ts +162 -0
  149. package/dist/stored.d.ts.map +1 -0
  150. package/dist/stored.js +549 -0
  151. package/dist/tables.d.ts +353 -0
  152. package/dist/tables.d.ts.map +1 -0
  153. package/dist/tables.js +585 -0
  154. package/dist/transfer.d.ts +0 -5
  155. package/dist/transfer.d.ts.map +1 -1
  156. package/dist/turn.d.ts +9 -0
  157. package/dist/turn.d.ts.map +1 -0
  158. package/dist/turn.js +75 -0
  159. package/dist/validation.d.ts +29 -0
  160. package/dist/validation.d.ts.map +1 -0
  161. package/dist/validation.js +101 -0
  162. package/dist/windows.d.ts +22 -0
  163. package/dist/windows.d.ts.map +1 -0
  164. package/dist/windows.js +89 -0
  165. package/dist/wire.d.ts +166 -30
  166. package/dist/wire.d.ts.map +1 -1
  167. package/dist/wire.js +57 -29
  168. package/package.json +26 -15
  169. package/AGENTS.md +0 -269
  170. package/dist/attachment.d.ts +0 -3
  171. package/dist/attachment.d.ts.map +0 -1
  172. package/dist/attachment.js +0 -8
  173. package/dist/read-side.d.ts +0 -18
  174. package/dist/read-side.d.ts.map +0 -1
  175. package/dist/read-side.js +0 -433
@@ -1,8 +1,30 @@
1
- import { parse, validate, VERSION, } from '@agentshouse/mdmodel';
1
+ import { parse, VERSION } from '@agentshouse/mdmodel';
2
2
  import { beneath, normalize } from './paths.js';
3
+ import { hashed } from './observation.js';
4
+ import { sortedKeys } from './shared.js';
3
5
  export const MD_MODEL = { identity: '@agentshouse/mdmodel', version: VERSION };
4
- const NO_TYPES = { types: {} };
5
- function selected(composition, path) {
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
+ }
27
+ export function selected(composition, path) {
6
28
  return (composition.selection !== null &&
7
29
  composition.selection.roots.some((root) => beneath(root, path)));
8
30
  }
@@ -11,22 +33,14 @@ export function governing(composition, path) {
11
33
  ? composition.selection.model
12
34
  : composition.model;
13
35
  }
14
- const parsedIn = new WeakMap();
15
- export function collectionOf(text, composition, previous) {
36
+ export function collectionOf(text, composition) {
16
37
  const parsed = new Map();
17
- if (previous !== undefined) {
18
- for (const [path, held] of parsedIn.get(previous) ?? []) {
19
- if (previous.text[path] === text[path])
20
- parsed.set(path, held);
21
- }
22
- }
23
- const collection = {
38
+ return {
24
39
  text,
25
40
  composition,
26
41
  document(path) {
27
- const held = parsed.get(path);
28
- if (held !== undefined)
29
- return held ?? undefined;
42
+ if (parsed.has(path))
43
+ return parsed.get(path) ?? undefined;
30
44
  const content = text[path];
31
45
  if (content === undefined)
32
46
  return undefined;
@@ -35,75 +49,20 @@ export function collectionOf(text, composition, previous) {
35
49
  return read.ok ? read.document : undefined;
36
50
  },
37
51
  };
38
- parsedIn.set(collection, parsed);
39
- return collection;
40
- }
41
- export function passingDocument(collection, path) {
42
- const held = parsedIn.get(collection)?.get(path);
43
- if (held !== undefined)
44
- return held ?? undefined;
45
- const content = collection.text[path];
46
- if (content === undefined)
47
- return undefined;
48
- const read = parse(content, path);
49
- return read.ok ? read.document : undefined;
50
52
  }
51
53
  export function* documentsOf(collection) {
52
- const parsed = parsedIn.get(collection);
53
- for (const path of Object.keys(collection.text).sort()) {
54
- const held = parsed?.get(path);
55
- if (held === null)
56
- continue;
57
- if (held !== undefined) {
58
- yield [path, held];
59
- continue;
54
+ const paths = yield* sortedKeys(collection.text);
55
+ return (function* () {
56
+ for (const path of paths) {
57
+ const document = collection.document(path);
58
+ if (document !== undefined)
59
+ yield [path, document];
60
60
  }
61
- const read = parse(collection.text[path], path);
62
- if (read.ok)
63
- yield [path, read.document];
64
- }
65
- }
66
- export function unreadable(text, previous) {
67
- for (const path of Object.keys(text).sort()) {
68
- if (previous?.[path] === text[path])
69
- continue;
70
- const read = parse(text[path], path);
71
- if (!read.ok)
72
- return { kind: 'refused', refusal: read.refusal };
73
- }
74
- return null;
61
+ })();
75
62
  }
76
63
  export function validRoot(root) {
77
64
  return typeof root === 'string' && normalize(root) === root;
78
65
  }
79
- function validateAgainst(documents, binaryTargets, model) {
80
- if (model.status === 'unavailable') {
81
- const typed = Object.entries(documents).find(([, content]) => {
82
- const parsed = parse(content);
83
- return parsed.ok && parsed.document.type !== undefined && parsed.document.type !== 'any';
84
- });
85
- if (typed !== undefined)
86
- return { verdict: 'refuse', rule: 'model-unavailable', file: typed[0] };
87
- }
88
- return validate(documents, { binaryTargets }, model.status === 'unavailable' ? NO_TYPES : { types: model.types });
89
- }
90
- export function validateCollection(text, binaryTargets, composition) {
91
- const collection = {};
92
- const selection = {};
93
- for (const [path, content] of Object.entries(text)) {
94
- if (selected(composition, path))
95
- selection[path] = content;
96
- else
97
- collection[path] = content;
98
- }
99
- const verdicts = [
100
- validateAgainst(collection, binaryTargets.filter((path) => !selected(composition, path)), composition.model),
101
- ];
102
- if (composition.selection !== null) {
103
- verdicts.push(validateAgainst(selection, binaryTargets.filter((path) => selected(composition, path)), composition.selection.model));
104
- }
105
- const refusals = verdicts.filter((verdict) => verdict.verdict === 'refuse');
106
- if (refusals.length === 0)
107
- return verdicts[0];
108
- return refusals.find((refusal) => refusal.rule !== 'model-unavailable') ?? refusals[0];
66
+ export function available(composition) {
67
+ return composition.model.status !== 'unavailable';
109
68
  }
@@ -0,0 +1,16 @@
1
+ import { type Plan, type QueryRows } from './query.js';
2
+ import type { Connection, Value } from './tables.js';
3
+ export type QueryRoom = {
4
+ readonly locator: string;
5
+ readonly key: number;
6
+ };
7
+ export type Fragment = {
8
+ readonly sql: string;
9
+ readonly bind: readonly Value[];
10
+ };
11
+ export type QueryAnswer = QueryRows & {
12
+ readonly more?: string;
13
+ };
14
+ export declare function selected(connection: Connection, plan: Plan, rooms: readonly QueryRoom[]): Fragment;
15
+ export declare function answerQuery(connection: Connection, plan: Plan, rooms: readonly QueryRoom[], budget?: number | null): QueryAnswer;
16
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAIA,OAAO,EAQL,KAAK,IAAI,EAIT,KAAK,SAAS,EAIf,MAAM,YAAY,CAAC;AAGpB,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,CAAC,IAAI,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,CAAC;AAgtBjF,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAqTjE,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,GAC1B,QAAQ,CAEV;AAED,wBAAgB,WAAW,CACzB,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,MAAM,GAAE,MAAM,GAAG,IAAW,GAC3B,WAAW,CAUb"}