@mcoda/core
Advanced tools
| import { Agent, RoutingDefaults, RoutingDefaultsUpdate, RoutingPreview } from "@mcoda/shared"; | ||
| export interface RoutingPreviewRequest { | ||
| workspaceId: string; | ||
| commandName: string; | ||
| agentOverride?: string; | ||
| taskType?: string; | ||
| projectKey?: string; | ||
| requiredCapabilities?: string[]; | ||
| } | ||
| export declare class RoutingApiClient { | ||
| private baseUrl; | ||
| constructor(baseUrl: string); | ||
| static create(): RoutingApiClient; | ||
| private fetchJson; | ||
| private putJson; | ||
| private postJson; | ||
| getWorkspaceDefaults(workspaceId: string): Promise<RoutingDefaults | undefined>; | ||
| updateWorkspaceDefaults(workspaceId: string, update: RoutingDefaultsUpdate): Promise<RoutingDefaults | undefined>; | ||
| preview(request: RoutingPreviewRequest): Promise<RoutingPreview | undefined>; | ||
| listAgents(): Promise<Agent[] | undefined>; | ||
| getAgent(idOrSlug: string): Promise<Agent | undefined>; | ||
| } | ||
| //# sourceMappingURL=RoutingApiClient.d.ts.map |
| {"version":3,"file":"RoutingApiClient.d.ts","sourceRoot":"","sources":["../../../src/services/agents/RoutingApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAM9F,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC;AAED,qBAAa,gBAAgB;IACf,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,MAAM;IAEnC,MAAM,CAAC,MAAM,IAAI,gBAAgB;YAKnB,SAAS;YAQT,OAAO;YAUP,QAAQ;IAUhB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAI/E,uBAAuB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAIjH,OAAO,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAW5E,UAAU,IAAI,OAAO,CAAC,KAAK,EAAE,GAAG,SAAS,CAAC;IAI1C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;CAG7D"} |
| const pickBaseUrl = () => { | ||
| return process.env.MCODA_ROUTING_API_URL ?? process.env.MCODA_API_BASE_URL; | ||
| }; | ||
| export class RoutingApiClient { | ||
| constructor(baseUrl) { | ||
| this.baseUrl = baseUrl; | ||
| } | ||
| static create() { | ||
| const baseUrl = pickBaseUrl() ?? "http://localhost"; | ||
| return new RoutingApiClient(baseUrl); | ||
| } | ||
| async fetchJson(path) { | ||
| const resp = await fetch(new URL(path, this.baseUrl), { | ||
| headers: { accept: "application/json" }, | ||
| }); | ||
| if (!resp.ok) | ||
| return undefined; | ||
| return (await resp.json()); | ||
| } | ||
| async putJson(path, body) { | ||
| const resp = await fetch(new URL(path, this.baseUrl), { | ||
| method: "PUT", | ||
| headers: { "content-type": "application/json", accept: "application/json" }, | ||
| body: JSON.stringify(body), | ||
| }); | ||
| if (!resp.ok) | ||
| return undefined; | ||
| return (await resp.json()); | ||
| } | ||
| async postJson(path, body) { | ||
| const resp = await fetch(new URL(path, this.baseUrl), { | ||
| method: "POST", | ||
| headers: { "content-type": "application/json", accept: "application/json" }, | ||
| body: JSON.stringify(body), | ||
| }); | ||
| if (!resp.ok) | ||
| return undefined; | ||
| return (await resp.json()); | ||
| } | ||
| async getWorkspaceDefaults(workspaceId) { | ||
| return this.fetchJson(`/workspaces/${encodeURIComponent(workspaceId)}/defaults`); | ||
| } | ||
| async updateWorkspaceDefaults(workspaceId, update) { | ||
| return this.putJson(`/workspaces/${encodeURIComponent(workspaceId)}/defaults`, update); | ||
| } | ||
| async preview(request) { | ||
| return this.postJson("/routing/preview", { | ||
| workspaceId: request.workspaceId, | ||
| commandName: request.commandName, | ||
| agentOverride: request.agentOverride, | ||
| taskType: request.taskType, | ||
| projectKey: request.projectKey, | ||
| requiredCapabilities: request.requiredCapabilities, | ||
| }); | ||
| } | ||
| async listAgents() { | ||
| return this.fetchJson("/agents"); | ||
| } | ||
| async getAgent(idOrSlug) { | ||
| return this.fetchJson(`/agents/${encodeURIComponent(idOrSlug)}`); | ||
| } | ||
| } |
+6
-6
| { | ||
| "name": "@mcoda/core", | ||
| "version": "0.1.127", | ||
| "version": "0.1.128", | ||
| "description": "Core services and APIs for the mcoda CLI.", | ||
@@ -35,7 +35,7 @@ "type": "module", | ||
| "yaml": "^2.4.2", | ||
| "@mcoda/agents": "0.1.127", | ||
| "@mcoda/db": "0.1.127", | ||
| "@mcoda/integrations": "0.1.127", | ||
| "@mcoda/generators": "0.1.127", | ||
| "@mcoda/shared": "0.1.127" | ||
| "@mcoda/agents": "0.1.128", | ||
| "@mcoda/db": "0.1.128", | ||
| "@mcoda/integrations": "0.1.128", | ||
| "@mcoda/generators": "0.1.128", | ||
| "@mcoda/shared": "0.1.128" | ||
| }, | ||
@@ -42,0 +42,0 @@ "scripts": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
3064136
0.13%317
0.96%63299
0.13%233
0.87%20
17.65%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated