@volter/supercode-teams 0.2.115 → 0.2.117

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/codex-startup.mjs CHANGED
@@ -1,8 +1,36 @@
1
1
  // Codex can still show hook review on resume despite its invocation trust flag.
2
2
  // Act only on this exact startup menu, and never submit without reading selection.
3
3
  import { composerText } from '@volter/supercode-terminal';
4
+ import { realpathSync } from 'node:fs';
4
5
  const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
5
6
 
7
+ // CLI and portable SDK callers can name a directory through a filesystem alias.
8
+ // Resolve only on the executing machine, before the native seed/server is built.
9
+ export function canonicalCodexFolderTrust(cwd, args = []) {
10
+ if (typeof cwd !== 'string' || !cwd) return args;
11
+ const grant = `projects={${JSON.stringify(cwd)}={trust_level="trusted"}}`;
12
+ const projects = [];
13
+ for (let i = 0; i < args.length && args[i] !== '--'; i += 1) {
14
+ const arg = args[i];
15
+ if (arg === '-c' || arg === '--config') {
16
+ const value = args[++i];
17
+ if (value?.startsWith('projects')) projects.push({ index: i, value, prefix: '' });
18
+ } else if (arg.startsWith('--config=')) {
19
+ const value = arg.slice('--config='.length);
20
+ if (value.startsWith('projects')) projects.push({ index: i, value, prefix: '--config=' });
21
+ }
22
+ }
23
+ // A custom table, an untrusted grant or multiple overrides belongs to the caller.
24
+ if (projects.length !== 1 || projects[0].value !== grant) return args;
25
+ let effective;
26
+ try { effective = realpathSync(cwd); } catch { return args; }
27
+ if (effective === cwd) return args;
28
+ const out = [...args];
29
+ const { index, prefix } = projects[0];
30
+ out[index] = `${prefix}projects={${JSON.stringify(effective)}={trust_level="trusted"}}`;
31
+ return out;
32
+ }
33
+
6
34
  function hookReview(screen) {
7
35
  const lines = String(screen).split('\n').map((line) => line.trim()).filter(Boolean);
8
36
  const start = lines.lastIndexOf('Hooks need review');
package/machine.mjs CHANGED
@@ -50,7 +50,7 @@ import { DEFAULT_RANK, normalizeRank, judge } from './attention.mjs';
50
50
  import { popupTerminal, openPopup } from './popup-terminals.mjs';
51
51
  import { JobOwner, executionCapabilities, streamProgram, serveWorkspace } from './execution.mjs';
52
52
  import { confirmNativeInitialInput } from './native-initial-input.mjs';
53
- import { settleCodexHookReview } from './codex-startup.mjs';
53
+ import { canonicalCodexFolderTrust, settleCodexHookReview } from './codex-startup.mjs';
54
54
 
55
55
  /** The preload every launched pane carries: it announces the ports a pane's node processes listen on. */
56
56
  const PORTHOLE_HOOK = fileURLToPath(new URL('./porthole-hook.cjs', import.meta.url));
@@ -1326,6 +1326,7 @@ export class TeamsMachine extends MachineCore {
1326
1326
  let session;
1327
1327
  let nativeInput;
1328
1328
  try {
1329
+ if (params.kind === 'codex') params = { ...params, arguments: canonicalCodexFolderTrust(params.cwd, params.arguments) };
1329
1330
  session = await this.host.createSession({
1330
1331
  command: this.#nativeQuestionCommand(params, contextKey, by, (value) => { nativeInput = value; }),
1331
1332
  contextKey,
package/mail-history.mjs CHANGED
@@ -4,6 +4,47 @@ import { hostname } from 'node:os';
4
4
  import { spawn } from 'node:child_process';
5
5
  import { teamsHome } from '@volter/teams/home';
6
6
 
7
+ const directories = new Map();
8
+ function sessionDirectory(binary, env, signal) {
9
+ const key = `${binary}:${teamsHome(env)}`;
10
+ const cached = directories.get(key);
11
+ if (cached && cached.until > Date.now()) return cached.value;
12
+ const value = new Promise((resolve, reject) => {
13
+ const child = spawn(binary, ['message', 'list', '--json'], { env, signal: AbortSignal.any([...(signal ? [signal] : []), AbortSignal.timeout(15_000)]), stdio: ['ignore', 'pipe', 'ignore'] });
14
+ let out = '';
15
+ child.stdout.on('data', chunk => { out += chunk; if (out.length > 4_000_000) child.kill(); });
16
+ child.on('error', reject);
17
+ child.on('close', code => { try { if (code !== 0) throw new Error('Session directory unavailable'); resolve(JSON.parse(out)); } catch (error) { reject(error); } });
18
+ }).catch(() => []);
19
+ directories.set(key, { until: Date.now() + 60_000, value });
20
+ return value;
21
+ }
22
+
23
+ /** Resolve from supercode's existing session directory and explicit voice
24
+ * backing, never by interpreting an operator mailbox's generated name. */
25
+ function mailActors(rows, sessions, self) {
26
+ const directory = new Map(sessions.map(session => [session.address, session]));
27
+ const voices = new Map(rows.filter(row => row.envelope.voice_for).map(row => [row.envelope.from, row.envelope.voice_for]));
28
+ const names = new Map(rows.map(row => [row.envelope.from, row.envelope.from_name]));
29
+ const actor = (address) => {
30
+ const backing = voices.get(address) || address;
31
+ const native = /^sc:([^:]+):([^:]+):(.+)$/.exec(backing);
32
+ const session = directory.get(backing);
33
+ const kind = native && !['operator', 'board', 'pane'].includes(native[2]) ? 'agent' : 'automation';
34
+ let name = session?.name || names.get(backing) || (native?.[2] === 'board' ? 'Board' : kind === 'agent' ? native[2] : 'Automation');
35
+ if (native && name.endsWith(`@${native[1]}`)) name = name.slice(0, -native[1].length - 1);
36
+ // An unnamed session gets its harness label, not its address as a name.
37
+ if (/^(?:codex|claude-code|claude|gemini|pi|goose|grok|opencode)-[0-9a-f]{8,}$/i.test(name)) name = native[2] === 'codex' ? 'Codex' : native[2];
38
+ return { id: backing, name, kind, self: backing === self, ...(native ? { session: { machine: native[1], harness: native[2], id: native[3] } } : {}), ...(voices.has(address) ? { via: 'voice' } : {}) };
39
+ };
40
+ return rows.map(({ envelope, session: to, direction, delivery }) => ({
41
+ id: envelope.id, from: envelope.from, fromName: envelope.from_name, to,
42
+ fromActor: actor(envelope.from), toActor: actor(to),
43
+ text: envelope.body, at: envelope.created_at_ms, direction,
44
+ inReplyTo: envelope.in_reply_to ?? null, delivery: delivery?.state ?? 'unknown',
45
+ }));
46
+ }
47
+
7
48
  // Match the CLI's local_machine_name: the native mailbox belongs to its
8
49
  // enrolled context, which can differ from a viewer connector's --home.
9
50
  function machineName(env) {
@@ -30,21 +71,17 @@ export function readMailHistory({ binary, env, harness, session, signal }) {
30
71
  const address = `sc:${machineName(env)}:${harness}:${session}`;
31
72
  return new Promise((resolve, reject) => {
32
73
  const child = spawn(binary, ['message', 'inbox', '--session', address, '--json', '--recent', '100'], {
33
- env, stdio: ['ignore', 'pipe', 'pipe'], signal: AbortSignal.any([signal, AbortSignal.timeout(20_000)]),
74
+ env, stdio: ['ignore', 'pipe', 'pipe'], signal: AbortSignal.any([...(signal ? [signal] : []), AbortSignal.timeout(20_000)]),
34
75
  });
35
76
  let out = '', error = '';
36
77
  child.stdout.on('data', chunk => { out += chunk; if (out.length > 8_000_000) child.kill(); });
37
78
  child.stderr.on('data', chunk => { error = (error + chunk).slice(-1000); });
38
79
  child.on('error', reject);
39
- child.on('close', code => {
80
+ child.on('close', async code => {
40
81
  if (code !== 0) return reject(new Error(error || 'Mailbox could not be read'));
41
82
  try {
42
83
  const rows = JSON.parse(out).filter(row => ['peer', 'channel'].includes(row.envelope?.kind));
43
- resolve(rows.map(({ envelope, session: to, direction, delivery }) => ({
44
- id: envelope.id, from: envelope.from, fromName: envelope.from_name, to,
45
- text: envelope.body, at: envelope.created_at_ms, direction,
46
- inReplyTo: envelope.in_reply_to ?? null, delivery: delivery?.state ?? 'unknown',
47
- })));
84
+ resolve(mailActors(rows, await sessionDirectory(binary, env, signal), address));
48
85
  } catch (error) { reject(error); }
49
86
  });
50
87
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.2.115",
3
+ "version": "0.2.117",
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",