@astralyn/pi 1.0.3 → 1.0.5

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 (135) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/bundle/chunks/{anthropic-messages-YET4T7BO.js → anthropic-messages-YIOJIMVL.js} +1 -1
  3. package/dist/bundle/chunks/azure-openai-responses-LDW4FGAQ.js +2 -0
  4. package/dist/bundle/chunks/{chunk-MPDALHNJ.js → chunk-57XI7YJH.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-SVJ7OGEB.js → chunk-A6ALEEY5.js} +1 -1
  6. package/dist/bundle/chunks/chunk-D3ZCGC4T.js +2 -0
  7. package/dist/bundle/chunks/{chunk-N2LEX5CU.js → chunk-HDHRZ7GT.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-Q7TDQ5LT.js → chunk-IE3Z7ESB.js} +184 -79
  9. package/dist/bundle/chunks/{chunk-IZ3S3GDX.js → chunk-IFELM7MW.js} +1 -1
  10. package/dist/bundle/chunks/chunk-RZ2V53SP.js +2 -0
  11. package/dist/bundle/chunks/{chunk-V66VGGOM.js → chunk-TCQ4HHQD.js} +1 -1
  12. package/dist/bundle/chunks/chunk-TXJO4AJ7.js +11 -0
  13. package/dist/bundle/chunks/{chunk-NY3CWK44.js → chunk-UCXU7KLO.js} +1 -1
  14. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-QI46LUZ6.js → cloudflare-workers-ai-system-one-OWU5SM6J.js} +1 -1
  15. package/dist/bundle/chunks/codemode-worker.js +99 -4
  16. package/dist/bundle/chunks/{google-generative-ai-YTZCSHQN.js → google-generative-ai-S5A5IBU4.js} +1 -1
  17. package/dist/bundle/chunks/{google-vertex-OTFZJJXQ.js → google-vertex-UBRQFDB4.js} +1 -1
  18. package/dist/bundle/chunks/{mistral-conversations-ELH4V4TY.js → mistral-conversations-A2N5FSOV.js} +1 -1
  19. package/dist/bundle/chunks/{openai-codex-responses-OLVTU4UA.js → openai-codex-responses-Q6JHCWLE.js} +1 -1
  20. package/dist/bundle/chunks/{openai-completions-53M2KJ67.js → openai-completions-H4VMO7AU.js} +1 -1
  21. package/dist/bundle/chunks/{openai-responses-4ABDEL4Z.js → openai-responses-G4PGNM2H.js} +1 -1
  22. package/dist/bundle/chunks/{typesafe-system-one-RREJAKWB.js → typesafe-system-one-KYKKNU3E.js} +1 -1
  23. package/dist/bundle/chunks/virtual-modules-46MSJGKO.js +2 -0
  24. package/dist/bundle/cli.js +1 -1
  25. package/dist/bundle/index.js +1 -1
  26. package/dist/bundle/rpc-entry.js +1 -1
  27. package/dist/cli/args.d.ts +1 -0
  28. package/dist/cli/args.d.ts.map +1 -1
  29. package/dist/cli/args.js +11 -4
  30. package/dist/cli/args.js.map +1 -1
  31. package/dist/config.d.ts +18 -1
  32. package/dist/config.d.ts.map +1 -1
  33. package/dist/config.js +44 -6
  34. package/dist/config.js.map +1 -1
  35. package/dist/core/agent-session.d.ts +26 -4
  36. package/dist/core/agent-session.d.ts.map +1 -1
  37. package/dist/core/agent-session.js +44 -12
  38. package/dist/core/agent-session.js.map +1 -1
  39. package/dist/core/bash-executor.d.ts.map +1 -1
  40. package/dist/core/bash-executor.js +2 -7
  41. package/dist/core/bash-executor.js.map +1 -1
  42. package/dist/core/extensions/types.d.ts +2 -0
  43. package/dist/core/extensions/types.d.ts.map +1 -1
  44. package/dist/core/extensions/types.js.map +1 -1
  45. package/dist/core/keybindings.d.ts +4 -4
  46. package/dist/core/mcp-servers.d.ts +8 -0
  47. package/dist/core/mcp-servers.d.ts.map +1 -1
  48. package/dist/core/mcp-servers.js +30 -7
  49. package/dist/core/mcp-servers.js.map +1 -1
  50. package/dist/core/model-resolver.js +1 -1
  51. package/dist/core/model-resolver.js.map +1 -1
  52. package/dist/core/resource-loader.d.ts +3 -0
  53. package/dist/core/resource-loader.d.ts.map +1 -1
  54. package/dist/core/resource-loader.js +3 -3
  55. package/dist/core/resource-loader.js.map +1 -1
  56. package/dist/core/sdk.d.ts +9 -4
  57. package/dist/core/sdk.d.ts.map +1 -1
  58. package/dist/core/sdk.js +3 -2
  59. package/dist/core/sdk.js.map +1 -1
  60. package/dist/core/skills.d.ts +4 -1
  61. package/dist/core/skills.d.ts.map +1 -1
  62. package/dist/core/skills.js +6 -1
  63. package/dist/core/skills.js.map +1 -1
  64. package/dist/core/system-prompt.d.ts +6 -0
  65. package/dist/core/system-prompt.d.ts.map +1 -1
  66. package/dist/core/system-prompt.js +9 -4
  67. package/dist/core/system-prompt.js.map +1 -1
  68. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  69. package/dist/core/tools/output-accumulator.js +6 -11
  70. package/dist/core/tools/output-accumulator.js.map +1 -1
  71. package/dist/core/tools/read.d.ts +13 -0
  72. package/dist/core/tools/read.d.ts.map +1 -1
  73. package/dist/core/tools/read.js +18 -1
  74. package/dist/core/tools/read.js.map +1 -1
  75. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  76. package/dist/extensions/codemode/execute.js +51 -9
  77. package/dist/extensions/codemode/execute.js.map +1 -1
  78. package/dist/extensions/codemode/index.d.ts.map +1 -1
  79. package/dist/extensions/codemode/index.js +1 -0
  80. package/dist/extensions/codemode/index.js.map +1 -1
  81. package/dist/extensions/codemode/tool.d.ts +9 -2
  82. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  83. package/dist/extensions/codemode/tool.js +13 -5
  84. package/dist/extensions/codemode/tool.js.map +1 -1
  85. package/dist/extensions/mcp/resources.d.ts +3 -4
  86. package/dist/extensions/mcp/resources.d.ts.map +1 -1
  87. package/dist/extensions/mcp/resources.js +3 -4
  88. package/dist/extensions/mcp/resources.js.map +1 -1
  89. package/dist/extensions/mcp/runtime.d.ts +4 -1
  90. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  91. package/dist/extensions/mcp/runtime.js +22 -5
  92. package/dist/extensions/mcp/runtime.js.map +1 -1
  93. package/dist/extensions/mcp/tools.d.ts +2 -1
  94. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  95. package/dist/extensions/mcp/tools.js +6 -10
  96. package/dist/extensions/mcp/tools.js.map +1 -1
  97. package/dist/main.d.ts.map +1 -1
  98. package/dist/main.js +1 -0
  99. package/dist/main.js.map +1 -1
  100. package/dist/modes/interactive/interactive-mode.d.ts +7 -0
  101. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  102. package/dist/modes/interactive/interactive-mode.js +42 -6
  103. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  104. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  105. package/dist/modes/interactive/theme/theme.js +1 -0
  106. package/dist/modes/interactive/theme/theme.js.map +1 -1
  107. package/dist/utils/output-files.d.ts +17 -0
  108. package/dist/utils/output-files.d.ts.map +1 -0
  109. package/dist/utils/output-files.js +30 -0
  110. package/dist/utils/output-files.js.map +1 -0
  111. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  112. package/dist/utils/syntax-highlight.js +6 -1
  113. package/dist/utils/syntax-highlight.js.map +1 -1
  114. package/docs/codemode.md +6 -5
  115. package/docs/extensions.md +1 -1
  116. package/docs/keybindings.md +7 -7
  117. package/docs/mcp.md +3 -1
  118. package/docs/providers.md +5 -1
  119. package/docs/settings.md +1 -1
  120. package/docs/usage.md +15 -3
  121. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  122. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  123. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  124. package/examples/extensions/gondolin/package-lock.json +2 -2
  125. package/examples/extensions/gondolin/package.json +1 -1
  126. package/examples/extensions/sandbox/package-lock.json +2 -2
  127. package/examples/extensions/sandbox/package.json +1 -1
  128. package/examples/extensions/with-deps/package-lock.json +2 -2
  129. package/examples/extensions/with-deps/package.json +1 -1
  130. package/npm-shrinkwrap.json +54 -54
  131. package/package.json +11 -11
  132. package/dist/bundle/chunks/azure-openai-responses-SBLL5YN3.js +0 -2
  133. package/dist/bundle/chunks/chunk-G4RY3GN7.js +0 -11
  134. package/dist/bundle/chunks/chunk-TRHTWM3C.js +0 -2
  135. package/dist/bundle/chunks/virtual-modules-UUHBXSJB.js +0 -2
@@ -13,7 +13,7 @@ import * as TuiLayouts from "@earendil-works/pi-tui";
13
13
  import { CombinedAutocompleteProvider, Container, fuzzyFilter, getCapabilities, hyperlink, Markdown, matchesKey, Spacer, setCapabilityOverrides, setKeybindings, Text, TruncatedText, TuiAltScreen, TuiMainScreen, visibleWidth, } from "@earendil-works/pi-tui";
14
14
  import chalk from "chalk";
15
15
  import { spawn } from "child_process";
16
- import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, INSTALL_TELEMETRY_URL, UPDATE_CHANGELOG_HINT, VERSION, } from "../../config.js";
16
+ import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, detectInstallChange, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, INSTALL_TELEMETRY_URL, UPDATE_CHANGELOG_HINT, VERSION, } from "../../config.js";
17
17
  import { parseSkillBlock } from "../../core/agent-session.js";
18
18
  import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
19
19
  import { CACHE_TTL_MS, collectCacheMisses, computeCacheWaste, detectCacheMiss, } from "../../core/cache-stats.js";
@@ -147,7 +147,9 @@ function hotkeysTaskSection(display) {
147
147
  | \`${display("app.tasks.detachSelected")}\` | ${detachSelected.description} (while /tasks is open) |
148
148
  `;
149
149
  }
150
- const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN"]);
150
+ // EIO: tty reads/ioctls from an orphaned background process group, or writes after hangup.
151
+ // ENOTTY: the tty was revoked (macOS) and stdin is no longer a terminal.
152
+ const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN", "ENOTTY"]);
151
153
  function isDeadTerminalError(error) {
152
154
  if (!error || typeof error !== "object" || !("code" in error)) {
153
155
  return false;
@@ -326,6 +328,7 @@ export class InteractiveMode {
326
328
  this.shutdownRequested = false;
327
329
  /** The `/bug` hint is shown at most once per session so error output stays readable. */
328
330
  this.bugReportHintShown = false;
331
+ this.installChangeWarningShown = false;
329
332
  // Extension UI state
330
333
  this.extensionSelector = undefined;
331
334
  this.extensionInput = undefined;
@@ -1654,8 +1657,32 @@ export class InteractiveMode {
1654
1657
  return;
1655
1658
  if (/\b(?:abort(?:ed)?|cancel(?:l?ed)?)\b/i.test(message.errorMessage ?? ""))
1656
1659
  return;
1660
+ if (this.maybeShowInstallChangeWarning())
1661
+ return;
1657
1662
  this.suggestBugReport();
1658
1663
  }
1664
+ /**
1665
+ * After an error, check whether an update replaced or removed this install while the session ran.
1666
+ * Code loaded on demand then fails with missing modules until restart (#10439). Returns true when
1667
+ * the install changed.
1668
+ */
1669
+ maybeShowInstallChangeWarning() {
1670
+ if (this.installChangeWarningShown)
1671
+ return true;
1672
+ const change = detectInstallChange();
1673
+ if (!change)
1674
+ return false;
1675
+ this.installChangeWarningShown = true;
1676
+ const cause = change.kind === "updated"
1677
+ ? `${APP_NAME} was updated to ${change.version} while this session was running (${VERSION})`
1678
+ : `The ${APP_NAME} installation this session runs from was removed or replaced`;
1679
+ const resumeCommand = formatResumeCommand(this.sessionManager);
1680
+ const restart = resumeCommand
1681
+ ? `Restart with \`${resumeCommand}\` to continue this session.`
1682
+ : `Restart ${APP_NAME}.`;
1683
+ this.showWarning(`${cause}. Features that load code on demand can fail until restart. ${restart}`);
1684
+ return true;
1685
+ }
1659
1686
  renderCurrentSessionState() {
1660
1687
  this.loadedResourcesContainer.clear();
1661
1688
  this.chatContainer.clear();
@@ -2878,6 +2905,8 @@ export class InteractiveMode {
2878
2905
  break;
2879
2906
  }
2880
2907
  case "tool_execution_end": {
2908
+ if (event.isError)
2909
+ this.maybeShowInstallChangeWarning();
2881
2910
  const component = this.pendingTools.get(event.toolCallId);
2882
2911
  if (component) {
2883
2912
  component.updateResult({ ...event.result, isError: event.isError });
@@ -3458,6 +3487,10 @@ export class InteractiveMode {
3458
3487
  * paste / Kitty / modifyOtherKeys sequences.
3459
3488
  */
3460
3489
  uncaughtCrash(error) {
3490
+ // A dead terminal is not a pi crash. Do not try to restore it or record it.
3491
+ if (isDeadTerminalError(error)) {
3492
+ this.emergencyTerminalExit();
3493
+ }
3461
3494
  if (this.isShuttingDown) {
3462
3495
  process.exit(1);
3463
3496
  }
@@ -3516,10 +3549,13 @@ export class InteractiveMode {
3516
3549
  }
3517
3550
  throw error;
3518
3551
  };
3519
- process.stdout.on("error", terminalErrorHandler);
3520
- process.stderr.on("error", terminalErrorHandler);
3521
- this.signalCleanupHandlers.push(() => process.stdout.off("error", terminalErrorHandler));
3522
- this.signalCleanupHandlers.push(() => process.stderr.off("error", terminalErrorHandler));
3552
+ // stdin needs the handler too: once the terminal is gone, reads and setRawMode
3553
+ // fail with EIO (orphaned background process group) or ENOTTY (revoked tty).
3554
+ // Node emits these as stream errors, which are uncaught without a listener.
3555
+ for (const stream of [process.stdin, process.stdout, process.stderr]) {
3556
+ stream.on("error", terminalErrorHandler);
3557
+ this.signalCleanupHandlers.push(() => stream.off("error", terminalErrorHandler));
3558
+ }
3523
3559
  // Restore the terminal before the process dies on any uncaught throw.
3524
3560
  // Without this, an unhandled exception from extension code (or anywhere
3525
3561
  // in pi) leaves the terminal in raw mode with no cursor.