@zixt/host 0.0.16 → 0.0.18

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.js +65 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ import { homedir } from "node:os";
31
31
  // package.json
32
32
  var package_default = {
33
33
  name: "@zixt/host",
34
- version: "0.0.16",
34
+ version: "0.0.18",
35
35
  type: "module",
36
36
  exports: {
37
37
  ".": "./src/client.ts",
@@ -15334,10 +15334,46 @@ var Host = external_exports.object({
15334
15334
  });
15335
15335
 
15336
15336
  // ../../packages/contracts/src/api.ts
15337
+ var ProblemCode = external_exports.enum([
15338
+ "network_unavailable",
15339
+ "not_authorized",
15340
+ "not_found",
15341
+ "invalid_input",
15342
+ "changed",
15343
+ "rate_limited",
15344
+ "service_unavailable",
15345
+ "machine_offline",
15346
+ "machine_return_required",
15347
+ "access_required",
15348
+ "unknown"
15349
+ ]);
15350
+ var ProblemSubject = external_exports.object({
15351
+ kind: external_exports.enum(["organization", "task", "machine", "integration", "credential", "teammate"]),
15352
+ id: external_exports.string().min(1).max(300).optional(),
15353
+ name: external_exports.string().min(1).max(300).optional()
15354
+ });
15355
+ var ProblemRecovery = external_exports.discriminatedUnion("kind", [
15356
+ external_exports.object({ kind: external_exports.literal("retry"), afterSeconds: external_exports.number().int().min(0).optional() }),
15357
+ external_exports.object({ kind: external_exports.literal("open_integration"), integrationId: external_exports.string().optional() }),
15358
+ external_exports.object({ kind: external_exports.literal("open_credential"), name: external_exports.string().optional() }),
15359
+ external_exports.object({ kind: external_exports.literal("open_machine"), machineId: external_exports.string().optional() }),
15360
+ external_exports.object({ kind: external_exports.literal("contact_admin") }),
15361
+ external_exports.object({ kind: external_exports.literal("wait_for_machine") }),
15362
+ external_exports.object({ kind: external_exports.literal("contact_support"), incidentId: external_exports.string().min(1).max(300) })
15363
+ ]);
15364
+ var Problem = external_exports.object({
15365
+ code: ProblemCode,
15366
+ state: external_exports.enum(["blocking", "degraded", "waiting"]),
15367
+ subject: ProblemSubject,
15368
+ parameters: external_exports.record(external_exports.string(), external_exports.union([external_exports.string(), external_exports.number(), external_exports.boolean(), external_exports.null()])),
15369
+ recovery: ProblemRecovery,
15370
+ evidenceAt: IsoDate2.optional()
15371
+ });
15337
15372
  var ApiError = external_exports.object({
15338
15373
  error: external_exports.object({
15339
15374
  code: external_exports.string(),
15340
- message: external_exports.string()
15375
+ message: external_exports.string(),
15376
+ problem: Problem.optional()
15341
15377
  })
15342
15378
  });
15343
15379
  var CreateOrgRequest = external_exports.object({
@@ -17928,9 +17964,17 @@ var TaskAssign = external_exports.object({
17928
17964
  /** True on continuation runs — the runner resumes instead of starting fresh. */
17929
17965
  resume: external_exports.boolean().optional(),
17930
17966
  /**
17931
- * The Task still carries its derived first-message name and wants an
17932
- * AI-minted one (TS-12). The host answers with one `task.title` frame;
17933
- * absence (older host, demo runner) simply keeps the derived name.
17967
+ * Cloud-authored, trust-preserving copy of the opening request. A Host
17968
+ * uses it only when a continuation cannot resume the local CLI session
17969
+ * and must start a new one (Machine loss, runner switch, or missing local
17970
+ * transcript). Optional for rolling upgrades and first runs.
17971
+ */
17972
+ recoveryContext: external_exports.string().max(12e4).optional(),
17973
+ /**
17974
+ * Execution epoch 1 still carries its derived first-message name and
17975
+ * wants one AI-minted replacement (TS-12). Later executions never ask to
17976
+ * rename the Task; absence (older host, demo runner) keeps the derived
17977
+ * name permanently.
17934
17978
  */
17935
17979
  titleWanted: external_exports.boolean().optional(),
17936
17980
  /** Advisory Ask / Plan / Act snapshot for this attempt (TS-12). */
@@ -33565,9 +33609,9 @@ function createCliRunner(adapter, opts = {}) {
33565
33609
  };
33566
33610
  }
33567
33611
  if (task.cancelledNow()) return cancelledBeforeRun();
33568
- const runPrompt = attachmentSection ? `${prepared.prompt}
33612
+ const promptWithAttachments = (prompt) => attachmentSection ? `${prompt}
33569
33613
 
33570
- ${attachmentSection}` : prepared.prompt;
33614
+ ${attachmentSection}` : prompt;
33571
33615
  let activeWorkingContextReport = null;
33572
33616
  let previousWorkingContext = "";
33573
33617
  const workingContextAbort = new AbortController();
@@ -33681,7 +33725,9 @@ ${attachmentSection}` : prepared.prompt;
33681
33725
  },
33682
33726
  cwd,
33683
33727
  env: runEnv,
33684
- prompt: runPrompt,
33728
+ prompt: promptWithAttachments(
33729
+ task.spec.resume && mode2 === "new" ? prepared.recoveryPrompt ?? prepared.prompt : prepared.prompt
33730
+ ),
33685
33731
  ...maxWallTimeMs === void 0 ? {} : { maxWallTimeMs },
33686
33732
  clockPaused: () => pendingAsks > 0,
33687
33733
  cancelled: task.cancelled,
@@ -33957,15 +34003,14 @@ function trustedWorkspaceSystemPrompt(existing, workspace, taskRoot) {
33957
34003
 
33958
34004
  ${guidance}` : guidance;
33959
34005
  }
33960
- function buildRunnerPrompt(task) {
33961
- if (task.spec.origin?.trust === "external") {
33962
- return `# Task: External-origin task
34006
+ function buildRunnerPrompt(task, recoverContinuation = false) {
34007
+ const current = task.spec.origin?.trust === "external" ? `# Task: External-origin task
33963
34008
 
33964
- ${task.spec.instructions}`;
33965
- }
33966
- return `# Task: ${task.spec.title}
34009
+ ${task.spec.instructions}` : `# Task: ${task.spec.title}
33967
34010
 
33968
34011
  ${task.spec.instructions}`;
34012
+ if (!recoverContinuation || !task.spec.recoveryContext) return current;
34013
+ return [task.spec.recoveryContext, "", "## Current request", "", current].join("\n");
33969
34014
  }
33970
34015
  function runnerGuardianEnv(inherited = process.env, containmentGateNonce) {
33971
34016
  const allowed = /* @__PURE__ */ new Set([
@@ -34443,6 +34488,7 @@ var claudeCodeAdapter = {
34443
34488
  ...mode === "resume" ? ["--resume", sessionId] : ["--session-id", sessionId]
34444
34489
  ],
34445
34490
  prompt: buildRunnerPrompt(input.task),
34491
+ recoveryPrompt: buildRunnerPrompt(input.task, true),
34446
34492
  createParser: (onStream) => createStreamParser(onStream, { onSessionModel: observeRuntime }),
34447
34493
  // Self-heal both directions: a crashed first run leaves a transcript
34448
34494
  // (new → conflict), a lost workspace breaks resume (resume → not
@@ -34760,11 +34806,13 @@ function createCodexAdapter(threadIndexRoot) {
34760
34806
  task.siblingTasks(),
34761
34807
  input.gitDetected
34762
34808
  );
34763
- const prompt = platformInstructions ? `<zixt_platform_instructions>
34809
+ const withPlatformInstructions = (prompt2) => platformInstructions ? `<zixt_platform_instructions>
34764
34810
  ${platformInstructions}
34765
34811
  </zixt_platform_instructions>
34766
34812
 
34767
- ${buildRunnerPrompt(task)}` : buildRunnerPrompt(task);
34813
+ ${prompt2}` : prompt2;
34814
+ const prompt = withPlatformInstructions(buildRunnerPrompt(task));
34815
+ const recoveryPrompt = withPlatformInstructions(buildRunnerPrompt(task, true));
34768
34816
  const sessionKey = task.spec.sessionKey;
34769
34817
  const indexPath = sessionKey ? threadIndexPath(threadIndexRoot, task.agentId, sessionKey) : null;
34770
34818
  const recordedThreadId = indexPath ? await readThreadId(indexPath) : null;
@@ -34784,6 +34832,7 @@ ${buildRunnerPrompt(task)}` : buildRunnerPrompt(task);
34784
34832
  return ["exec", ...flags, "-"];
34785
34833
  },
34786
34834
  prompt,
34835
+ recoveryPrompt,
34787
34836
  env,
34788
34837
  createParser: (onStream) => createCodexStreamParser(onStream, {
34789
34838
  onThreadStarted: (threadId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zixt/host",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./src/client.ts",