opencode-copilot-delegate 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +68 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +2290 -1933
- package/dist/lib/rpc-cleanup.d.ts +27 -0
- package/dist/runtime/continuity-checks.d.ts +7 -0
- package/dist/runtime/continuity-validation.d.ts +11 -0
- package/dist/runtime/envelope.d.ts +18 -0
- package/dist/runtime/notify.d.ts +27 -0
- package/dist/runtime/plugin-singleton.d.ts +72 -21
- package/dist/runtime/subprocess.d.ts +8 -0
- package/dist/runtime/task-registry.d.ts +28 -0
- package/dist/tools/resume.d.ts +62 -0
- package/dist/tui/index.js +39 -12
- package/package.json +9 -8
- package/src/tui/__tests__/index.test.ts +134 -11
- package/src/tui/index.tsx +95 -10
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wires graceful shutdown for the RPC server.
|
|
3
|
+
*
|
|
4
|
+
* This helper is intentionally NOT exported from `src/index.ts`. Any named
|
|
5
|
+
* export from the plugin entry is treated as a plugin factory by the OpenCode
|
|
6
|
+
* loader and called with `undefined` input, which crashes plugin loading. The
|
|
7
|
+
* same issue bit Systematic in v2.5.0 and v2.12.1. Moving helpers that are
|
|
8
|
+
* only needed internally into `src/lib/` keeps the plugin entry's public
|
|
9
|
+
* surface to `export default` only.
|
|
10
|
+
*
|
|
11
|
+
* Paired with `src/runtime/plugin-singleton.ts`: the singleton ensures the
|
|
12
|
+
* RPC server starts exactly once per process; this helper ensures it shuts
|
|
13
|
+
* down exactly once. Both constraints exist because the RPC server holds
|
|
14
|
+
* exclusive process resources (a bound TCP port and a PID file entry) —
|
|
15
|
+
* the same "exclusive resource" constraint that distinguishes this plugin
|
|
16
|
+
* from Systematic's stateless plugins and justifies retaining the singleton
|
|
17
|
+
* pattern after Systematic replaced it in PR #352
|
|
18
|
+
* (https://github.com/marcusrbrown/systematic/pull/352).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Wraps a `closeRpcServer` callback so it runs at most once, and registers
|
|
22
|
+
* `beforeExit` / `SIGTERM` handlers that trigger it automatically.
|
|
23
|
+
*
|
|
24
|
+
* Returns the idempotent `closeOnce` function so callers can also trigger
|
|
25
|
+
* shutdown imperatively (e.g. in tests via `__captureRpcCleanup`).
|
|
26
|
+
*/
|
|
27
|
+
export declare function wireRpcServerCleanup(closeRpcServer: () => Promise<void>): () => Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function normalizeContinuityError(stderr: string): string | null;
|
|
2
|
+
export declare function resolveConfigDir(explicit?: string): string;
|
|
3
|
+
export declare function isCopilotSessionUuid(value: string): boolean;
|
|
4
|
+
export type SessionLookupResult = boolean | {
|
|
5
|
+
error: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function hasLocalCopilotSession(uuid: string, configDir: string): Promise<SessionLookupResult>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type TargetId = {
|
|
2
|
+
type: 'uuid' | 'name';
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
type ValidationError = {
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function validateTargetId(value: string): TargetId | ValidationError;
|
|
9
|
+
export declare function validateAddDirs(values: string[], allowedRoots: string[]): string[] | ValidationError;
|
|
10
|
+
export declare function validateCwd(value: string, allowedRoots: string[]): string | ValidationError;
|
|
11
|
+
export {};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* gracefully rather than erroring.
|
|
7
7
|
*/
|
|
8
8
|
import type { ParsedEvent } from './jsonl-parser';
|
|
9
|
+
import type { TaskOrigin } from './task-registry';
|
|
9
10
|
/** Status of a delegated Copilot task. */
|
|
10
11
|
export type TaskStatus = 'running' | 'cancelling' | 'complete' | 'failed' | 'cancelled';
|
|
11
12
|
/** Summary of a single tool call made during the Copilot session. */
|
|
@@ -33,6 +34,10 @@ export type EnvelopeInput = {
|
|
|
33
34
|
modelName?: string;
|
|
34
35
|
errorText?: string;
|
|
35
36
|
timedOut?: boolean;
|
|
37
|
+
/** Source of the task — pass-through from `TaskState.origin`. */
|
|
38
|
+
origin?: TaskOrigin;
|
|
39
|
+
/** Upstream Copilot session UUID — pass-through from `TaskState`. */
|
|
40
|
+
copilotSessionId?: string;
|
|
36
41
|
};
|
|
37
42
|
/** The structured result envelope returned by `copilot_output`. */
|
|
38
43
|
export type OutputEnvelope = {
|
|
@@ -48,6 +53,19 @@ export type OutputEnvelope = {
|
|
|
48
53
|
error?: string;
|
|
49
54
|
timed_out?: boolean;
|
|
50
55
|
events_count: number;
|
|
56
|
+
/**
|
|
57
|
+
* Source of the task. Always populated; defaults to `'spawn'` for inputs
|
|
58
|
+
* that predate the discriminator (back-compat). Consumers branch on this
|
|
59
|
+
* to distinguish a fresh delegation from a resumed/connected session
|
|
60
|
+
* without re-reading the registry.
|
|
61
|
+
*/
|
|
62
|
+
origin: TaskOrigin;
|
|
63
|
+
/**
|
|
64
|
+
* Upstream Copilot session UUID, when known. Captured from the JSONL
|
|
65
|
+
* `result` event during the task lifecycle. Omitted when the subprocess
|
|
66
|
+
* never emitted a `result` event (e.g., killed early or crashed).
|
|
67
|
+
*/
|
|
68
|
+
copilot_session_id?: string;
|
|
51
69
|
};
|
|
52
70
|
/**
|
|
53
71
|
* Build the structured output envelope from parsed events and task metadata.
|
package/dist/runtime/notify.d.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* the same counter value and both setting noReply: false.
|
|
11
11
|
*/
|
|
12
12
|
import type { TaskStatus } from './envelope';
|
|
13
|
+
import type { SpawnCopilotResult } from './subprocess';
|
|
14
|
+
import type { TaskOrigin, TaskState } from './task-registry';
|
|
13
15
|
/** Minimal client interface for notification injection. */
|
|
14
16
|
export type NotifyClient = {
|
|
15
17
|
session: {
|
|
@@ -55,6 +57,12 @@ export type NotifyTaskInfo = {
|
|
|
55
57
|
modelName?: string;
|
|
56
58
|
startedAt: number;
|
|
57
59
|
exitCode?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Source of the task. Optional for back-compat with callers that
|
|
62
|
+
* predate the discriminator (S2 Unit 1); existing call sites and
|
|
63
|
+
* tests omit it and the formatter falls back to the spawn variant.
|
|
64
|
+
*/
|
|
65
|
+
origin?: TaskOrigin;
|
|
58
66
|
};
|
|
59
67
|
/** Increment the in-flight counter for a parent session. */
|
|
60
68
|
export declare function incrementInFlight(parentSessionID: string): void;
|
|
@@ -69,3 +77,22 @@ export declare function notifySpawn(client: NotifyClient, taskId: string): Promi
|
|
|
69
77
|
* Never throws — logs and swallows prompt/toast errors.
|
|
70
78
|
*/
|
|
71
79
|
export declare function notifyCompletion(client: NotifyClient, task: NotifyTaskInfo): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Attach the post-completion pipeline to a task and its underlying spawn
|
|
82
|
+
* result. Encapsulates the back-patch of late-arriving fields from
|
|
83
|
+
* `SpawnCopilotResult` to the registry `TaskState`, then dispatches the
|
|
84
|
+
* completion notification.
|
|
85
|
+
*
|
|
86
|
+
* The back-patch is load-bearing: `task` is created up-front from a
|
|
87
|
+
* snapshot of `spawnFields`, so post-spawn fields populated by the
|
|
88
|
+
* subprocess wrapper (status, finalMessage, copilotSessionId, etc) live
|
|
89
|
+
* on `spawnResult` until they are explicitly synced. Any field assigned
|
|
90
|
+
* after `createTask` returned needs to appear in the assign list —
|
|
91
|
+
* otherwise it is invisible to `copilot_output` even when present on
|
|
92
|
+
* `spawnResult`.
|
|
93
|
+
*
|
|
94
|
+
* Origin-aware notification text is delegated to `buildNotificationText`
|
|
95
|
+
* via `task.origin`, so this helper itself is origin-agnostic — the same
|
|
96
|
+
* pipeline drives spawn-, resume-, and (eventually) connect-origin tasks.
|
|
97
|
+
*/
|
|
98
|
+
export declare function attachCompletionPipeline(task: TaskState, spawnResult: SpawnCopilotResult, client: NotifyClient): void;
|
|
@@ -1,35 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Per-process
|
|
2
|
+
* Per-process register-once guard for the plugin factory.
|
|
3
3
|
*
|
|
4
4
|
* OpenCode invokes the plugin factory more than once per process when the
|
|
5
5
|
* same plugin is referenced by multiple config sources (for example a
|
|
6
6
|
* user-level `~/.config/opencode/opencode.json` AND a project-level
|
|
7
7
|
* `opencode.json`). Each invocation evaluates the plugin module fresh —
|
|
8
|
-
* module-local variables reset between calls — so the
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* On the first invocation
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
8
|
+
* module-local variables reset between calls — so the guard state must
|
|
9
|
+
* live on `globalThis` to persist across module instances within the
|
|
10
|
+
* same process.
|
|
11
|
+
*
|
|
12
|
+
* On the first invocation `doInit` runs and the resulting hooks promise
|
|
13
|
+
* is cached on `globalThis`; the caller receives `{ isFirst: true, hooks }`.
|
|
14
|
+
* On every subsequent invocation in the same PID `doInit` is skipped, the
|
|
15
|
+
* cached promise is awaited (so sticky rejections still propagate),
|
|
16
|
+
* `onDuplicate` fires exactly once, and the caller receives
|
|
17
|
+
* `{ isFirst: false, hooks: {} as T }`. Across PIDs the guard is treated
|
|
18
|
+
* as absent and init runs fresh — `globalThis` is per-process, but the
|
|
19
|
+
* explicit PID check adds defensive belt-and-suspenders against any
|
|
20
|
+
* state-leakage edge case.
|
|
21
|
+
*
|
|
22
|
+
* **Why empty hooks on duplicate invocations.** A whole-hooks singleton
|
|
23
|
+
* that returns the same hooks reference to both invocations does not
|
|
24
|
+
* deduplicate host-side tool registration: OpenCode iterates each plugin
|
|
25
|
+
* source's returned hook surface and registers every tool entry it finds,
|
|
26
|
+
* even when two sources return the same JS reference. Returning `{}` from
|
|
27
|
+
* the duplicate path is the only shape that prevents host-side double
|
|
28
|
+
* registration of `copilot_delegate`, `copilot_output`, and
|
|
29
|
+
* `copilot_cancel`. Verified empirically against
|
|
30
|
+
* `client.tool.list({...})`: under whole-hooks reuse a dual-source config
|
|
31
|
+
* lists each tool twice; under empty-hooks-on-duplicate it lists each
|
|
32
|
+
* tool once.
|
|
19
33
|
*
|
|
20
34
|
* The cached value is the init Promise rather than the resolved value so
|
|
21
35
|
* a second invocation that arrives while the first is still awaiting
|
|
22
36
|
* `mkdir` / `reapOrphans` converges on the same init result instead of
|
|
23
37
|
* starting a parallel init.
|
|
24
38
|
*
|
|
25
|
-
* **Known limitation — rejected init is
|
|
39
|
+
* **Known limitation — rejected init is sticky.** If `doInit()` rejects,
|
|
26
40
|
* the rejected promise is stored on `globalThis` and every subsequent
|
|
27
|
-
* invocation in the same PID
|
|
41
|
+
* invocation in the same PID surfaces the same rejection without
|
|
28
42
|
* retrying init. This is intentional: re-running heavy init on every
|
|
29
|
-
* call would defeat the
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
43
|
+
* call would defeat the guard's purpose. Recovery requires a process
|
|
44
|
+
* restart. OpenCode currently surfaces a failed plugin factory as a
|
|
45
|
+
* startup error rather than retrying within the process, so this matches
|
|
46
|
+
* the upstream contract.
|
|
47
|
+
*
|
|
48
|
+
* **Why this plugin keeps the singleton pattern when Systematic dropped it.**
|
|
49
|
+
* Systematic's PR #352 (https://github.com/marcusrbrown/systematic/pull/352,
|
|
50
|
+
* shipped in v2.12.1/v2.12.2) replaced `plugInOnce` with per-load
|
|
51
|
+
* registration guarded by a marker flag. That change was correct for
|
|
52
|
+
* Systematic: its plugins are stateless and idempotent — they register
|
|
53
|
+
* tools and inject prompts, but they do not bind ports or write PID files.
|
|
54
|
+
* Running the same Systematic plugin factory twice in the same process is
|
|
55
|
+
* harmless because the second run produces the same registrations as the
|
|
56
|
+
* first.
|
|
57
|
+
*
|
|
58
|
+
* This plugin's init is not idempotent. `doInit` starts an RPC server that
|
|
59
|
+
* binds a TCP port and writes a PID file to a well-known path. A second
|
|
60
|
+
* `doInit` call in the same process would attempt to bind the same port
|
|
61
|
+
* (EADDRINUSE) and overwrite the PID file with a duplicate entry. The
|
|
62
|
+
* singleton pattern is the correct constraint here: exactly one server
|
|
63
|
+
* starts per process, and exactly one PID file entry is written. The
|
|
64
|
+
* paired `wireRpcServerCleanup` helper in `src/lib/rpc-cleanup.ts`
|
|
65
|
+
* enforces the matching invariant on shutdown — the server closes exactly
|
|
66
|
+
* once. Both guards exist because the resource is exclusive to the process.
|
|
33
67
|
*/
|
|
34
68
|
export interface PlugInOnceOptions<T> {
|
|
35
69
|
/** Heavy init work that should run at most once per process. */
|
|
@@ -47,10 +81,27 @@ export interface PlugInOnceOptions<T> {
|
|
|
47
81
|
pid?: number;
|
|
48
82
|
}
|
|
49
83
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
84
|
+
* Result envelope for `plugInOnce(...)`.
|
|
85
|
+
*
|
|
86
|
+
* - `isFirst: true` — caller should return `hooks` (the real hooks from
|
|
87
|
+
* `doInit`) to OpenCode.
|
|
88
|
+
* - `isFirst: false` — caller MUST return `hooks` (which is an empty `{}`)
|
|
89
|
+
* so the host loader does not register tools or hooks twice.
|
|
90
|
+
*
|
|
91
|
+
* Callers that just `return result.hooks` do the right thing in both
|
|
92
|
+
* cases without needing to inspect `isFirst` — the empty object is what
|
|
93
|
+
* the host should register on the duplicate source.
|
|
94
|
+
*/
|
|
95
|
+
export interface PlugInOnceResult<T> {
|
|
96
|
+
isFirst: boolean;
|
|
97
|
+
hooks: T;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Run `doInit` at most once per process; on duplicate invocations resolve
|
|
101
|
+
* to empty hooks so the OpenCode host does not double-register tools and
|
|
102
|
+
* hooks under dual-source configurations.
|
|
52
103
|
*/
|
|
53
|
-
export declare function plugInOnce<T>({ doInit, onDuplicate, pid, }: PlugInOnceOptions<T>): Promise<T
|
|
104
|
+
export declare function plugInOnce<T>({ doInit, onDuplicate, pid, }: PlugInOnceOptions<T>): Promise<PlugInOnceResult<T>>;
|
|
54
105
|
/**
|
|
55
106
|
* Test-only: clear the singleton state so the next invocation re-runs
|
|
56
107
|
* init. Must not be called in production code paths.
|
|
@@ -19,6 +19,14 @@ export type SpawnCopilotResult = {
|
|
|
19
19
|
stdoutLineBuffer: string;
|
|
20
20
|
finalMessage?: string;
|
|
21
21
|
errorText?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Upstream Copilot session UUID captured from the terminal `result`
|
|
24
|
+
* JSONL event. Populated alongside `assignFinalMessage` in both the
|
|
25
|
+
* happy-path (`finalizeTask`) and cancelled-close branches; left
|
|
26
|
+
* undefined when no `result` event arrived (process killed early or
|
|
27
|
+
* crashed before emitting one).
|
|
28
|
+
*/
|
|
29
|
+
copilotSessionId?: string;
|
|
22
30
|
};
|
|
23
31
|
export declare function spawnCopilot(args: string[], opts: SpawnCopilotOptions): SpawnCopilotResult;
|
|
24
32
|
export {};
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { SpawnCopilotResult } from './subprocess';
|
|
2
|
+
/**
|
|
3
|
+
* Source of a TaskState.
|
|
4
|
+
*
|
|
5
|
+
* - `spawn` — fresh `copilot -p` subprocess started by `copilot_delegate`.
|
|
6
|
+
* - `resume` — `copilot --resume=<id>` continuation of a prior session.
|
|
7
|
+
* - `connect` — `copilot --connect=<id>` attach to a running session
|
|
8
|
+
* (deferred from the v0.x first slice; the type seam is in place for
|
|
9
|
+
* forward compatibility per the S2 plan amendment).
|
|
10
|
+
*/
|
|
11
|
+
export type TaskOrigin = 'spawn' | 'resume' | 'connect';
|
|
2
12
|
export type TaskState = SpawnCopilotResult & {
|
|
3
13
|
parentSessionID: string;
|
|
4
14
|
startedAt: number;
|
|
@@ -6,6 +16,14 @@ export type TaskState = SpawnCopilotResult & {
|
|
|
6
16
|
cwd: string;
|
|
7
17
|
agentName?: string;
|
|
8
18
|
modelName?: string;
|
|
19
|
+
origin: TaskOrigin;
|
|
20
|
+
/** Workspace paths passed via `--add-dir` (captured for resume reuse). */
|
|
21
|
+
addDirs?: string[];
|
|
22
|
+
/** ps comm + lstart captured at spawn time for connect identity gating. */
|
|
23
|
+
psIdentity?: {
|
|
24
|
+
comm: string;
|
|
25
|
+
lstart: string;
|
|
26
|
+
};
|
|
9
27
|
};
|
|
10
28
|
export type CreateTaskInput = Omit<SpawnCopilotResult, 'taskId'> & {
|
|
11
29
|
parentSessionID: string;
|
|
@@ -14,6 +32,16 @@ export type CreateTaskInput = Omit<SpawnCopilotResult, 'taskId'> & {
|
|
|
14
32
|
cwd: string;
|
|
15
33
|
agentName?: string;
|
|
16
34
|
modelName?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Source of the task. Optional on input — defaults to `'spawn'` so
|
|
37
|
+
* existing call sites that predate the discriminator keep working.
|
|
38
|
+
*/
|
|
39
|
+
origin?: TaskOrigin;
|
|
40
|
+
addDirs?: string[];
|
|
41
|
+
psIdentity?: {
|
|
42
|
+
comm: string;
|
|
43
|
+
lstart: string;
|
|
44
|
+
};
|
|
17
45
|
pidFilePath?: string;
|
|
18
46
|
};
|
|
19
47
|
export declare function createTask(input: CreateTaskInput, taskId?: string): TaskState;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* copilot_resume tool — resumes a prior Copilot session by ID, name, or prefix.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `copilot --resume=<target_id>` with:
|
|
5
|
+
* - Concurrency cap: same 10-task limit as copilot_delegate
|
|
6
|
+
* - Input validation (validateTargetId, validateAddDirs, validateCwd)
|
|
7
|
+
* - UUID preflight: checks local session.db before spawning; fs errors → structured { error }
|
|
8
|
+
* - configDir propagation: resolved configDir is passed as COPILOT_CONFIG_DIR env to the
|
|
9
|
+
* spawned process so preflight and CLI use the same session store
|
|
10
|
+
* - Known-task add_dir reuse: if a prior task's copilotSessionId matches target_id,
|
|
11
|
+
* its captured addDirs are reused when the caller omits add_dir; inherited paths bypass
|
|
12
|
+
* explicit containment so multi-repo context from the prior task is preserved
|
|
13
|
+
* - Symlink containment: realpath-based canonicalization in validateAddDirs/validateCwd
|
|
14
|
+
* - CLI no-match stderr normalization to structured { error } response
|
|
15
|
+
* - origin: 'resume' on the created TaskState
|
|
16
|
+
* - Full completion pipeline (attachCompletionPipeline) identical to delegate
|
|
17
|
+
*
|
|
18
|
+
* Public tool args use snake_case (target_id, add_dir, config_dir) consistent with
|
|
19
|
+
* the rest of the plugin's public API surface.
|
|
20
|
+
*
|
|
21
|
+
* No `prompt` argument — resume + new prompt is a fork operation.
|
|
22
|
+
*
|
|
23
|
+
* Exports `launchResume` for RPC reuse.
|
|
24
|
+
*/
|
|
25
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
26
|
+
export type LaunchResumeOptions = {
|
|
27
|
+
client: PluginInput['client'];
|
|
28
|
+
directory: string;
|
|
29
|
+
sessionID: string;
|
|
30
|
+
targetId: string;
|
|
31
|
+
cwd?: string;
|
|
32
|
+
addDirs?: string[];
|
|
33
|
+
configDir?: string;
|
|
34
|
+
pidFilePath?: string;
|
|
35
|
+
};
|
|
36
|
+
export type LaunchResumeResult = {
|
|
37
|
+
task_id: string;
|
|
38
|
+
} | {
|
|
39
|
+
error: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function launchResume(opts: LaunchResumeOptions): Promise<LaunchResumeResult>;
|
|
42
|
+
type ResumeToolOptions = {
|
|
43
|
+
client: PluginInput['client'];
|
|
44
|
+
directory: string;
|
|
45
|
+
pidFilePath?: string;
|
|
46
|
+
};
|
|
47
|
+
export declare function createResumeTool(options: ResumeToolOptions): {
|
|
48
|
+
description: string;
|
|
49
|
+
args: {
|
|
50
|
+
target_id: import("zod").ZodString;
|
|
51
|
+
cwd: import("zod").ZodOptional<import("zod").ZodString>;
|
|
52
|
+
add_dir: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
53
|
+
config_dir: import("zod").ZodOptional<import("zod").ZodString>;
|
|
54
|
+
};
|
|
55
|
+
execute(args: {
|
|
56
|
+
target_id: string;
|
|
57
|
+
cwd?: string | undefined;
|
|
58
|
+
add_dir?: string[] | undefined;
|
|
59
|
+
config_dir?: string | undefined;
|
|
60
|
+
}, context: import("@opencode-ai/plugin").ToolContext): Promise<import("@opencode-ai/plugin").ToolResult>;
|
|
61
|
+
};
|
|
62
|
+
export {};
|
package/dist/tui/index.js
CHANGED
|
@@ -11186,7 +11186,7 @@ function finalize(ctx, schema) {
|
|
|
11186
11186
|
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
11187
11187
|
} else if (ctx.target === "draft-04") {
|
|
11188
11188
|
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
11189
|
-
} else if (ctx.target === "openapi-3.0") {}
|
|
11189
|
+
} else if (ctx.target === "openapi-3.0") {}
|
|
11190
11190
|
if (ctx.external?.uri) {
|
|
11191
11191
|
const id = ctx.external.registry.get(schema)?.id;
|
|
11192
11192
|
if (!id)
|
|
@@ -11434,7 +11434,7 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
11434
11434
|
if (val === undefined) {
|
|
11435
11435
|
if (ctx.unrepresentable === "throw") {
|
|
11436
11436
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
11437
|
-
}
|
|
11437
|
+
}
|
|
11438
11438
|
} else if (typeof val === "bigint") {
|
|
11439
11439
|
if (ctx.unrepresentable === "throw") {
|
|
11440
11440
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
@@ -14054,6 +14054,40 @@ function errorMessage2(error48) {
|
|
|
14054
14054
|
}
|
|
14055
14055
|
return "Unknown RPC error.";
|
|
14056
14056
|
}
|
|
14057
|
+
function hasKeymapRegisterLayer(api2) {
|
|
14058
|
+
const candidate = api2.keymap;
|
|
14059
|
+
return candidate != null && typeof candidate.registerLayer === "function";
|
|
14060
|
+
}
|
|
14061
|
+
function registerCopilotStatusCommand(api2, openList) {
|
|
14062
|
+
if (hasKeymapRegisterLayer(api2)) {
|
|
14063
|
+
return api2.keymap.registerLayer({
|
|
14064
|
+
commands: [{
|
|
14065
|
+
namespace: "palette",
|
|
14066
|
+
name: "copilot-status",
|
|
14067
|
+
title: "Copilot Status",
|
|
14068
|
+
category: "Copilot",
|
|
14069
|
+
run() {
|
|
14070
|
+
openList();
|
|
14071
|
+
}
|
|
14072
|
+
}],
|
|
14073
|
+
bindings: []
|
|
14074
|
+
});
|
|
14075
|
+
}
|
|
14076
|
+
if (typeof api2.command?.register === "function") {
|
|
14077
|
+
return api2.command.register(() => [{
|
|
14078
|
+
title: "Copilot Status",
|
|
14079
|
+
value: "/copilot-status",
|
|
14080
|
+
slash: {
|
|
14081
|
+
name: "copilot-status"
|
|
14082
|
+
},
|
|
14083
|
+
onSelect() {
|
|
14084
|
+
openList();
|
|
14085
|
+
}
|
|
14086
|
+
}]);
|
|
14087
|
+
}
|
|
14088
|
+
console.warn("[opencode-copilot-delegate] No supported TUI command-registration API found (neither api.keymap.registerLayer nor api.command.register). The /copilot-status slash command will not be available, but the plugin remains loaded.");
|
|
14089
|
+
return () => {};
|
|
14090
|
+
}
|
|
14057
14091
|
var tui = async (api2) => {
|
|
14058
14092
|
const rpc = createRpcClient();
|
|
14059
14093
|
const closeDialog = () => {
|
|
@@ -14082,16 +14116,9 @@ var tui = async (api2) => {
|
|
|
14082
14116
|
});
|
|
14083
14117
|
});
|
|
14084
14118
|
};
|
|
14085
|
-
const unregister = api2
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
slash: {
|
|
14089
|
-
name: "copilot-status"
|
|
14090
|
-
},
|
|
14091
|
-
onSelect: () => {
|
|
14092
|
-
openList();
|
|
14093
|
-
}
|
|
14094
|
-
}]);
|
|
14119
|
+
const unregister = registerCopilotStatusCommand(api2, () => {
|
|
14120
|
+
openList();
|
|
14121
|
+
});
|
|
14095
14122
|
api2.lifecycle.onDispose(() => {
|
|
14096
14123
|
rpc.dispose();
|
|
14097
14124
|
unregister();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-copilot-delegate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "OpenCode plugin that delegates tasks to GitHub Copilot CLI as background subprocesses",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -52,14 +52,15 @@
|
|
|
52
52
|
"node": ">=24"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@opencode-ai/plugin": ">=1.14.
|
|
55
|
+
"@opencode-ai/plugin": ">=1.14.41"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@biomejs/biome": "2.4.
|
|
58
|
+
"@biomejs/biome": "2.4.14",
|
|
59
59
|
"@changesets/cli": "2.31.0",
|
|
60
|
-
"@opencode-ai/plugin": "1.14.
|
|
60
|
+
"@opencode-ai/plugin": "1.14.48",
|
|
61
|
+
"@types/babel__core": "^7.20.5",
|
|
61
62
|
"@types/bun": "1.3.13",
|
|
62
|
-
"@types/node": "24.12.
|
|
63
|
+
"@types/node": "24.12.3",
|
|
63
64
|
"rimraf": "6.1.3",
|
|
64
65
|
"typescript": "6.0.3"
|
|
65
66
|
},
|
|
@@ -78,10 +79,10 @@
|
|
|
78
79
|
"publish-changesets": "bun run build && changeset publish"
|
|
79
80
|
},
|
|
80
81
|
"dependencies": {
|
|
81
|
-
"@opentui/core": "0.
|
|
82
|
-
"@opentui/solid": "0.
|
|
82
|
+
"@opentui/core": "0.2.5",
|
|
83
|
+
"@opentui/solid": "0.2.5",
|
|
83
84
|
"fkill": "10.0.3",
|
|
84
|
-
"solid-js": "1.9.
|
|
85
|
+
"solid-js": "1.9.12",
|
|
85
86
|
"zod": "^4.3.0"
|
|
86
87
|
},
|
|
87
88
|
"overrides": {
|