@volter/teams 0.1.41 → 0.1.43

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.
@@ -46,8 +46,11 @@ 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
- /** One line typed into the channel's session as its user's own turn; rejects when the machine refuses the stream. */
50
- export function sendBrowserTurn(channel: BrowserChannel, text: string): Promise<BrowserTurnAnswer>;
49
+ /**
50
+ * One line typed into the channel's session as its user's own turn; rejects when the machine refuses the stream.
51
+ * `turnKey`: one per typed line, reused on retry, so the machine types the line once.
52
+ */
53
+ export function sendBrowserTurn(channel: BrowserChannel, text: string, options?: { turnKey?: string }): Promise<BrowserTurnAnswer>;
51
54
 
52
55
  /** A pane's terminal stream. Events: `data` (text), `hello`, `notice`, `error-message`, `close`. */
53
56
  export interface BrowserPane extends ChannelEvents {
@@ -155,9 +155,11 @@ export function openBrowserSession({ origin, teamId, sessionId, token }, { WebSo
155
155
  * One line typed into the channel's session as its user's own turn. Resolves with the machine's answer:
156
156
  * `{ code: 0, turn_id, door: 'runtime' | 'pane' | 'waiting' }` (waiting: filed, typed when the session's composer
157
157
  * is free), or `{ code, text }` when it was not delivered; rejects when the machine refuses the stream.
158
+ * `turnKey`: one key per line the person typed, reused when they retry it, so a line the machine took after its
159
+ * first send was given up on is not typed twice (a machine of door vocabulary 3 or later keeps each key once).
158
160
  */
159
- export async function sendBrowserTurn(channel, text) {
160
- const stream = await channel.open('mail', { request: { op: 'turn', text } });
161
+ export async function sendBrowserTurn(channel, text, { turnKey } = {}) {
162
+ const stream = await channel.open('mail', { request: { op: 'turn', text, ...(turnKey ? { turn_key: String(turnKey) } : {}) } });
161
163
  return new Promise((resolve) => {
162
164
  let answer = '';
163
165
  stream.on('data', (chunk) => { answer += chunk; });
package/machine-core.mjs CHANGED
@@ -263,7 +263,8 @@ export class MachineCore extends EventEmitter {
263
263
  return;
264
264
  }
265
265
  const index = this.nextConnection++;
266
- const entry = { channel, admitted: LOCAL_OPERATOR, principal: 'local' };
266
+ // The socket stays on the entry: who is on its other end is read from the kernel, not from what the client says.
267
+ const entry = { channel, admitted: LOCAL_OPERATOR, principal: 'local', socket };
267
268
  this.connections.set(index, entry);
268
269
  channel.on('stream', (stream, accept, refuse) => this.#routeStream(index, entry, stream, accept, refuse));
269
270
  channel.on('close', () => { this.connections.delete(index); this.connectionClosed(index); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/teams",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
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",