@cortexkit/aft-bridge 0.18.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.
- package/README.md +33 -0
- package/dist/active-logger.d.ts +22 -0
- package/dist/active-logger.d.ts.map +1 -0
- package/dist/bridge.d.ts +146 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/downloader.d.ts +35 -0
- package/dist/downloader.d.ts.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1387 -0
- package/dist/logger.d.ts +28 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/onnx-runtime.d.ts +53 -0
- package/dist/onnx-runtime.d.ts.map +1 -0
- package/dist/platform.d.ts +21 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/pool.d.ts +66 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/protocol.d.ts +94 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/resolver.d.ts +40 -0
- package/dist/resolver.d.ts.map +1 -0
- package/package.json +35 -0
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-injected logger contract.
|
|
3
|
+
*
|
|
4
|
+
* The shared bridge package never owns a log file, log-format, or tag — every
|
|
5
|
+
* host (OpenCode, Pi, future MCP harnesses) has its own log conventions and
|
|
6
|
+
* operators rely on the per-host filename for support flows like
|
|
7
|
+
* `aft doctor --issue`.
|
|
8
|
+
*
|
|
9
|
+
* The transport consumes only the {@link Logger} interface; plugins implement
|
|
10
|
+
* it on top of their own file/console handler.
|
|
11
|
+
*/
|
|
12
|
+
export interface Logger {
|
|
13
|
+
log(message: string, meta?: LogMeta): void;
|
|
14
|
+
warn(message: string, meta?: LogMeta): void;
|
|
15
|
+
error(message: string, meta?: LogMeta): void;
|
|
16
|
+
/**
|
|
17
|
+
* Optional. When implemented, returns the path to the on-disk log file so
|
|
18
|
+
* bridge-side error messages can point operators directly at it.
|
|
19
|
+
*/
|
|
20
|
+
getLogFilePath?(): string | undefined;
|
|
21
|
+
}
|
|
22
|
+
export interface LogMeta {
|
|
23
|
+
/** Optional session id for correlating multi-session host activity. */
|
|
24
|
+
sessionId?: string;
|
|
25
|
+
/** Optional structured metadata (pid, exit code, etc.). */
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C;;;OAGG;IACH,cAAc,CAAC,IAAI,MAAM,GAAG,SAAS,CAAC;CACvC;AAED,MAAM,WAAW,OAAO;IACtB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-download and manage ONNX Runtime shared library for semantic search.
|
|
3
|
+
*
|
|
4
|
+
* Downloads the CPU-only ONNX Runtime from Microsoft's GitHub releases.
|
|
5
|
+
* The library is cached in the storage directory alongside semantic index data.
|
|
6
|
+
*
|
|
7
|
+
* Audit-3 v0.17 #1 hardening (v0.17.1): the previous implementation used
|
|
8
|
+
* `curl` with no size cap, no archive containment validation, no install
|
|
9
|
+
* lock, and no integrity verification — leaving an entire parallel install
|
|
10
|
+
* path that bypassed every defense the LSP GitHub installer had earned in
|
|
11
|
+
* Phase A through Phase E. This rewrite brings ONNX onto the same security
|
|
12
|
+
* floor:
|
|
13
|
+
*
|
|
14
|
+
* - Streaming size cap via fetch + ReadableStream transformer (`MAX_DOWNLOAD_BYTES`).
|
|
15
|
+
* - Streaming SHA-256 of the downloaded archive, persisted in `.aft-onnx-installed`.
|
|
16
|
+
* - Atomic O_EXCL install lock with PID-aware stale-lock recovery.
|
|
17
|
+
* - Containment-checked extraction: every file under the staging dir
|
|
18
|
+
* must be inside the staging root, no symlinks allowed before move.
|
|
19
|
+
* - Total extracted size cap (`MAX_EXTRACT_BYTES`) to defeat decompression
|
|
20
|
+
* bombs.
|
|
21
|
+
* - TOFU verification: if `.aft-onnx-installed` already records a hash for
|
|
22
|
+
* this version, refuse to use a binary that doesn't match.
|
|
23
|
+
*
|
|
24
|
+
* Supported platforms:
|
|
25
|
+
* - macOS ARM64 (osx-arm64)
|
|
26
|
+
* - Linux x64 (linux-x64)
|
|
27
|
+
* - Linux ARM64 (linux-aarch64)
|
|
28
|
+
* - Windows x64 (win-x64)
|
|
29
|
+
* - Windows ARM64 (win-arm64)
|
|
30
|
+
*
|
|
31
|
+
* macOS x64 (Intel) is not provided by Microsoft — users must install via:
|
|
32
|
+
* brew install onnxruntime
|
|
33
|
+
*/
|
|
34
|
+
/** Check if this platform can auto-download ONNX Runtime */
|
|
35
|
+
export declare function isOrtAutoDownloadSupported(): boolean;
|
|
36
|
+
/** Get the install hint for platforms where auto-download isn't available */
|
|
37
|
+
export declare function getManualInstallHint(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Ensure ONNX Runtime is available. Returns the directory containing the library,
|
|
40
|
+
* or null if unavailable.
|
|
41
|
+
*
|
|
42
|
+
* Resolution order:
|
|
43
|
+
* 1. Cached in storageDir/onnxruntime/<version>/ (with TOFU verification)
|
|
44
|
+
* 2. System install (brew, apt, etc.)
|
|
45
|
+
* 3. Auto-download from GitHub releases (if platform supported)
|
|
46
|
+
* 4. null (user needs manual install)
|
|
47
|
+
*/
|
|
48
|
+
export declare function ensureOnnxRuntime(storageDir: string): Promise<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Remove ONNX Runtime from temp files. Cleanup helper for test isolation.
|
|
51
|
+
*/
|
|
52
|
+
export declare function cleanupOnnxRuntime(storageDir: string): void;
|
|
53
|
+
//# sourceMappingURL=onnx-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onnx-runtime.d.ts","sourceRoot":"","sources":["../src/onnx-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AA6FH,4DAA4D;AAC5D,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,IAAI,MAAM,CAQ7C;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA6ElF;AAqeD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAS3D"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared platform / architecture mappings used by both the resolver and downloader.
|
|
3
|
+
*
|
|
4
|
+
* Keeping them here avoids duplication and ensures resolver + downloader always
|
|
5
|
+
* agree on the canonical platform key strings (e.g. "darwin-arm64").
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Nested map: `process.platform` → `process.arch` → platform-key string.
|
|
9
|
+
*
|
|
10
|
+
* Used by the resolver to turn the current runtime environment into the
|
|
11
|
+
* canonical key (e.g. `"darwin-arm64"`) that the rest of the system uses.
|
|
12
|
+
*/
|
|
13
|
+
export declare const PLATFORM_ARCH_MAP: Record<string, Record<string, string>>;
|
|
14
|
+
/**
|
|
15
|
+
* Flat map: platform-key string → GitHub release asset filename.
|
|
16
|
+
*
|
|
17
|
+
* Used by the downloader to turn the canonical key into the exact asset name
|
|
18
|
+
* that appears in the GitHub release (e.g. `"aft-darwin-arm64"`).
|
|
19
|
+
*/
|
|
20
|
+
export declare const PLATFORM_ASSET_MAP: Record<string, string>;
|
|
21
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIpE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMrD,CAAC"}
|
package/dist/pool.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BinaryBridge, type BridgeOptions } from "./bridge.js";
|
|
2
|
+
export interface PoolOptions extends BridgeOptions {
|
|
3
|
+
maxPoolSize?: number;
|
|
4
|
+
idleTimeoutMs?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Manages a pool of BinaryBridge instances, keyed by **canonical project root**.
|
|
8
|
+
*
|
|
9
|
+
* Prior to issue #14, the pool spawned one binary process per OpenCode session,
|
|
10
|
+
* which duplicated every heavy in-memory structure (ONNX runtime, trigram and
|
|
11
|
+
* semantic indexes, LSP state, symbol caches) N times for N sessions in the
|
|
12
|
+
* same project. That produced an effective "leak" the user saw as many aft
|
|
13
|
+
* processes consuming gigabytes of RAM on large repositories.
|
|
14
|
+
*
|
|
15
|
+
* The current design spawns **one bridge per project** and relies on the Rust
|
|
16
|
+
* side to partition the small amount of truly session-scoped state (undo
|
|
17
|
+
* history, named checkpoints) via the `session_id` envelope field attached by
|
|
18
|
+
* the `callBridge()` helper. Sessions sharing a bridge still share the
|
|
19
|
+
* latency of a single request pipeline; the trade-off is acceptable because
|
|
20
|
+
* it removes the real RAM multiplier.
|
|
21
|
+
*/
|
|
22
|
+
export declare class BridgePool {
|
|
23
|
+
/** Project-root → bridge. Key is a normalized canonical path. */
|
|
24
|
+
private readonly bridges;
|
|
25
|
+
private binaryPath;
|
|
26
|
+
private readonly maxPoolSize;
|
|
27
|
+
private readonly idleTimeoutMs;
|
|
28
|
+
private readonly bridgeOptions;
|
|
29
|
+
private readonly configOverrides;
|
|
30
|
+
private cleanupTimer;
|
|
31
|
+
constructor(binaryPath: string, options?: PoolOptions, configOverrides?: Record<string, unknown>);
|
|
32
|
+
/**
|
|
33
|
+
* Get an alive bridge only when it belongs to the requested project root.
|
|
34
|
+
*
|
|
35
|
+
* Used by read-only paths (e.g. `/aft-status`, background-bash drains) that
|
|
36
|
+
* want to reuse a warm bridge with loaded indexes/LSP state. Returns `null`
|
|
37
|
+
* when no live bridge exists for `projectRoot`; callers typically fall back
|
|
38
|
+
* to {@link BridgePool.getBridge} which will create one. Cross-project bridge
|
|
39
|
+
* sharing is intentionally **not** supported — draining bg-completions or
|
|
40
|
+
* status from another project's bridge mixes session-isolated state.
|
|
41
|
+
*/
|
|
42
|
+
getActiveBridgeForRoot(projectRoot: string): BinaryBridge | null;
|
|
43
|
+
/**
|
|
44
|
+
* Get or create the bridge for `projectRoot`.
|
|
45
|
+
*
|
|
46
|
+
* Callers should always pass a **canonical** project root (see
|
|
47
|
+
* `projectRootFor()` in `tools/_shared.ts`). All sessions operating on the
|
|
48
|
+
* same project share one bridge; their undo/checkpoint state is still
|
|
49
|
+
* isolated by `session_id` on the Rust side.
|
|
50
|
+
*/
|
|
51
|
+
getBridge(projectRoot: string): BinaryBridge;
|
|
52
|
+
/** Shut down idle bridges that haven't been used within the timeout. */
|
|
53
|
+
private cleanup;
|
|
54
|
+
/** Evict the least recently used bridge to make room. */
|
|
55
|
+
private evictLRU;
|
|
56
|
+
/** Shut down all bridges and stop the cleanup timer. */
|
|
57
|
+
shutdown(): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Replace the binary path and restart all bridges.
|
|
60
|
+
* Used after downloading a newer binary version.
|
|
61
|
+
*/
|
|
62
|
+
replaceBinary(newPath: string): Promise<void>;
|
|
63
|
+
/** Number of active bridges in the pool. */
|
|
64
|
+
get size(): number;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAW/D,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,UAAU;IACrB,iEAAiE;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAgC;IACxD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA0B;IAC1D,OAAO,CAAC,YAAY,CAA+C;gBAGjE,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,WAAgB,EACzB,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;IAqB/C;;;;;;;;;OASG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAQhE;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY;IAmB5C,wEAAwE;IACxE,OAAO,CAAC,OAAO;IAUf,yDAAyD;IACzD,OAAO,CAAC,QAAQ;IAgBhB,wDAAwD;IAClD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAU/B;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcnD,4CAA4C;IAC5C,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-protocol types shared between the AFT plugins and the Rust `aft` binary.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the structures defined in `crates/aft/src/protocol.rs`.
|
|
5
|
+
* Tool-specific request/response shapes intentionally stay in plugin code —
|
|
6
|
+
* this module owns only the envelope and the host-relevant push frames so that
|
|
7
|
+
* the transport never needs to know about every command schema.
|
|
8
|
+
*/
|
|
9
|
+
export interface AftRequestEnvelope {
|
|
10
|
+
/** Stable request id, returned in the matching response. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** Bridge command name (e.g. `"bash"`, `"read"`). */
|
|
13
|
+
command: string;
|
|
14
|
+
/** Optional session id; partitions backup/checkpoint state per-session. */
|
|
15
|
+
session_id?: string;
|
|
16
|
+
/** Optional LSP hint payload threaded through edit-time diagnostics. */
|
|
17
|
+
lsp_hints?: unknown;
|
|
18
|
+
/** Tool-specific parameters live alongside the envelope at the top level. */
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface AftSuccessResponse {
|
|
22
|
+
id: string;
|
|
23
|
+
success: true;
|
|
24
|
+
/** Tool-specific result fields live on the same object. */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
export interface AftErrorResponse {
|
|
28
|
+
id: string;
|
|
29
|
+
success: false;
|
|
30
|
+
/** Machine-actionable error code (e.g. `"path_not_found"`). */
|
|
31
|
+
code?: string;
|
|
32
|
+
/** Human-readable error message. */
|
|
33
|
+
message?: string;
|
|
34
|
+
/** Tool-specific error metadata may be attached. */
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
export type AftResponse = AftSuccessResponse | AftErrorResponse;
|
|
38
|
+
/**
|
|
39
|
+
* Server-pushed frames (no client-side `id`). The transport recognises these
|
|
40
|
+
* and dispatches them through {@link BridgeOptions.onPushFrame} rather than
|
|
41
|
+
* matching them against a pending request.
|
|
42
|
+
*/
|
|
43
|
+
export type AftPushFrame = BashCompletedFrame | PermissionAskFrame | ProgressFrame | ConfigureWarningFrame;
|
|
44
|
+
export interface BashCompletedFrame {
|
|
45
|
+
type: "bash_completed";
|
|
46
|
+
task_id: string;
|
|
47
|
+
status: string;
|
|
48
|
+
exit_code: number | null;
|
|
49
|
+
command: string;
|
|
50
|
+
duration_ms?: number;
|
|
51
|
+
runtime_ms?: number;
|
|
52
|
+
runtime?: number;
|
|
53
|
+
output_preview?: string;
|
|
54
|
+
output_truncated?: boolean;
|
|
55
|
+
session_id?: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PermissionAskFrame {
|
|
58
|
+
type: "permission_ask";
|
|
59
|
+
request_id: string;
|
|
60
|
+
prompt: string;
|
|
61
|
+
options?: string[];
|
|
62
|
+
session_id?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface ProgressFrame {
|
|
65
|
+
type: "progress";
|
|
66
|
+
task_id?: string;
|
|
67
|
+
message?: string;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
export interface ConfigureWarningFrame {
|
|
71
|
+
type: "configure_warning";
|
|
72
|
+
code?: string;
|
|
73
|
+
message: string;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Background-bash completion record carried in `bash_drain_completions`
|
|
78
|
+
* responses and `bash_completed` push frames. Plugins consume this through
|
|
79
|
+
* their own bg-notification machinery.
|
|
80
|
+
*/
|
|
81
|
+
export interface BgCompletion {
|
|
82
|
+
task_id: string;
|
|
83
|
+
status: string;
|
|
84
|
+
exit_code: number | null;
|
|
85
|
+
command: string;
|
|
86
|
+
duration_ms?: number;
|
|
87
|
+
runtime_ms?: number;
|
|
88
|
+
runtime?: number;
|
|
89
|
+
/** Tail of stdout+stderr captured at completion (≤300 bytes from Rust). */
|
|
90
|
+
output_preview?: string;
|
|
91
|
+
/** True when the captured tail is shorter than the actual output. */
|
|
92
|
+
output_truncated?: boolean;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,kBAAkB;IACjC,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAC;IACX,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6EAA6E;IAC7E,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,IAAI,CAAC;IACd,2DAA2D;IAC3D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,KAAK,CAAC;IACf,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GACpB,kBAAkB,GAClB,kBAAkB,GAClB,aAAa,GACb,qBAAqB,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map the current `process.platform` and `process.arch` to the npm platform
|
|
3
|
+
* package suffix (e.g. `"darwin-arm64"`, `"linux-x64"`).
|
|
4
|
+
*
|
|
5
|
+
* Exported for testability — agents and scripts can call this directly to
|
|
6
|
+
* verify the platform mapping without running the full resolver.
|
|
7
|
+
*
|
|
8
|
+
* @throws {Error} with the exact `process.platform` and `process.arch` values
|
|
9
|
+
* when the combination is unsupported.
|
|
10
|
+
*/
|
|
11
|
+
export declare function platformKey(platform?: string, arch?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Locate the `aft` binary synchronously by checking (in order):
|
|
14
|
+
* 1. Cached binary from previous auto-download (~/.cache/aft/bin/)
|
|
15
|
+
* 2. npm platform package via `require.resolve(@cortexkit/aft-<platform>/bin/aft)`
|
|
16
|
+
* 3. PATH lookup via `which aft` (or `where aft` on Windows)
|
|
17
|
+
* 4. ~/.cargo/bin/aft (Rust cargo install location)
|
|
18
|
+
*
|
|
19
|
+
* @param expectedVersion Optional version (without `v` prefix) — when set, the
|
|
20
|
+
* versioned cache for that version is checked first. Hosts that ship in
|
|
21
|
+
* lock-step with the binary should pass their own package version so a
|
|
22
|
+
* freshly downloaded binary is picked up before fallback resolution.
|
|
23
|
+
* @returns Absolute path to the first binary found, or null if none found.
|
|
24
|
+
*/
|
|
25
|
+
export declare function findBinarySync(expectedVersion?: string): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Locate the `aft` binary, with auto-download as a last resort.
|
|
28
|
+
*
|
|
29
|
+
* Resolution order:
|
|
30
|
+
* 1. Cached binary (~/.cache/aft/bin/)
|
|
31
|
+
* 2. npm platform package (@cortexkit/aft-<platform>)
|
|
32
|
+
* 3. PATH lookup (which aft)
|
|
33
|
+
* 4. ~/.cargo/bin/aft
|
|
34
|
+
* 5. Auto-download from GitHub releases
|
|
35
|
+
*
|
|
36
|
+
* Returns the absolute path to the binary.
|
|
37
|
+
* Throws a descriptive error with install instructions if all sources fail.
|
|
38
|
+
*/
|
|
39
|
+
export declare function findBinary(expectedVersion?: string): Promise<string>;
|
|
40
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAoDA;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,QAAQ,GAAE,MAAyB,EACnC,IAAI,GAAE,MAAqB,GAC1B,MAAM,CAgBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsDtE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAiC1E"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cortexkit/aft-bridge",
|
|
3
|
+
"version": "0.18.5",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Shared NDJSON bridge transport, binary resolution, and ONNX runtime helpers for AFT agent-host plugins (OpenCode, Pi)",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/cortexkit/aft"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"module": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "bun build src/index.ts --outfile dist/index.js --target node --format esm --external '@cortexkit/aft-*' && tsc --emitDeclarationOnly",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"test": "bun test",
|
|
29
|
+
"prepublishOnly": "bun run build"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
33
|
+
"typescript": "^5.8.0"
|
|
34
|
+
}
|
|
35
|
+
}
|