@opencode-ai/schema 0.0.0-dev-18706 → 0.0.0-dev-18708
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/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/plugin.d.ts +26 -19
- package/dist/plugin.js +15 -15
- package/dist/rpc.d.ts +111 -0
- package/dist/rpc.js +9 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { Project } from "./project.js";
|
|
|
18
18
|
export { Worktree } from "./worktree.js";
|
|
19
19
|
export { Provider } from "./provider.js";
|
|
20
20
|
export { Reference } from "./reference.js";
|
|
21
|
+
export { Rpc } from "./rpc.js";
|
|
21
22
|
export { WebSearch } from "./websearch.js";
|
|
22
23
|
export { Session } from "./session.js";
|
|
23
24
|
export { Vcs } from "./vcs.js";
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export { Project } from "./project.js";
|
|
|
18
18
|
export { Worktree } from "./worktree.js";
|
|
19
19
|
export { Provider } from "./provider.js";
|
|
20
20
|
export { Reference } from "./reference.js";
|
|
21
|
+
export { Rpc } from "./rpc.js";
|
|
21
22
|
export { WebSearch } from "./websearch.js";
|
|
22
23
|
export { Session } from "./session.js";
|
|
23
24
|
export { Vcs } from "./vcs.js";
|
package/dist/plugin.d.ts
CHANGED
|
@@ -14,22 +14,22 @@ export declare const Source: Schema.Union<readonly [Schema.Struct<{
|
|
|
14
14
|
readonly type: Schema.Literal<"sdk">;
|
|
15
15
|
}>]>;
|
|
16
16
|
export type Source = typeof Source.Type;
|
|
17
|
-
export declare const
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}>, Schema.Struct<{
|
|
25
|
-
readonly type: Schema.Literal<"local">;
|
|
26
|
-
readonly path: Schema.String;
|
|
27
|
-
}>, Schema.Struct<{
|
|
28
|
-
readonly type: Schema.Literal<"sdk">;
|
|
29
|
-
}>]>;
|
|
17
|
+
export declare const Features: Schema.Struct<{
|
|
18
|
+
readonly server: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
19
|
+
readonly tui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
20
|
+
readonly rpc: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
21
|
+
}>;
|
|
22
|
+
export type Features = typeof Features.Type;
|
|
23
|
+
export declare const State: Schema.Union<readonly [Schema.Struct<{
|
|
30
24
|
readonly status: Schema.Literal<"active">;
|
|
31
|
-
readonly tui: Schema.Boolean;
|
|
32
25
|
}>, Schema.Struct<{
|
|
26
|
+
readonly status: Schema.Literal<"failed">;
|
|
27
|
+
readonly error: Schema.String;
|
|
28
|
+
}>]>;
|
|
29
|
+
export type State = typeof State.Type;
|
|
30
|
+
export interface Info extends Schema.Schema.Type<typeof Info> {
|
|
31
|
+
}
|
|
32
|
+
export declare const Info: Schema.Struct<{
|
|
33
33
|
readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Plugin.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Plugin.ID">>, never, never>;
|
|
34
34
|
readonly source: Schema.Union<readonly [Schema.Struct<{
|
|
35
35
|
readonly type: Schema.Literal<"builtin">;
|
|
@@ -42,11 +42,18 @@ export declare const Info: Schema.Union<readonly [Schema.Struct<{
|
|
|
42
42
|
}>, Schema.Struct<{
|
|
43
43
|
readonly type: Schema.Literal<"sdk">;
|
|
44
44
|
}>]>;
|
|
45
|
-
readonly
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
readonly features: Schema.Struct<{
|
|
46
|
+
readonly server: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
47
|
+
readonly tui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
48
|
+
readonly rpc: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
|
|
49
|
+
}>;
|
|
50
|
+
readonly state: Schema.Union<readonly [Schema.Struct<{
|
|
51
|
+
readonly status: Schema.Literal<"active">;
|
|
52
|
+
}>, Schema.Struct<{
|
|
53
|
+
readonly status: Schema.Literal<"failed">;
|
|
54
|
+
readonly error: Schema.String;
|
|
55
|
+
}>]>;
|
|
56
|
+
}>;
|
|
50
57
|
export declare const Event: {
|
|
51
58
|
Added: Schema.Struct<{
|
|
52
59
|
readonly id: Schema.brand<Schema.String, "Event.ID"> & {
|
package/dist/plugin.js
CHANGED
|
@@ -9,21 +9,21 @@ export const Source = Schema.Union([
|
|
|
9
9
|
Schema.Struct({ type: Schema.Literal("local"), path: Schema.String }),
|
|
10
10
|
Schema.Struct({ type: Schema.Literal("sdk") }),
|
|
11
11
|
]).annotate({ identifier: "Plugin.Source" });
|
|
12
|
-
export const
|
|
13
|
-
Schema.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}),
|
|
19
|
-
Schema.Struct({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
export const Features = Schema.Struct({
|
|
13
|
+
server: Schema.Literal(true).pipe(optional),
|
|
14
|
+
tui: Schema.Literal(true).pipe(optional),
|
|
15
|
+
rpc: Schema.Literal(true).pipe(optional),
|
|
16
|
+
}).annotate({ identifier: "Plugin.Features" });
|
|
17
|
+
export const State = Schema.Union([
|
|
18
|
+
Schema.Struct({ status: Schema.Literal("active") }),
|
|
19
|
+
Schema.Struct({ status: Schema.Literal("failed"), error: Schema.String }),
|
|
20
|
+
]).annotate({ identifier: "Plugin.State" });
|
|
21
|
+
export const Info = Schema.Struct({
|
|
22
|
+
id: ID.pipe(optional),
|
|
23
|
+
source: Source,
|
|
24
|
+
features: Features,
|
|
25
|
+
state: State,
|
|
26
|
+
}).annotate({ identifier: "Plugin.Info" });
|
|
27
27
|
const Added = ephemeral({
|
|
28
28
|
type: "plugin.added",
|
|
29
29
|
schema: { id: ID },
|
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export * as Rpc from "./rpc.js";
|
|
2
|
+
import type { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
+
import type { JsonSchema, Schema } from "effect";
|
|
4
|
+
import type { Event } from "./event.js";
|
|
5
|
+
import type { Location } from "./location.js";
|
|
6
|
+
import type { Tool } from "./tool.js";
|
|
7
|
+
export type ErrorMap = Readonly<Record<string, Tool.ValueSchema>> & {
|
|
8
|
+
readonly [Name in `rpc.${string}`]?: never;
|
|
9
|
+
};
|
|
10
|
+
export interface Method {
|
|
11
|
+
readonly input: Tool.ValueSchema;
|
|
12
|
+
readonly output: Tool.ValueSchema;
|
|
13
|
+
readonly errors?: ErrorMap;
|
|
14
|
+
}
|
|
15
|
+
export type PortableValueSchema = StandardSchemaV1<unknown, unknown> | JsonSchema.JsonSchema;
|
|
16
|
+
export interface PortableMethod extends Method {
|
|
17
|
+
readonly input: PortableValueSchema;
|
|
18
|
+
readonly output: PortableValueSchema;
|
|
19
|
+
readonly errors?: Readonly<Record<string, PortableValueSchema>> & {
|
|
20
|
+
readonly [Name in `rpc.${string}`]?: never;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
type EventDataObject = Readonly<Record<string, unknown>>;
|
|
24
|
+
type EventValueSchema = Schema.Codec<EventDataObject, EventDataObject> | StandardSchemaV1<unknown, EventDataObject> | (JsonSchema.JsonSchema & {
|
|
25
|
+
readonly type: "object";
|
|
26
|
+
});
|
|
27
|
+
type PortableEventValueSchema = StandardSchemaV1<unknown, EventDataObject> | (JsonSchema.JsonSchema & {
|
|
28
|
+
readonly type: "object";
|
|
29
|
+
});
|
|
30
|
+
export interface EventDefinition {
|
|
31
|
+
readonly schema: EventValueSchema;
|
|
32
|
+
}
|
|
33
|
+
export type PortableEventDefinition = EventDefinition & {
|
|
34
|
+
readonly schema: PortableEventValueSchema;
|
|
35
|
+
};
|
|
36
|
+
export interface Definition {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly methods: Readonly<Record<string, Method>> & {
|
|
39
|
+
readonly events?: never;
|
|
40
|
+
};
|
|
41
|
+
readonly events: Readonly<Record<string, EventDefinition>>;
|
|
42
|
+
}
|
|
43
|
+
export interface PortableDefinition extends Definition {
|
|
44
|
+
readonly methods: Readonly<Record<string, PortableMethod>> & {
|
|
45
|
+
readonly events?: never;
|
|
46
|
+
};
|
|
47
|
+
readonly events: Readonly<Record<string, PortableEventDefinition>>;
|
|
48
|
+
}
|
|
49
|
+
export declare function define<const D extends Definition>(definition: D): D;
|
|
50
|
+
export type Input<S extends Tool.ValueSchema> = S extends Schema.Top ? S["Encoded"] : S extends StandardSchemaV1 ? StandardSchemaV1.InferInput<S> : unknown;
|
|
51
|
+
export type Output<S extends Tool.ValueSchema> = S extends Schema.Top ? S["Type"] : S extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<S> : unknown;
|
|
52
|
+
export type HandlerOutput<S extends Tool.ValueSchema> = S extends Schema.Top ? Output<S> : Input<S>;
|
|
53
|
+
type MethodErrors<M extends Method> = M extends {
|
|
54
|
+
readonly errors: infer Errors extends ErrorMap;
|
|
55
|
+
} ? Errors : never;
|
|
56
|
+
type ErrorSchema<M extends Method, Name extends ErrorName<M>> = MethodErrors<M>[Name];
|
|
57
|
+
type ErrorData<Data> = unknown extends Data ? {
|
|
58
|
+
readonly data: Data;
|
|
59
|
+
} : undefined extends Data ? {
|
|
60
|
+
readonly data?: Data;
|
|
61
|
+
} : {
|
|
62
|
+
readonly data: Data;
|
|
63
|
+
};
|
|
64
|
+
type ErrorDataArguments<Data> = unknown extends Data ? [data: Data] : undefined extends Data ? [data?: Data] : [data: Data];
|
|
65
|
+
type Simplify<A> = {
|
|
66
|
+
readonly [K in keyof A]: A[K];
|
|
67
|
+
};
|
|
68
|
+
declare const HandlerErrorTypeId: unique symbol;
|
|
69
|
+
export interface Failure<Type extends string = string, Data = unknown> {
|
|
70
|
+
readonly type: Type;
|
|
71
|
+
readonly message: string;
|
|
72
|
+
readonly data?: Data;
|
|
73
|
+
}
|
|
74
|
+
export type SystemError = Failure<"rpc.unavailable" | "rpc.method_not_found" | "rpc.invalid_input" | "rpc.invalid_output" | "rpc.internal", never>;
|
|
75
|
+
export type ErrorName<M extends Method> = M extends {
|
|
76
|
+
readonly errors: infer Errors extends ErrorMap;
|
|
77
|
+
} ? Exclude<keyof Errors & string, `rpc.${string}`> : never;
|
|
78
|
+
export type HandlerErrorFor<M extends Method, Name extends ErrorName<M>> = Simplify<{
|
|
79
|
+
readonly type: Name;
|
|
80
|
+
readonly message: string;
|
|
81
|
+
readonly [HandlerErrorTypeId]: true;
|
|
82
|
+
} & ErrorData<HandlerOutput<ErrorSchema<M, Name>>>>;
|
|
83
|
+
export type HandlerError<M extends Method> = {
|
|
84
|
+
readonly [Name in ErrorName<M>]: HandlerErrorFor<M, Name>;
|
|
85
|
+
}[ErrorName<M>];
|
|
86
|
+
export type MethodErrorFor<M extends Method, Name extends ErrorName<M>> = Simplify<{
|
|
87
|
+
readonly type: Name;
|
|
88
|
+
readonly message: string;
|
|
89
|
+
} & ErrorData<Output<ErrorSchema<M, Name>>>>;
|
|
90
|
+
export type MethodError<M extends Method> = {
|
|
91
|
+
readonly [Name in ErrorName<M>]: MethodErrorFor<M, Name>;
|
|
92
|
+
}[ErrorName<M>];
|
|
93
|
+
export type ErrorArguments<M extends Method, Name extends ErrorName<M>> = [
|
|
94
|
+
type: Name,
|
|
95
|
+
message: string,
|
|
96
|
+
...data: ErrorDataArguments<HandlerOutput<ErrorSchema<M, Name>>>
|
|
97
|
+
];
|
|
98
|
+
export type ErrorFactory<M extends Method> = <Name extends ErrorName<M>>(...args: ErrorArguments<M, Name>) => HandlerErrorFor<M, Name>;
|
|
99
|
+
export type EventInputData<S extends EventValueSchema> = S extends JsonSchema.JsonSchema ? EventDataObject : HandlerOutput<S>;
|
|
100
|
+
export type EventData<S extends EventValueSchema> = S extends JsonSchema.JsonSchema ? EventDataObject : Output<S>;
|
|
101
|
+
export type EventInput<D extends Definition> = {
|
|
102
|
+
[Name in keyof D["events"] & string]: [name: Name, data: EventInputData<D["events"][Name]["schema"]>];
|
|
103
|
+
}[keyof D["events"] & string];
|
|
104
|
+
type EventPayloadFor<D extends Definition, Name extends keyof D["events"] & string> = Omit<Event.Payload<Event.EphemeralDefinition>, "type" | "data" | "durable" | "location"> & {
|
|
105
|
+
readonly type: `rpc.${D["id"]}.${Name}`;
|
|
106
|
+
readonly data: EventData<D["events"][Name]["schema"]>;
|
|
107
|
+
readonly location: Location.Ref;
|
|
108
|
+
};
|
|
109
|
+
export type EventPayload<D extends Definition, Name extends keyof D["events"] & string = keyof D["events"] & string> = {
|
|
110
|
+
readonly [K in Name]: EventPayloadFor<D, K>;
|
|
111
|
+
}[Name];
|
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * as Rpc from "./rpc.js";
|
|
2
|
+
export function define(definition) {
|
|
3
|
+
const reserved = Object.values(definition.methods)
|
|
4
|
+
.flatMap((method) => Object.keys(method.errors ?? {}))
|
|
5
|
+
.find((name) => name.startsWith("rpc."));
|
|
6
|
+
if (reserved)
|
|
7
|
+
throw new Error(`RPC error names starting with "rpc." are reserved: ${reserved}`);
|
|
8
|
+
return definition;
|
|
9
|
+
}
|