cortad 0.1.8 → 0.1.10

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.
@@ -0,0 +1,12 @@
1
+ // Where a provider key is asked for its model listing: the base URL their app is pointed at, when
2
+ // their env sets one beside the key (OPENAI_BASE_URL beside OPENAI_API_KEY), else the provider's own
3
+ // host. A Fireworks key under OPENAI_API_KEY is refused by api.openai.com and works where it is sent.
4
+ export function listingUrl(name, canonical, values) {
5
+ const prefix = name.replace(/_API_KEY$/, "");
6
+ const base = values[`${prefix}_BASE_URL`] || values[`${prefix}_API_BASE`];
7
+ if (!base) return canonical;
8
+ try {
9
+ const u = new URL(base);
10
+ return /^https?:$/.test(u.protocol) ? `${base.replace(/\/+$/, "")}/models` : canonical;
11
+ } catch { return canonical; }
12
+ }
package/local.mjs CHANGED
@@ -719,7 +719,10 @@ if (!files.length) fail("no source files here to read.");
719
719
  // Which project this is, as a hash of where it lives: the same folder coming back resumes the same
720
720
  // connection, and the path itself never leaves this machine.
721
721
  const project = createHash("sha256").update(realpathSync(root)).digest("hex").slice(0, 16);
722
- const attach = await call("POST", "/local/attach", { code, name: basename(root), project });
722
+ // A network that drops while connecting ends here in a sentence, never a stack trace: running the
723
+ // command again starts a clean connection.
724
+ const unreachable = (err) => fail(`could not reach ${origin.host}: ${err?.name === "TimeoutError" ? "it did not answer in time" : "the connection failed"}. Check your connection and run the command again.`);
725
+ const attach = await call("POST", "/local/attach", { code, name: basename(root), project }).catch(unreachable);
723
726
  if (!attach.ok) fail(attach.data?.error ?? `could not sign in (${attach.status})`);
724
727
  box = attach.data.box;
725
728
  key = attach.data.key;
@@ -759,7 +762,7 @@ const parts = Math.max(1, Math.ceil(bytes.length / PART));
759
762
  for (let off = 0; off < bytes.length; off += PART) {
760
763
  const last = off + PART >= bytes.length;
761
764
  step(parts > 1 ? `connecting, ${Math.floor(off / PART) + 1} of ${parts}` : "connecting");
762
- const put = await call("PUT", `/local/${box}/tree?last=${last ? 1 : 0}${last ? `&digest=${treeDigest}${head ? `&head=${head}` : ""}` : ""}`, bytes.subarray(off, off + PART), { raw: true, timeoutMs: 120_000 });
765
+ const put = await call("PUT", `/local/${box}/tree?last=${last ? 1 : 0}${last ? `&digest=${treeDigest}${head ? `&head=${head}` : ""}` : ""}`, bytes.subarray(off, off + PART), { raw: true, timeoutMs: 120_000 }).catch(unreachable);
763
766
  if (!put.ok) fail(put.data?.error ?? `upload failed (${put.status})`);
764
767
  if (last) resumed = put.data?.resumed === true;
765
768
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortad",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Connects the AI app on your machine to Cortad for test conversations. No dependencies.",
5
5
  "bin": {
6
6
  "cortad": "local.mjs"
@@ -10,6 +10,7 @@
10
10
  "README.md",
11
11
  "lib/door.mjs",
12
12
  "lib/identities.mjs",
13
+ "lib/listing.mjs",
13
14
  "lib/lock.mjs",
14
15
  "lib/mint.mjs",
15
16
  "lib/pyhook/sitecustomize.py",