An open-source implementation of an SDK.
Warning
This can still get your account banned. Official communication around this has been unreliable. See this tweet.
import { query } from "the-coding-sdk";
let finalResult = "";
for await (const message of query({
prompt: "Write a concise changelog entry for the current repository.",
cwd: process.cwd(),
})) {
if (message.type === "assistant") {
const content = message.message["content"];
if (typeof content === "string") {
process.stdout.write(content);
}
}
if (message.type === "result") {
finalResult = message.result;
}
}
console.log("\n\nFinal result:", finalResult);Important
While I am relatively confident in the API at this point, there are still runtime behaviors that are not fully validated. Use at your own risk.
This project grew out of a need for an SDK that could be fixed directly, instead of working around issues with brittle hacks.
It was built primarily by referencing the official Python SDK and using types from the TypeScript SDK. Where information was missing in either, behavior was derived through reverse-engineering of the TypeScript SDK.
This project is an unofficial wrapper around the CLI. I have not verified its compliance with the Terms of Service, so assess that risk for yourself.
That said, both the official SDK and this SDK still depend on the closed-source CLI. If the problem lives in the CLI itself, it cannot be fixed here.
This project is licensed under the Apache License, Version 2.0. You are free to use this project as you see fit, so long as you comply with the license's terms.