@skydiveai/pi-extensions 0.1.258-beta.133 → 0.1.258-beta.134

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/dist/index.mjs +229 -109
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -265,7 +265,7 @@ function createHealthHandler({ metadata }) {
265
265
  const CAPABILITY_SOUL_NUDGE = "New capability gained — once the current task is done, if this changes what you can do for the user, record it in `soul.md` so it carries into future conversations rather than being rediscovered from scratch (then commit and push).";
266
266
  //#endregion
267
267
  //#region src/extensions/tool-call-summary.ts
268
- const log$21 = logger.child({ module: "tool-call-summary-extension" });
268
+ const log$22 = logger.child({ module: "tool-call-summary-extension" });
269
269
  /**
270
270
  * The injected parameter name. Deliberately markdown-safe: the previous wire
271
271
  * name (`__skydive_summary__`, now `TOOL_CALL_SUMMARY_FIELD_LEGACY`) carried
@@ -499,7 +499,7 @@ function withSummaryStrippedBeforeValidation(tool) {
499
499
  try {
500
500
  stripped = withoutInjectedSummary(args);
501
501
  } catch (err) {
502
- log$21.error({
502
+ log$22.error({
503
503
  err,
504
504
  event: "tool_call_summary_prepare_strip_failed",
505
505
  toolName: tool.name
@@ -530,7 +530,7 @@ function stripInjectedSummary(pi, toolName, input) {
530
530
  if (toolDeclaresSummaryParam(pi, toolName)) return;
531
531
  for (const field of TOOL_CALL_SUMMARY_FIELDS) delete input[field];
532
532
  } catch (err) {
533
- log$21.error({
533
+ log$22.error({
534
534
  err,
535
535
  event: "tool_call_summary_strip_failed",
536
536
  toolName
@@ -546,7 +546,7 @@ function buildInjectedPayload(pi, payload) {
546
546
  try {
547
547
  return injectToolCallSummary(payload, getStrictToolNames(pi));
548
548
  } catch (err) {
549
- log$21.error({
549
+ log$22.error({
550
550
  err,
551
551
  event: "tool_call_summary_injection_failed"
552
552
  }, "tool_call_summary injection failed; passing payload through unchanged");
@@ -565,7 +565,7 @@ const toolCallSummaryExtension = (pi) => {
565
565
  pi.registerTool(withSummaryStrippedBeforeValidation(createEditToolDefinition(ctx.cwd)));
566
566
  editOverrideRegistered = true;
567
567
  } catch (err) {
568
- log$21.error({
568
+ log$22.error({
569
569
  err,
570
570
  event: "tool_call_summary_edit_override_failed"
571
571
  }, "failed to register summary-tolerant edit tool; built-in remains active");
@@ -596,7 +596,7 @@ const toolCallSummaryExtension = (pi) => {
596
596
  * or `ToolDefinition[]`. Files starting with `_` or `.` are skipped, so
597
597
  * `tools/_example.ts` documents the shape without registering.
598
598
  */
599
- const log$20 = logger.child({ module: "local-tools-extension" });
599
+ const log$21 = logger.child({ module: "local-tools-extension" });
600
600
  const TOOLS_DIRNAME = "tools";
601
601
  const fileState = /* @__PURE__ */ new Map();
602
602
  let pendingLocalToolsUpdate = null;
@@ -740,7 +740,7 @@ async function reconcileAndQueue({ pi, dir, reason }) {
740
740
  dir
741
741
  });
742
742
  if (reason !== "session_start" && summaryHasChanges$1(summary)) pendingLocalToolsUpdate = summary;
743
- log$20.info({
743
+ log$21.info({
744
744
  event: "local_tools_reconcile",
745
745
  reason,
746
746
  total_tools: summary.totalTools,
@@ -762,7 +762,7 @@ const localToolsExtension = (pi) => {
762
762
  reason: "session_start"
763
763
  });
764
764
  } catch (err) {
765
- log$20.error({
765
+ log$21.error({
766
766
  err,
767
767
  event: "local_tools_reconcile_failed"
768
768
  }, "local tools reconcile failed");
@@ -774,7 +774,7 @@ const localToolsExtension = (pi) => {
774
774
  try {
775
775
  current = await listToolFiles(dir);
776
776
  } catch (err) {
777
- log$20.warn({
777
+ log$21.warn({
778
778
  err,
779
779
  event: "local_tools_listing_failed"
780
780
  }, "tools/ listing failed");
@@ -796,7 +796,7 @@ const localToolsExtension = (pi) => {
796
796
  reason: "auto_reload"
797
797
  });
798
798
  } catch (err) {
799
- log$20.error({
799
+ log$21.error({
800
800
  err,
801
801
  event: "local_tools_auto_reload_failed"
802
802
  }, "auto-reload after tools/ change failed");
@@ -1500,7 +1500,7 @@ function toProviderSafeSchema(inputSchema) {
1500
1500
  * Clients are keyed by JSON-stringified config and reused across
1501
1501
  * reloads — only changed configs reconnect.
1502
1502
  */
1503
- const log$19 = logger.child({ module: "mcp-extension" });
1503
+ const log$20 = logger.child({ module: "mcp-extension" });
1504
1504
  function resolveToolSelection(server) {
1505
1505
  return {
1506
1506
  allow: server?.tools?.length ? new Set(server.tools) : null,
@@ -1698,7 +1698,7 @@ function providerSafeTools({ serverId, tools }) {
1698
1698
  for (const tool of tools) {
1699
1699
  const result = toProviderSafeSchema(tool.inputSchema);
1700
1700
  if (!result.ok) {
1701
- log$19.warn({
1701
+ log$20.warn({
1702
1702
  event: "mcp_tool_schema_unsupported",
1703
1703
  server_id: serverId,
1704
1704
  tool_name: tool.name,
@@ -2172,7 +2172,7 @@ var McpExtension = class {
2172
2172
  });
2173
2173
  this.lastConfigMtimeMs = await readConfigMtimeMs(configPath);
2174
2174
  if (reason !== "session_start" && summaryHasChanges(summary)) this.pendingMcpUpdate = summary;
2175
- log$19.info({
2175
+ log$20.info({
2176
2176
  event: "mcp_reconcile",
2177
2177
  reason,
2178
2178
  total_tools: summary.totalTools,
@@ -2199,7 +2199,7 @@ var McpExtension = class {
2199
2199
  contextWindow: ctx.model?.contextWindow
2200
2200
  });
2201
2201
  } catch (err) {
2202
- log$19.error({
2202
+ log$20.error({
2203
2203
  err,
2204
2204
  event: "mcp_reconcile_failed"
2205
2205
  }, "MCP reconcile failed");
@@ -2213,7 +2213,7 @@ var McpExtension = class {
2213
2213
  for (const legacy of renamed) {
2214
2214
  if (this.loggedLegacyToolNames.has(legacy)) continue;
2215
2215
  this.loggedLegacyToolNames.add(legacy);
2216
- log$19.info({
2216
+ log$20.info({
2217
2217
  event: "mcp_tool_legacy_name",
2218
2218
  legacy_name: legacy,
2219
2219
  tool_name: this.legacyToolNames.get(legacy)
@@ -2227,7 +2227,7 @@ var McpExtension = class {
2227
2227
  try {
2228
2228
  mtime = await readConfigMtimeMs(configPath);
2229
2229
  } catch (err) {
2230
- log$19.warn({
2230
+ log$20.warn({
2231
2231
  err,
2232
2232
  event: "mcp_mtime_check_failed"
2233
2233
  }, "mtime check on mcp.config.json failed");
@@ -2242,7 +2242,7 @@ var McpExtension = class {
2242
2242
  contextWindow: ctx.model?.contextWindow
2243
2243
  });
2244
2244
  } catch (err) {
2245
- log$19.error({
2245
+ log$20.error({
2246
2246
  err,
2247
2247
  event: "mcp_auto_reload_failed"
2248
2248
  }, "auto-reload after mcp.config.json change failed");
@@ -2989,7 +2989,7 @@ const SEAT_QUERY_TIMEOUTS = {
2989
2989
  preparation: 3e4
2990
2990
  };
2991
2991
  const PI_TOOLS_SERVER = "custom-tools";
2992
- const log$18 = logger.child({ module: "claude-seat-sdk" });
2992
+ const log$19 = logger.child({ module: "claude-seat-sdk" });
2993
2993
  /** Preserve existing MCP names; only ordinary Pi tools need a server prefix. */
2994
2994
  function toolBindings(context) {
2995
2995
  const parsed = (context.tools ?? []).map((definition) => {
@@ -3047,7 +3047,7 @@ var SeatQuery = class {
3047
3047
  this.deadline = setTimeout(() => {
3048
3048
  const err = /* @__PURE__ */ new Error(`Claude seat SDK timed out waiting for ${phase}`);
3049
3049
  err.name = "TimeoutError";
3050
- log$18.error({
3050
+ log$19.error({
3051
3051
  err,
3052
3052
  phase
3053
3053
  }, "Claude seat SDK wait deadline exceeded");
@@ -3228,7 +3228,7 @@ var SeatQuery = class {
3228
3228
  }
3229
3229
  } catch (err) {
3230
3230
  this.failure = err;
3231
- if (!this.controller.signal.aborted) log$18.error({
3231
+ if (!this.controller.signal.aborted) log$19.error({
3232
3232
  err,
3233
3233
  sessionId
3234
3234
  }, "Claude seat SDK query failed");
@@ -3243,7 +3243,7 @@ var SeatQuery = class {
3243
3243
  force: true
3244
3244
  });
3245
3245
  } catch (err) {
3246
- log$18.error({
3246
+ log$19.error({
3247
3247
  err,
3248
3248
  sessionId
3249
3249
  }, "Could not remove Claude seat SDK config");
@@ -3276,7 +3276,7 @@ function mapUsage(usage) {
3276
3276
  //#endregion
3277
3277
  //#region src/extensions/claude-seat-response.ts
3278
3278
  const toolInput = z.record(z.string(), z.unknown());
3279
- const log$17 = logger.child({ module: "claude-seat-sdk" });
3279
+ const log$18 = logger.child({ module: "claude-seat-sdk" });
3280
3280
  /**
3281
3281
  * Claude sometimes calls a tool by the name it had outside the bridge (Pi's
3282
3282
  * own name from non-seat history, or a bare MCP tool name). Resolve those when
@@ -3290,7 +3290,7 @@ function piToolName({ name, context, sessionId }) {
3290
3290
  const bare = bindings.filter((binding) => binding.toolName === name);
3291
3291
  const [only] = bare;
3292
3292
  if (only && bare.length === 1) return only.definition.name;
3293
- log$17.warn({
3293
+ log$18.warn({
3294
3294
  sessionId,
3295
3295
  toolName: name,
3296
3296
  candidates: bare.length
@@ -3481,7 +3481,7 @@ var ModelResponse = class {
3481
3481
  * each step resumes a private structured snapshot after Pi extensions run.
3482
3482
  * Initially adapted from elidickinson/pi-claude-bridge (MIT).
3483
3483
  */
3484
- const log$16 = logger.child({ module: "claude-seat-sdk" });
3484
+ const log$17 = logger.child({ module: "claude-seat-sdk" });
3485
3485
  const SEAT_SDK_ACTIVITY_EVENT = "claude-seat-sdk:activity";
3486
3486
  /** Session-scoped adapter; only the flagged provider dispatches here. */
3487
3487
  var SeatSdkBridge = class {
@@ -3532,7 +3532,7 @@ var SeatSdkBridge = class {
3532
3532
  } else if (message.type === "result") {
3533
3533
  const hasTools = response.hasTools;
3534
3534
  if (message.is_error && !(message.subtype === "error_max_turns" && hasTools)) throw new Error("errors" in message ? message.errors.join("; ") : message.result);
3535
- log$16.info({
3535
+ log$17.info({
3536
3536
  sessionId: this.deps.sessionId,
3537
3537
  queryUsage: mapUsage(message.usage),
3538
3538
  requestUsage: response.message.usage
@@ -3553,7 +3553,7 @@ var SeatSdkBridge = class {
3553
3553
  }
3554
3554
  } catch (err) {
3555
3555
  const reason = (seatQuery?.controller.signal.aborted || signal.aborted) && !(err instanceof Error && err.name === "TimeoutError") ? "aborted" : "error";
3556
- if (reason === "error") log$16.error({
3556
+ if (reason === "error") log$17.error({
3557
3557
  err,
3558
3558
  sessionId: this.deps.sessionId
3559
3559
  }, "Claude seat SDK response failed");
@@ -3624,7 +3624,7 @@ const HEARTBEAT_THROTTLE_MS = 6e4;
3624
3624
  const TOOL_HEARTBEAT_INTERVAL_MS = 5e3;
3625
3625
  const MAX_TOOL_HEARTBEATS = 1440 * 60 * 1e3 / TOOL_HEARTBEAT_INTERVAL_MS;
3626
3626
  const DAEMON_URL = "http://localhost:38994";
3627
- const log$15 = logger.child({ module: "platform-ext" });
3627
+ const log$16 = logger.child({ module: "platform-ext" });
3628
3628
  function sandboxClient() {
3629
3629
  const apiUrl = apiBaseUrl();
3630
3630
  if (!apiUrl) return null;
@@ -3692,7 +3692,7 @@ async function fetchHarnessFlags() {
3692
3692
  try {
3693
3693
  const res = await client["feature-flags"].$get();
3694
3694
  if (!res.ok) {
3695
- log$15.debug({
3695
+ log$16.debug({
3696
3696
  status: res.status,
3697
3697
  event: "feature_flags_fetch_failed"
3698
3698
  }, "feature-flags fetch failed");
@@ -3704,7 +3704,7 @@ async function fetchHarnessFlags() {
3704
3704
  closingText: body.closingText ?? null
3705
3705
  };
3706
3706
  } catch (err) {
3707
- log$15.debug({
3707
+ log$16.debug({
3708
3708
  err,
3709
3709
  event: "feature_flags_fetch_error"
3710
3710
  }, "feature-flags request errored");
@@ -3715,7 +3715,7 @@ function postHeartbeat({ messageId }) {
3715
3715
  const client = sandboxClient();
3716
3716
  if (!client) return;
3717
3717
  client.heartbeat.$post({ json: { messageId } }).catch((err) => {
3718
- log$15.debug({
3718
+ log$16.debug({
3719
3719
  err,
3720
3720
  event: "heartbeat_failed"
3721
3721
  }, "heartbeat failed");
@@ -3727,7 +3727,7 @@ async function resolveConversationFromApi(messageId) {
3727
3727
  try {
3728
3728
  const res = await client["message-conversation"].$get({ query: { messageId } });
3729
3729
  if (!res.ok) {
3730
- log$15.warn({
3730
+ log$16.warn({
3731
3731
  status: res.status,
3732
3732
  messageId,
3733
3733
  event: "resolve_conversation_failed"
@@ -3736,7 +3736,7 @@ async function resolveConversationFromApi(messageId) {
3736
3736
  }
3737
3737
  return (await res.json()).conversationId ?? null;
3738
3738
  } catch (err) {
3739
- log$15.warn({
3739
+ log$16.warn({
3740
3740
  err,
3741
3741
  messageId,
3742
3742
  event: "resolve_conversation_error"
@@ -3761,13 +3761,13 @@ async function putBackgroundTaskJournalSpec({ messageId, spec }) {
3761
3761
  messageId,
3762
3762
  spec
3763
3763
  } });
3764
- if (!res.ok) log$15.warn({
3764
+ if (!res.ok) log$16.warn({
3765
3765
  status: res.status,
3766
3766
  taskId: spec.id,
3767
3767
  event: "bg_journal_put_failed"
3768
3768
  }, "bg-task journal PUT failed");
3769
3769
  } catch (err) {
3770
- log$15.warn({
3770
+ log$16.warn({
3771
3771
  err,
3772
3772
  taskId: spec.id,
3773
3773
  event: "bg_journal_put_failed"
@@ -3783,7 +3783,7 @@ async function deleteBackgroundTaskJournalSpec({ messageId, taskId }) {
3783
3783
  taskId
3784
3784
  } });
3785
3785
  } catch (err) {
3786
- log$15.debug({
3786
+ log$16.debug({
3787
3787
  err,
3788
3788
  taskId,
3789
3789
  event: "bg_journal_delete_failed"
@@ -3798,7 +3798,7 @@ async function listBackgroundTaskJournalSpecs({ messageId }) {
3798
3798
  if (!res.ok) return [];
3799
3799
  return (await res.json()).specs ?? [];
3800
3800
  } catch (err) {
3801
- log$15.debug({
3801
+ log$16.debug({
3802
3802
  err,
3803
3803
  event: "bg_journal_list_failed"
3804
3804
  }, "bg-task journal GET failed");
@@ -3812,7 +3812,7 @@ function postBackgroundTasksSnapshot({ messageId, tasks }) {
3812
3812
  messageId,
3813
3813
  tasks
3814
3814
  } }).catch((err) => {
3815
- log$15.debug({
3815
+ log$16.debug({
3816
3816
  err,
3817
3817
  event: "bg_tasks_snapshot_failed"
3818
3818
  }, "bg-tasks snapshot publish failed");
@@ -3910,7 +3910,7 @@ function createToolHeartbeat({ messageId }) {
3910
3910
  }
3911
3911
  heartbeatCount++;
3912
3912
  if (heartbeatCount > MAX_TOOL_HEARTBEATS) {
3913
- log$15.warn({
3913
+ log$16.warn({
3914
3914
  heartbeatCount,
3915
3915
  activeToolCalls: [...activeToolCalls]
3916
3916
  }, "tool heartbeat max reached, stopping");
@@ -3941,7 +3941,7 @@ function postToDaemon(path, body) {
3941
3941
  headers: { "content-type": "application/json" },
3942
3942
  body: JSON.stringify(body)
3943
3943
  }).catch((err) => {
3944
- log$15.debug({
3944
+ log$16.debug({
3945
3945
  err,
3946
3946
  path,
3947
3947
  event: "daemon_post_failed"
@@ -3950,7 +3950,7 @@ function postToDaemon(path, body) {
3950
3950
  }
3951
3951
  function createPlatformExtensions({ sessionId, channelContext }) {
3952
3952
  return (pi) => {
3953
- log$15.info({
3953
+ log$16.info({
3954
3954
  sessionId,
3955
3955
  hasChannelContext: Boolean(channelContext)
3956
3956
  }, "platform extension initialized");
@@ -4004,7 +4004,7 @@ function createPlatformExtensions({ sessionId, channelContext }) {
4004
4004
  });
4005
4005
  });
4006
4006
  pi.on("agent_end", () => {
4007
- log$15.info({ sessionId }, "session ending");
4007
+ log$16.info({ sessionId }, "session ending");
4008
4008
  postToDaemon("/session/end", { sessionId });
4009
4009
  });
4010
4010
  };
@@ -4148,7 +4148,7 @@ function createOomNeutralBashOperations({ shellPath }) {
4148
4148
  * semantics; once promoted, the command inherits background-task lifecycle
4149
4149
  * (its own controller) and the foreground kill timeout no longer applies.
4150
4150
  */
4151
- const log$14 = logger.child({ module: "background-tasks-ext" });
4151
+ const log$15 = logger.child({ module: "background-tasks-ext" });
4152
4152
  const ops = createOomNeutralBashOperations({ shellPath: void 0 });
4153
4153
  const STEER_BACKGROUND_DEFAULT_SECONDS = 60;
4154
4154
  const STEER_BACKGROUND_ENV_KEYS = ["BASH_STEER_BACKGROUND_SECONDS", "SKYDIVE_BASH_STEER_BACKGROUND_SECONDS"];
@@ -4163,7 +4163,7 @@ function steerBackgroundThresholdMs() {
4163
4163
  if (raw === void 0 || raw.trim() === "") continue;
4164
4164
  const parsed = Number(raw);
4165
4165
  if (!Number.isFinite(parsed) || parsed < 0) {
4166
- log$14.warn({
4166
+ log$15.warn({
4167
4167
  envKey: key,
4168
4168
  raw
4169
4169
  }, "invalid BASH_STEER_BACKGROUND_SECONDS, using default");
@@ -4192,7 +4192,7 @@ async function notifyBashSteerArrival(args) {
4192
4192
  try {
4193
4193
  await listener();
4194
4194
  } catch (err) {
4195
- log$14.error({
4195
+ log$15.error({
4196
4196
  err,
4197
4197
  sessionId: args.sessionId
4198
4198
  }, "bash steer promotion failed");
@@ -4287,14 +4287,14 @@ function watchdogTick(now) {
4287
4287
  const overSize = meta.logBytes > MAX_LOG_BYTES;
4288
4288
  if (!overRuntime && !overSize) continue;
4289
4289
  const reason = overSize ? `output exceeded ${MAX_LOG_BYTES / (1024 * 1024)}MiB` : `exceeded ${KEEPALIVE_MAX_MS / 6e4}m max runtime`;
4290
- log$14.warn({
4290
+ log$15.warn({
4291
4291
  taskId: meta.id,
4292
4292
  reason
4293
4293
  }, "watchdog killing bg task");
4294
4294
  try {
4295
4295
  killTask(meta, reason);
4296
4296
  } catch (err) {
4297
- log$14.warn({
4297
+ log$15.warn({
4298
4298
  err,
4299
4299
  taskId: meta.id
4300
4300
  }, "watchdog kill failed");
@@ -4353,7 +4353,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
4353
4353
  const now = Date.now();
4354
4354
  const promotable = [...foregroundBash.values()].filter((call) => now - call.startedAt >= thresholdMs);
4355
4355
  if (promotable.length === 0) return;
4356
- log$14.info({
4356
+ log$15.info({
4357
4357
  event: "bash_steer_promotion",
4358
4358
  count: promotable.length,
4359
4359
  thresholdSeconds: Math.round(thresholdMs / 1e3),
@@ -4378,7 +4378,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
4378
4378
  try {
4379
4379
  await mkdir(tasksDir(), { recursive: true });
4380
4380
  } catch (err) {
4381
- log$14.error({ err }, "bg task adopt: mkdir failed");
4381
+ log$15.error({ err }, "bg task adopt: mkdir failed");
4382
4382
  }
4383
4383
  const logStream = createWriteStream(logPath(id), { flags: "a" });
4384
4384
  logStream.on("error", () => {});
@@ -4405,7 +4405,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
4405
4405
  tasks.set(id, meta);
4406
4406
  ensureWatchdog();
4407
4407
  schedulePublishSnapshot();
4408
- log$14.info({
4408
+ log$15.info({
4409
4409
  taskId: id,
4410
4410
  conversationId,
4411
4411
  startedAt: args.startedAt
@@ -4558,7 +4558,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
4558
4558
  try {
4559
4559
  shellPath = SettingsManager.create(ctx.cwd, getAgentDir()).getShellPath();
4560
4560
  } catch (err) {
4561
- log$14.warn({
4561
+ log$15.warn({
4562
4562
  err,
4563
4563
  cwd: ctx.cwd
4564
4564
  }, "bash steer promotion: shell settings unavailable, using default shell");
@@ -4573,7 +4573,7 @@ function createBackgroundTasksExtension({ channelContext, sessionId }) {
4573
4573
  ...definition,
4574
4574
  description: `${definition.description}\n\nLong-running bash commands are automatically moved to a background task when a new message arrives while the command has already been running for at least a minute: you get the task id immediately, are woken on completion, and must not depend on the command's output until that wake arrives. Shorter commands finish in the foreground like they always have.`
4575
4575
  });
4576
- log$14.info({
4576
+ log$15.info({
4577
4577
  event: "bash_steer_promotion_enabled",
4578
4578
  thresholdSeconds: Math.round(thresholdMs / 1e3)
4579
4579
  }, "supervised bash tool registered (steer-triggered backgrounding)");
@@ -4616,7 +4616,7 @@ or if you were explicitly waiting to report it.`,
4616
4616
  triggerTurn: true,
4617
4617
  deliverAs: "followUp"
4618
4618
  });
4619
- log$14.info({
4619
+ log$15.info({
4620
4620
  taskId: meta.id,
4621
4621
  conversationId
4622
4622
  }, "bg task completion delivered live (followUp)");
@@ -4624,7 +4624,7 @@ or if you were explicitly waiting to report it.`,
4624
4624
  }
4625
4625
  if (meta.messageId) {
4626
4626
  meta.notified = true;
4627
- log$14.info({
4627
+ log$15.info({
4628
4628
  taskId: meta.id,
4629
4629
  messageId: meta.messageId
4630
4630
  }, "posting idle bg-task-done wake");
@@ -4634,12 +4634,12 @@ or if you were explicitly waiting to report it.`,
4634
4634
  content: message.content
4635
4635
  }).catch((err) => {
4636
4636
  meta.notified = false;
4637
- log$14.warn({
4637
+ log$15.warn({
4638
4638
  err,
4639
4639
  taskId: meta.id
4640
4640
  }, "bg-task-done wake failed; will retry at next session_start");
4641
4641
  });
4642
- } else log$14.info({ taskId: meta.id }, "bg task completed idle with no origin message; deferring to next session_start");
4642
+ } else log$15.info({ taskId: meta.id }, "bg task completed idle with no origin message; deferring to next session_start");
4643
4643
  }
4644
4644
  const SNAPSHOT_TAIL_LINES = 40;
4645
4645
  let lastPublishedSignature = null;
@@ -4676,7 +4676,7 @@ or if you were explicitly waiting to report it.`,
4676
4676
  tasks: snapshot
4677
4677
  });
4678
4678
  } catch (err) {
4679
- log$14.debug({
4679
+ log$15.debug({
4680
4680
  err,
4681
4681
  event: "bg_tasks_snapshot_build_failed"
4682
4682
  }, "building bg-tasks snapshot failed");
@@ -4719,7 +4719,7 @@ or if you were explicitly waiting to report it.`,
4719
4719
  logStream.end();
4720
4720
  await finished(logStream).catch(() => {});
4721
4721
  meta.running = false;
4722
- log$14.info({
4722
+ log$15.info({
4723
4723
  taskId: meta.id,
4724
4724
  exitCode: meta.exitCode
4725
4725
  }, "bg task finished");
@@ -4736,14 +4736,14 @@ or if you were explicitly waiting to report it.`,
4736
4736
  try {
4737
4737
  await mkdir(tasksDir(), { recursive: true });
4738
4738
  } catch (err) {
4739
- log$14.error({
4739
+ log$15.error({
4740
4740
  err,
4741
4741
  taskId: id
4742
4742
  }, "background task dir unavailable");
4743
4743
  }
4744
4744
  const logStream = createWriteStream(logPath(id), { flags: "a" });
4745
4745
  logStream.on("error", (err) => {
4746
- log$14.warn({
4746
+ log$15.warn({
4747
4747
  err,
4748
4748
  taskId: id
4749
4749
  }, "bg task log write failed");
@@ -4793,7 +4793,7 @@ or if you were explicitly waiting to report it.`,
4793
4793
  }).catch((err) => {
4794
4794
  if (!meta.controller.signal.aborted) {
4795
4795
  meta.error = err instanceof Error ? err.message : String(err);
4796
- log$14.warn({
4796
+ log$15.warn({
4797
4797
  err,
4798
4798
  taskId: id
4799
4799
  }, "bg task exec error");
@@ -4802,7 +4802,7 @@ or if you were explicitly waiting to report it.`,
4802
4802
  await finishTask(meta, logStream);
4803
4803
  });
4804
4804
  ensureWatchdog();
4805
- log$14.info({
4805
+ log$15.info({
4806
4806
  taskId: id,
4807
4807
  conversationId
4808
4808
  }, "bg task started");
@@ -4821,7 +4821,7 @@ or if you were explicitly waiting to report it.`,
4821
4821
  for (const spec of specs) {
4822
4822
  const live = tasks.get(spec.id);
4823
4823
  if (live && sameScope(live, scopeKey())) continue;
4824
- log$14.info({
4824
+ log$15.info({
4825
4825
  taskId: spec.id,
4826
4826
  conversationId
4827
4827
  }, "relaunching journaled resumable bg task after restart");
@@ -4839,7 +4839,7 @@ or if you were explicitly waiting to report it.`,
4839
4839
  stream.write(`<resumed-after-restart>requeued and relaunched on a new sandbox after the previous one was drained; this is a fresh execution of the command from the start, not a continuation</resumed-after-restart>\n`);
4840
4840
  stream.end();
4841
4841
  } catch (err) {
4842
- log$14.debug({
4842
+ log$15.debug({
4843
4843
  err,
4844
4844
  taskId: meta.id
4845
4845
  }, "resume banner write failed");
@@ -4859,7 +4859,7 @@ or if you were explicitly waiting to report it.`,
4859
4859
  meta.notified = true;
4860
4860
  pi.sendMessage(await taskDoneMessage(meta));
4861
4861
  }
4862
- if (unnotified.length > 0) log$14.info({
4862
+ if (unnotified.length > 0) log$15.info({
4863
4863
  conversationId,
4864
4864
  count: unnotified.length
4865
4865
  }, "injected completed bg tasks at session_start");
@@ -5054,7 +5054,7 @@ or if you were explicitly waiting to report it.`,
5054
5054
  * read on the hot path before every LLM call), it falls back to the default
5055
5055
  * for that knob and logs once.
5056
5056
  */
5057
- const log$13 = logger.child({ module: "context-management-config" });
5057
+ const log$14 = logger.child({ module: "context-management-config" });
5058
5058
  const DEFAULT_CONTEXT_MANAGEMENT_CONFIG = {
5059
5059
  enabled: false,
5060
5060
  perResultMaxBytes: 16 * 1024,
@@ -5099,7 +5099,7 @@ function resolveContextManagementConfig(env = process.env) {
5099
5099
  clearAtLeastTokens: env.SKYDIVE_CTX_CLEAR_AT_LEAST_TOKENS
5100
5100
  });
5101
5101
  if (!parsed.success) {
5102
- log$13.warn({
5102
+ log$14.warn({
5103
5103
  event: "context_management_config_invalid",
5104
5104
  err: parsed.error
5105
5105
  }, "falling back to default context-management config");
@@ -5183,7 +5183,7 @@ function hasFlagSource(env = process.env) {
5183
5183
  * alive and an indeterminate result (no api url / transient failure) leaves the
5184
5184
  * last-known values untouched so a blip can't silently flip behavior.
5185
5185
  */
5186
- const log$12 = logger.child({ module: "feature-flags-poll" });
5186
+ const log$13 = logger.child({ module: "feature-flags-poll" });
5187
5187
  const FLAG_POLL_INTERVAL_MS = 6e4;
5188
5188
  let contextManagement = null;
5189
5189
  let closingText = null;
@@ -5223,7 +5223,7 @@ function apply(name, next) {
5223
5223
  if (next !== prev) for (const cb of subscribers[name]) try {
5224
5224
  cb(next);
5225
5225
  } catch (err) {
5226
- log$12.warn({
5226
+ log$13.warn({
5227
5227
  err,
5228
5228
  flag: name
5229
5229
  }, "flag subscriber threw");
@@ -5236,7 +5236,7 @@ async function pollOnce() {
5236
5236
  apply("contextManagement", flags.contextManagement ?? null);
5237
5237
  apply("closingText", flags.closingText ?? null);
5238
5238
  } catch (err) {
5239
- log$12.debug({ err }, "feature-flag poll threw");
5239
+ log$13.debug({ err }, "feature-flag poll threw");
5240
5240
  }
5241
5241
  }
5242
5242
  /**
@@ -5437,8 +5437,8 @@ const bashDefaultTimeoutExtension = (pi) => {
5437
5437
  * stat and the extension warns on what it can see — it must never break a
5438
5438
  * turn over an observability feature.
5439
5439
  */
5440
- const execFileAsync = promisify(execFile);
5441
- const log$11 = logger.child({ module: "resource-pressure-warning" });
5440
+ const execFileAsync$1 = promisify(execFile);
5441
+ const log$12 = logger.child({ module: "resource-pressure-warning" });
5442
5442
  const POLL_INTERVAL_MS = 1e4;
5443
5443
  function envOverride(name) {
5444
5444
  for (const prefix of ["SKYDIVE_", "ANYONE_"]) {
@@ -5506,7 +5506,7 @@ async function readMemUsePct() {
5506
5506
  */
5507
5507
  async function readDiskUsePct() {
5508
5508
  try {
5509
- const { stdout } = await execFileAsync("df", ["-P", diskRoot()]);
5509
+ const { stdout } = await execFileAsync$1("df", ["-P", diskRoot()]);
5510
5510
  const dataRow = stdout.trim().split("\n")[1];
5511
5511
  if (dataRow == null) return null;
5512
5512
  const capacity = dataRow.trim().split(/\s+/)[4];
@@ -5635,7 +5635,7 @@ const resourcePressureWarningExtension = (pi) => {
5635
5635
  warnedDiskThisTurn = true;
5636
5636
  }
5637
5637
  if (trigger === null) return;
5638
- log$11.warn({
5638
+ log$12.warn({
5639
5639
  trigger,
5640
5640
  mem,
5641
5641
  cpuPct,
@@ -5673,7 +5673,7 @@ const resourcePressureWarningExtension = (pi) => {
5673
5673
  if (!timer) {
5674
5674
  timer = setInterval(() => {
5675
5675
  checkOnce().catch((err) => {
5676
- log$11.error({ err }, "resource pressure check failed");
5676
+ log$12.error({ err }, "resource pressure check failed");
5677
5677
  });
5678
5678
  }, POLL_INTERVAL_MS);
5679
5679
  timer.unref?.();
@@ -5689,7 +5689,7 @@ const resourcePressureWarningExtension = (pi) => {
5689
5689
  };
5690
5690
  //#endregion
5691
5691
  //#region src/extensions/disk-guard.ts
5692
- const log$10 = logger.child({ module: "disk-guard" });
5692
+ const log$11 = logger.child({ module: "disk-guard" });
5693
5693
  /**
5694
5694
  * In-band bypass. The guard is a safety net, not a jail: when the agent knows
5695
5695
  * a flagged command is genuinely safe (writing to a different mount, a tiny
@@ -5829,7 +5829,7 @@ const diskGuardExtension = (pi) => {
5829
5829
  if (!isSpaceHungryCommand(command)) return;
5830
5830
  const diskPct = await readDiskUsePct();
5831
5831
  if (!shouldBlockForDisk(command, diskPct)) return;
5832
- log$10.warn({
5832
+ log$11.warn({
5833
5833
  diskPct,
5834
5834
  command: command.slice(0, 200)
5835
5835
  }, "blocked space-hungry bash command on near-full disk");
@@ -5841,7 +5841,7 @@ const diskGuardExtension = (pi) => {
5841
5841
  };
5842
5842
  //#endregion
5843
5843
  //#region src/extensions/noop-loop-guard.ts
5844
- const log$9 = logger.child({ module: "noop-loop-guard" });
5844
+ const log$10 = logger.child({ module: "noop-loop-guard" });
5845
5845
  /** Length of the rolling window that counts silence commands across streak resets. */
5846
5846
  const SILENCE_WINDOW_MS = 300 * 1e3;
5847
5847
  /** Bare shell no-op: `true` or `:` (case-insensitive). */
@@ -5996,7 +5996,7 @@ const noopLoopGuardExtension = (pi) => {
5996
5996
  if (bypassed) return;
5997
5997
  if (streak < 3 && windowCount < 8) return;
5998
5998
  const aborted = streak >= 25 || windowCount >= 40;
5999
- log$9.warn({
5999
+ log$10.warn({
6000
6000
  streak,
6001
6001
  windowCount,
6002
6002
  aborted,
@@ -6015,7 +6015,7 @@ const noopLoopGuardExtension = (pi) => {
6015
6015
  };
6016
6016
  //#endregion
6017
6017
  //#region src/extensions/repeat-call-guard.ts
6018
- const log$8 = logger.child({ module: "repeat-call-guard" });
6018
+ const log$9 = logger.child({ module: "repeat-call-guard" });
6019
6019
  const KILL_SWITCH_KEYS = ["REPEAT_CALL_GUARD_DISABLE", "SKYDIVE_REPEAT_CALL_GUARD_DISABLE"];
6020
6020
  function guardDisabledByEnv$1() {
6021
6021
  return KILL_SWITCH_KEYS.some((key) => {
@@ -6060,7 +6060,7 @@ const repeatCallGuardExtension = (pi) => {
6060
6060
  }));
6061
6061
  if (streak < 20) return;
6062
6062
  const aborted = streak >= 40;
6063
- log$8.warn({
6063
+ log$9.warn({
6064
6064
  toolName: event.toolName,
6065
6065
  streak,
6066
6066
  aborted,
@@ -6127,7 +6127,7 @@ const repeatCallGuardExtension = (pi) => {
6127
6127
  * embedding a script).
6128
6128
  */
6129
6129
  const execFileP = promisify(execFile);
6130
- const log$7 = logger.child({ module: "sleep-guard" });
6130
+ const log$8 = logger.child({ module: "sleep-guard" });
6131
6131
  /** How long the `platform automation create` call may take before we fall back to guidance. */
6132
6132
  const SCHEDULE_TIMEOUT_MS = 15e3;
6133
6133
  /** Title for the one-shot wakes this guard schedules. Visible in the Routines UI. */
@@ -6371,7 +6371,7 @@ async function scheduleSleepWake(seconds, ledger) {
6371
6371
  ], { timeout: SCHEDULE_TIMEOUT_MS });
6372
6372
  return at;
6373
6373
  } catch (err) {
6374
- log$7.warn({ err }, "failed to auto-schedule sleep wake; falling back to guidance");
6374
+ log$8.warn({ err }, "failed to auto-schedule sleep wake; falling back to guidance");
6375
6375
  return null;
6376
6376
  }
6377
6377
  }
@@ -6392,7 +6392,7 @@ const sleepGuardExtension = (pi) => {
6392
6392
  if (typeof command !== "string" || command.length === 0) return;
6393
6393
  const violation = shouldBlockForSleep(command);
6394
6394
  if (!violation) return;
6395
- log$7.warn({
6395
+ log$8.warn({
6396
6396
  seconds: violation.seconds,
6397
6397
  leading: violation.leading,
6398
6398
  unboundedLoop: violation.unboundedLoop,
@@ -6401,7 +6401,7 @@ const sleepGuardExtension = (pi) => {
6401
6401
  if (!violation.unboundedLoop && violation.seconds <= 86400 && isPureSleepCommand(blankQuotedRegions(command))) {
6402
6402
  const at = await scheduleSleepWake(violation.seconds, wakeLedger);
6403
6403
  if (at) {
6404
- log$7.info({
6404
+ log$8.info({
6405
6405
  at,
6406
6406
  seconds: violation.seconds
6407
6407
  }, "auto-scheduled sleep wake");
@@ -6509,7 +6509,7 @@ function transformContextMessages(messages, config, now) {
6509
6509
  }
6510
6510
  //#endregion
6511
6511
  //#region src/extensions/context-management.ts
6512
- const log$6 = logger.child({ module: "context-management-extension" });
6512
+ const log$7 = logger.child({ module: "context-management-extension" });
6513
6513
  function isAnthropicMessagesPayload(payload) {
6514
6514
  if (typeof payload !== "object" || payload === null) return false;
6515
6515
  const candidate = payload;
@@ -6574,13 +6574,13 @@ function createContextManagementExtension() {
6574
6574
  setContextManagementFlagOverride(getPolledFlag("contextManagement"));
6575
6575
  onFlagChange("contextManagement", (enabled) => {
6576
6576
  setContextManagementFlagOverride(enabled);
6577
- log$6.info({
6577
+ log$7.info({
6578
6578
  event: "context_management_flag_update",
6579
6579
  enabled
6580
6580
  }, "context-management flag updated from platform");
6581
6581
  });
6582
6582
  startFeatureFlagPoller();
6583
- log$6.info({
6583
+ log$7.info({
6584
6584
  event: "context_management_registered",
6585
6585
  enabled: initial.enabled,
6586
6586
  flagSource: hasFlagSource(),
@@ -6592,13 +6592,13 @@ function createContextManagementExtension() {
6592
6592
  const { messages } = event;
6593
6593
  try {
6594
6594
  const result = transformContextIfEnabled(messages, getContextManagementConfig(), Date.now());
6595
- if (result.stats && (result.stats.clearedResults > 0 || result.stats.trimmedResults > 0)) log$6.info({
6595
+ if (result.stats && (result.stats.clearedResults > 0 || result.stats.trimmedResults > 0)) log$7.info({
6596
6596
  event: "context_management_applied",
6597
6597
  ...result.stats
6598
6598
  }, "trimmed/cleared tool output before LLM call");
6599
6599
  return { messages: result.messages };
6600
6600
  } catch (err) {
6601
- log$6.error({
6601
+ log$7.error({
6602
6602
  err,
6603
6603
  event: "context_management_transform_failed"
6604
6604
  }, "context transform failed; passing messages through unchanged");
@@ -6610,7 +6610,7 @@ function createContextManagementExtension() {
6610
6610
  }
6611
6611
  //#endregion
6612
6612
  //#region src/extensions/current-time.ts
6613
- const log$5 = logger.child({ module: "current-time-extension" });
6613
+ const log$6 = logger.child({ module: "current-time-extension" });
6614
6614
  const PI_DATE_LINE = /^Current date:.*$/m;
6615
6615
  function formatCurrentTimeLine(now) {
6616
6616
  return `Current date: ${now.getUTCFullYear()}-${String(now.getUTCMonth() + 1).padStart(2, "0")}-${String(now.getUTCDate()).padStart(2, "0")} (${new Intl.DateTimeFormat("en-US", {
@@ -6623,7 +6623,7 @@ const currentTimeExtension = (pi) => {
6623
6623
  const line = formatCurrentTimeLine(/* @__PURE__ */ new Date());
6624
6624
  const base = event.systemPrompt;
6625
6625
  if (PI_DATE_LINE.test(base)) {
6626
- log$5.info({ event: "pi_date_line_present" }, "pi base prompt carries its own 'Current date:' line again; replacing it in place (pi prompt format may have changed)");
6626
+ log$6.info({ event: "pi_date_line_present" }, "pi base prompt carries its own 'Current date:' line again; replacing it in place (pi prompt format may have changed)");
6627
6627
  return { systemPrompt: base.replace(PI_DATE_LINE, line) };
6628
6628
  }
6629
6629
  return { systemPrompt: `${base}\n${line}` };
@@ -7011,7 +7011,7 @@ async function migrateMemory({ cwd }) {
7011
7011
  }
7012
7012
  //#endregion
7013
7013
  //#region src/extensions/memory.ts
7014
- const log$4 = logger.child({ module: "memory-extension" });
7014
+ const log$5 = logger.child({ module: "memory-extension" });
7015
7015
  /**
7016
7016
  * The standing instructions for the memory system. Always injected (even with
7017
7017
  * no `MEMORY.md`) so the agent knows it can persist notes and how. `users/` is
@@ -7048,13 +7048,13 @@ const memoryExtension = (pi) => {
7048
7048
  pi.on("session_start", async (_event, ctx) => {
7049
7049
  try {
7050
7050
  const migrated = await migrateMemory({ cwd: ctx.cwd });
7051
- if (migrated !== null) log$4.info({
7051
+ if (migrated !== null) log$5.info({
7052
7052
  event: "memory_migrated",
7053
7053
  from: migrated.from,
7054
7054
  to: migrated.to
7055
7055
  }, "migrated memory layout to current version");
7056
7056
  } catch (err) {
7057
- log$4.warn({
7057
+ log$5.warn({
7058
7058
  err,
7059
7059
  event: "memory_migration_failed"
7060
7060
  }, "memory migration failed; continuing with existing index");
@@ -7066,7 +7066,7 @@ const memoryExtension = (pi) => {
7066
7066
  index
7067
7067
  });
7068
7068
  } catch (err) {
7069
- log$4.warn({
7069
+ log$5.warn({
7070
7070
  err,
7071
7071
  event: "memory_index_failed"
7072
7072
  }, "memory index read failed; injecting instructions only");
@@ -7080,7 +7080,7 @@ const memoryExtension = (pi) => {
7080
7080
  };
7081
7081
  //#endregion
7082
7082
  //#region src/extensions/platform-memory.ts
7083
- const log$3 = logger.child({ module: "platform-memory-extension" });
7083
+ const log$4 = logger.child({ module: "platform-memory-extension" });
7084
7084
  /**
7085
7085
  * Resolve the human on this turn via the API, keyed by the message id.
7086
7086
  * `/sandbox/channel-context` only returns a sender for a platform-known
@@ -7093,13 +7093,13 @@ const log$3 = logger.child({ module: "platform-memory-extension" });
7093
7093
  async function resolveTurnUser(messageId) {
7094
7094
  const client = sandboxClient();
7095
7095
  if (!client) {
7096
- log$3.debug({ event: "resolve_turn_user_no_api_url" }, "no API url in env; withholding user memory");
7096
+ log$4.debug({ event: "resolve_turn_user_no_api_url" }, "no API url in env; withholding user memory");
7097
7097
  return null;
7098
7098
  }
7099
7099
  try {
7100
7100
  const res = await client["channel-context"].$get({ query: { messageId } });
7101
7101
  if (!res.ok) {
7102
- log$3.warn({
7102
+ log$4.warn({
7103
7103
  event: "resolve_turn_user_failed",
7104
7104
  status: res.status
7105
7105
  }, "channel-context returned non-ok; withholding user memory");
@@ -7112,7 +7112,7 @@ async function resolveTurnUser(messageId) {
7112
7112
  displayName: sender.displayName
7113
7113
  };
7114
7114
  } catch (err) {
7115
- log$3.warn({
7115
+ log$4.warn({
7116
7116
  err,
7117
7117
  event: "resolve_turn_user_failed"
7118
7118
  }, "failed to resolve current user; withholding user memory");
@@ -7159,7 +7159,7 @@ function createPlatformMemoryExtension({ channelContext }) {
7159
7159
  user
7160
7160
  });
7161
7161
  } catch (err) {
7162
- log$3.warn({
7162
+ log$4.warn({
7163
7163
  err,
7164
7164
  event: "user_memory_index_failed"
7165
7165
  }, "user memory index build failed; skipping injection");
@@ -7191,7 +7191,7 @@ const providerApiCompatExtension = (pi) => {
7191
7191
  };
7192
7192
  //#endregion
7193
7193
  //#region src/extensions/self-trace.ts
7194
- const log$2 = logger.child({ module: "self-trace-extension" });
7194
+ const log$3 = logger.child({ module: "self-trace-extension" });
7195
7195
  /**
7196
7196
  * Reports the agent's own execution as OpenTelemetry spans:
7197
7197
  * agent.session → agent.run → agent.turn.N → tool.NAME, with token/cost
@@ -7216,7 +7216,7 @@ const selfTraceExtension = (pi) => {
7216
7216
  sessionSpan = tracer.startSpan("agent.session", { attributes: { "agent.model": modelId } }, remoteCtx);
7217
7217
  sessionCtx = trace.setSpan(remoteCtx, sessionSpan);
7218
7218
  const sc = sessionSpan.spanContext();
7219
- log$2.info({
7219
+ log$3.info({
7220
7220
  event: "self_trace_session_start",
7221
7221
  trace_id: sc.traceId,
7222
7222
  span_id: sc.spanId,
@@ -7328,13 +7328,13 @@ const selfTraceExtension = (pi) => {
7328
7328
  * Lives in the harness package — soul.md is content from the agent's
7329
7329
  * own git repo, not from the platform — so its handling stays here.
7330
7330
  */
7331
- const log$1 = logger.child({ module: "soul-extension" });
7331
+ const log$2 = logger.child({ module: "soul-extension" });
7332
7332
  async function readSoul(cwd) {
7333
7333
  try {
7334
7334
  return (await readFile(join(cwd, "soul.md"), "utf8")).trim() || null;
7335
7335
  } catch (err) {
7336
7336
  if (err?.code === "ENOENT") return null;
7337
- log$1.warn({
7337
+ log$2.warn({
7338
7338
  err,
7339
7339
  event: "soul_read_failed"
7340
7340
  }, "soul.md read failed");
@@ -7366,7 +7366,7 @@ const soulExtension = (pi) => {
7366
7366
  };
7367
7367
  //#endregion
7368
7368
  //#region src/extensions/subagent/index.ts
7369
- const log = logger.child({ module: "subagent-ext" });
7369
+ const log$1 = logger.child({ module: "subagent-ext" });
7370
7370
  const MAX_TASKS = 8;
7371
7371
  const SpawnTaskItem = Type.Object({
7372
7372
  task: Type.String({ description: "The task to delegate to a subagent run." }),
@@ -7466,7 +7466,7 @@ function buildTool(messageId) {
7466
7466
  };
7467
7467
  } catch (err) {
7468
7468
  const message = err instanceof Error ? err.message : String(err);
7469
- log.warn({
7469
+ log$1.warn({
7470
7470
  err,
7471
7471
  event: "subagent_rearm_failed",
7472
7472
  taskId: task.taskId
@@ -7479,7 +7479,7 @@ function buildTool(messageId) {
7479
7479
  }
7480
7480
  }));
7481
7481
  const { taskIds } = spawned;
7482
- log.info({
7482
+ log$1.info({
7483
7483
  event: "subagent_spawned",
7484
7484
  count: taskIds.length
7485
7485
  }, "subagent tasks queued");
@@ -7510,7 +7510,7 @@ function buildTool(messageId) {
7510
7510
  };
7511
7511
  } catch (err) {
7512
7512
  const message = err instanceof Error ? err.message : String(err);
7513
- log.warn({
7513
+ log$1.warn({
7514
7514
  err,
7515
7515
  event: "subagent_spawn_failed"
7516
7516
  }, "subagent request failed");
@@ -7541,7 +7541,7 @@ function createSubagentExtension({ channelContext }) {
7541
7541
  if (registered) return;
7542
7542
  registered = true;
7543
7543
  pi.registerTool(buildTool(messageId));
7544
- log.info({ event: "subagent_enabled" }, "subagent tool registered");
7544
+ log$1.info({ event: "subagent_enabled" }, "subagent tool registered");
7545
7545
  };
7546
7546
  pi.on("session_start", () => {
7547
7547
  registerOnce();
@@ -7549,6 +7549,125 @@ function createSubagentExtension({ channelContext }) {
7549
7549
  };
7550
7550
  }
7551
7551
  //#endregion
7552
+ //#region src/extensions/template-build-push.ts
7553
+ /**
7554
+ * Same-turn notice that a push started a template build.
7555
+ *
7556
+ * An agent's `Dockerfile` / `install.sh` / lockfiles are BAKED: changing one
7557
+ * does not take effect when the file is written, nor when it is pushed, but
7558
+ * when a template build of that commit succeeds — minutes later, out of band,
7559
+ * with no result delivered anywhere the agent looks. So an agent edits its
7560
+ * Dockerfile, pushes, sees a clean `git push`, and reasonably concludes it is
7561
+ * done. If that build fails, it will go on answering from the last image that
7562
+ * built, and every later commit fails the same way.
7563
+ *
7564
+ * This closes the gap at the only moment the agent still has full context for
7565
+ * why it touched those files: the push itself. The notice appends one line to
7566
+ * the push's own tool result pointing at `platform builds wait`. It does not
7567
+ * block, does not wait for the build, and adds no request — it is a string
7568
+ * append onto a result that has already returned.
7569
+ *
7570
+ * Deliberately narrow: only a push whose diff touches a baked path says
7571
+ * anything. A push of ordinary code is not waiting on a build and must stay
7572
+ * silent, or the line becomes background noise that gets skimmed past.
7573
+ *
7574
+ * Best-effort throughout. Any failure to read the range or the diff leaves
7575
+ * the tool result exactly as it was — this is a hint, and a hint must never
7576
+ * be able to break a push.
7577
+ */
7578
+ const execFileAsync = promisify(execFile);
7579
+ const log = logger.child({ module: "template-build-push" });
7580
+ /**
7581
+ * Repo paths whose contents are baked into the template image.
7582
+ *
7583
+ * MUST stay identical to `BAKED_BUILD_PATHS` in
7584
+ * `apps/anyone/agent-lifecycle/src/agentPush.ts`, which is what the server
7585
+ * actually classifies pushes with. It is duplicated rather than imported
7586
+ * because the harness carries zero `@createinc/*` dependencies; the pair is
7587
+ * pinned by `template-build-push.contract.test.ts`, the same arrangement the
7588
+ * untrusted fence uses.
7589
+ */
7590
+ const BAKED_BUILD_PATHS = new Set([
7591
+ "Dockerfile",
7592
+ "install.sh",
7593
+ "package.json",
7594
+ "package-lock.json",
7595
+ ".npmrc",
7596
+ "yarn.lock",
7597
+ ".yarnrc.yml",
7598
+ ".yarnrc",
7599
+ "bun.lock",
7600
+ "bun.lockb",
7601
+ ".bunfig.toml",
7602
+ "pnpm-lock.yaml"
7603
+ ]);
7604
+ const BUILD_STARTED_NOTICE = "Note: this push changed a file that is baked into your computer image (Dockerfile / install.sh / a lockfile), so it started a template build. The change is NOT live here until that build succeeds — a failed build leaves you running the previous image, silently. Run `platform builds wait` to confirm it built before you rely on anything the change added, or treat it as unfinished work and check back with `platform builds show`.";
7605
+ /** True for a bash command that is (or contains) a `git push`. */
7606
+ function isGitPush(command) {
7607
+ return /(^|[\s;&|(])git\s+(?:\S+\s+)*?push(\s|$)/.test(command);
7608
+ }
7609
+ /**
7610
+ * The commit range a push reported, parsed from git's own output.
7611
+ *
7612
+ * git writes the range on the ref line of a successful push
7613
+ * (` abc1234..def5678 main -> main`). Reading it back is what lets the
7614
+ * diff be scoped to exactly what was pushed, with no guessing about upstream
7615
+ * tracking state. A new branch (`* [new branch]`) reports no range, which is
7616
+ * why {@link parsePushedRange} returns null there and the caller falls back
7617
+ * to notifying — a first push of a repo is overwhelmingly one that carries a
7618
+ * Dockerfile.
7619
+ */
7620
+ function parsePushedRange(output) {
7621
+ const match = output.match(/\b([0-9a-f]{7,40})\.\.([0-9a-f]{7,40})\b/);
7622
+ if (!match) return null;
7623
+ return `${match[1]}..${match[2]}`;
7624
+ }
7625
+ /** True when a forced update (`+ abc..def (forced update)`) or a new ref. */
7626
+ function isNewRef(output) {
7627
+ return /\[new (?:branch|tag)\]/.test(output);
7628
+ }
7629
+ async function touchedBakedPath({ cwd, range }) {
7630
+ const { stdout } = await execFileAsync("git", [
7631
+ "diff",
7632
+ "--name-only",
7633
+ range
7634
+ ], {
7635
+ cwd,
7636
+ timeout: 5e3,
7637
+ maxBuffer: 4 * 1024 * 1024
7638
+ });
7639
+ return stdout.split("\n").map((line) => line.trim()).some((path) => path.length > 0 && BAKED_BUILD_PATHS.has(path));
7640
+ }
7641
+ const templateBuildPushExtension = (pi) => {
7642
+ pi.on("tool_result", async (event, ctx) => {
7643
+ if (event.toolName !== "bash") return;
7644
+ if (event.isError) return;
7645
+ const command = event.input.command;
7646
+ if (typeof command !== "string" || !isGitPush(command)) return;
7647
+ const output = event.content.map((part) => part.type === "text" ? part.text : "").join("\n");
7648
+ let notify = false;
7649
+ try {
7650
+ const range = parsePushedRange(output);
7651
+ if (range === null) notify = isNewRef(output);
7652
+ else notify = await touchedBakedPath({
7653
+ cwd: ctx.cwd,
7654
+ range
7655
+ });
7656
+ } catch (err) {
7657
+ log.warn({
7658
+ err,
7659
+ event: "template_build_push_classify_failed"
7660
+ }, "could not classify pushed paths; leaving the push result unchanged");
7661
+ return;
7662
+ }
7663
+ if (!notify) return;
7664
+ return { content: [...event.content, {
7665
+ type: "text",
7666
+ text: `\n${BUILD_STARTED_NOTICE}`
7667
+ }] };
7668
+ });
7669
+ };
7670
+ //#endregion
7552
7671
  //#region src/extensions/tool-history.ts
7553
7672
  const VALID_NAME_RE = /^[a-zA-Z0-9_-]+$/;
7554
7673
  function isValidToolName(name) {
@@ -7717,6 +7836,7 @@ function platformExtensions({ sessionId, channelContext }) {
7717
7836
  createSubagentExtension({ channelContext }),
7718
7837
  createContextManagementExtension(),
7719
7838
  resourcePressureWarningExtension,
7839
+ templateBuildPushExtension,
7720
7840
  tool_history_default
7721
7841
  ];
7722
7842
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skydiveai/pi-extensions",
3
- "version": "0.1.258-beta.133",
3
+ "version": "0.1.258-beta.134",
4
4
  "homepage": "https://skydive.com",
5
5
  "license": "MIT",
6
6
  "author": "Create, Inc.",