@hyperwindmill/caretaker-cli 0.25.0 → 0.25.1

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.
@@ -23,6 +23,7 @@ export type AcpAgentHandle = {
23
23
  type Connector = (provider: ProviderConfig, app: ClientApp) => {
24
24
  conn: ClientConnection;
25
25
  kill: () => void;
26
+ stderr?: () => string;
26
27
  };
27
28
  export declare function __setConnector(fn: Connector): void;
28
29
  export declare function __resetConnector(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"acp_pool.d.ts","sourceRoot":"","sources":["../../src/harness/acp_pool.ts"],"names":[],"mappings":"AAYA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,KAAK,EACX,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,MAAM,WAAW,GAAG;IACxB;2DACuD;IACvD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3D,YAAY,EAAE,CAAC,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,yBAAyB,CAAC,CAAC;CACnF,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE;QAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;KAAE,CAAC;IACzC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,QAAQ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kB,CAAC;IACzB,OAAO,EAAE;QAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAAA;KAAE,CAAC;IACzC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF,KAAK,SAAS,GAAG,CACf,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,SAAS,KACX;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,MAAM,CAAA;CAAE,CAAC;AAmCzE,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAElD;AACD,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAkED,wBAAsB,eAAe,CACnC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,GAAG,IAAI,GACrB,OAAO,CAAC,cAAc,CAAC,CAqBzB;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI,CAMpF;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAUxC"}
@@ -35,7 +35,7 @@ const defaultConnector = (provider, app) => {
35
35
  });
36
36
  const stream = ndJsonStream(Writable.toWeb(child.stdin), Readable.toWeb(child.stdout));
37
37
  const conn = app.connect(stream);
38
- return { conn, kill: () => child.kill('SIGTERM') };
38
+ return { conn, kill: () => child.kill('SIGTERM'), stderr: () => stderrTail.trim() };
39
39
  };
40
40
  let connector = defaultConnector;
41
41
  export function __setConnector(fn) {
@@ -81,7 +81,7 @@ async function createHandle(provider) {
81
81
  return { outcome: { outcome: 'cancelled' } };
82
82
  return b.onPermission(ctx.params);
83
83
  });
84
- const { conn, kill } = connector(provider, app);
84
+ const { conn, kill, stderr } = connector(provider, app);
85
85
  let init;
86
86
  try {
87
87
  init = await conn.agent.request('initialize', {
@@ -101,6 +101,12 @@ async function createHandle(provider) {
101
101
  // protocol mismatch) must not be leaked as a zombie process.
102
102
  kill();
103
103
  conn.close();
104
+ // The child's stderr is the only diagnostic a crash-at-boot leaves behind
105
+ // (e.g. Antigravity without --uid= aborts on "Group nobody not found");
106
+ // "connection closed" alone sends the user hunting in the wrong place.
107
+ const tail = stderr?.();
108
+ if (tail)
109
+ throw new Error(`${err?.message ?? err} — agent stderr: ${tail.slice(-1500)}`);
104
110
  throw err;
105
111
  }
106
112
  return { conn, init, binding, kill, lastUsed: Date.now() };
@@ -1 +1 @@
1
- {"version":3,"file":"acp_runner.d.ts","sourceRoot":"","sources":["../../src/harness/acp_runner.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAuFrE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAIrE;AAYD,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAE,YAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+OxF"}
1
+ {"version":3,"file":"acp_runner.d.ts","sourceRoot":"","sources":["../../src/harness/acp_runner.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAuFrE,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAIrE;AA+DD,wBAAsB,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,GAAE,YAAiB,GAAG,OAAO,CAAC,SAAS,CAAC,CA+OxF"}
@@ -104,6 +104,44 @@ function extractToolResultText(content) {
104
104
  .filter(Boolean)
105
105
  .join('\n');
106
106
  }
107
+ /** ACP `auth_required` (JSON-RPC -32000) on session/new. The agent owns the
108
+ * login flow (OAuth in the browser, device code, …): the client only picks a
109
+ * method and calls `authenticate`, then retries. Credentials persist on the
110
+ * agent's side, so this is a first-run affair. */
111
+ function isAuthRequired(err) {
112
+ return err?.code === -32000;
113
+ }
114
+ async function newSessionWithAuth(handle, params, provider, extras, cb) {
115
+ try {
116
+ return await handle.conn.agent.request('session/new', params);
117
+ }
118
+ catch (err) {
119
+ if (!isAuthRequired(err))
120
+ throw err;
121
+ const methods = handle.init.authMethods ?? [];
122
+ const names = methods.map((m) => `${m.id} (${m.name})`).join(', ') || 'none advertised';
123
+ if ((extras.mode ?? 'interactive') !== 'interactive') {
124
+ // Unattended: nobody is there to finish a browser login, and a pending
125
+ // OAuth would just burn the run's wall-clock budget.
126
+ throw new Error(`acp agent "${provider.name}" requires authentication (methods: ${names}) — run one interactive chat with it to log in first`);
127
+ }
128
+ const method = methods[0];
129
+ if (!method) {
130
+ throw new Error(`acp agent "${provider.name}" requires authentication but advertises no auth method — log in with the agent's own CLI first`);
131
+ }
132
+ // ponytail: the first advertised method is the agent's own default (what its
133
+ // CLI would pick); a per-provider override is the upgrade path when someone
134
+ // needs e.g. oauth-business over oauth-personal.
135
+ cb.onThinking?.(`Authentication required — starting "${method.name}" (${method.id}); the agent may open your browser. Available methods: ${names}.`);
136
+ try {
137
+ await handle.conn.agent.request('authenticate', { methodId: method.id });
138
+ }
139
+ catch (e) {
140
+ throw new Error(`acp authentication "${method.id}" failed for provider "${provider.name}": ${e?.message ?? e} (methods: ${names})`);
141
+ }
142
+ return await handle.conn.agent.request('session/new', params);
143
+ }
144
+ }
107
145
  export async function runAcp(opts, cb = {}) {
108
146
  const { agent, provider } = opts;
109
147
  const extras = opts.acp ?? {};
@@ -244,7 +282,7 @@ export async function runAcp(opts, cb = {}) {
244
282
  }
245
283
  }
246
284
  if (!acpSessionId) {
247
- const res = await handle.conn.agent.request('session/new', { cwd: workingDir, mcpServers });
285
+ const res = await newSessionWithAuth(handle, { cwd: workingDir, mcpServers }, provider, extras, cb);
248
286
  acpSessionId = res.sessionId;
249
287
  modes = res.modes;
250
288
  isNewSession = true;
@@ -165,11 +165,11 @@ function ProviderForm({ existingNames, initial, onSave, onCancel, }) {
165
165
  setSelfLoaded(chosen.selfLoadedContextFiles);
166
166
  if (chosen.dist?.env)
167
167
  setEnv(chosen.dist.env);
168
- // Prefill only — the user reviews command/args before saving (binary
169
- // presets have nothing to prefill: install from the web GUI or type the path).
170
- const prefill = chosen.dist && chosen.dist.kind !== 'binary' ? chosen.dist : null;
171
- setCommand(prefill ? prefill.command : '');
172
- setArgs(prefill ? prefill.args.join(' ') : '');
168
+ // Prefill only — the user reviews command/args before saving. A binary
169
+ // preset has no command yet (install from the web GUI or type the path) but
170
+ // its registry args still apply (Antigravity on Linux needs `--uid=`).
171
+ setCommand(chosen.dist && chosen.dist.kind !== 'binary' ? chosen.dist.command : '');
172
+ setArgs((chosen.dist?.args ?? []).join(' '));
173
173
  setStep('command');
174
174
  };
175
175
  const finalize = () => {
@@ -15968,13 +15968,8 @@ ${text}</tr>
15968
15968
  if (!preset || !preset.dist) return;
15969
15969
  setSelfLoaded(preset.selfLoadedContextFiles);
15970
15970
  setPresetEnv(preset.dist.env);
15971
- if (preset.dist.kind === "binary") {
15972
- setCommand("");
15973
- setArgs("");
15974
- } else {
15975
- setCommand(preset.dist.command);
15976
- setArgs(preset.dist.args.join(" "));
15977
- }
15971
+ setCommand(preset.dist.kind === "binary" ? "" : preset.dist.command);
15972
+ setArgs((preset.dist.args ?? []).join(" "));
15978
15973
  };
15979
15974
  const startEdit = (provider) => {
15980
15975
  setEditingProvider(provider);