@canarycoders/ai 0.3.0 → 0.5.0

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/README.md CHANGED
@@ -16,9 +16,9 @@ bun add @canarycoders/ai
16
16
  ## Quick start
17
17
 
18
18
  ```ts
19
- import CanaryLLM from "@canarycoders/ai";
19
+ import CanaryCodersAI from "@canarycoders/ai";
20
20
 
21
- const client = new CanaryLLM({ apiKey: process.env.CANARY_AI_API_KEY });
21
+ const client = new CanaryCodersAI({ apiKey: process.env.CANARY_AI_API_KEY });
22
22
 
23
23
  const res = await client.chat.complete({
24
24
  provider: "openai",
@@ -29,7 +29,7 @@ const res = await client.chat.complete({
29
29
  console.log(res.content, res.usage.totalTokens);
30
30
  ```
31
31
 
32
- `apiKey` defaults to `CANARY_AI_API_KEY` (legacy `CANARYLLM_API_KEY` still works) and `baseURL` to the hosted gateway, so `new CanaryLLM()` with the env var set is enough.
32
+ `apiKey` defaults to `CANARY_AI_API_KEY` (legacy `CANARYLLM_API_KEY` still works) and `baseURL` to the hosted gateway, so `new CanaryCodersAI()` with the env var set is enough.
33
33
 
34
34
  ## How the queue works
35
35
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compat.ts"],"names":[],"mappings":";;;AAgBA,SAAS,GAAG,OAAA,EAAyB;AACnC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAC,CAAA,GAAA,CAAA;AACvC;AAEO,SAAS,YAAA,CAAa,SAAiB,MAAA,EAA8B;AAC1E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC;AAEO,SAAS,eAAA,CAAgB,SAAiB,MAAA,EAA8B;AAC7E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC","file":"compat.cjs","sourcesContent":["/**\n * Helpers to point the official OpenAI / Anthropic SDKs at CanaryLLM's\n * drop-in compatible endpoints. Use the `provider/modelId` model-string format\n * (e.g. `\"openai/gpt-4o-mini\"`, `\"anthropic/claude-sonnet-4-5\"`).\n *\n * @example\n * import OpenAI from \"openai\";\n * import { openaiTarget } from \"@canarycoders/ai/compat\";\n * const oa = new OpenAI(openaiTarget(baseURL, apiKey));\n */\nexport interface CompatTarget {\n baseURL: string;\n apiKey: string;\n defaultHeaders?: Record<string, string>;\n}\n\nfunction v1(baseURL: string): string {\n return `${baseURL.replace(/\\/+$/, \"\")}/v1`;\n}\n\nexport function openaiTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n\nexport function anthropicTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n"]}
1
+ {"version":3,"sources":["../src/compat.ts"],"names":[],"mappings":";;;AAgBA,SAAS,GAAG,OAAA,EAAyB;AACnC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAC,CAAA,GAAA,CAAA;AACvC;AAEO,SAAS,YAAA,CAAa,SAAiB,MAAA,EAA8B;AAC1E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC;AAEO,SAAS,eAAA,CAAgB,SAAiB,MAAA,EAA8B;AAC7E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC","file":"compat.cjs","sourcesContent":["/**\n * Helpers to point the official OpenAI / Anthropic SDKs at CanaryCoders AI's\n * drop-in compatible endpoints. Use the `provider/modelId` model-string format\n * (e.g. `\"openai/gpt-4o-mini\"`, `\"anthropic/claude-sonnet-4-5\"`).\n *\n * @example\n * import OpenAI from \"openai\";\n * import { openaiTarget } from \"@canarycoders/ai/compat\";\n * const oa = new OpenAI(openaiTarget(baseURL, apiKey));\n */\nexport interface CompatTarget {\n baseURL: string;\n apiKey: string;\n defaultHeaders?: Record<string, string>;\n}\n\nfunction v1(baseURL: string): string {\n return `${baseURL.replace(/\\/+$/, \"\")}/v1`;\n}\n\nexport function openaiTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n\nexport function anthropicTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n"]}
package/dist/compat.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Helpers to point the official OpenAI / Anthropic SDKs at CanaryLLM's
2
+ * Helpers to point the official OpenAI / Anthropic SDKs at CanaryCoders AI's
3
3
  * drop-in compatible endpoints. Use the `provider/modelId` model-string format
4
4
  * (e.g. `"openai/gpt-4o-mini"`, `"anthropic/claude-sonnet-4-5"`).
5
5
  *
package/dist/compat.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Helpers to point the official OpenAI / Anthropic SDKs at CanaryLLM's
2
+ * Helpers to point the official OpenAI / Anthropic SDKs at CanaryCoders AI's
3
3
  * drop-in compatible endpoints. Use the `provider/modelId` model-string format
4
4
  * (e.g. `"openai/gpt-4o-mini"`, `"anthropic/claude-sonnet-4-5"`).
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/compat.ts"],"names":[],"mappings":";AAgBA,SAAS,GAAG,OAAA,EAAyB;AACnC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAC,CAAA,GAAA,CAAA;AACvC;AAEO,SAAS,YAAA,CAAa,SAAiB,MAAA,EAA8B;AAC1E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC;AAEO,SAAS,eAAA,CAAgB,SAAiB,MAAA,EAA8B;AAC7E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC","file":"compat.js","sourcesContent":["/**\n * Helpers to point the official OpenAI / Anthropic SDKs at CanaryLLM's\n * drop-in compatible endpoints. Use the `provider/modelId` model-string format\n * (e.g. `\"openai/gpt-4o-mini\"`, `\"anthropic/claude-sonnet-4-5\"`).\n *\n * @example\n * import OpenAI from \"openai\";\n * import { openaiTarget } from \"@canarycoders/ai/compat\";\n * const oa = new OpenAI(openaiTarget(baseURL, apiKey));\n */\nexport interface CompatTarget {\n baseURL: string;\n apiKey: string;\n defaultHeaders?: Record<string, string>;\n}\n\nfunction v1(baseURL: string): string {\n return `${baseURL.replace(/\\/+$/, \"\")}/v1`;\n}\n\nexport function openaiTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n\nexport function anthropicTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n"]}
1
+ {"version":3,"sources":["../src/compat.ts"],"names":[],"mappings":";AAgBA,SAAS,GAAG,OAAA,EAAyB;AACnC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAC,CAAA,GAAA,CAAA;AACvC;AAEO,SAAS,YAAA,CAAa,SAAiB,MAAA,EAA8B;AAC1E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC;AAEO,SAAS,eAAA,CAAgB,SAAiB,MAAA,EAA8B;AAC7E,EAAA,OAAO,EAAE,OAAA,EAAS,EAAA,CAAG,OAAO,GAAG,MAAA,EAAO;AACxC","file":"compat.js","sourcesContent":["/**\n * Helpers to point the official OpenAI / Anthropic SDKs at CanaryCoders AI's\n * drop-in compatible endpoints. Use the `provider/modelId` model-string format\n * (e.g. `\"openai/gpt-4o-mini\"`, `\"anthropic/claude-sonnet-4-5\"`).\n *\n * @example\n * import OpenAI from \"openai\";\n * import { openaiTarget } from \"@canarycoders/ai/compat\";\n * const oa = new OpenAI(openaiTarget(baseURL, apiKey));\n */\nexport interface CompatTarget {\n baseURL: string;\n apiKey: string;\n defaultHeaders?: Record<string, string>;\n}\n\nfunction v1(baseURL: string): string {\n return `${baseURL.replace(/\\/+$/, \"\")}/v1`;\n}\n\nexport function openaiTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n\nexport function anthropicTarget(baseURL: string, apiKey: string): CompatTarget {\n return { baseURL: v1(baseURL), apiKey };\n}\n"]}
package/dist/index.cjs CHANGED
@@ -321,6 +321,12 @@ var Transport = class {
321
321
  if (!res.ok) throw await toAPIError(res);
322
322
  return res.text();
323
323
  }
324
+ /** Perform the request and return the raw binary body (audio, …). */
325
+ async bytes(method, path, opts = {}) {
326
+ const res = await this.send(method, path, opts);
327
+ if (!res.ok) throw await toAPIError(res);
328
+ return res.arrayBuffer();
329
+ }
324
330
  /** Open a streaming response. Throws if the initial response is an error. */
325
331
  async stream(method, path, opts = {}) {
326
332
  const res = await this.send(method, path, {
@@ -1197,6 +1203,18 @@ var SessionsAPI = class extends BaseResource {
1197
1203
  const data = await this.transport.json("GET", `/api/convagents/sessions/${id}`, { signal });
1198
1204
  return data.session;
1199
1205
  }
1206
+ /**
1207
+ * Fetch the session recording as raw audio bytes. Single use: the recording
1208
+ * is deleted from ElevenLabs on retrieval, so a second call rejects with 404.
1209
+ * Unfetched recordings are purged after 30 days.
1210
+ */
1211
+ getAudio(id, signal) {
1212
+ return this.transport.bytes(
1213
+ "GET",
1214
+ `/api/convagents/sessions/${id}/audio`,
1215
+ { signal }
1216
+ );
1217
+ }
1200
1218
  };
1201
1219
  var ConversationsResource = class extends BaseResource {
1202
1220
  templates = new TemplatesAPI(this.transport, this.defaultPoll);
@@ -1576,7 +1594,7 @@ function readEnv(key) {
1576
1594
  if (typeof process !== "undefined" && process.env) return process.env[key];
1577
1595
  return void 0;
1578
1596
  }
1579
- var CanaryLLM = class {
1597
+ var CanaryCodersAI = class {
1580
1598
  chat;
1581
1599
  queue;
1582
1600
  images;
@@ -1635,14 +1653,15 @@ var CanaryLLM = class {
1635
1653
  };
1636
1654
 
1637
1655
  // src/index.ts
1638
- var src_default = CanaryLLM;
1656
+ var src_default = CanaryCodersAI;
1639
1657
 
1640
1658
  exports.APIConnectionError = APIConnectionError;
1641
1659
  exports.APIConnectionTimeoutError = APIConnectionTimeoutError;
1642
1660
  exports.APIError = APIError;
1643
1661
  exports.AuthenticationError = AuthenticationError;
1644
1662
  exports.BadRequestError = BadRequestError;
1645
- exports.CanaryLLM = CanaryLLM;
1663
+ exports.CanaryCodersAI = CanaryCodersAI;
1664
+ exports.CanaryLLM = CanaryCodersAI;
1646
1665
  exports.ConflictError = ConflictError;
1647
1666
  exports.InternalServerError = InternalServerError;
1648
1667
  exports.Job = Job;