Skip to main content
REST client

Sessions

The 12 operations under sessions, as typed calls on the generated REST client.

2 min read
View MarkdownEdit on GitHub

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

GET/v1/sessions

List sessions

const  = await ..("/v1/sessions");

Parameters, body and every documented response: GET /v1/sessions in the HTTP reference.

POST /v1/sessions

POST/v1/sessions

Open 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}

GET/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}

DELETE/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

GET/v1/sessions/{id}/connections

List 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

POST/v1/sessions/{id}/execute
Can move money

Resolves `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

GET/v1/sessions/{id}/mocks

Read 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

POST/v1/sessions/{id}/proxy_execute
Can move money

`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

POST/v1/sessions/{id}/send
Can move money

a 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

GET/v1/sessions/{id}/tool-calls

List 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

POST/v1/sessions/{id}/tool-calls

Record 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}

PATCH/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.

Sessions | CodeSpar