@miller-tech/uap 1.148.19 → 1.148.20

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.
@@ -0,0 +1,61 @@
1
+ /**
2
+ * A mission must outlive the tool call that started it.
3
+ *
4
+ * Coding agents run shell commands in a bounded tool call: opencode puts each
5
+ * `bash -c …` in its own session and kills that process group when the call ends
6
+ * or times out. A model that invokes `uap deliver` from its bash tool therefore
7
+ * spawns a long mission INSIDE a short-lived container — and when the tool call
8
+ * ends, the whole mission dies wherever it happened to be. Observed lifetimes on
9
+ * the live sandbox were 531s, 258s, 34s, 0s, 291s: not timeouts, just "whenever
10
+ * the tool call happened to end". Nothing landed, ever.
11
+ *
12
+ * (The autoroute hook already spawns with start_new_session=True and is immune.
13
+ * This closes the same hole for a model that calls deliver directly.)
14
+ *
15
+ * So deliver re-launches itself into its OWN session, which a process-group kill
16
+ * cannot reach, and the foreground wrapper mirrors the mission's output. If the
17
+ * client tears the tool call down, the wrapper dies and the MISSION KEEPS GOING —
18
+ * to completion, with its result recorded and resumable.
19
+ *
20
+ * Two details that matter:
21
+ * - The child's stdio goes to a FILE, never to a pipe held by the wrapper. A
22
+ * pipe whose reader is killed would hand the child EPIPE and take it down
23
+ * too — defeating the entire point.
24
+ * - An interactive run (stdout is a TTY) is left alone: a human wants live
25
+ * output and a working Ctrl-C. Only a captured, non-TTY invocation — which is
26
+ * exactly what an agent tool call looks like — is detached.
27
+ */
28
+ /** Set on the detached child so it never re-detaches (infinite recursion). */
29
+ export declare const DETACH_ENV = "UAP_DELIVER_DETACHED";
30
+ /** Escape hatch: force the old attached behaviour. */
31
+ export declare const NO_DETACH_ENV = "UAP_DELIVER_NO_DETACH";
32
+ export interface DetachDecision {
33
+ detach: boolean;
34
+ reason: string;
35
+ }
36
+ /**
37
+ * Should this invocation re-launch itself detached? Exported for tests — the
38
+ * decision is the whole safety argument, so it must be checkable in isolation.
39
+ */
40
+ export declare function shouldDetach(opts: {
41
+ alreadyDetached: boolean;
42
+ noDetach: boolean;
43
+ isTTY: boolean;
44
+ dryRun: boolean;
45
+ }): DetachDecision;
46
+ /** Where the detached child streams its output (the wrapper tails this). */
47
+ export declare function detachLogPath(projectRoot: string, stamp: string): string;
48
+ /**
49
+ * Re-launch this same command in a new session and mirror its output.
50
+ *
51
+ * Returns the child's exit code once it finishes. If the WRAPPER is killed
52
+ * first (the tool-call teardown), the child simply carries on: it is in its own
53
+ * session, and its stdio is a file, so nothing about the wrapper's death can
54
+ * reach it.
55
+ */
56
+ export declare function relaunchDetached(projectRoot: string, stamp: string): Promise<number>;
57
+ /** Is this process the detached child? */
58
+ export declare function isDetachedChild(): boolean;
59
+ /** True when the project dir looks writable enough to host the detach log. */
60
+ export declare function canHostDetachLog(projectRoot: string): boolean;
61
+ //# sourceMappingURL=deliver-detach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deliver-detach.d.ts","sourceRoot":"","sources":["../../src/cli/deliver-detach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAMH,8EAA8E;AAC9E,eAAO,MAAM,UAAU,yBAAyB,CAAC;AACjD,sDAAsD;AACtD,eAAO,MAAM,aAAa,0BAA0B,CAAC;AAErD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,GAAG,cAAc,CAUjB;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExE;AAED;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgD1F;AAED,0CAA0C;AAC1C,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAM7D"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * A mission must outlive the tool call that started it.
3
+ *
4
+ * Coding agents run shell commands in a bounded tool call: opencode puts each
5
+ * `bash -c …` in its own session and kills that process group when the call ends
6
+ * or times out. A model that invokes `uap deliver` from its bash tool therefore
7
+ * spawns a long mission INSIDE a short-lived container — and when the tool call
8
+ * ends, the whole mission dies wherever it happened to be. Observed lifetimes on
9
+ * the live sandbox were 531s, 258s, 34s, 0s, 291s: not timeouts, just "whenever
10
+ * the tool call happened to end". Nothing landed, ever.
11
+ *
12
+ * (The autoroute hook already spawns with start_new_session=True and is immune.
13
+ * This closes the same hole for a model that calls deliver directly.)
14
+ *
15
+ * So deliver re-launches itself into its OWN session, which a process-group kill
16
+ * cannot reach, and the foreground wrapper mirrors the mission's output. If the
17
+ * client tears the tool call down, the wrapper dies and the MISSION KEEPS GOING —
18
+ * to completion, with its result recorded and resumable.
19
+ *
20
+ * Two details that matter:
21
+ * - The child's stdio goes to a FILE, never to a pipe held by the wrapper. A
22
+ * pipe whose reader is killed would hand the child EPIPE and take it down
23
+ * too — defeating the entire point.
24
+ * - An interactive run (stdout is a TTY) is left alone: a human wants live
25
+ * output and a working Ctrl-C. Only a captured, non-TTY invocation — which is
26
+ * exactly what an agent tool call looks like — is detached.
27
+ */
28
+ import { spawn } from 'child_process';
29
+ import { createWriteStream, existsSync, mkdirSync, openSync, statSync, createReadStream } from 'fs';
30
+ import { join } from 'path';
31
+ /** Set on the detached child so it never re-detaches (infinite recursion). */
32
+ export const DETACH_ENV = 'UAP_DELIVER_DETACHED';
33
+ /** Escape hatch: force the old attached behaviour. */
34
+ export const NO_DETACH_ENV = 'UAP_DELIVER_NO_DETACH';
35
+ /**
36
+ * Should this invocation re-launch itself detached? Exported for tests — the
37
+ * decision is the whole safety argument, so it must be checkable in isolation.
38
+ */
39
+ export function shouldDetach(opts) {
40
+ if (opts.alreadyDetached)
41
+ return { detach: false, reason: 'already the detached child' };
42
+ if (opts.noDetach)
43
+ return { detach: false, reason: `${NO_DETACH_ENV} is set` };
44
+ if (opts.dryRun)
45
+ return { detach: false, reason: 'a dry-run only plans; nothing to outlive' };
46
+ // A TTY means a human is watching: keep the foreground semantics they expect.
47
+ if (opts.isTTY)
48
+ return { detach: false, reason: 'interactive (stdout is a TTY)' };
49
+ return {
50
+ detach: true,
51
+ reason: 'captured stdout (an agent tool call) — the mission must outlive it',
52
+ };
53
+ }
54
+ /** Where the detached child streams its output (the wrapper tails this). */
55
+ export function detachLogPath(projectRoot, stamp) {
56
+ return join(projectRoot, '.uap', 'deliver-logs', `deliver-${stamp}.log`);
57
+ }
58
+ /**
59
+ * Re-launch this same command in a new session and mirror its output.
60
+ *
61
+ * Returns the child's exit code once it finishes. If the WRAPPER is killed
62
+ * first (the tool-call teardown), the child simply carries on: it is in its own
63
+ * session, and its stdio is a file, so nothing about the wrapper's death can
64
+ * reach it.
65
+ */
66
+ export async function relaunchDetached(projectRoot, stamp) {
67
+ const logPath = detachLogPath(projectRoot, stamp);
68
+ mkdirSync(join(projectRoot, '.uap', 'deliver-logs'), { recursive: true });
69
+ // Touch it so the tail below always has something to open.
70
+ createWriteStream(logPath, { flags: 'a' }).end();
71
+ const fd = openSync(logPath, 'a');
72
+ const child = spawn(process.argv[0], process.argv.slice(1), {
73
+ detached: true, // setsid: new session AND new process group — out of reach of a pgroup kill
74
+ stdio: ['ignore', fd, fd], // a FILE, never a pipe the wrapper could break
75
+ env: { ...process.env, [DETACH_ENV]: '1' },
76
+ cwd: process.cwd(),
77
+ });
78
+ child.unref();
79
+ console.log(`⇢ mission detached (pid ${child.pid}) so it outlives this tool call — streaming ${logPath}`);
80
+ // Mirror the log to our stdout for as long as we are alive.
81
+ return await new Promise((resolve) => {
82
+ let offset = 0;
83
+ let done = false;
84
+ const pump = () => {
85
+ let size = 0;
86
+ try {
87
+ size = statSync(logPath).size;
88
+ }
89
+ catch {
90
+ return;
91
+ }
92
+ if (size <= offset)
93
+ return;
94
+ const stream = createReadStream(logPath, { start: offset, end: size - 1, encoding: 'utf-8' });
95
+ offset = size;
96
+ stream.on('data', (chunk) => process.stdout.write(String(chunk)));
97
+ };
98
+ const timer = setInterval(pump, 400);
99
+ const finish = (code) => {
100
+ if (done)
101
+ return;
102
+ done = true;
103
+ clearInterval(timer);
104
+ setTimeout(() => {
105
+ pump(); // one last flush so the tail of the mission is not lost
106
+ resolve(code);
107
+ }, 500);
108
+ };
109
+ child.on('exit', (code, signal) => finish(signal ? 143 : (code ?? 0)));
110
+ child.on('error', () => finish(1));
111
+ });
112
+ }
113
+ /** Is this process the detached child? */
114
+ export function isDetachedChild() {
115
+ return process.env[DETACH_ENV] === '1';
116
+ }
117
+ /** True when the project dir looks writable enough to host the detach log. */
118
+ export function canHostDetachLog(projectRoot) {
119
+ try {
120
+ return existsSync(projectRoot);
121
+ }
122
+ catch {
123
+ return false;
124
+ }
125
+ }
126
+ //# sourceMappingURL=deliver-detach.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deliver-detach.js","sourceRoot":"","sources":["../../src/cli/deliver-detach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,IAAI,CAAC;AACpG,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,8EAA8E;AAC9E,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AACjD,sDAAsD;AACtD,MAAM,CAAC,MAAM,aAAa,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,wBAAsB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAyBhG"}
@@ -112,6 +112,7 @@ import { resolveSessionTokenBudget, sessionWorkingBudget, discoverModelContextWi
112
112
  import { orchestrate } from '../delivery/task-orchestrator.js';
113
113
  import { preflightProject, formatPreflightFailure } from '../delivery/project-preflight.js';
114
114
  import { installRunExitRecorder } from '../delivery/run-exit.js';
115
+ import { shouldDetach, relaunchDetached, isDetachedChild, canHostDetachLog, NO_DETACH_ENV, } from './deliver-detach.js';
115
116
  import { extractContract } from '../delivery/contract-extractor.js';
116
117
  import { completeDeliveryTask, openDeliveryTask, recordDeliveryOutcome, recordOrchestratorTaskOutcome, reopenDeliveryTask } from '../delivery/task-sync.js';
117
118
  import { autoMineHaloTraces, summarizeWeaknesses, weaknessGuidance, loadPersistedWeaknesses } from '../delivery/auto-mine.js';
@@ -371,6 +372,23 @@ export function acquireDeliverLock(projectRoot) {
371
372
  return release;
372
373
  }
373
374
  export async function deliverCommand(instruction, options) {
375
+ // A mission must outlive the tool call that started it. An agent's bash tool
376
+ // is a short-lived, process-group-killed container; a model that runs
377
+ // `uap deliver` from it was spawning a long mission inside a short one, and
378
+ // the mission died wherever it happened to be when the call ended. Re-launch
379
+ // into our own session first, then mirror the output (see deliver-detach.ts).
380
+ const projectRootForDetach = resolve(options.projectRoot ?? process.cwd());
381
+ const decision = shouldDetach({
382
+ alreadyDetached: isDetachedChild(),
383
+ noDetach: process.env[NO_DETACH_ENV] === '1',
384
+ isTTY: Boolean(process.stdout.isTTY),
385
+ dryRun: Boolean(options.dryRun),
386
+ });
387
+ if (decision.detach && canHostDetachLog(projectRootForDetach)) {
388
+ const stamp = new Date().toISOString().replace(/[-:.]/g, '').slice(0, 15);
389
+ process.exitCode = await relaunchDetached(projectRootForDetach, stamp);
390
+ return;
391
+ }
374
392
  try {
375
393
  await runDeliver(instruction, options);
376
394
  }