@volter/teams 0.1.72 → 0.1.73
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/browser-channel.d.ts +7 -1
- package/browser-channel.mjs +16 -5
- package/package.json +1 -1
package/browser-channel.d.ts
CHANGED
|
@@ -46,11 +46,17 @@ export type BrowserTurnAnswer =
|
|
|
46
46
|
| { code: 0; turn_id?: string; door?: 'runtime' | 'pane' | 'waiting'; text?: string }
|
|
47
47
|
| { code: number; text?: string };
|
|
48
48
|
|
|
49
|
+
/** The accepted stream ended without a valid receipt; delivery may have occurred. */
|
|
50
|
+
export declare class TurnDeliveryUnconfirmedError extends Error {
|
|
51
|
+
constructor(message: string);
|
|
52
|
+
}
|
|
53
|
+
|
|
49
54
|
/**
|
|
50
55
|
* One line typed into the channel's session as its user's own turn; rejects when the machine refuses the stream.
|
|
51
56
|
* `turnKey`: one per typed line, reused on retry, so the machine types the line once.
|
|
52
57
|
* Receipt waits time out after thirty seconds. Cancellation stops waiting; it
|
|
53
|
-
* does not undo delivery.
|
|
58
|
+
* does not undo delivery. After acceptance, a lost, invalid or cancelled receipt
|
|
59
|
+
* rejects with TurnDeliveryUnconfirmedError. Reuse the same key when retrying it.
|
|
54
60
|
*/
|
|
55
61
|
export function sendBrowserTurn(channel: BrowserChannel, text: string, options?: { turnKey?: string; signal?: AbortSignal }): Promise<BrowserTurnAnswer>;
|
|
56
62
|
|
package/browser-channel.mjs
CHANGED
|
@@ -167,6 +167,11 @@ export function openBrowserSession({ origin, teamId, sessionId, token }, { WebSo
|
|
|
167
167
|
return connectBrowserChannel(socket, channel, `could not reach session ${sessionId} through ${origin}`, 'the server closed the session channel');
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
/** A turn was accepted by its stream, but its delivery receipt was not obtained. */
|
|
171
|
+
export class TurnDeliveryUnconfirmedError extends Error {
|
|
172
|
+
constructor(message) { super(message); this.name = 'TurnDeliveryUnconfirmedError'; }
|
|
173
|
+
}
|
|
174
|
+
|
|
170
175
|
/**
|
|
171
176
|
* One line typed into the channel's session as its user's own turn. Resolves with the machine's answer:
|
|
172
177
|
* `{ code: 0, turn_id, door: 'runtime' | 'pane' | 'waiting' }` (waiting: filed, typed when the session's composer
|
|
@@ -189,13 +194,19 @@ export async function sendBrowserTurn(channel, text, { turnKey, signal } = {}) {
|
|
|
189
194
|
// receipt as success, or imply that a typed turn was rolled back.
|
|
190
195
|
stream.close(error.message);
|
|
191
196
|
};
|
|
192
|
-
const cancelled = () => fail(
|
|
193
|
-
const timer = setTimeout(() => fail(new
|
|
194
|
-
const data = chunk => { answer += chunk; if (answer.length > 256_000) fail(new
|
|
195
|
-
const closed =
|
|
197
|
+
const cancelled = () => fail(new TurnDeliveryUnconfirmedError('Turn delivery wait cancelled'));
|
|
198
|
+
const timer = setTimeout(() => fail(new TurnDeliveryUnconfirmedError('Turn delivery acknowledgement timed out')), 30_000);
|
|
199
|
+
const data = chunk => { answer += chunk; if (answer.length > 256_000) fail(new TurnDeliveryUnconfirmedError('Turn delivery receipt too large')); };
|
|
200
|
+
const closed = reason => {
|
|
196
201
|
if (settled) return;
|
|
197
202
|
settled = true; cleanup();
|
|
198
|
-
|
|
203
|
+
// Only an actual machine answer establishes delivery or refusal. A socket
|
|
204
|
+
// closing, an incomplete JSON frame or an empty receipt cannot prove either.
|
|
205
|
+
try {
|
|
206
|
+
const receipt = JSON.parse(answer);
|
|
207
|
+
if (!receipt || !Number.isInteger(receipt.code)) throw new Error('Invalid receipt');
|
|
208
|
+
resolve(receipt);
|
|
209
|
+
} catch { reject(new TurnDeliveryUnconfirmedError(reason || 'No complete delivery receipt from the machine')); }
|
|
199
210
|
};
|
|
200
211
|
stream.on('data', data);
|
|
201
212
|
if (!settled) stream.on('close', closed);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/teams",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
|
|
6
6
|
"license": "MIT",
|