Sessions
The 12 operations under sessions, as typed calls on the generated REST client.
Sessions
Available from @codespar/sdk 0.12.0; the version on npm is 0.12.0. Every example on this page is compiled against the installed package when these docs build: a call that does not type-check fails the build.
Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.
import { } from "@codespar/sdk";
const = new ({ : .. });GET /v1/sessions
/v1/sessionsList sessions
const = await ..("/v1/sessions");Parameters, body and every documented response: GET /v1/sessions in the HTTP reference.
POST /v1/sessions
/v1/sessionsOpen a session
const = await ..("post", "/v1/sessions", {
: {
: [
"string"
],
: "user_0000000000000000",
: {},
: {}
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (.) {
.(.);
}Parameters, body and every documented response: POST /v1/sessions in the HTTP reference.
GET /v1/sessions/{id}
/v1/sessions/{id}Read one session
const = await ..("/v1/sessions/{id}", {
: {
: "ses_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/sessions/{id} in the HTTP reference.
DELETE /v1/sessions/{id}
/v1/sessions/{id}Close a session
const = await ..("/v1/sessions/{id}", {
: {
: "ses_0000000000000000"
}
});Parameters, body and every documented response: DELETE /v1/sessions/{id} in the HTTP reference.
GET /v1/sessions/{id}/connections
/v1/sessions/{id}/connectionsList a session's servers and the tools it can call
const = await ..("/v1/sessions/{id}/connections", {
: {
: "ses_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/sessions/{id}/connections in the HTTP reference.
POST /v1/sessions/{id}/execute
/v1/sessions/{id}/executeResolves `tool` as a CodeSpar meta-tool first, then as a catalog tool
Run one tool in the session
const = await ..("post", "/v1/sessions/{id}/execute", {
: {
: "ses_0000000000000000"
},
: {
: "string",
: {},
: {},
: 0
}
});
// r.status is one of the documented statuses (200, 403, 422),
// each with its own body shape in r.data; nothing here throws on 403.
if (.) {
.(.);
}Parameters, body and every documented response: POST /v1/sessions/{id}/execute in the HTTP reference.
GET /v1/sessions/{id}/mocks
/v1/sessions/{id}/mocksRead a session's declared mocks and their consume counters
const = await ..("/v1/sessions/{id}/mocks", {
: {
: "ses_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/sessions/{id}/mocks in the HTTP reference.
POST /v1/sessions/{id}/proxy_execute
/v1/sessions/{id}/proxy_execute`method` + `endpoint` are forwarded to the server's upstream with credentials injected server-side
Make one raw HTTP call to a connected server
const = await ..("post", "/v1/sessions/{id}/proxy_execute", {
: {
: "ses_0000000000000000"
},
: {
: "string",
: "https://example.com/hook",
: "GET",
: {},
: {},
: 0
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (.) {
.(.);
}Parameters, body and every documented response: POST /v1/sessions/{id}/proxy_execute in the HTTP reference.
POST /v1/sessions/{id}/send
/v1/sessions/{id}/senda payment that settled on turn one is still visible when turn two died
Drive a model loop that may call tools
const = await ..("post", "/v1/sessions/{id}/send", {
: {
: "ses_0000000000000000"
},
: {
: "string"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (.) {
.(.);
}Parameters, body and every documented response: POST /v1/sessions/{id}/send in the HTTP reference.
GET /v1/sessions/{id}/tool-calls
/v1/sessions/{id}/tool-callsList one session's tool calls
const = await ..("/v1/sessions/{id}/tool-calls", {
: {
: "ses_0000000000000000"
}
});Parameters, body and every documented response: GET /v1/sessions/{id}/tool-calls in the HTTP reference.
POST /v1/sessions/{id}/tool-calls
/v1/sessions/{id}/tool-callsRecord a tool call the client executed
const = await ..("/v1/sessions/{id}/tool-calls", {
: {
: "ses_0000000000000000"
},
: {
: "srv_0000000000000000",
: "Example",
: "running",
: 0,
: "string"
}
});Parameters, body and every documented response: POST /v1/sessions/{id}/tool-calls in the HTTP reference.
PATCH /v1/sessions/{id}/tool-calls/{tc_id}
/v1/sessions/{id}/tool-calls/{tc_id}Finalize a recorded tool call
const = await ..("/v1/sessions/{id}/tool-calls/{tc_id}", {
: {
: "ses_0000000000000000",
: "tc_0000000000000000"
},
: {
: "success",
: 0
}
});Parameters, body and every documented response: PATCH /v1/sessions/{id}/tool-calls/{tc_id} in the HTTP reference.