@agentshouse/mdruntime 0.1.0-alpha.3 → 0.1.0-alpha.31

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 (128) hide show
  1. package/AGENTS.md +178 -0
  2. package/dist/adapter.d.ts +150 -18
  3. package/dist/adapter.d.ts.map +1 -1
  4. package/dist/adapter.js +2 -1
  5. package/dist/adapter.js.map +1 -1
  6. package/dist/bootstrap.d.ts +7 -7
  7. package/dist/bootstrap.d.ts.map +1 -1
  8. package/dist/bootstrap.js +13 -9
  9. package/dist/bootstrap.js.map +1 -1
  10. package/dist/change-set.d.ts +33 -0
  11. package/dist/change-set.d.ts.map +1 -0
  12. package/dist/change-set.js +89 -0
  13. package/dist/change-set.js.map +1 -0
  14. package/dist/change.d.ts +10 -0
  15. package/dist/change.d.ts.map +1 -1
  16. package/dist/change.js.map +1 -1
  17. package/dist/client.d.ts +72 -0
  18. package/dist/client.d.ts.map +1 -0
  19. package/dist/client.js +231 -0
  20. package/dist/client.js.map +1 -0
  21. package/dist/collection.d.ts +22 -12
  22. package/dist/collection.d.ts.map +1 -1
  23. package/dist/collection.js +88 -30
  24. package/dist/collection.js.map +1 -1
  25. package/dist/connection.d.ts +90 -20
  26. package/dist/connection.d.ts.map +1 -1
  27. package/dist/connection.js +1776 -194
  28. package/dist/connection.js.map +1 -1
  29. package/dist/conversation.d.ts +72 -0
  30. package/dist/conversation.d.ts.map +1 -0
  31. package/dist/conversation.js +529 -0
  32. package/dist/conversation.js.map +1 -0
  33. package/dist/durability.d.ts +9 -0
  34. package/dist/durability.d.ts.map +1 -0
  35. package/dist/durability.js +11 -0
  36. package/dist/durability.js.map +1 -0
  37. package/dist/file.d.ts +20 -0
  38. package/dist/file.d.ts.map +1 -0
  39. package/dist/file.js +149 -0
  40. package/dist/file.js.map +1 -0
  41. package/dist/host.d.ts +13 -0
  42. package/dist/host.d.ts.map +1 -0
  43. package/dist/host.js +205 -0
  44. package/dist/host.js.map +1 -0
  45. package/dist/identity.d.ts +3 -0
  46. package/dist/identity.d.ts.map +1 -0
  47. package/dist/identity.js +23 -0
  48. package/dist/identity.js.map +1 -0
  49. package/dist/index.d.ts +15 -6
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/log.d.ts +5 -0
  54. package/dist/log.d.ts.map +1 -0
  55. package/dist/log.js +15 -0
  56. package/dist/log.js.map +1 -0
  57. package/dist/memory.d.ts +17 -2
  58. package/dist/memory.d.ts.map +1 -1
  59. package/dist/memory.js +201 -15
  60. package/dist/memory.js.map +1 -1
  61. package/dist/model.d.ts +56 -0
  62. package/dist/model.d.ts.map +1 -0
  63. package/dist/model.js +37 -0
  64. package/dist/model.js.map +1 -0
  65. package/dist/observation.d.ts +25 -0
  66. package/dist/observation.d.ts.map +1 -0
  67. package/dist/observation.js +92 -0
  68. package/dist/observation.js.map +1 -0
  69. package/dist/outcome.d.ts +34 -0
  70. package/dist/outcome.d.ts.map +1 -0
  71. package/dist/outcome.js +3 -0
  72. package/dist/outcome.js.map +1 -0
  73. package/dist/overlay.d.ts +2 -0
  74. package/dist/overlay.d.ts.map +1 -1
  75. package/dist/overlay.js +107 -1
  76. package/dist/overlay.js.map +1 -1
  77. package/dist/paths.d.ts +0 -1
  78. package/dist/paths.d.ts.map +1 -1
  79. package/dist/paths.js +0 -4
  80. package/dist/paths.js.map +1 -1
  81. package/dist/query.d.ts +209 -0
  82. package/dist/query.d.ts.map +1 -0
  83. package/dist/query.js +467 -0
  84. package/dist/query.js.map +1 -0
  85. package/dist/read-side.d.ts +14 -0
  86. package/dist/read-side.d.ts.map +1 -0
  87. package/dist/read-side.js +451 -0
  88. package/dist/read-side.js.map +1 -0
  89. package/dist/refresh.d.ts +2 -2
  90. package/dist/refresh.d.ts.map +1 -1
  91. package/dist/refresh.js +8 -6
  92. package/dist/refresh.js.map +1 -1
  93. package/dist/replica.d.ts +22 -3
  94. package/dist/replica.d.ts.map +1 -1
  95. package/dist/replica.js +170 -8
  96. package/dist/replica.js.map +1 -1
  97. package/dist/room-draft.d.ts +124 -0
  98. package/dist/room-draft.d.ts.map +1 -0
  99. package/dist/room-draft.js +406 -0
  100. package/dist/room-draft.js.map +1 -0
  101. package/dist/rows.d.ts +39 -0
  102. package/dist/rows.d.ts.map +1 -0
  103. package/dist/rows.js +100 -0
  104. package/dist/rows.js.map +1 -0
  105. package/dist/save.d.ts +11 -2
  106. package/dist/save.d.ts.map +1 -1
  107. package/dist/save.js +104 -128
  108. package/dist/save.js.map +1 -1
  109. package/dist/search.d.ts +61 -0
  110. package/dist/search.d.ts.map +1 -0
  111. package/dist/search.js +155 -0
  112. package/dist/search.js.map +1 -0
  113. package/dist/status.d.ts +9 -1
  114. package/dist/status.d.ts.map +1 -1
  115. package/dist/status.js +7 -4
  116. package/dist/status.js.map +1 -1
  117. package/dist/store.d.ts +87 -15
  118. package/dist/store.d.ts.map +1 -1
  119. package/dist/store.js +436 -54
  120. package/dist/store.js.map +1 -1
  121. package/dist/transfer.d.ts +5 -0
  122. package/dist/transfer.d.ts.map +1 -1
  123. package/dist/transfer.js.map +1 -1
  124. package/dist/wire.d.ts +64 -0
  125. package/dist/wire.d.ts.map +1 -0
  126. package/dist/wire.js +142 -0
  127. package/dist/wire.js.map +1 -0
  128. package/package.json +14 -4
@@ -0,0 +1,89 @@
1
+ import { beneath } from './paths.js';
2
+ import { compositionOf } from './replica.js';
3
+ import { rowsOf } from './rows.js';
4
+ function rowsAt(locator, replica, path) {
5
+ const document = replica?.visible.collection.documents[path];
6
+ if (replica === null) return [];
7
+ if (document === undefined && !replica.visible.binaryTargets.includes(path)) return [];
8
+ return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record));
9
+ }
10
+ function modelShape(model) {
11
+ return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
12
+ }
13
+ export function changeSet(locator, before, after, changed = {}) {
14
+ const paths = new Set([
15
+ ...Object.keys(before?.visible.documents ?? {}),
16
+ ...Object.keys(after?.visible.documents ?? {}),
17
+ ...before?.visible.binaryTargets ?? [],
18
+ ...after?.visible.binaryTargets ?? []
19
+ ]);
20
+ const documents = [];
21
+ const oldRoom = before?.confirmed.record;
22
+ const newRoom = after?.confirmed.record;
23
+ const collectionChanged = oldRoom !== undefined && newRoom !== undefined && modelShape(oldRoom.model) !== modelShape(newRoom.model);
24
+ const selectionChanged = oldRoom !== undefined && newRoom !== undefined && modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);
25
+ for (const path of paths){
26
+ const selected = newRoom?.typedSelection?.roots.some((root)=>beneath(root, path)) ?? false;
27
+ const inCollection = newRoom !== undefined && (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));
28
+ const retyped = selected ? selectionChanged : inCollection && collectionChanged;
29
+ if (before?.visible.documents[path] === after?.visible.documents[path] && before?.visible.binaryTargets.includes(path) === after?.visible.binaryTargets.includes(path) && before?.visible.revisions[path] === after?.visible.revisions[path] && !retyped) continue;
30
+ documents.push({
31
+ locator,
32
+ path,
33
+ before: rowsAt(locator, before, path),
34
+ after: rowsAt(locator, after, path)
35
+ });
36
+ }
37
+ return {
38
+ documents,
39
+ drafts: (changed.drafts ?? []).map((path)=>({
40
+ locator,
41
+ path
42
+ })),
43
+ rooms: changed.room ? [
44
+ locator
45
+ ] : [],
46
+ queues: changed.queue ? [
47
+ locator
48
+ ] : [],
49
+ presentations: changed.presentation === undefined ? [] : [
50
+ changed.presentation
51
+ ],
52
+ messages: [],
53
+ conversations: []
54
+ };
55
+ }
56
+ export function conversationChangeSet(messages, conversations) {
57
+ return {
58
+ documents: [],
59
+ drafts: [],
60
+ rooms: [],
61
+ queues: [],
62
+ presentations: [],
63
+ messages,
64
+ conversations: [
65
+ ...new Set(conversations)
66
+ ]
67
+ };
68
+ }
69
+ export function mergeChangeSets(sets) {
70
+ return {
71
+ documents: sets.flatMap((set)=>set.documents),
72
+ drafts: sets.flatMap((set)=>set.drafts),
73
+ rooms: [
74
+ ...new Set(sets.flatMap((set)=>set.rooms))
75
+ ],
76
+ queues: [
77
+ ...new Set(sets.flatMap((set)=>set.queues))
78
+ ],
79
+ presentations: [
80
+ ...new Set(sets.flatMap((set)=>set.presentations))
81
+ ],
82
+ messages: sets.flatMap((set)=>set.messages),
83
+ conversations: [
84
+ ...new Set(sets.flatMap((set)=>set.conversations))
85
+ ]
86
+ };
87
+ }
88
+
89
+ //# sourceMappingURL=change-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/workspace/packages/mdruntime/src/change-set.ts"],"sourcesContent":["import { beneath } from './paths.js';\nimport { compositionOf, type Replica } from './replica.js';\nimport { rowsOf, type Row } from './rows.js';\n\nexport type DocumentChange = {\n locator: string;\n path: string;\n before: readonly Row[];\n after: readonly Row[];\n};\n\nexport type MessageChange = { conversation: string; identity: string };\n\nexport type ChangeSet = {\n documents: readonly DocumentChange[];\n drafts: readonly { locator: string; path: string }[];\n rooms: readonly string[];\n queues: readonly string[];\n presentations: readonly string[];\n messages: readonly MessageChange[];\n conversations: readonly string[];\n};\n\nfunction rowsAt(locator: string, replica: Replica | null, path: string): readonly Row[] {\n const document = replica?.visible.collection.documents[path];\n if (replica === null) return [];\n if (document === undefined && !replica.visible.binaryTargets.includes(path)) return [];\n return rowsOf(locator, path, document ?? null, compositionOf(replica.confirmed.record));\n}\n\nfunction modelShape(model: Replica['confirmed']['record']['model']): string {\n return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);\n}\n\nexport function changeSet(\n locator: string,\n before: Replica | null,\n after: Replica | null,\n changed: {\n drafts?: readonly string[];\n room?: boolean;\n queue?: boolean;\n presentation?: string;\n } = {},\n): ChangeSet {\n const paths = new Set([\n ...Object.keys(before?.visible.documents ?? {}),\n ...Object.keys(after?.visible.documents ?? {}),\n ...(before?.visible.binaryTargets ?? []),\n ...(after?.visible.binaryTargets ?? []),\n ]);\n const documents: DocumentChange[] = [];\n const oldRoom = before?.confirmed.record;\n const newRoom = after?.confirmed.record;\n const collectionChanged =\n oldRoom !== undefined &&\n newRoom !== undefined &&\n modelShape(oldRoom.model) !== modelShape(newRoom.model);\n const selectionChanged =\n oldRoom !== undefined &&\n newRoom !== undefined &&\n modelShape(oldRoom.selectionModel) !== modelShape(newRoom.selectionModel);\n for (const path of paths) {\n const selected = newRoom?.typedSelection?.roots.some((root) => beneath(root, path)) ?? false;\n const inCollection =\n newRoom !== undefined &&\n (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));\n const retyped = selected ? selectionChanged : inCollection && collectionChanged;\n if (\n before?.visible.documents[path] === after?.visible.documents[path] &&\n before?.visible.binaryTargets.includes(path) ===\n after?.visible.binaryTargets.includes(path) &&\n before?.visible.revisions[path] === after?.visible.revisions[path] &&\n !retyped\n )\n continue;\n documents.push({\n locator,\n path,\n before: rowsAt(locator, before, path),\n after: rowsAt(locator, after, path),\n });\n }\n return {\n documents,\n drafts: (changed.drafts ?? []).map((path) => ({ locator, path })),\n rooms: changed.room ? [locator] : [],\n queues: changed.queue ? [locator] : [],\n presentations: changed.presentation === undefined ? [] : [changed.presentation],\n messages: [],\n conversations: [],\n };\n}\n\nexport function conversationChangeSet(\n messages: readonly MessageChange[],\n conversations: readonly string[],\n): ChangeSet {\n return {\n documents: [],\n drafts: [],\n rooms: [],\n queues: [],\n presentations: [],\n messages,\n conversations: [...new Set(conversations)],\n };\n}\n\nexport function mergeChangeSets(sets: readonly ChangeSet[]): ChangeSet {\n return {\n documents: sets.flatMap((set) => set.documents),\n drafts: sets.flatMap((set) => set.drafts),\n rooms: [...new Set(sets.flatMap((set) => set.rooms))],\n queues: [...new Set(sets.flatMap((set) => set.queues))],\n presentations: [...new Set(sets.flatMap((set) => set.presentations))],\n messages: sets.flatMap((set) => set.messages),\n conversations: [...new Set(sets.flatMap((set) => set.conversations))],\n };\n}\n"],"names":["beneath","compositionOf","rowsOf","rowsAt","locator","replica","path","document","visible","collection","documents","undefined","binaryTargets","includes","confirmed","record","modelShape","model","status","JSON","stringify","types","changeSet","before","after","changed","paths","Set","Object","keys","oldRoom","newRoom","collectionChanged","selectionChanged","selectionModel","selected","typedSelection","roots","some","root","inCollection","collectionRoot","retyped","revisions","push","drafts","map","rooms","room","queues","queue","presentations","presentation","messages","conversations","conversationChangeSet","mergeChangeSets","sets","flatMap","set"],"mappings":"AAAA,SAASA,OAAO,QAAQ,aAAa;AACrC,SAASC,aAAa,QAAsB,eAAe;AAC3D,SAASC,MAAM,QAAkB,YAAY;AAqB7C,SAASC,OAAOC,OAAe,EAAEC,OAAuB,EAAEC,IAAY;IACpE,MAAMC,WAAWF,SAASG,QAAQC,WAAWC,SAAS,CAACJ,KAAK;IAC5D,IAAID,YAAY,MAAM,OAAO,EAAE;IAC/B,IAAIE,aAAaI,aAAa,CAACN,QAAQG,OAAO,CAACI,aAAa,CAACC,QAAQ,CAACP,OAAO,OAAO,EAAE;IACtF,OAAOJ,OAAOE,SAASE,MAAMC,YAAY,MAAMN,cAAcI,QAAQS,SAAS,CAACC,MAAM;AACvF;AAEA,SAASC,WAAWC,KAA8C;IAChE,OAAOA,MAAMC,MAAM,KAAK,gBAAgB,gBAAgBC,KAAKC,SAAS,CAACH,MAAMI,KAAK;AACpF;AAEA,OAAO,SAASC,UACdlB,OAAe,EACfmB,MAAsB,EACtBC,KAAqB,EACrBC,UAKI,CAAC,CAAC;IAEN,MAAMC,QAAQ,IAAIC,IAAI;WACjBC,OAAOC,IAAI,CAACN,QAAQf,QAAQE,aAAa,CAAC;WAC1CkB,OAAOC,IAAI,CAACL,OAAOhB,QAAQE,aAAa,CAAC;WACxCa,QAAQf,QAAQI,iBAAiB,EAAE;WACnCY,OAAOhB,QAAQI,iBAAiB,EAAE;KACvC;IACD,MAAMF,YAA8B,EAAE;IACtC,MAAMoB,UAAUP,QAAQT,UAAUC;IAClC,MAAMgB,UAAUP,OAAOV,UAAUC;IACjC,MAAMiB,oBACJF,YAAYnB,aACZoB,YAAYpB,aACZK,WAAWc,QAAQb,KAA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SAASC,sBACdF,QAAkC,EAClCC,aAAgC;IAEhC,OAAO;QACL5C,WAAW,EAAE;QACbmC,QAAQ,EAAE;QACVE,OAAO,EAAE;QACTE,QAAQ,EAAE;QACVE,eAAe,EAAE;QACjBE;QACAC,eAAe;eAAI,IAAI3B,IAAI2B;SAAe;IAC5C;AACF;AAEA,OAAO,SAASE,gBAAgBC,IAA0B;IACxD,OAAO;QACL/C,WAAW+C,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIjD,SAAS;QAC9CmC,QAAQY,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAId,MAAM;QACxCE,OAAO;eAAI,IAAIpB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIZ,KAAK;SAAG;QACrDE,QAAQ;eAAI,IAAItB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIV,MAAM;SAAG;QACvDE,eAAe;eAAI,IAAIxB,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIR,aAAa;SAAG;QACrEE,UAAUI,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIN,QAAQ;QAC5CC,eAAe;eAAI,IAAI3B,IAAI8B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIL,aAAa;SAAG;IACvE;AACF"}
package/dist/change.d.ts CHANGED
@@ -17,6 +17,10 @@ export type Change = {
17
17
  readonly path: string;
18
18
  readonly fields: Readonly<Record<string, unknown>>;
19
19
  readonly sections: Readonly<Record<string, string>>;
20
+ } | {
21
+ readonly kind: 'create';
22
+ readonly path: string;
23
+ readonly content: string;
20
24
  } | {
21
25
  readonly kind: 'replace';
22
26
  readonly path: string;
@@ -54,11 +58,17 @@ export type Precondition = {
54
58
  readonly kind: 'absent';
55
59
  readonly path: string;
56
60
  };
61
+ export type WrittenBy = {
62
+ readonly app: string;
63
+ readonly release: string;
64
+ };
57
65
  export type ChangeBatch = {
66
+ validation?: import('./model.js').ValidationReceipt;
58
67
  readonly id: string;
59
68
  readonly baseRoomVersion: string;
60
69
  readonly changes: readonly Change[];
61
70
  readonly preconditions: readonly Precondition[];
71
+ readonly writtenBy?: WrittenBy;
62
72
  };
63
73
  export declare function immutable(batch: ChangeBatch): ChangeBatch;
64
74
  //# sourceMappingURL=change.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change.d.ts","sourceRoot":"","sources":["../src/change.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GACd;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5E;IACE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACrD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7E;IAAE,QAAQ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AAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,SAAS,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3E,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,CAAC,EAAE,OAAO,YAAY,EAAE,iBAAiB,CAAC;IACpD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,YAAY,EAAE,CAAC;IAChD,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC,CAAC;AAUF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,CAEzD"}
@@ -1 +1 @@
1
- {"version":3,"sources":["/workspace/packages/mdruntime/src/change.ts"],"sourcesContent":["export type Change =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | {\n readonly kind: 'create';\n readonly path: string;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly sections: Readonly<Record<string, string>>;\n }\n | { readonly kind: 'replace'; readonly path: string; readonly content: string }\n | { readonly kind: 'move'; readonly path: string; readonly to: string }\n | { readonly kind: 'remove'; readonly path: string };\n\nexport type Precondition =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | { readonly kind: 'revision'; readonly path: string; readonly revision: string }\n | { readonly kind: 'present'; readonly path: string }\n | { readonly kind: 'absent'; readonly path: string };\n\nexport type ChangeBatch = {\n readonly id: string;\n readonly baseRoomVersion: string;\n readonly changes: readonly Change[];\n readonly preconditions: readonly Precondition[];\n};\n\nfunction frozen<T>(value: T): T {\n if (Array.isArray(value)) return Object.freeze(value.map((item) => frozen(item))) as T;\n if (value === null || typeof value !== 'object') return value;\n const copy: Record<string, unknown> = {};\n for (const [name, item] of Object.entries(value)) copy[name] = frozen(item);\n return Object.freeze(copy) as T;\n}\n\nexport function immutable(batch: ChangeBatch): ChangeBatch {\n return frozen(batch);\n}\n"],"names":["frozen","value","Array","isArray","Object","freeze","map","item","copy","name","entries","immutable","batch"],"mappings":"AAiDA,SAASA,OAAUC,KAAQ;IACzB,IAAIC,MAAMC,OAAO,CAACF,QAAQ,OAAOG,OAAOC,MAAM,CAACJ,MAAMK,GAAG,CAAC,CAACC,OAASP,OAAOO;IAC1E,IAAIN,UAAU,QAAQ,OAAOA,UAAU,UAAU,OAAOA;IACxD,MAAMO,OAAgC,CAAC;IACvC,KAAK,MAAM,CAACC,MAAMF,KAAK,IAAIH,OAAOM,OAAO,CAACT,OAAQO,IAAI,CAACC,KAAK,GAAGT,OAAOO;IACtE,OAAOH,OAAOC,MAAM,CAACG;AACvB;AAEA,OAAO,SAASG,UAAUC,KAAkB;IAC1C,OAAOZ,OAAOY;AAChB"}
1
+ {"version":3,"sources":["/workspace/packages/mdruntime/src/change.ts"],"sourcesContent":["export type Change =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | {\n readonly kind: 'create';\n readonly path: string;\n readonly fields: Readonly<Record<string, unknown>>;\n readonly sections: Readonly<Record<string, string>>;\n }\n | { readonly kind: 'create'; readonly path: string; readonly content: string }\n | { readonly kind: 'replace'; readonly path: string; readonly content: string }\n | { readonly kind: 'move'; readonly path: string; readonly to: string }\n | { readonly kind: 'remove'; readonly path: string };\n\nexport type Precondition =\n | {\n readonly kind: 'field';\n readonly path: string;\n readonly name: string;\n readonly value: unknown;\n }\n | {\n readonly kind: 'section';\n readonly path: string;\n readonly name: string;\n readonly value: string;\n }\n | { readonly kind: 'preamble'; readonly path: string; readonly value: string }\n | { readonly kind: 'revision'; readonly path: string; readonly revision: string }\n | { readonly kind: 'present'; readonly path: string }\n | { readonly kind: 'absent'; readonly path: string };\n\nexport type WrittenBy = { readonly app: string; readonly release: string };\n\nexport type ChangeBatch = {\n validation?: import('./model.js').ValidationReceipt;\n readonly id: string;\n readonly baseRoomVersion: string;\n readonly changes: readonly Change[];\n readonly preconditions: readonly Precondition[];\n readonly writtenBy?: WrittenBy;\n};\n\nfunction frozen<T>(value: T): T {\n if (Array.isArray(value)) return Object.freeze(value.map((item) => frozen(item))) as T;\n if (value === null || typeof value !== 'object') return value;\n const copy: Record<string, unknown> = {};\n for (const [name, item] of Object.entries(value)) copy[name] = frozen(item);\n return Object.freeze(copy) as T;\n}\n\nexport function immutable(batch: ChangeBatch): ChangeBatch {\n return frozen(batch);\n}\n"],"names":["frozen","value","Array","isArray","Object","freeze","map","item","copy","name","entries","immutable","batch"],"mappings":"AAsDA,SAASA,OAAUC,KAAQ;IACzB,IAAIC,MAAMC,OAAO,CAACF,QAAQ,OAAOG,OAAOC,MAAM,CAACJ,MAAMK,GAAG,CAAC,CAACC,OAASP,OAAOO;IAC1E,IAAIN,UAAU,QAAQ,OAAOA,UAAU,UAAU,OAAOA;IACxD,MAAMO,OAAgC,CAAC;IACvC,KAAK,MAAM,CAACC,MAAMF,KAAK,IAAIH,OAAOM,OAAO,CAACT,OAAQO,IAAI,CAACC,KAAK,GAAGT,OAAOO;IACtE,OAAOH,OAAOC,MAAM,CAACG;AACvB;AAEA,OAAO,SAASG,UAAUC,KAAkB;IAC1C,OAAOZ,OAAOY;AAChB"}
@@ -0,0 +1,72 @@
1
+ import type { AppRoom, AppSlot, ConnectionRefusal, HistoryQuery, RoomTypes, SavedRoomDraft, SaveResult } from './connection.js';
2
+ import type { HistoryResult } from './adapter.js';
3
+ import type { ChatDraft, ConversationEntry, ConversationOptions, ConversationView } from './conversation.js';
4
+ import { type Observation } from './observation.js';
5
+ import type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';
6
+ import type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';
7
+ import type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';
8
+ import type { SearchRequest, SearchResult } from './search.js';
9
+ import type { SyncStatus } from './status.js';
10
+ import { type RuntimePort } from './wire.js';
11
+ export type MdRuntimeClient = {
12
+ rooms(): Promise<readonly AppRoom[]>;
13
+ slots(): Promise<readonly AppSlot[]>;
14
+ query: {
15
+ (query: DocumentQuery): Promise<DocumentResult>;
16
+ (query: GroupQuery): Promise<GroupResult>;
17
+ };
18
+ search(request: SearchRequest): Promise<SearchResult>;
19
+ types(locator: string): Promise<RoomTypes>;
20
+ syncStatus(): Promise<SyncStatus>;
21
+ roomDraft: {
22
+ list(): Promise<readonly RoomDraft[]>;
23
+ read(room: string, path: string): Promise<RoomDraft | null>;
24
+ write(room: string, path: string, revision: string | null, parts: RoomDraftParts): Promise<RoomDraftWrite>;
25
+ discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
26
+ };
27
+ save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;
28
+ outcome(identifier: string): Promise<SubmissionOutcome | null>;
29
+ presentation: {
30
+ read(): Promise<unknown>;
31
+ write(value: unknown): Promise<void>;
32
+ };
33
+ conversation: {
34
+ list(): Promise<readonly ConversationEntry[]>;
35
+ read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;
36
+ create(input: unknown): Promise<CallResult>;
37
+ send(conversation: string): Promise<CallResult>;
38
+ answer(conversation: string, answer: unknown): Promise<CallResult>;
39
+ interrupt(conversation: string): Promise<CallResult>;
40
+ kill(conversation: string): Promise<CallResult>;
41
+ cancel(conversation: string, turn: string): Promise<CallResult>;
42
+ delete(conversation: string): Promise<CallResult>;
43
+ };
44
+ chatDraft: {
45
+ write(conversation: string, draft: ChatDraft): Promise<void>;
46
+ discard(conversation: string): Promise<void>;
47
+ };
48
+ history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;
49
+ call(name: string, input: unknown): Promise<CallResult>;
50
+ log(): Promise<string>;
51
+ storageLoss(): Promise<string | null>;
52
+ persistence(): Promise<boolean>;
53
+ deploymentFacts(): Promise<unknown>;
54
+ observe: {
55
+ (topic: 'deployment-facts'): Promise<Observation<unknown>>;
56
+ (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;
57
+ (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;
58
+ (topic: 'storage-loss'): Promise<Observation<string | null>>;
59
+ (topic: 'sync-status'): Promise<Observation<SyncStatus>>;
60
+ (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;
61
+ (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;
62
+ (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;
63
+ (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;
64
+ (topic: 'presentation'): Promise<Observation<unknown>>;
65
+ (topic: 'conversation', conversation: string, options: ConversationOptions): Promise<Observation<ConversationView>>;
66
+ };
67
+ reauthorize(): Promise<void>;
68
+ };
69
+ export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
70
+ export type { Observation } from './observation.js';
71
+ export type { RuntimePort } from './wire.js';
72
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,YAAY,EACZ,SAAS,EACT,cAAc,EACd,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;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AC;QAC7D,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;QACzD,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7E,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;QACvE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC,CAAC;QAC/E,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC,CAAC;QACnE,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,CACE,KAAK,EAAE,cAAc,EACrB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC,CAAC;KAC3C,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAqLnE;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,231 @@
1
+ import { observed } from './observation.js';
2
+ import { answer, AUTHORIZATION_ENDED, carried, envelope, PORT_CLOSED, PROTOCOL_MISMATCH } from './wire.js';
3
+ export function connectMdRuntime(port) {
4
+ let sequence = 0;
5
+ let refusal = null;
6
+ let ended = null;
7
+ const calls = new Map();
8
+ const opening = new Map();
9
+ const observations = new Map();
10
+ const send = (message)=>{
11
+ port.postMessage(envelope(message));
12
+ };
13
+ function begin(id, topic, first) {
14
+ const handle = observed(first, ()=>{
15
+ observations.delete(id);
16
+ if (refusal === null) send({
17
+ kind: 'stop',
18
+ id
19
+ });
20
+ }, topic === 'query');
21
+ observations.set(id, {
22
+ topic,
23
+ handle
24
+ });
25
+ return handle.observation;
26
+ }
27
+ function refuse(reported) {
28
+ refusal = reported;
29
+ for (const { topic, handle } of observations.values()){
30
+ if (topic === 'connection-refusal') handle.receive(reported);
31
+ }
32
+ const failure = new Error(reported.reason);
33
+ for (const [id, waiting] of opening){
34
+ if (waiting.topic === 'connection-refusal') waiting.settle(begin(id, waiting.topic, reported));
35
+ else waiting.fail(failure);
36
+ }
37
+ opening.clear();
38
+ for (const waiting of calls.values())waiting.fail(failure);
39
+ calls.clear();
40
+ }
41
+ function end(reason) {
42
+ if (ended !== null) return;
43
+ ended = reason;
44
+ const failure = new Error(reason);
45
+ for (const waiting of opening.values())waiting.fail(failure);
46
+ opening.clear();
47
+ for (const waiting of calls.values())waiting.fail(failure);
48
+ calls.clear();
49
+ for (const { handle } of observations.values())handle.end();
50
+ observations.clear();
51
+ }
52
+ port.addEventListener('message', (event)=>{
53
+ const wire = carried(event.data);
54
+ if (wire === null) return;
55
+ if (!wire.matching) {
56
+ refuse(PROTOCOL_MISMATCH);
57
+ return;
58
+ }
59
+ const message = answer(wire.message);
60
+ if (message === null) return;
61
+ if (message.kind === 'refusal') {
62
+ refuse(message.refusal);
63
+ return;
64
+ }
65
+ if (message.kind === 'ended') {
66
+ end(AUTHORIZATION_ENDED);
67
+ return;
68
+ }
69
+ if (message.kind === 'event') {
70
+ observations.get(message.id)?.handle.receive(message.value);
71
+ return;
72
+ }
73
+ const waiting = opening.get(message.id);
74
+ if (waiting !== undefined) {
75
+ opening.delete(message.id);
76
+ if (message.kind === 'failure') waiting.fail(new Error(message.message));
77
+ else waiting.settle(begin(message.id, waiting.topic, message.value));
78
+ return;
79
+ }
80
+ const called = calls.get(message.id);
81
+ if (called === undefined) return;
82
+ calls.delete(message.id);
83
+ if (message.kind === 'failure') called.fail(new Error(message.message));
84
+ else called.settle(message.value);
85
+ });
86
+ port.addEventListener('close', ()=>{
87
+ end(PORT_CLOSED);
88
+ });
89
+ port.start();
90
+ send({
91
+ kind: 'hello'
92
+ });
93
+ function ask(member, input) {
94
+ if (ended !== null) return Promise.reject(new Error(ended));
95
+ if (refusal !== null) return Promise.reject(new Error(refusal.reason));
96
+ const id = sequence += 1;
97
+ return new Promise((settle, fail)=>{
98
+ calls.set(id, {
99
+ settle: settle,
100
+ fail
101
+ });
102
+ send({
103
+ kind: 'call',
104
+ id,
105
+ member,
106
+ input
107
+ });
108
+ });
109
+ }
110
+ function watch(topic, input) {
111
+ if (ended !== null) return Promise.reject(new Error(ended));
112
+ const id = sequence += 1;
113
+ if (refusal !== null) {
114
+ return topic === 'connection-refusal' ? Promise.resolve(begin(id, topic, refusal)) : Promise.reject(new Error(refusal.reason));
115
+ }
116
+ return new Promise((settle, fail)=>{
117
+ opening.set(id, {
118
+ topic,
119
+ settle,
120
+ fail
121
+ });
122
+ send({
123
+ kind: 'observe',
124
+ id,
125
+ topic,
126
+ input
127
+ });
128
+ });
129
+ }
130
+ return {
131
+ rooms: ()=>ask('rooms', []),
132
+ slots: ()=>ask('slots', []),
133
+ query: (query)=>ask('query', [
134
+ query
135
+ ]),
136
+ search: (request)=>ask('search', [
137
+ request
138
+ ]),
139
+ types: (locator)=>ask('types', [
140
+ locator
141
+ ]),
142
+ syncStatus: ()=>ask('syncStatus', []),
143
+ roomDraft: {
144
+ list: ()=>ask('roomDraft.list', []),
145
+ read: (room, path)=>ask('roomDraft.read', [
146
+ room,
147
+ path
148
+ ]),
149
+ write: (room, path, revision, parts)=>ask('roomDraft.write', [
150
+ room,
151
+ path,
152
+ revision,
153
+ parts
154
+ ]),
155
+ discard: (room, path, revision)=>ask('roomDraft.discard', [
156
+ room,
157
+ path,
158
+ revision
159
+ ])
160
+ },
161
+ save: (room, roomDrafts)=>ask('save', [
162
+ room,
163
+ roomDrafts
164
+ ]),
165
+ outcome: (identifier)=>ask('outcome', [
166
+ identifier
167
+ ]),
168
+ presentation: {
169
+ read: ()=>ask('presentation.read', []),
170
+ write: (value)=>ask('presentation.write', [
171
+ value
172
+ ])
173
+ },
174
+ conversation: {
175
+ list: ()=>ask('conversation.list', []),
176
+ read: (conversation, options)=>ask('conversation.read', [
177
+ conversation,
178
+ options
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
+ chatDraft: {
205
+ write: (conversation, draft)=>ask('chatDraft.write', [
206
+ conversation,
207
+ draft
208
+ ]),
209
+ discard: (conversation)=>ask('chatDraft.discard', [
210
+ conversation
211
+ ])
212
+ },
213
+ history: (locator, path, query)=>ask('history', [
214
+ locator,
215
+ path,
216
+ query
217
+ ]),
218
+ call: (name, input)=>ask('call', [
219
+ name,
220
+ input
221
+ ]),
222
+ log: ()=>ask('log', []),
223
+ storageLoss: ()=>ask('storageLoss', []),
224
+ persistence: ()=>ask('persistence', []),
225
+ deploymentFacts: ()=>ask('deploymentFacts', []),
226
+ observe: (topic, ...input)=>watch(topic, input),
227
+ reauthorize: ()=>ask('reauthorize', [])
228
+ };
229
+ }
230
+
231
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/workspace/packages/mdruntime/src/client.ts"],"sourcesContent":["import type {\n AppRoom,\n AppSlot,\n ConnectionRefusal,\n HistoryQuery,\n RoomTypes,\n SavedRoomDraft,\n SaveResult,\n} from './connection.js';\nimport type { HistoryResult } from './adapter.js';\nimport type {\n ChatDraft,\n ConversationEntry,\n ConversationOptions,\n ConversationView,\n} from './conversation.js';\nimport { observed, type Observation, type Observed } from './observation.js';\nimport type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';\nimport type { DocumentQuery, DocumentResult, GroupQuery, GroupResult } from './query.js';\nimport type { RoomDraft, RoomDraftParts, RoomDraftWrite } from './room-draft.js';\nimport type { SearchRequest, SearchResult } from './search.js';\nimport type { SyncStatus } from './status.js';\nimport {\n answer,\n AUTHORIZATION_ENDED,\n carried,\n envelope,\n PORT_CLOSED,\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 slots(): Promise<readonly AppSlot[]>;\n query: {\n (query: DocumentQuery): Promise<DocumentResult>;\n (query: GroupQuery): Promise<GroupResult>;\n };\n search(request: SearchRequest): Promise<SearchResult>;\n types(locator: string): Promise<RoomTypes>;\n syncStatus(): Promise<SyncStatus>;\n roomDraft: {\n list(): Promise<readonly RoomDraft[]>;\n read(room: string, path: string): Promise<RoomDraft | null>;\n write(\n room: string,\n path: string,\n revision: string | null,\n parts: RoomDraftParts,\n ): Promise<RoomDraftWrite>;\n discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;\n };\n save(room: string, roomDrafts: readonly SavedRoomDraft[]): Promise<SaveResult>;\n outcome(identifier: string): Promise<SubmissionOutcome | null>;\n presentation: {\n read(): Promise<unknown>;\n write(value: unknown): Promise<void>;\n };\n conversation: {\n list(): Promise<readonly ConversationEntry[]>;\n read(conversation: string, options?: ConversationOptions): Promise<ConversationView>;\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 chatDraft: {\n write(conversation: string, draft: ChatDraft): Promise<void>;\n discard(conversation: string): Promise<void>;\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 deploymentFacts(): Promise<unknown>;\n observe: {\n (topic: 'deployment-facts'): Promise<Observation<unknown>>;\n (topic: 'rooms'): Promise<Observation<readonly AppRoom[]>>;\n (topic: 'connection-refusal'): Promise<Observation<ConnectionRefusal | null>>;\n (topic: 'storage-loss'): Promise<Observation<string | null>>;\n (topic: 'sync-status'): Promise<Observation<SyncStatus>>;\n (topic: 'query', query: DocumentQuery): Promise<Observation<DocumentResult>>;\n (topic: 'query', query: GroupQuery): Promise<Observation<GroupResult>>;\n (topic: 'queue', locator: string): Promise<Observation<readonly QueueEntry[]>>;\n (topic: 'room-drafts'): Promise<Observation<readonly RoomDraft[]>>;\n (topic: 'presentation'): Promise<Observation<unknown>>;\n (\n topic: 'conversation',\n conversation: string,\n options: ConversationOptions,\n ): Promise<Observation<ConversationView>>;\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: string | null = null;\n const calls = new Map<\n number,\n { settle: (value: unknown) => void; fail: (error: Error) => void }\n >();\n const opening = new Map<\n number,\n {\n topic: WireTopic;\n settle: (observation: Observation<unknown>) => void;\n fail: (error: Error) => void;\n }\n >();\n const observations = new Map<number, { topic: WireTopic; handle: Observed }>();\n\n const send = (message: WireRequest) => {\n port.postMessage(envelope(message));\n };\n\n function begin(id: number, topic: WireTopic, first: unknown): Observation<unknown> {\n const handle = observed(\n first,\n () => {\n observations.delete(id);\n if (refusal === null) send({ kind: 'stop', id });\n },\n topic === 'query',\n );\n observations.set(id, { topic, handle });\n return handle.observation;\n }\n\n function refuse(reported: ConnectionRefusal) {\n refusal = reported;\n for (const { topic, handle } of observations.values()) {\n if (topic === 'connection-refusal') handle.receive(reported);\n }\n const failure = new Error(reported.reason);\n for (const [id, waiting] of opening) {\n if (waiting.topic === 'connection-refusal')\n waiting.settle(begin(id, waiting.topic, reported));\n else waiting.fail(failure);\n }\n opening.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n }\n\n function end(reason: string) {\n if (ended !== null) return;\n ended = reason;\n const failure = new Error(reason);\n for (const waiting of opening.values()) waiting.fail(failure);\n opening.clear();\n for (const waiting of calls.values()) waiting.fail(failure);\n calls.clear();\n for (const { handle } of observations.values()) handle.end();\n observations.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(AUTHORIZATION_ENDED);\n return;\n }\n if (message.kind === 'event') {\n observations.get(message.id)?.handle.receive(message.value);\n return;\n }\n const waiting = opening.get(message.id);\n if (waiting !== undefined) {\n opening.delete(message.id);\n if (message.kind === 'failure') waiting.fail(new Error(message.message));\n else waiting.settle(begin(message.id, waiting.topic, message.value));\n return;\n }\n const called = calls.get(message.id);\n if (called === undefined) return;\n calls.delete(message.id);\n if (message.kind === 'failure') called.fail(new Error(message.message));\n else called.settle(message.value);\n });\n port.addEventListener('close', () => {\n end(PORT_CLOSED);\n });\n port.start();\n send({ kind: 'hello' });\n\n function ask<T>(member: WireMember, input: readonly unknown[]): Promise<T> {\n if (ended !== null) return Promise.reject(new Error(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(topic: WireTopic, input: readonly unknown[]): Promise<Observation<unknown>> {\n if (ended !== null) return Promise.reject(new Error(ended));\n const id = (sequence += 1);\n if (refusal !== null) {\n return topic === 'connection-refusal'\n ? Promise.resolve(begin(id, topic, refusal))\n : Promise.reject(new Error(refusal.reason));\n }\n return new Promise((settle, fail) => {\n opening.set(id, { topic, settle, fail });\n send({ kind: 'observe', id, topic, input });\n });\n }\n\n return {\n rooms: () => ask<readonly AppRoom[]>('rooms', []),\n slots: () => ask<readonly AppSlot[]>('slots', []),\n query: ((query: DocumentQuery | GroupQuery) =>\n ask('query', [query])) as MdRuntimeClient['query'],\n search: (request: SearchRequest) => ask<SearchResult>('search', [request]),\n types: (locator: string) => ask<RoomTypes>('types', [locator]),\n syncStatus: () => ask<SyncStatus>('syncStatus', []),\n roomDraft: {\n list: () => ask<readonly RoomDraft[]>('roomDraft.list', []),\n read: (room: string, path: string) => ask<RoomDraft | null>('roomDraft.read', [room, path]),\n write: (room: string, path: string, revision: string | null, parts: RoomDraftParts) =>\n ask<RoomDraftWrite>('roomDraft.write', [room, path, revision, parts]),\n discard: (room: string, path: string, revision: string) =>\n ask<RoomDraftWrite>('roomDraft.discard', [room, path, revision]),\n },\n save: (room: string, roomDrafts: readonly SavedRoomDraft[]) =>\n ask<SaveResult>('save', [room, roomDrafts]),\n outcome: (identifier: string) => ask<SubmissionOutcome | null>('outcome', [identifier]),\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, options?: ConversationOptions) =>\n ask<ConversationView>('conversation.read', [conversation, options]),\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 chatDraft: {\n write: (conversation: string, draft: ChatDraft) =>\n ask<void>('chatDraft.write', [conversation, draft]),\n discard: (conversation: string) => ask<void>('chatDraft.discard', [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 deploymentFacts: () => ask<unknown>('deploymentFacts', []),\n observe: ((topic: WireTopic, ...input: unknown[]) =>\n watch(topic, input)) as MdRuntimeClient['observe'],\n reauthorize: () => ask<void>('reauthorize', []),\n };\n}\n\nexport type { Observation } from './observation.js';\nexport type { RuntimePort } from './wire.js';\n"],"names":["observed","answer","AUTHORIZATION_ENDED","carried","envelope","PORT_CLOSED","PROTOCOL_MISMATCH","connectMdRuntime","port","sequence","refusal","ended","calls","Map","opening","observations","send","message","postMessage","begin","id","topic","first","handle","delete","kind","set","observation","refuse","reported","values","receive","failure","Error","reason","waiting","settle","fail","clear","end","addEventListener","event","wire","data","matching","get","value","undefined","called","start","ask","member","input","Promise","reject","watch","resolve","rooms","slots","query","search","request","types","locator","syncStatus","roomDraft","list","read","room","path","write","revision","parts","discard","save","roomDrafts","outcome","identifier","presentation","conversation","options","create","interrupt","kill","cancel","turn","chatDraft","draft","history","call","name","log","storageLoss","persistence","deploymentFacts","observe","reauthorize"],"mappings":"AAgBA,SAASA,QAAQ,QAAyC,mBAAmB;AAM7E,SACEC,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,iBAAiB,QAKZ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C7BnC,IAAgB,uBAAuB;oBAAC6B;oBAAcM;iBAAK;YAC7D7D,QAAQ,CAACuD,eAAyB7B,IAAgB,uBAAuB;oBAAC6B;iBAAa;QACzF;QACAO,WAAW;YACThB,OAAO,CAACS,cAAsBQ,QAC5BrC,IAAU,mBAAmB;oBAAC6B;oBAAcQ;iBAAM;YACpDd,SAAS,CAACM,eAAyB7B,IAAU,qBAAqB;oBAAC6B;iBAAa;QAClF;QACAS,SAAS,CAACzB,SAAiBM,MAAcV,QACvCT,IAAmB,WAAW;gBAACa;gBAASM;gBAAMV;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,iBAAiB,IAAM5C,IAAa,mBAAmB,EAAE;QACzD6C,SAAU,CAAC1E,OAAkB,GAAG+B,QAC9BG,MAAMlC,OAAO+B;QACf4C,aAAa,IAAM9C,IAAU,eAAe,EAAE;IAChD;AACF"}
@@ -1,18 +1,28 @@
1
- import { type Document } from '@agentshouse/mdmodel';
2
- import type { Selector } from '@agentshouse/query';
1
+ import { type Document, type Validation } from '@agentshouse/mdmodel';
2
+ import type { ModelState } from './model.js';
3
3
  import type { MdModelIdentity } from './adapter.js';
4
4
  export declare const MD_MODEL: MdModelIdentity;
5
- export declare const PRESENTED: Selector;
6
- export type MdType = {
7
- name: string;
8
- path: string;
9
- fields: Readonly<Record<string, unknown>>;
10
- sections: Readonly<Record<string, unknown>>;
11
- };
12
5
  export type Collection = {
13
6
  documents: Readonly<Record<string, Document>>;
14
- types: readonly MdType[];
7
+ composition: Composition;
8
+ };
9
+ export type Composition = {
10
+ collectionRoot: string;
11
+ model: ModelState;
12
+ selection: {
13
+ roots: readonly string[];
14
+ model: ModelState;
15
+ } | null;
15
16
  };
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;
17
+ export declare function governing(composition: Composition, path: string): ModelState;
18
+ export declare function parseCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: {
19
+ text: Readonly<Record<string, string>>;
20
+ collection: Collection;
21
+ }): Collection;
22
+ export declare function readCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: {
23
+ text: Readonly<Record<string, string>>;
24
+ collection: Collection;
25
+ }): Collection | null;
26
+ export declare function validRoot(root: unknown): root is string;
27
+ export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition): Validation;
18
28
  //# sourceMappingURL=collection.d.ts.map
@@ -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;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAKpD,eAAO,MAAM,QAAQ,EAAE,eAAwE,CAAC;AAEhG,eAAO,MAAM,SAAS,EAAE,QAAyC,CAAC;AAElE,MAAM,MAAM,MAAM,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1C,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9C,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B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