terminal-pilot 0.0.21 → 0.0.23

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 (61) hide show
  1. package/dist/cli.js +614 -250
  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.d.ts +35 -35
  12. package/dist/commands/index.js +97 -36
  13. package/dist/commands/index.js.map +4 -4
  14. package/dist/commands/install.js +74 -20
  15. package/dist/commands/install.js.map +4 -4
  16. package/dist/commands/installer.js +36 -2
  17. package/dist/commands/installer.js.map +4 -4
  18. package/dist/commands/list-sessions.js +6 -4
  19. package/dist/commands/list-sessions.js.map +3 -3
  20. package/dist/commands/press-key.js +6 -4
  21. package/dist/commands/press-key.js.map +3 -3
  22. package/dist/commands/read-history.js +6 -4
  23. package/dist/commands/read-history.js.map +3 -3
  24. package/dist/commands/read-screen.js +6 -4
  25. package/dist/commands/read-screen.js.map +3 -3
  26. package/dist/commands/resize.js +6 -4
  27. package/dist/commands/resize.js.map +3 -3
  28. package/dist/commands/runtime.js +6 -4
  29. package/dist/commands/runtime.js.map +3 -3
  30. package/dist/commands/screenshot.js +22 -8
  31. package/dist/commands/screenshot.js.map +4 -4
  32. package/dist/commands/send-signal.js +6 -4
  33. package/dist/commands/send-signal.js.map +3 -3
  34. package/dist/commands/type.js +6 -4
  35. package/dist/commands/type.js.map +3 -3
  36. package/dist/commands/uninstall.js +39 -5
  37. package/dist/commands/uninstall.js.map +4 -4
  38. package/dist/commands/wait-for-exit.js +6 -4
  39. package/dist/commands/wait-for-exit.js.map +3 -3
  40. package/dist/commands/wait-for.js +6 -4
  41. package/dist/commands/wait-for.js.map +3 -3
  42. package/dist/errors.d.ts +1 -0
  43. package/dist/errors.js +8 -0
  44. package/dist/errors.js.map +7 -0
  45. package/dist/index.js +8 -4
  46. package/dist/index.js.map +3 -3
  47. package/dist/terminal-pilot.js +6 -4
  48. package/dist/terminal-pilot.js.map +3 -3
  49. package/dist/terminal-session.js +6 -4
  50. package/dist/terminal-session.js.map +3 -3
  51. package/dist/testing/cli-repl.js +614 -250
  52. package/dist/testing/cli-repl.js.map +4 -4
  53. package/dist/testing/qa-cli.js +614 -250
  54. package/dist/testing/qa-cli.js.map +4 -4
  55. package/node_modules/@poe-code/agent-skill-config/dist/apply.js +2 -1
  56. package/node_modules/@poe-code/agent-skill-config/dist/bridge-active-skills.js +8 -9
  57. package/node_modules/@poe-code/agent-skill-config/dist/error-codes.d.ts +1 -0
  58. package/node_modules/@poe-code/agent-skill-config/dist/error-codes.js +5 -0
  59. package/node_modules/@poe-code/agent-skill-config/dist/git-exclude.js +18 -12
  60. package/node_modules/@poe-code/agent-skill-config/dist/templates.js +2 -1
  61. 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;
@@ -1730,9 +1758,14 @@ function resolvePath(rawPath, homeDir, pathMapper) {
1730
1758
  return filename.length === 0 ? mappedDirectory : path2.join(mappedDirectory, filename);
1731
1759
  }
1732
1760
 
1761
+ // ../config-mutations/src/error-codes.ts
1762
+ function hasOwnErrorCode(error2, code) {
1763
+ return typeof error2 === "object" && error2 !== null && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === code;
1764
+ }
1765
+
1733
1766
  // ../config-mutations/src/fs-utils.ts
1734
1767
  function isNotFound(error2) {
1735
- return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
1768
+ return hasOwnErrorCode(error2, "ENOENT");
1736
1769
  }
1737
1770
  async function readFileIfExists(fs3, target) {
1738
1771
  try {
@@ -1781,6 +1814,7 @@ async function backupInvalidDocument(context, targetPath, content) {
1781
1814
  return;
1782
1815
  } catch (error2) {
1783
1816
  if (!isAlreadyExists(error2)) {
1817
+ await context.fs.unlink(backupPath).catch(() => void 0);
1784
1818
  throw error2;
1785
1819
  }
1786
1820
  attempt += 1;
@@ -1788,7 +1822,7 @@ async function backupInvalidDocument(context, targetPath, content) {
1788
1822
  }
1789
1823
  }
1790
1824
  function isAlreadyExists(error2) {
1791
- return Boolean(error2 && typeof error2 === "object" && "code" in error2 && error2.code === "EEXIST");
1825
+ return hasOwnErrorCode(error2, "EEXIST");
1792
1826
  }
1793
1827
  async function assertRegularWriteTarget(context, targetPath) {
1794
1828
  const boundary = path3.dirname(path3.resolve(context.homeDir));
@@ -1812,28 +1846,34 @@ async function assertRegularWriteTarget(context, targetPath) {
1812
1846
  }
1813
1847
  async function writeAtomically(context, targetPath, content) {
1814
1848
  await assertRegularWriteTarget(context, targetPath);
1815
- let attempt = 0;
1816
- while (true) {
1817
- const tempPath = `${targetPath}.mutation-tmp-${attempt}`;
1849
+ for (let attempt = 0; attempt < 10; attempt += 1) {
1850
+ const tempPath = `${targetPath}.mutation-tmp-${process.pid}-${randomUUID()}`;
1851
+ let tempCreated = false;
1818
1852
  try {
1853
+ await assertRegularWriteTarget(context, tempPath);
1819
1854
  await context.fs.writeFile(tempPath, content, { encoding: "utf8", flag: "wx" });
1855
+ tempCreated = true;
1820
1856
  await context.fs.rename(tempPath, targetPath);
1857
+ tempCreated = false;
1821
1858
  return;
1822
1859
  } 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;
1860
+ const alreadyExists = isAlreadyExists(error2);
1861
+ if (tempCreated || !alreadyExists) {
1862
+ try {
1863
+ await context.fs.unlink(tempPath);
1864
+ } catch (cleanupError) {
1865
+ if (!isNotFound(cleanupError)) {
1866
+ void cleanupError;
1867
+ }
1832
1868
  }
1833
1869
  }
1870
+ if (alreadyExists) {
1871
+ continue;
1872
+ }
1834
1873
  throw error2;
1835
1874
  }
1836
1875
  }
1876
+ throw new Error(`Unable to create temporary mutation file for ${targetPath}.`);
1837
1877
  }
1838
1878
  function describeMutation(kind, targetPath) {
1839
1879
  const displayPath = targetPath ?? "target";
@@ -2125,6 +2165,7 @@ async function applyBackup(mutation, context, options) {
2125
2165
  break;
2126
2166
  } catch (error2) {
2127
2167
  if (!isAlreadyExists(error2)) {
2168
+ await context.fs.unlink(backupPath).catch(() => void 0);
2128
2169
  throw error2;
2129
2170
  }
2130
2171
  attempt += 1;
@@ -2508,6 +2549,11 @@ async function executeMutation(mutation, context, options) {
2508
2549
  }
2509
2550
  }
2510
2551
 
2552
+ // ../agent-skill-config/src/error-codes.ts
2553
+ function hasOwnErrorCode2(error2, code) {
2554
+ return error2 instanceof Error && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === code;
2555
+ }
2556
+
2511
2557
  // ../agent-skill-config/src/templates.ts
2512
2558
  import { readFile, stat } from "node:fs/promises";
2513
2559
  import path4 from "node:path";
@@ -2532,7 +2578,7 @@ async function pathExists2(fs3, targetPath) {
2532
2578
  await fs3.stat(targetPath);
2533
2579
  return true;
2534
2580
  } catch (error2) {
2535
- if (error2 && typeof error2 === "object" && "code" in error2 && error2.code === "ENOENT") {
2581
+ if (hasOwnErrorCode2(error2, "ENOENT")) {
2536
2582
  return false;
2537
2583
  }
2538
2584
  throw error2;
@@ -2591,12 +2637,13 @@ import path5 from "node:path";
2591
2637
 
2592
2638
  // ../agent-skill-config/src/git-exclude.ts
2593
2639
  import { execFileSync } from "node:child_process";
2640
+ import { randomUUID as randomUUID2 } from "node:crypto";
2594
2641
  import * as fs from "node:fs";
2595
2642
  import path6 from "node:path";
2596
2643
 
2597
2644
  // ../agent-skill-config/src/bridge-active-skills.ts
2598
2645
  import * as fs2 from "node:fs";
2599
- import { createHash, randomUUID } from "node:crypto";
2646
+ import { createHash, randomUUID as randomUUID3 } from "node:crypto";
2600
2647
  import path7 from "node:path";
2601
2648
 
2602
2649
  // ../toolcraft/src/index.ts
@@ -3017,12 +3064,19 @@ import os2 from "node:os";
3017
3064
  import path9 from "node:path";
3018
3065
  import * as nodeFs from "node:fs/promises";
3019
3066
  import { readFile as readFile2 } from "node:fs/promises";
3067
+
3068
+ // src/errors.ts
3069
+ function hasOwnErrorCode3(error2, code) {
3070
+ return error2 instanceof Error && Object.prototype.hasOwnProperty.call(error2, "code") && error2.code === code;
3071
+ }
3072
+
3073
+ // src/commands/installer.ts
3020
3074
  var DEFAULT_INSTALL_AGENT = "claude-code";
3021
3075
  var DEFAULT_INSTALL_SCOPE = "local";
3022
3076
  var TERMINAL_PILOT_SKILL_NAME = "terminal-pilot";
3023
3077
  var installableAgents = supportedAgents;
3024
3078
  function isNotFoundError(error2) {
3025
- return typeof error2 === "object" && error2 !== null && "code" in error2 && error2.code === "ENOENT";
3079
+ return hasOwnErrorCode3(error2, "ENOENT");
3026
3080
  }
3027
3081
  function resolveInstallerServices(installer) {
3028
3082
  return {