The open source coding agent.
TypeScript
sync
Dax Raad48f81fe4d3a2
diff --git a/js/src/app/config.ts b/js/src/app/config.tsindex 348eb77c39b..e68b24bb9cd 100644--- a/js/src/app/config.ts+++ b/js/src/app/config.ts@@ -11,25 +11,33 @@ export namespace Config {return result;});- export const Model = z.object({- name: z.string().optional(),- cost: z.object({- input: z.number(),- inputCached: z.number(),- output: z.number(),- outputCached: z.number(),- }),- contextWindow: z.number(),- maxTokens: z.number().optional(),- attachment: z.boolean(),- reasoning: z.boolean().optional(),- });+ export const Model = z+ .object({+ name: z.string().optional(),+ cost: z.object({+ input: z.number(),+ inputCached: z.number(),+ output: z.number(),+ outputCached: z.number(),+ }),+ contextWindow: z.number(),+ maxTokens: z.number().optional(),+ attachment: z.boolean(),+ reasoning: z.boolean().optional(),+ })+ .openapi({+ ref: "model",+ });export type Model = z.output<typeof Model>;- export const Provider = z.object({- options: z.record(z.string(), z.any()).optional(),- models: z.record(z.string(), Model),- });+ export const Provider = z+ .object({+ options: z.record(z.string(), z.any()).optional(),+ models: z.record(z.string(), Model),+ })+ .openapi({+ ref: "provider",+ });export type Provider = z.output<typeof Provider>;export const Info = zdiff --git a/js/src/server/server.ts b/js/src/server/server.tsindex 98b2cf5cbce..ff2d0924be6 100644--- a/js/src/server/server.ts+++ b/js/src/server/server.ts@@ -10,16 +10,6 @@ import { Config } from "../app/config";import { LLM } from "../llm/llm";import { Message } from "../session/message";-const SessionInfo = Session.Info.openapi({- ref: "Session.Info",-});--const ProviderInfo = Config.Provider.openapi({- ref: "Provider.Info",-});--type ProviderInfo = z.output<typeof ProviderInfo>;-export namespace Server {const log = Log.create({ service: "server" });const PORT = 16713;@@ -92,7 +82,7 @@ export namespace Server {description: "Successfully created session",content: {"application/json": {- schema: resolver(SessionInfo),+ schema: resolver(Session.Info),},},},@@ -112,7 +102,7 @@ export namespace Server {description: "Successfully shared session",content: {"application/json": {- schema: resolver(SessionInfo),+ schema: resolver(Session.Info),},},},@@ -244,7 +234,7 @@ export namespace Server {description: "List of providers",content: {"application/json": {- schema: resolver(z.record(z.string(), ProviderInfo)),+ schema: resolver(z.record(z.string(), Config.Provider)),},},},@@ -252,7 +242,7 @@ export namespace Server {}),async (c) => {const providers = await LLM.providers();- const result: Record<string, ProviderInfo> = {};+ const result: Record<string, Config.Provider> = {};for (const [providerID, provider] of Object.entries(providers)) {result[providerID] = provider.info;}diff --git a/js/src/session/session.ts b/js/src/session/session.tsindex 4b503050698..5e07764b801 100644--- a/js/src/session/session.ts+++ b/js/src/session/session.ts@@ -24,11 +24,15 @@ import { Bus } from "../bus";export namespace Session {const log = Log.create({ service: "session" });- export const Info = z.object({- id: Identifier.schema("session"),- shareID: z.string().optional(),- title: z.string(),- });+ export const Info = z+ .object({+ id: Identifier.schema("session"),+ shareID: z.string().optional(),+ title: z.string(),+ })+ .openapi({+ ref: "session.info",+ });export type Info = z.output<typeof Info>;export const Event = {diff --git a/pkg/client/gen/openapi.json b/pkg/client/gen/openapi.jsonindex 274c6c7d651..4e6506e73a9 100644--- a/pkg/client/gen/openapi.json+++ b/pkg/client/gen/openapi.json@@ -33,7 +33,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/Session.Info"+ "$ref": "#/components/schemas/session.info"}}}@@ -52,7 +52,7 @@"content": {"application/json": {"schema": {- "$ref": "#/components/schemas/Session.Info"+ "$ref": "#/components/schemas/session.info"}}}@@ -129,23 +129,7 @@"schema": {"type": "array","items": {- "type": "object",- "properties": {- "id": {- "type": "string",- "pattern": "^ses"- },- "shareID": {- "type": "string"- },- "title": {- "type": "string"- }- },- "required": [- "id",- "title"- ]+ "$ref": "#/components/schemas/session.info"}}}@@ -254,7 +238,7 @@"schema": {"type": "object","additionalProperties": {- "$ref": "#/components/schemas/Provider.Info"+ "$ref": "#/components/schemas/provider"}}}@@ -724,23 +708,7 @@"type": "object","properties": {"info": {- "type": "object",- "properties": {- "id": {- "type": "string",- "pattern": "^ses"- },- "shareID": {- "type": "string"- },- "title": {- "type": "string"- }- },- "required": [- "id",- "title"- ]+ "$ref": "#/components/schemas/session.info"}},"required": [@@ -753,7 +721,7 @@"properties"]},- "Session.Info": {+ "session.info": {"type": "object","properties": {"id": {@@ -772,7 +740,7 @@"title"]},- "Provider.Info": {+ "provider": {"type": "object","properties": {"options": {@@ -782,58 +750,61 @@"models": {"type": "object","additionalProperties": {- "type": "object",- "properties": {- "name": {- "type": "string"- },- "cost": {- "type": "object",- "properties": {- "input": {- "type": "number"- },- "inputCached": {- "type": "number"- },- "output": {- "type": "number"- },- "outputCached": {- "type": "number"- }- },- "required": [- "input",- "inputCached",- "output",- "outputCached"- ]- },- "contextWindow": {- "type": "number"- },- "maxTokens": {- "type": "number"- },- "attachment": {- "type": "boolean"- },- "reasoning": {- "type": "boolean"- }- },- "required": [- "cost",- "contextWindow",- "attachment"- ]+ "$ref": "#/components/schemas/model"}}},"required": ["models"]+ },+ "model": {+ "type": "object",+ "properties": {+ "name": {+ "type": "string"+ },+ "cost": {+ "type": "object",+ "properties": {+ "input": {+ "type": "number"+ },+ "inputCached": {+ "type": "number"+ },+ "output": {+ "type": "number"+ },+ "outputCached": {+ "type": "number"+ }+ },+ "required": [+ "input",+ "inputCached",+ "output",+ "outputCached"+ ]+ },+ "contextWindow": {+ "type": "number"+ },+ "maxTokens": {+ "type": "number"+ },+ "attachment": {+ "type": "boolean"+ },+ "reasoning": {+ "type": "boolean"+ }+ },+ "required": [+ "cost",+ "contextWindow",+ "attachment"+ ]}}}diff --git a/pkg/client/generated-client.go b/pkg/client/generated-client.goindex 7af8b48fde3..0fce536e749 100644--- a/pkg/client/generated-client.go+++ b/pkg/client/generated-client.go@@ -49,11 +49,7 @@ type EventMessageUpdated struct {// EventSessionUpdated defines model for Event.session.updated.type EventSessionUpdated struct {Properties struct {- Info struct {- Id string `json:"id"`- ShareID *string `json:"shareID,omitempty"`- Title string `json:"title"`- } `json:"info"`+ Info SessionInfo `json:"info"`} `json:"properties"`Type string `json:"type"`}@@ -174,25 +170,28 @@ type MessageToolInvocationToolResult struct {ToolName string `json:"toolName"`}-// ProviderInfo defines model for Provider.Info.-type ProviderInfo struct {- Models map[string]struct {- Attachment bool `json:"attachment"`- ContextWindow float32 `json:"contextWindow"`- Cost struct {- Input float32 `json:"input"`- InputCached float32 `json:"inputCached"`- Output float32 `json:"output"`- OutputCached float32 `json:"outputCached"`- } `json:"cost"`- MaxTokens *float32 `json:"maxTokens,omitempty"`- Name *string `json:"name,omitempty"`- Reasoning *bool `json:"reasoning,omitempty"`- } `json:"models"`+// Model defines model for model.+type Model struct {+ Attachment bool `json:"attachment"`+ ContextWindow float32 `json:"contextWindow"`+ Cost struct {+ Input float32 `json:"input"`+ InputCached float32 `json:"inputCached"`+ Output float32 `json:"output"`+ OutputCached float32 `json:"outputCached"`+ } `json:"cost"`+ MaxTokens *float32 `json:"maxTokens,omitempty"`+ Name *string `json:"name,omitempty"`+ Reasoning *bool `json:"reasoning,omitempty"`+}++// Provider defines model for provider.+type Provider struct {+ Models map[string]Model `json:"models"`Options *map[string]interface{} `json:"options,omitempty"`}-// SessionInfo defines model for Session.Info.+// SessionInfo defines model for session.info.type SessionInfo struct {Id string `json:"id"`ShareID *string `json:"shareID,omitempty"`@@ -1330,7 +1329,7 @@ func (r GetEventResponse) StatusCode() int {type PostProviderListResponse struct {Body []byteHTTPResponse *http.Response- JSON200 *map[string]ProviderInfo+ JSON200 *map[string]Provider}// Status returns HTTPResponse.Status@@ -1418,11 +1417,7 @@ func (r PostSessionCreateResponse) StatusCode() int {type PostSessionListResponse struct {Body []byteHTTPResponse *http.Response- JSON200 *[]struct {- Id string `json:"id"`- ShareID *string `json:"shareID,omitempty"`- Title string `json:"title"`- }+ JSON200 *[]SessionInfo}// Status returns HTTPResponse.Status@@ -1630,7 +1625,7 @@ func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponsswitch {case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:- var dest map[string]ProviderInfo+ var dest map[string]Providerif err := json.Unmarshal(bodyBytes, &dest); err != nil {return nil, err}@@ -1734,11 +1729,7 @@ func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse,switch {case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:- var dest []struct {- Id string `json:"id"`- ShareID *string `json:"shareID,omitempty"`- Title string `json:"title"`- }+ var dest []SessionInfoif err := json.Unmarshal(bodyBytes, &dest); err != nil {return nil, err}