@volter/supercode-teams 0.3.192 → 0.3.193

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 (2) hide show
  1. package/package.json +1 -1
  2. package/terminal-mail.mjs +19 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.3.192",
3
+ "version": "0.3.193",
4
4
  "type": "module",
5
5
  "description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
6
6
  "license": "MIT",
package/terminal-mail.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // Per-recipient terminal mailbox. A retained paste is never repeated: retries
2
- // press Enter and look for the exact user message in the native transcript.
2
+ // press Enter and look for the exact message in the native transcript (a user row, or the queued_command
3
+ // attachment a running Claude Code turn absorbs it as).
3
4
  import { statSync, openSync, readSync, closeSync } from 'node:fs';
4
5
  import { createHash, randomUUID } from 'node:crypto';
5
6
  import { spawnSync } from 'node:child_process';
@@ -52,7 +53,16 @@ function claudeHolds(batch, shown, owned = false) {
52
53
  return batch.placeholder === placeholder[0];
53
54
  }
54
55
 
55
- function confirmed(batch) {
56
+ /** Whether Claude Code recorded `text` as the prompt `wanted`. Claude records a large paste in a native
57
+ * `<pasted_content>` envelope; its whole body is compared, with line-ending and outer-whitespace normalization. */
58
+ function claudeSame(text, wanted) {
59
+ const native = normalized(text), want = normalized(wanted);
60
+ if (native === want) return true;
61
+ const pasted = /^<pasted_content id="([0-9a-f]{4})">\n([\s\S]*)\n<\/pasted_content id="\1">$/u.exec(native);
62
+ return Boolean(pasted) && normalized(pasted[2]) === want;
63
+ }
64
+
65
+ export function confirmed(batch) {
56
66
  let fd;
57
67
  try { fd = openSync(batch.path, 'r'); } catch (error) { if (error.code === 'ENOENT') return false; throw error; }
58
68
  try {
@@ -68,6 +78,12 @@ function confirmed(batch) {
68
78
  while ((end = buffered.indexOf('\n')) >= 0) {
69
79
  const line = buffered.slice(0, end); buffered = buffered.slice(end + 1);
70
80
  let row; try { row = JSON.parse(line); } catch { continue; }
81
+ // A prompt submitted while a turn runs is queued, and reaches the model as a `queued_command` attachment when
82
+ // the turn absorbs it (queue-operation remove, reason absorbed_mid_turn); no `user` row is written for it.
83
+ // That attachment is its delivery. An enqueue alone is not: a queued prompt can still be withdrawn.
84
+ if (batch.kind === 'claude-code' && row.type === 'attachment' && row.attachment?.type === 'queued_command'
85
+ && row.isSidechain !== true && (!batch.sessionId || row.sessionId === batch.sessionId)
86
+ && typeof row.attachment.prompt === 'string' && claudeSame(row.attachment.prompt, batch.text)) return { fragments: 1 };
71
87
  const content = batch.kind === 'codex' && row.type === 'response_item' && row.payload?.type === 'message' && row.payload.role === 'user'
72
88
  ? row.payload.content : batch.kind === 'claude-code' && row.type === 'user' && !row.isMeta && (!batch.sessionId || row.sessionId === batch.sessionId)
73
89
  ? row.message?.content : batch.kind === 'grok' && row.type === 'user' ? row.content : null;
@@ -75,13 +91,7 @@ function confirmed(batch) {
75
91
  if (text === null || text.length === 0) continue;
76
92
  if (text === batch.text) return { fragments: 1 };
77
93
  if (batch.kind === 'claude-code') {
78
- const native = normalized(text), wanted = normalized(batch.text);
79
- if (native === wanted) return { fragments: 1 };
80
- // Claude records a large paste in this native envelope. Compare its
81
- // whole body with matching identifiers, using the existing line-ending
82
- // and outer-whitespace normalization.
83
- const pasted = /^<pasted_content id="([0-9a-f]{4})">\n([\s\S]*)\n<\/pasted_content id="\1">$/u.exec(native);
84
- if (pasted && normalized(pasted[2]) === wanted) return { fragments: 1 };
94
+ if (claudeSame(text, batch.text)) return { fragments: 1 };
85
95
  continue;
86
96
  }
87
97
  // A Windows Codex is pasted its text with line ends as `\n` (codexWindowsPastes).