@omnicross/cli-launcher 0.1.10 → 0.2.1

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.
package/dist/index.js CHANGED
@@ -1,9 +1,3 @@
1
- import {
2
- __toCommonJS,
3
- init_pty_adapter,
4
- pty_adapter_exports
5
- } from "./chunk-K7IZD73K.js";
6
-
7
1
  // src/supervisor.ts
8
2
  import { randomUUID } from "crypto";
9
3
  import { serializeError } from "@omnicross/core/serializeError";
@@ -83,6 +77,7 @@ function killTreeUnix(pid, graceMs) {
83
77
  // src/child-adapter.ts
84
78
  var TAG2 = "[ProcessSupervisor]";
85
79
  var IS_WIN2 = process.platform === "win32";
80
+ var PREBUFFER_CHUNK_LIMIT = 512;
86
81
  function createChildAdapter(input) {
87
82
  const [command, ...args] = input.argv;
88
83
  if (!command) {
@@ -97,6 +92,8 @@ function createChildAdapter(input) {
97
92
  detached: !IS_WIN2
98
93
  };
99
94
  const child = cpSpawn2(command, args, opts);
95
+ const stdoutPump = pump(child.stdout);
96
+ const stderrPump = pump(child.stderr);
100
97
  const stdinMode = input.stdinMode ?? (input.input ? "pipe-closed" : "pipe-open");
101
98
  if (input.input && child.stdin) {
102
99
  child.stdin.write(input.input, () => {
@@ -111,12 +108,10 @@ function createChildAdapter(input) {
111
108
  return {
112
109
  pid: child.pid,
113
110
  onStdout(cb) {
114
- child.stdout?.setEncoding("utf8");
115
- child.stdout?.on("data", cb);
111
+ stdoutPump.subscribe(cb);
116
112
  },
117
113
  onStderr(cb) {
118
- child.stderr?.setEncoding("utf8");
119
- child.stderr?.on("data", cb);
114
+ stderrPump.subscribe(cb);
120
115
  },
121
116
  wait() {
122
117
  return new Promise((resolve) => {
@@ -145,12 +140,125 @@ function createChildAdapter(input) {
145
140
  dispose() {
146
141
  if (disposed) return;
147
142
  disposed = true;
143
+ stdoutPump.dispose();
144
+ stderrPump.dispose();
148
145
  child.stdout?.removeAllListeners();
149
146
  child.stderr?.removeAllListeners();
150
147
  child.removeAllListeners();
151
148
  }
152
149
  };
153
150
  }
151
+ function pump(stream) {
152
+ const buffered = [];
153
+ let subscriber = null;
154
+ if (!stream) {
155
+ return { subscribe: () => {
156
+ }, dispose: () => {
157
+ } };
158
+ }
159
+ stream.setEncoding("utf8");
160
+ const onData = (chunk) => {
161
+ if (subscriber) {
162
+ subscriber(chunk);
163
+ return;
164
+ }
165
+ if (buffered.length >= PREBUFFER_CHUNK_LIMIT) buffered.shift();
166
+ buffered.push(chunk);
167
+ };
168
+ stream.on("data", onData);
169
+ return {
170
+ subscribe(cb) {
171
+ subscriber = cb;
172
+ const replay = buffered.splice(0, buffered.length);
173
+ for (const chunk of replay) cb(chunk);
174
+ },
175
+ dispose() {
176
+ subscriber = null;
177
+ buffered.length = 0;
178
+ stream.off("data", onData);
179
+ stream.resume();
180
+ }
181
+ };
182
+ }
183
+
184
+ // src/pty-adapter.ts
185
+ import { createRequire } from "module";
186
+ import { isAbsolute } from "path";
187
+ var requireFromThisModule = createRequire(
188
+ typeof __filename === "string" && isAbsolute(__filename) ? __filename : import.meta.url
189
+ );
190
+ function buildPtyEnv(overlay) {
191
+ return overlay ? { ...process.env, ...overlay } : { ...process.env };
192
+ }
193
+ function createPtyAdapter(input) {
194
+ const nodePty = requireFromThisModule("node-pty");
195
+ const shell = input.shell ?? (process.platform === "win32" ? "powershell.exe" : "/bin/bash");
196
+ const pty = nodePty.spawn(shell, input.args ?? [], {
197
+ name: "xterm-256color",
198
+ cols: input.cols ?? 120,
199
+ rows: input.rows ?? 30,
200
+ cwd: input.cwd,
201
+ env: buildPtyEnv(input.env)
202
+ });
203
+ const stdoutListeners = [];
204
+ const stderrListeners = [];
205
+ const dataDisposable = pty.onData((data) => {
206
+ for (const cb of stdoutListeners) cb(data);
207
+ });
208
+ let exitResolve = null;
209
+ const exitPromise = new Promise((resolve) => {
210
+ exitResolve = resolve;
211
+ });
212
+ const exitDisposable = pty.onExit(({ exitCode, signal }) => {
213
+ exitResolve?.({ code: exitCode, signal: signal != null ? String(signal) : null });
214
+ });
215
+ let disposed = false;
216
+ return {
217
+ pid: pty.pid,
218
+ onStdout(cb) {
219
+ stdoutListeners.push(cb);
220
+ },
221
+ onStderr(cb) {
222
+ stderrListeners.push(cb);
223
+ },
224
+ stdin: {
225
+ write(data) {
226
+ if (!disposed) pty.write(data);
227
+ },
228
+ end() {
229
+ if (!disposed) pty.write("");
230
+ },
231
+ destroy() {
232
+ }
233
+ },
234
+ write(data) {
235
+ if (!disposed) pty.write(data);
236
+ },
237
+ resize(cols, rows) {
238
+ if (!disposed) pty.resize(cols, rows);
239
+ },
240
+ wait() {
241
+ return exitPromise;
242
+ },
243
+ kill(signal) {
244
+ if (disposed) return;
245
+ try {
246
+ pty.kill(signal);
247
+ } catch {
248
+ }
249
+ },
250
+ dispose() {
251
+ if (disposed) return;
252
+ disposed = true;
253
+ dataDisposable.dispose();
254
+ exitDisposable.dispose();
255
+ try {
256
+ pty.kill();
257
+ } catch {
258
+ }
259
+ }
260
+ };
261
+ }
154
262
 
155
263
  // src/run-registry.ts
156
264
  var MAX_EXITED = 500;
@@ -259,7 +367,6 @@ function createProcessSupervisor() {
259
367
  let adapter;
260
368
  try {
261
369
  if (input.mode === "pty") {
262
- const { createPtyAdapter } = (init_pty_adapter(), __toCommonJS(pty_adapter_exports));
263
370
  adapter = createPtyAdapter(input);
264
371
  } else {
265
372
  adapter = createChildAdapter(input);
@@ -649,6 +756,7 @@ import {
649
756
  } from "@omnicross/core/provider-proxy";
650
757
  var CODEX_PROXY_PROVIDER_NAME = "omnicross";
651
758
  var CODEX_PROXY_BASE_PATH = "/openai";
759
+ var CODEX_IMAGE_GENERATION_CAPABILITY_MARKER = "omnicross";
652
760
  function buildCodexConfigOverrides(baseUrl) {
653
761
  const name = CODEX_PROXY_PROVIDER_NAME;
654
762
  const providerBaseUrl = `${baseUrl}${CODEX_PROXY_BASE_PATH}`;
@@ -663,6 +771,8 @@ function buildCodexConfigOverrides(baseUrl) {
663
771
  `model_providers.${name}.wire_api="responses"`,
664
772
  "-c",
665
773
  `model_providers.${name}.env_key="${ROUTE_LEASE_CODEX_TOKEN_ENV}"`,
774
+ "-c",
775
+ `model_providers.${name}.http_headers={"X-OpenAI-Actor-Authorization"="${CODEX_IMAGE_GENERATION_CAPABILITY_MARKER}"}`,
666
776
  // disable_response_storage: the CLI sends full context each turn (no
667
777
  // server-side response store) — required because the proxy upstream is
668
778
  // stateless w.r.t. Codex's response-id store (design Q3 contract).
@@ -1,10 +1,109 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
-
4
-
5
- var _chunkHNYCLVZPcjs = require('./chunk-HNYCLVZP.cjs');
6
- _chunkHNYCLVZPcjs.init_pty_adapter.call(void 0, );
7
-
8
-
9
-
10
- exports.buildPtyEnv = _chunkHNYCLVZPcjs.buildPtyEnv; exports.createPtyAdapter = _chunkHNYCLVZPcjs.createPtyAdapter;
20
+ // src/pty-adapter.ts
21
+ var pty_adapter_exports = {};
22
+ __export(pty_adapter_exports, {
23
+ buildPtyEnv: () => buildPtyEnv,
24
+ createPtyAdapter: () => createPtyAdapter
25
+ });
26
+ module.exports = __toCommonJS(pty_adapter_exports);
27
+ var import_node_module = require("module");
28
+ var import_node_path = require("path");
29
+ var import_meta = {};
30
+ var requireFromThisModule = (0, import_node_module.createRequire)(
31
+ typeof __filename === "string" && (0, import_node_path.isAbsolute)(__filename) ? __filename : import_meta.url
32
+ );
33
+ function buildPtyEnv(overlay) {
34
+ return overlay ? { ...process.env, ...overlay } : { ...process.env };
35
+ }
36
+ function createPtyAdapter(input) {
37
+ const nodePty = requireFromThisModule("node-pty");
38
+ const shell = input.shell ?? (process.platform === "win32" ? "powershell.exe" : "/bin/bash");
39
+ const pty = nodePty.spawn(shell, input.args ?? [], {
40
+ name: "xterm-256color",
41
+ cols: input.cols ?? 120,
42
+ rows: input.rows ?? 30,
43
+ cwd: input.cwd,
44
+ env: buildPtyEnv(input.env)
45
+ });
46
+ const stdoutListeners = [];
47
+ const stderrListeners = [];
48
+ const dataDisposable = pty.onData((data) => {
49
+ for (const cb of stdoutListeners) cb(data);
50
+ });
51
+ let exitResolve = null;
52
+ const exitPromise = new Promise((resolve) => {
53
+ exitResolve = resolve;
54
+ });
55
+ const exitDisposable = pty.onExit(({ exitCode, signal }) => {
56
+ exitResolve?.({ code: exitCode, signal: signal != null ? String(signal) : null });
57
+ });
58
+ let disposed = false;
59
+ return {
60
+ pid: pty.pid,
61
+ onStdout(cb) {
62
+ stdoutListeners.push(cb);
63
+ },
64
+ onStderr(cb) {
65
+ stderrListeners.push(cb);
66
+ },
67
+ stdin: {
68
+ write(data) {
69
+ if (!disposed) pty.write(data);
70
+ },
71
+ end() {
72
+ if (!disposed) pty.write("");
73
+ },
74
+ destroy() {
75
+ }
76
+ },
77
+ write(data) {
78
+ if (!disposed) pty.write(data);
79
+ },
80
+ resize(cols, rows) {
81
+ if (!disposed) pty.resize(cols, rows);
82
+ },
83
+ wait() {
84
+ return exitPromise;
85
+ },
86
+ kill(signal) {
87
+ if (disposed) return;
88
+ try {
89
+ pty.kill(signal);
90
+ } catch {
91
+ }
92
+ },
93
+ dispose() {
94
+ if (disposed) return;
95
+ disposed = true;
96
+ dataDisposable.dispose();
97
+ exitDisposable.dispose();
98
+ try {
99
+ pty.kill();
100
+ } catch {
101
+ }
102
+ }
103
+ };
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ buildPtyEnv,
108
+ createPtyAdapter
109
+ });
@@ -1,9 +1,81 @@
1
- import {
2
- buildPtyEnv,
3
- createPtyAdapter,
4
- init_pty_adapter
5
- } from "./chunk-K7IZD73K.js";
6
- init_pty_adapter();
1
+ // src/pty-adapter.ts
2
+ import { createRequire } from "module";
3
+ import { isAbsolute } from "path";
4
+ var requireFromThisModule = createRequire(
5
+ typeof __filename === "string" && isAbsolute(__filename) ? __filename : import.meta.url
6
+ );
7
+ function buildPtyEnv(overlay) {
8
+ return overlay ? { ...process.env, ...overlay } : { ...process.env };
9
+ }
10
+ function createPtyAdapter(input) {
11
+ const nodePty = requireFromThisModule("node-pty");
12
+ const shell = input.shell ?? (process.platform === "win32" ? "powershell.exe" : "/bin/bash");
13
+ const pty = nodePty.spawn(shell, input.args ?? [], {
14
+ name: "xterm-256color",
15
+ cols: input.cols ?? 120,
16
+ rows: input.rows ?? 30,
17
+ cwd: input.cwd,
18
+ env: buildPtyEnv(input.env)
19
+ });
20
+ const stdoutListeners = [];
21
+ const stderrListeners = [];
22
+ const dataDisposable = pty.onData((data) => {
23
+ for (const cb of stdoutListeners) cb(data);
24
+ });
25
+ let exitResolve = null;
26
+ const exitPromise = new Promise((resolve) => {
27
+ exitResolve = resolve;
28
+ });
29
+ const exitDisposable = pty.onExit(({ exitCode, signal }) => {
30
+ exitResolve?.({ code: exitCode, signal: signal != null ? String(signal) : null });
31
+ });
32
+ let disposed = false;
33
+ return {
34
+ pid: pty.pid,
35
+ onStdout(cb) {
36
+ stdoutListeners.push(cb);
37
+ },
38
+ onStderr(cb) {
39
+ stderrListeners.push(cb);
40
+ },
41
+ stdin: {
42
+ write(data) {
43
+ if (!disposed) pty.write(data);
44
+ },
45
+ end() {
46
+ if (!disposed) pty.write("");
47
+ },
48
+ destroy() {
49
+ }
50
+ },
51
+ write(data) {
52
+ if (!disposed) pty.write(data);
53
+ },
54
+ resize(cols, rows) {
55
+ if (!disposed) pty.resize(cols, rows);
56
+ },
57
+ wait() {
58
+ return exitPromise;
59
+ },
60
+ kill(signal) {
61
+ if (disposed) return;
62
+ try {
63
+ pty.kill(signal);
64
+ } catch {
65
+ }
66
+ },
67
+ dispose() {
68
+ if (disposed) return;
69
+ disposed = true;
70
+ dataDisposable.dispose();
71
+ exitDisposable.dispose();
72
+ try {
73
+ pty.kill();
74
+ } catch {
75
+ }
76
+ }
77
+ };
78
+ }
7
79
  export {
8
80
  buildPtyEnv,
9
81
  createPtyAdapter
package/dist/types.cjs CHANGED
@@ -1 +1,18 @@
1
- "use strict";
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
package/package.json CHANGED
@@ -1,58 +1,59 @@
1
- {
2
- "name": "@omnicross/cli-launcher",
3
- "version": "0.1.10",
4
- "description": "Omnicross CLI-launcher — the ProcessSupervisor subprocess-lifecycle mechanism + per-CLI proxy-env wiring.",
5
- "license": "MIT",
6
- "author": "Sayo (https://github.com/Dumoedss)",
7
- "homepage": "https://github.com/Dumoedss/omnicross#readme",
8
- "keywords": [
9
- "omnicross",
10
- "cli",
11
- "process-supervisor",
12
- "subprocess",
13
- "proxy"
14
- ],
15
- "repository": {
16
- "type": "git",
17
- "url": "git+https://github.com/Dumoedss/omnicross.git",
18
- "directory": "packages/cli-launcher"
19
- },
20
- "publishConfig": {
21
- "access": "public"
22
- },
23
- "engines": {
24
- "node": ">=20"
25
- },
26
- "type": "module",
27
- "main": "dist/index.cjs",
28
- "module": "dist/index.js",
29
- "types": "dist/index.d.ts",
30
- "exports": {
31
- ".": {
32
- "types": "./dist/index.d.ts",
33
- "import": "./dist/index.js",
34
- "require": "./dist/index.cjs"
35
- },
36
- "./*": {
37
- "types": "./dist/*.d.ts",
38
- "import": "./dist/*.js",
39
- "require": "./dist/*.cjs"
40
- }
41
- },
42
- "files": [
43
- "dist",
44
- "LICENSE",
45
- "NOTICE",
46
- "README.md"
47
- ],
48
- "scripts": {
49
- "build": "tsup",
50
- "typecheck": "tsc -p tsconfig.typecheck.json --noEmit"
51
- },
52
- "dependencies": {
53
- "@omnicross/core": "^0.1.0"
54
- },
55
- "optionalDependencies": {
56
- "node-pty": "npm:@karinjs/node-pty@^1.1.3"
57
- }
58
- }
1
+ {
2
+ "name": "@omnicross/cli-launcher",
3
+ "version": "0.2.1",
4
+ "description": "Omnicross CLI-launcher — the ProcessSupervisor subprocess-lifecycle mechanism + per-CLI proxy-env wiring.",
5
+ "license": "MIT",
6
+ "author": "Sayo (https://github.com/Dumoedss)",
7
+ "homepage": "https://github.com/Dumoedss/omnicross#readme",
8
+ "keywords": [
9
+ "omnicross",
10
+ "cli",
11
+ "process-supervisor",
12
+ "subprocess",
13
+ "proxy"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/DumoeDss/omnicross",
18
+ "directory": "packages/cli-launcher"
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "type": "module",
27
+ "main": "dist/index.cjs",
28
+ "module": "dist/index.js",
29
+ "types": "dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.cjs"
35
+ },
36
+ "./*": {
37
+ "types": "./dist/*.d.ts",
38
+ "import": "./dist/*.js",
39
+ "require": "./dist/*.cjs"
40
+ }
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "LICENSE",
45
+ "NOTICE",
46
+ "README.md"
47
+ ],
48
+ "scripts": {
49
+ "build": "tsup",
50
+ "postbuild": "node scripts/smoke-dist.cjs",
51
+ "typecheck": "tsc -p tsconfig.typecheck.json --noEmit"
52
+ },
53
+ "dependencies": {
54
+ "@omnicross/core": "^0.2.1"
55
+ },
56
+ "optionalDependencies": {
57
+ "node-pty": "npm:@karinjs/node-pty@^1.1.3"
58
+ }
59
+ }