dsh-realtime 0.2.3 → 0.2.5

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.
package/lib/journal.d.ts CHANGED
@@ -51,6 +51,8 @@ export type JournalKind =
51
51
  | 'answer.received'
52
52
  /** A context append was acknowledged on the wire. Not delivery — see invariant 6. */
53
53
  | 'append.acknowledged'
54
+ /** A narrated step the provider did not take. Not an answer failure — a step nobody will hear. */
55
+ | 'progress.dropped'
54
56
  /** Audio was handed to the transport. **Not** a claim that anyone heard it. */
55
57
  | 'speech.sent'
56
58
  /** The configuration as resolved, so a journal can be read without the profile beside it. */
@@ -105,6 +107,7 @@ export declare class Journal {
105
107
  private readonly capacity;
106
108
  private readonly secrets;
107
109
  private readonly entries;
110
+ private readonly sinks;
108
111
  private nextSeq;
109
112
  /**
110
113
  * @param options - capacity and the values that must never be retained.
@@ -123,6 +126,21 @@ export declare class Journal {
123
126
  * @param values - secrets to add; empty and duplicate values are ignored.
124
127
  */
125
128
  addSecrets(values: readonly string[]): void;
129
+ /**
130
+ * Send every entry, as it is recorded, to somewhere else as well.
131
+ *
132
+ * The journal itself stays I/O-free on purpose — it is a plain object a test can construct and a route can
133
+ * serve — so persistence is a *sink* the caller supplies rather than something this class does. Additive,
134
+ * for the same reason `addSecrets` is: sinks arrive with the plugins that want them, and plugins load in no
135
+ * guaranteed order.
136
+ *
137
+ * **A sink cannot break the record.** It is called inside a guard, so a sink that throws — a full disk, a
138
+ * path that does not exist, a bug in the caller's own writer — costs the copy and never the entry. A
139
+ * diagnostic mechanism that can lose the diagnostic is worse than none, because it fails exactly when it is
140
+ * needed.
141
+ * @param sink - called with each entry, oldest to newest, in the order they were recorded.
142
+ */
143
+ onEntry(sink: (entry: JournalEntry) => void): void;
126
144
  /**
127
145
  * Redact and retain one entry, evicting the oldest when the buffer is full.
128
146
  * @param kind - what happened.
@@ -1 +1 @@
1
- {"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../src/journ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{
38
38
  capacity;
39
39
  secrets;
40
40
  entries = [];
41
+ sinks = [];
41
42
  nextSeq = 1;
42
43
  /**
43
44
  * @param options - capacity and the values that must never be retained.
@@ -70,6 +71,25 @@ export class Journal {
70
71
  this.secrets.push(value);
71
72
  }
72
73
  }
74
+ /**
75
+ * Send every entry, as it is recorded, to somewhere else as well.
76
+ *
77
+ * The journal itself stays I/O-free on purpose — it is a plain object a test can construct and a route can
78
+ * serve — so persistence is a *sink* the caller supplies rather than something this class does. Additive,
79
+ * for the same reason `addSecrets` is: sinks arrive with the plugins that want them, and plugins load in no
80
+ * guaranteed order.
81
+ *
82
+ * **A sink cannot break the record.** It is called inside a guard, so a sink that throws — a full disk, a
83
+ * path that does not exist, a bug in the caller's own writer — costs the copy and never the entry. A
84
+ * diagnostic mechanism that can lose the diagnostic is worse than none, because it fails exactly when it is
85
+ * needed.
86
+ * @param sink - called with each entry, oldest to newest, in the order they were recorded.
87
+ */
88
+ onEntry(sink) {
89
+ if (typeof sink !== 'function')
90
+ return;
91
+ this.sinks.push(sink);
92
+ }
73
93
  /**
74
94
  * Redact and retain one entry, evicting the oldest when the buffer is full.
75
95
  * @param kind - what happened.
@@ -93,6 +113,17 @@ export class Journal {
93
113
  // the memory ceiling is a property of the type rather than of the caller's discipline.
94
114
  while (this.entries.length > this.capacity)
95
115
  this.entries.shift();
116
+ for (const sink of this.sinks) {
117
+ try {
118
+ sink(entry);
119
+ }
120
+ catch {
121
+ // Deliberately swallowed: see `onEntry`. The entry is already retained, so a broken sink costs the
122
+ // copy and not the record — and re-throwing here would let a diagnostics sink take down the path it
123
+ // was added to illuminate. This guard is proven able to fail: remove it and `journal-sink.spec.ts`
124
+ // reports a lost entry.
125
+ }
126
+ }
96
127
  return entry;
97
128
  }
98
129
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"journal.js","sourceRoot":"","sources":["../src/journal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,E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,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAA;IAC7B,CAAC;CACF"}
package/lib/types.d.ts CHANGED
@@ -213,4 +213,28 @@ export interface RealtimeDelegationSettlement {
213
213
  /** The controller's own reason, redacted, when the outcome is `refused`. */
214
214
  readonly reason?: string;
215
215
  }
216
+ /**
217
+ * One progress step of a delegated turn, on its way to an ear or to the model's own context.
218
+ *
219
+ * The vocabulary of a **narration**, not of the protocol: the provider's append is the transport, and this
220
+ * is what a plugin says through it. `channel` reuses the distinction the seam already carries on an answer
221
+ * — `commentary` is spoken aloud, `thinking` is context the model may use without saying it — because
222
+ * "spoken for milestones, silent for chatter" is a choice about that one field.
223
+ *
224
+ * Deliberately carries **no tool arguments, ever**. A step is derived from the tool's own *name* against a
225
+ * configured phrase table; a tool's raw arguments are model-authored text, and the only model-authored text
226
+ * that may reach a user's ear is the answer, which is redacted on the way out.
227
+ *
228
+ * How long the window lasts, and why a step is placed at all, is measured in
229
+ * [`usable-window.md`](https://github.com/Travizm/dsh-openai-live/blob/main/docs/usable-window.md): a step
230
+ * is placed while the session's timeline advances, which is while the client's microphone is streaming.
231
+ */
232
+ export interface RealtimeDelegationProgress {
233
+ /** The delegation this step belongs to. A step for an id nobody is waiting on is dropped. */
234
+ readonly id: string;
235
+ /** `commentary` is spoken; `thinking` is context the model may keep to itself. */
236
+ readonly channel: 'commentary' | 'thinking';
237
+ /** The words — authored by configuration, never by the model. */
238
+ readonly text: string;
239
+ }
216
240
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC,sGAAsG;IACtG,EAAE,EAAE,MAAM,CAAA;IACV,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,0GAA0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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-realtime",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "Realtime voice capability seam for DeepSeek Harness: a provider registry plus the session adapter base.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
package/src/journal.ts CHANGED
@@ -55,6 +55,8 @@ export type JournalKind =
55
55
  | 'answer.received'
56
56
  /** A context append was acknowledged on the wire. Not delivery — see invariant 6. */
57
57
  | 'append.acknowledged'
58
+ /** A narrated step the provider did not take. Not an answer failure — a step nobody will hear. */
59
+ | 'progress.dropped'
58
60
  /** Audio was handed to the transport. **Not** a claim that anyone heard it. */
59
61
  | 'speech.sent'
60
62
  /** The configuration as resolved, so a journal can be read without the profile beside it. */
@@ -112,6 +114,7 @@ export class Journal {
112
114
  private readonly capacity: number
113
115
  private readonly secrets: string[]
114
116
  private readonly entries: JournalEntry[] = []
117
+ private readonly sinks: ((entry: JournalEntry) => void)[] = []
115
118
  private nextSeq = 1
116
119
 
117
120
  /**
@@ -145,6 +148,25 @@ export class Journal {
145
148
  }
146
149
  }
147
150
 
151
+ /**
152
+ * Send every entry, as it is recorded, to somewhere else as well.
153
+ *
154
+ * The journal itself stays I/O-free on purpose — it is a plain object a test can construct and a route can
155
+ * serve — so persistence is a *sink* the caller supplies rather than something this class does. Additive,
156
+ * for the same reason `addSecrets` is: sinks arrive with the plugins that want them, and plugins load in no
157
+ * guaranteed order.
158
+ *
159
+ * **A sink cannot break the record.** It is called inside a guard, so a sink that throws — a full disk, a
160
+ * path that does not exist, a bug in the caller's own writer — costs the copy and never the entry. A
161
+ * diagnostic mechanism that can lose the diagnostic is worse than none, because it fails exactly when it is
162
+ * needed.
163
+ * @param sink - called with each entry, oldest to newest, in the order they were recorded.
164
+ */
165
+ onEntry(sink: (entry: JournalEntry) => void): void {
166
+ if (typeof sink !== 'function') return
167
+ this.sinks.push(sink)
168
+ }
169
+
148
170
  /**
149
171
  * Redact and retain one entry, evicting the oldest when the buffer is full.
150
172
  * @param kind - what happened.
@@ -167,6 +189,16 @@ export class Journal {
167
189
  // `shift()` on a bounded array: the buffer is capped, so this stays O(capacity) at worst and
168
190
  // the memory ceiling is a property of the type rather than of the caller's discipline.
169
191
  while (this.entries.length > this.capacity) this.entries.shift()
192
+ for (const sink of this.sinks) {
193
+ try {
194
+ sink(entry)
195
+ } catch {
196
+ // Deliberately swallowed: see `onEntry`. The entry is already retained, so a broken sink costs the
197
+ // copy and not the record — and re-throwing here would let a diagnostics sink take down the path it
198
+ // was added to illuminate. This guard is proven able to fail: remove it and `journal-sink.spec.ts`
199
+ // reports a lost entry.
200
+ }
201
+ }
170
202
  return entry
171
203
  }
172
204
 
package/src/types.ts CHANGED
@@ -234,3 +234,28 @@ export interface RealtimeDelegationSettlement {
234
234
  /** The controller's own reason, redacted, when the outcome is `refused`. */
235
235
  readonly reason?: string
236
236
  }
237
+
238
+ /**
239
+ * One progress step of a delegated turn, on its way to an ear or to the model's own context.
240
+ *
241
+ * The vocabulary of a **narration**, not of the protocol: the provider's append is the transport, and this
242
+ * is what a plugin says through it. `channel` reuses the distinction the seam already carries on an answer
243
+ * — `commentary` is spoken aloud, `thinking` is context the model may use without saying it — because
244
+ * "spoken for milestones, silent for chatter" is a choice about that one field.
245
+ *
246
+ * Deliberately carries **no tool arguments, ever**. A step is derived from the tool's own *name* against a
247
+ * configured phrase table; a tool's raw arguments are model-authored text, and the only model-authored text
248
+ * that may reach a user's ear is the answer, which is redacted on the way out.
249
+ *
250
+ * How long the window lasts, and why a step is placed at all, is measured in
251
+ * [`usable-window.md`](https://github.com/Travizm/dsh-openai-live/blob/main/docs/usable-window.md): a step
252
+ * is placed while the session's timeline advances, which is while the client's microphone is streaming.
253
+ */
254
+ export interface RealtimeDelegationProgress {
255
+ /** The delegation this step belongs to. A step for an id nobody is waiting on is dropped. */
256
+ readonly id: string
257
+ /** `commentary` is spoken; `thinking` is context the model may keep to itself. */
258
+ readonly channel: 'commentary' | 'thinking'
259
+ /** The words — authored by configuration, never by the model. */
260
+ readonly text: string
261
+ }