@cortexkit/aft-opencode 0.58.0 → 0.58.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.
- package/dist/bridge-bootstrap.d.ts +8 -0
- package/dist/bridge-bootstrap.d.ts.map +1 -1
- package/dist/config-live-reload.d.ts +323 -0
- package/dist/config-live-reload.d.ts.map +1 -0
- package/dist/config.d.ts +59 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/entry/server.js +2543 -989
- package/dist/hashline-tag-sources.d.ts +18 -0
- package/dist/hashline-tag-sources.d.ts.map +1 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +1 -0
- package/dist/hooks/auto-update-checker/checker.d.ts.map +1 -1
- package/dist/hooks/auto-update-checker/index.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1901 -748
- package/dist/lsp-auto-install.d.ts +30 -0
- package/dist/lsp-auto-install.d.ts.map +1 -1
- package/dist/lsp-github-table.d.ts +4 -3
- package/dist/lsp-github-table.d.ts.map +1 -1
- package/dist/lsp-npm-table.d.ts +11 -1
- package/dist/lsp-npm-table.d.ts.map +1 -1
- package/dist/lsp-registry-probe.d.ts +8 -4
- package/dist/lsp-registry-probe.d.ts.map +1 -1
- package/dist/permissions/v2-service.d.ts +110 -5
- package/dist/permissions/v2-service.d.ts.map +1 -1
- package/dist/rpc/register.d.ts +0 -4
- package/dist/rpc/register.d.ts.map +1 -1
- package/dist/shared/read-vision.d.ts +10 -0
- package/dist/shared/read-vision.d.ts.map +1 -0
- package/dist/shared/session-directory.d.ts +7 -0
- package/dist/shared/session-directory.d.ts.map +1 -1
- package/dist/shared/subagent-detect.d.ts +11 -4
- package/dist/shared/subagent-detect.d.ts.map +1 -1
- package/dist/tool-perf.d.ts +1 -0
- package/dist/tool-perf.d.ts.map +1 -1
- package/dist/tool-registration.d.ts +8 -5
- package/dist/tool-registration.d.ts.map +1 -1
- package/dist/tools/_shared.d.ts +16 -15
- package/dist/tools/_shared.d.ts.map +1 -1
- package/dist/tools/bash.d.ts +24 -1
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash_watch.d.ts +5 -2
- package/dist/tools/bash_watch.d.ts.map +1 -1
- package/dist/tools/bash_write.d.ts.map +1 -1
- package/dist/tools/definitions/v2.d.ts +2 -0
- package/dist/tools/definitions/v2.d.ts.map +1 -1
- package/dist/tools/hoisted/v2.d.ts +8 -1
- package/dist/tools/hoisted/v2.d.ts.map +1 -1
- package/dist/tools/hoisted.d.ts +9 -7
- package/dist/tools/hoisted.d.ts.map +1 -1
- package/dist/tools/permissions.d.ts.map +1 -1
- package/dist/tools/reading.d.ts +0 -3
- package/dist/tools/reading.d.ts.map +1 -1
- package/dist/v2-prompt-detach.d.ts +69 -0
- package/dist/v2-prompt-detach.d.ts.map +1 -0
- package/dist/wakes/runtime-consumer.d.ts +2 -0
- package/dist/wakes/runtime-consumer.d.ts.map +1 -1
- package/dist/wakes/session-delivery.d.ts +9 -0
- package/dist/wakes/session-delivery.d.ts.map +1 -1
- package/dist/workflow-hints.d.ts +20 -7
- package/dist/workflow-hints.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/entry/server-runtime.mjs +36 -5
- package/src/shared/read-vision.ts +100 -0
- package/src/shared/session-directory.ts +92 -0
- package/src/shared/subagent-detect.ts +89 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../../src/tools/definitions/v2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkBhC,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,SAAS,CAA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AC;AAE3D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG;QAC3C,QAAQ,EAAE,KAAK,CAAC;KACjB,CAAC;IACF,OAAO,CACL,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;CACpD;AA4OD,2EAA2E;AAC3E,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,cAAc,EAC1B,QAAQ,EAAE,UAAU,EACpB,SAAS,GAAE,eAAoB,GAC9B,cAAc,CAqChB;AAED,wFAAwF;AACxF,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,cAAc,GAAG,MAAM,CAwBhG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type V2PermissionHostContext } from "../../permissions/v2.js";
|
|
2
|
-
import { type V2PromptChannel } from "../../permissions/v2-service.js";
|
|
2
|
+
import { type V2PromptChannel, type V2PromptServerSettings } from "../../permissions/v2-service.js";
|
|
3
3
|
import type { V2ToolConsumers } from "../definitions/v2.js";
|
|
4
4
|
export declare const V2_BUILTIN_REPLACEMENTS: readonly ["read", "edit", "write", "apply_patch"];
|
|
5
5
|
export declare const V2_AFT_FILESYSTEM_TOOLS: readonly ["aft_delete", "aft_move"];
|
|
@@ -15,4 +15,11 @@ export declare const V2_PERMISSION_ASK_INVENTORY: readonly ["read", "edit", "wri
|
|
|
15
15
|
* dropped with these consumers when the Location scope ends.
|
|
16
16
|
*/
|
|
17
17
|
export declare function hoistedV2ToolConsumers(host: V2PermissionHostContext | object, prompt?: V2PromptChannel): V2ToolConsumers;
|
|
18
|
+
/**
|
|
19
|
+
* The prompt channel for a Location, honoring the user's `opencode` setting.
|
|
20
|
+
*
|
|
21
|
+
* The setting is the user-tier `opencode` block of the AFT config the Location
|
|
22
|
+
* booted with; a project config cannot supply it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function v2PromptChannelFor(settings: V2PromptServerSettings | undefined): V2PromptChannel;
|
|
18
25
|
//# sourceMappingURL=v2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../../src/tools/hoisted/v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,
|
|
1
|
+
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../../src/tools/hoisted/v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,uBAAuB,mDAAoD,CAAC;AACzF,eAAO,MAAM,uBAAuB,qCAAsC,CAAC;AAE3E,eAAO,MAAM,2BAA2B,8HAS9B,CAAC;AAQX;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,uBAAuB,GAAG,MAAM,EACtC,MAAM,GAAE,eAAyC,GAChD,eAAe,CAMjB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,GAAG,eAAe,CAEhG"}
|
package/dist/tools/hoisted.d.ts
CHANGED
|
@@ -20,14 +20,16 @@ export declare const _buildUnifiedDiffForTest: (fp: string, before: string, afte
|
|
|
20
20
|
export declare function createReadTool(ctx: PluginContext): ToolDefinition;
|
|
21
21
|
/**
|
|
22
22
|
* Returns AFT's host-slot tools keyed by the host's built-in names, plus the
|
|
23
|
-
* move/delete tools and the bash companions.
|
|
23
|
+
* move/delete tools and, while `bash.background` is on, the bash companions.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
25
|
+
* `buildAftToolDefinitions` then removes the names listed in the resolved
|
|
26
|
+
* `disabled_tools`. The bash companions (`bash_status`, `bash_write`,
|
|
27
|
+
* `bash_watch`, `bash_kill`) are independent of `bash` itself: disabling
|
|
28
|
+
* `bash` does not remove them, and when the bash runtime gate (`bash.enabled`)
|
|
29
|
+
* is off every bash operation reports `bash_disabled` instead of disappearing.
|
|
30
|
+
* They exist only to inspect, wait on, feed and stop background tasks, so with
|
|
31
|
+
* `bash.background` off, when no background task can exist, they are not
|
|
32
|
+
* registered at all.
|
|
31
33
|
*/
|
|
32
34
|
export declare function hoistedTools(ctx: PluginContext): Record<string, ToolDefinition>;
|
|
33
35
|
//# sourceMappingURL=hoisted.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hoisted.d.ts","sourceRoot":"","sources":["../../src/tools/hoisted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"hoisted.d.ts","sourceRoot":"","sources":["../../src/tools/hoisted.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,OAAO,KAAK,EAAe,cAAc,EAAc,MAAM,qBAAqB,CAAC;AAOnF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA4CjD,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/E;AAaD,wEAAwE;AACxE,e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sB,mBAAmB,CACvC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAE7B;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgB7B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOhE"}
|
package/dist/tools/reading.d.ts
CHANGED
|
@@ -11,9 +11,6 @@ interface ZoomBatchResult {
|
|
|
11
11
|
symbols: ZoomBatchSymbolResult[];
|
|
12
12
|
text: string;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Tool definitions for code reading commands: outline + zoom.
|
|
16
|
-
*/
|
|
17
14
|
export declare function readingTools(ctx: PluginContext): Record<string, ToolDefinition>;
|
|
18
15
|
/**
|
|
19
16
|
* Format multi-symbol zoom results as plain text. Successful entries use
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../../src/tools/reading.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reading.d.ts","sourceRoot":"","sources":["../../src/tools/reading.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAe,cAAc,EAAc,MAAM,qBAAqB,CAAC;AAInF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA8CjD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;CACd;AAsBD,wBAAgB,YAAY,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CA2R/E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,EAAE,EACjB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GACnC,eAAe,CAyBjB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { interruptBashWaitsForChatMessage } from "./bash-wait-detach.js";
|
|
3
|
+
import type { AftConfig } from "./config.js";
|
|
4
|
+
/** An offset range into `prompt.text`; `end` is exclusive. */
|
|
5
|
+
interface PromptMention {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
interface MentionCarrier {
|
|
11
|
+
mention?: PromptMention;
|
|
12
|
+
}
|
|
13
|
+
/** The fields of OpenCode 2's `SessionHooks["prompt"]` event this hook reads or edits. */
|
|
14
|
+
export interface V2PromptHookEvent {
|
|
15
|
+
readonly sessionID: string;
|
|
16
|
+
prompt: {
|
|
17
|
+
text: string;
|
|
18
|
+
files?: MentionCarrier[];
|
|
19
|
+
agents?: MentionCarrier[];
|
|
20
|
+
skills?: MentionCarrier[];
|
|
21
|
+
};
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
type ChatMessagePool = Parameters<typeof interruptBashWaitsForChatMessage>[0];
|
|
25
|
+
export interface V2PromptDetachRuntime {
|
|
26
|
+
/** The Location's bridge pool, where a session's waits live. */
|
|
27
|
+
readonly pool: ChatMessagePool;
|
|
28
|
+
/**
|
|
29
|
+
* The root this Location's tools run on (the Location's own directory); its
|
|
30
|
+
* bridge is asked to detach before any other.
|
|
31
|
+
*/
|
|
32
|
+
readonly projectRoot: string;
|
|
33
|
+
/**
|
|
34
|
+
* Read on every prompt so a live config reload of
|
|
35
|
+
* `bash.detach_on_user_message` applies to the next message.
|
|
36
|
+
*/
|
|
37
|
+
getConfig(): AftConfig;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Run the shared chat-message decision on one OpenCode 2 prompt and write the
|
|
41
|
+
* stripped text (and moved mention offsets) back onto it. Returns whether the
|
|
42
|
+
* session's waits were interrupted.
|
|
43
|
+
*
|
|
44
|
+
* A prompt AFT admitted itself (a completion wake) is passed to the shared
|
|
45
|
+
* decision as a synthetic part, exactly as OpenCode 1 marks such parts: it
|
|
46
|
+
* interrupts a wait whenever `bash.detach_on_user_message` is on, but its text
|
|
47
|
+
* is never read for `&detach` and never edited.
|
|
48
|
+
*
|
|
49
|
+
* All edits are computed before any is applied, so a throw leaves the prompt
|
|
50
|
+
* exactly as it arrived.
|
|
51
|
+
*/
|
|
52
|
+
export declare function interruptBashWaitsForV2Prompt(runtime: V2PromptDetachRuntime, event: V2PromptHookEvent): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The callback registered as OpenCode 2's session `prompt` hook. The host
|
|
55
|
+
* waits for it before admitting the message and a failure would reject the
|
|
56
|
+
* message, so it never fails and never waits: errors are caught, logged once
|
|
57
|
+
* per distinct reason, and the prompt passes through unchanged; the bridge
|
|
58
|
+
* detach request it may start is not awaited.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createV2PromptDetachHook(runtime: V2PromptDetachRuntime): (event: V2PromptHookEvent) => Effect.Effect<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Register the prompt hook on an OpenCode 2 host context. The registration is
|
|
63
|
+
* scoped by the host, so it ends with the Location. A host context without
|
|
64
|
+
* `session.hook` gets no hook, which leaves waits un-detachable by messages
|
|
65
|
+
* but otherwise working.
|
|
66
|
+
*/
|
|
67
|
+
export declare function registerV2PromptDetachHook(context: unknown, runtime: V2PromptDetachRuntime): Effect.Effect<boolean, never, unknown>;
|
|
68
|
+
export {};
|
|
69
|
+
//# sourceMappingURL=v2-prompt-detach.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v2-prompt-detach.d.ts","sourceRoot":"","sources":["../src/v2-prompt-detach.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,gCAAgC,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,8DAA8D;AAC9D,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,cAAc;IACtB,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,0FAA0F;AAC1F,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;QACzB,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;QAC1B,MAAM,CAAC,EAAE,cAAc,EAAE,CAAC;KAC3B,CAAC;IACF,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,gCAAgC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9E,MAAM,WAAW,qBAAqB;IACpC,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,SAAS,IAAI,SAAS,CAAC;CACxB;AAuDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,qBAAqB,EAC9B,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAuBT;AAMD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAC7B,CAAC,KAAK,EAAE,iBAAiB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAenD;AAOD;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,qBAAqB,GAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAYxC"}
|
|
@@ -4,6 +4,8 @@ import { type V2SessionAdmission } from "./session-delivery.js";
|
|
|
4
4
|
export interface V2WakeHostContext {
|
|
5
5
|
readonly session: V2SessionAdmission;
|
|
6
6
|
}
|
|
7
|
+
/** Test-only: forget every route and held completion in the process-wide table. */
|
|
8
|
+
export declare function __resetV2WakeRoutesForTests(): void;
|
|
7
9
|
declare const sharedBridgeOptions: Pick<BridgeOptions, "onBashCompletion" | "onBashLongRunning">;
|
|
8
10
|
export interface V2RuntimeConsumer extends V2ToolConsumers {
|
|
9
11
|
readonly bridgeOptions: typeof sharedBridgeOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-consumer.d.ts","sourceRoot":"","sources":["../../src/wakes/runtime-consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EACd,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-consumer.d.ts","sourceRoot":"","sources":["../../src/wakes/runtime-consumer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAM/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,KAAK,kBAAkB,EAAqB,MAAM,uBAAuB,CAAC;AAEnF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACtC;AAkJD,mFAAmF;AACnF,wBAAgB,2BAA2B,IAAI,IAAI,CAKlD;AAED,QAAA,MAAM,mBAAmB,EAAE,IAAI,CAAC,aAAa,EAAE,kBAAkB,GAAG,mBAAmB,CAGtF,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,QAAQ,CAAC,aAAa,EAAE,OAAO,mBAAmB,CAAC;IACnD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,GAAG,iBAAiB,CAiErF"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* The `metadata.source` value on every prompt AFT admits into a session itself
|
|
4
|
+
* (background-completion wakes). OpenCode 2 runs every prompt, AFT's own
|
|
5
|
+
* included, through the session `prompt` hook; the hook reads this marker to
|
|
6
|
+
* tell AFT's machine-written text from text an operator typed, never the text.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AFT_PROMPT_SOURCE = "aft";
|
|
9
|
+
/** True when a prompt's metadata marks it as one AFT admitted itself. */
|
|
10
|
+
export declare function isAftOriginatedPrompt(metadata: unknown): boolean;
|
|
2
11
|
export interface V2SessionPromptInput {
|
|
3
12
|
readonly sessionID: string;
|
|
4
13
|
readonly text: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-delivery.d.ts","sourceRoot":"","sources":["../../src/wakes/session-delivery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,OAAO,C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: boolean;
|
|
5
5
|
/** Resolved bash compression flag. */
|
|
6
6
|
bashCompressionEnabled: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Resolved `bash.rewrite` flag. Only rewritten `cat`/`head`/`tail` commands
|
|
9
|
+
* mint hashline tags through bash, so the hashline hint names them only when
|
|
10
|
+
* rewriting is on. Omitted means on.
|
|
11
|
+
*/
|
|
12
|
+
bashRewriteEnabled?: boolean;
|
|
7
13
|
/** Set of tool names that are not registered. */
|
|
8
14
|
disabledTools: Set<string>;
|
|
9
15
|
/** Whether the hashline `edit` arm is the one actually registered. */
|
|
10
16
|
hashlineEffective?: boolean;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
|
-
* Routing rule for hashline sessions
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* snapshot, so an agent that inspects a symbol and then patches it is refused
|
|
17
|
-
* for a tag it believes it already has. Naming the tag-minting tools is the
|
|
18
|
-
* only way to distinguish "I have seen this code" from "I can address it".
|
|
19
|
+
* Routing rule for hashline sessions: which calls mint the tags a patch
|
|
20
|
+
* addresses (see `hashlineTagSourceSentence`). The bash rewrite path and each
|
|
21
|
+
* AFT navigation tool are named only when present.
|
|
19
22
|
*/
|
|
20
|
-
export declare
|
|
23
|
+
export declare function hashlineTagSourceHint(bashRewritesMintTags: boolean, isRegistered?: (toolName: string) => boolean): string;
|
|
24
|
+
/** The hashline hint for a session whose bash rewrites `cat`/`head`/`tail`. */
|
|
25
|
+
export declare const HASHLINE_TAG_SOURCE_HINT: string;
|
|
21
26
|
/**
|
|
22
27
|
* Build the workflow hints block. Returns `null` when no hints are
|
|
23
28
|
* applicable for the configured surface (e.g. `tool_surface: "minimal"`
|
|
@@ -32,6 +37,14 @@ export declare function buildWorkflowHints(opts: WorkflowHintsOpts): string | nu
|
|
|
32
37
|
* `bash.background` setting controls whether the hint appears.
|
|
33
38
|
*/
|
|
34
39
|
export declare function buildHintsFromConfig(config: AftConfig, disabledTools: Set<string>, hashlineEffective?: boolean): string | null;
|
|
40
|
+
/** Every tool name a workflow-hints section can mention. */
|
|
41
|
+
export declare const WORKFLOW_HINT_TOOL_NAMES: readonly string[];
|
|
42
|
+
/**
|
|
43
|
+
* Build the hints block for the tools that are actually registered. Every
|
|
44
|
+
* hint-relevant name missing from `registeredTools` is passed as absent, so
|
|
45
|
+
* sections for tools the agent cannot call are dropped.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildHintsForRegisteredTools(config: AftConfig, registeredTools: ReadonlySet<string>, hashlineEffective?: boolean): string | null;
|
|
35
48
|
/**
|
|
36
49
|
* Fold the hints block into a host `system[]` array in place.
|
|
37
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-hints.d.ts","sourceRoot":"","sources":["../src/workflow-hints.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-hints.d.ts","sourceRoot":"","sources":["../src/workflow-hints.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,aAAa,CAAC;AAGhE,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,qBAAqB,EAAE,OAAO,CAAC;IAC/B,sCAAsC;IACtC,sBAAsB,EAAE,OAAO,CAAC;IAChC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,iDAAiD;IACjD,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAID;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,EAAE,OAAO,EAC7B,YAAY,GAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAoB,GACvD,MAAM,CAER;AAED,+EAA+E;AAC/E,eAAO,MAAM,wBAAwB,QAA8B,CAAC;AAEpE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAkJzE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,EAC1B,iBAAiB,UAAQ,GACxB,MAAM,GAAG,IAAI,CASf;AAED,4DAA4D;AAC5D,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAYrD,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,SAAS,EACjB,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,EACpC,iBAAiB,UAAQ,GACxB,MAAM,GAAG,IAAI,CAGf;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAQ9E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/aft-opencode",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "OpenCode plugin for Agent File Tools (AFT) — tree-sitter and lsp powered code analysis",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@clack/prompts": "^1.6.0",
|
|
42
|
-
"@cortexkit/aft-bridge": "0.58.
|
|
42
|
+
"@cortexkit/aft-bridge": "0.58.2",
|
|
43
43
|
"@opencode/client": "2.0.11",
|
|
44
44
|
"@opentui/core": "0.4.3",
|
|
45
45
|
"@opentui/solid": "0.4.3",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"zod": "^4.4.3"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
|
-
"@cortexkit/aft-darwin-arm64": "0.58.
|
|
54
|
-
"@cortexkit/aft-darwin-x64": "0.58.
|
|
55
|
-
"@cortexkit/aft-linux-arm64": "0.58.
|
|
56
|
-
"@cortexkit/aft-linux-x64": "0.58.
|
|
57
|
-
"@cortexkit/aft-win32-arm64": "0.58.
|
|
58
|
-
"@cortexkit/aft-win32-x64": "0.58.
|
|
53
|
+
"@cortexkit/aft-darwin-arm64": "0.58.2",
|
|
54
|
+
"@cortexkit/aft-darwin-x64": "0.58.2",
|
|
55
|
+
"@cortexkit/aft-linux-arm64": "0.58.2",
|
|
56
|
+
"@cortexkit/aft-linux-x64": "0.58.2",
|
|
57
|
+
"@cortexkit/aft-win32-arm64": "0.58.2",
|
|
58
|
+
"@cortexkit/aft-win32-x64": "0.58.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@opencode-ai/plugin": "^1.17.11",
|
|
@@ -13,10 +13,12 @@ import {
|
|
|
13
13
|
} from "../bridge-bootstrap.js";
|
|
14
14
|
import { resolveBridgePoolTransportOptions } from "../config.js";
|
|
15
15
|
import { buildConfigErrorToolMap } from "../config-error-surface.js";
|
|
16
|
+
import { startOpenCodeLiveConfigReload } from "../config-live-reload.js";
|
|
16
17
|
import { debug, log, warn } from "../logger.js";
|
|
17
18
|
import { resolvePluginVersion } from "../plugin-version.js";
|
|
18
19
|
import { registerAftConfigErrorRpc, registerAftRpc } from "../rpc/register.js";
|
|
19
|
-
import { hoistedV2ToolConsumers } from "../tools/hoisted/v2.js";
|
|
20
|
+
import { hoistedV2ToolConsumers, v2PromptChannelFor } from "../tools/hoisted/v2.js";
|
|
21
|
+
import { registerV2PromptDetachHook } from "../v2-prompt-detach.js";
|
|
20
22
|
import { createV2RuntimeConsumer } from "../wakes/runtime-consumer.js";
|
|
21
23
|
import {
|
|
22
24
|
buildAftToolDefinitions,
|
|
@@ -33,12 +35,16 @@ const defaults = {
|
|
|
33
35
|
registerTools: registerAftTools,
|
|
34
36
|
registerRpc: registerAftRpc,
|
|
35
37
|
registerConfigErrorRpc: registerAftConfigErrorRpc,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
registerPromptHook: registerV2PromptDetachHook,
|
|
39
|
+
// The prompt server comes from the user-only `opencode` block of the
|
|
40
|
+
// Location's config; without it AFT finds the server it runs inside.
|
|
41
|
+
toolConsumers: (context, config) => ({
|
|
42
|
+
...hoistedV2ToolConsumers(context, v2PromptChannelFor(config?.opencode)),
|
|
38
43
|
...createV2RuntimeConsumer(context),
|
|
39
44
|
}),
|
|
40
45
|
acquireBridge,
|
|
41
46
|
releaseBridge,
|
|
47
|
+
startLiveConfigReload: startOpenCodeLiveConfigReload,
|
|
42
48
|
resolvePoolOptions: resolveBridgePoolTransportOptions,
|
|
43
49
|
resolveVersion: () => resolvePluginVersion(import.meta.url),
|
|
44
50
|
};
|
|
@@ -73,7 +79,7 @@ async function bootLocation(context, location, dependencies) {
|
|
|
73
79
|
dependencies,
|
|
74
80
|
);
|
|
75
81
|
const canonicalDirectory = location.project?.canonical ?? directory;
|
|
76
|
-
const consumers = dependencies.toolConsumers(context);
|
|
82
|
+
const consumers = dependencies.toolConsumers(context, config);
|
|
77
83
|
// Only a rejected configuration keeps AFT out of a project; there is no
|
|
78
84
|
// config switch that turns it off.
|
|
79
85
|
const isProjectEnabled = createProjectAcceptance(directory, dependencies);
|
|
@@ -113,7 +119,19 @@ async function bootLocation(context, location, dependencies) {
|
|
|
113
119
|
const { hashlineEditRegistered } = applyToolSurfaceOverrides(pool, config, registeredTools);
|
|
114
120
|
reportHashlineDowngrade(config, registeredTools, notify);
|
|
115
121
|
toolContext.hashlineEffective = hashlineEditRegistered;
|
|
116
|
-
|
|
122
|
+
// Keep this Location's live config keys current when a config file changes.
|
|
123
|
+
// The finalizer that releases the bridge also stops the watch.
|
|
124
|
+
const liveConfigReload = dependencies.startLiveConfigReload({
|
|
125
|
+
directory,
|
|
126
|
+
initialSources: bootstrap.sources ?? [],
|
|
127
|
+
initialSourceTexts: bootstrap.sourceTexts,
|
|
128
|
+
getConfig: () => toolContext.config,
|
|
129
|
+
setConfig: (next) => {
|
|
130
|
+
toolContext.config = next;
|
|
131
|
+
},
|
|
132
|
+
notify,
|
|
133
|
+
});
|
|
134
|
+
return { consumers, pool, tools, liveConfigReload, toolContext, directory };
|
|
117
135
|
}
|
|
118
136
|
|
|
119
137
|
/**
|
|
@@ -185,12 +203,25 @@ export function makeServerEffect(overrides = {}) {
|
|
|
185
203
|
|
|
186
204
|
yield* Effect.addFinalizer(() =>
|
|
187
205
|
Effect.promise(async () => {
|
|
206
|
+
runtime.liveConfigReload?.stop();
|
|
188
207
|
runtime.consumers.dispose?.();
|
|
189
208
|
await dependencies.releaseBridge(runtime.pool);
|
|
190
209
|
}),
|
|
191
210
|
);
|
|
192
211
|
const rpc = yield* dependencies.registerRpc(context, location, runtime.pool);
|
|
193
212
|
yield* Effect.addFinalizer(() => Effect.promise(() => rpc.dispose()));
|
|
213
|
+
// OpenCode 2 has no chat.message hook; its session prompt hook is where a
|
|
214
|
+
// new message detaches a waiting bash, as chat.message does on OpenCode 1.
|
|
215
|
+
// The config is read through the tool context so live reloads apply.
|
|
216
|
+
// The bridge asked first is the one this Location's tools run on, the
|
|
217
|
+
// Location's own directory; for a Location in a linked git worktree that
|
|
218
|
+
// is the worktree, not the canonical main checkout the pool was acquired
|
|
219
|
+
// for (issue #387). Other bridges are still tried after it.
|
|
220
|
+
yield* dependencies.registerPromptHook(context, {
|
|
221
|
+
pool: runtime.pool,
|
|
222
|
+
projectRoot: runtime.directory,
|
|
223
|
+
getConfig: () => runtime.toolContext.config,
|
|
224
|
+
});
|
|
194
225
|
yield* dependencies.registerTools(
|
|
195
226
|
context,
|
|
196
227
|
location,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { resolvePromptContext } from "./last-assistant-model.js";
|
|
2
|
+
|
|
3
|
+
export const VISION_HOST_TIMEOUT_MS = 1500;
|
|
4
|
+
type Model = { providerID: string; modelID: string };
|
|
5
|
+
type State = {
|
|
6
|
+
models: Map<string, Model>;
|
|
7
|
+
history: Map<string, Promise<Model | undefined>>;
|
|
8
|
+
capabilities: Map<string, Promise<boolean | undefined>>;
|
|
9
|
+
};
|
|
10
|
+
const states = new WeakMap<object, State>();
|
|
11
|
+
function stateFor(client: object): State {
|
|
12
|
+
let state = states.get(client);
|
|
13
|
+
if (!state) {
|
|
14
|
+
state = { models: new Map(), history: new Map(), capabilities: new Map() };
|
|
15
|
+
states.set(client, state);
|
|
16
|
+
}
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Host hooks are authoritative; history is only a fallback before the first hook. */
|
|
21
|
+
export function rememberReadModel(client: object, sessionID: string, model: Model): void {
|
|
22
|
+
stateFor(client).models.set(sessionID, model);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function bounded<T>(call: () => Promise<T>): Promise<T | undefined> {
|
|
26
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
27
|
+
try {
|
|
28
|
+
return await Promise.race([
|
|
29
|
+
Promise.resolve().then(call),
|
|
30
|
+
new Promise<undefined>((resolve) => {
|
|
31
|
+
timer = setTimeout(() => resolve(undefined), VISION_HOST_TIMEOUT_MS);
|
|
32
|
+
}),
|
|
33
|
+
]);
|
|
34
|
+
} catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
} finally {
|
|
37
|
+
clearTimeout(timer);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function record(value: unknown): Record<string, unknown> | undefined {
|
|
41
|
+
return typeof value === "object" && value !== null && !Array.isArray(value)
|
|
42
|
+
? (value as Record<string, unknown>)
|
|
43
|
+
: undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function currentSessionVisionCapability(
|
|
47
|
+
client: object,
|
|
48
|
+
sessionID: string | undefined,
|
|
49
|
+
): Promise<boolean | undefined> {
|
|
50
|
+
if (!sessionID) return undefined;
|
|
51
|
+
const state = stateFor(client);
|
|
52
|
+
let model = state.models.get(sessionID);
|
|
53
|
+
if (!model) {
|
|
54
|
+
let pending = state.history.get(sessionID);
|
|
55
|
+
if (!pending) {
|
|
56
|
+
pending = bounded(() => resolvePromptContext(client, sessionID)).then(
|
|
57
|
+
(context) => context?.model,
|
|
58
|
+
);
|
|
59
|
+
state.history.set(sessionID, pending);
|
|
60
|
+
void pending.finally(() => state.history.delete(sessionID));
|
|
61
|
+
}
|
|
62
|
+
const historical = await pending;
|
|
63
|
+
// A hook may have supplied a newer model while history was in flight.
|
|
64
|
+
model = state.models.get(sessionID) ?? historical;
|
|
65
|
+
}
|
|
66
|
+
if (!model) return undefined;
|
|
67
|
+
const currentModel = model;
|
|
68
|
+
const key = JSON.stringify([model.providerID, model.modelID]);
|
|
69
|
+
let capability = state.capabilities.get(key);
|
|
70
|
+
if (!capability) {
|
|
71
|
+
capability = (async () => {
|
|
72
|
+
const api = (client as { provider?: { list?: () => Promise<unknown> } }).provider;
|
|
73
|
+
if (!api?.list) return undefined;
|
|
74
|
+
const list = api.list.bind(api);
|
|
75
|
+
const listed = record(await bounded(list));
|
|
76
|
+
const catalog = record(listed?.data) ?? listed;
|
|
77
|
+
const providers = catalog?.all ?? catalog?.providers;
|
|
78
|
+
if (!Array.isArray(providers)) return undefined;
|
|
79
|
+
const provider = providers.map(record).find((entry) => entry?.id === currentModel.providerID);
|
|
80
|
+
const models = provider?.models;
|
|
81
|
+
const entry = record(
|
|
82
|
+
Array.isArray(models)
|
|
83
|
+
? models.find((entry) => record(entry)?.id === currentModel.modelID)
|
|
84
|
+
: record(models)?.[currentModel.modelID],
|
|
85
|
+
);
|
|
86
|
+
const inputs = record(entry?.modalities)?.input;
|
|
87
|
+
return Array.isArray(inputs)
|
|
88
|
+
? inputs.includes("image")
|
|
89
|
+
: typeof entry?.attachment === "boolean"
|
|
90
|
+
? entry.attachment
|
|
91
|
+
: undefined;
|
|
92
|
+
})();
|
|
93
|
+
state.capabilities.set(key, capability);
|
|
94
|
+
// Do not retain transient failures or unknown catalog entries indefinitely.
|
|
95
|
+
void capability.then((value) => {
|
|
96
|
+
if (value === undefined) state.capabilities.delete(key);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return capability;
|
|
100
|
+
}
|
|
@@ -19,12 +19,62 @@
|
|
|
19
19
|
* `packages/opencode/src/session/registry.ts`. Until then this
|
|
20
20
|
* workaround makes AFT robust against the wrong cwd.
|
|
21
21
|
*/
|
|
22
|
+
import { Effect } from "effect";
|
|
23
|
+
|
|
22
24
|
import { sessionWarn } from "../logger.js";
|
|
23
25
|
|
|
24
26
|
interface SessionInfo {
|
|
25
27
|
directory?: string;
|
|
26
28
|
}
|
|
27
29
|
|
|
30
|
+
/**
|
|
31
|
+
* OpenCode 2 passes its plugin context where OpenCode 1 passes the SDK client
|
|
32
|
+
* (`entry/server-runtime.mjs` hands the context over as `client`). That context
|
|
33
|
+
* has a different session API, verified against the `v2` branch of the OpenCode repository:
|
|
34
|
+
*
|
|
35
|
+
* - `session.get` takes `{ sessionID }` and returns an Effect of `Session.Info`
|
|
36
|
+
* (packages/client/src/effect/api/api.ts `SessionGetOperation`,
|
|
37
|
+
* packages/plugin/src/effect/plugin.ts `Context`). Calling it the OpenCode 1
|
|
38
|
+
* way builds an Effect that never runs, and awaiting an Effect yields the
|
|
39
|
+
* Effect itself, so no directory was ever read.
|
|
40
|
+
* - `Session.Info` has no `directory`; the session's working directory is
|
|
41
|
+
* `location.directory`, a required `Location.Ref`
|
|
42
|
+
* (packages/schema/src/session.ts `Info`, packages/schema/src/location.ts
|
|
43
|
+
* `Ref`). For a session created in a linked git worktree it is that worktree.
|
|
44
|
+
*
|
|
45
|
+
* It is told apart from an OpenCode 1 SDK client by having a string
|
|
46
|
+
* `location.directory` next to a `session.get` function; the OpenCode 2 entry
|
|
47
|
+
* refuses to boot without that `location`, and `subagent-detect.ts` uses the
|
|
48
|
+
* same test for its own session lookup.
|
|
49
|
+
*/
|
|
50
|
+
interface V2SessionInfo {
|
|
51
|
+
location?: { directory?: unknown };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface V2PluginContextShape {
|
|
55
|
+
location: { directory: string };
|
|
56
|
+
session: {
|
|
57
|
+
get(input: { sessionID: string }): Effect.Effect<V2SessionInfo | undefined, unknown>;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isV2PluginContext(client: unknown): client is V2PluginContextShape {
|
|
62
|
+
if (!client || typeof client !== "object") return false;
|
|
63
|
+
const candidate = client as { location?: { directory?: unknown }; session?: { get?: unknown } };
|
|
64
|
+
return (
|
|
65
|
+
typeof candidate.location?.directory === "string" &&
|
|
66
|
+
typeof candidate.session?.get === "function"
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* How long an OpenCode 2 session lookup may run. The lookup is awaited before
|
|
72
|
+
* the first tool call of a session is routed, so a host that never answers
|
|
73
|
+
* must not hold that call; after this long the call proceeds with the
|
|
74
|
+
* Location's directory instead.
|
|
75
|
+
*/
|
|
76
|
+
export const V2_SESSION_LOOKUP_TIMEOUT_MS = 3_000;
|
|
77
|
+
|
|
28
78
|
interface OpenCodeClientShape {
|
|
29
79
|
session?: {
|
|
30
80
|
get?: (input: {
|
|
@@ -71,6 +121,8 @@ export async function getSessionDirectory(
|
|
|
71
121
|
return cached.directory;
|
|
72
122
|
}
|
|
73
123
|
|
|
124
|
+
if (isV2PluginContext(client)) return lookupV2SessionDirectory(client, sessionId);
|
|
125
|
+
|
|
74
126
|
const c = client as OpenCodeClientShape;
|
|
75
127
|
const sessionApi = c?.session;
|
|
76
128
|
if (!sessionApi || typeof sessionApi.get !== "function") {
|
|
@@ -108,6 +160,46 @@ export async function getSessionDirectory(
|
|
|
108
160
|
return dir;
|
|
109
161
|
}
|
|
110
162
|
|
|
163
|
+
/**
|
|
164
|
+
* OpenCode 2 lookup: run the context's `session.get` Effect under a timeout and
|
|
165
|
+
* read `location.directory`.
|
|
166
|
+
*
|
|
167
|
+
* Unlike the OpenCode 1 path, a failure or timeout is cached (as `null`), so it
|
|
168
|
+
* is logged once per session and never retried. The fallback is already right:
|
|
169
|
+
* with no cached directory, `projectRootFor` uses the tool call's Location
|
|
170
|
+
* directory for OpenCode 2 runtimes, and OpenCode 2 runs every session inside
|
|
171
|
+
* the Location created for that session's own directory. Retrying would only
|
|
172
|
+
* add up to the timeout to every later tool call while the host misbehaves.
|
|
173
|
+
*/
|
|
174
|
+
async function lookupV2SessionDirectory(
|
|
175
|
+
context: V2PluginContextShape,
|
|
176
|
+
sessionId: string,
|
|
177
|
+
): Promise<string | null> {
|
|
178
|
+
let dir: string | null = null;
|
|
179
|
+
let failure: string | undefined;
|
|
180
|
+
try {
|
|
181
|
+
const session = await Effect.runPromise(
|
|
182
|
+
Effect.timeout(
|
|
183
|
+
context.session.get({ sessionID: sessionId }) as Effect.Effect<V2SessionInfo | undefined>,
|
|
184
|
+
V2_SESSION_LOOKUP_TIMEOUT_MS,
|
|
185
|
+
),
|
|
186
|
+
);
|
|
187
|
+
const directory = session?.location?.directory;
|
|
188
|
+
if (typeof directory === "string" && directory.length > 0) dir = directory;
|
|
189
|
+
else failure = "the session record has no location.directory";
|
|
190
|
+
} catch (err) {
|
|
191
|
+
failure = err instanceof Error ? err.message || err.name : String(err);
|
|
192
|
+
}
|
|
193
|
+
if (failure !== undefined) {
|
|
194
|
+
sessionWarn(
|
|
195
|
+
sessionId,
|
|
196
|
+
`[aft-plugin] OpenCode 2 session lookup failed (${failure}); tool paths and bash use the Location directory ${context.location.directory} for this session`,
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
setCache(sessionId, dir);
|
|
200
|
+
return dir;
|
|
201
|
+
}
|
|
202
|
+
|
|
111
203
|
function setCache(sessionId: string, directory: string | null): void {
|
|
112
204
|
if (cache.has(sessionId)) cache.delete(sessionId);
|
|
113
205
|
cache.set(sessionId, { directory, recordedAt: Date.now() });
|