@code-yeongyu/senpi 2026.11.6-3 → 2026.11.9

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 (147) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/bundle/chunks/{chunk-JMQOLOC2.js → chunk-3CRPNPTR.js} +1 -1
  3. package/dist/bundle/chunks/{chunk-5LKB732P.js → chunk-3TZQXZKH.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-X53PD4ZC.js → chunk-45MVD7BU.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-L7ZIS3MC.js → chunk-4JIBEZZE.js} +3 -3
  6. package/dist/bundle/chunks/{chunk-CF5OGBC4.js → chunk-4NYNMAYF.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-6CEDL5S2.js → chunk-4UR6UFBH.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-F5JLDCYD.js → chunk-527Q2UYM.js} +5 -5
  9. package/dist/bundle/chunks/{chunk-7DRWPZ3N.js → chunk-622VYTRI.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-GKAYPJ4E.js → chunk-7PROV6BB.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-4E7GDG4H.js → chunk-7VMEE62L.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-CFEHJ4VU.js → chunk-HXNXISJD.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-4BATXPB7.js → chunk-K3UHGDUQ.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-SB6MXNO5.js → chunk-M7GF73FO.js} +2 -2
  15. package/dist/bundle/chunks/{chunk-V2QAYGOK.js → chunk-OCMGRBJ5.js} +22 -22
  16. package/dist/bundle/chunks/{chunk-EO2VPZ2K.js → chunk-SGAFIMAU.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-BASS47UD.js → chunk-STGOYIXC.js} +1 -1
  18. package/dist/bundle/chunks/{chunk-DSWDJ7HT.js → chunk-WQ4RBPMS.js} +1 -1
  19. package/dist/bundle/chunks/{chunk-MJTCZUXS.js → chunk-WX2HB4DD.js} +1 -1
  20. package/dist/bundle/chunks/chunk-XZDCMDUH.js +2 -0
  21. package/dist/bundle/chunks/{chunk-LUZVGPQ7.js → chunk-Y5L4UFMI.js} +1 -1
  22. package/dist/bundle/chunks/{cli-main-RWHDZKTQ.js → cli-main-E4NDWAUD.js} +1 -1
  23. package/dist/bundle/chunks/{hand-entry-G5LYF62Q.js → hand-entry-5X5Z5Y3D.js} +1 -1
  24. package/dist/bundle/chunks/{headless-host-ES74ZB6M.js → headless-host-YXUGONR3.js} +1 -1
  25. package/dist/bundle/chunks/{host-command-I2JZ5JM7.js → host-command-VHX2ILLM.js} +1 -1
  26. package/dist/bundle/chunks/{host-session-command-Y52NFPP2.js → host-session-command-P3MRW63Z.js} +1 -1
  27. package/dist/bundle/chunks/{interactive-mode-PA7DGVS6.js → interactive-mode-XUSBLLWI.js} +1 -1
  28. package/dist/bundle/chunks/{main-OBL6375C.js → main-3TWVKTJN.js} +1 -1
  29. package/dist/bundle/chunks/{multi-session-host-NM6I5BWZ.js → multi-session-host-HRGM66PY.js} +1 -1
  30. package/dist/bundle/chunks/{package-manager-cli-GNRQ5MVR.js → package-manager-cli-WSH7U4YE.js} +1 -1
  31. package/dist/bundle/chunks/{role-F56BS2ZQ.js → role-4BUU46VW.js} +3 -3
  32. package/dist/bundle/chunks/{rotation-stream-BN2YK2MC.js → rotation-stream-TODBIHXJ.js} +1 -1
  33. package/dist/bundle/chunks/{rpc-mode-G4KIP7XS.js → rpc-mode-OAPIV46G.js} +1 -1
  34. package/dist/bundle/chunks/{run-attached-tui-XTGPAGYM.js → run-attached-tui-MXCC5IZR.js} +1 -1
  35. package/dist/bundle/chunks/{schedule-command-L4M3TSQ3.js → schedule-command-MX56D6UE.js} +1 -1
  36. package/dist/bundle/chunks/{session-control-endpoint-V46WMCDF.js → session-control-endpoint-IL6ERD4U.js} +1 -1
  37. package/dist/bundle/chunks/{session-picker-AG6KSR5A.js → session-picker-6VRC25MJ.js} +1 -1
  38. package/dist/bundle/chunks/session-worker.js +44 -44
  39. package/dist/bundle/cli.js +2 -2
  40. package/dist/bundle/index.js +1 -1
  41. package/dist/bundle/rpc-entry.js +1 -1
  42. package/dist/bundle/runtime-manifest.json +1 -1
  43. package/dist/core/agent-session-services.d.ts +2 -0
  44. package/dist/core/agent-session-services.js +1 -0
  45. package/dist/core/agent-session.d.ts +8 -0
  46. package/dist/core/agent-session.js +51 -4
  47. package/dist/core/egress/classify.d.ts +8 -3
  48. package/dist/core/egress/classify.js +177 -158
  49. package/dist/core/egress/console-redactor.d.ts +7 -0
  50. package/dist/core/egress/console-redactor.js +74 -0
  51. package/dist/core/egress/credentials.d.ts +73 -0
  52. package/dist/core/egress/credentials.js +20 -0
  53. package/dist/core/egress/device-custody.d.ts +1 -1
  54. package/dist/core/egress/device-custody.js +18 -15
  55. package/dist/core/egress/device-proxy-call.d.ts +59 -0
  56. package/dist/core/egress/device-proxy-call.js +148 -0
  57. package/dist/core/egress/device-proxy-lost-calls.d.ts +27 -0
  58. package/dist/core/egress/device-proxy-lost-calls.js +28 -0
  59. package/dist/core/egress/device-proxy-ports.d.ts +49 -0
  60. package/dist/core/egress/device-proxy-ports.js +2 -0
  61. package/dist/core/egress/device-proxy-request.d.ts +34 -0
  62. package/dist/core/egress/device-proxy-request.js +69 -0
  63. package/dist/core/egress/device-proxy-waits.d.ts +40 -0
  64. package/dist/core/egress/device-proxy-waits.js +67 -0
  65. package/dist/core/egress/device-proxy.d.ts +3 -0
  66. package/dist/core/egress/device-proxy.js +214 -0
  67. package/dist/core/egress/endpoint.js +2 -1
  68. package/dist/core/egress/entry-verify.d.ts +13 -0
  69. package/dist/core/egress/entry-verify.js +33 -0
  70. package/dist/core/egress/hpke.js +13 -9
  71. package/dist/core/egress/key-policy-template.d.ts +7 -1
  72. package/dist/core/egress/ledger-schema.d.ts +80 -0
  73. package/dist/core/egress/ledger-schema.js +117 -0
  74. package/dist/core/egress/ledger.d.ts +55 -0
  75. package/dist/core/egress/ledger.js +159 -0
  76. package/dist/core/egress/pinned-infra.d.ts +23 -2
  77. package/dist/core/egress/pinned-infra.js +9 -2
  78. package/dist/core/egress/redact.d.ts +10 -0
  79. package/dist/core/egress/redact.js +134 -0
  80. package/dist/core/egress/sealed-source.d.ts +35 -0
  81. package/dist/core/egress/sealed-source.js +140 -0
  82. package/dist/core/egress/verified-keys.js +1 -1
  83. package/dist/core/egress/wire.d.ts +5 -3
  84. package/dist/core/egress/wire.js +5 -3
  85. package/dist/core/extensions/builtin/monitor-state-event.d.ts +26 -0
  86. package/dist/core/extensions/builtin/monitor-state-event.js +2 -0
  87. package/dist/core/extensions/builtin/terminal/background-age.d.ts +25 -0
  88. package/dist/core/extensions/builtin/terminal/background-age.js +91 -0
  89. package/dist/core/extensions/builtin/terminal/extension-state.d.ts +1 -1
  90. package/dist/core/extensions/builtin/terminal/extension-state.js +21 -3
  91. package/dist/core/extensions/builtin/terminal/notify.d.ts +6 -0
  92. package/dist/core/extensions/builtin/terminal/notify.js +39 -5
  93. package/dist/core/extensions/builtin/terminal/session-bundle.d.ts +9 -2
  94. package/dist/core/extensions/builtin/terminal/session-bundle.js +36 -1
  95. package/dist/core/extensions/builtin/terminal/settings.d.ts +2 -0
  96. package/dist/core/extensions/builtin/terminal/settings.js +8 -0
  97. package/dist/core/extensions/builtin/terminal/tools/background-auto-reap.d.ts +15 -0
  98. package/dist/core/extensions/builtin/terminal/tools/background-auto-reap.js +87 -0
  99. package/dist/core/extensions/builtin/terminal/tools/bash.d.ts +2 -0
  100. package/dist/core/extensions/builtin/terminal/tools/bash.js +6 -6
  101. package/dist/core/extensions/builtin/terminal/tools/child-placement.d.ts +8 -0
  102. package/dist/core/extensions/builtin/terminal/tools/child-placement.js +43 -6
  103. package/dist/core/extensions/builtin/terminal/tools/context.d.ts +11 -2
  104. package/dist/core/extensions/session-control-types.d.ts +15 -0
  105. package/dist/core/extensions/session-control-types.js +11 -0
  106. package/dist/core/external-admission.d.ts +16 -2
  107. package/dist/core/external-admission.js +22 -4
  108. package/dist/core/retry-fallback/controller.d.ts +1 -0
  109. package/dist/core/retry-fallback/controller.js +3 -0
  110. package/dist/core/retry-fallback/unusable.d.ts +2 -0
  111. package/dist/core/retry-fallback/unusable.js +7 -1
  112. package/dist/core/retry-fallback/usage-limit.d.ts +6 -1
  113. package/dist/core/retry-fallback/usage-limit.js +9 -4
  114. package/dist/core/sdk.d.ts +6 -1
  115. package/dist/core/sdk.js +1 -0
  116. package/dist/core/terminal-settings.d.ts +1 -0
  117. package/dist/core/turn-origin.d.ts +4 -0
  118. package/dist/core/turn-origin.js +10 -0
  119. package/dist/modes/interactive/components/remote-delivery-message.d.ts +2 -1
  120. package/dist/modes/interactive/components/remote-delivery-message.js +13 -5
  121. package/dist/modes/rpc/admit-external-message-command.d.ts +37 -0
  122. package/dist/modes/rpc/admit-external-message-command.js +61 -0
  123. package/dist/modes/rpc/admit-external-message-wire.d.ts +42 -0
  124. package/dist/modes/rpc/admit-external-message-wire.js +55 -0
  125. package/dist/modes/rpc/connection-handler.js +14 -0
  126. package/dist/modes/rpc/effect-commands.d.ts +1 -1
  127. package/dist/modes/rpc/host-idle-handover.js +1 -0
  128. package/dist/modes/rpc/method-classes-schema-delivery.d.ts +32 -0
  129. package/dist/modes/rpc/method-classes-schema-delivery.js +22 -0
  130. package/dist/modes/rpc/method-classes-schema-session.d.ts +27 -0
  131. package/dist/modes/rpc/method-classes-schema-session.js +2 -0
  132. package/dist/modes/rpc/method-classes-schema.d.ts +27 -0
  133. package/dist/modes/rpc/method-classes.d.ts +1 -0
  134. package/dist/modes/rpc/method-classes.js +2 -0
  135. package/dist/modes/rpc/rpc-input-validation.js +4 -3
  136. package/dist/modes/rpc/rpc-response-types.d.ts +2 -1
  137. package/dist/modes/rpc/rpc-session-command-types.d.ts +2 -1
  138. package/dist/modes/rpc/tool-child/terminal-jobs.d.ts +1 -0
  139. package/dist/modes/rpc/tool-child/terminal-jobs.js +17 -1
  140. package/docs/engine-socket/fixtures/admission-routes/h-legacy.json +1 -1
  141. package/docs/engine-socket/fixtures/rpc-inbound-samples.json +19 -2
  142. package/docs/rpc.md +57 -0
  143. package/docs/terminal-tools.md +25 -1
  144. package/native/socket-secret/prebuilds/win32-arm64/senpi_socket_secret.win32-arm64.node +0 -0
  145. package/native/socket-secret/prebuilds/win32-x64/senpi_socket_secret.win32-x64.node +0 -0
  146. package/package.json +6 -6
  147. package/dist/bundle/chunks/chunk-UODSYQ2D.js +0 -2
@@ -21,6 +21,28 @@ Background sessions are NEVER killed by `timeout` (they live until they exit or
21
21
  call `kill_bash`), even though the bash-timeout extension injects a default `timeout`
22
22
  into every `bash` call. Foreground calls behave like the classic `bash` tool.
23
23
 
24
+ ### Long-running background sessions
25
+
26
+ A background session that is still running (started with `run_in_background`, or a
27
+ foreground command that auto-detached) is reported once it has run 10 minutes, then
28
+ every 30 minutes after that (10, 40, 70, ... minutes). Each report names the session's
29
+ `bash_id` and its command or label, says how long it has been running, and gives the
30
+ call that stops it (`kill_bash({ bash_id })`). It reaches the agent like a completion
31
+ notice (subject to `notify`), shows in the TUI, and goes to RPC clients as the
32
+ `terminal_background_age` event ([RPC](rpc.md#background-session-age)). A report that came
33
+ due while the machine slept is sent once, not once per missed interval.
34
+
35
+ Nothing is stopped automatically by default. To stop long sessions at a set age, opt in
36
+ with the `terminal.backgroundAutoReapMinutes` setting, or per call with the `bash`
37
+ parameter `auto_reap_minutes` (which wins over the setting; `0` turns it off for that
38
+ call). At that age the session is stopped the way `kill_bash` stops it (TERM to its
39
+ process group, then KILL after a grace), its completion notice says it was stopped
40
+ automatically, and a `terminal_background_age` event with `kind: "reaped"` is sent.
41
+ It counts as reaped only once that stop has really ended the session. If the stop fails
42
+ or the session survives it, one notice (and a `kind: "reap_failed"` event) says
43
+ auto-reap failed and why; the session keeps running, its age reports go on, and the
44
+ auto-reap does not retry.
45
+
24
46
  Background sessions and monitors also survive a session reload (`/reload`): existing
25
47
  `bash_N` ids stay addressable, watchers keep injecting events, and completion
26
48
  notifications keep arriving. Quitting or switching sessions still tears everything down.
@@ -214,7 +236,8 @@ Configure the suite under `terminal` in `settings.json` (global
214
236
  "scrollback": 10000,
215
237
  "maxSessions": 32,
216
238
  "timeoutAction": "background",
217
- "notify": "wake"
239
+ "notify": "wake",
240
+ "backgroundAutoReapMinutes": 120
218
241
  }
219
242
  }
220
243
  ```
@@ -223,6 +246,7 @@ Configure the suite under `terminal` in `settings.json` (global
223
246
  - `scrollback` — xterm scrollback lines per session (default 10000).
224
247
  - `maxSessions` — concurrent sessions before least-recently-used exited sessions are pruned (default 32).
225
248
  - `timeoutAction` — fate of a foreground timeout (default `background`).
249
+ - `backgroundAutoReapMinutes` — stop a background session once it has run this many minutes (default unset: never). A whole number of minutes of at least 1 turns it on; `0` or any other value leaves it off. The `bash` parameter `auto_reap_minutes` overrides it per call.
226
250
  - `notify` — async completion behavior: `wake` (wake an idle interactive agent once), `next-turn`, or `off` (default `wake`). Non-interactive `-p` / `--print` / `--mode json` runs never wake.
227
251
  - `killGuard` — `on` (default) or `off`, read from the global settings file only (a project value is ignored). While on, an agent command or eval cell that would signal every process (`kill -1`, a `pkill` pattern such as `a||b`, `.*` or one letter), a protected process (pid 1, the agent, its ancestors, the user's service manager) or a process group holding one is refused before it runs with a `[senpi:kill-guard]` message naming the rule and a narrow alternative. Narrow kills by pid, exact name (`pkill -x`) or anchored pattern run as before. Values only known when a command runs (`pkill -f "$P"`, `xargs kill`, a script's `kill $PID`) are judged then: on macOS and Linux every agent shell, monitor and eval kernel gets `kill`, `pkill` and `killall` shims first on `PATH` (in `<agent dir>/kill-guard/<version>/`) and a `BASH_ENV` that wraps bash's builtin `kill`, chaining any `BASH_ENV` you already set; an interactive bash the agent starts gets the same wrapper from a `PROMPT_COMMAND` hook before its first prompt, after your startup files, and your own `PROMPT_COMMAND` still runs after it; a refused command exits 126 with the same message. This also judges what the agent types into a running shell with `bash_input` (edited, recalled or history-expanded lines included), because the shell judges the line it actually runs. Builtin `kill` in dash or zsh, in `bash --posix -c` and in `bash -i -c`, in an interactive bash whose startup files replace `PROMPT_COMMAND`, and a `kill` named by absolute path, are judged only from the command text. A command you type yourself with `!` is never judged and gets no shims. `off` restores the unguarded behavior (no shims, no `BASH_ENV`, `PROMPT_COMMAND` left as you set it) and shows one notice per session.
228
252
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-yeongyu/senpi",
3
- "version": "2026.11.6-3",
3
+ "version": "2026.11.9",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -92,9 +92,9 @@
92
92
  },
93
93
  "dependencies": {
94
94
  "@earendil-works/chord": "0.99.1",
95
- "@earendil-works/pi-agent-core": "npm:@code-yeongyu/senpi-agent-core@2026.11.6-3",
96
- "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.6-3",
97
- "@earendil-works/pi-tui": "npm:@code-yeongyu/senpi-tui@2026.11.6-3",
95
+ "@earendil-works/pi-agent-core": "npm:@code-yeongyu/senpi-agent-core@2026.11.9",
96
+ "@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@2026.11.9",
97
+ "@earendil-works/pi-tui": "npm:@code-yeongyu/senpi-tui@2026.11.9",
98
98
  "@silvia-odwyer/photon-node": "0.3.4",
99
99
  "ajv": "8.20.0",
100
100
  "chalk": "6.0.0",
@@ -115,8 +115,8 @@
115
115
  "yaml": "2.9.1",
116
116
  "@anthropic-ai/claude-agent-sdk": "0.3.306",
117
117
  "@anthropic-ai/sdk": "0.127.0",
118
- "@code-yeongyu/senpi-codemode": "2026.11.6-3",
119
- "@earendil-works/pi-pty": "npm:@code-yeongyu/senpi-pty@2026.11.6-3",
118
+ "@code-yeongyu/senpi-codemode": "2026.11.9",
119
+ "@earendil-works/pi-pty": "npm:@code-yeongyu/senpi-pty@2026.11.9",
120
120
  "@modelcontextprotocol/sdk": "1.32.1",
121
121
  "@mozilla/readability": "0.6.0",
122
122
  "linkedom": "0.18.13",
@@ -1,2 +0,0 @@
1
- import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
2
- import{rateLimitModelFamily}from"./chunk-6VWIMHMH.js";import{describeProviderFailureForUser,isQuotaExhaustionMessage}from"./chunk-OKMHSVCA.js";var BILLING_ERROR_PATTERN=new RegExp(["credit[- ]balance","insufficient[_ -]quota","\\bbilling\\b","purchase credits","credits[-_ ]required","credits are required","usage_limit_reached","usage_not_included","usage limit has been reached"].join("|"),"i"),STRONG_BILLING_ERROR_PATTERN=new RegExp(["credit[- ]balance","insufficient[_ -]quota","purchase credits","credits[-_ ]required","credits are required","usage_limit_reached","usage_not_included","usage limit has been reached"].join("|"),"i"),TRANSIENT_SERVER_SIGNAL_PATTERN=/(?:^|[^0-9])(?:500|502|503|504|520|522|524)(?:[^0-9]|$)|"type"\s*:\s*"server_error"/i;function isBillingErrorMessage(errorMessage){return errorMessage===void 0?!1:STRONG_BILLING_ERROR_PATTERN.test(errorMessage)?!0:BILLING_ERROR_PATTERN.test(errorMessage)?!TRANSIENT_SERVER_SIGNAL_PATTERN.test(errorMessage):!1}var AccountUsageLimitError=class extends Error{constructor(provider,raw="usage limit reached",resetsAt,families){let message=describeProviderFailureForUser(raw,{model:provider,usageLimit:"account",...resetsAt===void 0?{}:{resetsAt:formatResetTime(resetsAt)}});super(families===void 0||families.length===0?message:`${message} The limit named no model family; it was confirmed on ${families.join(" and ")}.`),this.name="AccountUsageLimitError"}};function formatResetTime(epochMs){return new Date(epochMs).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}var SUBSCRIPTION_LIMIT_PATTERN=/\bhit\s+your\b[^.]*\blimit\b|\b(?:session|weekly|monthly|daily|hourly|\d+[- ]hour|usage)\s+limit\b|\bblocking_limit\b|\brapid_refill_breaker\b/i,PLAN_MODEL_LIMIT_PATTERN=/\breached\b[^.]*\b(?:free|plan|tier|model)\b[^.]*\blimit\b[\s\S]*\bswitch to (?:a |an )?(?:different|another) model\b/i,MODEL_SCOPE_PATTERN=/\bmodels?\b|\bpremium\b|\b(?:opus|sonnet|haiku|fable|mythos)\b/i;function usageLimitScope(failure){if(typeof failure=="object"&&failure.errorCause?.type==="usage_limit"){let scope=failure.errorCause.scope;if(scope==="account"||scope==="model")return scope}let errorMessage=typeof failure=="object"?failure.errorMessage:failure;if(errorMessage===void 0)return;if(rateLimitModelFamily(errorMessage)!==void 0)return"model";if(isQuotaExhaustionMessage(errorMessage)||isBillingErrorMessage(errorMessage)||SUBSCRIPTION_LIMIT_PATTERN.test(errorMessage)||PLAN_MODEL_LIMIT_PATTERN.test(errorMessage))return MODEL_SCOPE_PATTERN.test(errorMessage)?"model":"account"}function describeUsageLimitMessage(message){let scope=usageLimitScope(message);return!scope||message.errorCause?.type==="usage_limit"&&message.errorCause.scope===scope?message:{...message,errorCause:{type:"usage_limit",scope},...scope==="account"?{errorMessage:describeProviderFailureForUser(message.errorMessage,{model:`${message.provider}/${message.model}`,usageLimit:scope})}:{}}}function describeUsageLimitEntry(entry){if(entry.type!=="message"||entry.message.role!=="assistant")return entry;let message=describeUsageLimitMessage(entry.message);return message===entry.message?entry:{...entry,message}}function usageLimitCause(from,limit){if(limit==="model")return`${from} hit its usage limit`;if(limit==="account")return`the ${from.slice(0,Math.max(0,from.indexOf("/")))||from} account hit its usage limit, so its other models were skipped`}var SecretInputUnavailableError=class extends Error{constructor(reason){super("This client cannot collect a secret; use the TUI or the host's settings route."),this.code="secret_input_unavailable",this.name="SecretInputUnavailableError",this.reason=reason}};function resolveSecretInputTimeout(opts){let requested=opts?.timeout??18e5;if(!Number.isFinite(requested)||requested<=0)throw new Error("Invalid secret input timeout");let timeout=Math.ceil(requested);if(!Number.isSafeInteger(Date.now()+timeout))throw new Error("Invalid secret input timeout");return timeout}function armSecretInputDeadline(deadline,expire){let timer,check=()=>{let remaining=deadline-Date.now();remaining<=0?expire():timer=setTimeout(check,Math.min(remaining,2147483647))};return timer=setTimeout(check,Math.max(0,Math.min(deadline-Date.now(),2**31-1))),()=>clearTimeout(timer)}function isSecretInputValue(value){return!/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/u.test(value)}import{realpathSync,watch}from"node:fs";import{opendir}from"node:fs/promises";var FS_WATCH_RETRY_DELAY_MS=5e3;function closeWatcher(watcher){if(watcher)try{watcher.close()}catch{}}function canonicalWatchPath(path){if(process.platform!=="win32")return path;try{return realpathSync.native(path)}catch{return path}}async function probeDirectoryOpenable(directory){let handle=await opendir(directory);try{await handle.read()}finally{await handle.close()}}function watchWithErrorHandler(path,listener,onError,options){try{let watcher=watch(canonicalWatchPath(path),{...options,encoding:"utf8"},listener);return watcher.on("error",onError),watcher}catch{return onError(),null}}export{FS_WATCH_RETRY_DELAY_MS,closeWatcher,canonicalWatchPath,probeDirectoryOpenable,watchWithErrorHandler,isBillingErrorMessage,AccountUsageLimitError,usageLimitScope,describeUsageLimitMessage,describeUsageLimitEntry,usageLimitCause,SecretInputUnavailableError,resolveSecretInputTimeout,armSecretInputDeadline,isSecretInputValue};