@cpajs/cpa 0.0.0-stage → 0.0.1-alpha-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +142 -2
  3. package/dist/client/errors.d.ts +70 -0
  4. package/dist/client/errors.d.ts.map +1 -0
  5. package/dist/client/errors.js +91 -0
  6. package/dist/client/errors.js.map +1 -0
  7. package/dist/client/index.d.ts +46 -0
  8. package/dist/client/index.d.ts.map +1 -0
  9. package/dist/client/index.js +65 -0
  10. package/dist/client/index.js.map +1 -0
  11. package/dist/client/resources/config.d.ts +61 -0
  12. package/dist/client/resources/config.d.ts.map +1 -0
  13. package/dist/client/resources/config.js +80 -0
  14. package/dist/client/resources/config.js.map +1 -0
  15. package/dist/client/resources/credentials.d.ts +64 -0
  16. package/dist/client/resources/credentials.d.ts.map +1 -0
  17. package/dist/client/resources/credentials.js +94 -0
  18. package/dist/client/resources/credentials.js.map +1 -0
  19. package/dist/client/resources/download.d.ts +8 -0
  20. package/dist/client/resources/download.d.ts.map +1 -0
  21. package/dist/client/resources/download.js +17 -0
  22. package/dist/client/resources/download.js.map +1 -0
  23. package/dist/client/resources/logs.d.ts +23 -0
  24. package/dist/client/resources/logs.d.ts.map +1 -0
  25. package/dist/client/resources/logs.js +37 -0
  26. package/dist/client/resources/logs.js.map +1 -0
  27. package/dist/client/resources/oauth.d.ts +43 -0
  28. package/dist/client/resources/oauth.d.ts.map +1 -0
  29. package/dist/client/resources/oauth.js +70 -0
  30. package/dist/client/resources/oauth.js.map +1 -0
  31. package/dist/client/resources/plugins.d.ts +25 -0
  32. package/dist/client/resources/plugins.d.ts.map +1 -0
  33. package/dist/client/resources/plugins.js +47 -0
  34. package/dist/client/resources/plugins.js.map +1 -0
  35. package/dist/client/resources/requests.d.ts +14 -0
  36. package/dist/client/resources/requests.d.ts.map +1 -0
  37. package/dist/client/resources/requests.js +16 -0
  38. package/dist/client/resources/requests.js.map +1 -0
  39. package/dist/client/resources/routing.d.ts +12 -0
  40. package/dist/client/resources/routing.d.ts.map +1 -0
  41. package/dist/client/resources/routing.js +20 -0
  42. package/dist/client/resources/routing.js.map +1 -0
  43. package/dist/client/resources/server.d.ts +17 -0
  44. package/dist/client/resources/server.d.ts.map +1 -0
  45. package/dist/client/resources/server.js +49 -0
  46. package/dist/client/resources/server.js.map +1 -0
  47. package/dist/client/resources/usage.d.ts +16 -0
  48. package/dist/client/resources/usage.d.ts.map +1 -0
  49. package/dist/client/resources/usage.js +20 -0
  50. package/dist/client/resources/usage.js.map +1 -0
  51. package/dist/client/transport.d.ts +60 -0
  52. package/dist/client/transport.d.ts.map +1 -0
  53. package/dist/client/transport.js +170 -0
  54. package/dist/client/transport.js.map +1 -0
  55. package/dist/client/types/common.d.ts +38 -0
  56. package/dist/client/types/common.d.ts.map +1 -0
  57. package/dist/client/types/common.js +4 -0
  58. package/dist/client/types/common.js.map +1 -0
  59. package/dist/client/types/config.d.ts +407 -0
  60. package/dist/client/types/config.d.ts.map +1 -0
  61. package/dist/client/types/config.js +9 -0
  62. package/dist/client/types/config.js.map +1 -0
  63. package/dist/client/types/credentials.d.ts +240 -0
  64. package/dist/client/types/credentials.d.ts.map +1 -0
  65. package/dist/client/types/credentials.js +4 -0
  66. package/dist/client/types/credentials.js.map +1 -0
  67. package/dist/client/types/index.d.ts +10 -0
  68. package/dist/client/types/index.d.ts.map +1 -0
  69. package/dist/client/types/index.js +2 -0
  70. package/dist/client/types/index.js.map +1 -0
  71. package/dist/client/types/oauth.d.ts +89 -0
  72. package/dist/client/types/oauth.d.ts.map +1 -0
  73. package/dist/client/types/oauth.js +4 -0
  74. package/dist/client/types/oauth.js.map +1 -0
  75. package/dist/client/types/observability.d.ts +111 -0
  76. package/dist/client/types/observability.d.ts.map +1 -0
  77. package/dist/client/types/observability.js +4 -0
  78. package/dist/client/types/observability.js.map +1 -0
  79. package/dist/client/types/plugins.d.ts +171 -0
  80. package/dist/client/types/plugins.d.ts.map +1 -0
  81. package/dist/client/types/plugins.js +4 -0
  82. package/dist/client/types/plugins.js.map +1 -0
  83. package/dist/client/types/requests.d.ts +16 -0
  84. package/dist/client/types/requests.d.ts.map +1 -0
  85. package/dist/client/types/requests.js +4 -0
  86. package/dist/client/types/requests.js.map +1 -0
  87. package/dist/client/types/routing.d.ts +50 -0
  88. package/dist/client/types/routing.d.ts.map +1 -0
  89. package/dist/client/types/routing.js +4 -0
  90. package/dist/client/types/routing.js.map +1 -0
  91. package/dist/client/types/server.d.ts +15 -0
  92. package/dist/client/types/server.d.ts.map +1 -0
  93. package/dist/client/types/server.js +4 -0
  94. package/dist/client/types/server.js.map +1 -0
  95. package/dist/index.d.ts +3 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +3 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/server/binary.d.ts +35 -0
  100. package/dist/server/binary.d.ts.map +1 -0
  101. package/dist/server/binary.js +108 -0
  102. package/dist/server/binary.js.map +1 -0
  103. package/dist/server/config.d.ts +37 -0
  104. package/dist/server/config.d.ts.map +1 -0
  105. package/dist/server/config.js +103 -0
  106. package/dist/server/config.js.map +1 -0
  107. package/dist/server/cpa-version.d.ts +12 -0
  108. package/dist/server/cpa-version.d.ts.map +1 -0
  109. package/dist/server/cpa-version.js +12 -0
  110. package/dist/server/cpa-version.js.map +1 -0
  111. package/dist/server/errors.d.ts +36 -0
  112. package/dist/server/errors.d.ts.map +1 -0
  113. package/dist/server/errors.js +26 -0
  114. package/dist/server/errors.js.map +1 -0
  115. package/dist/server/index.d.ts +18 -0
  116. package/dist/server/index.d.ts.map +1 -0
  117. package/dist/server/index.js +208 -0
  118. package/dist/server/index.js.map +1 -0
  119. package/dist/server/process.d.ts +27 -0
  120. package/dist/server/process.d.ts.map +1 -0
  121. package/dist/server/process.js +114 -0
  122. package/dist/server/process.js.map +1 -0
  123. package/dist/server/readiness.d.ts +13 -0
  124. package/dist/server/readiness.d.ts.map +1 -0
  125. package/dist/server/readiness.js +56 -0
  126. package/dist/server/readiness.js.map +1 -0
  127. package/dist/server/redact.d.ts +3 -0
  128. package/dist/server/redact.d.ts.map +1 -0
  129. package/dist/server/redact.js +16 -0
  130. package/dist/server/redact.js.map +1 -0
  131. package/dist/server/targets.d.ts +48 -0
  132. package/dist/server/targets.d.ts.map +1 -0
  133. package/dist/server/targets.js +90 -0
  134. package/dist/server/targets.js.map +1 -0
  135. package/dist/server/types.d.ts +87 -0
  136. package/dist/server/types.d.ts.map +1 -0
  137. package/dist/server/types.js +2 -0
  138. package/dist/server/types.js.map +1 -0
  139. package/package.json +83 -4
  140. package/src/client/errors.ts +104 -0
  141. package/src/client/index.ts +95 -0
  142. package/src/client/resources/config.ts +124 -0
  143. package/src/client/resources/credentials.ts +133 -0
  144. package/src/client/resources/download.ts +21 -0
  145. package/src/client/resources/logs.ts +46 -0
  146. package/src/client/resources/oauth.ts +105 -0
  147. package/src/client/resources/plugins.ts +70 -0
  148. package/src/client/resources/requests.ts +20 -0
  149. package/src/client/resources/routing.ts +29 -0
  150. package/src/client/resources/server.ts +52 -0
  151. package/src/client/resources/usage.ts +27 -0
  152. package/src/client/transport.ts +215 -0
  153. package/src/client/types/common.ts +38 -0
  154. package/src/client/types/config.ts +248 -0
  155. package/src/client/types/credentials.ts +195 -0
  156. package/src/client/types/index.ts +9 -0
  157. package/src/client/types/oauth.ts +71 -0
  158. package/src/client/types/observability.ts +93 -0
  159. package/src/client/types/plugins.ts +136 -0
  160. package/src/client/types/requests.ts +19 -0
  161. package/src/client/types/routing.ts +44 -0
  162. package/src/client/types/server.ts +18 -0
  163. package/src/index.ts +2 -0
  164. package/src/server/binary.ts +128 -0
  165. package/src/server/config.ts +128 -0
  166. package/src/server/cpa-version.ts +11 -0
  167. package/src/server/errors.ts +48 -0
  168. package/src/server/index.ts +236 -0
  169. package/src/server/process.ts +124 -0
  170. package/src/server/readiness.ts +58 -0
  171. package/src/server/redact.ts +14 -0
  172. package/src/server/targets.ts +133 -0
  173. package/src/server/types.ts +93 -0
@@ -0,0 +1,27 @@
1
+ import { type ChildProcess } from 'node:child_process';
2
+ import type { ExitResult, LogLine } from './types.ts';
3
+ export interface SpawnOptions {
4
+ cwd: string;
5
+ env: NodeJS.ProcessEnv;
6
+ redact: (text: string) => string;
7
+ onLog?: ((log: LogLine) => void) | undefined;
8
+ }
9
+ /** A spawned CPA process with line-buffered, redacted output and idempotent stop. */
10
+ export declare class ManagedProcess {
11
+ #private;
12
+ readonly child: ChildProcess;
13
+ readonly exited: Promise<ExitResult>;
14
+ readonly recentLogs: LogLine[];
15
+ /** Set when the process could not be spawned at all. */
16
+ spawnError: Error | undefined;
17
+ exitResult: ExitResult | undefined;
18
+ constructor(binaryPath: string, args: readonly string[], options: SpawnOptions);
19
+ onLine(listener: (log: LogLine) => void): () => void;
20
+ output(): string;
21
+ /**
22
+ * Sends SIGTERM and waits up to `timeoutMs` before SIGKILL. On Windows Node
23
+ * can only terminate the process forcefully, so both steps are immediate.
24
+ */
25
+ stop(timeoutMs: number): Promise<ExitResult>;
26
+ }
27
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/server/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAgBtD,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACjC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAC9C;AAED,qFAAqF;AACrF,qBAAa,cAAc;;IACzB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,OAAO,EAAE,CAAM;IACpC,wDAAwD;IACxD,UAAU,EAAE,KAAK,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;IAOnC,YAAY,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,EAsB7E;IAkCD,MAAM,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI,CAGnD;IAED,MAAM,IAAI,MAAM,CAEf;IAED;;;OAGG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAc3C;CACF"}
@@ -0,0 +1,114 @@
1
+ import { spawn } from 'node:child_process';
2
+ const MAX_RECENT_LINES = 200;
3
+ // Children still running when the parent exits are killed so they never outlive it.
4
+ const live = new Set();
5
+ let exitHookInstalled = false;
6
+ function trackChild(child) {
7
+ live.add(child);
8
+ if (exitHookInstalled)
9
+ return;
10
+ exitHookInstalled = true;
11
+ process.once('exit', () => {
12
+ for (const c of live)
13
+ c.kill('SIGKILL');
14
+ });
15
+ }
16
+ /** A spawned CPA process with line-buffered, redacted output and idempotent stop. */
17
+ export class ManagedProcess {
18
+ child;
19
+ exited;
20
+ recentLogs = [];
21
+ /** Set when the process could not be spawned at all. */
22
+ spawnError;
23
+ exitResult;
24
+ #redact;
25
+ #onLog;
26
+ #lineListeners = new Set();
27
+ #stopping;
28
+ constructor(binaryPath, args, options) {
29
+ this.#redact = options.redact;
30
+ this.#onLog = options.onLog;
31
+ this.child = spawn(binaryPath, [...args], {
32
+ cwd: options.cwd,
33
+ env: options.env,
34
+ stdio: ['ignore', 'pipe', 'pipe'],
35
+ windowsHide: true,
36
+ });
37
+ trackChild(this.child);
38
+ this.exited = new Promise((resolve) => {
39
+ this.child.once('error', (error) => {
40
+ this.spawnError = error;
41
+ // 'exit' is not emitted when spawning fails.
42
+ if (this.child.pid === undefined)
43
+ this.#finish(resolve, { code: null, signal: null });
44
+ });
45
+ this.child.once('close', (code, signal) => this.#finish(resolve, { code, signal }));
46
+ });
47
+ this.#pipe(this.child.stdout, 'stdout');
48
+ this.#pipe(this.child.stderr, 'stderr');
49
+ }
50
+ #finish(resolve, result) {
51
+ if (this.exitResult)
52
+ return;
53
+ this.exitResult = result;
54
+ live.delete(this.child);
55
+ resolve(result);
56
+ }
57
+ #pipe(stream, name) {
58
+ if (!stream)
59
+ return;
60
+ stream.setEncoding('utf8');
61
+ let pending = '';
62
+ const emit = (raw) => {
63
+ const log = { stream: name, line: this.#redact(raw.replace(/\r$/, '')) };
64
+ this.recentLogs.push(log);
65
+ if (this.recentLogs.length > MAX_RECENT_LINES)
66
+ this.recentLogs.shift();
67
+ for (const listener of this.#lineListeners)
68
+ listener(log);
69
+ this.#onLog?.(log);
70
+ };
71
+ stream.on('data', (chunk) => {
72
+ pending += chunk;
73
+ let index;
74
+ while ((index = pending.indexOf('\n')) !== -1) {
75
+ emit(pending.slice(0, index));
76
+ pending = pending.slice(index + 1);
77
+ }
78
+ });
79
+ stream.on('end', () => {
80
+ if (pending)
81
+ emit(pending);
82
+ pending = '';
83
+ });
84
+ }
85
+ onLine(listener) {
86
+ this.#lineListeners.add(listener);
87
+ return () => this.#lineListeners.delete(listener);
88
+ }
89
+ output() {
90
+ return this.recentLogs.map((l) => l.line).join('\n');
91
+ }
92
+ /**
93
+ * Sends SIGTERM and waits up to `timeoutMs` before SIGKILL. On Windows Node
94
+ * can only terminate the process forcefully, so both steps are immediate.
95
+ */
96
+ stop(timeoutMs) {
97
+ if (this.exitResult)
98
+ return Promise.resolve(this.exitResult);
99
+ this.#stopping ??= (async () => {
100
+ this.child.kill('SIGTERM');
101
+ let timer;
102
+ const timedOut = new Promise((resolve) => {
103
+ timer = setTimeout(() => resolve('timeout'), timeoutMs);
104
+ });
105
+ const first = await Promise.race([this.exited, timedOut]);
106
+ clearTimeout(timer);
107
+ if (first === 'timeout')
108
+ this.child.kill('SIGKILL');
109
+ return this.exited;
110
+ })();
111
+ return this.#stopping;
112
+ }
113
+ }
114
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/server/process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAI9D,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,oFAAoF;AACpF,MAAM,IAAI,GAAG,IAAI,GAAG,EAAgB,CAAC;AACrC,IAAI,iBAAiB,GAAG,KAAK,CAAC;AAC9B,SAAS,UAAU,CAAC,KAAmB;IACrC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChB,IAAI,iBAAiB;QAAE,OAAO;IAC9B,iBAAiB,GAAG,IAAI,CAAC;IACzB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;QACxB,KAAK,MAAM,CAAC,IAAI,IAAI;YAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC;AASD,qFAAqF;AACrF,MAAM,OAAO,cAAc;IAChB,KAAK,CAAe;IACpB,MAAM,CAAsB;IAC5B,UAAU,GAAc,EAAE,CAAC;IACpC,wDAAwD;IACxD,UAAU,CAAoB;IAC9B,UAAU,CAAyB;IAE1B,OAAO,CAA2B;IAClC,MAAM,CAAuC;IAC7C,cAAc,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC5D,SAAS,CAAkC;IAE3C,YAAY,UAAkB,EAAE,IAAuB,EAAE,OAAqB;QAC5E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,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ACL,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /** Hostname to connect to for a configured bind host. */
2
+ export declare function connectHost(bindHost: string): string;
3
+ export declare function formatOrigin(protocol: 'http' | 'https', host: string, port: number): string;
4
+ /**
5
+ * Single `GET /healthz` probe. Certificate checks are skipped because the probe
6
+ * only targets the child process this package just started.
7
+ */
8
+ export declare function probeHealth(origin: string, timeoutMs: number): Promise<boolean>;
9
+ /** Asks the OS for a currently free TCP port on `host`. */
10
+ export declare function findFreePort(host: string): Promise<number>;
11
+ /** Resolves to true when nothing is listening on `host:port`. */
12
+ export declare function isPortFree(host: string, port: number): Promise<boolean>;
13
+ //# sourceMappingURL=readiness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readiness.d.ts","sourceRoot":"","sources":["../../src/server/readiness.ts"],"names":[],"mappings":"AAIA,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAG3F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAY/E;AAED,2DAA2D;AAC3D,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAW1D;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQvE"}
@@ -0,0 +1,56 @@
1
+ import { request as httpRequest } from 'node:http';
2
+ import { request as httpsRequest } from 'node:https';
3
+ import { createServer } from 'node:net';
4
+ /** Hostname to connect to for a configured bind host. */
5
+ export function connectHost(bindHost) {
6
+ if (bindHost === '' || bindHost === '0.0.0.0')
7
+ return '127.0.0.1';
8
+ if (bindHost === '::' || bindHost === '[::]')
9
+ return '::1';
10
+ return bindHost;
11
+ }
12
+ export function formatOrigin(protocol, host, port) {
13
+ const h = host.includes(':') && !host.startsWith('[') ? `[${host}]` : host;
14
+ return `${protocol}://${h}:${port}`;
15
+ }
16
+ /**
17
+ * Single `GET /healthz` probe. Certificate checks are skipped because the probe
18
+ * only targets the child process this package just started.
19
+ */
20
+ export function probeHealth(origin, timeoutMs) {
21
+ const url = new URL('/healthz', origin);
22
+ const request = url.protocol === 'https:' ? httpsRequest : httpRequest;
23
+ return new Promise((resolve) => {
24
+ const req = request(url, { method: 'GET', timeout: timeoutMs, rejectUnauthorized: false }, (res) => {
25
+ res.resume();
26
+ resolve(res.statusCode === 200);
27
+ });
28
+ req.on('timeout', () => req.destroy());
29
+ req.on('error', () => resolve(false));
30
+ req.end();
31
+ });
32
+ }
33
+ /** Asks the OS for a currently free TCP port on `host`. */
34
+ export function findFreePort(host) {
35
+ return new Promise((resolve, reject) => {
36
+ const server = createServer();
37
+ server.unref();
38
+ server.once('error', reject);
39
+ server.listen({ host: connectHost(host), port: 0, exclusive: true }, () => {
40
+ const address = server.address();
41
+ const port = typeof address === 'object' && address ? address.port : 0;
42
+ server.close(() => (port ? resolve(port) : reject(new Error('Could not allocate a free port.'))));
43
+ });
44
+ });
45
+ }
46
+ /** Resolves to true when nothing is listening on `host:port`. */
47
+ export function isPortFree(host, port) {
48
+ return new Promise((resolve) => {
49
+ const server = createServer();
50
+ server.unref();
51
+ server.once('error', (error) => resolve(error.code !== 'EADDRINUSE'));
52
+ // An empty bind host means all interfaces, which is what CPA binds in that case.
53
+ server.listen({ host: host === '' ? undefined : host, port, exclusive: true }, () => server.close(() => resolve(true)));
54
+ });
55
+ }
56
+ //# sourceMappingURL=readiness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readiness.js","sourceRoot":"","sources":["../../src/server/readi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,IAAY,EAAE,IAAY;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;QAC9B,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAA4B,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC;QAC7F,iFAAiF;QACjF,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1H,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Replaces every occurrence of the given secrets with `[REDACTED]`. */
2
+ export declare function createRedactor(secrets: Iterable<string | undefined>): (text: string) => string;
3
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../src/server/redact.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAU9F"}
@@ -0,0 +1,16 @@
1
+ const MIN_SECRET_LENGTH = 4;
2
+ /** Replaces every occurrence of the given secrets with `[REDACTED]`. */
3
+ export function createRedactor(secrets) {
4
+ const values = [...new Set([...secrets].filter((s) => typeof s === 'string' && s.length >= MIN_SECRET_LENGTH))]
5
+ // Longest first so a secret containing another one is fully masked.
6
+ .sort((a, b) => b.length - a.length);
7
+ if (values.length === 0)
8
+ return (text) => text;
9
+ return (text) => {
10
+ let out = text;
11
+ for (const value of values)
12
+ out = out.split(value).join('[REDACTED]');
13
+ return out;
14
+ };
15
+ }
16
+ //# sourceMappingURL=redact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.js","sourceRoot":"","sources":["../../src/server/redact.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,wEAAwE;AACxE,MAAM,UAAU,cAAc,CAAC,OAAqC;IAClE,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,iBAAiB,CAAC,CAAC,CAAC;QAC1H,oEAAoE;SACnE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAC/C,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,IAAI,GAAG,GAAG,IAAI,CAAC;QACf,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACtE,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Platform targets for the prebuilt CLIProxyAPI binaries.
3
+ *
4
+ * This list is the single source of truth for both the runtime binary lookup
5
+ * and the build/assembly scripts, so it must stay free of Node-only imports.
6
+ */
7
+ /** How a target binary is produced. */
8
+ export type TargetBuild =
9
+ /** CGO enabled, dynamic library plugins supported (matches the upstream default build). */
10
+ 'plugin'
11
+ /** CGO disabled, statically linked, no dynamic library plugins (upstream "no-plugin"). */
12
+ | 'portable';
13
+ /** The strongest verification CI performs for a target. */
14
+ export type TargetVerification =
15
+ /** Started natively on a matching runner and smoke-tested over HTTP. */
16
+ 'native'
17
+ /** Started under QEMU user-mode emulation and smoke-tested over HTTP. */
18
+ | 'emulated'
19
+ /** Only cross-compiled; the binary is never executed in CI. */
20
+ | 'cross-compiled';
21
+ export interface Target {
22
+ /** Package suffix, e.g. `linux-x64-gnu` → `@cpajs/linux-x64-gnu`. */
23
+ readonly id: string;
24
+ /** `process.platform` value. */
25
+ readonly os: NodeJS.Platform;
26
+ /** `process.arch` value. */
27
+ readonly cpu: NodeJS.Architecture;
28
+ /** npm `libc` constraint. Omitted for static binaries that run on any libc. */
29
+ readonly libc?: 'glibc' | 'musl';
30
+ readonly goos: string;
31
+ readonly goarch: string;
32
+ /** Extra Go environment, e.g. `GOARM`. */
33
+ readonly goenv?: Readonly<Record<string, string>>;
34
+ readonly build: TargetBuild;
35
+ readonly verification: TargetVerification;
36
+ /** Human-readable caveats shown in docs and errors. */
37
+ readonly notes?: string;
38
+ }
39
+ export declare const NPM_SCOPE = "@cpajs";
40
+ export declare const TARGETS: readonly Target[];
41
+ /**
42
+ * Node platforms deliberately not covered, with the reason. Checked by
43
+ * cross-compiling the pinned source with CGO disabled.
44
+ */
45
+ export declare const UNSUPPORTED_PLATFORMS: Readonly<Record<string, string>>;
46
+ export declare function packageName(target: Target): string;
47
+ export declare function binaryName(target: Pick<Target, 'os'>): string;
48
+ //# sourceMappingURL=targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.d.ts","sourceRoot":"","sources":["../../src/server/targets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uCAAuC;AACvC,MAAM,MAAM,WAAW;AACrB,2FAA2F;AACzF,QAAQ;AACV,0FAA0F;GACxF,UAAU,CAAC;AAEf,2DAA2D;AAC3D,MAAM,MAAM,kBAAkB;AAC5B,wEAAwE;AACtE,QAAQ;AACV,yEAAyE;GACvE,UAAU;AACZ,+DAA+D;GAC7D,gBAAgB,CAAC;AAErB,MAAM,WAAW,MAAM;IACrB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC7B,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAC1C,uDAAuD;IACvD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,SAAS,WAAW,CAAC;AAElC,eAAO,MAAM,OAAO,EAAE,SAAS,MAAM,EAmEpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOlE,CAAC;AAEF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Platform targets for the prebuilt CLIProxyAPI binaries.
3
+ *
4
+ * This list is the single source of truth for both the runtime binary lookup
5
+ * and the build/assembly scripts, so it must stay free of Node-only imports.
6
+ */
7
+ export const NPM_SCOPE = '@cpajs';
8
+ export const TARGETS = [
9
+ { id: 'darwin-x64', os: 'darwin', cpu: 'x64', goos: 'darwin', goarch: 'amd64', build: 'plugin', verification: 'native' },
10
+ { id: 'darwin-arm64', os: 'darwin', cpu: 'arm64', goos: 'darwin', goarch: 'arm64', build: 'plugin', verification: 'native' },
11
+ { id: 'win32-x64', os: 'win32', cpu: 'x64', goos: 'windows', goarch: 'amd64', build: 'plugin', verification: 'native' },
12
+ { id: 'win32-arm64', os: 'win32', cpu: 'arm64', goos: 'windows', goarch: 'arm64', build: 'plugin', verification: 'native' },
13
+ {
14
+ id: 'win32-ia32',
15
+ os: 'win32',
16
+ cpu: 'ia32',
17
+ goos: 'windows',
18
+ goarch: '386',
19
+ build: 'portable',
20
+ verification: 'native',
21
+ notes: 'Not built upstream. Smoke-tested under WOW64 on an x64 runner.',
22
+ },
23
+ { id: 'linux-x64-gnu', os: 'linux', cpu: 'x64', libc: 'glibc', goos: 'linux', goarch: 'amd64', build: 'plugin', verification: 'native', notes: 'Requires glibc 2.17 or newer.' },
24
+ { id: 'linux-arm64-gnu', os: 'linux', cpu: 'arm64', libc: 'glibc', goos: 'linux', goarch: 'arm64', build: 'plugin', verification: 'native', notes: 'Requires glibc 2.17 or newer.' },
25
+ { id: 'linux-x64-musl', os: 'linux', cpu: 'x64', libc: 'musl', goos: 'linux', goarch: 'amd64', build: 'portable', verification: 'native' },
26
+ { id: 'linux-arm64-musl', os: 'linux', cpu: 'arm64', libc: 'musl', goos: 'linux', goarch: 'arm64', build: 'portable', verification: 'native' },
27
+ {
28
+ id: 'linux-arm',
29
+ os: 'linux',
30
+ cpu: 'arm',
31
+ goos: 'linux',
32
+ goarch: 'arm',
33
+ goenv: { GOARM: '7' },
34
+ build: 'portable',
35
+ verification: 'emulated',
36
+ notes: 'ARMv7 or newer (GOARM=7). Static binary for both glibc and musl. Not built upstream.',
37
+ },
38
+ { id: 'linux-ia32', os: 'linux', cpu: 'ia32', goos: 'linux', goarch: '386', build: 'portable', verification: 'native', notes: 'Not built upstream.' },
39
+ { id: 'linux-riscv64', os: 'linux', cpu: 'riscv64', goos: 'linux', goarch: 'riscv64', build: 'portable', verification: 'emulated', notes: 'Not built upstream.' },
40
+ { id: 'linux-ppc64', os: 'linux', cpu: 'ppc64', goos: 'linux', goarch: 'ppc64le', build: 'portable', verification: 'emulated', notes: 'Little-endian ppc64le only. Not built upstream.' },
41
+ { id: 'linux-s390x', os: 'linux', cpu: 's390x', goos: 'linux', goarch: 's390x', build: 'portable', verification: 'emulated', notes: 'Not built upstream.' },
42
+ { id: 'linux-loong64', os: 'linux', cpu: 'loong64', goos: 'linux', goarch: 'loong64', build: 'portable', verification: 'emulated', notes: 'Not built upstream.' },
43
+ {
44
+ id: 'linux-mips',
45
+ os: 'linux',
46
+ cpu: 'mips',
47
+ goos: 'linux',
48
+ goarch: 'mips',
49
+ goenv: { GOMIPS: 'softfloat' },
50
+ build: 'portable',
51
+ verification: 'emulated',
52
+ notes: 'Big-endian 32-bit MIPS, soft float. Not built upstream.',
53
+ },
54
+ {
55
+ id: 'linux-mipsel',
56
+ os: 'linux',
57
+ cpu: 'mipsel',
58
+ goos: 'linux',
59
+ goarch: 'mipsle',
60
+ goenv: { GOMIPS: 'softfloat' },
61
+ build: 'portable',
62
+ verification: 'emulated',
63
+ notes: 'Little-endian 32-bit MIPS, soft float. Not built upstream.',
64
+ },
65
+ { id: 'freebsd-x64', os: 'freebsd', cpu: 'x64', goos: 'freebsd', goarch: 'amd64', build: 'plugin', verification: 'cross-compiled', notes: 'Cross-compiled against a FreeBSD 14 sysroot, as upstream does.' },
66
+ { id: 'freebsd-arm64', os: 'freebsd', cpu: 'arm64', goos: 'freebsd', goarch: 'arm64', build: 'portable', verification: 'cross-compiled' },
67
+ { id: 'freebsd-ia32', os: 'freebsd', cpu: 'ia32', goos: 'freebsd', goarch: '386', build: 'portable', verification: 'cross-compiled', notes: 'Not built upstream.' },
68
+ { id: 'openbsd-x64', os: 'openbsd', cpu: 'x64', goos: 'openbsd', goarch: 'amd64', build: 'portable', verification: 'cross-compiled', notes: 'Not built upstream.' },
69
+ { id: 'openbsd-arm64', os: 'openbsd', cpu: 'arm64', goos: 'openbsd', goarch: 'arm64', build: 'portable', verification: 'cross-compiled', notes: 'Not built upstream.' },
70
+ { id: 'netbsd-x64', os: 'netbsd', cpu: 'x64', goos: 'netbsd', goarch: 'amd64', build: 'portable', verification: 'cross-compiled', notes: 'Not built upstream.' },
71
+ ];
72
+ /**
73
+ * Node platforms deliberately not covered, with the reason. Checked by
74
+ * cross-compiling the pinned source with CGO disabled.
75
+ */
76
+ export const UNSUPPORTED_PLATFORMS = {
77
+ 'android-*': 'Link fails: github.com/wlynxg/anet references net.zoneCache, which Go no longer allows.',
78
+ 'sunos-x64': 'Compile fails: syscall.Flock is undefined on solaris/illumos; pion/transport needs SO_REUSEPORT.',
79
+ 'aix-ppc64': 'Compile fails: syscall.Flock is undefined on aix.',
80
+ 'linux-mips64el': 'No matching Node.js process.arch value.',
81
+ 'haiku-*': 'Not a Go target.',
82
+ 'cygwin-*': 'Use the win32 packages.',
83
+ };
84
+ export function packageName(target) {
85
+ return `${NPM_SCOPE}/${target.id}`;
86
+ }
87
+ export function binaryName(target) {
88
+ return target.os === 'win32' ? 'cli-proxy-api.exe' : 'cli-proxy-api';
89
+ }
90
+ //# sourceMappingURL=targets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"targets.js","sourceRoot":"","sources":["../../src/server/targets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAqCH,MAAM,CAAC,MAAM,SAAS,GAAG,QAAQ,CAAC;AAElC,MAAM,CAAC,MAAM,OAAO,GAAsB;IACxC,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,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AAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,GAAG,SAAS,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAA0B;IACnD,OAAO,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,eAAe,CAAC;AACvE,CAAC"}
@@ -0,0 +1,87 @@
1
+ import type { ChildProcess } from 'node:child_process';
2
+ import type { CpaConfig } from '../client/types/config.ts';
3
+ export interface LogLine {
4
+ stream: 'stdout' | 'stderr';
5
+ /** One line of output with secrets redacted and the trailing newline removed. */
6
+ line: string;
7
+ }
8
+ interface CommonServerOptions {
9
+ /** Use this executable instead of the bundled platform package. */
10
+ binaryPath?: string;
11
+ /**
12
+ * Working directory for CPA and home of the managed config file and auth
13
+ * directory. When omitted, a temporary directory is created and removed on stop.
14
+ */
15
+ stateDir?: string;
16
+ /**
17
+ * Management key passed to CPA through the `MANAGEMENT_PASSWORD` environment
18
+ * variable, so it never touches disk. Note that upstream treats this variable
19
+ * as allowing remote management access regardless of `management.allow-remote`.
20
+ */
21
+ managementKey?: string;
22
+ /** Extra CLI arguments, e.g. `['-local-model']`. Passed as an argv array, never through a shell. */
23
+ args?: readonly string[];
24
+ /** Environment for the child process. Defaults to `process.env`; entries set to `undefined` are removed. */
25
+ env?: Readonly<Record<string, string | undefined>>;
26
+ /** Maximum time to wait for `/healthz` to answer. Default 30 000 ms. */
27
+ startupTimeoutMs?: number;
28
+ /** Cancels startup. After startup it has no effect; call `stop()` instead. */
29
+ signal?: AbortSignal;
30
+ /** Receives every output line, redacted. */
31
+ onLog?: (log: LogLine) => void;
32
+ /** Additional strings to redact from logs and errors. */
33
+ redact?: readonly string[];
34
+ /** Default grace period for `stop()` before the process is killed. Default 10 000 ms. */
35
+ stopTimeoutMs?: number;
36
+ }
37
+ export interface StartWithConfigOptions extends CommonServerOptions {
38
+ /**
39
+ * Native CPA configuration. It is written to `<stateDir>/config.yaml` on
40
+ * every start, replacing whatever CPA persisted there during the last run.
41
+ */
42
+ config?: CpaConfig;
43
+ configPath?: never;
44
+ /** Bind host. Overrides `config.server.host`. Default `127.0.0.1`. */
45
+ host?: string;
46
+ /** Bind port. Overrides `config.server.port`. Default `0`, meaning a free port is picked. */
47
+ port?: number;
48
+ }
49
+ export interface StartWithConfigPathOptions extends CommonServerOptions {
50
+ /** Existing CPA config file, handed to CPA as-is. CPA may rewrite it (e.g. to hash `secret-key`). */
51
+ configPath: string;
52
+ config?: never;
53
+ host?: never;
54
+ port?: never;
55
+ }
56
+ export type StartServerOptions = StartWithConfigOptions | StartWithConfigPathOptions;
57
+ export interface ExitResult {
58
+ code: number | null;
59
+ signal: NodeJS.Signals | null;
60
+ }
61
+ export interface StopOptions {
62
+ /** Grace period after the termination signal before the process is killed. */
63
+ timeoutMs?: number;
64
+ }
65
+ export interface CpaServer {
66
+ /** e.g. `http://127.0.0.1:8317`. Use as the client `baseUrl`. */
67
+ readonly origin: string;
68
+ /** Model API base URL (`<origin>/v1`) for OpenAI-compatible SDKs. */
69
+ readonly baseUrl: string;
70
+ readonly host: string;
71
+ readonly port: number;
72
+ readonly pid: number;
73
+ readonly binaryPath: string;
74
+ readonly configPath: string;
75
+ readonly stateDir: string;
76
+ /** The management key given in the options, if any. */
77
+ readonly managementKey: string | undefined;
78
+ readonly process: ChildProcess;
79
+ /** Recent output lines (redacted), oldest first. */
80
+ readonly recentLogs: readonly LogLine[];
81
+ /** Settles when the process exits, whether or not `stop()` was called. */
82
+ readonly exited: Promise<ExitResult>;
83
+ /** Terminates CPA gracefully, killing it after the grace period. Idempotent. */
84
+ stop(options?: StopOptions): Promise<ExitResult>;
85
+ }
86
+ export {};
87
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MA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K,CAAC;IACb,IAAI,CAAC,EAAE,KAAK,CAAC;CACd;AAED,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GAAG,0BAA0B,CAAC;AAErF,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,uDAAuD;IACvD,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,SAAS,OAAO,EAAE,CAAC;IACxC,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACrC,gFAAgF;IAChF,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAClD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@cpajs/cpa",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-alpha-2",
4
+ "description": "Run the official CLIProxyAPI from JavaScript and talk to its v8 management API with a typed client",
5
+ "license": "MIT",
6
+ "author": "akarachen",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/AkaraChen/cpajs.git"
10
+ },
11
+ "type": "module",
12
+ "engines": {
13
+ "node": ">=22"
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "src",
18
+ "!src/**/*.test.ts"
19
+ ],
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "default": "./dist/index.js"
24
+ },
25
+ "./client": {
26
+ "types": "./dist/client/index.d.ts",
27
+ "default": "./dist/client/index.js"
28
+ },
29
+ "./server": {
30
+ "types": "./dist/server/index.d.ts",
31
+ "default": "./dist/server/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "scripts": {
36
+ "build": "rm -rf dist && tsc -p tsconfig.build.json",
37
+ "typecheck": "tsc -p tsconfig.json",
38
+ "test": "vitest run",
39
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
40
+ "cpa:source": "node scripts/fetch-source.ts",
41
+ "cpa:build": "node scripts/build-binary.ts",
42
+ "cpa:verify": "node scripts/verify-binary.ts",
43
+ "packages:assemble": "node scripts/assemble-packages.ts",
44
+ "prepack": "pnpm run build",
45
+ "packages:pack": "node scripts/pack.ts",
46
+ "test:install": "node scripts/install-test.ts"
47
+ },
48
+ "dependencies": {
49
+ "yaml": "^2.9.1"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^24.0.0",
53
+ "typescript": "^7.0.2",
54
+ "vitest": "^5.0.5"
55
+ },
56
+ "packageManager": "pnpm@11.20.0",
57
+ "publishConfig": {
58
+ "access": "public"
59
+ },
60
+ "optionalDependencies": {
61
+ "@cpajs/darwin-x64": "0.0.1-alpha-2",
62
+ "@cpajs/darwin-arm64": "0.0.1-alpha-2",
63
+ "@cpajs/win32-x64": "0.0.1-alpha-2",
64
+ "@cpajs/win32-arm64": "0.0.1-alpha-2",
65
+ "@cpajs/win32-ia32": "0.0.1-alpha-2",
66
+ "@cpajs/linux-x64-gnu": "0.0.1-alpha-2",
67
+ "@cpajs/linux-arm64-gnu": "0.0.1-alpha-2",
68
+ "@cpajs/linux-x64-musl": "0.0.1-alpha-2",
69
+ "@cpajs/linux-arm64-musl": "0.0.1-alpha-2",
70
+ "@cpajs/linux-arm": "0.0.1-alpha-2",
71
+ "@cpajs/linux-ia32": "0.0.1-alpha-2",
72
+ "@cpajs/linux-riscv64": "0.0.1-alpha-2",
73
+ "@cpajs/linux-ppc64": "0.0.1-alpha-2",
74
+ "@cpajs/linux-s390x": "0.0.1-alpha-2",
75
+ "@cpajs/linux-loong64": "0.0.1-alpha-2",
76
+ "@cpajs/linux-mips": "0.0.1-alpha-2",
77
+ "@cpajs/linux-mipsel": "0.0.1-alpha-2",
78
+ "@cpajs/freebsd-x64": "0.0.1-alpha-2",
79
+ "@cpajs/freebsd-arm64": "0.0.1-alpha-2",
80
+ "@cpajs/freebsd-ia32": "0.0.1-alpha-2",
81
+ "@cpajs/openbsd-x64": "0.0.1-alpha-2",
82
+ "@cpajs/openbsd-arm64": "0.0.1-alpha-2",
83
+ "@cpajs/netbsd-x64": "0.0.1-alpha-2"
84
+ }
85
+ }