@lostcoords/yuke
v0.0.8
Published
TypeScript types and a typed dispatch surface for the yuke wire protocol, generated from schema/wire.json.
Readme
@lostcoords/yuke
TypeScript types and a typed client for the yuke wire protocol, generated from
schema/wire.json (keep in sync with yuke/schema).
How to use
Compiled JS + .d.ts and no runtime dependencies. Uses the runtime's global WebSocket and
fetch (Node 22+, Bun, Deno, browsers).
import { Account, Client, SessionReplica, attach, run, discoverDaemon, connect } from "@lostcoords/yuke";
// A minted yk_sess_ token. Device credentials are refused.
const account = Account.fromSession({ url: "https://platform.yuke.sh", token: process.env.YUKE_TOKEN });
const local = await discoverDaemon({ host: "127.0.0.1", port: 9853 });
const { client } = await connect({
host: "127.0.0.1",
port: 9853,
client: { name: "my-app", version: "1.0.0" },
});
// one shot example: (hangs on a permission prompt unless permission is "yolo"):
const { text, outcome } = await run({
client,
prompt: "summarize src/",
workspace_path: "/work/repo",
permission: "yolo",
});Relay (Path B):
import { Account } from "@lostcoords/yuke";
import { connectAccount, generateStaticSecret } from "@lostcoords/yuke/relay";
const account = Account.fromSession({ url: "https://platform.yuke.sh", token: process.env.YUKE_TOKEN });
const roster = await account.devices();
if (roster.status !== "ok") throw new Error(roster.status);
const { client } = await connectAccount(account, {
device: roster.devices[0],
client: { name: "my-app", version: "1.0.0" },
staticSecret: generateStaticSecret(), // different on every call, persist per app if the daemon pins clients (TODO)
});Teams & daemon sharing:
Account also manages teams and who a daemon is shared with — over the same session token. The
roster distinguishes them: each Device carries access ("owner" vs "shared"), and shared
daemons add shared_via, source_label, and owner. Some features are only under Pro tier.
const account = Account.fromSession({ url: "https://platform.yuke.sh", token: process.env.YUKE_TOKEN });
const teams = await account.teams(); // TeamSummary[]
const team = await account.createTeam({ name: "infra" }); // → { status: "ok", data: Team }
if (team.status === "ok") {
// A verified account is added immediately; anyone else is invited by email.
const outcome = await account.addMember(team.data.id, { email: "[email protected]", role: "admin" });
// outcome.data.status is "granted" | "invited"
}
// Share a daemon with a team or a person; revoke by share id.
await account.shareDevice(deviceId, { teamId: team.data.id }); // or { email: "[email protected]" }
const shares = await account.deviceShares(deviceId); // { shares, invitations }Commands
npm run generate regenerate src/generated from schema/wire.json
npm run build compile src -> dist as .js + .d.ts
npm run typecheck tsc --noEmit
npm test node:test
npm run verify generate, typecheck, test, purity gate, build