New:Socket for Asana Is Now Available.Learn more
Get Started

@opencode-ai/protocol

Package Overview
Dependencies
Maintainers
2
Versions
1560
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opencode-ai/protocol - npm Package Compare versions

Comparing version
0.0.0-dev-18706
to
0.0.0-dev-18708
+22
dist/groups/rpc.d.ts
import { Schema } from "effect";
import { HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
import { RpcError, RpcInternalError } from "../errors.js";
export declare const RpcInput: Schema.Struct<{
readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Unknown>>, Schema.optionalKey<Schema.Unknown>, never, never>;
}>;
export declare const RpcOutput: Schema.Struct<{
readonly output: Schema.optionalKey<Schema.Unknown>;
}>;
export declare const RpcGroup: HttpApiGroup.HttpApiGroup<"server.rpc", HttpApiEndpoint.HttpApiEndpoint<"rpc.call", "POST", "/api/rpc/:rpcID/:method", Schema.toCodecStringTree<Schema.Struct<{
rpcID: Schema.String;
method: Schema.String;
}>>, Schema.toCodecStringTree<Schema.Struct<{
readonly location: Schema.optional<Schema.Struct<{
readonly directory: Schema.optional<Schema.String>;
readonly workspace: Schema.optional<Schema.String>;
}>>;
}>>, Schema.toCodecJson<Schema.Struct<{
readonly input: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Unknown>>, Schema.optionalKey<Schema.Unknown>, never, never>;
}>>, never, Schema.toCodecJson<Schema.Struct<{
readonly output: Schema.optionalKey<Schema.Unknown>;
}>>, Schema.toCodecJson<typeof RpcError | typeof RpcInternalError>, never, never>, false>;
import { optional } from "@opencode-ai/schema/schema";
import { Schema } from "effect";
import { HttpApiEndpoint, HttpApiGroup, OpenApi } from "effect/unstable/httpapi";
import { RpcError, RpcInternalError } from "../errors.js";
import { LocationQuery, locationQueryOpenApi } from "./location.js";
export const RpcInput = Schema.Struct({ input: optional(Schema.Unknown) }).annotate({ identifier: "Rpc.Input" });
export const RpcOutput = Schema.Struct({ output: Schema.optionalKey(Schema.Unknown) }).annotate({
identifier: "Rpc.Output",
});
export const RpcGroup = HttpApiGroup.make("server.rpc")
.add(HttpApiEndpoint.post("rpc.call", "/api/rpc/:rpcID/:method", {
params: { rpcID: Schema.String, method: Schema.String },
query: LocationQuery,
payload: RpcInput,
success: RpcOutput,
error: [RpcError, RpcInternalError],
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(OpenApi.annotations({
identifier: "v2.rpc.call",
summary: "Call a plugin RPC",
description: "Dispatch a method to the currently registered RPC at the requested location.",
})))
.annotateMerge(OpenApi.annotations({ title: "rpc", description: "Plugin RPC routes." }));
+2
-1

@@ -14,2 +14,3 @@ import { Context } from "effect";

import { SkillGroup } from "./groups/skill.js";
import { RpcGroup } from "./groups/rpc.js";
import { EventGroup, makeEventGroup } from "./groups/event.js";

@@ -38,3 +39,3 @@ import type { Definition } from "@opencode-ai/schema/event";

import { WorkspaceGroup } from "./groups/workspace.js";
type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof LocationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof WebSearchGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof McpGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CredentialGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PtyGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
type LocationGroups<LocationId extends HttpApiMiddleware.AnyId> = HttpApiGroup.AddMiddleware<typeof LocationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof AgentGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PluginGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ModelGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProviderGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof IntegrationGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof WebSearchGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof McpGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CredentialGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ProjectGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof FileSystemGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof CommandGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof SkillGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof RpcGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof PtyGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ShellGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ReferenceGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof VcsGroup, LocationId> | HttpApiGroup.AddMiddleware<typeof ConfigGroup, LocationId>;
type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService>> | typeof MessageGroup;

@@ -41,0 +42,0 @@ type FormGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, FormLocationId extends HttpApiMiddleware.AnyId, FormLocationService> = ReturnType<typeof makeFormGroup<LocationId, LocationService, FormLocationId, FormLocationService>>;

@@ -14,2 +14,3 @@ import { Context } from "effect";

import { SkillGroup } from "./groups/skill.js";
import { RpcGroup } from "./groups/rpc.js";
import { EventGroup, makeEventGroup } from "./groups/event.js";

@@ -58,2 +59,3 @@ import { AgentGroup } from "./groups/agent.js";

.add(SkillGroup.middleware(locationMiddleware))
.add(RpcGroup.middleware(locationMiddleware))
.add(eventGroup)

@@ -60,0 +62,0 @@ .add(PtyGroup.middleware(locationMiddleware))

@@ -49,2 +49,3 @@ import { InvalidRequestError, SessionNotFoundError } from "./errors.js";

readonly "server.skill": "skill";
readonly "server.rpc": "rpc";
readonly "server.event": "event";

@@ -51,0 +52,0 @@ readonly "server.pty": "pty";

@@ -36,2 +36,3 @@ import { InvalidRequestError, SessionNotFoundError } from "./errors.js";

"server.skill": "skill",
"server.rpc": "rpc",
"server.event": "event",

@@ -38,0 +39,0 @@ "server.pty": "pty",

@@ -9,2 +9,16 @@ import { Schema } from "effect";

}
declare const RpcError_base: Schema.Class<RpcError, Schema.TaggedStruct<"RpcError", {
readonly type: Schema.String;
readonly message: Schema.String;
readonly data: Schema.optional<Schema.Unknown>;
}>, import("effect/Cause").YieldableError>;
export declare class RpcError extends RpcError_base {
}
declare const RpcInternalError_base: Schema.Class<RpcInternalError, Schema.TaggedStruct<"RpcInternalError", {
readonly type: Schema.Literals<readonly ["rpc.internal", "rpc.invalid_output"]>;
readonly message: Schema.String;
readonly data: Schema.optional<Schema.Unknown>;
}>, import("effect/Cause").YieldableError>;
export declare class RpcInternalError extends RpcInternalError_base {
}
declare const UnauthorizedError_base: Schema.Class<UnauthorizedError, Schema.TaggedStruct<"UnauthorizedError", {

@@ -11,0 +25,0 @@ readonly message: Schema.String;

@@ -9,2 +9,14 @@ import { Schema } from "effect";

}
export class RpcError extends Schema.TaggedError()("RpcError", {
type: Schema.String,
message: Schema.String,
data: Schema.optional(Schema.Unknown),
}, { httpApiStatus: 400 }) {
}
export class RpcInternalError extends Schema.TaggedError()("RpcInternalError", {
type: Schema.Literals(["rpc.internal", "rpc.invalid_output"]),
message: Schema.String,
data: Schema.optional(Schema.Unknown),
}, { httpApiStatus: 500 }) {
}
export class UnauthorizedError extends Schema.TaggedError()("UnauthorizedError", { message: Schema.String }, { httpApiStatus: 401 }) {

@@ -11,0 +23,0 @@ }

@@ -11,4 +11,13 @@ import { Event } from "@opencode-ai/schema/event";

};
const rpcEvent = Schema.Struct({
id: Event.ID,
created: Schema.Finite,
metadata: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)),
type: Schema.TemplateLiteral(["rpc.", Schema.String]),
location: Location.Ref,
data: Schema.Record(Schema.String, Schema.Unknown),
}).annotate({ identifier: "V2Event.rpc" });
const schema = (definitions) => Schema.Union([
...definitions,
rpcEvent,
...(definitions.some((definition) => definition.type === "server.connected")

@@ -34,3 +43,3 @@ ? []

summary: "Subscribe to events",
description: "Subscribe to native event payloads for the server. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.",
description: "Subscribe to native events and plugin RPC events across all server locations. Volatile by contract: a slow consumer overflows and fails the stream, and events during disconnection are missed.",
})))

@@ -44,2 +53,2 @@ .annotateMerge(OpenApi.annotations({ title: "event", description: "Experimental event stream routes." })),

export const OpenCodeEvent = event.schema;
export const isOpenCodeEvent = (event) => event.type === "server.connected" || EventManifest.isServer(event);
export const isOpenCodeEvent = (event) => event.type === "server.connected" || EventManifest.isServer(event) || event.type.startsWith("rpc.");

@@ -11,4 +11,4 @@ import { Location } from "@opencode-ai/schema/location";

readonly location: typeof Location.Info;
readonly data: Schema.$Array<Schema.Union<readonly [Schema.Struct<{
readonly id: Schema.brand<Schema.String, "Plugin.ID">;
readonly data: Schema.$Array<Schema.Struct<{
readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Plugin.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Plugin.ID">>, never, never>;
readonly source: Schema.Union<readonly [Schema.Struct<{

@@ -25,21 +25,14 @@ readonly type: Schema.Literal<"builtin">;

}>]>;
readonly status: Schema.Literal<"active">;
readonly tui: Schema.Boolean;
}>, Schema.Struct<{
readonly id: Schema.decodeTo<Schema.optional<Schema.toType<Schema.brand<Schema.String, "Plugin.ID">>>, Schema.optionalKey<Schema.brand<Schema.String, "Plugin.ID">>, never, never>;
readonly source: Schema.Union<readonly [Schema.Struct<{
readonly type: Schema.Literal<"builtin">;
readonly features: Schema.Struct<{
readonly server: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
readonly tui: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
readonly rpc: Schema.decodeTo<Schema.optional<Schema.toType<Schema.Literal<true>>>, Schema.optionalKey<Schema.Literal<true>>, never, never>;
}>;
readonly state: Schema.Union<readonly [Schema.Struct<{
readonly status: Schema.Literal<"active">;
}>, Schema.Struct<{
readonly type: Schema.Literal<"package">;
readonly package: Schema.String;
}>, Schema.Struct<{
readonly type: Schema.Literal<"local">;
readonly path: Schema.String;
}>, Schema.Struct<{
readonly type: Schema.Literal<"sdk">;
readonly status: Schema.Literal<"failed">;
readonly error: Schema.String;
}>]>;
readonly status: Schema.Literal<"failed">;
readonly error: Schema.String;
readonly tui: Schema.Boolean;
}>]>>;
}>>;
}>>, never, never, never>, false>;
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/protocol",
"version": "0.0.0-dev-18706",
"version": "0.0.0-dev-18708",
"type": "module",

@@ -35,3 +35,3 @@ "license": "MIT",

"dependencies": {
"@opencode-ai/schema": "0.0.0-dev-18706",
"@opencode-ai/schema": "0.0.0-dev-18708",
"effect": "4.0.0-rc.112"

@@ -38,0 +38,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display