@opencode-compat/facade-plugin 0.1.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/README.md +7 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/tool.d.ts +66 -0
- package/dist/tool.js +9 -0
- package/dist/tui.d.ts +44 -0
- package/dist/tui.js +83 -0
- package/dist/types.d.ts +371 -0
- package/dist/types.js +2 -0
- package/dist/v2/effect.d.ts +3 -0
- package/dist/v2/effect.js +14 -0
- package/dist/v2/promise.d.ts +7 -0
- package/dist/v2/promise.js +22 -0
- package/package.json +74 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @opencode-compat/facade-plugin — install-override stand-in for `@opencode-ai/plugin`.
|
|
3
|
+
*
|
|
4
|
+
* Classic surface: Hooks types + `tool` re-export.
|
|
5
|
+
* Subpaths: `./tool`, `./tui`, `./v2/promise`, `./v2/effect`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PKG: "@opencode-compat/facade-plugin";
|
|
8
|
+
export declare const VERSION: "0.1.0";
|
|
9
|
+
export * from "./tool";
|
|
10
|
+
export type { AuthHook, AuthOAuthResult, AuthOuathResult, AuthPrompt, BunShell, Config, Event, HostClient, Hooks, Message, Model, ModelV2, Part, Permission, Plugin, PluginInput, PluginModule, PluginOptions, Project, Provider, ProviderContext, ProviderHook, ProviderHookContext, ProviderV2, UserMessage, WorkspaceAdapter, WorkspaceInfo, WorkspaceTarget, } from "./types";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @opencode-compat/facade-plugin — install-override stand-in for `@opencode-ai/plugin`.
|
|
3
|
+
*
|
|
4
|
+
* Classic surface: Hooks types + `tool` re-export.
|
|
5
|
+
* Subpaths: `./tool`, `./tui`, `./v2/promise`, `./v2/effect`.
|
|
6
|
+
*/
|
|
7
|
+
export const PKG = "@opencode-compat/facade-plugin";
|
|
8
|
+
export const VERSION = "0.1.0";
|
|
9
|
+
export * from "./tool";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
package/dist/tool.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type ToolContext = {
|
|
3
|
+
sessionID: string;
|
|
4
|
+
messageID: string;
|
|
5
|
+
agent: string;
|
|
6
|
+
/**
|
|
7
|
+
* Current project directory for this session.
|
|
8
|
+
* Prefer this over process.cwd() when resolving relative paths.
|
|
9
|
+
*/
|
|
10
|
+
directory: string;
|
|
11
|
+
/**
|
|
12
|
+
* Project worktree root for this session.
|
|
13
|
+
* Useful for generating stable relative paths (e.g. path.relative(worktree, absPath)).
|
|
14
|
+
*/
|
|
15
|
+
worktree: string;
|
|
16
|
+
abort: AbortSignal;
|
|
17
|
+
metadata(input: {
|
|
18
|
+
title?: string;
|
|
19
|
+
metadata?: {
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
}): void;
|
|
23
|
+
ask(input: AskInput): Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
type AskInput = {
|
|
26
|
+
permission: string;
|
|
27
|
+
patterns: string[];
|
|
28
|
+
always: string[];
|
|
29
|
+
metadata: {
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export type ToolAttachment = {
|
|
34
|
+
type: "file";
|
|
35
|
+
mime: string;
|
|
36
|
+
url: string;
|
|
37
|
+
filename?: string;
|
|
38
|
+
};
|
|
39
|
+
export type ToolResult = string | {
|
|
40
|
+
title?: string;
|
|
41
|
+
output: string;
|
|
42
|
+
metadata?: {
|
|
43
|
+
[key: string]: unknown;
|
|
44
|
+
};
|
|
45
|
+
attachments?: ToolAttachment[];
|
|
46
|
+
};
|
|
47
|
+
type ToolFn = {
|
|
48
|
+
<Args extends z.ZodRawShape>(input: {
|
|
49
|
+
description: string;
|
|
50
|
+
args: Args;
|
|
51
|
+
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<ToolResult>;
|
|
52
|
+
}): {
|
|
53
|
+
description: string;
|
|
54
|
+
args: Args;
|
|
55
|
+
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<ToolResult>;
|
|
56
|
+
};
|
|
57
|
+
schema: typeof z;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Classic `tool()` helper — identity wrapper matching `@opencode-ai/plugin/tool`.
|
|
61
|
+
* Implemented in the facade so forks without remapping still get a working helper.
|
|
62
|
+
*/
|
|
63
|
+
export declare const tool: ToolFn;
|
|
64
|
+
export type ToolDefinition = ReturnType<typeof tool>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=tool.d.ts.map
|
package/dist/tool.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Classic `tool()` helper — identity wrapper matching `@opencode-ai/plugin/tool`.
|
|
4
|
+
* Implemented in the facade so forks without remapping still get a working helper.
|
|
5
|
+
*/
|
|
6
|
+
export const tool = Object.assign(function tool(input) {
|
|
7
|
+
return input;
|
|
8
|
+
}, { schema: z });
|
|
9
|
+
//# sourceMappingURL=tool.js.map
|
package/dist/tui.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare const PKG_TUI: "@opencode-compat/facade-plugin/tui";
|
|
2
|
+
/** Loose portable stubs — full fidelity comes from native host tui. */
|
|
3
|
+
export type TuiPlugin = (api: TuiPluginApi, options: Record<string, unknown> | undefined, meta: TuiPluginMeta) => Promise<void>;
|
|
4
|
+
export type TuiPluginModule = {
|
|
5
|
+
id?: string;
|
|
6
|
+
tui: TuiPlugin;
|
|
7
|
+
server?: never;
|
|
8
|
+
};
|
|
9
|
+
export type TuiPluginState = "first" | "updated" | "same";
|
|
10
|
+
export type TuiPluginEntry = {
|
|
11
|
+
id: string;
|
|
12
|
+
source: "file" | "npm" | "internal";
|
|
13
|
+
spec: string;
|
|
14
|
+
target: string;
|
|
15
|
+
requested?: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
modified?: number;
|
|
18
|
+
first_time: number;
|
|
19
|
+
last_time: number;
|
|
20
|
+
time_changed: number;
|
|
21
|
+
load_count: number;
|
|
22
|
+
fingerprint: string;
|
|
23
|
+
};
|
|
24
|
+
export type TuiPluginMeta = TuiPluginEntry & {
|
|
25
|
+
state: TuiPluginState;
|
|
26
|
+
};
|
|
27
|
+
export type TuiPluginApi = {
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
};
|
|
30
|
+
type NativeTui = Record<string, unknown>;
|
|
31
|
+
export declare function getNativeTui(): Promise<NativeTui>;
|
|
32
|
+
/**
|
|
33
|
+
* Async helpers that load native then invoke.
|
|
34
|
+
* Prefer these over the sync binds when the host plugin may not be preloaded.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createBindingLookup(...args: unknown[]): Promise<unknown>;
|
|
37
|
+
export declare function stringifyKeySequence(...args: unknown[]): Promise<unknown>;
|
|
38
|
+
export declare function stringifyKeyStroke(...args: unknown[]): Promise<unknown>;
|
|
39
|
+
export declare function formatCommandBindings(...args: unknown[]): Promise<unknown>;
|
|
40
|
+
export declare function formatKeySequence(...args: unknown[]): Promise<unknown>;
|
|
41
|
+
/** @deprecated Sync bind requires prior getNativeTui(); prefer async helpers. */
|
|
42
|
+
export declare const createBindingLookupSync: (...args: unknown[]) => unknown;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=tui.d.ts.map
|
package/dist/tui.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facade path for `@opencode-ai/plugin/tui`.
|
|
3
|
+
*
|
|
4
|
+
* Runtime values are loaded lazily from the host’s native plugin `./tui`.
|
|
5
|
+
* Portable type stubs cover the common TuiPlugin* surface for type-only imports.
|
|
6
|
+
*/
|
|
7
|
+
import { importNativePlugin } from "@opencode-compat/adapter";
|
|
8
|
+
export const PKG_TUI = "@opencode-compat/facade-plugin/tui";
|
|
9
|
+
let nativePromise;
|
|
10
|
+
let nativeCache;
|
|
11
|
+
export function getNativeTui() {
|
|
12
|
+
nativePromise ??= importNativePlugin("tui")
|
|
13
|
+
.then((mod) => {
|
|
14
|
+
nativeCache = mod;
|
|
15
|
+
return mod;
|
|
16
|
+
})
|
|
17
|
+
.catch((err) => {
|
|
18
|
+
nativePromise = undefined;
|
|
19
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
20
|
+
throw new Error(`${PKG_TUI}: failed to load host native ./tui — ${message}. ` +
|
|
21
|
+
"Ensure a cooperating host (opencode/mimo/kilo) is detected and its plugin package is installed.");
|
|
22
|
+
});
|
|
23
|
+
return nativePromise;
|
|
24
|
+
}
|
|
25
|
+
function bind(name) {
|
|
26
|
+
return (...args) => {
|
|
27
|
+
if (!nativeCache) {
|
|
28
|
+
throw new Error(`${PKG_TUI}: native tui not loaded yet — call await getNativeTui() first, or use getNativeTui() for full exports. Missing eager bind: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
const value = nativeCache[name];
|
|
31
|
+
if (typeof value !== "function") {
|
|
32
|
+
throw new Error(`${PKG_TUI}: native export missing: ${name}`);
|
|
33
|
+
}
|
|
34
|
+
return value(...args);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Async helpers that load native then invoke.
|
|
39
|
+
* Prefer these over the sync binds when the host plugin may not be preloaded.
|
|
40
|
+
*/
|
|
41
|
+
export async function createBindingLookup(...args) {
|
|
42
|
+
const native = await getNativeTui();
|
|
43
|
+
const fn = native.createBindingLookup;
|
|
44
|
+
if (typeof fn !== "function") {
|
|
45
|
+
throw new Error(`${PKG_TUI}: native export missing: createBindingLookup`);
|
|
46
|
+
}
|
|
47
|
+
return fn(...args);
|
|
48
|
+
}
|
|
49
|
+
export async function stringifyKeySequence(...args) {
|
|
50
|
+
const native = await getNativeTui();
|
|
51
|
+
const fn = native.stringifyKeySequence;
|
|
52
|
+
if (typeof fn !== "function") {
|
|
53
|
+
throw new Error(`${PKG_TUI}: native export missing: stringifyKeySequence`);
|
|
54
|
+
}
|
|
55
|
+
return fn(...args);
|
|
56
|
+
}
|
|
57
|
+
export async function stringifyKeyStroke(...args) {
|
|
58
|
+
const native = await getNativeTui();
|
|
59
|
+
const fn = native.stringifyKeyStroke;
|
|
60
|
+
if (typeof fn !== "function") {
|
|
61
|
+
throw new Error(`${PKG_TUI}: native export missing: stringifyKeyStroke`);
|
|
62
|
+
}
|
|
63
|
+
return fn(...args);
|
|
64
|
+
}
|
|
65
|
+
export async function formatCommandBindings(...args) {
|
|
66
|
+
const native = await getNativeTui();
|
|
67
|
+
const fn = native.formatCommandBindings;
|
|
68
|
+
if (typeof fn !== "function") {
|
|
69
|
+
throw new Error(`${PKG_TUI}: native export missing: formatCommandBindings`);
|
|
70
|
+
}
|
|
71
|
+
return fn(...args);
|
|
72
|
+
}
|
|
73
|
+
export async function formatKeySequence(...args) {
|
|
74
|
+
const native = await getNativeTui();
|
|
75
|
+
const fn = native.formatKeySequence;
|
|
76
|
+
if (typeof fn !== "function") {
|
|
77
|
+
throw new Error(`${PKG_TUI}: native export missing: formatKeySequence`);
|
|
78
|
+
}
|
|
79
|
+
return fn(...args);
|
|
80
|
+
}
|
|
81
|
+
/** @deprecated Sync bind requires prior getNativeTui(); prefer async helpers. */
|
|
82
|
+
export const createBindingLookupSync = bind("createBindingLookup");
|
|
83
|
+
//# sourceMappingURL=tui.js.map
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable classic plugin types for OCP facades.
|
|
3
|
+
* Structurally aligned with @opencode-ai/plugin@1.18.3 Hooks keys;
|
|
4
|
+
* SDK entity shapes are intentionally loose so facades do not hard-depend
|
|
5
|
+
* on a single fork’s generated client types.
|
|
6
|
+
*/
|
|
7
|
+
import type { Auth } from "@opencode-compat/facade-sdk";
|
|
8
|
+
import type { ToolDefinition } from "./tool";
|
|
9
|
+
/** Opaque host client — OpenCode `createOpencodeClient` / MiMo residual / Kilo `createKiloClient`. */
|
|
10
|
+
export type HostClient = {
|
|
11
|
+
readonly [key: string]: unknown;
|
|
12
|
+
};
|
|
13
|
+
export type Project = {
|
|
14
|
+
id: string;
|
|
15
|
+
worktree: string;
|
|
16
|
+
vcsDir?: string;
|
|
17
|
+
vcs?: "git";
|
|
18
|
+
time: {
|
|
19
|
+
created: number;
|
|
20
|
+
initialized?: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type Model = {
|
|
24
|
+
id: string;
|
|
25
|
+
providerID: string;
|
|
26
|
+
name: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
};
|
|
29
|
+
export type Provider = {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
source: "env" | "config" | "custom" | "api";
|
|
33
|
+
env: string[];
|
|
34
|
+
key?: string;
|
|
35
|
+
options: Record<string, unknown>;
|
|
36
|
+
models: Record<string, Model>;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
export type ProviderV2 = {
|
|
40
|
+
id: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
};
|
|
44
|
+
export type ModelV2 = {
|
|
45
|
+
id: string;
|
|
46
|
+
providerID?: string;
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
};
|
|
49
|
+
export type Permission = {
|
|
50
|
+
id: string;
|
|
51
|
+
type: string;
|
|
52
|
+
pattern?: string | string[];
|
|
53
|
+
sessionID: string;
|
|
54
|
+
messageID: string;
|
|
55
|
+
callID?: string;
|
|
56
|
+
title: string;
|
|
57
|
+
metadata: Record<string, unknown>;
|
|
58
|
+
time: {
|
|
59
|
+
created: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type UserMessage = {
|
|
63
|
+
id: string;
|
|
64
|
+
sessionID: string;
|
|
65
|
+
role: "user";
|
|
66
|
+
time: {
|
|
67
|
+
created: number;
|
|
68
|
+
};
|
|
69
|
+
agent: string;
|
|
70
|
+
model: {
|
|
71
|
+
providerID: string;
|
|
72
|
+
modelID: string;
|
|
73
|
+
};
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
};
|
|
76
|
+
export type Message = UserMessage | {
|
|
77
|
+
role: string;
|
|
78
|
+
id: string;
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
};
|
|
81
|
+
export type Part = {
|
|
82
|
+
id?: string;
|
|
83
|
+
type?: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
};
|
|
86
|
+
export type Event = {
|
|
87
|
+
type: string;
|
|
88
|
+
properties?: unknown;
|
|
89
|
+
};
|
|
90
|
+
export type BunShell = {
|
|
91
|
+
(strings: TemplateStringsArray, ...values: unknown[]): unknown;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
};
|
|
94
|
+
export type ProviderContext = {
|
|
95
|
+
source: "env" | "config" | "custom" | "api";
|
|
96
|
+
info: Provider;
|
|
97
|
+
options: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
export type WorkspaceInfo = {
|
|
100
|
+
id: string;
|
|
101
|
+
type: string;
|
|
102
|
+
name: string;
|
|
103
|
+
branch: string | null;
|
|
104
|
+
directory: string | null;
|
|
105
|
+
extra: unknown | null;
|
|
106
|
+
projectID: string;
|
|
107
|
+
};
|
|
108
|
+
export type WorkspaceTarget = {
|
|
109
|
+
type: "local";
|
|
110
|
+
directory: string;
|
|
111
|
+
} | {
|
|
112
|
+
type: "remote";
|
|
113
|
+
url: string | URL;
|
|
114
|
+
headers?: Record<string, string>;
|
|
115
|
+
};
|
|
116
|
+
export type WorkspaceAdapter = {
|
|
117
|
+
name: string;
|
|
118
|
+
description: string;
|
|
119
|
+
configure(config: WorkspaceInfo): WorkspaceInfo | Promise<WorkspaceInfo>;
|
|
120
|
+
create(config: WorkspaceInfo, env: Record<string, string | undefined>, from?: WorkspaceInfo): Promise<void>;
|
|
121
|
+
remove(config: WorkspaceInfo): Promise<void>;
|
|
122
|
+
target(config: WorkspaceInfo): WorkspaceTarget | Promise<WorkspaceTarget>;
|
|
123
|
+
};
|
|
124
|
+
export type PluginInput = {
|
|
125
|
+
client: HostClient;
|
|
126
|
+
project: Project;
|
|
127
|
+
directory: string;
|
|
128
|
+
worktree: string;
|
|
129
|
+
experimental_workspace: {
|
|
130
|
+
register(type: string, adapter: WorkspaceAdapter): void;
|
|
131
|
+
};
|
|
132
|
+
serverUrl: URL;
|
|
133
|
+
$: BunShell;
|
|
134
|
+
};
|
|
135
|
+
export type PluginOptions = Record<string, unknown>;
|
|
136
|
+
export type Config = {
|
|
137
|
+
plugin?: Array<string | [string, PluginOptions]>;
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
};
|
|
140
|
+
export type Plugin = (input: PluginInput, options?: PluginOptions) => Promise<Hooks>;
|
|
141
|
+
export type PluginModule = {
|
|
142
|
+
id?: string;
|
|
143
|
+
server: Plugin;
|
|
144
|
+
tui?: never;
|
|
145
|
+
};
|
|
146
|
+
type Rule = {
|
|
147
|
+
key: string;
|
|
148
|
+
op: "eq" | "neq";
|
|
149
|
+
value: string;
|
|
150
|
+
};
|
|
151
|
+
export type AuthHook = {
|
|
152
|
+
provider: string;
|
|
153
|
+
loader?: (auth: () => Promise<Auth>, provider: Provider) => Promise<Record<string, unknown>>;
|
|
154
|
+
methods: Array<{
|
|
155
|
+
type: "oauth";
|
|
156
|
+
label: string;
|
|
157
|
+
prompts?: AuthPrompt[];
|
|
158
|
+
authorize(inputs?: Record<string, string>): Promise<AuthOAuthResult>;
|
|
159
|
+
} | {
|
|
160
|
+
type: "api";
|
|
161
|
+
label: string;
|
|
162
|
+
prompts?: AuthPrompt[];
|
|
163
|
+
authorize?(inputs?: Record<string, string>): Promise<{
|
|
164
|
+
type: "success";
|
|
165
|
+
key: string;
|
|
166
|
+
provider?: string;
|
|
167
|
+
metadata?: Record<string, string>;
|
|
168
|
+
} | {
|
|
169
|
+
type: "failed";
|
|
170
|
+
}>;
|
|
171
|
+
}>;
|
|
172
|
+
};
|
|
173
|
+
export type AuthPrompt = {
|
|
174
|
+
type: "text";
|
|
175
|
+
key: string;
|
|
176
|
+
message: string;
|
|
177
|
+
placeholder?: string;
|
|
178
|
+
validate?: (value: string) => string | undefined;
|
|
179
|
+
/** @deprecated Use `when` instead */
|
|
180
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
181
|
+
when?: Rule;
|
|
182
|
+
} | {
|
|
183
|
+
type: "select";
|
|
184
|
+
key: string;
|
|
185
|
+
message: string;
|
|
186
|
+
options: Array<{
|
|
187
|
+
label: string;
|
|
188
|
+
value: string;
|
|
189
|
+
hint?: string;
|
|
190
|
+
}>;
|
|
191
|
+
/** @deprecated Use `when` instead */
|
|
192
|
+
condition?: (inputs: Record<string, string>) => boolean;
|
|
193
|
+
when?: Rule;
|
|
194
|
+
};
|
|
195
|
+
export type AuthOAuthResult = {
|
|
196
|
+
url: string;
|
|
197
|
+
instructions: string;
|
|
198
|
+
} & ({
|
|
199
|
+
method: "auto";
|
|
200
|
+
callback(): Promise<({
|
|
201
|
+
type: "success";
|
|
202
|
+
provider?: string;
|
|
203
|
+
} & ({
|
|
204
|
+
refresh: string;
|
|
205
|
+
access: string;
|
|
206
|
+
expires: number;
|
|
207
|
+
accountId?: string;
|
|
208
|
+
enterpriseUrl?: string;
|
|
209
|
+
} | {
|
|
210
|
+
key: string;
|
|
211
|
+
metadata?: Record<string, string>;
|
|
212
|
+
})) | {
|
|
213
|
+
type: "failed";
|
|
214
|
+
}>;
|
|
215
|
+
} | {
|
|
216
|
+
method: "code";
|
|
217
|
+
callback(code: string): Promise<({
|
|
218
|
+
type: "success";
|
|
219
|
+
provider?: string;
|
|
220
|
+
} & ({
|
|
221
|
+
refresh: string;
|
|
222
|
+
access: string;
|
|
223
|
+
expires: number;
|
|
224
|
+
accountId?: string;
|
|
225
|
+
enterpriseUrl?: string;
|
|
226
|
+
} | {
|
|
227
|
+
key: string;
|
|
228
|
+
metadata?: Record<string, string>;
|
|
229
|
+
})) | {
|
|
230
|
+
type: "failed";
|
|
231
|
+
}>;
|
|
232
|
+
});
|
|
233
|
+
/** @deprecated Use AuthOAuthResult instead. */
|
|
234
|
+
export type AuthOuathResult = AuthOAuthResult;
|
|
235
|
+
export type ProviderHookContext = {
|
|
236
|
+
auth?: Auth;
|
|
237
|
+
};
|
|
238
|
+
export type ProviderHook = {
|
|
239
|
+
id: string;
|
|
240
|
+
models?: (provider: ProviderV2, ctx: ProviderHookContext) => Promise<Record<string, ModelV2>>;
|
|
241
|
+
};
|
|
242
|
+
/** OCP 0.1 portable classic Hooks (OpenCode ∩ Kilo core; MiMo gaps accepted). */
|
|
243
|
+
export interface Hooks {
|
|
244
|
+
dispose?: () => Promise<void>;
|
|
245
|
+
event?: (input: {
|
|
246
|
+
event: Event;
|
|
247
|
+
}) => Promise<void>;
|
|
248
|
+
config?: (input: Config) => Promise<void>;
|
|
249
|
+
tool?: {
|
|
250
|
+
[key: string]: ToolDefinition;
|
|
251
|
+
};
|
|
252
|
+
auth?: AuthHook;
|
|
253
|
+
provider?: ProviderHook;
|
|
254
|
+
"chat.message"?: (input: {
|
|
255
|
+
sessionID: string;
|
|
256
|
+
agent?: string;
|
|
257
|
+
model?: {
|
|
258
|
+
providerID: string;
|
|
259
|
+
modelID: string;
|
|
260
|
+
};
|
|
261
|
+
messageID?: string;
|
|
262
|
+
variant?: string;
|
|
263
|
+
}, output: {
|
|
264
|
+
message: UserMessage;
|
|
265
|
+
parts: Part[];
|
|
266
|
+
}) => Promise<void>;
|
|
267
|
+
"chat.params"?: (input: {
|
|
268
|
+
sessionID: string;
|
|
269
|
+
agent: string;
|
|
270
|
+
model: Model;
|
|
271
|
+
provider: ProviderContext;
|
|
272
|
+
message: UserMessage;
|
|
273
|
+
}, output: {
|
|
274
|
+
temperature: number;
|
|
275
|
+
topP: number;
|
|
276
|
+
topK: number;
|
|
277
|
+
maxOutputTokens: number | undefined;
|
|
278
|
+
options: Record<string, unknown>;
|
|
279
|
+
}) => Promise<void>;
|
|
280
|
+
"chat.headers"?: (input: {
|
|
281
|
+
sessionID: string;
|
|
282
|
+
agent: string;
|
|
283
|
+
model: Model;
|
|
284
|
+
provider: ProviderContext;
|
|
285
|
+
message: UserMessage;
|
|
286
|
+
}, output: {
|
|
287
|
+
headers: Record<string, string>;
|
|
288
|
+
}) => Promise<void>;
|
|
289
|
+
"permission.ask"?: (input: Permission, output: {
|
|
290
|
+
status: "ask" | "deny" | "allow";
|
|
291
|
+
}) => Promise<void>;
|
|
292
|
+
"command.execute.before"?: (input: {
|
|
293
|
+
command: string;
|
|
294
|
+
sessionID: string;
|
|
295
|
+
arguments: string;
|
|
296
|
+
}, output: {
|
|
297
|
+
parts: Part[];
|
|
298
|
+
}) => Promise<void>;
|
|
299
|
+
"tool.execute.before"?: (input: {
|
|
300
|
+
tool: string;
|
|
301
|
+
sessionID: string;
|
|
302
|
+
callID: string;
|
|
303
|
+
}, output: {
|
|
304
|
+
args: unknown;
|
|
305
|
+
}) => Promise<void>;
|
|
306
|
+
"shell.env"?: (input: {
|
|
307
|
+
cwd: string;
|
|
308
|
+
sessionID?: string;
|
|
309
|
+
callID?: string;
|
|
310
|
+
}, output: {
|
|
311
|
+
env: Record<string, string>;
|
|
312
|
+
}) => Promise<void>;
|
|
313
|
+
"tool.execute.after"?: (input: {
|
|
314
|
+
tool: string;
|
|
315
|
+
sessionID: string;
|
|
316
|
+
callID: string;
|
|
317
|
+
args: unknown;
|
|
318
|
+
}, output: {
|
|
319
|
+
title: string;
|
|
320
|
+
output: string;
|
|
321
|
+
metadata: unknown;
|
|
322
|
+
}) => Promise<void>;
|
|
323
|
+
"experimental.chat.messages.transform"?: (input: Record<string, never>, output: {
|
|
324
|
+
messages: {
|
|
325
|
+
info: Message;
|
|
326
|
+
parts: Part[];
|
|
327
|
+
}[];
|
|
328
|
+
}) => Promise<void>;
|
|
329
|
+
"experimental.chat.system.transform"?: (input: {
|
|
330
|
+
sessionID?: string;
|
|
331
|
+
model: Model;
|
|
332
|
+
}, output: {
|
|
333
|
+
system: string[];
|
|
334
|
+
}) => Promise<void>;
|
|
335
|
+
"experimental.provider.small_model"?: (input: {
|
|
336
|
+
provider: ProviderV2;
|
|
337
|
+
}, output: {
|
|
338
|
+
model?: ModelV2;
|
|
339
|
+
}) => Promise<void>;
|
|
340
|
+
"experimental.session.compacting"?: (input: {
|
|
341
|
+
sessionID: string;
|
|
342
|
+
}, output: {
|
|
343
|
+
context: string[];
|
|
344
|
+
prompt?: string;
|
|
345
|
+
}) => Promise<void>;
|
|
346
|
+
"experimental.compaction.autocontinue"?: (input: {
|
|
347
|
+
sessionID: string;
|
|
348
|
+
agent: string;
|
|
349
|
+
model: Model;
|
|
350
|
+
provider: ProviderContext;
|
|
351
|
+
message: UserMessage;
|
|
352
|
+
overflow: boolean;
|
|
353
|
+
}, output: {
|
|
354
|
+
enabled: boolean;
|
|
355
|
+
}) => Promise<void>;
|
|
356
|
+
"experimental.text.complete"?: (input: {
|
|
357
|
+
sessionID: string;
|
|
358
|
+
messageID: string;
|
|
359
|
+
partID: string;
|
|
360
|
+
}, output: {
|
|
361
|
+
text: string;
|
|
362
|
+
}) => Promise<void>;
|
|
363
|
+
"tool.definition"?: (input: {
|
|
364
|
+
toolID: string;
|
|
365
|
+
}, output: {
|
|
366
|
+
description: string;
|
|
367
|
+
parameters: unknown;
|
|
368
|
+
}) => Promise<void>;
|
|
369
|
+
}
|
|
370
|
+
export {};
|
|
371
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facade path for `@opencode-ai/plugin/v2/effect` — loud fail unless host capable.
|
|
3
|
+
*/
|
|
4
|
+
import { detect } from "@opencode-compat/profile";
|
|
5
|
+
export const PKG_V2_EFFECT = "@opencode-compat/facade-plugin/v2/effect";
|
|
6
|
+
export function define(_plugin) {
|
|
7
|
+
const result = detect();
|
|
8
|
+
if (result.supported && result.profile.capabilities.effectV2) {
|
|
9
|
+
throw new Error(`${PKG_V2_EFFECT}: host declares effectV2 but Effect host bridge is not implemented in this facade build`);
|
|
10
|
+
}
|
|
11
|
+
throw new Error(`${PKG_V2_EFFECT}: Effect v2 not supported by this host/facade build` +
|
|
12
|
+
(result.supported ? ` (host=${result.profile.id})` : ""));
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createPluginContext, createPromiseV2Host, injectLanguageModel, injectSdk, resolveProvider, runPromisePlugin, type LanguageModelInput, type LanguageModelV3Like, type Plugin, type PluginContext, type PromisePlugin, type PromiseV2Host } from "@opencode-compat/host-promise-v2";
|
|
2
|
+
export declare const PKG_V2_PROMISE: "@opencode-compat/facade-plugin/v2/promise";
|
|
3
|
+
export type { LanguageModelInput, LanguageModelV3Like, Plugin, PluginContext, PromisePlugin, PromiseV2Host, };
|
|
4
|
+
/** Re-exports for hosts / tests that import through the facade path. */
|
|
5
|
+
export { createPluginContext, createPromiseV2Host, injectLanguageModel, injectSdk, resolveProvider, runPromisePlugin, };
|
|
6
|
+
export declare function define(plugin: Plugin): Plugin;
|
|
7
|
+
//# sourceMappingURL=promise.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Facade path for `@opencode-ai/plugin/v2/promise`.
|
|
3
|
+
* T3 surface — requires host kit (`@opencode-compat/host-promise-v2`) + capable host.
|
|
4
|
+
*/
|
|
5
|
+
import { detect } from "@opencode-compat/profile";
|
|
6
|
+
import { createPluginContext, createPromiseV2Host, define as hostDefine, injectLanguageModel, injectSdk, resolveProvider, runPromisePlugin, } from "@opencode-compat/host-promise-v2";
|
|
7
|
+
export const PKG_V2_PROMISE = "@opencode-compat/facade-plugin/v2/promise";
|
|
8
|
+
/** Re-exports for hosts / tests that import through the facade path. */
|
|
9
|
+
export { createPluginContext, createPromiseV2Host, injectLanguageModel, injectSdk, resolveProvider, runPromisePlugin, };
|
|
10
|
+
export function define(plugin) {
|
|
11
|
+
const result = detect();
|
|
12
|
+
if (!result.supported) {
|
|
13
|
+
throw new Error(`${PKG_V2_PROMISE}: host ${result.id} cannot load OCP plugins. ${result.message ?? ""}`.trim());
|
|
14
|
+
}
|
|
15
|
+
if (!result.profile.capabilities.promiseV2) {
|
|
16
|
+
throw new Error(`${PKG_V2_PROMISE}: Promise v2 not available on host "${result.profile.id}". ` +
|
|
17
|
+
"Wire @opencode-compat/host-promise-v2 from the OCP layer (or run on OpenCode). " +
|
|
18
|
+
"See docs/ocp/0.1.md §7.");
|
|
19
|
+
}
|
|
20
|
+
return hostDefine(plugin);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=promise.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opencode-compat/facade-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Install-override stand-in for @opencode-ai/plugin (classic + v2/promise)",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MPL-2.0",
|
|
7
|
+
"author": "oakimov",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/oakimov/opencode-plugin-compat.git",
|
|
11
|
+
"directory": "packages/facade-plugin"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./tool": {
|
|
24
|
+
"types": "./dist/tool.d.ts",
|
|
25
|
+
"import": "./dist/tool.js"
|
|
26
|
+
},
|
|
27
|
+
"./tui": {
|
|
28
|
+
"types": "./dist/tui.d.ts",
|
|
29
|
+
"import": "./dist/tui.js"
|
|
30
|
+
},
|
|
31
|
+
"./v2/promise": {
|
|
32
|
+
"types": "./dist/v2/promise.d.ts",
|
|
33
|
+
"import": "./dist/v2/promise.js"
|
|
34
|
+
},
|
|
35
|
+
"./v2/effect": {
|
|
36
|
+
"types": "./dist/v2/effect.d.ts",
|
|
37
|
+
"import": "./dist/v2/effect.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"README.md",
|
|
44
|
+
"!dist/**/*.map"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "bunx tsc -p tsconfig.json",
|
|
48
|
+
"typecheck": "bunx tsc -p tsconfig.json --noEmit",
|
|
49
|
+
"prepack": "bunx tsc -p tsconfig.json"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@opencode-compat/adapter": "0.1.0",
|
|
53
|
+
"@opencode-compat/facade-sdk": "0.1.0",
|
|
54
|
+
"@opencode-compat/host-promise-v2": "0.1.0",
|
|
55
|
+
"@opencode-compat/profile": "0.1.0",
|
|
56
|
+
"zod": "^4.1.8"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"typescript": "^5.8.3"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/oakimov/opencode-plugin-compat/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/oakimov/opencode-plugin-compat/tree/main/packages/facade-plugin#readme",
|
|
65
|
+
"keywords": [
|
|
66
|
+
"opencode",
|
|
67
|
+
"ocp",
|
|
68
|
+
"facade",
|
|
69
|
+
"plugin"
|
|
70
|
+
],
|
|
71
|
+
"engines": {
|
|
72
|
+
"bun": ">=1.2.0"
|
|
73
|
+
}
|
|
74
|
+
}
|