@karlorz/codexhost-cli-win32-x64 0.16.1-2 → 0.16.1-3

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/README.md CHANGED
@@ -7,7 +7,7 @@ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install -g @karlorz/codexhost-cli@0.16.1-2
10
+ npm install -g @karlorz/codexhost-cli@0.16.1-3
11
11
  ```
12
12
 
13
13
  Do not install this package directly. npm selects it through the optional dependencies of `@karlorz/codexhost-cli`.
@@ -1 +1 @@
1
- {"schemaVersion":1,"version":"0.16.1-2","distribution":"npm","target":"windows-x64"}
1
+ {"schemaVersion":1,"version":"0.16.1-3","distribution":"npm","target":"windows-x64"}
@@ -17030,6 +17030,37 @@ var voiceSettingsStateSchema = external_exports.strictObject({
17030
17030
  })
17031
17031
  });
17032
17032
 
17033
+ // packages/shared-contracts/dist/background-activity.js
17034
+ var backgroundActivitySchema = external_exports.strictObject({
17035
+ id: external_exports.string().min(1),
17036
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
17037
+ label: external_exports.string(),
17038
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
17039
+ canStop: external_exports.boolean(),
17040
+ /** Existing detached command Item presented by Desktop's native process UI. */
17041
+ commandItemId: hostItemIdSchema.optional(),
17042
+ schedule: external_exports.string().optional(),
17043
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
17044
+ relatedActivityId: external_exports.string().optional(),
17045
+ threadId: hostThreadIdSchema.optional()
17046
+ });
17047
+ var backgroundActivityDetailSchema = external_exports.strictObject({
17048
+ activity: backgroundActivitySchema,
17049
+ output: external_exports.string(),
17050
+ truncated: external_exports.boolean()
17051
+ });
17052
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
17053
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
17054
+ activityId: external_exports.string().min(1)
17055
+ });
17056
+ var threadActivityListResultSchema = external_exports.strictObject({
17057
+ supported: external_exports.boolean(),
17058
+ activities: external_exports.array(backgroundActivitySchema)
17059
+ });
17060
+ var threadActivityStopResultSchema = external_exports.strictObject({
17061
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
17062
+ });
17063
+
17033
17064
  // packages/shared-contracts/dist/index.js
17034
17065
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
17035
17066
 
@@ -16261,6 +16261,37 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16261
16261
  })
16262
16262
  });
16263
16263
 
16264
+ // ../shared-contracts/dist/background-activity.js
16265
+ var backgroundActivitySchema = external_exports.strictObject({
16266
+ id: external_exports.string().min(1),
16267
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
16268
+ label: external_exports.string(),
16269
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
16270
+ canStop: external_exports.boolean(),
16271
+ /** Existing detached command Item presented by Desktop's native process UI. */
16272
+ commandItemId: hostItemIdSchema.optional(),
16273
+ schedule: external_exports.string().optional(),
16274
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
16275
+ relatedActivityId: external_exports.string().optional(),
16276
+ threadId: hostThreadIdSchema.optional()
16277
+ });
16278
+ var backgroundActivityDetailSchema = external_exports.strictObject({
16279
+ activity: backgroundActivitySchema,
16280
+ output: external_exports.string(),
16281
+ truncated: external_exports.boolean()
16282
+ });
16283
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
16284
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
16285
+ activityId: external_exports.string().min(1)
16286
+ });
16287
+ var threadActivityListResultSchema = external_exports.strictObject({
16288
+ supported: external_exports.boolean(),
16289
+ activities: external_exports.array(backgroundActivitySchema)
16290
+ });
16291
+ var threadActivityStopResultSchema = external_exports.strictObject({
16292
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
16293
+ });
16294
+
16264
16295
  // ../shared-contracts/dist/index.js
16265
16296
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16266
16297
 
@@ -16156,6 +16156,37 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16156
16156
  })
16157
16157
  });
16158
16158
 
16159
+ // ../shared-contracts/dist/background-activity.js
16160
+ var backgroundActivitySchema = external_exports.strictObject({
16161
+ id: external_exports.string().min(1),
16162
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
16163
+ label: external_exports.string(),
16164
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
16165
+ canStop: external_exports.boolean(),
16166
+ /** Existing detached command Item presented by Desktop's native process UI. */
16167
+ commandItemId: hostItemIdSchema.optional(),
16168
+ schedule: external_exports.string().optional(),
16169
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
16170
+ relatedActivityId: external_exports.string().optional(),
16171
+ threadId: hostThreadIdSchema.optional()
16172
+ });
16173
+ var backgroundActivityDetailSchema = external_exports.strictObject({
16174
+ activity: backgroundActivitySchema,
16175
+ output: external_exports.string(),
16176
+ truncated: external_exports.boolean()
16177
+ });
16178
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
16179
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
16180
+ activityId: external_exports.string().min(1)
16181
+ });
16182
+ var threadActivityListResultSchema = external_exports.strictObject({
16183
+ supported: external_exports.boolean(),
16184
+ activities: external_exports.array(backgroundActivitySchema)
16185
+ });
16186
+ var threadActivityStopResultSchema = external_exports.strictObject({
16187
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
16188
+ });
16189
+
16159
16190
  // ../shared-contracts/dist/index.js
16160
16191
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16161
16192
 
@@ -16408,6 +16408,37 @@ var voiceSettingsStateSchema = external_exports.strictObject({
16408
16408
  })
16409
16409
  });
16410
16410
 
16411
+ // packages/shared-contracts/dist/background-activity.js
16412
+ var backgroundActivitySchema = external_exports.strictObject({
16413
+ id: external_exports.string().min(1),
16414
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
16415
+ label: external_exports.string(),
16416
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
16417
+ canStop: external_exports.boolean(),
16418
+ /** Existing detached command Item presented by Desktop's native process UI. */
16419
+ commandItemId: hostItemIdSchema.optional(),
16420
+ schedule: external_exports.string().optional(),
16421
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
16422
+ relatedActivityId: external_exports.string().optional(),
16423
+ threadId: hostThreadIdSchema.optional()
16424
+ });
16425
+ var backgroundActivityDetailSchema = external_exports.strictObject({
16426
+ activity: backgroundActivitySchema,
16427
+ output: external_exports.string(),
16428
+ truncated: external_exports.boolean()
16429
+ });
16430
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
16431
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
16432
+ activityId: external_exports.string().min(1)
16433
+ });
16434
+ var threadActivityListResultSchema = external_exports.strictObject({
16435
+ supported: external_exports.boolean(),
16436
+ activities: external_exports.array(backgroundActivitySchema)
16437
+ });
16438
+ var threadActivityStopResultSchema = external_exports.strictObject({
16439
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
16440
+ });
16441
+
16411
16442
  // packages/shared-contracts/dist/index.js
16412
16443
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16413
16444
 
@@ -5121,12 +5121,12 @@ async function verifyDownloadedArtifact(source, filePath, result) {
5121
5121
  // packages/update-manager/dist/updater-ready.js
5122
5122
  import { setTimeout as delay } from "node:timers/promises";
5123
5123
  async function waitForUpdaterReady(child, readStatus, timeoutMs = 1e4) {
5124
- let failure2;
5124
+ let failure3;
5125
5125
  const onError = (error51) => {
5126
- failure2 = error51;
5126
+ failure3 = error51;
5127
5127
  };
5128
5128
  const onExit = () => {
5129
- failure2 = new Error("Background Updater exited before completing handoff");
5129
+ failure3 = new Error("Background Updater exited before completing handoff");
5130
5130
  };
5131
5131
  child.on("error", onError);
5132
5132
  child.on("exit", onExit);
@@ -5136,8 +5136,8 @@ async function waitForUpdaterReady(child, readStatus, timeoutMs = 1e4) {
5136
5136
  const status2 = await readStatus();
5137
5137
  if (status2?.phase === "failed")
5138
5138
  throw new Error(status2.error ?? "Background Updater failed");
5139
- if (failure2)
5140
- throw failure2;
5139
+ if (failure3)
5140
+ throw failure3;
5141
5141
  if (child.exitCode != null || child.signalCode != null) {
5142
5142
  throw new Error("Background Updater exited before completing handoff");
5143
5143
  }
@@ -21695,6 +21695,40 @@ var voiceSettingsStateSchema = external_exports.strictObject({
21695
21695
  })
21696
21696
  });
21697
21697
 
21698
+ // packages/shared-contracts/dist/background-activity.js
21699
+ var THREAD_ACTIVITY_LIST_METHOD = "codexhost/thread/activity/list";
21700
+ var THREAD_ACTIVITY_READ_METHOD = "codexhost/thread/activity/read";
21701
+ var THREAD_ACTIVITY_STOP_METHOD = "codexhost/thread/activity/stop";
21702
+ var backgroundActivitySchema = external_exports.strictObject({
21703
+ id: external_exports.string().min(1),
21704
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
21705
+ label: external_exports.string(),
21706
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
21707
+ canStop: external_exports.boolean(),
21708
+ /** Existing detached command Item presented by Desktop's native process UI. */
21709
+ commandItemId: hostItemIdSchema.optional(),
21710
+ schedule: external_exports.string().optional(),
21711
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
21712
+ relatedActivityId: external_exports.string().optional(),
21713
+ threadId: hostThreadIdSchema.optional()
21714
+ });
21715
+ var backgroundActivityDetailSchema = external_exports.strictObject({
21716
+ activity: backgroundActivitySchema,
21717
+ output: external_exports.string(),
21718
+ truncated: external_exports.boolean()
21719
+ });
21720
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
21721
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
21722
+ activityId: external_exports.string().min(1)
21723
+ });
21724
+ var threadActivityListResultSchema = external_exports.strictObject({
21725
+ supported: external_exports.boolean(),
21726
+ activities: external_exports.array(backgroundActivitySchema)
21727
+ });
21728
+ var threadActivityStopResultSchema = external_exports.strictObject({
21729
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
21730
+ });
21731
+
21698
21732
  // packages/shared-contracts/dist/index.js
21699
21733
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
21700
21734
 
@@ -21807,11 +21841,11 @@ var RuntimeMaintenance = class {
21807
21841
  }, UPDATER_WATCH_INTERVAL_MS);
21808
21842
  this.#watch.unref();
21809
21843
  }
21810
- async #recordStartFailure(version2, failure2) {
21844
+ async #recordStartFailure(version2, failure3) {
21811
21845
  await writeFile3(this.#cancelPath, JSON.stringify({ targetVersion: version2 }), { mode: 384 });
21812
21846
  await writeFile3(
21813
21847
  this.#statusPath,
21814
- JSON.stringify({ phase: "failed", targetVersion: version2, error: failure2 }),
21848
+ JSON.stringify({ phase: "failed", targetVersion: version2, error: failure3 }),
21815
21849
  { mode: 384 }
21816
21850
  );
21817
21851
  }
@@ -22022,9 +22056,9 @@ var RuntimeMaintenance = class {
22022
22056
  process.kill(helperPid);
22023
22057
  } catch {
22024
22058
  }
22025
- const failure2 = "Remote updater did not start";
22026
- await this.#recordStartFailure(version2, failure2);
22027
- throw new Error(failure2);
22059
+ const failure3 = "Remote updater did not start";
22060
+ await this.#recordStartFailure(version2, failure3);
22061
+ throw new Error(failure3);
22028
22062
  }
22029
22063
  await new Promise((resolve) => setTimeout(resolve, 50));
22030
22064
  }
@@ -22047,6 +22081,65 @@ import path41 from "node:path";
22047
22081
  import { homedir as homedir5 } from "node:os";
22048
22082
  import { fileURLToPath as fileURLToPath2 } from "node:url";
22049
22083
 
22084
+ // packages/host-runtime/src/external-thread-activity.ts
22085
+ async function executeExternalActivity(input) {
22086
+ const capability = input.session.backgroundActivity;
22087
+ if (!capability)
22088
+ return input.method === THREAD_ACTIVITY_LIST_METHOD ? { result: { supported: false, activities: [] } } : { error: { code: -32076, message: "Background activity is unsupported" } };
22089
+ const current = () => {
22090
+ if (!input.isCurrent()) throw new Error("Background activity Session changed");
22091
+ };
22092
+ const resolveChildren = async (activities) => {
22093
+ const children = capability.subagents?.() ?? [];
22094
+ return Promise.all(
22095
+ activities.map(async (activity) => {
22096
+ if (activity.kind !== "subagent") return activity;
22097
+ const child = children.find((entry) => entry.activityId === activity.id)?.state;
22098
+ if (!child) return activity;
22099
+ current();
22100
+ const resolved = await input.materialize(child);
22101
+ current();
22102
+ return resolved.subagentId !== child.nativeSubagentId ? { ...activity, threadId: resolved.subagentId } : activity;
22103
+ })
22104
+ );
22105
+ };
22106
+ try {
22107
+ current();
22108
+ if (input.method === THREAD_ACTIVITY_LIST_METHOD) {
22109
+ const result2 = await capability.list();
22110
+ current();
22111
+ if (!result2.ok) return failure(result2.error);
22112
+ const activities = await resolveChildren(result2.value);
22113
+ return { result: threadActivityListResultSchema.parse({ supported: true, activities }) };
22114
+ }
22115
+ if (input.method === THREAD_ACTIVITY_READ_METHOD) {
22116
+ const result2 = await capability.read(input.activityId ?? "");
22117
+ current();
22118
+ if (!result2.ok) return failure(result2.error);
22119
+ const [activity] = await resolveChildren([result2.value.activity]);
22120
+ return { result: backgroundActivityDetailSchema.parse({ ...result2.value, activity }) };
22121
+ }
22122
+ const result = await capability.stop(input.activityId ?? "");
22123
+ current();
22124
+ return result.ok ? { result: threadActivityStopResultSchema.parse(result.value) } : failure(result.error);
22125
+ } catch (error51) {
22126
+ return {
22127
+ error: {
22128
+ code: -32083,
22129
+ message: error51 instanceof Error ? error51.message : "Background activity failed"
22130
+ }
22131
+ };
22132
+ }
22133
+ }
22134
+ function failure(error51) {
22135
+ return {
22136
+ error: {
22137
+ code: error51.code === "unsupported" ? -32076 : error51.code === "invalidRequest" ? -32602 : -32083,
22138
+ message: error51.message
22139
+ }
22140
+ };
22141
+ }
22142
+
22050
22143
  // packages/harness-adapter/dist/account-credits.js
22051
22144
  function parseHarnessAccountCredits(value2) {
22052
22145
  if (!value2 || typeof value2 !== "object" || Array.isArray(value2))
@@ -27156,11 +27249,11 @@ async function executeExternalGoal(session, threadId2, method, params) {
27156
27249
  try {
27157
27250
  if (method === "thread/goal/get") {
27158
27251
  let read = await goals.read();
27159
- if (!read.ok) return failure(read.error);
27252
+ if (!read.ok) return failure2(read.error);
27160
27253
  const completed = read.value === null ? await goals.readLastCompleted?.() : void 0;
27161
27254
  if (completed?.ok && completed.value?.status === "complete") {
27162
27255
  read = await goals.read();
27163
- if (!read.ok) return failure(read.error);
27256
+ if (!read.ok) return failure2(read.error);
27164
27257
  }
27165
27258
  return {
27166
27259
  result: {
@@ -27176,7 +27269,7 @@ async function executeExternalGoal(session, threadId2, method, params) {
27176
27269
  }
27177
27270
  if (method === "thread/goal/clear") {
27178
27271
  const cleared = await goals.clear({ origin });
27179
- return cleared.ok ? { result: { cleared: cleared.value.cleared } } : failure(cleared.error);
27272
+ return cleared.ok ? { result: { cleared: cleared.value.cleared } } : failure2(cleared.error);
27180
27273
  }
27181
27274
  const parsed2 = harnessGoalSetSchema.safeParse({
27182
27275
  ...params.objective == null ? {} : { objective: params.objective },
@@ -27187,12 +27280,12 @@ async function executeExternalGoal(session, threadId2, method, params) {
27187
27280
  if (!parsed2.success)
27188
27281
  return { error: { code: -32602, message: "Invalid external goal mutation" } };
27189
27282
  const set2 = await goals.set(parsed2.data);
27190
- return set2.ok ? { result: { goal: projectCodexGoal(threadId2, set2.value) } } : failure(set2.error);
27283
+ return set2.ok ? { result: { goal: projectCodexGoal(threadId2, set2.value) } } : failure2(set2.error);
27191
27284
  } catch {
27192
27285
  return { error: { code: -32076, message: "External goal state or operation is unavailable" } };
27193
27286
  }
27194
27287
  }
27195
- function failure(error51) {
27288
+ function failure2(error51) {
27196
27289
  return {
27197
27290
  error: { code: error51.code === "invalidRequest" ? -32602 : -32076, message: error51.message }
27198
27291
  };
@@ -28071,10 +28164,10 @@ function createLocalPageOpener(environment) {
28071
28164
  socket.setEncoding("utf8");
28072
28165
  let buffer = "";
28073
28166
  let pending;
28074
- let failure2;
28167
+ let failure3;
28075
28168
  const fail = () => {
28076
- failure2 ??= new Error("Codex local page connection closed");
28077
- pending?.reject(failure2);
28169
+ failure3 ??= new Error("Codex local page connection closed");
28170
+ pending?.reject(failure3);
28078
28171
  pending = void 0;
28079
28172
  };
28080
28173
  socket.on("error", fail);
@@ -28100,8 +28193,8 @@ function createLocalPageOpener(environment) {
28100
28193
  }
28101
28194
  });
28102
28195
  const request = async (command) => {
28103
- if (failure2)
28104
- throw failure2;
28196
+ if (failure3)
28197
+ throw failure3;
28105
28198
  if (pending)
28106
28199
  throw new Error("Local page operation already pending");
28107
28200
  const result = Promise.withResolvers();
@@ -28131,7 +28224,7 @@ function createLocalPageOpener(environment) {
28131
28224
  },
28132
28225
  close() {
28133
28226
  closing ??= operations.catch(() => void 0).then(async () => {
28134
- if (!socket.destroyed && !failure2)
28227
+ if (!socket.destroyed && !failure3)
28135
28228
  await request("CLOSE");
28136
28229
  }).catch(() => void 0).finally(() => socket.destroy());
28137
28230
  return closing;
@@ -33864,7 +33957,7 @@ function externalThreadValue(input) {
33864
33957
  thread_spawn: {
33865
33958
  parent_thread_id: record5.subagent.parentHostThreadId,
33866
33959
  depth: 1,
33867
- agent_path: null,
33960
+ agent_path: record5.title || record5.subagent.role || record5.subagent.nativeSubagentId,
33868
33961
  agent_nickname: record5.title || null,
33869
33962
  agent_role: record5.subagent.role ?? null
33870
33963
  }
@@ -35785,8 +35878,8 @@ var ExternalThreadRuntime = class {
35785
35878
  async #locate(threadId2) {
35786
35879
  const loaded = this.#threads.get(threadId2);
35787
35880
  if (loaded) {
35788
- const failure2 = this.idleRelease.failure(loaded);
35789
- if (failure2) return { kind: "error", error: { code: -32075, message: failure2 } };
35881
+ const failure3 = this.idleRelease.failure(loaded);
35882
+ if (failure3) return { kind: "error", error: { code: -32075, message: failure3 } };
35790
35883
  return { kind: "external", record: loaded.record, thread: loaded };
35791
35884
  }
35792
35885
  let record5;
@@ -35846,8 +35939,8 @@ var ExternalThreadRuntime = class {
35846
35939
  message: "External Session changed during recovery; retry the request"
35847
35940
  };
35848
35941
  }
35849
- const failure2 = this.idleRelease.failure(thread);
35850
- if (failure2) return { code: -32075, message: failure2 };
35942
+ const failure3 = this.idleRelease.failure(thread);
35943
+ if (failure3) return { code: -32075, message: failure3 };
35851
35944
  if (thread.sessionUnavailable && this.#idleForRestore(thread)) {
35852
35945
  const revived = await this.#reviveIdleSession(thread);
35853
35946
  if (revived) return revived;
@@ -36010,11 +36103,11 @@ var ExternalThreadRuntime = class {
36010
36103
  );
36011
36104
  return null;
36012
36105
  } catch (error51) {
36013
- const failure2 = error51 instanceof Error ? error51 : new Error(errorMessage3(error51));
36014
- thread.persistenceError = failure2;
36015
- thread.stateObserver.fault(failure2);
36106
+ const failure3 = error51 instanceof Error ? error51 : new Error(errorMessage3(error51));
36107
+ thread.persistenceError = failure3;
36108
+ thread.stateObserver.fault(failure3);
36016
36109
  this.#diagnose("External Turn identity could not be persisted");
36017
- return failure2;
36110
+ return failure3;
36018
36111
  }
36019
36112
  }
36020
36113
  async #restore(record5) {
@@ -36523,18 +36616,18 @@ var ExternalTurnSteering = class {
36523
36616
  });
36524
36617
  };
36525
36618
  if (typeof delivery === "string") return deliver(delivery);
36526
- const failure2 = Promise.withResolvers();
36619
+ const failure3 = Promise.withResolvers();
36527
36620
  let failureReason = null;
36528
36621
  const pending = {
36529
36622
  turnId: input.expectedTurnId,
36530
36623
  resolve: () => void 0,
36531
36624
  reject(error51) {
36532
36625
  failureReason ??= error51;
36533
- failure2.reject(error51);
36626
+ failure3.reject(error51);
36534
36627
  }
36535
36628
  };
36536
36629
  this.#pending.set(thread.id, pending);
36537
- return Promise.race([delivery, failure2.promise]).then((mode) => {
36630
+ return Promise.race([delivery, failure3.promise]).then((mode) => {
36538
36631
  if (failureReason) throw failureReason;
36539
36632
  if (this.#pending.get(thread.id) === pending) this.#pending.delete(thread.id);
36540
36633
  return deliver(mode);
@@ -36571,14 +36664,14 @@ var ExternalTurnSteering = class {
36571
36664
  if (!turnId)
36572
36665
  throw new ExternalSteerError(-32074, "External steering must reference the active Turn");
36573
36666
  const terminal3 = Promise.withResolvers();
36574
- const failure2 = Promise.withResolvers();
36667
+ const failure3 = Promise.withResolvers();
36575
36668
  let failureReason = null;
36576
36669
  const pending = {
36577
36670
  turnId: input.expectedTurnId,
36578
36671
  resolve: terminal3.resolve,
36579
36672
  reject(error51) {
36580
36673
  failureReason ??= error51;
36581
- failure2.reject(error51);
36674
+ failure3.reject(error51);
36582
36675
  }
36583
36676
  };
36584
36677
  this.#pending.set(thread.id, pending);
@@ -36594,12 +36687,12 @@ var ExternalTurnSteering = class {
36594
36687
  try {
36595
36688
  const cancelled = await Promise.race([
36596
36689
  thread.session.execute({ type: "turn.cancel", turnId }),
36597
- failure2.promise
36690
+ failure3.promise
36598
36691
  ]);
36599
36692
  if (!cancelled.ok && cancelled.error.code !== "invalidState") {
36600
36693
  throw new ExternalSteerError(-32074, cancelled.error.message);
36601
36694
  }
36602
- const outcome = await Promise.race([terminal3.promise, failure2.promise]);
36695
+ const outcome = await Promise.race([terminal3.promise, failure3.promise]);
36603
36696
  clearTimeout(timeout);
36604
36697
  const assertActive = () => {
36605
36698
  if (failureReason) throw failureReason;
@@ -39529,10 +39622,10 @@ async function loadHarnessPlugins(options2) {
39529
39622
  ...manifest.notice ? { notice: manifest.notice } : {}
39530
39623
  });
39531
39624
  let adapter;
39532
- let failure2;
39625
+ let failure3;
39533
39626
  if (manifest.adapterApiVersion !== HARNESS_PLUGIN_API_VERSION) {
39534
- failure2 = "incompatibleVersion";
39535
- adapter = unavailableAdapter(descriptor, failure2);
39627
+ failure3 = "incompatibleVersion";
39628
+ adapter = unavailableAdapter(descriptor, failure3);
39536
39629
  } else {
39537
39630
  try {
39538
39631
  if (manifest.icon) descriptor.icon = await readPluginIcon(candidate.root, manifest.icon);
@@ -39551,11 +39644,11 @@ async function loadHarnessPlugins(options2) {
39551
39644
  }
39552
39645
  } catch (error51) {
39553
39646
  if (error51 instanceof PluginLoadCancelled) return;
39554
- failure2 = error51 instanceof PluginLoadTimeout ? "loadTimeout" : "loadFailed";
39555
- adapter = unavailableAdapter(descriptor, failure2);
39647
+ failure3 = error51 instanceof PluginLoadTimeout ? "loadTimeout" : "loadFailed";
39648
+ adapter = unavailableAdapter(descriptor, failure3);
39556
39649
  }
39557
39650
  }
39558
- if (failure2) diagnose({ id: manifest.id, code: failure2 });
39651
+ if (failure3) diagnose({ id: manifest.id, code: failure3 });
39559
39652
  loaded.set(candidate, { descriptor, adapter });
39560
39653
  }
39561
39654
  };
@@ -42256,6 +42349,39 @@ var AppServerHost = class {
42256
42349
  }
42257
42350
  return;
42258
42351
  }
42352
+ if ([
42353
+ THREAD_ACTIVITY_LIST_METHOD,
42354
+ THREAD_ACTIVITY_READ_METHOD,
42355
+ THREAD_ACTIVITY_STOP_METHOD
42356
+ ].includes(request.method)) {
42357
+ const parsed2 = (request.method === THREAD_ACTIVITY_LIST_METHOD ? threadActivityParamsSchema : threadActivityItemParamsSchema).safeParse(request.params);
42358
+ if (!parsed2.success) {
42359
+ await this.#writer.json(rpcError(request, -32602, "Invalid background activity request"));
42360
+ return;
42361
+ }
42362
+ await this.#externalRuntime.idleRelease.runOperation(parsed2.data.threadId, async () => {
42363
+ const resolution = await this.#resolveExternalThread(parsed2.data.threadId);
42364
+ if (await this.#writeResolutionError(request, resolution)) return;
42365
+ if (resolution.kind !== "external") {
42366
+ await this.#writer.json(
42367
+ request.method === THREAD_ACTIVITY_LIST_METHOD ? rpcEnvelope(request, { result: { supported: false, activities: [] } }) : rpcError(request, -32076, "Background activity is unsupported")
42368
+ );
42369
+ return;
42370
+ }
42371
+ const thread = resolution.thread;
42372
+ const result = await executeExternalActivity({
42373
+ session: thread.session,
42374
+ method: request.method,
42375
+ ..."activityId" in parsed2.data ? { activityId: String(parsed2.data.activityId) } : {},
42376
+ isCurrent: () => this.#externalRuntime.get(thread.id) === thread,
42377
+ materialize: (child) => this.#materializeSubagent(thread, child)
42378
+ });
42379
+ await this.#writer.json(
42380
+ result.error ? rpcError(request, result.error.code, result.error.message) : rpcEnvelope(request, { result: jsonValueSchema.parse(result.result) })
42381
+ );
42382
+ });
42383
+ return;
42384
+ }
42259
42385
  if (request.method === THREAD_QUESTIONS_LIST_METHOD || request.method === THREAD_QUESTION_RESPOND_METHOD || request.method === THREAD_QUESTION_ACTIVITY_METHOD) {
42260
42386
  await this.#handleSharedQuestionRequest(request);
42261
42387
  return;
@@ -43149,8 +43275,8 @@ var AppServerHost = class {
43149
43275
  })
43150
43276
  );
43151
43277
  } catch (error51) {
43152
- const failure2 = codexAccountRpcError(error51);
43153
- await this.#writer.json(rpcError(request, failure2.code, failure2.message));
43278
+ const failure3 = codexAccountRpcError(error51);
43279
+ await this.#writer.json(rpcError(request, failure3.code, failure3.message));
43154
43280
  }
43155
43281
  }
43156
43282
  async #observeOfficialTurnLifecycle(value2) {
@@ -45636,7 +45762,7 @@ var AppServerHost = class {
45636
45762
  thread,
45637
45763
  error51,
45638
45764
  (output) => this.#projectHarnessOutput(thread, output),
45639
- (failure2) => this.#diagnose(failure2)
45765
+ (failure3) => this.#diagnose(failure3)
45640
45766
  );
45641
45767
  } finally {
45642
45768
  this.#externalSteering.fault(
@@ -48057,12 +48183,12 @@ var DelegationWatchService = class {
48057
48183
  await this.#api.send({ threadId: notifyThreadId, message: notification(pending) });
48058
48184
  for (const watch of pending) this.#remove(watch);
48059
48185
  } catch (error51) {
48060
- const failure2 = deliveryFailure(error51);
48186
+ const failure3 = deliveryFailure(error51);
48061
48187
  const message2 = error51 instanceof Error ? error51.message : String(error51);
48062
48188
  for (const watch of pending) {
48063
- if (failure2 !== "rejected" || Date.now() >= (watch.deliveryDeadline ?? 0)) {
48189
+ if (failure3 !== "rejected" || Date.now() >= (watch.deliveryDeadline ?? 0)) {
48064
48190
  watch.state = "undeliverable";
48065
- watch.reason = failure2 === "unknown" ? `Delivery outcome unknown; the notification may already have started a Turn, so it is not retried (${message2})` : message2;
48191
+ watch.reason = failure3 === "unknown" ? `Delivery outcome unknown; the notification may already have started a Turn, so it is not retried (${message2})` : message2;
48066
48192
  }
48067
48193
  }
48068
48194
  this.#trimUndeliverable();
@@ -16550,6 +16550,37 @@ var voiceSettingsStateSchema = external_exports.strictObject({
16550
16550
  })
16551
16551
  });
16552
16552
 
16553
+ // ../../shared-contracts/dist/background-activity.js
16554
+ var backgroundActivitySchema = external_exports.strictObject({
16555
+ id: external_exports.string().min(1),
16556
+ kind: external_exports.enum(["task", "monitor", "loop", "subagent"]),
16557
+ label: external_exports.string(),
16558
+ status: external_exports.enum(["running", "scheduled", "completed", "failed", "cancelled", "unknown"]),
16559
+ canStop: external_exports.boolean(),
16560
+ /** Existing detached command Item presented by Desktop's native process UI. */
16561
+ commandItemId: hostItemIdSchema.optional(),
16562
+ schedule: external_exports.string().optional(),
16563
+ nextRunAt: external_exports.string().datetime({ offset: true }).optional(),
16564
+ relatedActivityId: external_exports.string().optional(),
16565
+ threadId: hostThreadIdSchema.optional()
16566
+ });
16567
+ var backgroundActivityDetailSchema = external_exports.strictObject({
16568
+ activity: backgroundActivitySchema,
16569
+ output: external_exports.string(),
16570
+ truncated: external_exports.boolean()
16571
+ });
16572
+ var threadActivityParamsSchema = external_exports.strictObject({ threadId: hostThreadIdSchema });
16573
+ var threadActivityItemParamsSchema = threadActivityParamsSchema.extend({
16574
+ activityId: external_exports.string().min(1)
16575
+ });
16576
+ var threadActivityListResultSchema = external_exports.strictObject({
16577
+ supported: external_exports.boolean(),
16578
+ activities: external_exports.array(backgroundActivitySchema)
16579
+ });
16580
+ var threadActivityStopResultSchema = external_exports.strictObject({
16581
+ outcome: external_exports.enum(["stopped", "alreadyStopped", "notFound"])
16582
+ });
16583
+
16553
16584
  // ../../shared-contracts/dist/index.js
16554
16585
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16555
16586