speculos-toolkit 1.1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speculos-toolkit",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "description": "The Speculos toolkit for coding agents \u2014 deploy any frontend/backend to a live URL and build against your linked data connectors (BigQuery, Postgres, Snowflake, Salesforce, \u2026). Built for Claude Code, Codex, Cursor, and friends.",
5
5
  "bin": {
6
6
  "speculos-toolkit": "bin/speculos-toolkit.js"
package/src/client.js CHANGED
@@ -1,8 +1,10 @@
1
- // HTTP client to the Speculos orchestrator (management API). Holds no platform
2
- // secrets. The orchestrator runs self-hosted behind the Cloudflare forwarding
3
- // deploy-orch-38hd4.speculos.ai; it drives Daytona backends and pushes frontends
4
- // to the EC2 host that serves them at user-deployed.speculos.ai.
5
- const DEFAULT_API = process.env.SPECULOS_API || "https://deploy-orch-38hd4.speculos.ai";
1
+ // HTTP client to the Speculos platform gateway (management API). Holds no
2
+ // platform secrets. The gateway proxies these calls to the deploy orchestrator
3
+ // on the same box and files every deploy in the console's shared history, so a
4
+ // CLI deploy and a console publish sit in one list under one identity. The
5
+ // orchestrator's own hostname (deploy-orch-38hd4.speculos.ai) still answers and
6
+ // can be selected with --api; deployed apps keep calling the broker there.
7
+ const DEFAULT_API = process.env.SPECULOS_API || "https://unified-api.speculos.ai/toolkit";
6
8
 
7
9
  function base(opts) { return (opts.api || DEFAULT_API).replace(/\/$/, ""); }
8
10
 
@@ -14,8 +16,8 @@ async function post(url, body, token) {
14
16
  if (!res.ok) { const e = new Error(data.error || `HTTP ${res.status}`); e.code = data.code; e.status = res.status; throw e; }
15
17
  return data;
16
18
  }
17
- async function get(url, token) {
18
- const headers = {};
19
+ async function get(url, token, extra) {
20
+ const headers = Object.assign({}, extra || {});
19
21
  if (token) headers["Authorization"] = "Bearer " + token;
20
22
  const res = await fetch(url, { headers });
21
23
  const data = await res.json().catch(() => ({}));
@@ -36,14 +38,18 @@ async function whoami(token, opts = {}) { return get(base(opts) + "/api/account/
36
38
  async function linkMachine(token, payload, opts = {}) { return post(base(opts) + "/api/account/link", payload, token); }
37
39
  async function logout(token, opts = {}) { return post(base(opts) + "/api/account/logout", {}, token); }
38
40
  // poll a backend job (owner-authenticated)
41
+ // The machine credentials travel as headers, not a query string: a query
42
+ // string is written to every access log between here and the orchestrator.
39
43
  async function backendStatus(jobId, creds = {}, opts = {}) {
40
- const qs = new URLSearchParams({ userId: creds.userId || "", userKey: creds.userKey || "" });
41
- return get(base(opts) + "/api/backend/" + encodeURIComponent(jobId) + "?" + qs.toString());
44
+ return get(base(opts) + "/api/backend/" + encodeURIComponent(jobId), null,
45
+ { "x-speculos-user-id": creds.userId || "", "x-speculos-user-key": creds.userKey || "" });
42
46
  }
43
- // upload built/static frontend
44
- async function putFrontend(payload, opts = {}) { return post(base(opts) + "/api/frontend", payload); }
47
+ // upload built/static frontend. The account token rides along so the gateway
48
+ // can file the deploy under the person, not the machine; the orchestrator
49
+ // itself authorizes on the machine credentials in the body as before.
50
+ async function putFrontend(payload, opts = {}) { return post(base(opts) + "/api/frontend", payload, opts.token); }
45
51
  // remove a deployment
46
- async function teardown(payload, opts = {}) { return post(base(opts) + "/api/teardown", payload); }
52
+ async function teardown(payload, opts = {}) { return post(base(opts) + "/api/teardown", payload, opts.token); }
47
53
  // ---- connectors (data sources linked in the dashboard) ----
48
54
  async function connectorsList(token, opts = {}) {
49
55
  return get(base(opts) + "/api/connectors" + (opts.noTools ? "?tools=0" : ""), token);
package/src/index.js CHANGED
@@ -129,7 +129,7 @@ OPTIONS
129
129
  --args <json> connectors exec: tool arguments as inline JSON
130
130
  --args-file <f> connectors exec: tool arguments from a JSON file (preferred
131
131
  in agents — inline JSON with $ ( ) etc. may need approval)
132
- --api <url> orchestrator base url (default https://deploy-orch-38hd4.speculos.ai)
132
+ --api <url> platform API base (default https://unified-api.speculos.ai/toolkit)
133
133
  --timeout <sec> max seconds to wait for the backend (default 600)
134
134
  --json machine-readable only (auto-on when non-TTY/CI)
135
135
 
@@ -335,6 +335,7 @@ async function cmdTeardown(root, opts) {
335
335
  if (!slug) { emit({ ok: false, error: "--slug required (or run from the project dir with a .speculos.json)" }); return 2; }
336
336
  if (!identity || !identity.userId) { emit({ ok: false, error: "no identity found (~/.speculos/identity.json) — nothing to tear down from this machine" }); return 1; }
337
337
  try {
338
+ if (identity.accountToken) opts.token = identity.accountToken;
338
339
  const r = await client.teardown({ userId: identity.userId, userKey: identity.userKey, slug }, opts);
339
340
  if (saved && saved.slug === slug) creds.remove(root);
340
341
  emit({ ok: true, ...r });