omo-ai 5.1.4 → 5.1.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.
@@ -76,8 +76,8 @@ export async function doctorComputerUseLines(options = {}) {
76
76
  const report = await runtime.computerUseDoctorReport({
77
77
  cwd: options.cwd ?? process.cwd(),
78
78
  env: options.env ?? process.env,
79
- version: packageManifest().version,
80
- packageRoot,
79
+ version: options.version ?? packageManifest().version,
80
+ packageRoot: options.packageRoot ?? packageRoot,
81
81
  platform: options.platform ?? process.platform,
82
82
  arch: options.arch ?? process.arch,
83
83
  timeoutMs: options.timeoutMs,
@@ -0,0 +1,24 @@
1
+ import { join } from "node:path"
2
+ import { pathToFileURL } from "node:url"
3
+ import { COVERAGE_RUNTIME } from "./category-coverage.js"
4
+ import { packageRoot } from "./package-paths.js"
5
+
6
+ // The launcher is plain JS, so it reaches the TypeScript config loader through the same staged
7
+ // runtime bundle the category-coverage and computer-use reports use (category-coverage-entry.ts).
8
+ async function loadRuntime() {
9
+ return import(pathToFileURL(join(packageRoot, COVERAGE_RUNTIME)).href)
10
+ }
11
+
12
+ /**
13
+ * @param {{ cwd?: string, env?: Record<string, string | undefined>, loadRuntime?: () => Promise<any> }} [options]
14
+ * @returns {Promise<string[]>}
15
+ */
16
+ export async function doctorConfigLines(options = {}) {
17
+ try {
18
+ const runtime = await (options.loadRuntime ?? loadRuntime)()
19
+ return [...runtime.configDoctorLines({ cwd: options.cwd ?? process.cwd(), env: options.env ?? process.env })]
20
+ } catch (error) {
21
+ const message = error instanceof Error ? error.message : String(error)
22
+ return [`WARN config: diagnostics unavailable: ${message}`]
23
+ }
24
+ }
@@ -0,0 +1,89 @@
1
+ import { existsSync, readFileSync } from "node:fs"
2
+ import { createRequire } from "node:module"
3
+ import { join } from "node:path"
4
+
5
+ /**
6
+ * Where `omo daemon` reads its config. Its `task.*` keys (`host_engine_policy`, `host_idle_exit_ms`) come
7
+ * from the omo-config-core loader (~/.omo/omo.jsonc or ~/.omo/omo.json plus project `.omo` layers, JSONC,
8
+ * the precedence every other `task.*` key has), reached through the staged
9
+ * `plugin/runtime/task-config/index.js` bundle (task-config-entry.ts). `<agentDir>/omo.json` is the
10
+ * deprecated source: it still supplies a key when the loader finds none for it.
11
+ *
12
+ * Fail-open: a payload without the runtime, or any error inside it, reads exactly the legacy file.
13
+ */
14
+
15
+ export const TASK_CONFIG_RUNTIME = join("runtime", "task-config", "index.js")
16
+
17
+ const requireRuntime = createRequire(import.meta.url)
18
+ const POLICIES = new Set(["upgrade", "fallback", "never"])
19
+
20
+ /** Each key `omo daemon` reads, with the check its consumer applies (resolvePolicy, hostCommandEnvironment). */
21
+ const DAEMON_KEYS = {
22
+ host_engine_policy: (value) => POLICIES.has(value),
23
+ host_idle_exit_ms: (value) => typeof value === "number" && Number.isFinite(value) && value > 0,
24
+ }
25
+
26
+ function loadTaskConfigRuntime(pluginRoot) {
27
+ return requireRuntime(join(pluginRoot, TASK_CONFIG_RUNTIME))
28
+ }
29
+
30
+ /** The legacy file is optional and may be hand-edited, so unreadable config must not take the CLI down. */
31
+ function readLegacyConfig(path) {
32
+ if (!existsSync(path)) return undefined
33
+ try {
34
+ return JSON.parse(readFileSync(path, "utf8"))
35
+ } catch {
36
+ return undefined
37
+ }
38
+ }
39
+
40
+ function loaderSettings(options) {
41
+ try {
42
+ const runtime = (options.loadRuntime ?? loadTaskConfigRuntime)(options.pluginRoot)
43
+ return { available: true, settings: runtime.resolveDaemonTaskSettings({ cwd: options.cwd ?? process.cwd(), env: options.env }) }
44
+ } catch {
45
+ return { available: false, settings: {} }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * @param options.pluginRoot the staged plugin dir the runtime is loaded from
51
+ * @param options.agentDir the dir holding the deprecated omo.json
52
+ * @param options.env / options.cwd where the loader looks up the user and project layers
53
+ * @param options.loadRuntime injected so tests never need the staged payload
54
+ * @returns {{ config: object | undefined, legacyPath: string, legacySources: { key: string, value: unknown }[] }}
55
+ * `legacySources` lists the keys the deprecated file supplied while the loader ran and set none of them
56
+ */
57
+ export function readDaemonConfig(options) {
58
+ const legacyPath = join(options.agentDir, "omo.json")
59
+ const legacy = readLegacyConfig(legacyPath)
60
+ const loaded = loaderSettings(options)
61
+ const fromLoader = Object.keys(DAEMON_KEYS).filter((key) => loaded.settings[key] !== undefined)
62
+ const legacySources = loaded.available
63
+ ? Object.entries(DAEMON_KEYS)
64
+ .filter(([key, usable]) => loaded.settings[key] === undefined && usable(legacy?.task?.[key]))
65
+ .map(([key]) => ({ key, value: legacy.task[key] }))
66
+ : []
67
+ if (fromLoader.length === 0) return { config: legacy, legacyPath, legacySources }
68
+ const task = { ...legacy?.task }
69
+ for (const key of fromLoader) task[key] = loaded.settings[key]
70
+ return { config: { ...legacy, task }, legacyPath, legacySources }
71
+ }
72
+
73
+ /**
74
+ * Moving a legacy value into omo.jsonc must not change what the daemon does, and the config schema takes
75
+ * only `upgrade|fallback` and whole milliseconds, so values it would reject get the advice that keeps them.
76
+ */
77
+ function migrationAdvice({ key, value }) {
78
+ if (key === "host_engine_policy" && value === "never") {
79
+ return '"never" is a command-line policy only (the config key accepts upgrade|fallback); pass --no-upgrade instead'
80
+ }
81
+ if (key === "host_idle_exit_ms" && !Number.isInteger(value)) return "move it to ~/.omo/omo.jsonc as whole milliseconds"
82
+ return "move it to ~/.omo/omo.jsonc"
83
+ }
84
+
85
+ /** One doctor line per key the deprecated file supplied; none when the loader supplies them or cannot run. */
86
+ export function daemonConfigDoctorLines(options) {
87
+ const { legacyPath, legacySources } = readDaemonConfig(options)
88
+ return legacySources.map((source) => `WARN task.${source.key}: read from deprecated ${legacyPath}; ${migrationAdvice(source)}`)
89
+ }
@@ -1,4 +1,5 @@
1
1
  import { DAEMON_EXIT } from "./daemon-args.js"
2
+ import { daemonConfigDoctorLines } from "./daemon-config.js"
2
3
  import { parseEngineLine, readAllEndpoints } from "./daemon-operations.js"
3
4
  import { formatDoctorLines } from "./daemon-status.js"
4
5
 
@@ -6,7 +7,18 @@ import { formatDoctorLines } from "./daemon-status.js"
6
7
  * The `omo doctor` view: one INFO line, never a FAIL - a machine without a daemon is healthy,
7
8
  * it just has nothing shared to report. Returned as lines so doctor can place it with the rest.
8
9
  */
9
- export function daemonReportLines({ engine, pluginRoot, agentDir, env, platform }) {
10
+ export function daemonReportLines(options) {
11
+ const configLines = daemonConfigDoctorLines({
12
+ pluginRoot: options.pluginRoot,
13
+ agentDir: options.agentDir,
14
+ env: options.env,
15
+ cwd: options.cwd,
16
+ loadRuntime: options.loadTaskConfig,
17
+ })
18
+ return [...engineReportLines(options), ...configLines]
19
+ }
20
+
21
+ function engineReportLines({ engine, agentDir, env, platform }) {
10
22
  if (platform === "win32") return ["INFO Daemon: unavailable on win32 (no unix socket to share)"]
11
23
  const all = readAllEndpoints(engine, agentDir, env)
12
24
  if (all.kind === "all") {
package/bin/lib/daemon.js CHANGED
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync } from "node:fs"
1
+ import { existsSync } from "node:fs"
2
2
  import { join } from "node:path"
3
3
  import {
4
4
  parseEngineLine,
@@ -11,6 +11,7 @@ import {
11
11
  } from "./daemon-operations.js"
12
12
  import { runRollbackPrepare } from "./daemon-rollback.js"
13
13
  import { attachLaunchArgs, blockingPause, DAEMON_EXIT, readTimeoutSeconds } from "./daemon-args.js"
14
+ import { readDaemonConfig } from "./daemon-config.js"
14
15
 
15
16
  export { DAEMON_EXIT } from "./daemon-args.js"
16
17
  export { daemonReportLines } from "./daemon-doctor-report.js"
@@ -24,7 +25,7 @@ export { daemonReportLines } from "./daemon-doctor-report.js"
24
25
  * Everything that decides WHO serves a socket lives in the engine (`senpi host`): probing an
25
26
  * existing host, comparing build ordinals, handing a generation over, refusing when the two sides
26
27
  * cannot agree. This wrapper owns three much smaller things, and deliberately nothing else:
27
- * omo's launch spec is the argv source, omo.json is where the policy comes from, and the caller
28
+ * omo's launch spec is the argv source, the omo config is where the policy comes from, and the caller
28
29
  * gets an exit code it can branch on without reading prose.
29
30
  */
30
31
 
@@ -61,17 +62,6 @@ function resolvePolicy(args, config) {
61
62
  return "upgrade"
62
63
  }
63
64
 
64
- /** omo.json is optional and may be hand-edited, so unreadable config must not take the CLI down. */
65
- function readConfig(agentDir) {
66
- const path = join(agentDir, "omo.json")
67
- if (!existsSync(path)) return undefined
68
- try {
69
- return JSON.parse(readFileSync(path, "utf8"))
70
- } catch {
71
- return undefined
72
- }
73
- }
74
-
75
65
  /**
76
66
  * The engine owns four subcommands - ensure, status, stop, handoff. `run` and `attach` are omo's
77
67
  * words for the same ensure: one asks for a daemon, the other asks for a daemon plus the
@@ -149,7 +139,7 @@ export function runDaemonCommand(args, options) {
149
139
  return DAEMON_EXIT.engineRefused
150
140
  }
151
141
 
152
- const config = readConfig(agentDir)
142
+ const { config } = readDaemonConfig({ pluginRoot, agentDir, env, cwd: options.cwd, loadRuntime: options.loadTaskConfig })
153
143
  if (subcommand === "status") {
154
144
  const status = runStatus({
155
145
  engine,
package/bin/lib/doctor.js CHANGED
@@ -42,7 +42,7 @@ function fail(lines, message) {
42
42
  lines.push(`FAIL ${message}`)
43
43
  }
44
44
 
45
- function warningsForSettings() {
45
+ export function warningsForSettings() {
46
46
  const agentDir = canonicalAgentDir()
47
47
  const settingsPath = join(agentDir, "settings.json")
48
48
  if (!existsSync(settingsPath)) return []
@@ -108,8 +108,22 @@ function listProcesses() {
108
108
  return entries
109
109
  }
110
110
 
111
+ // A standalone binary runs its engine as the provisioned runtime executable itself. The same
112
+ // executable also serves omo's own commands, internal hosts and bundled scripts, so only a bare launch
113
+ // or engine flags count; those other roles are never engines.
114
+ const BINARY_ENGINE = /[\\/]binary-runtime[\\/][^\\/\s]+[\\/]omo(?:\.exe)?(?=\s|$)\s*(\S*)/
115
+ const BINARY_NON_ENGINE_COMMANDS = new Set(["doctor", "setup", "daemon", "update", "upgrade", "host", "install", "remove", "list", "config", "auth", "app-server", "ulw-loop", "--version", "-v"])
116
+
117
+ function isBinaryEngine(command) {
118
+ const match = BINARY_ENGINE.exec(command)
119
+ if (!match) return false
120
+ const first = match[1] ?? ""
121
+ if (first.startsWith("--internal-") || /\.(?:m?js|cjs|ts)$/.test(first)) return false
122
+ return !BINARY_NON_ENGINE_COMMANDS.has(first)
123
+ }
124
+
111
125
  function isEngine(entry) {
112
- return ENGINE_MARKERS.some((marker) => entry.command.includes(marker))
126
+ return ENGINE_MARKERS.some((marker) => entry.command.includes(marker)) || isBinaryEngine(entry.command)
113
127
  }
114
128
 
115
129
  function isInteractive(entry) {
@@ -252,7 +266,7 @@ export function reapStaleEngines(args, options = {}) {
252
266
  return { lines, failed, reaped }
253
267
  }
254
268
 
255
- function staleEngineReport(options) {
269
+ export function staleEngineReport(options) {
256
270
  const list = options.list ?? listProcesses
257
271
  return formatStaleEngineLines(classifyEngineProcesses(list()).stale)
258
272
  }
@@ -307,7 +321,7 @@ export function formatTransientMemoryLines(counts) {
307
321
  ]
308
322
  }
309
323
 
310
- function transientMemoryReport(options) {
324
+ export function transientMemoryReport(options) {
311
325
  const root = memoryRoot(options.env ?? process.env)
312
326
  return formatTransientMemoryLines(countTransientMemoryIdentities({
313
327
  agentsRoot: join(root, MEMORY_AGENTS_DIRNAME),
@@ -391,6 +405,7 @@ export function runDoctor(inventory, args = [], options = {}) {
391
405
  lines.push(`INFO Update: ${updateTarget().command}`)
392
406
  lines.push(...migrationReport(options, updateTarget().command))
393
407
  lines.push(...warningsForSettings())
408
+ lines.push(...(options.configDiagnostics ?? []))
394
409
  lines.push(...piConfigReport({ env: options.env, homeDir: options.homeDir }))
395
410
  lines.push(...staleEngineReport(options))
396
411
  lines.push(...retiredPayloadReport(options))
@@ -4,6 +4,7 @@ import { delimiter, isAbsolute, join, relative, sep } from "node:path"
4
4
  import { spawnNode } from "./child-process.js"
5
5
  import { doctorCoverageLines } from "./category-coverage.js"
6
6
  import { doctorComputerUseLines } from "./computer-use-doctor.js"
7
+ import { doctorConfigLines } from "./config-doctor.js"
7
8
  import { runDaemonCommand } from "./daemon.js"
8
9
  import { runDoctor } from "./doctor.js"
9
10
  import { ensureEnginePrepared, preparePluginLaunchSpec } from "./engine-prepare.js"
@@ -230,8 +231,8 @@ export async function runLauncher(args = process.argv.slice(2)) {
230
231
  process.exitCode = 2
231
232
  return
232
233
  }
233
- // The daemon is the engine's to run; omo only supplies the launch spec, the policy from
234
- // omo.json, and an exit code the caller can branch on.
234
+ // The daemon is the engine's to run; omo only supplies the launch spec, the task settings from
235
+ // the omo config (daemon-config.js), and an exit code the caller can branch on.
235
236
  if (command === "daemon") {
236
237
  const outcome = runDaemonCommand(args.slice(1), {
237
238
  engine: { run: engineHostCall },
@@ -258,16 +259,18 @@ export async function runLauncher(args = process.argv.slice(2)) {
258
259
  if (command === "doctor") {
259
260
  // Doctor is a launch too: it reports only what the launch-time preparation could not fix.
260
261
  preparePluginLaunchSpec({ pluginRoot: join(packageRoot, "plugin") })
261
- const [categoryCoverage, computerUse] = args[1] === "--reap"
262
- ? [[], []]
262
+ const [categoryCoverage, computerUse, configDiagnostics] = args[1] === "--reap"
263
+ ? [[], [], []]
263
264
  : await Promise.all([
264
265
  doctorCoverageLines({ agentDir: canonicalAgentDir() }),
265
266
  doctorComputerUseLines(),
267
+ doctorConfigLines(),
266
268
  ])
267
269
  runDoctor(await detectHarnesses(), args.slice(1), {
268
270
  daemonEngine: { run: engineHostCall },
269
271
  categoryCoverage,
270
272
  computerUse,
273
+ configDiagnostics,
271
274
  })
272
275
  return
273
276
  }
@@ -10,6 +10,7 @@ import { join } from "node:path"
10
10
  import { readRow, readRows } from "./sqlite-rows.js"
11
11
  import { credentialGuidance } from "./setup-guidance.js"
12
12
  import { literalConfigValue, readAuthStore, writeAuthStore } from "./auth-store.js"
13
+ import providerMap from "./provider-map.json" with { type: "json" }
13
14
 
14
15
  export const API_KEY_TYPE_ACCEPTLIST = new Set(["api_key"])
15
16
  const SQLITE_STORES = [
@@ -22,7 +23,7 @@ function sorted(values) {
22
23
  }
23
24
 
24
25
  function readProviderMap() {
25
- return JSON.parse(readFileSync(new URL("./provider-map.json", import.meta.url), "utf8"))
26
+ return providerMap
26
27
  }
27
28
 
28
29
  function targetProvider(provider, providerMap) {
@@ -94,7 +94,7 @@ export async function runSetup(args = process.argv.slice(2), options = {}) {
94
94
  const inventory = await detectHarnesses(runtime)
95
95
  const plans = await planAll(runtime, agentDir)
96
96
  if (dryRun) process.stdout.write("DRY RUN: no files will be written\n")
97
- const categories = await setupCoverage({ agentDir, home, env, plans, loadRuntime: options.loadCoverageRuntime })
97
+ const categories = await setupCoverage({ agentDir, home, env, plans, loadRuntime: options.loadCoverageRuntime, loadEngine: options.loadCoverageEngine })
98
98
  process.stdout.write(formatSetupSummary({ home, agentDir, inventory, ...plans, categories }))
99
99
  process.stdout.write(`${TELEMETRY_NOTICE}\n`)
100
100
  if (dryRun) {
@@ -9,6 +9,7 @@ import { homedir } from "node:os"
9
9
  import { join } from "node:path"
10
10
  import { literalConfigValue } from "./auth-store.js"
11
11
  import { convertPlaceholders, opencodeConfigSources, readOpencodeSection, unconvertedPlaceholder } from "./setup-opencode-assets.js"
12
+ import providerMap from "./provider-map.json" with { type: "json" }
12
13
 
13
14
  // The AI SDK package an OpenCode provider names decides its wire protocol; each engine api id here
14
15
  // speaks the same one (pi-ai compat.js BUILTIN_APIS). Any other package is reported, never guessed.
@@ -38,8 +39,7 @@ function positive(value) {
38
39
  }
39
40
 
40
41
  function builtinProviderIds() {
41
- const map = JSON.parse(readFileSync(new URL("./provider-map.json", import.meta.url), "utf8"))
42
- return new Set([...map.builtinProviderIds, ...Object.keys(map.providers)])
42
+ return new Set([...providerMap.builtinProviderIds, ...Object.keys(providerMap.providers)])
43
43
  }
44
44
 
45
45
  // The engine resolves api keys and header values as config values: literal bytes are escaped, and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omo-ai",
3
- "version": "5.1.4",
3
+ "version": "5.1.5",
4
4
  "type": "module",
5
5
  "description": "OmO Native - the standalone omo command with the OMO extension built in: bun add -g omo-ai",
6
6
  "bin": {
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [5.1.5] - 2026-09-30
11
+
12
+ **Big thanks to [@ashmoonori-afk](https://github.com/ashmoonori-afk), whose [#9209](https://github.com/code-yeongyu/oh-my-openagent/pull/9209) teaches memory recall to find Korean, Japanese and Chinese notes and to pick the right note out of a big memory.**
13
+
14
+ **Hotfix: `eval` works again in the standalone `omo` binary.** ([#9248](https://github.com/code-yeongyu/oh-my-openagent/issues/9248), [#9250](https://github.com/code-yeongyu/oh-my-openagent/pull/9250)) The 5.1.3 and 5.1.4 binaries from GitHub Releases and get.omo.dev left out `@babel/parser`, which the `eval` tool loads, so JavaScript and Python `eval` were missing on every OS; npm and bun installs were fine. Each release now refuses a binary in which `eval` does not register and run.
15
+
16
+ ### Added
17
+
18
+ Memory recall finds Korean, Japanese and Chinese notes and picks the right note out of a large memory with nothing to configure, while an English phrase that matches a note word for word still comes first. ([#9209](https://github.com/code-yeongyu/oh-my-openagent/pull/9209))
19
+
20
+ The Recommended profile tries GPT-6.1 Sol (medium) before GPT-6 Sol on your ChatGPT subscription or the OpenAI API, and GitHub Copilot and OpenCode Zen keep GPT-6 Sol. ([#9237](https://github.com/code-yeongyu/oh-my-openagent/pull/9237))
21
+
22
+ In the standalone binary, `omo setup` now imports your settings, `omo doctor` prints the same sections as an npm install, and `omo doctor --reap` cleans up the binary's own stale engines. ([#9252](https://github.com/code-yeongyu/oh-my-openagent/issues/9252), [#9253](https://github.com/code-yeongyu/oh-my-openagent/pull/9253), [#9265](https://github.com/code-yeongyu/oh-my-openagent/pull/9265))
23
+
24
+ omo.dev has guide pages on mass ulw runs, agents, keywords, telemetry and desktop updates under `/docs/`. ([#9261](https://github.com/code-yeongyu/oh-my-openagent/pull/9261), [#9264](https://github.com/code-yeongyu/oh-my-openagent/pull/9264))
25
+
26
+ ### Fixed
27
+
28
+ OmO no longer slows your machine down with many sessions open, because memory recall reads the memory repository with one git batch per reload instead of one git process per note. ([#9251](https://github.com/code-yeongyu/oh-my-openagent/issues/9251), [#9254](https://github.com/code-yeongyu/oh-my-openagent/pull/9254))
29
+
30
+ The Windows release `.exe` runs from the folder you downloaded it to instead of failing at startup. ([#7485](https://github.com/code-yeongyu/oh-my-openagent/issues/7485), [#9255](https://github.com/code-yeongyu/oh-my-openagent/pull/9255))
31
+
32
+ The standalone binary downloads the Claude Code version it is pinned to on your first Claude subscription turn, checks its hash and caches it, so you no longer need `claude` installed yourself, and `omo doctor` shows it. ([#9262](https://github.com/code-yeongyu/oh-my-openagent/issues/9262), [#9266](https://github.com/code-yeongyu/oh-my-openagent/pull/9266), [#9276](https://github.com/code-yeongyu/oh-my-openagent/issues/9276), [#9277](https://github.com/code-yeongyu/oh-my-openagent/pull/9277))
33
+
34
+ One invalid value in `omo.jsonc` no longer switches off the whole file: only that key is ignored, `omo doctor` prints one warning naming it, and an unsafe key like `__proto__` is dropped without losing its valid neighbors. Thanks to @mooire733. ([#7676](https://github.com/code-yeongyu/oh-my-openagent/pull/7676), [#9249](https://github.com/code-yeongyu/oh-my-openagent/pull/9249))
35
+
36
+ On Windows those config warnings name the file as `~/.omo/omo.jsonc`. ([#9244](https://github.com/code-yeongyu/oh-my-openagent/pull/9244))
37
+
38
+ `omo daemon` reads its settings from `~/.omo/omo.jsonc` like the rest of OmO, and a setting left in the old `~/.omo/agent/omo.json` still applies with a warning in `omo doctor`. ([#9192](https://github.com/code-yeongyu/oh-my-openagent/issues/9192), [#9199](https://github.com/code-yeongyu/oh-my-openagent/pull/9199))
39
+
40
+ A foreground subagent waits at most 15 minutes before it moves to the background, even when a long prompt-cache window would allow an hour. ([#9236](https://github.com/code-yeongyu/oh-my-openagent/pull/9236))
41
+
10
42
  ## [5.1.4] - 2026-09-29
11
43
 
12
44
  ### Changed
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- // omo:9PitjnESwrwWmljoOOuwNRy8Moqb3L822vhV9Ok5EOQ:VfbjzNRugIPcA7fFoNmdsR-DDYSGWaYZ_nAdaDJhEqU
3
- import{spawn as t}from"node:child_process";import*as e from"node:fs";import*as r from"node:fs/promises";function n(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}async function i(t){for(let e=0;;e+=1)try{return await t()}catch(t){if("EINTR"!==n(t)||e>=128)throw t}}function o(t){for(let e=0;;e+=1)try{return t()}catch(t){if("EINTR"!==n(t)||e>=128)throw t}}import{Buffer as a}from"node:buffer";import{constants as s}from"node:fs";function l(t){return"number"==typeof t?0!==(t&s.O_EXCL):"string"==typeof t&&t.toLowerCase().includes("x")}function c(t){return"function"==typeof t}function u(t){return(...e)=>i(async()=>t(...e))}function d(t){return(...e)=>o(()=>t(...e))}function f(t,e){let r="async"===e?u:d,n=new Map;return new Proxy(t,{get(t,e){if(n.has(e))return n.get(e);let i=Reflect.get(t,e);if(!c(i))return i;let o=r(i),a=Reflect.get(i,"native");return c(a)&&Object.assign(o,{native:r(a)}),n.set(e,o),o}})}var p=new Set(["stat","sync","datasync","chmod","chown","utimes","truncate"]);var m=f(r,"async"),w=f(e,"sync"),{access:h,chmod:y,copyFile:g,cp:v,link:b,lstat:E,mkdir:S,mkdtemp:_,readFile:I,readdir:x,realpath:N,rename:O,rm:k,rmdir:P,stat:T,unlink:R}=m,{accessSync:M,chmodSync:A,fsyncSync:$,linkSync:C,lstatSync:D,mkdirSync:L,readFileSync:U,readdirSync:q,realpathSync:j,statSync:F,unlinkSync:J,writeFileSync:B,writeSync:G}=w,{constants:H,watch:V}=e,Y=async(...t)=>{let e=()=>r.open(...t);return function(t){return new Proxy(t,{get(t,e){let r=Reflect.get(t,e);if(!c(r))return r;let o=e=>Reflect.apply(r,t,[...e]);return"close"===e||e===Symbol.asyncDispose?(...t)=>{let e=o(t);return e instanceof Promise?e.catch(t=>{if("EINTR"!==n(t))throw t}):e}:"string"==typeof e&&p.has(e)?(...t)=>{let e=o(t);return e instanceof Promise?e.catch(e=>{if("EINTR"!==n(e))throw e;return i(async()=>o(t))}):e}:(...t)=>o(t)}})}(await(l(t[1]??"r")?e():i(e)))},z=(t,r,n)=>function(t,e,r,n){return l(r)?t(e,r,n):o(()=>t(e,r,n))}(e.openSync,t,r,n??void 0);function K(t){try{e.closeSync(t)}catch(t){if("EINTR"!==n(t))throw t}}function X(t){try{return o(()=>e.statSync(t)),!0}catch{return!1}}import{join as Z}from"node:path";import{fileURLToPath as W}from"node:url";import{randomUUID as Q}from"node:crypto";import{dirname as tt}from"node:path";async function et(t){return JSON.parse(await I(t,"utf8"))}async function rt(t,e,r=384){let n=`${t}.tmp-${process.pid}-${Q()}`,i=await Y(n,"wx",r),o=!1;try{try{await i.writeFile(`${JSON.stringify(e,null,2)}\n`,"utf8"),await i.sync()}finally{await i.close()}await O(n,t),o=!0,await async function(t){try{let e=await Y(t,"r");try{await e.sync()}finally{await e.close()}}catch(t){let e=t instanceof Error&&"code"in t?t.code:void 0;if("win32"!==process.platform||!["EISDIR","EPERM"].includes(String(e)))throw t}}(tt(t))}finally{o||await it(n)}}async function nt(t,e){let r=await et(t);await rt(t,{...r,...e})}async function it(t){try{await R(t)}catch(t){if(!(t instanceof Error&&"code"in t&&"ENOENT"===t.code))throw t}}import{spawn as ot,spawnSync as at}from"node:child_process";import{execFile as st}from"node:child_process";var lt=null;function ct(){return lt??=async function(){if("darwin"!==process.platform)return null;try{let{dlopen:t,FFIType:e}=await(import("bun:ffi")),r=t("/usr/lib/libSystem.B.dylib",{proc_pidinfo:{args:[e.i32,e.i32,e.u64,e.ptr,e.i32],returns:e.i32}});return(t,e,n,i,o)=>Number(r.symbols.proc_pidinfo(t,e,n,i,o))}catch{return null}}(),lt}var ut=null;async function dt(t){if("win32"!==process.platform)return null;if(!Number.isSafeInteger(t)||t<=0)return null;ut??=async function(){if("win32"!==process.platform)return null;try{let{dlopen:t,FFIType:e}=await(import("bun:ffi"));return t("kernel32.dll",{OpenProcess:{args:[e.u32,e.i32,e.u32],returns:e.ptr},GetProcessTimes:{args:[e.ptr,e.ptr,e.ptr,e.ptr,e.ptr],returns:e.i32},CloseHandle:{args:[e.ptr],returns:e.i32}}).symbols}catch{return null}}();let e=await ut;if(null===e)return null;let r=e.OpenProcess(4096,0,t);if(null===r||0===r||0n===r)return null;try{let t=new BigUint64Array(1),n=e.GetProcessTimes(r,t,new BigUint64Array(1),new BigUint64Array(1),new BigUint64Array(1)),i=t[0]??0n;return 0===n||0n===i?null:i}finally{e.CloseHandle(r)}}async function ft(t,e){return await new Promise(r=>{st(t,e,{encoding:"utf8",timeout:2e3,windowsHide:!0},(t,e)=>{if(null!==t)return void r(null);let n=e.trim();r(n.length>0?n:null)})})}var pt=function(t,e){let r;return n=>n!==e?t(n):(r??=t(n).then(t=>(null===t&&(r=void 0),t),t=>{throw r=void 0,t}),r)}(async function(t){if("linux"===process.platform)return await async function(t){try{let e=await I(`/proc/${t}/stat`,"utf8"),r=e.lastIndexOf(")");if(r<0)return null;let n=e.slice(r+2).trim().split(/\s+/)[19];return void 0===n?null:`linux-proc-start-ticks:${n}`}catch{return null}}(t);if("darwin"===process.platform||"freebsd"===process.platform){if("dead"===wt(t))return null;let e=await async function(t){if("darwin"!==process.platform)return null;if(!Number.isSafeInteger(t)||t<=0)return null;let e=await ct();if(null===e)return null;let r=new Uint8Array(136),n=0;try{n=e(t,3,0n,r,136)}catch{return null}if(136!==n)return null;let i=new DataView(r.buffer,r.byteOffset,r.byteLength),o=Number(i.getBigUint64(120,!0));return o>0?o:null}(t);if(null!==e)return`proc-start-epoch:${e}`;let r=await ft("/bin/ps",["-o","lstart=","-p",String(t)]);return null===r?null:`ps-lstart:${r.replace(/\s+/g," ")}`}return"win32"===process.platform?await async function(t){if("dead"===wt(t))return null;let e=await dt(t);if(null!==e)return`win32-creation-filetime:${e}`;let r=await ft("powershell.exe",["-NoProfile","-Command",`(Get-Process -Id ${t} -ErrorAction SilentlyContinue).StartTime.ToUniversalTime().ToString('o')`]);return null===r?null:`win32-creation-date:${r}`}(t):null},process.pid);function mt(t){let e=t.indexOf(":");return e<=0?null:t.slice(0,e)}function wt(t){try{return process.kill(t,0),"alive"}catch(t){let e=function(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}(t);return"ESRCH"===e?"dead":"EPERM"===e?"alive":"unknown"}}function ht(){return"1"===process.env.OMO_MEMORY_SUPERVISOR_ALLOW_TEST_SEAMS}function yt(){if(ht()){let t=process.env.OMO_MEMORY_SUPERVISOR_PLATFORM;if("posix"===t||"win32"===t)return t}return"win32"===process.platform?"win32":"posix"}function gt(t,e){let r=ht()?process.env.OMO_MEMORY_SUPERVISOR_CLOCK_PATH:void 0;if(void 0===r){let r=setTimeout(e,Math.max(0,t-Date.now()));return()=>clearTimeout(r)}let n=!1,i=()=>{if(n)return;let i=bt(r);!Number.isFinite(i)||i<t||(n=!0,o?.close(),clearInterval(a),e())};if(bt(r)>=t)return n=!0,e(),()=>{};let o=V(r,i),a=setInterval(i,vt);return i(),()=>{n||(n=!0,o.close(),clearInterval(a))}}var vt=25;function bt(t){let e=q(t).map(t=>/^(\d+)-(-?\d+(?:\.\d+)?)$/.exec(t)).filter(t=>null!==t).sort((t,e)=>Number(t[1])-Number(e[1])).at(-1);return void 0===e?Number.NaN:Number(e[2])}function Et(t,e){if(!ht())return;let r=process.env.OMO_MEMORY_SUPERVISOR_TASKKILL_RUN_DIR;void 0!==r&&B(`${r}/${t}-${process.pid}.json`,`${JSON.stringify({targetPid:e})}\n`,"utf8")}function St(t){if(!ht())return;let e=process.env[t];if(void 0===e)return;let r=JSON.parse(e);if(!Array.isArray(r)||!r.every(t=>"string"==typeof t)||0===r.length)throw TypeError(`${t} must be a non-empty string array`);return r}function _t(t,e,r){let[n,...i]=t;if(void 0===n)throw TypeError("termination command is required");if(r){let t=at(n,[...i,...e],{env:process.env,stdio:"ignore",windowsHide:!0});if(void 0!==t.error)throw t.error;return}ot(n,[...i,...e],{env:process.env,stdio:"ignore",windowsHide:!0}).once("error",t=>process.stderr.write(`${t.message}\n`))}function It(t,e){Et(`posix-${e}`,t);let r=St("OMO_MEMORY_SUPERVISOR_POSIX_SIGNAL_COMMAND");if(void 0===r)try{process.kill(-t,e)}catch(t){if(!(t instanceof Error&&"code"in t&&"ESRCH"===t.code))throw t}else _t(r,["--signal-group",String(t),e],!1)}function xt(t){void 0!==t&&Et("win32-graceful",t)}function Nt(t,e){"win32"===t?(xt(e.pid),e.kill()):void 0!==e.pid&&It(e.pid,"SIGTERM")}function Ot(t,e,r=!1){void 0!==e&&("win32"===t?function(t,e){_t(St("OMO_MEMORY_SUPERVISOR_TASKKILL_COMMAND")??["taskkill"],["/pid",String(t),"/T","/F"],e)}(e,r):It(e,"SIGKILL"))}async function kt(t){return await pt(t)}import{join as Pt}from"node:path";function Tt(t){return"object"==typeof t&&null!==t}function Rt(t,e){try{return t?.[e]}catch(t){return void Error}}function Mt(t,e){let r=Rt(t,e);return Tt(r)?r:void 0}function At(t){if(!t)return"";if("string"==typeof t)return t.toLowerCase();if(!Tt(t))try{return JSON.stringify(t).toLowerCase()}catch(t){if(!(t instanceof Error))throw t;return""}let e=Mt(t,"data"),r=[e,Mt(t,"error"),t,Mt(e,"error")].filter(t=>void 0!==t);for(let t of r){let e=Rt(t,"message");if("string"==typeof e&&e.length>0)return e.toLowerCase()}let n=Rt(t,"name");if("string"==typeof n&&n.length>0){let t=n.match(/:\s*(.+)/);if(t)return t[1]?.trim().toLowerCase()??""}try{return JSON.stringify(t).toLowerCase()}catch(t){if(!(t instanceof Error))throw t;return""}}function $t(t,e){if(function(t){return"object"==typeof t&&null!==t}(t))try{return t[e]}catch(t){return void Error}}function Ct(t){return"terminal_quota_exhausted"===function(t){let e=$t(t,"data"),r=$t(t,"detail")??$t(e,"detail")??t,n=$t(r,"error")??r,i=$t(n,"type")??$t(r,"type");return"string"==typeof i?i.toLowerCase():void 0}(t)||(e=At(t),!/\bnon[-\s]+terminal\s+quota\b/i.test(e)&&!/\bnon[-\s]+terminal\s+billing\s+limit\b/i.test(e)&&(/\bterminal\s+quota\b/i.test(e)||/\bterminal\s+billing\s+limit\b/i.test(e)||/\bhard\s+billing\s+limit\b/i.test(e)));var e}function Dt(t){if(Ct(t))return"abort";let e=At(t),r=function(t){if(!Tt(t))return;let e=Mt(t,"data"),r=[t,e,Mt(t,"error"),Mt(e,"error")].filter(t=>void 0!==t);for(let t of r){let e=Rt(t,"name");if("string"==typeof e&&e.length>0)return e}}(t)?.toLowerCase().replace(/[_-]/g,"");return r?.includes("messageabortederror")||r?.includes("aborterror")?"abort":"contextoverflowerror"===r?"context_overflow":r?.includes("ailoadapikeyerror")||r?.includes("loadapi")||/api.?key.?is.?missing/i.test(e)&&/environment variable/i.test(e)?"missing_api_key":/api.?key/i.test(e)&&/must be a string/i.test(e)?"invalid_api_key":r?.includes("providermodelnotfounderror")||r?.includes("modelnotfounderror")||r?.includes("unknownerror")&&/model\s+not\s+found/i.test(e)?"model_not_found":r?.includes("quotaexceeded")||r?.includes("insufficientquota")||r?.includes("billingerror")||r?.includes("resourceexhausted")||r?.includes("insufficientcredits")||r?.includes("usagelimit")||/quota.?exceeded/i.test(e)||/exceeded.*quota/i.test(e)||/quota\b.*\breset/i.test(e)||/usage\s*quota/i.test(e)||/subscription.?(?:quota|limit)/i.test(e)||/insufficient.?(?:quota|balance|funds?|credits?)/i.test(e)||/credits?\s+exhausted/i.test(e)||/\b(?:session|weekly|monthly|daily|hourly|\d+[-\s]hour|plan|call)\s+limit\b/i.test(e)||/\bhit\s+your\b[^.]*\blimit\b/i.test(e)||/\bin\s+arrears\b/i.test(e)||/\brecharge\s+and\s+try\b/i.test(e)||/billing.?(?:hard.?)?limit/i.test(e)||/exhausted\s+your\s+capacity/i.test(e)||/resource.?exhausted/i.test(e)||/out\s+of\s+credits?/i.test(e)||/payment.?required/i.test(e)||/usage\s+limit/i.test(e)||/credit\s+balance.*too\s+low/i.test(e)||/limit\s+exhausted/i.test(e)||/使用上限/.test(e)||/用量上限/.test(e)||/达到.*限制/.test(e)||/额度.*不足/.test(e)||/余额.*不足/.test(e)||/已耗尽/.test(e)||function(t){return/预扣费额度失败/i.test(t)&&/用户剩余额度/i.test(t)||/用户剩余额度/i.test(t)&&/需要预扣费额度/i.test(t)}(e)?"quota_exceeded":void 0}var Lt=new Set(["providermodelnotfounderror","ratelimiterror","modelunavailableerror","providerconnectionerror","authenticationerror"]),Ut=new Set(["messageabortederror","permissiondeniederror","contextlengtherror","timeouterror","validationerror","syntaxerror","usererror"]),qt=["rate_limit","rate limit","usage_limit_reached","usage limit has been reached","quota","all credentials for model","cooling down","exhausted your capacity","not found","unavailable","insufficient","too many requests","over limit","overloaded","bad gateway","bad request","unknown provider","provider not found","model_not_supported","model not supported","model is not supported","connection error","network error","timeout","service unavailable","internal_server_error","free usage","usage exceeded","credit","balance","temporarily unavailable","try again","请稍后重试","503","502","504","429","529","selected provider is forbidden","provider is forbidden","频率限制","请求过于频繁","暂时不可用","服务不可用","server_error","an error occurred while processing","upstream request failed"],jt=["rate limit","cooling down","credentials for model"];function Ft(t){let e=t.name?.toLowerCase();if(void 0!==e&&Ut.has(e))return!1;if(Ct(t))return!1;if("quota_exceeded"===Dt(t))return!0;if(void 0!==e&&Lt.has(e))return!0;let r=t.message?.toLowerCase()??"";return!(!(n=r).includes("retrying in")||!jt.some(t=>n.includes(t)))||(null!=t.statusCode&&(429===t.statusCode||503===t.statusCode||529===t.statusCode)||qt.some(t=>r.includes(t)));var n}var Jt=[/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/model_context_window_exceeded/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,/(?:request[ _])?(?:body|entity|payload)[_ ]too[_ ]large/i,/Request payload is \d+ (?:bytes, over the \d+ byte|tokens, over the \d+ token) limit Kiro accepts\./i,/Model context limit reached\. Conversation size exceeds model capacity\./i],Bt=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];var Gt=/^Error: Model "([^"]+)" not found\. Use --list-models to see available models\.$/m,Ht=/^(?:Error:\s*)?No API key found for\s+([^\s.]+)/m,Vt=/(?:^|\s)(\d{3})\s*:/;function Yt(t){if(t.timedOut||0===t.code)return;let e=`${t.stderr}\n${t.stdout}`,r=Gt.exec(e)?.[1];if(void 0!==r)return{kind:"model_not_visible",id:r};let n=Ht.exec(e)?.[1];if(void 0!==n)return{kind:"auth_missing",provider:n};let i=function(t){for(let e of[t.stderr,t.stdout]){let t=e.split("\n").map(t=>t.trim()).find(t=>t.length>0);if(void 0!==t)return t.slice(0,200)}return}(t);if(void 0===i)return;if(o=i,!Bt.some(t=>t.test(o))&&Jt.some(t=>t.test(o)))return{kind:"context_overflow",detail:i};var o;let a=Number.parseInt(Vt.exec(i)?.[1]??"",10);return Ft({message:i,...Number.isNaN(a)?{}:{statusCode:a}})?{kind:"provider_unavailable",detail:i}:void 0}import{randomUUID as zt}from"node:crypto";import{dirname as Kt,join as Xt}from"node:path";import{randomUUID as Zt}from"node:crypto";import{hostname as Wt}from"node:os";import Qt from"node:path";import te from"node:path";var ee=new Set;function re(t){ee.add(t)}function ne(t){ee.delete(t)}var ie=/\.candidate-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function oe(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}function ae(t,e){try{t.onFailure?.(e)}catch{}}function se(t){if("win32"!==process.platform)return!1;let e=oe(t);return"EBUSY"===e||"EPERM"===e||"EACCES"===e}import{randomUUID as le}from"node:crypto";import{hostname as ce}from"node:os";function ue(t){return"string"==typeof t&&t.length>0}function de(t){let e;try{e=JSON.parse(t)}catch{return null}if("object"!=typeof e||null===e||Array.isArray(e))return null;let r=e;return!Number.isInteger(r.pid)||Number(r.pid)<=0?null:ue(r.process_start)&&ue(r.hostname)&&ue(r.nonce)?!ue(r.created_at)||Number.isNaN(Date.parse(r.created_at))?null:ue(r.purpose)&&(void 0===r.run_id||ue(r.run_id))?{pid:Number(r.pid),process_start:r.process_start,hostname:r.hostname,nonce:r.nonce,created_at:r.created_at,purpose:r.purpose,...void 0===r.run_id?{}:{run_id:r.run_id}}:null:null}async function fe(t,e={}){if(0===t.length)throw Error("lock purpose must not be empty");let r=await pt(process.pid);return{pid:process.pid,process_start:r??"unavailable",hostname:ce(),nonce:le(),created_at:(new Date).toISOString(),purpose:t,...void 0===e.runId?{}:{run_id:e.runId}}}class pe extends Error{lockPath;owner;retriable=!0;constructor(t,e){super(`Lock is held: ${t}`),this.lockPath=t,this.owner=e,this.name="LockContentionError"}}function me(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}function we(t,e){if(void 0!==e)return e(t);if("win32"!==process.platform)return!1;let r=me(t);return"EBUSY"===r||"EPERM"===r||"EACCES"===r}async function he(t){for(let e=0;e<3;e+=1)try{return await(Ee.unlink??R)(t),ne(t),!0}catch(r){if("ENOENT"===me(r))return ne(t),!0;if(!we(r,Ee.isSharingError))throw re(t),Se(Qt.dirname(t)),r;if(e+1===3)return re(t),Se(Qt.dirname(t)),!1}return!1}function ye(t,e){return e?.throwIfAborted(),new Promise((r,n)=>{let i=setTimeout(a,t),o=()=>a(e?.reason??new DOMException("The operation was aborted","AbortError"));function a(t){clearTimeout(i),e?.removeEventListener("abort",o),void 0===t?r():n(t)}e?.addEventListener("abort",o,{once:!0})})}async function ge(t){try{let e=await I(t,"utf8");return{raw:e,record:de(e)}}catch(t){let e=me(t);if("ENOENT"===e)return null;if("\\"===Qt.sep&&"EPERM"===e)return{raw:"",record:null};throw t}}async function ve(t,e){await S(Qt.dirname(t),{recursive:!0,mode:448});let{candidatePath:r,handle:n}=await async function(t){for(let e=0;;e+=1){let r=`${t}.candidate-${Zt()}`;try{return{candidatePath:r,handle:await Y(r,"wx",384)}}catch(n){if(await he(r)||Se(Qt.dirname(t)),"EINTR"!==me(n)||e>=128)throw n}}}(t);try{try{await async function(t,e,r,n){let o="string"==typeof e?a.from(e,r??"utf8"):e,s=0;for(;s<o.length;){n?.throwIfAborted();let{bytesWritten:e}=await i(()=>t.write(o,s));if(e<=0)throw Error(`fs write made no progress at offset ${s}`);s+=e}}(n,`${JSON.stringify(e)}\n`,"utf8"),await n.sync()}finally{await n.close()}try{return await b(r,t),!0}catch(t){if(function(t){let e=me(t);return"EEXIST"===e||"ENOENT"===e}(t))return!1;throw t}}finally{await he(r)||Se(Qt.dirname(t))}}var be=new Set,Ee={};function Se(t){be.delete(t)}async function _e(t){if(t.hostname!==Wt())return!1;let e=wt(t.pid);if("dead"===e)return!0;if("unknown"===e)return!1;let r=await pt(t.pid);return null!==r&&"unavailable"!==t.process_start&&function(t,e){let r=mt(t);return null!==r&&r===mt(e)&&t!==e}(t.process_start,r)}async function Ie(t){let e=await ge(t);if(null===e||null===e.record||!await _e(e.record))return!1;let r=`${t}.reaping-${Zt()}`;try{await O(t,r)}catch(t){if("ENOENT"===me(t))return!1;if(we(t))return!1;throw t}let n=await ge(r);if(null!==n&&n.raw===e.raw)return await R(r),!0;try{await b(r,t)}catch(t){if("EEXIST"!==me(t))throw t}return await R(r),!1}async function xe(t,e,r){if(null===e.record||!await _e(e.record))return!1;let n=`${t}.recovery`,i={...r,nonce:Zt(),created_at:(new Date).toISOString(),purpose:`${r.purpose}:recovery`};for(let t=0;!await ve(n,i);t+=1)if(t>0||!await Ie(n))return!1;try{let r=await ge(t);if(null===r)return!0;if(r.raw!==e.raw||null===r.record)return!1;if(!await _e(r.record))return!1;let o=await ge(n);return null!==o&&o.record?.nonce===i.nonce&&(await R(t),!0)}finally{await Oe(n,i)}}async function Ne(t,e,r={}){let n=r.waitTimeoutMs??0,i=r.retryDelayMs??25;if(n<0||i<=0)throw Error("lock wait options must be positive");let o=Qt.dirname(t);be.has(o)||(be.add(o),await async function(t,e=Date.now,r={}){let n;try{n=await x(t)}catch(e){if("ENOENT"===oe(e)){for(let e of ee)te.dirname(e)===t&&ne(e);return 0}throw e}let i=0;for(let o of n){if(!ie.test(o))continue;let n=te.join(t,o);try{let t=await T(n);if(!ee.has(n)&&e()-t.mtimeMs<=36e5)continue;let o=!1;for(let t=0;t<3;t+=1)try{await(r.unlink??R)(n),ne(n),o=!0;break}catch(e){if("ENOENT"===oe(e)){ne(n),o=!0;break}if(!(r.isSharingError?.(e)??se(e)))throw e;t+1===3&&ae(r,n)}o&&(i+=1)}catch(t){"ENOENT"===oe(t)&&ne(n),ae(r,n)}}return i}(o,Date.now,{...void 0===Ee.unlink?{}:{unlink:Ee.unlink},...void 0===Ee.isSharingError?{}:{isSharingError:Ee.isSharingError},onFailure:()=>Se(o)}).catch(()=>{Se(o)}));let a=Date.now()+n;for(;;){r.signal?.throwIfAborted();let n=await ge(t);if(null===n){if(await ve(t,e))return;if(r.signal?.throwIfAborted(),n=await ge(t),null===n)continue}if(!await xe(t,n,e)){if(r.signal?.throwIfAborted(),Date.now()>=a)throw new pe(t,n.record);await ye(Math.min(i,Math.max(1,a-Date.now())),r.signal)}}}async function Oe(t,e){let r=await ge(t);if(null===r||r.record?.nonce!==e.nonce)return!1;try{return await R(t),!0}catch(t){if("ENOENT"===me(t))return!1;throw t}}async function ke(t,e,r,n){await Ne(t,e,n);try{return await r()}finally{await Oe(t,e)}}Promise.resolve();var Pe=[["\\bAKIA[0-9A-Z]{16}\\b",""],["\\b(?:bearer|token|api[_-]?key|secret|password|passwd|pwd)\\s*[=:]\\s*\\S{1,256}","i"],["\\bAuthorization\\s*:\\s*Bearer\\s+\\S{1,256}","i"],["\\bsk-(?:proj-)?[-_A-Za-z0-9]+\\b",""],["\\b(?:ghp|github_pat|glpat|xox[baprs])-[-_A-Za-z0-9]+\\b",""]];Pe.map(([t,e])=>new RegExp(t,e)),Pe.map(([t,e])=>new RegExp(t,`${e}g`));new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});import{dirname as Te}from"node:path";import{fileURLToPath as Re}from"node:url";Te(Re(import.meta.url));import{dirname as Me}from"node:path";import{fileURLToPath as Ae}from"node:url";Me(Ae(import.meta.url)),new Date(0).toISOString();import{dirname as $e}from"node:path";import{fileURLToPath as Ce}from"node:url";$e(Ce(import.meta.url));function De(t){return Xt(t,"terminal-claim.json")}function Le(t,e,r){return t.runId===e.runId&&t.attempt===e.attempt&&(void 0===r||t.kind===r)}function Ue(t,e){let r=`${t}.${process.pid}.${zt()}.candidate`;!function(t,e){let r=z(t,"wx",384);try{B(r,`${JSON.stringify(e,null,2)}\n`,"utf8"),$(r)}finally{K(r)}}(r,e);try{C(r,t)}catch(t){if("EEXIST"===Ge(t))return!1;throw t}finally{Fe(r)}return function(t){let e;try{e=z(t,"r")}catch(t){if("win32"===process.platform&&["EISDIR","EPERM"].includes(Ge(t)??""))return;throw t}try{$(e)}catch(t){if("win32"!==process.platform||!["EPERM","EACCES","EINVAL"].includes(Ge(t)??""))throw t}finally{K(e)}}(Kt(t)),!0}function qe(t){let e;try{e=U(t,"utf8")}catch(t){if("ENOENT"===Ge(t))return;throw t}try{return{raw:e,claim:Be(JSON.parse(e))}}catch{return{raw:e,claim:void 0}}}async function je(t,e,r,n,i,o){let a=await fe("reflection-finalize",{runId:i.runId});return ke(Xt(t,"terminal-claim-recovery.lock"),a,async()=>{let t=qe(e);if(void 0!==t){if(t.raw!==r.raw)return t.claim;if("invalid"===n){if(void 0!==t.claim)return t.claim}else{if(void 0===t.claim)return;if("publish"!==t.claim.kind||!Je(t.claim,o))return t.claim}Fe(e)}},{waitTimeoutMs:Number.POSITIVE_INFINITY})}function Fe(t){try{J(t)}catch(t){if("ENOENT"!==Ge(t))throw t}}function Je(t,e){return"dead"===(e.getPidLiveness??wt)(t.claimantPid)}function Be(t){if(!function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}(t)||1!==t.version||"publish"!==t.kind&&"abandon"!==t.kind||"string"!=typeof t.runId||!Number.isInteger(t.attempt)||!Number.isInteger(t.claimantPid)||Number(t.claimantPid)<=0)throw TypeError("Invalid run terminal claim");return{version:1,kind:t.kind,runId:t.runId,attempt:Number(t.attempt),claimantPid:Number(t.claimantPid)}}function Ge(t){return t instanceof Error&&"code"in t?String(t.code):void 0}import{join as He}from"node:path";async function Ve(t,e,r){let n={runId:e.runId,attempt:e.attempt??1},i=await async function(t,e,r,n={},i=process.pid){let o=De(t),a={version:1,kind:r,runId:e.runId,attempt:e.attempt,claimantPid:i},s=0;for(;;){if(Ue(o,a))return a;let i=qe(o);if(void 0===i)continue;let l=i.claim;if(void 0===l){if(s>0)throw TypeError("Invalid run terminal claim");s+=1,await(n.beforeRecovery?.("invalid"));let r=await je(t,o,i,"invalid",e,n);if(void 0!==r)return r;continue}if(Le(l,e,r))return l;if("publish"!==l.kind||!Je(l,n))return l;await(n.beforeRecovery?.("dead-publish"));let c=await je(t,o,i,"dead-publish",e,n);if(void 0!==c)return c}}(t,n,"publish");Le(i,n,"publish")&&(await rt(Pt(t,"publishing.json"),{version:1,...n,finishedAt:r.finishedAt}),await async function(t,e,r,n=ke,i=fe){let o=await i("reflection-finalize",{runId:e});return n(He(t,"terminalization.lock"),o,r,{waitTimeoutMs:Number.POSITIVE_INFINITY})}(t,e.runId,async()=>{if(X(Pt(t,"final.json"))||X(Pt(t,"abandoned.json")))return;if(!Le(function(t){return Be(JSON.parse(U(De(t),"utf8")))}(t),n,"publish"))return;let i=void 0!==Yt({code:r.childExit.code,stdout:U(e.stdoutPath,"utf8"),stderr:U(e.stderrPath,"utf8"),timedOut:r.timedOut});i&&void 0!==e.nextAttempt&&await nt(Pt(t,"ledger.json"),{attempt:e.nextAttempt.attempt,model:e.nextAttempt.model,...void 0===e.nextAttempt.thinking?{thinking:void 0}:{thinking:e.nextAttempt.thinking},launching:!0,pid:void 0,processStart:void 0,childPid:void 0,childProcessStart:void 0}),await rt(Pt(t,"outcome.json"),r),i&&await it(De(t))}))}function Ye(t){try{G(3,`${JSON.stringify(t)}\n`)}catch(t){if(!(t instanceof Error&&"code"in t&&["EPIPE","EBADF"].includes(String(t.code))))throw t}}var ze=process.argv.slice(2);try{if("--child-bootstrap"===ze[0]){if(void 0===ze[1])throw TypeError("run directory is required");await async function(e){if(!await async function(){for await(let t of process.stdin)if(Buffer.byteLength(t)>0)return!0;return!1}())return;let r=await et(Z(e,"launch.json")),n=yt(),i=t(r.command,[...r.args],{cwd:r.cwd,env:r.env,detached:!1,stdio:["ignore","inherit","inherit"],windowsHide:!0});Ye({code:i.pid??null,signal:"MODEL_PID"});let o=()=>{"win32"!==n&&"win32"!==process.platform||i.kill()};process.on("SIGTERM",o),process.on("SIGINT",o);let a=gt(r.hardDeadlineAt,()=>{"win32"===n?Nt(n,i):It(process.pid,"SIGTERM")}),s=gt(r.hardDeadlineAt+r.terminationGraceMs,()=>{Ot(n,process.pid)});Ye(await new Promise(t=>{let e=!1;i.once("error",()=>{e||(e=!0,t({code:null,signal:null}))}),i.once("close",(r,n)=>{e||(e=!0,t({code:r,signal:n}))})}).finally(()=>{a(),s()}))}(ze[1])}else{if(void 0===ze[0])throw TypeError("run directory is required");await async function(e){let r=Z(e,"launch.json"),n=Z(e,"ledger.json"),i=await et(r),o=yt();await nt(n,{launching:!1,pid:process.pid,processStart:await kt(process.pid)});let a,s=z(i.stdoutPath,"w"),l=z(i.stderrPath,"w"),c=t(process.execPath,[W(import.meta.url),"--child-bootstrap",e],{env:process.env,detached:!0,stdio:["pipe",s,l,"pipe"],windowsHide:!0}),u=c.pid,d="",f=c.stdio[3];null!=f&&"setEncoding"in f&&(f.setEncoding("utf8"),f.on("data",t=>{d+=t;for(let t of d.split("\n"))try{let e=JSON.parse(t);"MODEL_PID"===e.signal&&"number"==typeof e.code&&(a=e.code)}catch(t){if(!(t instanceof SyntaxError))throw t}}));let p=(t=!1)=>{try{Ot(o,u,t)}catch(t){process.stderr.write(`${t instanceof Error?t.message:String(t)}\n`)}};if(process.once("exit",()=>p(!0)),process.once("SIGTERM",()=>{p(),u=void 0,process.exit(143)}),process.once("SIGINT",()=>{p(),u=void 0,process.exit(130)}),void 0===c.pid)throw Error("child bootstrap did not receive a pid");await nt(n,{childPid:c.pid,childProcessStart:await kt(c.pid)}),c.stdin?.end("1\n");let m,w=!1,h=Promise.resolve();"win32"===o&&(h=new Promise(t=>{m=t}));let y=gt(i.hardDeadlineAt,()=>{w=!0,"win32"===o?xt(c.pid):Nt(o,c)}),g=gt(i.hardDeadlineAt+i.terminationGraceMs,()=>{Ot(o,a??u),m?.()}),v=await new Promise((t,e)=>{let r=!1;c.once("error",t=>{r||(r=!0,e(t))}),c.once("close",(e,n)=>{r||(r=!0,t({code:e,signal:n}))})}),b=function(t){let e=t.trim().split("\n").at(-1);if(void 0!==e&&0!==e.length)try{let t=JSON.parse(e),r="number"==typeof t.code||null===t.code?t.code:void 0,n="string"==typeof t.signal||null===t.signal?t.signal:void 0;return void 0===r||void 0===n||"MODEL_PID"===n?void 0:{code:r,signal:n}}catch{return}}(d);"win32"===o&&w&&void 0===b&&await h,y(),g(),u=void 0,K(s),K(l);let E=function(){let t=ht()?process.env.OMO_MEMORY_SUPERVISOR_CLOCK_PATH:void 0;return void 0===t?Date.now():bt(t)}(),S=(new Date).toISOString(),_={version:1,runId:i.runId,attempt:i.attempt,finishedAt:S,childExit:b??v,timedOut:w||Number.isFinite(E)&&E>=i.hardDeadlineAt};await Ve(e,i,_),await it(r),process.exit(0)}(ze[0])}}catch(t){process.stderr.write(`${t instanceof Error?t.stack??t.message:String(t)}\n`),process.exitCode=1}
2
+ // omo:1kZRR0pWVWGZ425iwHP0eR10sHDFbjNM4RwymIpzDU4:wrcNysGCSmPQBapD2B6XCs6Q9IVy4wapNChJ-vEMgU8
3
+ import{spawn as t}from"node:child_process";import*as e from"node:fs";import*as r from"node:fs/promises";function n(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}async function i(t){for(let e=0;;e+=1)try{return await t()}catch(t){if("EINTR"!==n(t)||e>=128)throw t}}function o(t){for(let e=0;;e+=1)try{return t()}catch(t){if("EINTR"!==n(t)||e>=128)throw t}}import{Buffer as a}from"node:buffer";import{constants as s}from"node:fs";function l(t){return"number"==typeof t?0!==(t&s.O_EXCL):"string"==typeof t&&t.toLowerCase().includes("x")}function c(t){return"function"==typeof t}function u(t){return(...e)=>i(async()=>t(...e))}function d(t){return(...e)=>o(()=>t(...e))}function f(t,e){let r="async"===e?u:d,n=new Map;return new Proxy(t,{get(t,e){if(n.has(e))return n.get(e);let i=Reflect.get(t,e);if(!c(i))return i;let o=r(i),a=Reflect.get(i,"native");return c(a)&&Object.assign(o,{native:r(a)}),n.set(e,o),o}})}var p=new Set(["stat","sync","datasync","chmod","chown","utimes","truncate"]);var m=f(r,"async"),w=f(e,"sync"),{access:h,chmod:y,copyFile:g,cp:v,link:b,lstat:E,mkdir:S,mkdtemp:_,readFile:x,readdir:I,realpath:N,rename:O,rm:k,rmdir:P,stat:T,unlink:R}=m,{accessSync:M,chmodSync:A,fsyncSync:$,linkSync:L,lstatSync:C,mkdirSync:D,readFileSync:U,readdirSync:q,realpathSync:j,statSync:F,unlinkSync:H,writeFileSync:J,writeSync:B}=w,{constants:G,watch:V}=e,Y=async(...t)=>{let e=()=>r.open(...t);return function(t){return new Proxy(t,{get(t,e){let r=Reflect.get(t,e);if(!c(r))return r;let o=e=>Reflect.apply(r,t,[...e]);return"close"===e||e===Symbol.asyncDispose?(...t)=>{let e=o(t);return e instanceof Promise?e.catch(t=>{if("EINTR"!==n(t))throw t}):e}:"string"==typeof e&&p.has(e)?(...t)=>{let e=o(t);return e instanceof Promise?e.catch(e=>{if("EINTR"!==n(e))throw e;return i(async()=>o(t))}):e}:(...t)=>o(t)}})}(await(l(t[1]??"r")?e():i(e)))},K=(t,r,n)=>function(t,e,r,n){return l(r)?t(e,r,n):o(()=>t(e,r,n))}(e.openSync,t,r,n??void 0);function z(t){try{e.closeSync(t)}catch(t){if("EINTR"!==n(t))throw t}}function X(t){try{return o(()=>e.statSync(t)),!0}catch{return!1}}import{join as Z}from"node:path";import{fileURLToPath as W}from"node:url";import{randomUUID as Q}from"node:crypto";import{dirname as tt}from"node:path";async function et(t){return JSON.parse(await x(t,"utf8"))}async function rt(t,e,r=384){let n=`${t}.tmp-${process.pid}-${Q()}`,i=await Y(n,"wx",r),o=!1;try{try{await i.writeFile(`${JSON.stringify(e,null,2)}\n`,"utf8"),await i.sync()}finally{await i.close()}await O(n,t),o=!0,await async function(t){try{let e=await Y(t,"r");try{await e.sync()}finally{await e.close()}}catch(t){let e=t instanceof Error&&"code"in t?t.code:void 0;if("win32"!==process.platform||!["EISDIR","EPERM"].includes(String(e)))throw t}}(tt(t))}finally{o||await it(n)}}async function nt(t,e){let r=await et(t);await rt(t,{...r,...e})}async function it(t){try{await R(t)}catch(t){if(!(t instanceof Error&&"code"in t&&"ENOENT"===t.code))throw t}}import{spawn as ot,spawnSync as at}from"node:child_process";import{execFile as st}from"node:child_process";var lt=null;function ct(){return lt??=async function(){if("darwin"!==process.platform)return null;try{let{dlopen:t,FFIType:e}=await(import("bun:ffi")),r=t("/usr/lib/libSystem.B.dylib",{proc_pidinfo:{args:[e.i32,e.i32,e.u64,e.ptr,e.i32],returns:e.i32}});return(t,e,n,i,o)=>Number(r.symbols.proc_pidinfo(t,e,n,i,o))}catch{return null}}(),lt}var ut=null;async function dt(t){if("win32"!==process.platform)return null;if(!Number.isSafeInteger(t)||t<=0)return null;ut??=async function(){if("win32"!==process.platform)return null;try{let{dlopen:t,FFIType:e}=await(import("bun:ffi"));return t("kernel32.dll",{OpenProcess:{args:[e.u32,e.i32,e.u32],returns:e.ptr},GetProcessTimes:{args:[e.ptr,e.ptr,e.ptr,e.ptr,e.ptr],returns:e.i32},CloseHandle:{args:[e.ptr],returns:e.i32}}).symbols}catch{return null}}();let e=await ut;if(null===e)return null;let r=e.OpenProcess(4096,0,t);if(null===r||0===r||0n===r)return null;try{let t=new BigUint64Array(1),n=e.GetProcessTimes(r,t,new BigUint64Array(1),new BigUint64Array(1),new BigUint64Array(1)),i=t[0]??0n;return 0===n||0n===i?null:i}finally{e.CloseHandle(r)}}async function ft(t,e){return await new Promise(r=>{st(t,e,{encoding:"utf8",timeout:2e3,windowsHide:!0},(t,e)=>{if(null!==t)return void r(null);let n=e.trim();r(n.length>0?n:null)})})}var pt=function(t,e){let r;return n=>n!==e?t(n):(r??=t(n).then(t=>(null===t&&(r=void 0),t),t=>{throw r=void 0,t}),r)}(async function(t){if("linux"===process.platform)return await async function(t){try{let e=await x(`/proc/${t}/stat`,"utf8"),r=e.lastIndexOf(")");if(r<0)return null;let n=e.slice(r+2).trim().split(/\s+/)[19];return void 0===n?null:`linux-proc-start-ticks:${n}`}catch{return null}}(t);if("darwin"===process.platform||"freebsd"===process.platform){if("dead"===wt(t))return null;let e=await async function(t){if("darwin"!==process.platform)return null;if(!Number.isSafeInteger(t)||t<=0)return null;let e=await ct();if(null===e)return null;let r=new Uint8Array(136),n=0;try{n=e(t,3,0n,r,136)}catch{return null}if(136!==n)return null;let i=new DataView(r.buffer,r.byteOffset,r.byteLength),o=Number(i.getBigUint64(120,!0));return o>0?o:null}(t);if(null!==e)return`proc-start-epoch:${e}`;let r=await ft("/bin/ps",["-o","lstart=","-p",String(t)]);return null===r?null:`ps-lstart:${r.replace(/\s+/g," ")}`}return"win32"===process.platform?await async function(t){if("dead"===wt(t))return null;let e=await dt(t);if(null!==e)return`win32-creation-filetime:${e}`;let r=await ft("powershell.exe",["-NoProfile","-Command",`(Get-Process -Id ${t} -ErrorAction SilentlyContinue).StartTime.ToUniversalTime().ToString('o')`]);return null===r?null:`win32-creation-date:${r}`}(t):null},process.pid);function mt(t){let e=t.indexOf(":");return e<=0?null:t.slice(0,e)}function wt(t){try{return process.kill(t,0),"alive"}catch(t){let e=function(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}(t);return"ESRCH"===e?"dead":"EPERM"===e?"alive":"unknown"}}function ht(){return"1"===process.env.OMO_MEMORY_SUPERVISOR_ALLOW_TEST_SEAMS}function yt(){if(ht()){let t=process.env.OMO_MEMORY_SUPERVISOR_PLATFORM;if("posix"===t||"win32"===t)return t}return"win32"===process.platform?"win32":"posix"}function gt(t,e){let r=ht()?process.env.OMO_MEMORY_SUPERVISOR_CLOCK_PATH:void 0;if(void 0===r){let r=setTimeout(e,Math.max(0,t-Date.now()));return()=>clearTimeout(r)}let n=!1,i=()=>{if(n)return;let i=bt(r);!Number.isFinite(i)||i<t||(n=!0,o?.close(),clearInterval(a),e())};if(bt(r)>=t)return n=!0,e(),()=>{};let o=V(r,i),a=setInterval(i,vt);return i(),()=>{n||(n=!0,o.close(),clearInterval(a))}}var vt=25;function bt(t){let e=q(t).map(t=>/^(\d+)-(-?\d+(?:\.\d+)?)$/.exec(t)).filter(t=>null!==t).sort((t,e)=>Number(t[1])-Number(e[1])).at(-1);return void 0===e?Number.NaN:Number(e[2])}function Et(t,e){if(!ht())return;let r=process.env.OMO_MEMORY_SUPERVISOR_TASKKILL_RUN_DIR;void 0!==r&&J(`${r}/${t}-${process.pid}.json`,`${JSON.stringify({targetPid:e})}\n`,"utf8")}function St(t){if(!ht())return;let e=process.env[t];if(void 0===e)return;let r=JSON.parse(e);if(!Array.isArray(r)||!r.every(t=>"string"==typeof t)||0===r.length)throw TypeError(`${t} must be a non-empty string array`);return r}function _t(t,e,r){let[n,...i]=t;if(void 0===n)throw TypeError("termination command is required");if(r){let t=at(n,[...i,...e],{env:process.env,stdio:"ignore",windowsHide:!0});if(void 0!==t.error)throw t.error;return}ot(n,[...i,...e],{env:process.env,stdio:"ignore",windowsHide:!0}).once("error",t=>process.stderr.write(`${t.message}\n`))}function xt(t,e){Et(`posix-${e}`,t);let r=St("OMO_MEMORY_SUPERVISOR_POSIX_SIGNAL_COMMAND");if(void 0===r)try{process.kill(-t,e)}catch(t){if(!(t instanceof Error&&"code"in t&&"ESRCH"===t.code))throw t}else _t(r,["--signal-group",String(t),e],!1)}function It(t){void 0!==t&&Et("win32-graceful",t)}function Nt(t,e){"win32"===t?(It(e.pid),e.kill()):void 0!==e.pid&&xt(e.pid,"SIGTERM")}function Ot(t,e,r=!1){void 0!==e&&("win32"===t?function(t,e){_t(St("OMO_MEMORY_SUPERVISOR_TASKKILL_COMMAND")??["taskkill"],["/pid",String(t),"/T","/F"],e)}(e,r):xt(e,"SIGKILL"))}async function kt(t){return await pt(t)}import{join as Pt}from"node:path";function Tt(t){return"object"==typeof t&&null!==t}function Rt(t,e){try{return t?.[e]}catch(t){return void Error}}function Mt(t,e){let r=Rt(t,e);return Tt(r)?r:void 0}function At(t){if(!t)return"";if("string"==typeof t)return t.toLowerCase();if(!Tt(t))try{return JSON.stringify(t).toLowerCase()}catch(t){if(!(t instanceof Error))throw t;return""}let e=Mt(t,"data"),r=[e,Mt(t,"error"),t,Mt(e,"error")].filter(t=>void 0!==t);for(let t of r){let e=Rt(t,"message");if("string"==typeof e&&e.length>0)return e.toLowerCase()}let n=Rt(t,"name");if("string"==typeof n&&n.length>0){let t=n.match(/:\s*(.+)/);if(t)return t[1]?.trim().toLowerCase()??""}try{return JSON.stringify(t).toLowerCase()}catch(t){if(!(t instanceof Error))throw t;return""}}function $t(t,e){if(function(t){return"object"==typeof t&&null!==t}(t))try{return t[e]}catch(t){return void Error}}function Lt(t){return"terminal_quota_exhausted"===function(t){let e=$t(t,"data"),r=$t(t,"detail")??$t(e,"detail")??t,n=$t(r,"error")??r,i=$t(n,"type")??$t(r,"type");return"string"==typeof i?i.toLowerCase():void 0}(t)||(e=At(t),!/\bnon[-\s]+terminal\s+quota\b/i.test(e)&&!/\bnon[-\s]+terminal\s+billing\s+limit\b/i.test(e)&&(/\bterminal\s+quota\b/i.test(e)||/\bterminal\s+billing\s+limit\b/i.test(e)||/\bhard\s+billing\s+limit\b/i.test(e)));var e}function Ct(t){if(Lt(t))return"abort";let e=At(t),r=function(t){if(!Tt(t))return;let e=Mt(t,"data"),r=[t,e,Mt(t,"error"),Mt(e,"error")].filter(t=>void 0!==t);for(let t of r){let e=Rt(t,"name");if("string"==typeof e&&e.length>0)return e}}(t)?.toLowerCase().replace(/[_-]/g,"");return r?.includes("messageabortederror")||r?.includes("aborterror")?"abort":"contextoverflowerror"===r?"context_overflow":r?.includes("ailoadapikeyerror")||r?.includes("loadapi")||/api.?key.?is.?missing/i.test(e)&&/environment variable/i.test(e)?"missing_api_key":/api.?key/i.test(e)&&/must be a string/i.test(e)?"invalid_api_key":r?.includes("providermodelnotfounderror")||r?.includes("modelnotfounderror")||r?.includes("unknownerror")&&/model\s+not\s+found/i.test(e)?"model_not_found":r?.includes("quotaexceeded")||r?.includes("insufficientquota")||r?.includes("billingerror")||r?.includes("resourceexhausted")||r?.includes("insufficientcredits")||r?.includes("usagelimit")||/quota.?exceeded/i.test(e)||/exceeded.*quota/i.test(e)||/quota\b.*\breset/i.test(e)||/usage\s*quota/i.test(e)||/subscription.?(?:quota|limit)/i.test(e)||/insufficient.?(?:quota|balance|funds?|credits?)/i.test(e)||/credits?\s+exhausted/i.test(e)||/\b(?:session|weekly|monthly|daily|hourly|\d+[-\s]hour|plan|call)\s+limit\b/i.test(e)||/\bhit\s+your\b[^.]*\blimit\b/i.test(e)||/\bin\s+arrears\b/i.test(e)||/\brecharge\s+and\s+try\b/i.test(e)||/billing.?(?:hard.?)?limit/i.test(e)||/exhausted\s+your\s+capacity/i.test(e)||/resource.?exhausted/i.test(e)||/out\s+of\s+credits?/i.test(e)||/payment.?required/i.test(e)||/usage\s+limit/i.test(e)||/credit\s+balance.*too\s+low/i.test(e)||/limit\s+exhausted/i.test(e)||/使用上限/.test(e)||/用量上限/.test(e)||/达到.*限制/.test(e)||/额度.*不足/.test(e)||/余额.*不足/.test(e)||/已耗尽/.test(e)||function(t){return/预扣费额度失败/i.test(t)&&/用户剩余额度/i.test(t)||/用户剩余额度/i.test(t)&&/需要预扣费额度/i.test(t)}(e)?"quota_exceeded":void 0}var Dt=new Set(["providermodelnotfounderror","ratelimiterror","modelunavailableerror","providerconnectionerror","authenticationerror"]),Ut=new Set(["messageabortederror","permissiondeniederror","contextlengtherror","timeouterror","validationerror","syntaxerror","usererror"]),qt=["rate_limit","rate limit","usage_limit_reached","usage limit has been reached","quota","all credentials for model","cooling down","exhausted your capacity","not found","unavailable","insufficient","too many requests","over limit","overloaded","bad gateway","bad request","unknown provider","provider not found","model_not_supported","model not supported","model is not supported","connection error","network error","timeout","service unavailable","internal_server_error","free usage","usage exceeded","credit","balance","temporarily unavailable","try again","请稍后重试","503","502","504","429","529","selected provider is forbidden","provider is forbidden","频率限制","请求过于频繁","暂时不可用","服务不可用","server_error","an error occurred while processing","upstream request failed"],jt=["rate limit","cooling down","credentials for model"];function Ft(t){let e=t.name?.toLowerCase();if(void 0!==e&&Ut.has(e))return!1;if(Lt(t))return!1;if("quota_exceeded"===Ct(t))return!0;if(void 0!==e&&Dt.has(e))return!0;let r=t.message?.toLowerCase()??"";return!(!(n=r).includes("retrying in")||!jt.some(t=>n.includes(t)))||(null!=t.statusCode&&(429===t.statusCode||503===t.statusCode||529===t.statusCode)||qt.some(t=>r.includes(t)));var n}var Ht=[/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length(?: of [\d,]+ tokens?|\s*\([\d,]+\))/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \d+ tokens/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/prompt has [\d,]+ tokens?, but the configured context size is [\d,]+ tokens?/i,/prompt too long; exceeded (?:max )?context length/i,/range of input length should be/i,/model_context_window_exceeded/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i,/(?:request[ _])?(?:body|entity|payload)[_ ]too[_ ]large/i,/Request payload is \d+ (?:bytes, over the \d+ byte|tokens, over the \d+ token) limit Kiro accepts\./i,/Model context limit reached\. Conversation size exceeds model capacity\./i],Jt=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];var Bt=/^Error: Model "([^"]+)" not found\. Use --list-models to see available models\.$/m,Gt=/^(?:Error:\s*)?No API key found for\s+([^\s.]+)/m,Vt=/(?:^|\s)(\d{3})\s*:/;function Yt(t){if(t.timedOut||0===t.code)return;let e=`${t.stderr}\n${t.stdout}`,r=Bt.exec(e)?.[1];if(void 0!==r)return{kind:"model_not_visible",id:r};let n=Gt.exec(e)?.[1];if(void 0!==n)return{kind:"auth_missing",provider:n};let i=function(t){for(let e of[t.stderr,t.stdout]){let t=e.split("\n").map(t=>t.trim()).find(t=>t.length>0);if(void 0!==t)return t.slice(0,200)}return}(t);if(void 0===i)return;if(o=i,!Jt.some(t=>t.test(o))&&Ht.some(t=>t.test(o)))return{kind:"context_overflow",detail:i};var o;let a=Number.parseInt(Vt.exec(i)?.[1]??"",10);return Ft({message:i,...Number.isNaN(a)?{}:{statusCode:a}})?{kind:"provider_unavailable",detail:i}:void 0}import{randomUUID as Kt}from"node:crypto";import{dirname as zt,join as Xt}from"node:path";import{randomUUID as Zt}from"node:crypto";import{hostname as Wt}from"node:os";import Qt from"node:path";import te from"node:path";var ee=new Set;function re(t){ee.add(t)}function ne(t){ee.delete(t)}var ie=/\.candidate-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function oe(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}function ae(t,e){try{t.onFailure?.(e)}catch{}}function se(t){if("win32"!==process.platform)return!1;let e=oe(t);return"EBUSY"===e||"EPERM"===e||"EACCES"===e}import{randomUUID as le}from"node:crypto";import{hostname as ce}from"node:os";function ue(t){return"string"==typeof t&&t.length>0}function de(t){let e;try{e=JSON.parse(t)}catch{return null}if("object"!=typeof e||null===e||Array.isArray(e))return null;let r=e;return!Number.isInteger(r.pid)||Number(r.pid)<=0?null:ue(r.process_start)&&ue(r.hostname)&&ue(r.nonce)?!ue(r.created_at)||Number.isNaN(Date.parse(r.created_at))?null:ue(r.purpose)&&(void 0===r.run_id||ue(r.run_id))?{pid:Number(r.pid),process_start:r.process_start,hostname:r.hostname,nonce:r.nonce,created_at:r.created_at,purpose:r.purpose,...void 0===r.run_id?{}:{run_id:r.run_id}}:null:null}async function fe(t,e={}){if(0===t.length)throw Error("lock purpose must not be empty");let r=await pt(process.pid);return{pid:process.pid,process_start:r??"unavailable",hostname:ce(),nonce:le(),created_at:(new Date).toISOString(),purpose:t,...void 0===e.runId?{}:{run_id:e.runId}}}class pe extends Error{lockPath;owner;retriable=!0;constructor(t,e){super(`Lock is held: ${t}`),this.lockPath=t,this.owner=e,this.name="LockContentionError"}}function me(t){if(t instanceof Error&&"code"in t)return"string"==typeof t.code?t.code:void 0}function we(t,e){if(void 0!==e)return e(t);if("win32"!==process.platform)return!1;let r=me(t);return"EBUSY"===r||"EPERM"===r||"EACCES"===r}async function he(t){for(let e=0;e<3;e+=1)try{return await(Ee.unlink??R)(t),ne(t),!0}catch(r){if("ENOENT"===me(r))return ne(t),!0;if(!we(r,Ee.isSharingError))throw re(t),Se(Qt.dirname(t)),r;if(e+1===3)return re(t),Se(Qt.dirname(t)),!1}return!1}function ye(t,e){return e?.throwIfAborted(),new Promise((r,n)=>{let i=setTimeout(a,t),o=()=>a(e?.reason??new DOMException("The operation was aborted","AbortError"));function a(t){clearTimeout(i),e?.removeEventListener("abort",o),void 0===t?r():n(t)}e?.addEventListener("abort",o,{once:!0})})}async function ge(t){try{let e=await x(t,"utf8");return{raw:e,record:de(e)}}catch(t){let e=me(t);if("ENOENT"===e)return null;if("\\"===Qt.sep&&"EPERM"===e)return{raw:"",record:null};throw t}}async function ve(t,e){await S(Qt.dirname(t),{recursive:!0,mode:448});let{candidatePath:r,handle:n}=await async function(t){for(let e=0;;e+=1){let r=`${t}.candidate-${Zt()}`;try{return{candidatePath:r,handle:await Y(r,"wx",384)}}catch(n){if(await he(r)||Se(Qt.dirname(t)),"EINTR"!==me(n)||e>=128)throw n}}}(t);try{try{await async function(t,e,r,n){let o="string"==typeof e?a.from(e,r??"utf8"):e,s=0;for(;s<o.length;){n?.throwIfAborted();let{bytesWritten:e}=await i(()=>t.write(o,s));if(e<=0)throw Error(`fs write made no progress at offset ${s}`);s+=e}}(n,`${JSON.stringify(e)}\n`,"utf8"),await n.sync()}finally{await n.close()}try{return await b(r,t),!0}catch(t){if(function(t){let e=me(t);return"EEXIST"===e||"ENOENT"===e}(t))return!1;throw t}}finally{await he(r)||Se(Qt.dirname(t))}}var be=new Set,Ee={};function Se(t){be.delete(t)}async function _e(t){if(t.hostname!==Wt())return!1;let e=wt(t.pid);if("dead"===e)return!0;if("unknown"===e)return!1;let r=await pt(t.pid);return null!==r&&"unavailable"!==t.process_start&&function(t,e){let r=mt(t);return null!==r&&r===mt(e)&&t!==e}(t.process_start,r)}async function xe(t){let e=await ge(t);if(null===e||null===e.record||!await _e(e.record))return!1;let r=`${t}.reaping-${Zt()}`;try{await O(t,r)}catch(t){if("ENOENT"===me(t))return!1;if(we(t))return!1;throw t}let n=await ge(r);if(null!==n&&n.raw===e.raw)return await R(r),!0;try{await b(r,t)}catch(t){if("EEXIST"!==me(t))throw t}return await R(r),!1}async function Ie(t,e,r){if(null===e.record||!await _e(e.record))return!1;let n=`${t}.recovery`,i={...r,nonce:Zt(),created_at:(new Date).toISOString(),purpose:`${r.purpose}:recovery`};for(let t=0;!await ve(n,i);t+=1)if(t>0||!await xe(n))return!1;try{let r=await ge(t);if(null===r)return!0;if(r.raw!==e.raw||null===r.record)return!1;if(!await _e(r.record))return!1;let o=await ge(n);return null!==o&&o.record?.nonce===i.nonce&&(await R(t),!0)}finally{await Oe(n,i)}}async function Ne(t,e,r={}){let n=r.waitTimeoutMs??0,i=r.retryDelayMs??25;if(n<0||i<=0)throw Error("lock wait options must be positive");let o=Qt.dirname(t);be.has(o)||(be.add(o),await async function(t,e=Date.now,r={}){let n;try{n=await I(t)}catch(e){if("ENOENT"===oe(e)){for(let e of ee)te.dirname(e)===t&&ne(e);return 0}throw e}let i=0;for(let o of n){if(!ie.test(o))continue;let n=te.join(t,o);try{let t=await T(n);if(!ee.has(n)&&e()-t.mtimeMs<=36e5)continue;let o=!1;for(let t=0;t<3;t+=1)try{await(r.unlink??R)(n),ne(n),o=!0;break}catch(e){if("ENOENT"===oe(e)){ne(n),o=!0;break}if(!(r.isSharingError?.(e)??se(e)))throw e;t+1===3&&ae(r,n)}o&&(i+=1)}catch(t){"ENOENT"===oe(t)&&ne(n),ae(r,n)}}return i}(o,Date.now,{...void 0===Ee.unlink?{}:{unlink:Ee.unlink},...void 0===Ee.isSharingError?{}:{isSharingError:Ee.isSharingError},onFailure:()=>Se(o)}).catch(()=>{Se(o)}));let a=Date.now()+n;for(;;){r.signal?.throwIfAborted();let n=await ge(t);if(null===n){if(await ve(t,e))return;if(r.signal?.throwIfAborted(),n=await ge(t),null===n)continue}if(!await Ie(t,n,e)){if(r.signal?.throwIfAborted(),Date.now()>=a)throw new pe(t,n.record);await ye(Math.min(i,Math.max(1,a-Date.now())),r.signal)}}}async function Oe(t,e){let r=await ge(t);if(null===r||r.record?.nonce!==e.nonce)return!1;try{return await R(t),!0}catch(t){if("ENOENT"===me(t))return!1;throw t}}async function ke(t,e,r,n){await Ne(t,e,n);try{return await r()}finally{await Oe(t,e)}}Promise.resolve();var Pe=[["\\bAKIA[0-9A-Z]{16}\\b",""],["\\b(?:bearer|token|api[_-]?key|secret|password|passwd|pwd)\\s*[=:]\\s*\\S{1,256}","i"],["\\bAuthorization\\s*:\\s*Bearer\\s+\\S{1,256}","i"],["\\bsk-(?:proj-)?[-_A-Za-z0-9]+\\b",""],["\\b(?:ghp|github_pat|glpat|xox[baprs])-[-_A-Za-z0-9]+\\b",""]];Pe.map(([t,e])=>new RegExp(t,e)),Pe.map(([t,e])=>new RegExp(t,`${e}g`));new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});import{dirname as Te}from"node:path";import{fileURLToPath as Re}from"node:url";Te(Re(import.meta.url));import{dirname as Me}from"node:path";import{fileURLToPath as Ae}from"node:url";Me(Ae(import.meta.url)),new Date(0).toISOString();var $e="\\p{Script=Hangul}\\p{Script=Han}\\p{Script=Hiragana}\\p{Script=Katakana}\\u30fc";new RegExp(`[${$e}]+|(?:(?![${$e}])[\\p{L}\\p{M}\\p{N}])+`,"gu"),new RegExp(`^[${$e}]+$`,"u"),new RegExp(`[${$e}]`,"u"),new RegExp(`[${$e}]`,"gu"),new RegExp(`[\\p{L}${$e}]`,"gu");import{dirname as Le}from"node:path";import{fileURLToPath as Ce}from"node:url";Le(Ce(import.meta.url));function De(t){return Xt(t,"terminal-claim.json")}function Ue(t,e,r){return t.runId===e.runId&&t.attempt===e.attempt&&(void 0===r||t.kind===r)}function qe(t,e){let r=`${t}.${process.pid}.${Kt()}.candidate`;!function(t,e){let r=K(t,"wx",384);try{J(r,`${JSON.stringify(e,null,2)}\n`,"utf8"),$(r)}finally{z(r)}}(r,e);try{L(r,t)}catch(t){if("EEXIST"===Ge(t))return!1;throw t}finally{He(r)}return function(t){let e;try{e=K(t,"r")}catch(t){if("win32"===process.platform&&["EISDIR","EPERM"].includes(Ge(t)??""))return;throw t}try{$(e)}catch(t){if("win32"!==process.platform||!["EPERM","EACCES","EINVAL"].includes(Ge(t)??""))throw t}finally{z(e)}}(zt(t)),!0}function je(t){let e;try{e=U(t,"utf8")}catch(t){if("ENOENT"===Ge(t))return;throw t}try{return{raw:e,claim:Be(JSON.parse(e))}}catch{return{raw:e,claim:void 0}}}async function Fe(t,e,r,n,i,o){let a=await fe("reflection-finalize",{runId:i.runId});return ke(Xt(t,"terminal-claim-recovery.lock"),a,async()=>{let t=je(e);if(void 0!==t){if(t.raw!==r.raw)return t.claim;if("invalid"===n){if(void 0!==t.claim)return t.claim}else{if(void 0===t.claim)return;if("publish"!==t.claim.kind||!Je(t.claim,o))return t.claim}He(e)}},{waitTimeoutMs:Number.POSITIVE_INFINITY})}function He(t){try{H(t)}catch(t){if("ENOENT"!==Ge(t))throw t}}function Je(t,e){return"dead"===(e.getPidLiveness??wt)(t.claimantPid)}function Be(t){if(!function(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)}(t)||1!==t.version||"publish"!==t.kind&&"abandon"!==t.kind||"string"!=typeof t.runId||!Number.isInteger(t.attempt)||!Number.isInteger(t.claimantPid)||Number(t.claimantPid)<=0)throw TypeError("Invalid run terminal claim");return{version:1,kind:t.kind,runId:t.runId,attempt:Number(t.attempt),claimantPid:Number(t.claimantPid)}}function Ge(t){return t instanceof Error&&"code"in t?String(t.code):void 0}import{join as Ve}from"node:path";async function Ye(t,e,r){let n={runId:e.runId,attempt:e.attempt??1},i=await async function(t,e,r,n={},i=process.pid){let o=De(t),a={version:1,kind:r,runId:e.runId,attempt:e.attempt,claimantPid:i},s=0;for(;;){if(qe(o,a))return a;let i=je(o);if(void 0===i)continue;let l=i.claim;if(void 0===l){if(s>0)throw TypeError("Invalid run terminal claim");s+=1,await(n.beforeRecovery?.("invalid"));let r=await Fe(t,o,i,"invalid",e,n);if(void 0!==r)return r;continue}if(Ue(l,e,r))return l;if("publish"!==l.kind||!Je(l,n))return l;await(n.beforeRecovery?.("dead-publish"));let c=await Fe(t,o,i,"dead-publish",e,n);if(void 0!==c)return c}}(t,n,"publish");Ue(i,n,"publish")&&(await rt(Pt(t,"publishing.json"),{version:1,...n,finishedAt:r.finishedAt}),await async function(t,e,r,n=ke,i=fe){let o=await i("reflection-finalize",{runId:e});return n(Ve(t,"terminalization.lock"),o,r,{waitTimeoutMs:Number.POSITIVE_INFINITY})}(t,e.runId,async()=>{if(X(Pt(t,"final.json"))||X(Pt(t,"abandoned.json")))return;if(!Ue(function(t){return Be(JSON.parse(U(De(t),"utf8")))}(t),n,"publish"))return;let i=void 0!==Yt({code:r.childExit.code,stdout:U(e.stdoutPath,"utf8"),stderr:U(e.stderrPath,"utf8"),timedOut:r.timedOut});i&&void 0!==e.nextAttempt&&await nt(Pt(t,"ledger.json"),{attempt:e.nextAttempt.attempt,model:e.nextAttempt.model,...void 0===e.nextAttempt.thinking?{thinking:void 0}:{thinking:e.nextAttempt.thinking},launching:!0,pid:void 0,processStart:void 0,childPid:void 0,childProcessStart:void 0}),await rt(Pt(t,"outcome.json"),r),i&&await it(De(t))}))}function Ke(t){try{B(3,`${JSON.stringify(t)}\n`)}catch(t){if(!(t instanceof Error&&"code"in t&&["EPIPE","EBADF"].includes(String(t.code))))throw t}}var ze=process.argv.slice(2);try{if("--child-bootstrap"===ze[0]){if(void 0===ze[1])throw TypeError("run directory is required");await async function(e){if(!await async function(){for await(let t of process.stdin)if(Buffer.byteLength(t)>0)return!0;return!1}())return;let r=await et(Z(e,"launch.json")),n=yt(),i=t(r.command,[...r.args],{cwd:r.cwd,env:r.env,detached:!1,stdio:["ignore","inherit","inherit"],windowsHide:!0});Ke({code:i.pid??null,signal:"MODEL_PID"});let o=()=>{"win32"!==n&&"win32"!==process.platform||i.kill()};process.on("SIGTERM",o),process.on("SIGINT",o);let a=gt(r.hardDeadlineAt,()=>{"win32"===n?Nt(n,i):xt(process.pid,"SIGTERM")}),s=gt(r.hardDeadlineAt+r.terminationGraceMs,()=>{Ot(n,process.pid)});Ke(await new Promise(t=>{let e=!1;i.once("error",()=>{e||(e=!0,t({code:null,signal:null}))}),i.once("close",(r,n)=>{e||(e=!0,t({code:r,signal:n}))})}).finally(()=>{a(),s()}))}(ze[1])}else{if(void 0===ze[0])throw TypeError("run directory is required");await async function(e){let r=Z(e,"launch.json"),n=Z(e,"ledger.json"),i=await et(r),o=yt();await nt(n,{launching:!1,pid:process.pid,processStart:await kt(process.pid)});let a,s=K(i.stdoutPath,"w"),l=K(i.stderrPath,"w"),c=t(process.execPath,[W(import.meta.url),"--child-bootstrap",e],{env:process.env,detached:!0,stdio:["pipe",s,l,"pipe"],windowsHide:!0}),u=c.pid,d="",f=c.stdio[3];null!=f&&"setEncoding"in f&&(f.setEncoding("utf8"),f.on("data",t=>{d+=t;for(let t of d.split("\n"))try{let e=JSON.parse(t);"MODEL_PID"===e.signal&&"number"==typeof e.code&&(a=e.code)}catch(t){if(!(t instanceof SyntaxError))throw t}}));let p=(t=!1)=>{try{Ot(o,u,t)}catch(t){process.stderr.write(`${t instanceof Error?t.message:String(t)}\n`)}};if(process.once("exit",()=>p(!0)),process.once("SIGTERM",()=>{p(),u=void 0,process.exit(143)}),process.once("SIGINT",()=>{p(),u=void 0,process.exit(130)}),void 0===c.pid)throw Error("child bootstrap did not receive a pid");await nt(n,{childPid:c.pid,childProcessStart:await kt(c.pid)}),c.stdin?.end("1\n");let m,w=!1,h=Promise.resolve();"win32"===o&&(h=new Promise(t=>{m=t}));let y=gt(i.hardDeadlineAt,()=>{w=!0,"win32"===o?It(c.pid):Nt(o,c)}),g=gt(i.hardDeadlineAt+i.terminationGraceMs,()=>{Ot(o,a??u),m?.()}),v=await new Promise((t,e)=>{let r=!1;c.once("error",t=>{r||(r=!0,e(t))}),c.once("close",(e,n)=>{r||(r=!0,t({code:e,signal:n}))})}),b=function(t){let e=t.trim().split("\n").at(-1);if(void 0!==e&&0!==e.length)try{let t=JSON.parse(e),r="number"==typeof t.code||null===t.code?t.code:void 0,n="string"==typeof t.signal||null===t.signal?t.signal:void 0;return void 0===r||void 0===n||"MODEL_PID"===n?void 0:{code:r,signal:n}}catch{return}}(d);"win32"===o&&w&&void 0===b&&await h,y(),g(),u=void 0,z(s),z(l);let E=function(){let t=ht()?process.env.OMO_MEMORY_SUPERVISOR_CLOCK_PATH:void 0;return void 0===t?Date.now():bt(t)}(),S=(new Date).toISOString(),_={version:1,runId:i.runId,attempt:i.attempt,finishedAt:S,childExit:b??v,timedOut:w||Number.isFinite(E)&&E>=i.hardDeadlineAt};await Ye(e,i,_),await it(r),process.exit(0)}(ze[0])}}catch(t){process.stderr.write(`${t instanceof Error?t.stack??t.message:String(t)}\n`),process.exitCode=1}