@agentshouse/mdruntime 0.1.0-cdf6e063566ab → 0.1.0-cdf8ca5c0fa11

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 (192) hide show
  1. package/README.md +1 -1
  2. package/dist/acceptance.d.ts.map +1 -1
  3. package/dist/acceptance.js +30 -1
  4. package/dist/actions.d.ts.map +1 -1
  5. package/dist/actions.js +35 -7
  6. package/dist/adapter.d.ts +71 -16
  7. package/dist/adapter.d.ts.map +1 -1
  8. package/dist/attached-model.d.ts.map +1 -1
  9. package/dist/attached-model.js +2 -2
  10. package/dist/{binary.d.ts → attachment.d.ts} +8 -4
  11. package/dist/attachment.d.ts.map +1 -0
  12. package/dist/attachment.js +15 -0
  13. package/dist/authored.d.ts.map +1 -1
  14. package/dist/authored.js +2 -0
  15. package/dist/chain.d.ts +1 -1
  16. package/dist/chain.d.ts.map +1 -1
  17. package/dist/chain.js +5 -2
  18. package/dist/change.d.ts +2 -2
  19. package/dist/chat-types.js +2 -2
  20. package/dist/client.d.ts +11 -6
  21. package/dist/client.d.ts.map +1 -1
  22. package/dist/client.js +16 -15
  23. package/dist/collection.d.ts +1 -0
  24. package/dist/collection.d.ts.map +1 -1
  25. package/dist/collection.js +7 -1
  26. package/dist/compile.d.ts +2 -1
  27. package/dist/compile.d.ts.map +1 -1
  28. package/dist/compile.js +71 -39
  29. package/dist/connection.d.ts +1 -1
  30. package/dist/connection.d.ts.map +1 -1
  31. package/dist/connection.js +5 -3
  32. package/dist/conversation-live.d.ts +2 -3
  33. package/dist/conversation-live.d.ts.map +1 -1
  34. package/dist/conversation-live.js +2 -2
  35. package/dist/conversation.d.ts +13 -7
  36. package/dist/conversation.d.ts.map +1 -1
  37. package/dist/conversation.js +35 -20
  38. package/dist/declaration.js +3 -3
  39. package/dist/discovery.d.ts +1 -1
  40. package/dist/discovery.d.ts.map +1 -1
  41. package/dist/discovery.js +21 -3
  42. package/dist/download.d.ts +2 -2
  43. package/dist/download.d.ts.map +1 -1
  44. package/dist/entry.d.ts +22 -3
  45. package/dist/entry.d.ts.map +1 -1
  46. package/dist/entry.js +111 -45
  47. package/dist/figures.d.ts +1 -1
  48. package/dist/figures.d.ts.map +1 -1
  49. package/dist/figures.js +2 -2
  50. package/dist/host.d.ts +6 -2
  51. package/dist/host.d.ts.map +1 -1
  52. package/dist/host.js +51 -21
  53. package/dist/house-query.d.ts +24 -0
  54. package/dist/house-query.d.ts.map +1 -0
  55. package/dist/house-query.js +102 -0
  56. package/dist/identity.d.ts +1 -1
  57. package/dist/identity.d.ts.map +1 -1
  58. package/dist/identity.js +1 -1
  59. package/dist/index.d.ts +16 -10
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +9 -5
  62. package/dist/lifecycle.d.ts +1 -1
  63. package/dist/lifecycle.d.ts.map +1 -1
  64. package/dist/lifecycle.js +21 -13
  65. package/dist/listing.d.ts +1 -0
  66. package/dist/listing.d.ts.map +1 -1
  67. package/dist/live.d.ts +14 -0
  68. package/dist/live.d.ts.map +1 -1
  69. package/dist/live.js +29 -12
  70. package/dist/loaded.d.ts +5 -3
  71. package/dist/loaded.d.ts.map +1 -1
  72. package/dist/loaded.js +12 -6
  73. package/dist/locks.d.ts.map +1 -1
  74. package/dist/locks.js +2 -0
  75. package/dist/media.d.ts +5 -6
  76. package/dist/media.d.ts.map +1 -1
  77. package/dist/media.js +94 -25
  78. package/dist/memory.d.ts +2 -2
  79. package/dist/memory.js +9 -9
  80. package/dist/messages.d.ts +6 -1
  81. package/dist/messages.d.ts.map +1 -1
  82. package/dist/messages.js +10 -1
  83. package/dist/model.d.ts +6 -5
  84. package/dist/model.d.ts.map +1 -1
  85. package/dist/name.d.ts +0 -1
  86. package/dist/name.d.ts.map +1 -1
  87. package/dist/name.js +3 -7
  88. package/dist/online.d.ts +7 -0
  89. package/dist/online.d.ts.map +1 -0
  90. package/dist/online.js +29 -0
  91. package/dist/opened.d.ts +5 -5
  92. package/dist/opened.d.ts.map +1 -1
  93. package/dist/opened.js +2 -2
  94. package/dist/opening.d.ts.map +1 -1
  95. package/dist/opening.js +18 -2
  96. package/dist/outcome.d.ts +21 -13
  97. package/dist/outcome.d.ts.map +1 -1
  98. package/dist/outcome.js +5 -5
  99. package/dist/overlay.d.ts +19 -8
  100. package/dist/overlay.d.ts.map +1 -1
  101. package/dist/overlay.js +108 -37
  102. package/dist/parts.d.ts +3 -1
  103. package/dist/parts.d.ts.map +1 -1
  104. package/dist/parts.js +30 -7
  105. package/dist/paths.d.ts +1 -1
  106. package/dist/paths.js +1 -1
  107. package/dist/preparation.d.ts +10 -5
  108. package/dist/preparation.d.ts.map +1 -1
  109. package/dist/preparation.js +78 -48
  110. package/dist/queries.d.ts.map +1 -1
  111. package/dist/queries.js +75 -53
  112. package/dist/query.d.ts +2 -2
  113. package/dist/query.d.ts.map +1 -1
  114. package/dist/questions.d.ts.map +1 -1
  115. package/dist/questions.js +2 -1
  116. package/dist/reach.d.ts +11 -1
  117. package/dist/reach.d.ts.map +1 -1
  118. package/dist/reach.js +97 -23
  119. package/dist/readiness.d.ts +17 -4
  120. package/dist/readiness.d.ts.map +1 -1
  121. package/dist/readiness.js +17 -7
  122. package/dist/reads.d.ts.map +1 -1
  123. package/dist/reads.js +15 -4
  124. package/dist/reference-forms.d.ts +4 -0
  125. package/dist/reference-forms.d.ts.map +1 -0
  126. package/dist/reference-forms.js +74 -0
  127. package/dist/refresh.d.ts +1 -1
  128. package/dist/refresh.js +4 -4
  129. package/dist/replica.d.ts +3 -8
  130. package/dist/replica.d.ts.map +1 -1
  131. package/dist/replica.js +3 -3
  132. package/dist/room-draft.d.ts +1 -1
  133. package/dist/room-draft.d.ts.map +1 -1
  134. package/dist/room-draft.js +9 -6
  135. package/dist/room-drafts.d.ts.map +1 -1
  136. package/dist/room-drafts.js +8 -6
  137. package/dist/rows.d.ts +9 -1
  138. package/dist/rows.d.ts.map +1 -1
  139. package/dist/rows.js +18 -4
  140. package/dist/running.d.ts +5 -0
  141. package/dist/running.d.ts.map +1 -0
  142. package/dist/running.js +10 -0
  143. package/dist/runtime.d.ts +4 -2
  144. package/dist/runtime.d.ts.map +1 -1
  145. package/dist/save.d.ts +1 -0
  146. package/dist/save.d.ts.map +1 -1
  147. package/dist/save.js +6 -6
  148. package/dist/saves.d.ts +5 -5
  149. package/dist/saves.d.ts.map +1 -1
  150. package/dist/saves.js +71 -45
  151. package/dist/selector.d.ts +3 -0
  152. package/dist/selector.d.ts.map +1 -0
  153. package/dist/selector.js +22 -0
  154. package/dist/shown.d.ts.map +1 -1
  155. package/dist/shown.js +17 -4
  156. package/dist/socket/session.d.ts +4 -1
  157. package/dist/socket/session.d.ts.map +1 -1
  158. package/dist/socket/session.js +3 -0
  159. package/dist/socket.d.ts +1 -0
  160. package/dist/socket.d.ts.map +1 -1
  161. package/dist/socket.js +1 -0
  162. package/dist/source.d.ts +2 -0
  163. package/dist/source.d.ts.map +1 -1
  164. package/dist/source.js +2 -0
  165. package/dist/store/records.d.ts +15 -5
  166. package/dist/store/records.d.ts.map +1 -1
  167. package/dist/store/records.js +12 -4
  168. package/dist/store.d.ts +3 -2
  169. package/dist/store.d.ts.map +1 -1
  170. package/dist/store.js +4 -1
  171. package/dist/stored.d.ts +17 -3
  172. package/dist/stored.d.ts.map +1 -1
  173. package/dist/stored.js +138 -31
  174. package/dist/surface.d.ts +4 -2
  175. package/dist/surface.d.ts.map +1 -1
  176. package/dist/surface.js +7 -3
  177. package/dist/sync.d.ts +2 -1
  178. package/dist/sync.d.ts.map +1 -1
  179. package/dist/sync.js +26 -18
  180. package/dist/tables.d.ts +14 -2
  181. package/dist/tables.d.ts.map +1 -1
  182. package/dist/tables.js +10 -3
  183. package/dist/tallies.js +2 -2
  184. package/dist/validation.d.ts +2 -0
  185. package/dist/validation.d.ts.map +1 -1
  186. package/dist/validation.js +49 -3
  187. package/dist/wire.d.ts +14 -6
  188. package/dist/wire.d.ts.map +1 -1
  189. package/dist/wire.js +12 -11
  190. package/package.json +4 -4
  191. package/dist/binary.d.ts.map +0 -1
  192. package/dist/binary.js +0 -8
@@ -4,7 +4,7 @@ import { type ChangeSet } from './change-set.js';
4
4
  import { type LiveConversations } from './conversation-live.js';
5
5
  import { type ConversationHeld } from './conversation-row.js';
6
6
  import type { Open } from './open.js';
7
- import { type BinaryLinkAnswer, type CallResult, type ConversationAttachAnswer, type Offline } from './outcome.js';
7
+ import { type AttachmentLinkAnswer, type CallResult, type ConversationAttachAnswer, type Offline } from './outcome.js';
8
8
  import type { ChatRequest } from './source.js';
9
9
  import type { CycleProgress } from './status.js';
10
10
  import type { RuntimeStore } from './store.js';
@@ -18,15 +18,19 @@ export type ConversationEntry = ConversationHeld & {
18
18
  };
19
19
  name: string;
20
20
  created: string;
21
- finished: string | null;
22
21
  outcome: string | null;
23
22
  waiting: boolean;
24
23
  subject: string | null;
24
+ room: string | null;
25
+ model: string | null;
26
+ effort: string | null;
25
27
  state: ConversationState;
26
28
  started: string | null;
27
29
  line: string | null;
28
30
  question: string | null;
29
31
  asked: string | null;
32
+ jobs: SessionState['running'];
33
+ deliveryWaiting: readonly string[];
30
34
  };
31
35
  export type ConversationAgent = {
32
36
  identity: string;
@@ -34,6 +38,7 @@ export type ConversationAgent = {
34
38
  cli: string;
35
39
  model: string | null;
36
40
  effort: string | null;
41
+ model_fixed: boolean;
37
42
  environment: AgentEnvironment;
38
43
  };
39
44
  export type RunningTurn = {
@@ -67,9 +72,6 @@ export type ConversationView = {
67
72
  options: readonly SessionOption[];
68
73
  starting: string | null;
69
74
  state: SessionState | null;
70
- link: {
71
- connected: boolean;
72
- } | null;
73
75
  deliveryWaiting: readonly string[];
74
76
  deliveryUnknown: readonly string[];
75
77
  chatDraft: (ChatDraft & {
@@ -91,19 +93,23 @@ export type ConversationSurface = {
91
93
  takeOut(conversation: string, message: string, operation: string): Promise<CallResult>;
92
94
  decide(request: ChatRequest, decision: RequestDecision, operation: string): Promise<CallResult>;
93
95
  rename(conversation: string, name: string, operation: string): Promise<CallResult>;
94
- option(conversation: string, option: string, value: string | boolean, operation: string): Promise<CallResult>;
96
+ set(conversation: string, settings: ConversationSettings, operation: string): Promise<CallResult>;
95
97
  retry(conversation: string, message: string, operation: string): Promise<CallResult>;
96
98
  pin(figures: readonly string[]): Promise<void>;
97
99
  openTurn(conversation: string, turn: string): Promise<void>;
98
100
  dismissSuggestion(conversation: string, suggestion: string): Promise<void>;
99
101
  attach(file: File): Promise<ConversationAttachAnswer>;
100
- attachment(link: string): Promise<BinaryLinkAnswer>;
102
+ attachment(link: string): Promise<AttachmentLinkAnswer>;
101
103
  };
102
104
  export type ConversationFiles = Pick<ConversationSurface, 'attach' | 'attachment'>;
103
105
  export type ConversationAnswer = {
104
106
  interaction_id: string;
105
107
  response: unknown;
106
108
  };
109
+ export type ConversationSettings = {
110
+ readonly model?: string;
111
+ readonly effort?: string;
112
+ };
107
113
  export type ChatDraftSurface = {
108
114
  write(conversation: string, draft: ChatDraft, revision?: string): Promise<void>;
109
115
  prepend(conversation: string, draft: ChatDraft): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../src/conversation.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,IAAI,EACT,KAAK,YAAY,EAClB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAEV,gBAAgB,EAEhB,iBAAiB,EAEjB,mBAAmB,EACnB,WAAW,EAEX,cAAc,EACd,aAAa,EAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAKL,KAAK,iBAAiB,EAEvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B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AAE,iBAAiB,EACxB,OAAO,EAAE,CAAC,OAAO,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GACvD,MAAM,IAAI,CAIZ;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,KAAK,IAAI,GACtD,MAAM,IAAI,CAIZ;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,KAAK,IAAI,GAChD,MAAM,IAAI,CAIZ;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,CAEnF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAgCjG"}
@@ -25,7 +25,6 @@ export function unheldView(conversation) {
25
25
  options: [],
26
26
  starting: null,
27
27
  state: null,
28
- link: null,
29
28
  deliveryWaiting: [],
30
29
  deliveryUnknown: [],
31
30
  chatDraft: null,
@@ -228,7 +227,6 @@ function viewOf(alive, conversation, held, frame, { draft, ended, dismissed, pin
228
227
  options: structuredClone(facts.options),
229
228
  starting: facts.starting,
230
229
  state: sessionOf(facts, held, ended),
231
- link: facts.link === null ? null : { ...facts.link },
232
230
  deliveryWaiting: [...facts.deliveryWaiting],
233
231
  deliveryUnknown: [...facts.deliveryUnknown],
234
232
  chatDraft: draft === null || unwritten(draft) ? null : { text: draft.text, revision: draft.revision },
@@ -236,18 +234,23 @@ function viewOf(alive, conversation, held, frame, { draft, ended, dismissed, pin
236
234
  pins: [...pins],
237
235
  };
238
236
  }
239
- function sessionOf(facts, held, ended) {
237
+ function standing(facts, saved, ended) {
240
238
  if (facts.state !== null)
241
239
  return structuredClone(facts.state);
240
+ if (saved === null)
241
+ return null;
242
+ const down = facts.process?.running === false;
243
+ return structuredClone(standingState(saved.state, saved.at, down ? saved.at : ended));
244
+ }
245
+ function sessionOf(facts, held, ended) {
242
246
  const saved = [...held]
243
247
  .reverse()
244
248
  .map(({ message }) => record(message))
245
249
  .find(({ content }) => isTurn(content));
246
250
  const at = saved === undefined ? null : text(saved, 'accepted_at');
247
- if (saved === undefined || !isTurn(saved.content) || at === null)
248
- return null;
249
- const down = facts.process?.running === false;
250
- return structuredClone(standingState(saved.content.state, at, down ? at : ended));
251
+ return standing(facts, saved === undefined || !isTurn(saved.content) || at === null
252
+ ? null
253
+ : { state: saved.content.state, at }, ended);
251
254
  }
252
255
  function emit(alive, conversation) {
253
256
  if (alive.deps.closed())
@@ -297,13 +300,14 @@ function stateOf(alive, conversation) {
297
300
  return facts.turn === null ? 'idle' : 'working';
298
301
  }
299
302
  function rowOf(alive, conversation) {
300
- const { turn, questions } = alive.liveOf(conversation);
303
+ const { turn, questions, deliveryWaiting } = alive.liveOf(conversation);
301
304
  return {
302
305
  state: stateOf(alive, conversation),
303
306
  started: turn?.started ?? null,
304
307
  line: turn === null ? null : runningLine(turn.parts),
305
308
  question: openQuestion(questions),
306
309
  asked: questionAsked(questions),
310
+ deliveryWaiting: [...deliveryWaiting],
307
311
  };
308
312
  }
309
313
  async function entries(alive) {
@@ -325,12 +329,15 @@ async function entries(alive) {
325
329
  agent: { identity: agent.id, name: agent.name, retired: agent.retired_at !== null },
326
330
  name: entry.name,
327
331
  created: entry.created,
328
- finished: entry.finished,
329
332
  outcome: entry.outcome,
330
333
  waiting: entry.waiting,
331
334
  subject: entry.subject,
335
+ room: entry.room,
336
+ model: entry.model,
337
+ effort: entry.effort,
332
338
  ...rowOf(alive, entry.conversation),
333
339
  ...heldFacts(rows.get(entry.conversation), entry),
340
+ jobs: standing(alive.liveOf(entry.conversation), rows.get(entry.conversation)?.saved ?? null, entry.processEnded)?.running ?? [],
334
341
  };
335
342
  });
336
343
  }
@@ -356,7 +363,9 @@ function upserted(kept, set, key) {
356
363
  function listChanged(alive, change) {
357
364
  void alive.deps
358
365
  .durably(async (local) => {
359
- const { conversationList, agentList, conversationCursor } = await local.facts();
366
+ const { conversationList, agentList, conversationCursor, readUntil } = await local.facts();
367
+ if (readUntil === null)
368
+ await local.fact('readUntil', new Date().toISOString());
360
369
  const held = upserted(change.replacing ? [] : (conversationList ?? []), change.set, (entry) => entry.conversation);
361
370
  for (const entry of change.set)
362
371
  alive.created(entry.conversation);
@@ -390,7 +399,7 @@ function listChanged(alive, change) {
390
399
  const list = listing.conversations;
391
400
  endedAnew(alive, list);
392
401
  if (change.cursor !== undefined) {
393
- alive.held.set({ listKnown: true, openingListed: true });
402
+ alive.held.set({ listKnown: true, listHeld: true, openingListed: true });
394
403
  settleBehind(alive, list);
395
404
  openingEnded(alive);
396
405
  alive.deps.settled();
@@ -489,6 +498,7 @@ function agentsOf(listing) {
489
498
  cli: agent.cli,
490
499
  model: agent.model,
491
500
  effort: agent.effort,
501
+ model_fixed: agent.model_fixed,
492
502
  environment: {
493
503
  identity: agent.environment,
494
504
  name: agent.environment_name,
@@ -517,11 +527,18 @@ function emitAgents(alive) {
517
527
  }
518
528
  });
519
529
  }
530
+ function ran({ state, process }) {
531
+ return JSON.stringify([state?.running ?? null, process?.running ?? null]);
532
+ }
520
533
  function setLive(alive, conversation, next) {
534
+ const was = ran(alive.liveOf(conversation));
521
535
  const before = rowOf(alive, conversation);
522
536
  alive.holdLive(conversation, next);
523
537
  const after = rowOf(alive, conversation);
524
- if (after.state !== before.state || after.started !== before.started)
538
+ if (after.state !== before.state ||
539
+ after.started !== before.started ||
540
+ ran(alive.liveOf(conversation)) !== was ||
541
+ after.deliveryWaiting.join() !== before.deliveryWaiting.join())
525
542
  emitList(alive);
526
543
  else if (after.line !== before.line ||
527
544
  after.question !== before.question ||
@@ -552,7 +569,6 @@ function openingEnded(alive) {
552
569
  options: facts.has('options') ? QUIET.options : held.options,
553
570
  starting: facts.has('starting') ? QUIET.starting : held.starting,
554
571
  state: facts.has('state') ? QUIET.state : held.state,
555
- link: facts.has('link') ? QUIET.link : held.link,
556
572
  deliveryWaiting: facts.has('deliveryWaiting') ? QUIET.deliveryWaiting : held.deliveryWaiting,
557
573
  deliveryUnknown: facts.has('deliveryUnknown') ? QUIET.deliveryUnknown : held.deliveryUnknown,
558
574
  });
@@ -784,10 +800,6 @@ function heard(alive, event) {
784
800
  live(alive, conversation, { state: structuredClone(event.state) });
785
801
  return;
786
802
  }
787
- if (event.kind === 'link') {
788
- live(alive, conversation, { link: { connected: event.connected } });
789
- return;
790
- }
791
803
  if (event.kind === 'deliveries') {
792
804
  live(alive, conversation, {
793
805
  deliveryWaiting: [...event.waiting],
@@ -1025,8 +1037,8 @@ export function conversationSurface(alive, files) {
1025
1037
  rename(conversation, name, operation) {
1026
1038
  return invoke(alive, 'conversations/rename', conversation, operation, { name });
1027
1039
  },
1028
- option(conversation, option, value, operation) {
1029
- return invoke(alive, 'conversations/option/set', conversation, operation, { option, value });
1040
+ set(conversation, settings, operation) {
1041
+ return invoke(alive, 'conversations/set', conversation, operation, settings);
1030
1042
  },
1031
1043
  retry(conversation, message, operation) {
1032
1044
  return invoke(alive, 'conversations/retry', conversation, operation, {
@@ -1090,7 +1102,10 @@ export function chatDraftSurface(alive) {
1090
1102
  }
1091
1103
  export async function conversationsOpened(alive, local) {
1092
1104
  const { conversationList, agentList, conversationCursor } = await local.facts();
1093
- if (conversationList === null || agentList === null || alive.known())
1105
+ if (conversationList === null || agentList === null)
1106
+ return;
1107
+ alive.held.set({ listHeld: true });
1108
+ if (alive.known())
1094
1109
  return;
1095
1110
  alive.deps.stream()?.hold(conversationCursor);
1096
1111
  conversationsLearned(alive);
@@ -1,5 +1,5 @@
1
1
  import { equalValue } from '@agentshouse/mdmodel';
2
- import { authoredAt, covered, normalize } from './paths.js';
2
+ import { documentAt, covered, normalize } from './paths.js';
3
3
  export function declared({ locator: _locator, roomVersion: _roomVersion, ...declaration }) {
4
4
  return declaration;
5
5
  }
@@ -8,10 +8,10 @@ export function sameDeclaration(left, right) {
8
8
  }
9
9
  export function writeRule({ operations, providerOwnedPaths, authoredPaths, }, pathRule, local) {
10
10
  return (path, needs) => {
11
- const normalized = normalize(path);
11
+ const normalized = normalize(path.normalize('NFC'));
12
12
  if (normalized === null || normalized === '')
13
13
  return { code: 'room-root', path };
14
- if (covered(providerOwnedPaths, normalized) || !authoredAt(authoredPaths, normalized)) {
14
+ if (covered(providerOwnedPaths, normalized) || !documentAt(authoredPaths, normalized)) {
15
15
  return { code: 'provider-owned-path', path: normalized };
16
16
  }
17
17
  if (!pathRule(normalized))
@@ -8,5 +8,5 @@ export declare function applyDiscovery(runtime: Runtime, found: readonly Discove
8
8
  export declare const DISCOVERY = "discovery";
9
9
  export declare function signIn(runtime: Runtime, local: RuntimeStore, signedIn: Member | null): Promise<void>;
10
10
  export declare function zoned(runtime: Runtime, local: RuntimeStore, zone: string | null): Promise<void>;
11
- export declare function discoverRooms(runtime: Runtime, local: RuntimeStore, progress: CycleProgress, live: Live, found: Discovery | null): Promise<readonly DiscoveredRoom[] | null>;
11
+ export declare function discoverRooms(runtime: Runtime, progress: CycleProgress, live: Live, found: Discovery | null): Promise<readonly DiscoveredRoom[] | null>;
12
12
  //# sourceMappingURL=discovery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,cAAc,EACd,MAAM,EAEP,MAAM,cAAc,CAAC;AAOtB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAkB/C,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,GAAG,IAAI,CAsB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AAM,EACf,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAgDpC;AAUD,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC,wBAAsB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,iBAI1F;AAED,wBAAsB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,iBAIrF;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,SAAS,GAAG,IAAI,GACtB,OAAO,CAAC,SAAS,cAAc,EAAE,GAAG,IAAI,CAAC,CA2E3C"}
package/dist/discovery.js CHANGED
@@ -37,6 +37,12 @@ export function malformed(listed) {
37
37
  }
38
38
  export async function applyDiscovery(runtime, found, started, left) {
39
39
  const { store, socket, presence } = runtime;
40
+ if (found.length === 0 && !store.needed()) {
41
+ const listed = presence.list([], { whole: left === undefined, live: socket.isOpen() });
42
+ socket.session.set({ roomsListed: true });
43
+ emitRooms(runtime);
44
+ return listed;
45
+ }
40
46
  const lockedBefore = await lockedRooms(runtime);
41
47
  const local = await store.open();
42
48
  const fenced = new Set(await local.fences());
@@ -90,8 +96,8 @@ export async function zoned(runtime, local, zone) {
90
96
  await local.fact('timeZone', zone);
91
97
  emitTimeZone(runtime, zone);
92
98
  }
93
- export async function discoverRooms(runtime, local, progress, live, found) {
94
- const { socket } = runtime;
99
+ export async function discoverRooms(runtime, progress, live, found) {
100
+ const { store, socket } = runtime;
95
101
  const { session } = socket;
96
102
  const { closed, authorization } = session.now();
97
103
  if (closed || authorization === undefined) {
@@ -114,7 +120,8 @@ export async function discoverRooms(runtime, local, progress, live, found) {
114
120
  if (result.kind === 'discovery')
115
121
  runtime.retries.succeeded('connection', DISCOVERY);
116
122
  if (result.kind === 'transport-uncertainty') {
117
- await cachedModels(runtime, local);
123
+ if (store.needed())
124
+ await cachedModels(runtime, await store.open());
118
125
  progress.reachable = false;
119
126
  progress.complete = false;
120
127
  socket.notifyReady();
@@ -144,12 +151,23 @@ export async function discoverRooms(runtime, local, progress, live, found) {
144
151
  session.set({ refusal: null });
145
152
  emitRefusal(runtime);
146
153
  }
154
+ const queriesOnly = result.queriesOnly ?? [];
155
+ if (!store.needed() && result.rooms.length === 0) {
156
+ session.set({ queriesOnly, unstored: result });
157
+ socket.notifyReady();
158
+ return applyDiscovery(runtime, result.rooms, started);
159
+ }
160
+ const local = await store.open();
147
161
  const held = await local.facts();
148
162
  if (JSON.stringify(result.providerLimits) !== JSON.stringify(held.providerLimits) ||
149
163
  JSON.stringify(result.capabilities) !== JSON.stringify(held.capabilities)) {
150
164
  await local.fact('providerLimits', result.providerLimits);
151
165
  await local.fact('capabilities', result.capabilities);
152
166
  }
167
+ if (JSON.stringify(queriesOnly) !== JSON.stringify(held.queriesOnly)) {
168
+ await local.fact('queriesOnly', queriesOnly);
169
+ }
170
+ session.set({ queriesOnly, unstored: null });
153
171
  socket.notifyReady();
154
172
  await signIn(runtime, local, result.member ?? null);
155
173
  await zoned(runtime, local, result.timeZone ?? null);
@@ -1,6 +1,6 @@
1
1
  import type { MdRuntimeClient } from './client.js';
2
- import type { BinaryLinkAnswer, DownloadAnswer } from './outcome.js';
2
+ import type { AttachmentLinkAnswer, DownloadAnswer } from './outcome.js';
3
3
  export declare function handedCopy(copy: Blob, name: string): DownloadAnswer;
4
- export declare function handedLink(path: string, link: () => Promise<BinaryLinkAnswer>): Promise<DownloadAnswer>;
4
+ export declare function handedLink(path: string, link: () => Promise<AttachmentLinkAnswer>): Promise<DownloadAnswer>;
5
5
  export declare function downloadAttachment(client: MdRuntimeClient, link: string): Promise<DownloadAnswer>;
6
6
  //# sourceMappingURL=download.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuBrE,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAKnE;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,GACpC,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAEjG"}
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAuBzE,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,cAAc,CAKnE;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,GACxC,OAAO,CAAC,cAAc,CAAC,CAazB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAEjG"}
package/dist/entry.d.ts CHANGED
@@ -1,17 +1,29 @@
1
1
  import { type VerifiedModel } from '@agentshouse/mdmodel';
2
- import type { BinaryFile, HeadChange } from './adapter.js';
2
+ import type { Attachment, HeadChange } from './adapter.js';
3
+ import type { ChangeBatch } from './change.js';
4
+ import { type Written } from './overlay.js';
3
5
  import { type QueryRows } from './query.js';
6
+ import { type ValuedEntry } from './stored.js';
4
7
  import type { Connection } from './tables.js';
5
8
  export { QueryError } from '@agentshouse/mdmodel';
9
+ export { documentKey, pathOfKey } from './rows.js';
10
+ export type { ValuedEntry } from './stored.js';
11
+ export type EntryArea = {
12
+ readonly path: string;
13
+ readonly open: readonly string[];
14
+ };
6
15
  export type EntryRoom = {
7
16
  locator: string;
17
+ handle?: string;
18
+ readable?: readonly string[];
19
+ areas?: readonly EntryArea[];
8
20
  schema: string | null;
9
21
  documents: Readonly<Record<string, string>>;
10
22
  revisions?: Readonly<Record<string, string>>;
11
23
  fileIds?: Readonly<Record<string, string>>;
12
24
  created?: Readonly<Record<string, string>>;
13
25
  changes?: Readonly<Record<string, HeadChange>>;
14
- binaryFiles?: Readonly<Record<string, BinaryFile>>;
26
+ attachments?: Readonly<Record<string, Attachment>>;
15
27
  };
16
28
  export type EntryArguments = Readonly<Record<string, string>>;
17
29
  export type EntryParameterKind = 'string' | 'integer' | 'number' | 'boolean';
@@ -21,5 +33,12 @@ export declare function entryRefusal(template: unknown): string | null;
21
33
  export type EntryScope = {
22
34
  results(queries: Readonly<Record<string, unknown>>): Promise<Record<string, QueryRows>>;
23
35
  };
24
- export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection): EntryScope;
36
+ export type CountedRoom = {
37
+ locator: string;
38
+ schema: string | null;
39
+ documents: readonly ValuedEntry[];
40
+ };
41
+ export declare function writtenIn(room: EntryRoom, roomTypes: VerifiedModel, batch: ChangeBatch): Written;
42
+ export declare function entryScope(rooms: readonly EntryRoom[], roomTypes: VerifiedModel, connection: Connection, followed?: readonly EntryRoom[]): EntryScope;
43
+ export declare function countScope(room: CountedRoom, roomTypes: VerifiedModel, connection: Connection): EntryScope;
25
44
  //# sourceMappingURL=entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entry.d.ts","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK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AC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;CACzF,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,SAAS,WAAW,EAAE,CAAC;CACnC,CAAC;AAgCF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAiBhG;AAqHD,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,EACtB,QAAQ,GAAE,SAAS,SAAS,EAAO,GAClC,UAAU,CAOZ;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,GACrB,UAAU,CAaZ"}
package/dist/entry.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { invalid, plain, QueryError, } from '@agentshouse/mdmodel';
2
2
  import { attachedModel } from './attached-model.js';
3
+ import { writtenDocuments } from './overlay.js';
3
4
  import { answerQuery } from './compile.js';
4
5
  import { planWithin } from './query.js';
5
- import { writtenFacts } from './rows.js';
6
- import { entered, REPLICA_TABLES } from './stored.js';
6
+ import { documentKey, writtenFacts } from './rows.js';
7
+ import { entered, enteredValues, REPLICA_TABLES, } from './stored.js';
7
8
  export { QueryError } from '@agentshouse/mdmodel';
9
+ export { documentKey, pathOfKey } from './rows.js';
8
10
  const PARAMETER = '$param';
9
11
  const KIND = 'as';
10
12
  const INTEGER = /^-?(?:0|[1-9][0-9]*)$/u;
@@ -100,8 +102,8 @@ function sampled(template, key) {
100
102
  }
101
103
  return template;
102
104
  }
103
- function entryPlan(query, facts) {
104
- const plan = planWithin(query, facts);
105
+ function entryPlan(query, facts, reach = null) {
106
+ const plan = planWithin(query, facts, reach);
105
107
  if (plan.fileIds !== null)
106
108
  invalid('fileIds', 'an entry Room holds no file IDs');
107
109
  return plan;
@@ -117,56 +119,120 @@ export function entryRefusal(template) {
117
119
  throw error;
118
120
  }
119
121
  }
120
- export function entryScope(rooms, roomTypes, connection) {
121
- for (const table of REPLICA_TABLES)
122
- connection.run(table);
123
- const held = [];
124
- const keys = rooms.map((room) => {
125
- const model = attachedModel({
126
- kind: 'model',
127
- snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
128
- }, roomTypes);
129
- held.push({
122
+ function composedRoom(room, roomTypes) {
123
+ const model = attachedModel({
124
+ kind: 'model',
125
+ snapshot: { identity: room.locator, version: '', schema: room.schema, revision: null },
126
+ }, roomTypes);
127
+ return { model, selection: null, typedPaths: [] };
128
+ }
129
+ export function writtenIn(room, roomTypes, batch) {
130
+ const written = writtenDocuments({
131
+ documents: room.documents,
132
+ binaries: {},
133
+ revisions: room.revisions ?? {},
134
+ fileIds: {},
135
+ created: {},
136
+ changes: {},
137
+ }, batch, composedRoom(room, roomTypes));
138
+ for (;;) {
139
+ const step = written.next();
140
+ if (step.done === true)
141
+ return step.value;
142
+ }
143
+ }
144
+ function enteredRoom(room, roomTypes, connection) {
145
+ const composition = composedRoom(room, roomTypes);
146
+ const { model } = composition;
147
+ const key = room.enter(composition);
148
+ if (room.handle !== undefined)
149
+ connection.run("INSERT INTO replica_rooms (locator, key, record) VALUES (?, ?, json_object('declaration', json_object('handle', ?)))", [room.locator, key, room.handle]);
150
+ return {
151
+ locator: room.locator,
152
+ key,
153
+ composition,
154
+ ...(room.handle === undefined ? {} : { handle: room.handle }),
155
+ facts: {
130
156
  locator: room.locator,
131
157
  available: model.status !== 'unavailable',
132
158
  types: model.status === 'unavailable' ? [] : Object.values(model.types),
133
- });
134
- const composition = { model, selection: null, typedPaths: [] };
135
- const heads = (path) => ({
136
- revision: room.revisions?.[path] ?? null,
137
- fileId: room.fileIds?.[path] ?? null,
138
- created: room.created?.[path] ?? null,
139
- change: room.changes?.[path] ?? null,
140
- written: null,
141
- });
142
- const entries = [
143
- ...Object.entries(room.documents).map(([path, content]) => ({
144
- path,
145
- content,
146
- facts: writtenFacts(path, content, composition),
147
- binary: null,
148
- ...heads(path),
149
- })),
150
- ...Object.entries(room.binaryFiles ?? {}).map(([path, binary]) => ({
151
- path,
152
- content: null,
153
- facts: null,
154
- binary: { state: 'accepted', ...binary },
155
- ...heads(path),
156
- })),
157
- ];
158
- const key = entered(connection, room.locator, composition, entries.sort((left, right) => (left.path < right.path ? -1 : 1)));
159
- return { locator: room.locator, key, composition };
160
- });
161
- const planned = { listed: true, rooms: held };
159
+ },
160
+ };
161
+ }
162
+ function reachOf(rooms, followed) {
163
+ if (followed.every(({ readable, areas }) => readable === undefined && areas === undefined))
164
+ return null;
165
+ return {
166
+ rooms: [...rooms, ...followed.filter(({ readable }) => readable === undefined)].map(({ locator }) => locator),
167
+ documents: followed.flatMap(({ locator, readable }) => (readable ?? []).map((path) => documentKey(locator, path))),
168
+ areas: followed.flatMap(({ locator, areas }) => (areas ?? []).map(({ path, open }) => ({ room: locator, path, open }))),
169
+ };
170
+ }
171
+ function scope(rooms, roomTypes, connection, followed = []) {
172
+ for (const table of REPLICA_TABLES)
173
+ connection.run(table);
174
+ const keys = rooms.map((room) => enteredRoom(room, roomTypes, connection));
175
+ const follows = [
176
+ ...keys,
177
+ ...followed.map((room) => enteredRoom(room, roomTypes, connection)),
178
+ ].filter(({ handle }) => handle !== undefined);
179
+ const planned = { listed: true, rooms: keys.map(({ facts }) => facts) };
180
+ const reach = reachOf(rooms, followed);
162
181
  return {
163
182
  async results(queries) {
164
183
  const results = {};
165
184
  for (const [name, query] of Object.entries(queries)) {
166
- const plan = entryPlan(query, planned);
167
- results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)));
185
+ const plan = entryPlan(query, planned, reach);
186
+ results[name] = answerQuery(connection, plan, keys.filter(({ locator }) => plan.rooms === null || plan.rooms.includes(locator)), null, follows);
168
187
  }
169
188
  return results;
170
189
  },
171
190
  };
172
191
  }
192
+ function scopedRoom(room, connection) {
193
+ return {
194
+ locator: room.locator,
195
+ ...(room.handle === undefined ? {} : { handle: room.handle }),
196
+ ...(room.readable === undefined ? {} : { readable: room.readable }),
197
+ ...(room.areas === undefined ? {} : { areas: room.areas }),
198
+ schema: room.schema,
199
+ enter(composition) {
200
+ const heads = (path) => ({
201
+ revision: room.revisions?.[path] ?? null,
202
+ fileId: room.fileIds?.[path] ?? null,
203
+ created: room.created?.[path] ?? null,
204
+ change: room.changes?.[path] ?? null,
205
+ written: null,
206
+ });
207
+ const entries = [
208
+ ...Object.entries(room.documents).map(([path, content]) => ({
209
+ path,
210
+ content,
211
+ facts: writtenFacts(path, content, composition),
212
+ binary: null,
213
+ ...heads(path),
214
+ })),
215
+ ...Object.entries(room.attachments ?? {}).map(([path, binary]) => ({
216
+ path,
217
+ content: null,
218
+ facts: null,
219
+ binary: { state: 'accepted', ...binary },
220
+ ...heads(path),
221
+ })),
222
+ ];
223
+ return entered(connection, room.locator, composition, entries.sort((left, right) => (left.path < right.path ? -1 : 1)));
224
+ },
225
+ };
226
+ }
227
+ export function entryScope(rooms, roomTypes, connection, followed = []) {
228
+ return scope(rooms.map((room) => scopedRoom(room, connection)), roomTypes, connection, followed.map((room) => scopedRoom(room, connection)));
229
+ }
230
+ export function countScope(room, roomTypes, connection) {
231
+ return scope([
232
+ {
233
+ locator: room.locator,
234
+ schema: room.schema,
235
+ enter: (composition) => enteredValues(connection, room.locator, composition, room.documents),
236
+ },
237
+ ], roomTypes, connection);
238
+ }
package/dist/figures.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { GroupTotal, PendingResult } from './query.js';
3
3
  import type { Deliver, Fail } from './reach.js';
4
4
  import type { ConversationTally, RoomTally } from './tallies.js';
5
5
  import type { QueryRoom } from './tables.js';
6
- export declare const HOUSE_DIRECTORY = "house";
6
+ export declare const HOUSE_FOLDER = "house";
7
7
  export declare const ROOM_TOTALS: {
8
8
  readonly outside: readonly ["house"];
9
9
  readonly groupBy: readonly ["room"];