@agentshouse/mdruntime 0.1.0-alpha.2 → 0.1.0-alpha.21

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 (110) hide show
  1. package/AGENTS.md +87 -0
  2. package/dist/adapter.d.ts +145 -28
  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 +11 -13
  7. package/dist/bootstrap.d.ts.map +1 -1
  8. package/dist/bootstrap.js +25 -24
  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 +74 -0
  13. package/dist/change-set.js.map +1 -0
  14. package/dist/change.d.ts +70 -0
  15. package/dist/change.d.ts.map +1 -0
  16. package/dist/change.js +12 -0
  17. package/dist/change.js.map +1 -0
  18. package/dist/client.d.ts +66 -0
  19. package/dist/client.d.ts.map +1 -0
  20. package/dist/client.js +229 -0
  21. package/dist/client.js.map +1 -0
  22. package/dist/collection.d.ts +25 -3
  23. package/dist/collection.d.ts.map +1 -1
  24. package/dist/collection.js +97 -25
  25. package/dist/collection.js.map +1 -1
  26. package/dist/connection.d.ts +87 -5
  27. package/dist/connection.d.ts.map +1 -1
  28. package/dist/connection.js +1653 -70
  29. package/dist/connection.js.map +1 -1
  30. package/dist/conversation.d.ts +57 -0
  31. package/dist/conversation.d.ts.map +1 -0
  32. package/dist/conversation.js +404 -0
  33. package/dist/conversation.js.map +1 -0
  34. package/dist/durability.d.ts +9 -0
  35. package/dist/durability.d.ts.map +1 -0
  36. package/dist/durability.js +11 -0
  37. package/dist/durability.js.map +1 -0
  38. package/dist/file.d.ts +20 -0
  39. package/dist/file.d.ts.map +1 -0
  40. package/dist/file.js +149 -0
  41. package/dist/file.js.map +1 -0
  42. package/dist/host.d.ts +13 -0
  43. package/dist/host.d.ts.map +1 -0
  44. package/dist/host.js +229 -0
  45. package/dist/host.js.map +1 -0
  46. package/dist/identity.d.ts +2 -0
  47. package/dist/identity.d.ts.map +1 -0
  48. package/dist/identity.js +16 -0
  49. package/dist/identity.js.map +1 -0
  50. package/dist/index.d.ts +13 -2
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +1 -0
  53. package/dist/index.js.map +1 -1
  54. package/dist/log.d.ts +5 -0
  55. package/dist/log.d.ts.map +1 -0
  56. package/dist/log.js +15 -0
  57. package/dist/log.js.map +1 -0
  58. package/dist/memory.d.ts +17 -2
  59. package/dist/memory.d.ts.map +1 -1
  60. package/dist/memory.js +264 -21
  61. package/dist/memory.js.map +1 -1
  62. package/dist/model.d.ts +70 -0
  63. package/dist/model.d.ts.map +1 -0
  64. package/dist/model.js +28 -0
  65. package/dist/model.js.map +1 -0
  66. package/dist/outcome.d.ts +37 -0
  67. package/dist/outcome.d.ts.map +1 -0
  68. package/dist/outcome.js +23 -0
  69. package/dist/outcome.js.map +1 -0
  70. package/dist/overlay.d.ts +10 -0
  71. package/dist/overlay.d.ts.map +1 -0
  72. package/dist/overlay.js +245 -0
  73. package/dist/overlay.js.map +1 -0
  74. package/dist/paths.d.ts +6 -0
  75. package/dist/paths.d.ts.map +1 -0
  76. package/dist/paths.js +47 -0
  77. package/dist/paths.js.map +1 -0
  78. package/dist/query.d.ts +13 -0
  79. package/dist/query.d.ts.map +1 -0
  80. package/dist/query.js +18 -0
  81. package/dist/query.js.map +1 -0
  82. package/dist/refresh.d.ts +14 -0
  83. package/dist/refresh.d.ts.map +1 -0
  84. package/dist/refresh.js +65 -0
  85. package/dist/refresh.js.map +1 -0
  86. package/dist/replica.d.ts +33 -0
  87. package/dist/replica.d.ts.map +1 -0
  88. package/dist/replica.js +134 -0
  89. package/dist/replica.js.map +1 -0
  90. package/dist/save.d.ts +35 -0
  91. package/dist/save.d.ts.map +1 -0
  92. package/dist/save.js +561 -0
  93. package/dist/save.js.map +1 -0
  94. package/dist/status.d.ts +25 -0
  95. package/dist/status.d.ts.map +1 -0
  96. package/dist/status.js +32 -0
  97. package/dist/status.js.map +1 -0
  98. package/dist/store.d.ts +86 -4
  99. package/dist/store.d.ts.map +1 -1
  100. package/dist/store.js +394 -9
  101. package/dist/store.js.map +1 -1
  102. package/dist/transfer.d.ts +5 -0
  103. package/dist/transfer.d.ts.map +1 -0
  104. package/dist/transfer.js +5 -0
  105. package/dist/transfer.js.map +1 -0
  106. package/dist/wire.d.ts +63 -0
  107. package/dist/wire.d.ts.map +1 -0
  108. package/dist/wire.js +142 -0
  109. package/dist/wire.js.map +1 -0
  110. package/package.json +13 -4
@@ -0,0 +1,74 @@
1
+ import { beneath } from './paths.js';
2
+ function documentAt(replica, path) {
3
+ const content = replica?.visible.documents[path];
4
+ const document = replica?.visible.collection.documents[path];
5
+ if (content === undefined || document === undefined) return null;
6
+ return {
7
+ content,
8
+ revision: replica?.visible.revisions[path] ?? null,
9
+ document
10
+ };
11
+ }
12
+ function modelShape(model) {
13
+ return model.status === 'unavailable' ? 'unavailable' : JSON.stringify(model.types);
14
+ }
15
+ export function changeSet(locator, before, after, changed = {}) {
16
+ const paths = new Set([
17
+ ...Object.keys(before?.visible.documents ?? {}),
18
+ ...Object.keys(after?.visible.documents ?? {})
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 prior = documentAt(before, path);
27
+ const next = documentAt(after, path);
28
+ const selected = newRoom?.typedSelection?.roots.some((root)=>beneath(root, path)) ?? false;
29
+ const inCollection = newRoom !== undefined && (newRoom.collectionRoot === '' || beneath(newRoom.collectionRoot, path));
30
+ const retyped = selected ? selectionChanged : inCollection && collectionChanged;
31
+ if (prior?.content === next?.content && prior?.revision === next?.revision && !retyped) continue;
32
+ documents.push({
33
+ locator,
34
+ path,
35
+ before: prior,
36
+ after: next
37
+ });
38
+ }
39
+ return {
40
+ documents,
41
+ drafts: (changed.drafts ?? []).map((path)=>({
42
+ locator,
43
+ path
44
+ })),
45
+ rooms: changed.room ? [
46
+ locator
47
+ ] : [],
48
+ queues: changed.queue ? [
49
+ locator
50
+ ] : [],
51
+ presentations: changed.presentation === undefined ? [] : [
52
+ changed.presentation
53
+ ],
54
+ query: changed.query ?? false
55
+ };
56
+ }
57
+ export function mergeChangeSets(sets) {
58
+ return {
59
+ documents: sets.flatMap((set)=>set.documents),
60
+ drafts: sets.flatMap((set)=>set.drafts),
61
+ rooms: [
62
+ ...new Set(sets.flatMap((set)=>set.rooms))
63
+ ],
64
+ queues: [
65
+ ...new Set(sets.flatMap((set)=>set.queues))
66
+ ],
67
+ presentations: [
68
+ ...new Set(sets.flatMap((set)=>set.presentations))
69
+ ],
70
+ query: sets.some((set)=>set.query)
71
+ };
72
+ }
73
+
74
+ //# sourceMappingURL=change-set.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/workspace/packages/mdruntime/src/change-set.ts"],"sourcesContent":["import type { Document } from '@agentshouse/mdmodel';\nimport { beneath } from './paths.js';\nimport type { Replica } from './replica.js';\n\nexport type VisibleDocument = {\n content: string;\n revision: string | null;\n document: Document;\n};\n\nexport type DocumentChange = {\n locator: string;\n path: string;\n before: VisibleDocument | null;\n after: VisibleDocument | null;\n};\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 query: boolean;\n};\n\nfunction documentAt(replica: Replica | null, path: string): VisibleDocument | null {\n const content = replica?.visible.documents[path];\n const document = replica?.visible.collection.documents[path];\n if (content === undefined || document === undefined) return null;\n return { content, revision: replica?.visible.revisions[path] ?? null, document };\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 query?: boolean;\n } = {},\n): ChangeSet {\n const paths = new Set([\n ...Object.keys(before?.visible.documents ?? {}),\n ...Object.keys(after?.visible.documents ?? {}),\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 prior = documentAt(before, path);\n const next = documentAt(after, path);\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 (prior?.content === next?.content && prior?.revision === next?.revision && !retyped)\n continue;\n documents.push({ locator, path, before: prior, after: next });\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 query: changed.query ?? false,\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 query: sets.some((set) => set.query),\n };\n}\n"],"names":["beneath","documentAt","replica","path","content","visible","documents","document","collection","undefined","revision","revisions","modelShape","model","status","JSON","stringify","types","changeSet","locator","before","after","changed","paths","Set","Object","keys","oldRoom","confirmed","record","newRoom","collectionChanged","selectionChanged","selectionModel","prior","next","selected","typedSelection","roots","some","root","inCollection","collectionRoot","retyped","push","drafts","map","rooms","room","queues","queue","presentations","presentation","query","mergeChangeSets","sets","flatMap","set"],"mappings":"AACA,SAASA,OAAO,QAAQ,aAAa;AAyBrC,SAASC,WAAWC,OAAuB,EAAEC,IAAY;IACvD,MAAMC,UAAUF,SAASG,QAAQC,SAAS,CAACH,KAAK;IAChD,MAAMI,WAAWL,SAASG,QAAQG,WAAWF,SAAS,CAACH,KAAK;IAC5D,IAAIC,YAAYK,aAAaF,aAAaE,WAAW,OAAO;IAC5D,OAAO;QAAEL;QAASM,UAAUR,SAASG,QAAQM,SAAS,CAACR,KAAK,IAAI;QAAMI;IAAS;AACjF;AAEA,SAASK,WAAWC,KAA8C;IAChE,OAAOA,MAAMC,MAAM,KAAK,gBAAgB,gBAAgBC,KAAKC,SAAS,CAACH,MAAMI,KAAK;AACpF;AAEA,OAAO,SAASC,UACdC,OAAe,EACfC,MAAsB,EACtBC,KAAqB,EACrBC,UAMI,CAAC,CAAC;IAEN,MAAMC,QAAQ,IAAIC,IAAI;WACjBC,OAAOC,IAAI,CAACN,QAAQf,QAAQC,aAAa,CAAC;WAC1CmB,OAAOC,IAAI,CAACL,OAAOhB,QAAQC,aAAa,CAAC;KAC7C;IACD,MAAMA,YAA8B,EAAE;IACtC,MAAMqB,UAAUP,QAAQQ,UAAUC;IAClC,MAAMC,UAAUT,OAAOO,UAAUC;IACjC,MAAME,oBACJJ,YAAYlB,aACZqB,YAAYrB,aACZG,WAAWe,QAAQd,KAAK,MAAMD,WAAWkB,QAAQjB,KAAK;IACxD,MAAMmB,mBACJL,YAAYlB,aACZqB,YAAYrB,aACZG,WAAWe,QAAQM,cAAc,MAAMrB,WAAWkB,QAAQG,cAAc;IAC1E,KAAK,MAAM9B,QAAQoB,MAAO;QACxB,MAAMW,QAAQjC,WAAWmB,Q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AM;SAAG;QACvDE,eAAe;eAAI,IAAI3B,IAAI+B,KAAKC,OAAO,CAAC,CAACC,MAAQA,IAAIN,aAAa;SAAG;QACrEE,OAAOE,KAAKhB,IAAI,CAAC,CAACkB,MAAQA,IAAIJ,KAAK;IACrC;AACF"}
@@ -0,0 +1,70 @@
1
+ export type Change = {
2
+ readonly kind: 'field';
3
+ readonly path: string;
4
+ readonly name: string;
5
+ readonly value: unknown;
6
+ } | {
7
+ readonly kind: 'section';
8
+ readonly path: string;
9
+ readonly name: string;
10
+ readonly value: string;
11
+ } | {
12
+ readonly kind: 'preamble';
13
+ readonly path: string;
14
+ readonly value: string;
15
+ } | {
16
+ readonly kind: 'create';
17
+ readonly path: string;
18
+ readonly fields: Readonly<Record<string, unknown>>;
19
+ readonly sections: Readonly<Record<string, string>>;
20
+ } | {
21
+ readonly kind: 'replace';
22
+ readonly path: string;
23
+ readonly content: string;
24
+ } | {
25
+ readonly kind: 'move';
26
+ readonly path: string;
27
+ readonly to: string;
28
+ } | {
29
+ readonly kind: 'remove';
30
+ readonly path: string;
31
+ };
32
+ export type Precondition = {
33
+ readonly kind: 'field';
34
+ readonly path: string;
35
+ readonly name: string;
36
+ readonly value: unknown;
37
+ } | {
38
+ readonly kind: 'section';
39
+ readonly path: string;
40
+ readonly name: string;
41
+ readonly value: string;
42
+ } | {
43
+ readonly kind: 'preamble';
44
+ readonly path: string;
45
+ readonly value: string;
46
+ } | {
47
+ readonly kind: 'revision';
48
+ readonly path: string;
49
+ readonly revision: string;
50
+ } | {
51
+ readonly kind: 'present';
52
+ readonly path: string;
53
+ } | {
54
+ readonly kind: 'absent';
55
+ readonly path: string;
56
+ };
57
+ export type WrittenBy = {
58
+ readonly app: string;
59
+ readonly release: string;
60
+ };
61
+ export type ChangeBatch = {
62
+ validation?: import('./model.js').ValidationReceipt;
63
+ readonly id: string;
64
+ readonly baseRoomVersion: string;
65
+ readonly changes: readonly Change[];
66
+ readonly preconditions: readonly Precondition[];
67
+ readonly writtenBy?: WrittenBy;
68
+ };
69
+ export declare function immutable(batch: ChangeBatch): ChangeBatch;
70
+ //# sourceMappingURL=change.d.ts.map
@@ -0,0 +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,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAA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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"}
package/dist/change.js ADDED
@@ -0,0 +1,12 @@
1
+ function frozen(value) {
2
+ if (Array.isArray(value)) return Object.freeze(value.map((item)=>frozen(item)));
3
+ if (value === null || typeof value !== 'object') return value;
4
+ const copy = {};
5
+ for (const [name, item] of Object.entries(value))copy[name] = frozen(item);
6
+ return Object.freeze(copy);
7
+ }
8
+ export function immutable(batch) {
9
+ return frozen(batch);
10
+ }
11
+
12
+ //# sourceMappingURL=change.js.map
@@ -0,0 +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 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":"AAqDA,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,66 @@
1
+ import type { QueryOptions, QueryResult } from '@agentshouse/query';
2
+ import type { Change } from './change.js';
3
+ import type { AppRoom, AppSlot, ConnectionRefusal, DraftEntry, HistoryQuery, RoomTypes, SaveResult } from './connection.js';
4
+ import type { HistoryResult } from './adapter.js';
5
+ import type { ConversationEntry, ConversationView, UnsentInstruction } from './conversation.js';
6
+ import type { CallResult, QueueEntry, SubmissionOutcome } from './outcome.js';
7
+ import type { SyncStatus } from './status.js';
8
+ import { type RuntimePort } from './wire.js';
9
+ export type MdRuntimeClient = {
10
+ rooms(): Promise<readonly AppRoom[]>;
11
+ slots(): Promise<readonly AppSlot[]>;
12
+ query(options?: QueryOptions): Promise<QueryResult>;
13
+ types(locator: string): Promise<RoomTypes>;
14
+ syncStatus(): Promise<SyncStatus>;
15
+ draft: {
16
+ list(): Promise<readonly DraftEntry[]>;
17
+ read(locator: string, path: string): Promise<unknown>;
18
+ replace(locator: string, path: string, content: unknown): Promise<void>;
19
+ discard(locator: string, path: string): Promise<void>;
20
+ };
21
+ save(locator: string, changes: readonly Change[], replacing?: string): Promise<SaveResult>;
22
+ outcome(identifier: string): Promise<SubmissionOutcome | null>;
23
+ queue: {
24
+ discard(locator: string, identifier: string): Promise<void>;
25
+ };
26
+ presentation: {
27
+ read(): Promise<unknown>;
28
+ write(value: unknown): Promise<void>;
29
+ };
30
+ conversation: {
31
+ list(): Promise<readonly ConversationEntry[]>;
32
+ read(conversation: string): Promise<ConversationView>;
33
+ older(conversation: string): Promise<CallResult | null>;
34
+ compose(conversation: string, instruction: UnsentInstruction): Promise<void>;
35
+ discard(conversation: string): Promise<void>;
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
+ history(locator: string, path: string, query?: HistoryQuery): Promise<HistoryResult>;
45
+ call(name: string, input: unknown): Promise<CallResult>;
46
+ log(): Promise<string>;
47
+ storageLoss(): Promise<string | null>;
48
+ persistence(): Promise<boolean>;
49
+ deploymentFacts(): Promise<unknown>;
50
+ observe: {
51
+ (topic: 'deployment-facts', listener: (value: unknown) => void): Promise<() => void>;
52
+ (topic: 'rooms', listener: (rooms: readonly AppRoom[]) => void): Promise<() => void>;
53
+ (topic: 'connection-refusal', listener: (refusal: ConnectionRefusal | null) => void): Promise<() => void>;
54
+ (topic: 'storage-loss', listener: (statement: string | null) => void): Promise<() => void>;
55
+ (topic: 'sync-status', listener: (status: SyncStatus) => void): Promise<() => void>;
56
+ (topic: 'query', query: QueryOptions, listener: (result: QueryResult) => void): Promise<() => void>;
57
+ (topic: 'queue', locator: string, listener: (entries: readonly QueueEntry[]) => void): Promise<() => void>;
58
+ (topic: 'drafts', listener: (drafts: readonly DraftEntry[]) => void): Promise<() => void>;
59
+ (topic: 'presentation', listener: (value: unknown) => void): Promise<() => void>;
60
+ (topic: 'conversation', conversation: string, listener: (view: ConversationView) => void): Promise<() => void>;
61
+ };
62
+ reauthorize(): Promise<void>;
63
+ };
64
+ export declare function connectMdRuntime(port: RuntimePort): MdRuntimeClient;
65
+ export type { RuntimePort } from './wire.js';
66
+ //# 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,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,UAAU,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAML,KAAK,WAAW,EAIjB,MAAM,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AAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,UAAU,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QAC1F,CAAC,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;QACjF,CACE,KAAK,EAAE,cAAc,EACrB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GACzC,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;KACxB,CAAC;IACF,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAwKnE;AAED,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,229 @@
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
+ slots: ()=>ask('slots', []),
123
+ query: (options)=>ask('query', [
124
+ options
125
+ ]),
126
+ types: (locator)=>ask('types', [
127
+ locator
128
+ ]),
129
+ syncStatus: ()=>ask('syncStatus', []),
130
+ draft: {
131
+ list: ()=>ask('draft.list', []),
132
+ read: (locator, path)=>ask('draft.read', [
133
+ locator,
134
+ path
135
+ ]),
136
+ replace: (locator, path, content)=>ask('draft.replace', [
137
+ locator,
138
+ path,
139
+ content
140
+ ]),
141
+ discard: (locator, path)=>ask('draft.discard', [
142
+ locator,
143
+ path
144
+ ])
145
+ },
146
+ save: (locator, changes, replacing)=>ask('save', [
147
+ locator,
148
+ changes,
149
+ replacing
150
+ ]),
151
+ outcome: (identifier)=>ask('outcome', [
152
+ identifier
153
+ ]),
154
+ queue: {
155
+ discard: (locator, identifier)=>ask('queue.discard', [
156
+ locator,
157
+ identifier
158
+ ])
159
+ },
160
+ presentation: {
161
+ read: ()=>ask('presentation.read', []),
162
+ write: (value)=>ask('presentation.write', [
163
+ value
164
+ ])
165
+ },
166
+ conversation: {
167
+ list: ()=>ask('conversation.list', []),
168
+ read: (conversation)=>ask('conversation.read', [
169
+ conversation
170
+ ]),
171
+ older: (conversation)=>ask('conversation.older', [
172
+ conversation
173
+ ]),
174
+ compose: (conversation, instruction)=>ask('conversation.compose', [
175
+ conversation,
176
+ instruction
177
+ ]),
178
+ discard: (conversation)=>ask('conversation.discard', [
179
+ conversation
180
+ ]),
181
+ create: (input)=>ask('conversation.create', [
182
+ input
183
+ ]),
184
+ send: (conversation)=>ask('conversation.send', [
185
+ conversation
186
+ ]),
187
+ answer: (conversation, answer)=>ask('conversation.answer', [
188
+ conversation,
189
+ answer
190
+ ]),
191
+ interrupt: (conversation)=>ask('conversation.interrupt', [
192
+ conversation
193
+ ]),
194
+ kill: (conversation)=>ask('conversation.kill', [
195
+ conversation
196
+ ]),
197
+ cancel: (conversation, turn)=>ask('conversation.cancel', [
198
+ conversation,
199
+ turn
200
+ ]),
201
+ delete: (conversation)=>ask('conversation.delete', [
202
+ conversation
203
+ ])
204
+ },
205
+ history: (locator, path, query)=>ask('history', [
206
+ locator,
207
+ path,
208
+ query
209
+ ]),
210
+ call: (name, input)=>ask('call', [
211
+ name,
212
+ input
213
+ ]),
214
+ log: ()=>ask('log', []),
215
+ storageLoss: ()=>ask('storageLoss', []),
216
+ persistence: ()=>ask('persistence', []),
217
+ deploymentFacts: ()=>ask('deploymentFacts', []),
218
+ observe (topic, second, third) {
219
+ const positional = topic === 'query' || topic === 'queue' || topic === 'conversation';
220
+ const notify = positional ? third : second;
221
+ return watch(topic, positional ? [
222
+ second
223
+ ] : [], notify);
224
+ },
225
+ reauthorize: ()=>ask('reauthorize', [])
226
+ };
227
+ }
228
+
229
+ //# 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 AppSlot,\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 slots(): Promise<readonly AppSlot[]>;\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 deploymentFacts(): Promise<unknown>;\n observe: {\n (topic: 'deployment-facts', listener: (value: unknown) => void): Promise<() => void>;\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 slots: () => ask<readonly AppSlot[]>('slots', []),\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 deploymentFacts: () => ask<unknown>('deploymentFacts', []),\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","slots","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","deploymentFacts","observe","second","third","positional","reauthorize"],"mappings":"AAeA,SACEA,MAAM,EACNC,mBAAmB,EACnBC,OAAO,EACPC,QAAQ,EACRC,iBAAiB,QAKZ,YAAY;AAuEnB,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,SAASE,MAAM,CAACX;QAC/D;IACF;IAEA,SAASY;QACPrB,QAAQ;QACR,MAAMc,UAAU,IAAIC,MAAMvB;QAC1B,KAAK,MAAMkB,WAAWP,KAAKQ,MAAM,GAAID,QAAQO,IAAI,CAACH;QAClDX,KAAKU,KAAK;QACV,KAAK,MAAMH,WAAWT,MAAMU,MAAM,GAAID,QAAQO,IAAI,CAACH;QACnDb,MAAMY,KAAK;QACXT,UAAUS,KAAK;IACjB;IAEAhB,KAAKyB,gBAAgB,CAAC,WAAW,CAACC;QAChC,MAAMC,OAAO/B,QAAQ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sBQ,OAC7BtC,IAAgB,uBAAuB;oBAAC8B;oBAAcQ;iBAAK;YAC7DxC,QAAQ,CAACgC,eAAyB9B,IAAgB,uBAAuB;oBAAC8B;iBAAa;QACzF;QACAS,SAAS,CAAC1B,SAAiBK,MAAcR,QACvCV,IAAmB,WAAW;gBAACa;gBAASK;gBAAMR;aAAM;QACtD8B,MAAM,CAACC,MAAcvC,QAAmBF,IAAgB,QAAQ;gBAACyC;gBAAMvC;aAAM;QAC7EwC,KAAK,IAAM1C,IAAY,OAAO,EAAE;QAChC2C,aAAa,IAAM3C,IAAmB,eAAe,EAAE;QACvD4C,aAAa,IAAM5C,IAAa,eAAe,EAAE;QACjD6C,iBAAiB,IAAM7C,IAAa,mBAAmB,EAAE;QACzD8C,SACE9D,KAAgB,EAChB+D,MAAwD,EACxDC,KAA8B;YAE9B,MAAMC,aAAajE,UAAU,WAAWA,UAAU,WAAWA,UAAU;YACvE,MAAMC,SAAUgE,aAAaD,QAAQD;YACrC,OAAOzC,MAAMtB,OAAOiE,aAAa;gBAACF;aAAO,GAAG,EAAE,EAAE9D;QAClD;QACAiE,aAAa,IAAMlD,IAAU,eAAe,EAAE;IAChD;AACF"}
@@ -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,7 +12,28 @@ export type MdType = {
11
12
  };
12
13
  export type Collection = {
13
14
  documents: Readonly<Record<string, Document>>;
14
- types: readonly MdType[];
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, previous?: {
28
+ text: Readonly<Record<string, string>>;
29
+ collection: Collection;
30
+ }): Collection;
31
+ export declare function readCollection(text: Readonly<Record<string, string>>, composition: Composition, previous?: {
32
+ text: Readonly<Record<string, string>>;
33
+ collection: Collection;
34
+ }): Collection | null;
35
+ export declare function validRoot(root: unknown): root is string;
36
+ export declare function validateCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[], composition: Composition, binding: AttachedModelBinding | null): Validation & {
37
+ source?: 'content' | 'model';
15
38
  };
16
- export declare function readCollection(text: Readonly<Record<string, string>>, binaryTargets: readonly string[]): Collection | null;
17
39
  //# 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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