terminal-pilot 0.0.21 → 0.0.22

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 (58) hide show
  1. package/dist/cli.js +467 -193
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +6 -4
  4. package/dist/commands/close-session.js.map +3 -3
  5. package/dist/commands/create-session.js +6 -4
  6. package/dist/commands/create-session.js.map +3 -3
  7. package/dist/commands/fill.js +6 -4
  8. package/dist/commands/fill.js.map +3 -3
  9. package/dist/commands/get-session.js +6 -4
  10. package/dist/commands/get-session.js.map +3 -3
  11. package/dist/commands/index.js +79 -33
  12. package/dist/commands/index.js.map +4 -4
  13. package/dist/commands/install.js +64 -20
  14. package/dist/commands/install.js.map +4 -4
  15. package/dist/commands/installer.js +36 -2
  16. package/dist/commands/installer.js.map +4 -4
  17. package/dist/commands/list-sessions.js +6 -4
  18. package/dist/commands/list-sessions.js.map +3 -3
  19. package/dist/commands/press-key.js +6 -4
  20. package/dist/commands/press-key.js.map +3 -3
  21. package/dist/commands/read-history.js +6 -4
  22. package/dist/commands/read-history.js.map +3 -3
  23. package/dist/commands/read-screen.js +6 -4
  24. package/dist/commands/read-screen.js.map +3 -3
  25. package/dist/commands/resize.js +6 -4
  26. package/dist/commands/resize.js.map +3 -3
  27. package/dist/commands/runtime.js +6 -4
  28. package/dist/commands/runtime.js.map +3 -3
  29. package/dist/commands/screenshot.js +17 -8
  30. package/dist/commands/screenshot.js.map +3 -3
  31. package/dist/commands/send-signal.js +6 -4
  32. package/dist/commands/send-signal.js.map +3 -3
  33. package/dist/commands/type.js +6 -4
  34. package/dist/commands/type.js.map +3 -3
  35. package/dist/commands/uninstall.js +39 -5
  36. package/dist/commands/uninstall.js.map +4 -4
  37. package/dist/commands/wait-for-exit.js +6 -4
  38. package/dist/commands/wait-for-exit.js.map +3 -3
  39. package/dist/commands/wait-for.js +6 -4
  40. package/dist/commands/wait-for.js.map +3 -3
  41. package/dist/errors.d.ts +1 -0
  42. package/dist/errors.js +8 -0
  43. package/dist/errors.js.map +7 -0
  44. package/dist/index.js +8 -4
  45. package/dist/index.js.map +3 -3
  46. package/dist/terminal-pilot.js +6 -4
  47. package/dist/terminal-pilot.js.map +3 -3
  48. package/dist/terminal-session.js +6 -4
  49. package/dist/terminal-session.js.map +3 -3
  50. package/dist/testing/cli-repl.js +467 -193
  51. package/dist/testing/cli-repl.js.map +4 -4
  52. package/dist/testing/qa-cli.js +467 -193
  53. package/dist/testing/qa-cli.js.map +4 -4
  54. package/node_modules/@poe-code/agent-skill-config/dist/apply.js +4 -1
  55. package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +1 -1
  56. package/node_modules/@poe-code/agent-skill-config/dist/git-exclude.js +17 -9
  57. package/node_modules/@poe-code/agent-skill-config/dist/templates.js +4 -1
  58. package/package.json +1 -1
@@ -11,6 +11,11 @@ var claudeCodeAgent = {
11
11
  aliases: ["claude"],
12
12
  binaryName: "claude",
13
13
  apiShapes: ["anthropic-messages"],
14
+ otelCapture: {
15
+ env: {
16
+ CLAUDE_CODE_ENABLE_TELEMETRY: "1"
17
+ }
18
+ },
14
19
  configPath: "~/.claude/settings.json",
15
20
  branding: {
16
21
  colors: {
@@ -43,6 +48,16 @@ var codexAgent = {
43
48
  summary: "Configure Codex to use Poe as the model provider.",
44
49
  binaryName: "codex",
45
50
  apiShapes: ["openai-responses"],
51
+ otelCapture: {
52
+ args: (endpoint, content) => [
53
+ "-c",
54
+ `otel.trace_exporter={"otlp-http"={endpoint=${JSON.stringify(`${endpoint}/v1/traces`)},protocol="json"}}`,
55
+ "-c",
56
+ `otel.exporter={"otlp-http"={endpoint=${JSON.stringify(`${endpoint}/v1/logs`)},protocol="json"}}`,
57
+ "-c",
58
+ `otel.log_user_prompt=${content}`
59
+ ]
60
+ },
46
61
  configPath: "~/.codex/config.toml",
47
62
  branding: {
48
63
  colors: {
@@ -78,6 +93,11 @@ var openCodeAgent = {
78
93
  summary: "Configure OpenCode CLI to use the Poe API.",
79
94
  binaryName: "opencode",
80
95
  apiShapes: ["openai-chat-completions"],
96
+ otelCapture: {
97
+ env: {
98
+ OPENCODE_CONFIG_CONTENT: '{"experimental":{"openTelemetry":true}}'
99
+ }
100
+ },
81
101
  configPath: "~/.config/opencode/config.json",
82
102
  branding: {
83
103
  colors: {
@@ -113,6 +133,7 @@ var gooseAgent = {
113
133
  summary: "Block's open-source AI agent with ACP support.",
114
134
  binaryName: "goose",
115
135
  apiShapes: ["openai-chat-completions"],
136
+ otelCapture: {},
116
137
  configPath: "~/.config/goose/config.yaml",
117
138
  branding: {
118
139
  colors: {
@@ -146,6 +167,12 @@ function freezeAgent(agent) {
146
167
  if (agent.apiShapes !== void 0) {
147
168
  Object.freeze(agent.apiShapes);
148
169
  }
170
+ if (agent.otelCapture?.env !== void 0) {
171
+ Object.freeze(agent.otelCapture.env);
172
+ }
173
+ if (agent.otelCapture !== void 0) {
174
+ Object.freeze(agent.otelCapture);
175
+ }
149
176
  Object.freeze(agent.branding.colors);
150
177
  Object.freeze(agent.branding);
151
178
  return Object.freeze(agent);
@@ -305,6 +332,7 @@ var templateMutation = {
305
332
  };
306
333
 
307
334
  // ../config-mutations/src/execution/apply-mutation.ts
335
+ import { randomUUID } from "node:crypto";
308
336
  import path3 from "node:path";
309
337
 
310
338
  // ../toolcraft-design/src/internal/color-support.ts
@@ -1387,7 +1415,7 @@ function merge(base, patch) {
1387
1415
  if (value === void 0) {
1388
1416
  continue;
1389
1417
  }
1390
- const existing = result[key];
1418
+ const existing = hasConfigEntry(result, key) ? result[key] : void 0;
1391
1419
  if (isConfigObject(existing) && isConfigObject(value)) {
1392
1420
  setConfigEntry(result, key, merge(existing, value));
1393
1421
  continue;
@@ -1515,7 +1543,7 @@ function merge2(base, patch) {
1515
1543
  if (value === void 0) {
1516
1544
  continue;
1517
1545
  }
1518
- const existing = result[key];
1546
+ const existing = hasConfigEntry(result, key) ? result[key] : void 0;
1519
1547
  if (isConfigObject2(existing) && isConfigObject2(value)) {
1520
1548
  setConfigEntry(result, key, merge2(existing, value));
1521
1549
  continue;
@@ -1595,7 +1623,7 @@ function merge3(base, patch) {
1595
1623
  if (value === void 0) {
1596
1624
  continue;
1597
1625
  }
1598
- const existing = result[key];
1626
+ const existing = hasConfigEntry(result, key) ? result[key] : void 0;
1599
1627
  if (isConfigObject3(existing) && isConfigObject3(value)) {
1600
1628
  setConfigEntry(result, key, merge3(existing, value));
1601
1629
  continue;
@@ -1732,7 +1760,7 @@ function resolvePath(rawPath, homeDir, pathMapper) {
1732
1760
 
1733
1761
  // ../config-mutations/src/fs-utils.ts
1734
1762
  function isNotFound(error2) {
1735
- return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
1763
+ return typeof error2 === "object" && error2 !== null && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === "ENOENT";
1736
1764
  }
1737
1765
  async function readFileIfExists(fs3, target) {
1738
1766
  try {
@@ -1781,6 +1809,7 @@ async function backupInvalidDocument(context, targetPath, content) {
1781
1809
  return;
1782
1810
  } catch (error2) {
1783
1811
  if (!isAlreadyExists(error2)) {
1812
+ await context.fs.unlink(backupPath).catch(() => void 0);
1784
1813
  throw error2;
1785
1814
  }
1786
1815
  attempt += 1;
@@ -1788,7 +1817,7 @@ async function backupInvalidDocument(context, targetPath, content) {
1788
1817
  }
1789
1818
  }
1790
1819
  function isAlreadyExists(error2) {
1791
- return Boolean(error2 && typeof error2 === "object" && "code" in error2 && error2.code === "EEXIST");
1820
+ return typeof error2 === "object" && error2 !== null && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === "EEXIST";
1792
1821
  }
1793
1822
  async function assertRegularWriteTarget(context, targetPath) {
1794
1823
  const boundary = path3.dirname(path3.resolve(context.homeDir));
@@ -1812,28 +1841,34 @@ async function assertRegularWriteTarget(context, targetPath) {
1812
1841
  }
1813
1842
  async function writeAtomically(context, targetPath, content) {
1814
1843
  await assertRegularWriteTarget(context, targetPath);
1815
- let attempt = 0;
1816
- while (true) {
1817
- const tempPath = `${targetPath}.mutation-tmp-${attempt}`;
1844
+ for (let attempt = 0; attempt < 10; attempt += 1) {
1845
+ const tempPath = `${targetPath}.mutation-tmp-${process.pid}-${randomUUID()}`;
1846
+ let tempCreated = false;
1818
1847
  try {
1848
+ await assertRegularWriteTarget(context, tempPath);
1819
1849
  await context.fs.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
1850
+ tempCreated = true;
1820
1851
  await context.fs.rename(tempPath, targetPath);
1852
+ tempCreated = false;
1821
1853
  return;
1822
1854
  } catch (error2) {
1823
- if (isAlreadyExists(error2)) {
1824
- attempt += 1;
1825
- continue;
1826
- }
1827
- try {
1828
- await context.fs.unlink(tempPath);
1829
- } catch (cleanupError) {
1830
- if (!isNotFound(cleanupError)) {
1831
- void cleanupError;
1855
+ const alreadyExists = isAlreadyExists(error2);
1856
+ if (tempCreated || !alreadyExists) {
1857
+ try {
1858
+ await context.fs.unlink(tempPath);
1859
+ } catch (cleanupError) {
1860
+ if (!isNotFound(cleanupError)) {
1861
+ void cleanupError;
1862
+ }
1832
1863
  }
1833
1864
  }
1865
+ if (alreadyExists) {
1866
+ continue;
1867
+ }
1834
1868
  throw error2;
1835
1869
  }
1836
1870
  }
1871
+ throw new Error(`Unable to create temporary mutation file for ${targetPath}.`);
1837
1872
  }
1838
1873
  function describeMutation(kind, targetPath) {
1839
1874
  const displayPath = targetPath ?? "target";
@@ -2125,6 +2160,7 @@ async function applyBackup(mutation, context, options) {
2125
2160
  break;
2126
2161
  } catch (error2) {
2127
2162
  if (!isAlreadyExists(error2)) {
2163
+ await context.fs.unlink(backupPath).catch(() => void 0);
2128
2164
  throw error2;
2129
2165
  }
2130
2166
  attempt += 1;
@@ -2532,7 +2568,7 @@ async function pathExists2(fs3, targetPath) {
2532
2568
  await fs3.stat(targetPath);
2533
2569
  return true;
2534
2570
  } catch (error2) {
2535
- if (error2 && typeof error2 === "object" && "code" in error2 && error2.code === "ENOENT") {
2571
+ if (typeof error2 === "object" && error2 !== null && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === "ENOENT") {
2536
2572
  return false;
2537
2573
  }
2538
2574
  throw error2;
@@ -2591,12 +2627,13 @@ import path5 from "node:path";
2591
2627
 
2592
2628
  // ../agent-skill-config/src/git-exclude.ts
2593
2629
  import { execFileSync } from "node:child_process";
2630
+ import { randomUUID as randomUUID2 } from "node:crypto";
2594
2631
  import * as fs from "node:fs";
2595
2632
  import path6 from "node:path";
2596
2633
 
2597
2634
  // ../agent-skill-config/src/bridge-active-skills.ts
2598
2635
  import * as fs2 from "node:fs";
2599
- import { createHash, randomUUID } from "node:crypto";
2636
+ import { createHash, randomUUID as randomUUID3 } from "node:crypto";
2600
2637
  import path7 from "node:path";
2601
2638
 
2602
2639
  // ../toolcraft/src/index.ts
@@ -3017,12 +3054,19 @@ import os2 from "node:os";
3017
3054
  import path9 from "node:path";
3018
3055
  import * as nodeFs from "node:fs/promises";
3019
3056
  import { readFile as readFile2 } from "node:fs/promises";
3057
+
3058
+ // src/errors.ts
3059
+ function hasOwnErrorCode(error2, code) {
3060
+ return error2 instanceof Error && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === code;
3061
+ }
3062
+
3063
+ // src/commands/installer.ts
3020
3064
  var DEFAULT_INSTALL_AGENT = "claude-code";
3021
3065
  var DEFAULT_INSTALL_SCOPE = "local";
3022
3066
  var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
3023
3067
  var installableAgents = supportedAgents;
3024
3068
  function isNotFoundError(error2) {
3025
- return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
3069
+ return hasOwnErrorCode(error2, "ENOENT");
3026
3070
  }
3027
3071
  function resolveInstallerServices(installer) {
3028
3072
  return {