@compforge/harness-toolbox 0.4.7 → 0.5.0

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 (59) hide show
  1. package/README.md +15 -8
  2. package/dist/{chunk-1ts7pswj.js → chunk-0d8vs5q8.js} +33 -2
  3. package/dist/{chunk-h8fwx0k7.js → chunk-18gcp0ck.js} +32 -7
  4. package/dist/{chunk-gm4swndx.js → chunk-43mcyrh4.js} +14 -24
  5. package/dist/{chunk-zp1s833x.js → chunk-7hbvjzb9.js} +25 -12
  6. package/dist/{chunk-f3vq900j.js → chunk-92aacbwh.js} +1 -1
  7. package/dist/{chunk-35cjec9z.js → chunk-ccre3nh1.js} +6 -6
  8. package/dist/chunk-ehmx0yhp.js +52 -0
  9. package/dist/{chunk-t4hrnaj0.js → chunk-ex429qjt.js} +22 -20
  10. package/dist/{chunk-fqrknvr8.js → chunk-kap6ka3n.js} +27 -12
  11. package/dist/{chunk-m4d29vfd.js → chunk-kxpecgy7.js} +109 -36
  12. package/dist/{chunk-nftzckdy.js → chunk-mvkxs8d0.js} +17 -2
  13. package/dist/{chunk-f98qrpx1.js → chunk-njs48b51.js} +28 -27
  14. package/dist/chunk-sb5qzv37.js +62 -0
  15. package/dist/{chunk-dx6yvj81.js → chunk-xhfbark7.js} +1 -1
  16. package/dist/{chunk-m391jmpw.js → chunk-ze1hng62.js} +9 -9
  17. package/dist/connection/acquire.d.ts +3 -4
  18. package/dist/connection/acquire.js +2 -4
  19. package/dist/datasource.d.ts +0 -6
  20. package/dist/file/client.js +2 -2
  21. package/dist/file/index.js +4 -4
  22. package/dist/file/local.js +3 -3
  23. package/dist/file/pod.js +3 -3
  24. package/dist/kubernetes/client.js +8 -8
  25. package/dist/kubernetes/environment.js +8 -8
  26. package/dist/kubernetes/exec-transport.js +2 -2
  27. package/dist/kubernetes/pod-log-client.js +2 -2
  28. package/dist/kubernetes/pod-log-datasource.js +3 -3
  29. package/dist/kubernetes/port-forward.d.ts +4 -0
  30. package/dist/kubernetes/port-forward.js +1 -1
  31. package/dist/kubernetes/resource-transport.js +2 -2
  32. package/dist/kubernetes/service-port-forward.d.ts +3 -2
  33. package/dist/kubernetes/service-port-forward.js +2 -2
  34. package/dist/mysql/client.d.ts +7 -7
  35. package/dist/mysql/client.js +12 -7
  36. package/dist/mysql/index.js +18 -13
  37. package/dist/opensearch/client.d.ts +14 -4
  38. package/dist/opensearch/client.js +15 -8
  39. package/dist/opensearch/index.js +15 -8
  40. package/dist/redis/client.d.ts +7 -6
  41. package/dist/redis/client.js +12 -7
  42. package/dist/redis/index.js +16 -11
  43. package/dist/s3/client.d.ts +5 -3
  44. package/dist/s3/client.js +14 -1
  45. package/dist/s3/datasource.js +13 -7
  46. package/dist/s3/index.js +13 -7
  47. package/dist/transport/index.d.ts +18 -8
  48. package/dist/transport/index.js +17 -4
  49. package/dist/transport/lifecycle.d.ts +22 -0
  50. package/dist/transport/lifecycle.js +8 -0
  51. package/dist/transport/pod-relay.d.ts +7 -4
  52. package/dist/transport/pod-relay.js +6 -3
  53. package/dist/transport/service-port-forward.d.ts +30 -0
  54. package/dist/transport/service-port-forward.js +15 -0
  55. package/package.json +3 -2
  56. package/dist/{chunk-mnad4zkp.js → chunk-010339ga.js} +3 -3
  57. package/dist/{chunk-x0yhfg29.js → chunk-5w85c7cs.js} +3 -3
  58. package/dist/{chunk-ww11q58v.js → chunk-rncagjbc.js} +3 -3
  59. package/dist/{chunk-r3rnsvwv.js → chunk-xeft7af0.js} +3 -3
@@ -1,3 +1,7 @@
1
+ import { Transport } from "./lifecycle";
2
+ import type { ConnectionAttempt } from "../connection/acquire";
3
+ export { Transport } from "./lifecycle";
4
+ /** Dial address only. Protocol identity remains with the client, never inferred from a forwarded address. */
1
5
  export interface Endpoint {
2
6
  host: string;
3
7
  port: number;
@@ -6,20 +10,24 @@ export interface Endpoint {
6
10
  export interface TcpTransport {
7
11
  readonly kind: "tcp";
8
12
  readonly name: string;
9
- connect(endpoint: Endpoint): Promise<Endpoint>;
13
+ connect(endpoint: Endpoint, attempt?: ConnectionAttempt): Promise<Endpoint>;
10
14
  }
11
- export declare class DirectTransport implements TcpTransport {
15
+ export declare class DirectTransport extends Transport implements TcpTransport {
12
16
  readonly kind = "tcp";
13
17
  readonly name = "direct";
14
- connect(endpoint: Endpoint): Promise<Endpoint>;
18
+ protected paths(): readonly TransportPath[];
19
+ connect(endpoint: Endpoint, attempt?: ConnectionAttempt): Promise<Endpoint>;
15
20
  }
16
21
  /** The supplied forwarder owns port allocation and cleanup; external endpoints may stay direct. */
17
- export declare class PortForwardTransport implements TcpTransport {
22
+ export declare class PortForwardTransport extends Transport implements TcpTransport {
18
23
  private readonly forward;
24
+ private readonly release?;
19
25
  readonly kind = "tcp";
20
26
  readonly name = "port-forward";
21
- constructor(forward: (endpoint: Endpoint) => Promise<Endpoint>);
22
- connect(endpoint: Endpoint): Promise<Endpoint>;
27
+ constructor(forward: (endpoint: Endpoint, attempt?: ConnectionAttempt) => Promise<Endpoint>, release?: (() => void | Promise<void>) | undefined, signal?: AbortSignal);
28
+ protected paths(): readonly TransportPath[];
29
+ connect(endpoint: Endpoint, attempt?: ConnectionAttempt): Promise<Endpoint>;
30
+ protected close(): Promise<void>;
23
31
  }
24
32
  export interface PodRunOptions {
25
33
  stdin: string;
@@ -27,15 +35,17 @@ export interface PodRunOptions {
27
35
  }
28
36
  export type PodRunner = (command: readonly string[], options: PodRunOptions) => Promise<string>;
29
37
  /** A Python-capable Pod path. Protocol code supplies the script; the host enforces access. */
30
- export declare class PodPythonTransport {
38
+ export declare class PodPythonTransport extends Transport {
31
39
  private readonly exec;
32
40
  private readonly python;
33
41
  readonly kind = "python";
34
42
  readonly name = "pod-python";
35
43
  constructor(exec: PodRunner, python?: string);
44
+ protected paths(): readonly TransportPath[];
36
45
  run(script: string, input: unknown, timeoutMs: number): Promise<string>;
37
46
  }
38
- export type Transport = TcpTransport | PodPythonTransport;
47
+ export type TransportPath = TcpTransport | PodPythonTransport;
39
48
  /** Only failure to establish a connection permits a route change; never replay protocol operations. */
40
49
  export declare function isConnectionNetworkError(error: unknown): boolean;
41
50
  export { PodRelayTransport, type PodRelayOptions } from "./pod-relay";
51
+ export { ServicePortForwardTransport } from "./service-port-forward";
@@ -3,16 +3,29 @@ import {
3
3
  PodPythonTransport,
4
4
  PortForwardTransport,
5
5
  isConnectionNetworkError
6
- } from "../chunk-h8fwx0k7.js";
6
+ } from "../chunk-18gcp0ck.js";
7
7
  import {
8
8
  PodRelayTransport
9
- } from "../chunk-fqrknvr8.js";
10
- import"../chunk-nftzckdy.js";
9
+ } from "../chunk-kap6ka3n.js";
10
+ import"../chunk-ssj93brx.js";
11
+ import {
12
+ ServicePortForwardTransport
13
+ } from "../chunk-ehmx0yhp.js";
14
+ import"../chunk-0d8vs5q8.js";
15
+ import"../chunk-xgnz10sr.js";
16
+ import"../chunk-6fnhzhdb.js";
17
+ import"../chunk-mvkxs8d0.js";
11
18
  import"../chunk-rq5fc007.js";
12
19
  import"../chunk-9shz0bw1.js";
13
- import"../chunk-ssj93brx.js";
20
+ import {
21
+ Transport
22
+ } from "../chunk-sb5qzv37.js";
23
+ import"../chunk-43mcyrh4.js";
24
+ import"../chunk-rkt41za2.js";
14
25
  export {
15
26
  isConnectionNetworkError,
27
+ Transport,
28
+ ServicePortForwardTransport,
16
29
  PortForwardTransport,
17
30
  PodRelayTransport,
18
31
  PodPythonTransport,
@@ -0,0 +1,22 @@
1
+ import type { Client } from "../client";
2
+ import { type Acquisition } from "../connection/acquire";
3
+ import type { TransportPath } from "./index";
4
+ /**
5
+ * @spec A transport selects and prepares access paths; protocol establishment is supplied by the client.
6
+ * @rule Borrowed routes are never disposed by their consumers. Register resource-owning routes with ClientManager.
7
+ * @see {@link component://docs/toolbox.md}
8
+ */
9
+ export declare class Transport implements Client {
10
+ #private;
11
+ private readonly candidates;
12
+ /** Root cancellation stops borrowers; only this transport's disposal tears down shared resources. */
13
+ protected readonly resourceSignal: AbortSignal;
14
+ readonly signal: AbortSignal;
15
+ constructor(candidates?: readonly TransportPath[], signal?: AbortSignal);
16
+ protected paths(): readonly TransportPath[];
17
+ initialize(): Promise<void>;
18
+ /** Internal handshake collaboration: only establishment errors can select another path. */
19
+ acquire<C>(options: Acquisition<TransportPath, C>): Promise<C>;
20
+ protected close(): Promise<void>;
21
+ dispose(): Promise<void>;
22
+ }
@@ -0,0 +1,8 @@
1
+ import {
2
+ Transport
3
+ } from "../chunk-sb5qzv37.js";
4
+ import"../chunk-43mcyrh4.js";
5
+ import"../chunk-rkt41za2.js";
6
+ export {
7
+ Transport
8
+ };
@@ -1,7 +1,9 @@
1
1
  import type { Client } from "../client";
2
2
  import { type Executor, type KubectlOptions } from "../kubernetes/executor";
3
3
  import { type StartPortForward } from "../kubernetes/port-forward";
4
- import type { Endpoint, TcpTransport } from "./index";
4
+ import { Transport } from "./lifecycle";
5
+ import type { Endpoint, TcpTransport, TransportPath } from "./index";
6
+ import type { ConnectionAttempt } from "../connection/acquire";
5
7
  export interface PodRelayOptions extends KubectlOptions {
6
8
  namespace: string;
7
9
  /** Restrict eligible existing Pods without coupling callers to the relay runtime. */
@@ -16,7 +18,7 @@ export interface PodRelayOptions extends KubectlOptions {
16
18
  /** Execution-scoped TCP transport borrowed by all Service clients; only its root owner disposes it.
17
19
  * Python is private. Requires list pods, pods/exec and pods/portforward, never pods/create.
18
20
  */
19
- export declare class PodRelayTransport implements TcpTransport, Client {
21
+ export declare class PodRelayTransport extends Transport implements TcpTransport, Client {
20
22
  #private;
21
23
  private readonly options;
22
24
  readonly kind = "tcp";
@@ -25,7 +27,8 @@ export declare class PodRelayTransport implements TcpTransport, Client {
25
27
  executor?: Executor;
26
28
  startForward?: StartPortForward;
27
29
  });
30
+ protected paths(): readonly TransportPath[];
28
31
  initialize(): Promise<void>;
29
- connect(endpoint: Endpoint): Promise<Endpoint>;
30
- dispose(): Promise<void>;
32
+ connect(endpoint: Endpoint, attempt?: ConnectionAttempt): Promise<Endpoint>;
33
+ protected close(): Promise<void>;
31
34
  }
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  PodRelayTransport
3
- } from "../chunk-fqrknvr8.js";
4
- import"../chunk-nftzckdy.js";
3
+ } from "../chunk-kap6ka3n.js";
4
+ import"../chunk-ssj93brx.js";
5
+ import"../chunk-mvkxs8d0.js";
5
6
  import"../chunk-rq5fc007.js";
6
7
  import"../chunk-9shz0bw1.js";
7
- import"../chunk-ssj93brx.js";
8
+ import"../chunk-sb5qzv37.js";
9
+ import"../chunk-43mcyrh4.js";
10
+ import"../chunk-rkt41za2.js";
8
11
  export {
9
12
  PodRelayTransport
10
13
  };
@@ -0,0 +1,30 @@
1
+ import { Transport } from "./lifecycle";
2
+ import type { Endpoint, TcpTransport, TransportPath } from "./index";
3
+ import type { ConnectionAttempt } from "../connection/acquire";
4
+ import { type Executor, type KubectlOptions } from "../kubernetes/executor";
5
+ import type { StartPortForward } from "../kubernetes/port-forward";
6
+ /**
7
+ * @spec One manager-owned transport shares forwards across protocol clients in the same namespace.
8
+ * @rule Cancelling a borrower does not stop a shared forward; root disposal releases it.
9
+ * @see {@link component://docs/toolbox.md}
10
+ */
11
+ export declare class ServicePortForwardTransport extends Transport implements TcpTransport {
12
+ #private;
13
+ private readonly options;
14
+ private readonly dependencies?;
15
+ readonly kind = "tcp";
16
+ readonly name = "port-forward";
17
+ constructor(options: KubectlOptions & {
18
+ namespace: string;
19
+ signal?: AbortSignal;
20
+ onDiagnostic?: (line: string) => void;
21
+ }, dependencies?: {
22
+ executor?: Executor;
23
+ startForward?: StartPortForward;
24
+ } | undefined);
25
+ protected paths(): readonly TransportPath[];
26
+ initialize(): Promise<void>;
27
+ get activeForwards(): readonly import("../kubernetes/port-forward").PortForward[];
28
+ connect(endpoint: Endpoint, attempt?: ConnectionAttempt): Promise<Endpoint>;
29
+ protected close(): Promise<void>;
30
+ }
@@ -0,0 +1,15 @@
1
+ import {
2
+ ServicePortForwardTransport
3
+ } from "../chunk-ehmx0yhp.js";
4
+ import"../chunk-0d8vs5q8.js";
5
+ import"../chunk-xgnz10sr.js";
6
+ import"../chunk-6fnhzhdb.js";
7
+ import"../chunk-mvkxs8d0.js";
8
+ import"../chunk-rq5fc007.js";
9
+ import"../chunk-9shz0bw1.js";
10
+ import"../chunk-sb5qzv37.js";
11
+ import"../chunk-43mcyrh4.js";
12
+ import"../chunk-rkt41za2.js";
13
+ export {
14
+ ServicePortForwardTransport
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compforge/harness-toolbox",
3
- "version": "0.4.7",
3
+ "version": "0.5.0",
4
4
  "description": "Shared infrastructure clients, transports and bounded data capture",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -99,14 +99,15 @@
99
99
  "README.md"
100
100
  ],
101
101
  "dependencies": {
102
- "@compforge/harness-common": "0.5.4",
103
102
  "@aws-sdk/client-s3": "3.1133.0",
103
+ "@compforge/harness-common": "0.5.10",
104
104
  "@kubernetes/client-node": "1.4.0",
105
105
  "@opensearch-project/opensearch": "3.6.0",
106
106
  "@redis/client": "6.1.0",
107
107
  "@smithy/node-http-handler": "4.12.1",
108
108
  "mysql2": "3.23.1",
109
109
  "node-fetch": "2.7.0",
110
+ "race-signal": "2.0.2",
110
111
  "ws": "8.21.3"
111
112
  },
112
113
  "devDependencies": {
@@ -2,12 +2,12 @@ import {
2
2
  PodLogByteBudget,
3
3
  runPodLogCapturePlan
4
4
  } from "./chunk-8nm9f0hh.js";
5
- import {
6
- logTimestampNanos
7
- } from "./chunk-mp88s7r7.js";
8
5
  import {
9
6
  LogCaptureFile
10
7
  } from "./chunk-1vfwvgkj.js";
8
+ import {
9
+ logTimestampNanos
10
+ } from "./chunk-mp88s7r7.js";
11
11
  import {
12
12
  clientKey
13
13
  } from "./chunk-a9htb6cr.js";
@@ -4,14 +4,14 @@ import {
4
4
  import {
5
5
  clientKey
6
6
  } from "./chunk-a9htb6cr.js";
7
+ import {
8
+ ConcurrencyPool
9
+ } from "./chunk-v3hxvnrc.js";
7
10
  import {
8
11
  KubernetesError,
9
12
  ToolboxError,
10
13
  kubernetesHttpError
11
14
  } from "./chunk-rkt41za2.js";
12
- import {
13
- ConcurrencyPool
14
- } from "./chunk-v3hxvnrc.js";
15
15
 
16
16
  // src/kubernetes/resource-transport.ts
17
17
  import { KubeConfig } from "@kubernetes/client-node";
@@ -1,10 +1,10 @@
1
+ import {
2
+ ConcurrencyPool
3
+ } from "./chunk-v3hxvnrc.js";
1
4
  import {
2
5
  FileError,
3
6
  ToolboxError
4
7
  } from "./chunk-rkt41za2.js";
5
- import {
6
- ConcurrencyPool
7
- } from "./chunk-v3hxvnrc.js";
8
8
 
9
9
  // src/file/client.ts
10
10
  function fileClientOptions(options) {
@@ -1,10 +1,10 @@
1
+ import {
2
+ ConcurrencyPool
3
+ } from "./chunk-v3hxvnrc.js";
1
4
  import {
2
5
  KubernetesError,
3
6
  kubernetesHttpError
4
7
  } from "./chunk-rkt41za2.js";
5
- import {
6
- ConcurrencyPool
7
- } from "./chunk-v3hxvnrc.js";
8
8
 
9
9
  // src/kubernetes/exec-transport.ts
10
10
  import { KubeConfig } from "@kubernetes/client-node";