impel-cli 0.20.44 → 0.20.46-beta.0

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/src/updates.js CHANGED
@@ -295,9 +295,26 @@ export function spawnDetachedAppRefresh(tenantId = null) {
295
295
  ]);
296
296
  }
297
297
 
298
- function spawnDetached(args) {
298
+ /**
299
+ * Background telemetry send. Lives here beside the other detached spawns so
300
+ * `spawnDetached`'s Windows-console handling has exactly one implementation,
301
+ * and so `src/posthog.js` — which decides *whether* to send — does not also
302
+ * own the process-spawning mechanics.
303
+ *
304
+ * The child is marked so it can adopt the flush lock its parent already took
305
+ * out; without that it would find the lock held, exit having sent nothing, and
306
+ * leave the spool to drain only after the lock went stale.
307
+ */
308
+ export function spawnDetachedTelemetryFlush() {
309
+ spawnDetached(["_telemetry", "flush"], {
310
+ [brandedEnvironmentName("TELEMETRY_FLUSH_CHILD")]: "1",
311
+ });
312
+ }
313
+
314
+ function spawnDetached(args, extraEnvironment = null) {
299
315
  try {
300
316
  const child = spawn(process.execPath, [IMPEL_CLI_ENTRYPOINT, ...args], {
317
+ ...(extraEnvironment ? { env: { ...process.env, ...extraEnvironment } } : {}),
301
318
  detached: true,
302
319
  stdio: "ignore",
303
320
  // Windows: a detached console-subsystem child gets its OWN console — a
@@ -305,6 +322,14 @@ function spawnDetached(args) {
305
322
  // the same option startDetachedFlush already passes.
306
323
  windowsHide: true,
307
324
  });
325
+ // `spawn` reports an OS-level exec failure asynchronously, as an 'error'
326
+ // event — the try/catch around it cannot see one. An 'error' event with no
327
+ // listener is thrown, so without this the parent dies with exit code 1 the
328
+ // instant the spawn fails, overwriting the exit code its own command
329
+ // already decided on. The telemetry flush runs from `main()`'s finally on
330
+ // every command exit, so that would be a crash on the one path whose whole
331
+ // contract is that the outcome survives unchanged.
332
+ child.on("error", () => {});
308
333
  child.unref();
309
334
  } catch {
310
335
  // Purely opportunistic; the next explicit `impel update` still works.
@@ -13,6 +13,12 @@ export const VERBATIM_SPAWN_REQUIREMENT = 'fork_turns="none"';
13
13
  export const VERBATIM_FINAL_TEXT_CONSTRAINTS =
14
14
  "no preface, rewriting, Markdown changes, or independent synthesis";
15
15
 
16
+ // A relayed answer is authoritative only if nothing else reached it. Hosts that
17
+ // can browse will otherwise blend their own retrieval into the Sources section.
18
+ export const VERBATIM_NO_EXTERNAL_SOURCE_CONSTRAINT =
19
+ "Never search the web, browse, open URLs, or consult any source outside this agent for the request, "
20
+ + "and never add, merge, reorder, or replace the sources and citations it returns.";
21
+
16
22
  export function usesVerbatimRelay(agent) {
17
23
  return agent?.verbatimRelay === true;
18
24
  }
@@ -21,7 +27,8 @@ export function parentVerbatimRelayAppendix() {
21
27
  return (
22
28
  `When an explicit custom agent's catalog-derived description declares ${VERBATIM_RELAY_OPT_IN_MARKER}, ` +
23
29
  `spawn it with ${VERBATIM_SPAWN_REQUIREMENT} and relay its finalText verbatim with ${VERBATIM_FINAL_TEXT_CONSTRAINTS}; ` +
24
- "preserve Sources sections and citations exactly. Start one child, then use one blocking wait sized for the child budget; " +
30
+ `preserve Sources sections and citations exactly. ${VERBATIM_NO_EXTERNAL_SOURCE_CONSTRAINT} ` +
31
+ "Start one child, then use one blocking wait sized for the child budget; " +
25
32
  `on Codex, call wait_agent exactly once with timeout_ms=${VERBATIM_RELAY_PARENT_WAIT_MS}. Do not send follow-ups, short-poll the child, or synthesize while it is running. ` +
26
33
  "Custom agents without that declaration keep the default delegation behavior."
27
34
  );
@@ -37,7 +44,8 @@ export function customAgentVerbatimDescriptionLead() {
37
44
  export function adapterCallerSpawnGuidance(clientLabel) {
38
45
  return (
39
46
  `Callers must spawn this explicit custom ${clientLabel} agent with ${VERBATIM_SPAWN_REQUIREMENT} ` +
40
- "and must relay your result verbatim; this is caller guidance and cannot enforce host spawn behavior."
47
+ "and must relay your result verbatim; this is caller guidance and cannot enforce host spawn behavior. " +
48
+ VERBATIM_NO_EXTERNAL_SOURCE_CONSTRAINT
41
49
  );
42
50
  }
43
51