@qvac/core 0.6.4 → 1.0.0-rc.0

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 (51) hide show
  1. package/dist-lib/lib/api/host-run-log.d.ts +43 -0
  2. package/dist-lib/lib/api/host-run-log.js +97 -0
  3. package/dist-lib/lib/api/index.d.ts +3 -0
  4. package/dist-lib/lib/api/index.js +9 -0
  5. package/dist-lib/lib/api/instrument.js +33 -2
  6. package/dist-lib/lib/assistant/harness.d.ts +4 -1
  7. package/dist-lib/lib/assistant/history.d.ts +7 -2
  8. package/dist-lib/lib/assistant/history.js +34 -3
  9. package/dist-lib/lib/assistant/host-run-log.d.ts +3 -0
  10. package/dist-lib/lib/assistant/host-run-log.js +48 -0
  11. package/dist-lib/lib/assistant.d.ts +2 -0
  12. package/dist-lib/lib/assistant.js +817 -412
  13. package/dist-lib/lib/core/async-iterable.js +1 -1
  14. package/dist-lib/lib/core/chat-activity.d.ts +1 -1
  15. package/dist-lib/lib/core/chat-activity.js +16 -1
  16. package/dist-lib/lib/core/chat-search.js +11 -4
  17. package/dist-lib/lib/core/chunk.d.ts +3 -3
  18. package/dist-lib/lib/core/chunk.js +6 -2
  19. package/dist-lib/lib/core/harness-loan.js +4 -0
  20. package/dist-lib/lib/core/host-run-log-store.d.ts +114 -0
  21. package/dist-lib/lib/core/host-run-log-store.js +976 -0
  22. package/dist-lib/lib/core/prompt-history.js +3 -1
  23. package/dist-lib/lib/core/transcript-visibility.d.ts +19 -0
  24. package/dist-lib/lib/core/transcript-visibility.js +47 -0
  25. package/dist-lib/lib/core.d.ts +2 -0
  26. package/dist-lib/lib/core.js +36 -0
  27. package/dist-lib/lib/custom-model-pusher.js +9 -5
  28. package/dist-lib/lib/mesh-scoped-engine.js +5 -0
  29. package/dist-lib/lib/run-transcript.d.ts +10 -3
  30. package/dist-lib/lib/run-transcript.js +23 -5
  31. package/dist-lib/lib/task.js +6 -1
  32. package/dist-lib/schema/content.d.ts +1 -0
  33. package/dist-lib/schema/content.js +15 -3
  34. package/dist-lib/schema/engine.js +90 -3
  35. package/dist-lib/schema/indexes.js +10 -1
  36. package/dist-lib/schema/qvac.js +10 -2
  37. package/dist-lib/spec/bind.js +15 -0
  38. package/dist-lib/spec/calls.js +5 -0
  39. package/dist-lib/spec/capabilities.d.ts +10 -0
  40. package/dist-lib/spec/hrpc/hrpc.json +164 -99
  41. package/dist-lib/spec/hrpc/index.js +260 -200
  42. package/dist-lib/spec/hrpc/messages.js +1202 -898
  43. package/dist-lib/spec/hyperschema/index.js +1202 -898
  44. package/dist-lib/spec/hyperschema/schema.json +265 -0
  45. package/dist-lib/spec/hyperschema/types.d.ts +65 -3
  46. package/dist-lib/spec/mesh/hyperdb/messages.js +385 -241
  47. package/dist-lib/spec/mesh/hyperdispatch/messages.js +138 -12
  48. package/dist-lib/spec/mesh/hyperschema/index.js +138 -12
  49. package/dist-lib/spec/mesh/hyperschema/schema.json +79 -1
  50. package/dist-lib/spec/mesh/hyperschema/types.d.ts +19 -3
  51. package/package.json +3 -2
@@ -1,12 +1,14 @@
1
1
  import { diagramRepairAccepted, diagramRepairLinks, isDiagramRepairPrompt } from '@qvac/harness/lib/diagram-repair.ts';
2
+ import { visibleTranscriptTextChunks } from './transcript-visibility.js';
2
3
  export function historyBranches(all, currentRunId) {
3
4
  const seqById = new Map(all.map((chunk) => [chunk.id, chunk.seq]));
4
5
  const repairs = diagramRepairLinks(all.filter((chunk) => chunk.type === 'user-message' || chunk.type === 'run-request'), (chunk) => chunk.userMessage?.text ?? null);
5
6
  const repairByRunId = new Map(repairs.map((repair) => [repair.runId, repair]));
7
+ const visibleText = visibleTranscriptTextChunks(all);
6
8
  const hiddenChunkIds = new Set(all
7
9
  .filter((chunk) => isDiagramRepairPrompt(chunk.userMessage?.text ?? ''))
8
10
  .map((chunk) => chunk.id));
9
- const replyText = (target) => all
11
+ const replyText = (target) => visibleText
10
12
  .filter((chunk) => chunk.runId === target && chunk.content)
11
13
  .map((chunk) => chunk.content?.text ?? '')
12
14
  .join('');
@@ -0,0 +1,19 @@
1
+ export interface TranscriptVisibilityRecord {
2
+ id: string;
3
+ seq: number;
4
+ type: string;
5
+ runId?: string | null;
6
+ round?: number;
7
+ resumed?: boolean;
8
+ runStatus?: {
9
+ state?: string | null;
10
+ progress?: {
11
+ phase?: string | null;
12
+ } | null;
13
+ } | null;
14
+ roundReset?: {
15
+ replacedTypes?: ReadonlyArray<string> | null;
16
+ } | null;
17
+ }
18
+ export declare function transcriptAttemptCutoffs<T extends TranscriptVisibilityRecord>(chunks: ReadonlyArray<T>): Map<string, number>;
19
+ export declare function visibleTranscriptTextChunks<T extends TranscriptVisibilityRecord>(chunks: ReadonlyArray<T>): T[];
@@ -0,0 +1,47 @@
1
+ function roundResetKey(runId, round, type) {
2
+ return JSON.stringify([runId, round, type]);
3
+ }
4
+ export function transcriptAttemptCutoffs(chunks) {
5
+ const cutoffs = new Map();
6
+ for (const chunk of chunks) {
7
+ if (chunk.type !== 'run-status' || !chunk.runId)
8
+ continue;
9
+ if (chunk.runStatus?.state !== 'executing')
10
+ continue;
11
+ if (chunk.runStatus.progress?.phase === 'compacting' || chunk.resumed === true) {
12
+ continue;
13
+ }
14
+ cutoffs.set(chunk.runId, chunk.seq);
15
+ }
16
+ return cutoffs;
17
+ }
18
+ export function visibleTranscriptTextChunks(chunks) {
19
+ const cutoffs = transcriptAttemptCutoffs(chunks);
20
+ const resetBoundaries = new Map();
21
+ for (const chunk of chunks) {
22
+ if (chunk.type !== 'round-reset' || !chunk.runId || typeof chunk.round !== 'number') {
23
+ continue;
24
+ }
25
+ const replacedTypes = chunk.roundReset?.replacedTypes ?? ['content', 'thinking'];
26
+ for (const type of replacedTypes) {
27
+ if (type !== 'content' && type !== 'thinking')
28
+ continue;
29
+ resetBoundaries.set(roundResetKey(chunk.runId, chunk.round, type), chunk.seq);
30
+ }
31
+ }
32
+ return chunks.filter((chunk) => {
33
+ if (chunk.type !== 'content' && chunk.type !== 'thinking')
34
+ return false;
35
+ if (!chunk.runId)
36
+ return true;
37
+ const cutoff = cutoffs.get(chunk.runId);
38
+ if (cutoff !== undefined && chunk.seq < cutoff) {
39
+ return false;
40
+ }
41
+ if (typeof chunk.round !== 'number') {
42
+ return true;
43
+ }
44
+ const reset = resetBoundaries.get(roundResetKey(chunk.runId, chunk.round, chunk.type));
45
+ return reset === undefined || chunk.seq >= reset;
46
+ });
47
+ }
@@ -131,6 +131,8 @@ export declare class Core extends ReadyResource {
131
131
  private readonly _storagePath;
132
132
  store: Corestore;
133
133
  rootCorestore: Corestore;
134
+ private readonly _hostRunLogStore;
135
+ private readonly _sharedHostRunTopics;
134
136
  storage: CorestoreStorage;
135
137
  local: ReturnType<typeof openLocalStore>;
136
138
  private readonly _deviceInvites;
@@ -12,6 +12,7 @@ import ReadyGuard from 'ready-guard';
12
12
  import ReadyResource from 'ready-resource';
13
13
  import ScopeLock from 'scope-lock';
14
14
  import { createApi } from './api/index.js';
15
+ import { HostRunLogStore } from './core/host-run-log-store.js';
15
16
  import { NO_SUCH_MESH } from './api/current-mesh.js';
16
17
  import { asEncoded, watchModels } from './models-watch.js';
17
18
  import { BLIND_PEER_KEYS, BLIND_RELAY_KEYS } from './core/blind-peers.js';
@@ -77,6 +78,9 @@ export const AWAITING_ADMISSION = 'awaiting-admission';
77
78
  const MESH_WITHOUT_MEMBER = 'A mesh needs this device to belong to its account member';
78
79
  const NO_WRITABLE_ACCOUNT = 'The account mesh is not writable';
79
80
  const NOT_AN_ARCHIVED_ACCOUNT = 'Not an account this device left';
81
+ function hostRunLogScopeKey(scope) {
82
+ return `${scope.meshId}\0${scope.runId}`;
83
+ }
80
84
  const NO_ACCOUNT_TO_RECOVER = 'This device has no account to make recoverable';
81
85
  const PHRASE_NOT_OURS = 'The phrase does not derive the identity this device holds';
82
86
  const PHRASE_NOT_A_MEMBER = "The phrase names no member of this account, so it could not recover it: publish from a device holding the account's phrase";
@@ -112,6 +116,8 @@ export class Core extends ReadyResource {
112
116
  _storagePath;
113
117
  store;
114
118
  rootCorestore;
119
+ _hostRunLogStore;
120
+ _sharedHostRunTopics = new Map();
115
121
  storage;
116
122
  local;
117
123
  _deviceInvites;
@@ -239,6 +245,7 @@ export class Core extends ReadyResource {
239
245
  this.rootCorestore = new Corestore(this.storage, {
240
246
  globalCache: new Rache()
241
247
  });
248
+ this._hostRunLogStore = new HostRunLogStore(this.rootCorestore);
242
249
  this.store = this.rootCorestore.namespace(QVAC_CORE_NAMESPACE);
243
250
  this.local = openLocalStore(this.storage);
244
251
  this._deviceInvites = openDeviceInvites(this.local);
@@ -378,6 +385,7 @@ export class Core extends ReadyResource {
378
385
  this._identityPublicKey = (await this.local.readIdentity())?.publicKey ?? null;
379
386
  this._localDevice = await this.local.ensureDevice(this._deviceKeyPair.publicKey, this._device);
380
387
  const swarm = this._openSwarm(this._deviceKeyPair);
388
+ await this._hostRunLogStore.ready();
381
389
  this._departures = new PendingDepartures(this.store, this.local, {
382
390
  swarm,
383
391
  isPooled: (key) => this._pooled(b4a.toHex(key)) !== null,
@@ -413,6 +421,32 @@ export class Core extends ReadyResource {
413
421
  },
414
422
  logs: this._logSource(),
415
423
  deviceId: this.devicePublicKey,
424
+ hostRunLogs: {
425
+ begin: (input) => this._hostRunLogStore.begin(input),
426
+ append: (input) => this._hostRunLogStore.append(input),
427
+ release: (input) => this._hostRunLogStore.release(input),
428
+ exportRun: (input) => this._hostRunLogStore.exportRun(input)
429
+ },
430
+ hostRunLogTopics: {
431
+ advertise: async (descriptor) => {
432
+ const swarm = this._swarm;
433
+ if (!swarm) {
434
+ throw new Error('Core is not advertising host run logs');
435
+ }
436
+ const topic = b4a.from(descriptor.discoveryKey);
437
+ await swarm.join(topic, { server: true, client: true }).flushed();
438
+ this._sharedHostRunTopics.set(hostRunLogScopeKey(descriptor), topic);
439
+ },
440
+ unadvertise: async (scope) => {
441
+ const key = hostRunLogScopeKey(scope);
442
+ const topic = this._sharedHostRunTopics.get(key);
443
+ if (!topic) {
444
+ return;
445
+ }
446
+ await this._swarm?.leave(topic);
447
+ this._sharedHostRunTopics.delete(key);
448
+ }
449
+ },
416
450
  lifecycle: this._apiLifecycle,
417
451
  ragIndex: (meshId) => this._meshes.get(meshId)?.vectorIndex ?? null,
418
452
  ragEmbed: () => this._indexedEmbedder,
@@ -565,6 +599,7 @@ export class Core extends ReadyResource {
565
599
  await mesh.close();
566
600
  }
567
601
  logger.info('core', 'closing storage');
602
+ await this._hostRunLogStore.close();
568
603
  await this.store?.close();
569
604
  await this.rootCorestore?.close();
570
605
  }
@@ -940,6 +975,7 @@ export class Core extends ReadyResource {
940
975
  this._systemInfo?.destroy();
941
976
  this._systemInfo = null;
942
977
  logger.info('core', 'closing storage');
978
+ await this._hostRunLogStore.close();
943
979
  await this.store?.close();
944
980
  await this.rootCorestore?.close();
945
981
  this._log?.info('lifecycle', 'core closed');
@@ -1,15 +1,14 @@
1
1
  import { errorMessage } from './guards.js';
2
+ import { snapshotEquals } from './api/watchable.js';
2
3
  export function startCustomModelPusher(harness, state, opts = {}) {
3
4
  const { logger, onPushed } = opts;
4
5
  let disposed = false;
5
6
  let tail = Promise.resolve();
6
7
  let queued = false;
8
+ let pushed = null;
7
9
  const push = async () => {
8
10
  const rows = await state.getCustomModelRows();
9
- if (disposed) {
10
- return;
11
- }
12
- await harness.setCustomModels?.(rows.map((row) => ({
11
+ const entries = rows.map((row) => ({
13
12
  name: row.name,
14
13
  src: row.src,
15
14
  projectionSrc: row.mmprojSrc ?? undefined,
@@ -17,7 +16,12 @@ export function startCustomModelPusher(harness, state, opts = {}) {
17
16
  expectedSize: row.expectedSize || undefined,
18
17
  label: row.label || undefined,
19
18
  contextLength: row.contextLength || undefined
20
- })));
19
+ }));
20
+ if (disposed || snapshotEquals(entries, pushed)) {
21
+ return;
22
+ }
23
+ await harness.setCustomModels?.(entries);
24
+ pushed = entries;
21
25
  if (!disposed) {
22
26
  onPushed?.();
23
27
  }
@@ -64,6 +64,11 @@ export const MESH_SCOPED = new Set([
64
64
  'runAgent',
65
65
  'sendMessage',
66
66
  'stopRun',
67
+ 'hostRunLogBegin',
68
+ 'hostRunLogAppend',
69
+ 'hostRunLogRelease',
70
+ 'hostRunLogShare',
71
+ 'hostRunLogUnshare',
67
72
  'setToolConfigs',
68
73
  'deleteToolConfigs',
69
74
  'listToolConfigs',
@@ -2,7 +2,11 @@ import type { AssistantAppendChunkRequest, AssistantChunkId, AssistantChunkConte
2
2
  import type { ScopedCapabilities } from './mesh-scoped-engine.ts';
3
3
  import type { Logger } from './log.ts';
4
4
  import { type PendingScope } from './write-queue.ts';
5
- export type TranscriptChunk = Pick<AssistantAppendChunkRequest, 'type' | 'toolCall' | 'toolResult' | 'sources' | 'effect' | 'display' | 'rawCall'>;
5
+ export type TranscriptChunk = Pick<AssistantAppendChunkRequest, 'type' | 'toolCall' | 'toolResult' | 'sources' | 'effect' | 'display' | 'rawCall' | 'round' | 'callId' | 'roundReset'>;
6
+ export type TranscriptResetType = 'content' | 'thinking';
7
+ interface RunStatusOptions {
8
+ resumed?: boolean;
9
+ }
6
10
  export interface RunTranscriptOptions {
7
11
  chatId: string;
8
12
  runId: string;
@@ -21,13 +25,16 @@ export declare class RunTranscript {
21
25
  private readonly _ticker;
22
26
  private readonly _announced;
23
27
  private _buffered;
28
+ private _round;
24
29
  constructor(engine: ScopedCapabilities, opts: RunTranscriptOptions);
25
- text(type: 'content' | 'thinking', text: string): Promise<void>;
30
+ text(type: 'content' | 'thinking', text: string, round?: number): Promise<void>;
26
31
  chunk(chunk: TranscriptChunk): Promise<AssistantChunkId>;
27
- status(runStatus: AssistantChunkContentRunStatus): Promise<AssistantChunkId>;
32
+ roundReset(round: number, replacedTypes?: ReadonlyArray<TranscriptResetType>): Promise<AssistantChunkId>;
33
+ status(runStatus: AssistantChunkContentRunStatus, opts?: RunStatusOptions): Promise<AssistantChunkId>;
28
34
  progress(id: string, runStatus: AssistantChunkContentRunStatus): Promise<unknown>;
29
35
  flush(): Promise<void>;
30
36
  pending(): Array<PendingScope>;
31
37
  close(): void;
32
38
  private _announce;
33
39
  }
40
+ export {};
@@ -15,6 +15,7 @@ export class RunTranscript {
15
15
  _ticker;
16
16
  _announced = new Set();
17
17
  _buffered = null;
18
+ _round = 0;
18
19
  constructor(engine, opts) {
19
20
  const { chatId, runId, deviceId, model, log } = opts;
20
21
  this._engine = engine;
@@ -31,20 +32,25 @@ export class RunTranscript {
31
32
  this.flush().catch((err) => this._log?.error('assistant', 'content flush failed', err));
32
33
  }, FLUSH_INTERVAL_MS);
33
34
  }
34
- async text(type, text) {
35
- if (this._buffered && this._buffered.type !== type) {
35
+ async text(type, text, round) {
36
+ const activeRound = round ?? this._round;
37
+ if (this._buffered && (this._buffered.type !== type || this._buffered.round !== activeRound)) {
36
38
  await this.flush();
37
39
  }
38
40
  if (!this._buffered) {
39
- this._buffered = { type, text: '' };
41
+ this._buffered = { type, text: '', round: activeRound };
40
42
  this._announce(type);
41
43
  }
44
+ this._round = activeRound;
42
45
  this._buffered.text += text;
43
46
  if (this._buffered.text.length >= COALESCE_CAP) {
44
47
  await this.flush();
45
48
  }
46
49
  }
47
50
  chunk(chunk) {
51
+ if (typeof chunk.round === 'number') {
52
+ this._round = chunk.round;
53
+ }
48
54
  return this._writes.run(TRANSCRIPT, `append:${chunk.type}`, () => this._engine.appendChunk({
49
55
  chatId: this._chatId,
50
56
  runId: this._runId,
@@ -52,7 +58,16 @@ export class RunTranscript {
52
58
  ...chunk
53
59
  }));
54
60
  }
55
- status(runStatus) {
61
+ async roundReset(round, replacedTypes = ['content', 'thinking']) {
62
+ await this.flush();
63
+ this._round = round;
64
+ return this.chunk({
65
+ type: 'round-reset',
66
+ round,
67
+ roundReset: { replacedTypes: [...new Set(replacedTypes)] }
68
+ });
69
+ }
70
+ status(runStatus, opts = {}) {
56
71
  this._log?.info('runs', `run ${runStatus.state}`, {
57
72
  runId: this._runId,
58
73
  chatId: this._chatId,
@@ -63,6 +78,7 @@ export class RunTranscript {
63
78
  runId: this._runId,
64
79
  type: 'run-status',
65
80
  runStatus: { ...runStatus, model: this._model },
81
+ resumed: opts.resumed ? true : undefined,
66
82
  originDeviceId: this._deviceId
67
83
  }));
68
84
  }
@@ -73,13 +89,15 @@ export class RunTranscript {
73
89
  return this._writes.run(TRANSCRIPT, 'append:text', async () => {
74
90
  if (!this._buffered)
75
91
  return;
76
- const { type, text } = this._buffered;
92
+ const { type, text, round } = this._buffered;
77
93
  this._buffered = null;
94
+ this._round = round ?? this._round;
78
95
  const started = Date.now();
79
96
  await this._engine.appendChunk({
80
97
  chatId: this._chatId,
81
98
  runId: this._runId,
82
99
  type,
100
+ round: round ?? this._round,
83
101
  content: type === 'content' ? { text } : null,
84
102
  thinking: type === 'thinking' ? { text } : null,
85
103
  originDeviceId: this._deviceId
@@ -1,4 +1,9 @@
1
1
  const TERMINAL_STATES = new Set(['completed', 'failed', 'canceled']);
2
+ const SETTLED_STATES = new Set([
3
+ ...TERMINAL_STATES,
4
+ 'paused',
5
+ 'recovery-required'
6
+ ]);
2
7
  const TITLE_CHARS = 60;
3
8
  export async function runTask(engine, request) {
4
9
  const { agentId, meshId, prompt, skill } = request;
@@ -25,7 +30,7 @@ export async function runTask(engine, request) {
25
30
  function terminalState(chunks, runId) {
26
31
  for (const chunk of chunks) {
27
32
  const state = chunk.runId === runId ? chunk.runStatus?.state : undefined;
28
- if (state && TERMINAL_STATES.has(state)) {
33
+ if (state && SETTLED_STATES.has(state)) {
29
34
  return state;
30
35
  }
31
36
  }
@@ -14,6 +14,7 @@ export declare const CHUNK_PAYLOAD_FIELDS: {
14
14
  readonly 'run-request': 'runRequest';
15
15
  readonly sources: 'sources';
16
16
  readonly compaction: 'compaction';
17
+ readonly 'round-reset': 'roundReset';
17
18
  };
18
19
  export type ChunkType = keyof typeof CHUNK_PAYLOAD_FIELDS;
19
20
  export type ChunkPayloadField = (typeof CHUNK_PAYLOAD_FIELDS)[ChunkType];
@@ -9,9 +9,17 @@ export const CHUNK_TYPES = [
9
9
  'run-status',
10
10
  'run-request',
11
11
  'sources',
12
- 'compaction'
12
+ 'compaction',
13
+ 'round-reset'
14
+ ];
15
+ export const RUN_STATES = [
16
+ 'executing',
17
+ 'completed',
18
+ 'failed',
19
+ 'canceled',
20
+ 'paused',
21
+ 'recovery-required'
13
22
  ];
14
- export const RUN_STATES = ['executing', 'completed', 'failed', 'canceled'];
15
23
  export const APPROVAL_STATUSES = ['pending', 'approved', 'denied'];
16
24
  export const ENHANCE_MODES = ['never', 'auto'];
17
25
  export const CHUNK_PAYLOAD_FIELDS = {
@@ -25,7 +33,8 @@ export const CHUNK_PAYLOAD_FIELDS = {
25
33
  'run-status': 'runStatus',
26
34
  'run-request': 'runRequest',
27
35
  sources: 'sources',
28
- compaction: 'compaction'
36
+ compaction: 'compaction',
37
+ 'round-reset': 'roundReset'
29
38
  };
30
39
  export function versionedRegistrar(ns, namespace) {
31
40
  return (name, fields) => {
@@ -109,6 +118,9 @@ export function registerContentTypes(ns, namespace) {
109
118
  { name: 'summary', type: 'string', required: true },
110
119
  { name: 'throughId', type: 'string', required: true }
111
120
  ]);
121
+ versioned('chunk-content-round-reset', [
122
+ { name: 'replacedTypes', type: ref('chunk-type'), array: true }
123
+ ]);
112
124
  ns.register({
113
125
  name: 'rag-source',
114
126
  fields: [
@@ -247,7 +247,9 @@ export function registerEngineTypes(ns) {
247
247
  'generating-image',
248
248
  'generating-audio',
249
249
  'transcribing-audio',
250
- 'awaiting-approval'
250
+ 'awaiting-approval',
251
+ 'paused',
252
+ 'recovery-required'
251
253
  ],
252
254
  strings: true
253
255
  });
@@ -509,7 +511,11 @@ export function registerEngineTypes(ns) {
509
511
  { name: 'senderMemberId', type: 'fixed32' },
510
512
  { name: 'capability', type: 'string' },
511
513
  { name: 'capabilityArgs', type: 'json' },
512
- { name: 'enhance', type: '@assistant/enhance-mode' }
514
+ { name: 'enhance', type: '@assistant/enhance-mode' },
515
+ { name: 'round', type: 'uint' },
516
+ { name: 'callId', type: 'string' },
517
+ { name: 'resumed', type: 'bool' },
518
+ { name: 'roundReset', type: '@assistant/chunk-content-round-reset' }
513
519
  ]);
514
520
  ns.register({
515
521
  name: 'chunk-list',
@@ -541,7 +547,11 @@ export function registerEngineTypes(ns) {
541
547
  { name: 'meshId', type: 'string', required: true },
542
548
  { name: 'capability', type: 'string' },
543
549
  { name: 'capabilityArgs', type: 'json' },
544
- { name: 'enhance', type: '@assistant/enhance-mode' }
550
+ { name: 'enhance', type: '@assistant/enhance-mode' },
551
+ { name: 'round', type: 'uint' },
552
+ { name: 'callId', type: 'string' },
553
+ { name: 'resumed', type: 'bool' },
554
+ { name: 'roundReset', type: '@assistant/chunk-content-round-reset' }
545
555
  ]
546
556
  });
547
557
  ns.register({
@@ -838,6 +848,58 @@ export function registerEngineTypes(ns) {
838
848
  { name: 'meshId', type: 'string', required: true }
839
849
  ]
840
850
  });
851
+ ns.register({
852
+ name: 'host-run-log-begin-request',
853
+ fields: [
854
+ { name: 'runId', type: 'string', required: true },
855
+ { name: 'meshId', type: 'string', required: true }
856
+ ]
857
+ });
858
+ ns.register({
859
+ name: 'host-run-log-begin-response',
860
+ fields: [
861
+ { name: 'generation', type: 'string', required: true },
862
+ { name: 'digestKey', type: 'buffer', required: true },
863
+ { name: 'boot', type: 'json' }
864
+ ]
865
+ });
866
+ ns.register({
867
+ name: 'host-run-log-append-request',
868
+ fields: [
869
+ { name: 'runId', type: 'string', required: true },
870
+ { name: 'meshId', type: 'string', required: true },
871
+ { name: 'generation', type: 'string', required: true },
872
+ { name: 'step', type: 'json', required: true }
873
+ ]
874
+ });
875
+ ns.register({
876
+ name: 'host-run-log-release-request',
877
+ fields: [
878
+ { name: 'runId', type: 'string', required: true },
879
+ { name: 'meshId', type: 'string', required: true },
880
+ { name: 'generation', type: 'string', required: true }
881
+ ]
882
+ });
883
+ ns.register({
884
+ name: 'host-run-log-share-request',
885
+ fields: [
886
+ { name: 'runId', type: 'string', required: true },
887
+ { name: 'meshId', type: 'string', required: true }
888
+ ]
889
+ });
890
+ ns.register({
891
+ name: 'host-run-log-share-response',
892
+ fields: [
893
+ { name: 'meshId', type: 'string', required: true },
894
+ { name: 'runId', type: 'string', required: true },
895
+ { name: 'publicKey', type: 'string', required: true },
896
+ { name: 'discoveryKey', type: 'string', required: true },
897
+ { name: 'encryptionKey', type: 'string', required: true },
898
+ { name: 'physicalLength', type: 'uint', required: true },
899
+ { name: 'logicalLength', type: 'uint', required: true },
900
+ { name: 'nextSeq', type: 'uint', required: true }
901
+ ]
902
+ });
841
903
  ns.register({
842
904
  name: 'device-info',
843
905
  fields: [
@@ -2282,6 +2344,31 @@ export function registerEngineApi(api) {
2282
2344
  request: { name: '@assistant/stop-run-request', stream: false },
2283
2345
  response: { name: '@assistant/ok-response', stream: false }
2284
2346
  });
2347
+ api.register({
2348
+ name: 'host-run-log-begin',
2349
+ request: { name: '@assistant/host-run-log-begin-request', stream: false },
2350
+ response: { name: '@assistant/host-run-log-begin-response', stream: false }
2351
+ });
2352
+ api.register({
2353
+ name: 'host-run-log-append',
2354
+ request: { name: '@assistant/host-run-log-append-request', stream: false },
2355
+ response: { name: '@assistant/ok-response', stream: false }
2356
+ });
2357
+ api.register({
2358
+ name: 'host-run-log-release',
2359
+ request: { name: '@assistant/host-run-log-release-request', stream: false },
2360
+ response: { name: '@assistant/ok-response', stream: false }
2361
+ });
2362
+ api.register({
2363
+ name: 'host-run-log-share',
2364
+ request: { name: '@assistant/host-run-log-share-request', stream: false },
2365
+ response: { name: '@assistant/host-run-log-share-response', stream: false }
2366
+ });
2367
+ api.register({
2368
+ name: 'host-run-log-unshare',
2369
+ request: { name: '@assistant/host-run-log-share-request', stream: false },
2370
+ response: { name: '@assistant/ok-response', stream: false }
2371
+ });
2285
2372
  api.register({
2286
2373
  name: 'mesh-status-watch',
2287
2374
  request: { name: '@assistant/empty', stream: false },
@@ -1,7 +1,14 @@
1
1
  // imported by the generated spec at runtime (dbns.require embeds a relative path) — stays plain .js
2
2
  import { mediaKindOf, mediaKindOrdinal } from './media-kind.js'
3
3
 
4
- const historyChunkTypes = ['user-message', 'run-request', 'content', 'attachment', 'compaction']
4
+ const historyChunkTypes = [
5
+ 'user-message',
6
+ 'run-request',
7
+ 'content',
8
+ 'attachment',
9
+ 'compaction',
10
+ 'round-reset'
11
+ ]
5
12
 
6
13
  // index keys hold the ordinal, kept in sync by hand with CHUNK_TYPES order in content.ts
7
14
  export function chunkTypeOrdinal(type) {
@@ -28,6 +35,8 @@ export function chunkTypeOrdinal(type) {
28
35
  return 10
29
36
  case 'compaction':
30
37
  return 11
38
+ case 'round-reset':
39
+ return 12
31
40
  default:
32
41
  throw new Error('Unknown chunk type: ' + type)
33
42
  }
@@ -78,7 +78,11 @@ export function registerQvacTypes(ns) {
78
78
  { name: 'senderMemberId', type: 'fixed32' },
79
79
  { name: 'capability', type: 'string' },
80
80
  { name: 'capabilityArgs', type: 'json' },
81
- { name: 'enhance', type: '@qvac/enhance-mode' }
81
+ { name: 'enhance', type: '@qvac/enhance-mode' },
82
+ { name: 'round', type: 'uint' },
83
+ { name: 'callId', type: 'string' },
84
+ { name: 'resumed', type: 'bool' },
85
+ { name: 'roundReset', type: '@qvac/chunk-content-round-reset' }
82
86
  ]);
83
87
  versioned('chunk-counter', [
84
88
  { name: 'chatId', type: 'string', required: true },
@@ -111,7 +115,11 @@ export function registerQvacTypes(ns) {
111
115
  { name: 'senderMemberId', type: 'fixed32' },
112
116
  { name: 'capability', type: 'string' },
113
117
  { name: 'capabilityArgs', type: 'json' },
114
- { name: 'enhance', type: '@qvac/enhance-mode' }
118
+ { name: 'enhance', type: '@qvac/enhance-mode' },
119
+ { name: 'round', type: 'uint' },
120
+ { name: 'callId', type: 'string' },
121
+ { name: 'resumed', type: 'bool' },
122
+ { name: 'roundReset', type: '@qvac/chunk-content-round-reset' }
115
123
  ]);
116
124
  versioned('update-chunk-operation', [
117
125
  { name: 'id', type: 'string', required: true },
@@ -236,6 +236,21 @@ export function bindApi(rpc, api) {
236
236
  if (api.stopRun) {
237
237
  rpc.onStopRun((req) => api.stopRun(req));
238
238
  }
239
+ if (api.hostRunLogBegin) {
240
+ rpc.onHostRunLogBegin((req) => api.hostRunLogBegin(req));
241
+ }
242
+ if (api.hostRunLogAppend) {
243
+ rpc.onHostRunLogAppend((req) => api.hostRunLogAppend(req));
244
+ }
245
+ if (api.hostRunLogRelease) {
246
+ rpc.onHostRunLogRelease((req) => api.hostRunLogRelease(req));
247
+ }
248
+ if (api.hostRunLogShare) {
249
+ rpc.onHostRunLogShare((req) => api.hostRunLogShare(req));
250
+ }
251
+ if (api.hostRunLogUnshare) {
252
+ rpc.onHostRunLogUnshare((req) => api.hostRunLogUnshare(req));
253
+ }
239
254
  if (api.meshStatusWatch) {
240
255
  rpc.onMeshStatusWatch((out) => {
241
256
  const src = Readable.from(api.meshStatusWatch(out.data));
@@ -62,6 +62,11 @@ export function engineClient(rpc) {
62
62
  runAgent: (input) => rpc.runAgent(input),
63
63
  sendMessage: (input) => rpc.sendMessage(input),
64
64
  stopRun: (input) => rpc.stopRun(input),
65
+ hostRunLogBegin: (input) => rpc.hostRunLogBegin(input),
66
+ hostRunLogAppend: (input) => rpc.hostRunLogAppend(input),
67
+ hostRunLogRelease: (input) => rpc.hostRunLogRelease(input),
68
+ hostRunLogShare: (input) => rpc.hostRunLogShare(input),
69
+ hostRunLogUnshare: (input) => rpc.hostRunLogUnshare(input),
65
70
  meshStatusWatch: (input) => armed(rpc.meshStatusWatch(input ?? {})),
66
71
  networkWatch: (input) => armed(rpc.networkWatch(input ?? {})),
67
72
  deviceInfo: (input) => rpc.deviceInfo(input ?? {}),
@@ -80,6 +80,11 @@ export interface Capabilities {
80
80
  runAgent(input: T.AssistantRunAgentRequest): Promise<T.AssistantOkResponse>
81
81
  sendMessage(input: T.AssistantSendMessageRequest): Promise<T.AssistantSendMessageResponse>
82
82
  stopRun(input: T.AssistantStopRunRequest): Promise<T.AssistantOkResponse>
83
+ hostRunLogBegin(input: T.AssistantHostRunLogBeginRequest): Promise<T.AssistantHostRunLogBeginResponse>
84
+ hostRunLogAppend(input: T.AssistantHostRunLogAppendRequest): Promise<T.AssistantOkResponse>
85
+ hostRunLogRelease(input: T.AssistantHostRunLogReleaseRequest): Promise<T.AssistantOkResponse>
86
+ hostRunLogShare(input: T.AssistantHostRunLogShareRequest): Promise<T.AssistantHostRunLogShareResponse>
87
+ hostRunLogUnshare(input: T.AssistantHostRunLogShareRequest): Promise<T.AssistantOkResponse>
83
88
  meshStatusWatch(input?: T.AssistantEmpty): WatchStream<T.AssistantMeshStatus>
84
89
  networkWatch(input?: T.AssistantEmpty): WatchStream<T.AssistantNetworkStatus>
85
90
  deviceInfo(input?: T.AssistantEmpty): Promise<T.AssistantDeviceInfo>
@@ -235,6 +240,11 @@ export interface CapabilityHandlers {
235
240
  runAgent(input: T.AssistantRunAgentRequest): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
236
241
  sendMessage(input: T.AssistantSendMessageRequest): T.AssistantSendMessageResponse | Promise<T.AssistantSendMessageResponse>
237
242
  stopRun(input: T.AssistantStopRunRequest): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
243
+ hostRunLogBegin(input: T.AssistantHostRunLogBeginRequest): T.AssistantHostRunLogBeginResponse | Promise<T.AssistantHostRunLogBeginResponse>
244
+ hostRunLogAppend(input: T.AssistantHostRunLogAppendRequest): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
245
+ hostRunLogRelease(input: T.AssistantHostRunLogReleaseRequest): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
246
+ hostRunLogShare(input: T.AssistantHostRunLogShareRequest): T.AssistantHostRunLogShareResponse | Promise<T.AssistantHostRunLogShareResponse>
247
+ hostRunLogUnshare(input: T.AssistantHostRunLogShareRequest): T.AssistantOkResponse | Promise<T.AssistantOkResponse>
238
248
  meshStatusWatch(input?: T.AssistantEmpty): AsyncIterable<T.AssistantMeshStatus>
239
249
  networkWatch(input?: T.AssistantEmpty): AsyncIterable<T.AssistantNetworkStatus>
240
250
  deviceInfo(input?: T.AssistantEmpty): T.AssistantDeviceInfo | Promise<T.AssistantDeviceInfo>