@opencode-compat/facade-sdk 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 ADDED
@@ -0,0 +1,7 @@
1
+ # @opencode-compat/facade-sdk
2
+
3
+ Minimal install-override stand-in for @opencode-ai/sdk
4
+
5
+ **License:** MPL-2.0
6
+
7
+ See the monorepo [README](../../README.md) and [OCP 0.1](../../docs/ocp/0.1.md).
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Minimal install-override stand-in for `@opencode-ai/sdk`.
3
+ * Starts from types used by classic auth plugins; expands via fixtures.
4
+ */
5
+ export declare const PKG: "@opencode-compat/facade-sdk";
6
+ export declare const VERSION: "0.1.0";
7
+ export type OAuth = {
8
+ type: "oauth";
9
+ refresh: string;
10
+ access: string;
11
+ expires: number;
12
+ enterpriseUrl?: string;
13
+ accountId?: string;
14
+ };
15
+ export type ApiAuth = {
16
+ type: "api";
17
+ key: string;
18
+ metadata?: {
19
+ [key: string]: string;
20
+ };
21
+ };
22
+ export type WellKnownAuth = {
23
+ type: "wellknown";
24
+ key: string;
25
+ token: string;
26
+ };
27
+ export type Auth = OAuth | ApiAuth | WellKnownAuth;
28
+ export type Model = {
29
+ id: string;
30
+ providerID: string;
31
+ name: string;
32
+ [key: string]: unknown;
33
+ };
34
+ export type Provider = {
35
+ id: string;
36
+ name: string;
37
+ source: "env" | "config" | "custom" | "api";
38
+ env: string[];
39
+ key?: string;
40
+ options: Record<string, unknown>;
41
+ models: Record<string, Model>;
42
+ [key: string]: unknown;
43
+ };
44
+ export type Project = {
45
+ id: string;
46
+ worktree: string;
47
+ vcsDir?: string;
48
+ vcs?: "git";
49
+ time: {
50
+ created: number;
51
+ initialized?: number;
52
+ };
53
+ };
54
+ /**
55
+ * Opaque host client. Real method surface comes from the native SDK
56
+ * (`@opencode-ai/sdk`, `@mimo-ai/sdk`, or `@kilocode/sdk`).
57
+ */
58
+ export type OpencodeClient = {
59
+ readonly [key: string]: unknown;
60
+ };
61
+ export type OpencodeClientConfig = {
62
+ baseUrl?: string;
63
+ directory?: string;
64
+ [key: string]: unknown;
65
+ };
66
+ type ClientFactory = (config?: OpencodeClientConfig & {
67
+ directory?: string;
68
+ }) => OpencodeClient;
69
+ /** OCP layer / tests may inject the native client factory. */
70
+ export declare function setCreateOpencodeClient(factory: ClientFactory | undefined): void;
71
+ /**
72
+ * Sync client factory matching `@opencode-ai/sdk` signature.
73
+ *
74
+ * Classic plugins mostly need `ReturnType<typeof createOpencodeClient>` for
75
+ * `PluginInput.client`. Runtime construction should use a host-injected factory
76
+ * (`setCreateOpencodeClient`) or `createOpencodeClientAsync`.
77
+ */
78
+ export declare function createOpencodeClient(config?: OpencodeClientConfig & {
79
+ directory?: string;
80
+ }): OpencodeClient;
81
+ /** Async path: load native SDK and invoke createOpencodeClient / createKiloClient. */
82
+ export declare function createOpencodeClientAsync(config?: OpencodeClientConfig & {
83
+ directory?: string;
84
+ }): Promise<OpencodeClient>;
85
+ export {};
86
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Minimal install-override stand-in for `@opencode-ai/sdk`.
3
+ * Starts from types used by classic auth plugins; expands via fixtures.
4
+ */
5
+ export const PKG = "@opencode-compat/facade-sdk";
6
+ export const VERSION = "0.1.0";
7
+ let injectedFactory;
8
+ /** OCP layer / tests may inject the native client factory. */
9
+ export function setCreateOpencodeClient(factory) {
10
+ injectedFactory = factory;
11
+ }
12
+ /**
13
+ * Sync client factory matching `@opencode-ai/sdk` signature.
14
+ *
15
+ * Classic plugins mostly need `ReturnType<typeof createOpencodeClient>` for
16
+ * `PluginInput.client`. Runtime construction should use a host-injected factory
17
+ * (`setCreateOpencodeClient`) or `createOpencodeClientAsync`.
18
+ */
19
+ export function createOpencodeClient(config) {
20
+ if (injectedFactory)
21
+ return injectedFactory(config);
22
+ throw new Error(`${PKG}: createOpencodeClient has no native factory. ` +
23
+ "Call setCreateOpencodeClient(...) from the host bridge, or use createOpencodeClientAsync().");
24
+ }
25
+ /** Async path: load native SDK and invoke createOpencodeClient / createKiloClient. */
26
+ export async function createOpencodeClientAsync(config) {
27
+ if (injectedFactory)
28
+ return injectedFactory(config);
29
+ const { importNativeSdk } = await import("@opencode-compat/adapter");
30
+ const native = await importNativeSdk();
31
+ const factory = native.createOpencodeClient ??
32
+ native.createKiloClient;
33
+ if (typeof factory !== "function") {
34
+ throw new Error(`${PKG}: native SDK has no createOpencodeClient/createKiloClient export`);
35
+ }
36
+ injectedFactory = factory;
37
+ return factory(config);
38
+ }
39
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@opencode-compat/facade-sdk",
3
+ "version": "0.1.0",
4
+ "description": "Minimal install-override stand-in for @opencode-ai/sdk",
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-sdk"
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
+ },
24
+ "files": [
25
+ "dist",
26
+ "LICENSE",
27
+ "README.md",
28
+ "!dist/**/*.map"
29
+ ],
30
+ "scripts": {
31
+ "build": "bunx tsc -p tsconfig.json",
32
+ "typecheck": "bunx tsc -p tsconfig.json --noEmit",
33
+ "prepack": "bunx tsc -p tsconfig.json"
34
+ },
35
+ "dependencies": {
36
+ "@opencode-compat/adapter": "0.1.0",
37
+ "@opencode-compat/profile": "0.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "typescript": "^5.8.3"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/oakimov/opencode-plugin-compat/issues"
44
+ },
45
+ "homepage": "https://github.com/oakimov/opencode-plugin-compat/tree/main/packages/facade-sdk#readme",
46
+ "keywords": [
47
+ "opencode",
48
+ "ocp",
49
+ "facade",
50
+ "sdk"
51
+ ],
52
+ "engines": {
53
+ "bun": ">=1.2.0"
54
+ }
55
+ }