@magpie-community/opencode-opendesign-auth 0.1.6 → 0.1.7

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.
Files changed (2) hide show
  1. package/index.mjs +9 -3
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -121,10 +121,16 @@ async function api(base, path, { key, body, method = "GET", signal } = {}) {
121
121
 
122
122
  // startDevice opens a device authorization: a code, the page that approves
123
123
  // it, and the secret the approval is polled with.
124
- async function startDevice({ signal } = {}) {
124
+ // host is this computer's name, as `vela login` sends it (os.Hostname());
125
+ // when it can't be read the CLI stops with "resolve hostname", and so does
126
+ // this, rather than send a name of its own.
127
+ async function startDevice({ signal, host = hostname } = {}) {
128
+ let name = ""
129
+ try { name = String(host() ?? "").trim() } catch {}
130
+ if (!name) throw new Error("Open Design sign-in: this computer's name couldn't be read, and the sign-in sends it")
125
131
  const r = await api(CONTROL, "/api/v1/cli/device-authorizations", {
126
132
  method: "POST",
127
- body: { cliVersion: CLI_VERSION, host: hostname() || "magpie", profile: "prod" },
133
+ body: { cliVersion: CLI_VERSION, host: name, profile: "prod" },
128
134
  signal,
129
135
  })
130
136
  const d = r.body
@@ -499,4 +505,4 @@ export const OpenDesignAuthPlugin = async () => {
499
505
 
500
506
  // _internal is what the tests read through; magpie calls every exported
501
507
  // function as a plugin, so only the plugin itself is exported bare.
502
- export const _internal = { authOf, allowances, controlKeyOf, credits, modelsOf, money, runtimeKeyOf, said, thePlan, usedPercent, waitForDevice, windowName, when, workspaceOf }
508
+ export const _internal = { authOf, allowances, controlKeyOf, credits, modelsOf, money, runtimeKeyOf, said, startDevice, thePlan, usedPercent, waitForDevice, windowName, when, workspaceOf }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-opendesign-auth",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Open Design Cloud (Design Plan) in OpenCode and magpie: the account's device sign-in, its models, and the plan's 5-hour and 7-day allowance",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",