Sign In

@opencode-ai/protocol

Package Overview
Dependencies
Maintainers
2
Versions
1082
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-next-14759
to
0.0.0-next-14761
dist/groups/form.d.ts

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

+96
import { Form } from "@opencode-ai/schema/form";
import { Location } from "@opencode-ai/schema/location";
import { Session } from "@opencode-ai/schema/session";
import { Context, Schema } from "effect";
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi";
import { ConflictError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError, InvalidRequestError, SessionNotFoundError, } from "../errors.js";
import { LocationQuery, locationQueryOpenApi } from "./location.js";
const CreatePayload = Schema.Struct({
id: Form.ID.pipe(Schema.optional),
title: Form.FormInfo.fields.title,
metadata: Form.FormInfo.fields.metadata,
mode: Schema.Literals(["form", "url"]),
fields: Form.FormInfo.fields.fields.pipe(Schema.optional),
url: Form.UrlInfo.fields.url.pipe(Schema.optional),
}).annotate({ identifier: "Form.CreatePayload" });
export const makeFormGroup = (locationMiddleware, sessionLocationMiddleware) => HttpApiGroup.make("server.form")
.add(HttpApiEndpoint.get("form.request.list", "/api/form/request", {
query: LocationQuery,
success: Location.response(Schema.Array(Form.Info)),
})
.annotateMerge(locationQueryOpenApi)
.annotateMerge(OpenApi.annotations({
identifier: "v2.form.request.list",
summary: "List pending form requests",
description: "Retrieve pending forms for a location.",
})))
.middleware(locationMiddleware)
.add(HttpApiEndpoint.get("session.form.list", "/api/session/:sessionID/form", {
params: { sessionID: Session.ID },
success: Schema.Struct({ data: Schema.Array(Form.Info) }),
error: SessionNotFoundError,
})
.middleware(sessionLocationMiddleware)
.annotateMerge(OpenApi.annotations({
identifier: "v2.session.form.list",
summary: "List session forms",
description: "Retrieve pending forms for a session.",
})))
.add(HttpApiEndpoint.post("session.form.create", "/api/session/:sessionID/form", {
params: { sessionID: Session.ID },
payload: CreatePayload,
success: Schema.Struct({ data: Form.Info }),
error: [SessionNotFoundError, ConflictError, InvalidRequestError],
})
.middleware(sessionLocationMiddleware)
.annotateMerge(OpenApi.annotations({
identifier: "v2.session.form.create",
summary: "Create session form",
description: "Create a form for a session.",
})))
.add(HttpApiEndpoint.get("session.form.get", "/api/session/:sessionID/form/:formID", {
params: { sessionID: Session.ID, formID: Form.ID },
success: Schema.Struct({ data: Form.Info }),
error: [SessionNotFoundError, FormNotFoundError],
})
.middleware(sessionLocationMiddleware)
.annotateMerge(OpenApi.annotations({
identifier: "v2.session.form.get",
summary: "Get session form",
description: "Retrieve a form for a session.",
})))
.add(HttpApiEndpoint.get("session.form.state", "/api/session/:sessionID/form/:formID/state", {
params: { sessionID: Session.ID, formID: Form.ID },
success: Schema.Struct({ data: Form.State }),
error: [SessionNotFoundError, FormNotFoundError],
})
.middleware(sessionLocationMiddleware)
.annotateMerge(OpenApi.annotations({
identifier: "v2.session.form.state",
summary: "Get form state",
description: "Retrieve the current state for a form.",
})))
.add(HttpApiEndpoint.post("session.form.reply", "/api/session/:sessionID/form/:formID/reply", {
params: { sessionID: Session.ID, formID: Form.ID },
payload: Form.Reply,
success: HttpApiSchema.NoContent,
error: [SessionNotFoundError, FormAlreadySettledError, FormInvalidAnswerError, FormNotFoundError],
})
.middleware(sessionLocationMiddleware)
.annotateMerge(OpenApi.annotations({
identifier: "v2.session.form.reply",
summary: "Reply to form",
description: "Submit an answer to a pending form.",
})))
.add(HttpApiEndpoint.post("session.form.cancel", "/api/session/:sessionID/form/:formID/cancel", {
params: { sessionID: Session.ID, formID: Form.ID },
success: HttpApiSchema.NoContent,
error: [SessionNotFoundError, FormAlreadySettledError, FormNotFoundError],
})
.middleware(sessionLocationMiddleware)
.annotateMerge(OpenApi.annotations({
identifier: "v2.session.form.cancel",
summary: "Cancel form",
description: "Cancel a pending form.",
})))
.annotateMerge(OpenApi.annotations({ title: "forms", description: "Session form routes." }));
+2
-1

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

import { FileSystemGroup } from "./groups/fs.js";
import { makeFormGroup } from "./groups/form.js";
import { CommandGroup } from "./groups/command.js";

@@ -32,3 +33,3 @@ import { SkillGroup } from "./groups/skill.js";

type SessionGroups<SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makeSessionGroup<SessionLocationId, SessionLocationService>> | HttpApiGroup.AddMiddleware<typeof MessageGroup, SessionLocationId>;
type MixedMiddlewareGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makePermissionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>> | ReturnType<typeof makeQuestionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>>;
type MixedMiddlewareGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService> = ReturnType<typeof makePermissionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>> | ReturnType<typeof makeFormGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>> | ReturnType<typeof makeQuestionGroup<LocationId, LocationService, SessionLocationId, SessionLocationService>>;
type ApiGroups<LocationId extends HttpApiMiddleware.AnyId, LocationService, SessionLocationId extends HttpApiMiddleware.AnyId, SessionLocationService, Event extends HttpApiGroup.Any> = typeof HealthGroup | LocationGroups<LocationId> | SessionGroups<SessionLocationId, SessionLocationService> | MixedMiddlewareGroups<LocationId, LocationService, SessionLocationId, SessionLocationService> | Event;

@@ -35,0 +36,0 @@ type EventGroupFor<Definitions extends ReadonlyArray<Definition>> = ReturnType<typeof makeEventGroup<Definitions>>;

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

import { FileSystemGroup } from "./groups/fs.js";
import { makeFormGroup } from "./groups/form.js";
import { CommandGroup } from "./groups/command.js";

@@ -44,2 +45,3 @@ import { SkillGroup } from "./groups/skill.js";

.add(ProjectGroup.middleware(locationMiddleware))
.add(makeFormGroup(locationMiddleware, sessionLocationMiddleware))
.add(makePermissionGroup(locationMiddleware, sessionLocationMiddleware))

@@ -46,0 +48,0 @@ .add(FileSystemGroup.middleware(locationMiddleware))

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

readonly "server.credential": "credential";
readonly "server.form": "form";
readonly "server.permission": "permission";

@@ -69,2 +70,3 @@ readonly "server.fs": "file";

readonly "permission.saved.remove": "removeSaved";
readonly "form.request.list": "listRequests";
readonly "question.request.list": "listRequests";

@@ -71,0 +73,0 @@ };

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

"server.credential": "credential",
"server.form": "form",
"server.permission": "permission",

@@ -53,2 +54,3 @@ "server.fs": "file",

"permission.saved.remove": "removeSaved",
"form.request.list": "listRequests",
"question.request.list": "listRequests",

@@ -55,0 +57,0 @@ };

@@ -92,2 +92,20 @@ import { Schema } from "effect";

}
declare const FormNotFoundError_base: Schema.Class<FormNotFoundError, Schema.TaggedStruct<"FormNotFoundError", {
readonly id: Schema.String;
readonly message: Schema.String;
}>, import("effect/Cause").YieldableError>;
export declare class FormNotFoundError extends FormNotFoundError_base {
}
declare const FormAlreadySettledError_base: Schema.Class<FormAlreadySettledError, Schema.TaggedStruct<"FormAlreadySettledError", {
readonly id: Schema.String;
readonly message: Schema.String;
}>, import("effect/Cause").YieldableError>;
export declare class FormAlreadySettledError extends FormAlreadySettledError_base {
}
declare const FormInvalidAnswerError_base: Schema.Class<FormInvalidAnswerError, Schema.TaggedStruct<"FormInvalidAnswerError", {
readonly id: Schema.String;
readonly message: Schema.String;
}>, import("effect/Cause").YieldableError>;
export declare class FormInvalidAnswerError extends FormInvalidAnswerError_base {
}
declare const ForbiddenError_base: Schema.Class<ForbiddenError, Schema.TaggedStruct<"ForbiddenError", {

@@ -94,0 +112,0 @@ readonly message: Schema.String;

@@ -73,2 +73,17 @@ import { Schema } from "effect";

}
export class FormNotFoundError extends Schema.TaggedErrorClass()("FormNotFoundError", {
id: Schema.String,
message: Schema.String,
}, { httpApiStatus: 404 }) {
}
export class FormAlreadySettledError extends Schema.TaggedErrorClass()("FormAlreadySettledError", {
id: Schema.String,
message: Schema.String,
}, { httpApiStatus: 409 }) {
}
export class FormInvalidAnswerError extends Schema.TaggedErrorClass()("FormInvalidAnswerError", {
id: Schema.String,
message: Schema.String,
}, { httpApiStatus: 400 }) {
}
export class ForbiddenError extends Schema.TaggedErrorClass()("ForbiddenError", { message: Schema.String }, { httpApiStatus: 403 }) {

@@ -75,0 +90,0 @@ }

{
"$schema": "https://json.schemastore.org/package.json",
"name": "@opencode-ai/protocol",
"version": "0.0.0-next-14759",
"version": "0.0.0-next-14761",
"type": "module",

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

"dependencies": {
"@opencode-ai/schema": "0.0.0-next-14759",
"@opencode-ai/schema": "0.0.0-next-14761",
"effect": "4.0.0-beta.83"

@@ -32,0 +32,0 @@ },

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