@cortexkit/aft-opencode 0.18.4 → 0.19.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/bg-notifications.d.ts.map +1 -1
- package/dist/configure-warnings.d.ts +31 -0
- package/dist/configure-warnings.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18049 -17794
- package/dist/logger.d.ts +18 -0
- package/dist/logger.d.ts.map +1 -1
- package/dist/notifications.d.ts.map +1 -1
- package/dist/shared/last-assistant-model.d.ts +51 -0
- package/dist/shared/last-assistant-model.d.ts.map +1 -0
- package/dist/shared/session-directory.d.ts +32 -0
- package/dist/shared/session-directory.d.ts.map +1 -0
- package/dist/tools/_shared.d.ts +26 -4
- package/dist/tools/_shared.d.ts.map +1 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/hoisted.d.ts +9 -1
- package/dist/tools/hoisted.d.ts.map +1 -1
- package/dist/tools/reading.d.ts +8 -2
- package/dist/tools/reading.d.ts.map +1 -1
- package/dist/tui.js +7 -6
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/workflow-hints.d.ts.map +1 -1
- package/package.json +7 -6
- package/src/logger.ts +19 -0
- package/src/shared/last-assistant-model.ts +179 -0
- package/src/shared/session-directory.ts +152 -0
- package/dist/bridge.d.ts +0 -122
- package/dist/bridge.d.ts.map +0 -1
- package/dist/downloader.d.ts +0 -35
- package/dist/downloader.d.ts.map +0 -1
- package/dist/onnx-runtime.d.ts +0 -53
- package/dist/onnx-runtime.d.ts.map +0 -1
- package/dist/platform.d.ts +0 -21
- package/dist/platform.d.ts.map +0 -1
- package/dist/pool.d.ts +0 -66
- package/dist/pool.d.ts.map +0 -1
- package/dist/resolver.d.ts +0 -36
- package/dist/resolver.d.ts.map +0 -1
- package/dist/shared/last-user-model.d.ts +0 -38
- package/dist/shared/last-user-model.d.ts.map +0 -1
- package/dist/shared/url-fetch.d.ts +0 -33
- package/dist/shared/url-fetch.d.ts.map +0 -1
- package/src/shared/last-user-model.ts +0 -133
- package/src/shared/url-fetch.ts +0 -465
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workaround for OpenCode's session-directory bug: when a user runs
|
|
3
|
+
* `opencode -s <sessionID>` (or otherwise resumes a session) from a
|
|
4
|
+
* directory other than the session's original project directory,
|
|
5
|
+
* OpenCode's tool registry sets `ctx.directory = process.cwd()` for
|
|
6
|
+
* every tool call instead of the session's stored directory.
|
|
7
|
+
*
|
|
8
|
+
* That breaks every plugin that does workspace-scoped work — including
|
|
9
|
+
* AFT, where it caused configure to spin up against the user's home
|
|
10
|
+
* directory and time out trying to index hundreds of thousands of
|
|
11
|
+
* unrelated files.
|
|
12
|
+
*
|
|
13
|
+
* The session itself stores the correct directory in OpenCode's SQLite
|
|
14
|
+
* (`Session.directory` in the SDK). This helper looks it up once per
|
|
15
|
+
* session and caches the result — sessions don't change directory
|
|
16
|
+
* across their lifetime, so the cache never needs invalidation.
|
|
17
|
+
*
|
|
18
|
+
* The bug should also be fixed upstream in OpenCode's
|
|
19
|
+
* `packages/opencode/src/session/registry.ts`. Until then this
|
|
20
|
+
* workaround makes AFT robust against the wrong cwd.
|
|
21
|
+
*/
|
|
22
|
+
import { sessionWarn } from "../logger.js";
|
|
23
|
+
|
|
24
|
+
interface SessionInfo {
|
|
25
|
+
directory?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface OpenCodeClientShape {
|
|
29
|
+
session?: {
|
|
30
|
+
get?: (input: {
|
|
31
|
+
sessionID: string;
|
|
32
|
+
directory?: string;
|
|
33
|
+
}) => Promise<{ data?: SessionInfo } | SessionInfo | undefined>;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface CacheEntry {
|
|
38
|
+
/** Resolved directory, or `null` if lookup failed and we should not retry. */
|
|
39
|
+
directory: string | null;
|
|
40
|
+
/** Wall-clock timestamp of the cache entry, used only for LRU eviction. */
|
|
41
|
+
recordedAt: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const CACHE_MAX_ENTRIES = 200;
|
|
45
|
+
const cache = new Map<string, CacheEntry>();
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the project directory the session was created with. Returns
|
|
49
|
+
* `null` when the lookup is unavailable or fails — callers should fall
|
|
50
|
+
* back to the runtime's directory in that case.
|
|
51
|
+
*
|
|
52
|
+
* This function is best-effort: any error (missing `client.session.get`,
|
|
53
|
+
* network failure, malformed response) is logged and recorded as a
|
|
54
|
+
* negative cache entry so we don't retry on every tool call within the
|
|
55
|
+
* same session.
|
|
56
|
+
*/
|
|
57
|
+
export async function getSessionDirectory(
|
|
58
|
+
client: unknown,
|
|
59
|
+
sessionId: string,
|
|
60
|
+
fallbackDirectory: string,
|
|
61
|
+
): Promise<string | null> {
|
|
62
|
+
if (!sessionId) return null;
|
|
63
|
+
|
|
64
|
+
const cached = cache.get(sessionId);
|
|
65
|
+
if (cached) {
|
|
66
|
+
// Refresh LRU position
|
|
67
|
+
cache.delete(sessionId);
|
|
68
|
+
cache.set(sessionId, cached);
|
|
69
|
+
return cached.directory;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const c = client as OpenCodeClientShape;
|
|
73
|
+
const sessionApi = c?.session;
|
|
74
|
+
if (!sessionApi || typeof sessionApi.get !== "function") {
|
|
75
|
+
setCache(sessionId, null);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let dir: string | null = null;
|
|
80
|
+
try {
|
|
81
|
+
// Call as a method so the SDK's `this._client` reference resolves
|
|
82
|
+
// correctly. Extracting `c.session.get` into a local would lose the
|
|
83
|
+
// binding and crash the SDK with "undefined is not an object".
|
|
84
|
+
const result = await sessionApi.get({ sessionID: sessionId, directory: fallbackDirectory });
|
|
85
|
+
// SDK responses come either as `{ data: Session }` or directly as `Session`
|
|
86
|
+
// depending on `ThrowOnError`. Handle both shapes.
|
|
87
|
+
const session: SessionInfo | undefined =
|
|
88
|
+
(result as { data?: SessionInfo } | undefined)?.data ?? (result as SessionInfo | undefined);
|
|
89
|
+
if (session && typeof session.directory === "string" && session.directory.length > 0) {
|
|
90
|
+
dir = session.directory;
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
// Don't poison the cache on transient errors — but do log once.
|
|
94
|
+
sessionWarn(
|
|
95
|
+
sessionId,
|
|
96
|
+
`[aft-plugin] session.get lookup failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
97
|
+
);
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setCache(sessionId, dir);
|
|
102
|
+
return dir;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function setCache(sessionId: string, directory: string | null): void {
|
|
106
|
+
if (cache.has(sessionId)) cache.delete(sessionId);
|
|
107
|
+
cache.set(sessionId, { directory, recordedAt: Date.now() });
|
|
108
|
+
if (cache.size > CACHE_MAX_ENTRIES) {
|
|
109
|
+
const oldest = cache.keys().next().value;
|
|
110
|
+
if (oldest !== undefined) cache.delete(oldest);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Synchronous cache probe. Returns the resolved directory for a session if we
|
|
116
|
+
* already looked it up; otherwise `undefined` so the caller falls through to
|
|
117
|
+
* its synchronous fallback (typically `runtime.directory`).
|
|
118
|
+
*
|
|
119
|
+
* This is the hot path: `bridgeFor()` runs on every tool call and must not
|
|
120
|
+
* block on an SDK round-trip. The async {@link warmSessionDirectory} should
|
|
121
|
+
* be called eagerly (without await) at the start of each tool call to keep
|
|
122
|
+
* the cache filled, so by the time a second call from the same session
|
|
123
|
+
* arrives, this probe returns the correct directory.
|
|
124
|
+
*/
|
|
125
|
+
export function getSessionDirectoryCached(
|
|
126
|
+
sessionId: string | undefined,
|
|
127
|
+
): string | null | undefined {
|
|
128
|
+
if (!sessionId) return undefined;
|
|
129
|
+
const cached = cache.get(sessionId);
|
|
130
|
+
if (!cached) return undefined;
|
|
131
|
+
return cached.directory;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Fire-and-forget cache warmup. Safe to call from synchronous code; failures
|
|
136
|
+
* are logged but not propagated. Subsequent calls to {@link getSessionDirectoryCached}
|
|
137
|
+
* will return the resolved directory once the lookup completes.
|
|
138
|
+
*/
|
|
139
|
+
export function warmSessionDirectory(
|
|
140
|
+
client: unknown,
|
|
141
|
+
sessionId: string | undefined,
|
|
142
|
+
fallbackDirectory: string,
|
|
143
|
+
): void {
|
|
144
|
+
if (!sessionId) return;
|
|
145
|
+
if (cache.has(sessionId)) return;
|
|
146
|
+
void getSessionDirectory(client, sessionId, fallbackDirectory);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Test-only: clear the cache between unit tests. */
|
|
150
|
+
export function _resetSessionDirectoryCacheForTest(): void {
|
|
151
|
+
cache.clear();
|
|
152
|
+
}
|
package/dist/bridge.d.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { BgCompletion } from "./bg-notifications.js";
|
|
2
|
-
/**
|
|
3
|
-
* Compare two semver version strings (major.minor.patch plus pre-release).
|
|
4
|
-
* Returns: negative if a < b, 0 if equal, positive if a > b.
|
|
5
|
-
*/
|
|
6
|
-
export declare function compareSemver(a: string, b: string): number;
|
|
7
|
-
interface ConfigureWarningsContext {
|
|
8
|
-
projectRoot: string;
|
|
9
|
-
sessionId?: string;
|
|
10
|
-
client?: unknown;
|
|
11
|
-
warnings: unknown[];
|
|
12
|
-
}
|
|
13
|
-
export interface BridgeOptions {
|
|
14
|
-
/** Request timeout in milliseconds. Default: 30000 */
|
|
15
|
-
timeoutMs?: number;
|
|
16
|
-
/** Maximum restart attempts before giving up. Default: 3 */
|
|
17
|
-
maxRestarts?: number;
|
|
18
|
-
/** Minimum binary version required (semver). If the binary is older, onVersionMismatch is called. */
|
|
19
|
-
minVersion?: string;
|
|
20
|
-
/** Called when binary version is older than minVersion. Receives (binaryVersion, minVersion). */
|
|
21
|
-
onVersionMismatch?: (binaryVersion: string, minVersion: string) => void;
|
|
22
|
-
/** Called after the first successful configure returns user-visible warnings. */
|
|
23
|
-
onConfigureWarnings?: (context: ConfigureWarningsContext) => void | Promise<void>;
|
|
24
|
-
/** Called for server-pushed background bash completions. */
|
|
25
|
-
onBashCompletion?: (completion: BashCompletedPayload, bridge: BinaryBridge) => void | Promise<void>;
|
|
26
|
-
}
|
|
27
|
-
export interface BashCompletedPayload extends BgCompletion {
|
|
28
|
-
type: "bash_completed";
|
|
29
|
-
session_id: string;
|
|
30
|
-
}
|
|
31
|
-
export interface BridgeRequestOptions {
|
|
32
|
-
onProgress?: (chunk: {
|
|
33
|
-
kind: "stdout" | "stderr";
|
|
34
|
-
text: string;
|
|
35
|
-
}) => void;
|
|
36
|
-
/** Per-call transport timeout in milliseconds. Defaults to the bridge-wide timeout. */
|
|
37
|
-
transportTimeoutMs?: number;
|
|
38
|
-
/**
|
|
39
|
-
* Skip the "kill the child process on timeout" behavior for this request.
|
|
40
|
-
*
|
|
41
|
-
* The default (false) treats a transport-level timeout as evidence the bridge
|
|
42
|
-
* is wedged — Rust normally responds well within the budget, so silence past
|
|
43
|
-
* the deadline almost always means a stuck child. Killing forces a clean
|
|
44
|
-
* respawn on the next call.
|
|
45
|
-
*
|
|
46
|
-
* Some commands enforce their own timeouts on the Rust side (notably `bash`,
|
|
47
|
-
* which uses a watchdog thread to terminate the child shell and return a
|
|
48
|
-
* timeout response). For those, a transport timeout means the response was
|
|
49
|
-
* lost or queued behind something else — the bridge itself is still healthy
|
|
50
|
-
* and should keep its warm state (LSP servers, semantic index, callers
|
|
51
|
-
* cache, undo history). Pass `keepBridgeOnTimeout: true` to reject the
|
|
52
|
-
* request without tearing down the bridge.
|
|
53
|
-
*/
|
|
54
|
-
keepBridgeOnTimeout?: boolean;
|
|
55
|
-
}
|
|
56
|
-
interface SendOptions extends BridgeRequestOptions {
|
|
57
|
-
timeoutMs?: number;
|
|
58
|
-
configureWarningClient?: unknown;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Manages a persistent `aft` child process, communicating via NDJSON over
|
|
62
|
-
* stdin/stdout. Lazy-spawns on first `send()` call. Handles crash detection
|
|
63
|
-
* with exponential backoff auto-restart.
|
|
64
|
-
*/
|
|
65
|
-
export declare class BinaryBridge {
|
|
66
|
-
private static readonly RESTART_RESET_MS;
|
|
67
|
-
/** How many recent stderr lines to keep for crash diagnostics. */
|
|
68
|
-
private static readonly STDERR_TAIL_MAX;
|
|
69
|
-
private binaryPath;
|
|
70
|
-
private cwd;
|
|
71
|
-
private process;
|
|
72
|
-
private pending;
|
|
73
|
-
private nextId;
|
|
74
|
-
private stdoutBuffer;
|
|
75
|
-
/** Ring buffer of the last N stderr lines, cleared on every spawn. */
|
|
76
|
-
private stderrTail;
|
|
77
|
-
private _restartCount;
|
|
78
|
-
private _shuttingDown;
|
|
79
|
-
private timeoutMs;
|
|
80
|
-
private maxRestarts;
|
|
81
|
-
private configured;
|
|
82
|
-
private _configurePromise;
|
|
83
|
-
private configOverrides;
|
|
84
|
-
private minVersion;
|
|
85
|
-
private onVersionMismatch;
|
|
86
|
-
private onConfigureWarnings;
|
|
87
|
-
private onBashCompletion;
|
|
88
|
-
private restartResetTimer;
|
|
89
|
-
constructor(binaryPath: string, cwd: string, options?: BridgeOptions, configOverrides?: Record<string, unknown>);
|
|
90
|
-
/** Number of times the binary has been restarted after a crash. */
|
|
91
|
-
get restartCount(): number;
|
|
92
|
-
/** Whether the child process is currently alive. */
|
|
93
|
-
isAlive(): boolean;
|
|
94
|
-
hasPendingRequests(): boolean;
|
|
95
|
-
/**
|
|
96
|
-
* Send a command to the binary and return the parsed response.
|
|
97
|
-
* Lazy-spawns the binary on first call.
|
|
98
|
-
*/
|
|
99
|
-
send(command: string, params?: Record<string, unknown>, options?: SendOptions): Promise<Record<string, unknown>>;
|
|
100
|
-
private deliverConfigureWarnings;
|
|
101
|
-
/** Kill the child process and reject all pending requests. */
|
|
102
|
-
shutdown(): Promise<void>;
|
|
103
|
-
/** Query binary version and compare against minVersion. Calls onVersionMismatch if outdated. */
|
|
104
|
-
private checkVersion;
|
|
105
|
-
private ensureSpawned;
|
|
106
|
-
private spawnProcess;
|
|
107
|
-
private pushStderrLine;
|
|
108
|
-
/**
|
|
109
|
-
* Format the current stderr tail for inclusion in error messages. Returns
|
|
110
|
-
* empty string when nothing has been captured (e.g., silent SIGKILL from
|
|
111
|
-
* macOS amfid) so the caller can safely concatenate unconditionally.
|
|
112
|
-
*/
|
|
113
|
-
private formatStderrTail;
|
|
114
|
-
private onStdoutData;
|
|
115
|
-
private handleTimeout;
|
|
116
|
-
private handleCrash;
|
|
117
|
-
private rejectAllPending;
|
|
118
|
-
private scheduleRestartCountReset;
|
|
119
|
-
private clearRestartResetTimer;
|
|
120
|
-
}
|
|
121
|
-
export {};
|
|
122
|
-
//# sourceMappingURL=bridge.d.ts.map
|
package/dist/bridge.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"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"}
|
package/dist/downloader.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-download the AFT binary from GitHub releases.
|
|
3
|
-
*
|
|
4
|
-
* Resolution order (in resolver.ts):
|
|
5
|
-
* 1. Cached binary in ~/.cache/aft/bin/
|
|
6
|
-
* 2. npm platform package (@cortexkit/aft-darwin-arm64, etc.)
|
|
7
|
-
* 3. PATH lookup (which aft)
|
|
8
|
-
* 4. ~/.cargo/bin/aft
|
|
9
|
-
* 5. Auto-download from GitHub releases (this module)
|
|
10
|
-
*
|
|
11
|
-
* Cache dir respects XDG_CACHE_HOME on Linux/macOS and LOCALAPPDATA on Windows.
|
|
12
|
-
*/
|
|
13
|
-
/** Get the cache directory, respecting XDG_CACHE_HOME / LOCALAPPDATA. */
|
|
14
|
-
export declare function getCacheDir(): string;
|
|
15
|
-
/** Binary name for the current platform. */
|
|
16
|
-
export declare function getBinaryName(): string;
|
|
17
|
-
/** Return the cached binary path if it exists, otherwise null.
|
|
18
|
-
* Checks the version-specific cache directory only.
|
|
19
|
-
* The legacy flat cache (~/.cache/aft/bin/aft) is intentionally NOT checked
|
|
20
|
-
* because it can be overwritten by other instances, corrupting running processes. */
|
|
21
|
-
export declare function getCachedBinaryPath(version?: string): string | null;
|
|
22
|
-
/**
|
|
23
|
-
* Download the AFT binary for the current platform from GitHub releases.
|
|
24
|
-
*
|
|
25
|
-
* @param version - Git tag to download from (e.g. "v0.1.0"). If omitted,
|
|
26
|
-
* fetches the latest release tag via the GitHub API.
|
|
27
|
-
* @returns Absolute path to the downloaded binary, or null on failure.
|
|
28
|
-
*/
|
|
29
|
-
export declare function downloadBinary(version?: string): Promise<string | null>;
|
|
30
|
-
/**
|
|
31
|
-
* Ensure the AFT binary is available: check cache, then download if needed.
|
|
32
|
-
* This is the main entry point called by the resolver.
|
|
33
|
-
*/
|
|
34
|
-
export declare function ensureBinary(version?: string): Promise<string | null>;
|
|
35
|
-
//# sourceMappingURL=downloader.d.ts.map
|
package/dist/downloader.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"downloader.d.ts","sourceRoot":"","sources":["../src/downloader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,yEAAyE;AACzE,wBAAgB,WAAW,IAAI,MAAM,CASpC;AAED,4CAA4C;AAC5C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;sFAGsF;AACtF,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAInE;AAED;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgH7E;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB3E"}
|
package/dist/onnx-runtime.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/platform.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
package/dist/platform.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { BinaryBridge, type BridgeOptions } from "./bridge";
|
|
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 any existing bridge that is configured and alive, preferring one that
|
|
34
|
-
* matches the given project root.
|
|
35
|
-
*
|
|
36
|
-
* Used by `/aft-status` and similar read-only paths that want to reuse a
|
|
37
|
-
* warm bridge (with loaded semantic indexes etc.) instead of paying the
|
|
38
|
-
* cold-start cost on a cheap query.
|
|
39
|
-
*/
|
|
40
|
-
getAnyActiveBridge(projectRoot: string): BinaryBridge | null;
|
|
41
|
-
/** Get an alive bridge only when it belongs to the requested project root. */
|
|
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
|
package/dist/pool.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../src/pool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAY5D,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;;;;;;;OAOG;IACH,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAgB5D,8EAA8E;IAC9E,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"}
|
package/dist/resolver.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
* Returns the absolute path to the first binary found, or null if none found.
|
|
20
|
-
*/
|
|
21
|
-
export declare function findBinarySync(): string | null;
|
|
22
|
-
/**
|
|
23
|
-
* Locate the `aft` binary, with auto-download as a last resort.
|
|
24
|
-
*
|
|
25
|
-
* Resolution order:
|
|
26
|
-
* 1. Cached binary (~/.cache/aft/bin/)
|
|
27
|
-
* 2. npm platform package (@cortexkit/aft-<platform>)
|
|
28
|
-
* 3. PATH lookup (which aft)
|
|
29
|
-
* 4. ~/.cargo/bin/aft
|
|
30
|
-
* 5. Auto-download from GitHub releases
|
|
31
|
-
*
|
|
32
|
-
* Returns the absolute path to the binary.
|
|
33
|
-
* Throws a descriptive error with install instructions if all sources fail.
|
|
34
|
-
*/
|
|
35
|
-
export declare function findBinary(): Promise<string>;
|
|
36
|
-
//# sourceMappingURL=resolver.d.ts.map
|
package/dist/resolver.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAiD9C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAiClD"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Cache-busting fix: every PromptInput we send to OpenCode starts a new
|
|
3
|
-
* assistant turn (via `noReply: false`) or stores a new user message
|
|
4
|
-
* (via `noReply: true`). OpenCode's `createUserMessage` (in
|
|
5
|
-
* `packages/opencode/src/session/prompt.ts`) only preserves the user's
|
|
6
|
-
* model variant if we pass it explicitly — otherwise it falls back to
|
|
7
|
-
* `agent.variant` or undefined, silently switching the next assistant
|
|
8
|
-
* turn off the variant the human chose. That switch evicts the
|
|
9
|
-
* provider's prefix cache on every notification.
|
|
10
|
-
*
|
|
11
|
-
* This module fetches the last real user message's `{ providerID,
|
|
12
|
-
* modelID, variant }` and exposes it so prompt callers can include it
|
|
13
|
-
* verbatim in `PromptInput.model` + `PromptInput.variant`. Results are
|
|
14
|
-
* memoised per session for a short window so a batch of warnings or
|
|
15
|
-
* bg-completions only hits the messages API once.
|
|
16
|
-
*/
|
|
17
|
-
export interface LastUserModel {
|
|
18
|
-
providerID: string;
|
|
19
|
-
modelID: string;
|
|
20
|
-
variant?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Returns the most recent real user message's model + variant for the
|
|
24
|
-
* session, or `null` when the session has no user messages or the
|
|
25
|
-
* client doesn't expose `session.messages`. Result is cached for
|
|
26
|
-
* {@link CACHE_TTL_MS} ms per session — long enough to coalesce a
|
|
27
|
-
* batch of notifications, short enough that an actual variant change
|
|
28
|
-
* inside the conversation is picked up promptly.
|
|
29
|
-
*
|
|
30
|
-
* NOTE: Skips synthetic user messages we just produced ourselves
|
|
31
|
-
* (those whose only parts are `ignored: true`). Otherwise our own
|
|
32
|
-
* announcement could pin the variant after a single round-trip and
|
|
33
|
-
* defeat the fix.
|
|
34
|
-
*/
|
|
35
|
-
export declare function getLastUserModel(client: unknown, sessionId: string): Promise<LastUserModel | null>;
|
|
36
|
-
/** Test-only: drop the cache so unit tests can simulate fresh sessions. */
|
|
37
|
-
export declare function __resetLastUserModelCacheForTests(): void;
|
|
38
|
-
//# sourceMappingURL=last-user-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"last-user-model.d.ts","sourceRoot":"","sources":["../../src/shared/last-user-model.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAwBH,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA0C/B;AAiBD,2EAA2E;AAC3E,wBAAgB,iCAAiC,IAAI,IAAI,CAExD"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { lookup } from "node:dns/promises";
|
|
2
|
-
import { type Dispatcher } from "undici";
|
|
3
|
-
interface FetchUrlOptions {
|
|
4
|
-
allowPrivate?: boolean;
|
|
5
|
-
/** Test-only injection point. Production fetches use undici with DNS pinning. */
|
|
6
|
-
fetchImpl?: FetchImpl;
|
|
7
|
-
/** Test-only injection point. Production DNS resolution uses node:dns/promises.lookup. */
|
|
8
|
-
lookup?: LookupFn;
|
|
9
|
-
/** Test-only injection point for observing the DNS-pinned dispatcher. */
|
|
10
|
-
dispatcherFactory?: (validatedIp: string) => Dispatcher;
|
|
11
|
-
}
|
|
12
|
-
type LookupFn = typeof lookup;
|
|
13
|
-
interface FetchInit {
|
|
14
|
-
signal?: AbortSignal;
|
|
15
|
-
redirect?: "manual";
|
|
16
|
-
dispatcher?: Dispatcher;
|
|
17
|
-
headers?: Record<string, string>;
|
|
18
|
-
}
|
|
19
|
-
type FetchImpl = (input: string, init: FetchInit) => Promise<Response>;
|
|
20
|
-
/** Exported for unit tests. */
|
|
21
|
-
export declare function _isPrivateIpv4(address: string): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Fetch a URL to a cached temp file. Uses disk cache with 1-day TTL.
|
|
24
|
-
* Returns the cached file path the Rust outline/zoom command can read.
|
|
25
|
-
* Throws on errors (invalid URL, network failure, unsupported content type, oversized body).
|
|
26
|
-
*/
|
|
27
|
-
export declare function fetchUrlToTempFile(url: string, storageDir: string, options?: FetchUrlOptions): Promise<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Remove cache entries older than TTL. Called periodically at plugin startup.
|
|
30
|
-
*/
|
|
31
|
-
export declare function cleanupUrlCache(storageDir: string): void;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=url-fetch.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"url-fetch.d.ts","sourceRoot":"","sources":["../../src/shared/url-fetch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAW3C,OAAO,EAAS,KAAK,UAAU,EAAwB,MAAM,QAAQ,CAAC;AAWtE,UAAU,eAAe;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,UAAU,CAAC;CACzD;AAED,KAAK,QAAQ,GAAG,OAAO,MAAM,CAAC;AAC9B,UAAU,SAAS;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAyBvE,+BAA+B;AAC/B,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAavD;AAgPD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAgGjB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAkCxD"}
|