cognia-sdk 0.1.5 → 0.1.6

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.
@@ -120,8 +120,9 @@ class Cognia {
120
120
  token = await (timeoutMs ? Promise.race([provider, deadline]) : provider);
121
121
  }
122
122
  catch (e) {
123
+ // never the provider's own object or message (it may carry the bearer): a fresh error either way
123
124
  if (e?.name === "AbortError")
124
- throw e;
125
+ throw Object.assign(new Error("tokenProvider timed out"), { name: "AbortError" });
125
126
  throw new CogniaError(`Cognia ${method} ${path} → token provider failed`, 0, null);
126
127
  }
127
128
  finally {
@@ -133,7 +134,7 @@ class Cognia {
133
134
  token = this.key;
134
135
  if (!token)
135
136
  throw new CogniaError(`Cognia ${method} ${path} → no credential`, 0, null);
136
- const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk/0.1.5" }, body: body === undefined ? undefined : JSON.stringify(body), signal: ac.signal });
137
+ const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk/0.1.6" }, body: body === undefined ? undefined : JSON.stringify(body), signal: ac.signal });
137
138
  let j = null;
138
139
  try {
139
140
  j = await r.json();
@@ -115,8 +115,9 @@ export class Cognia {
115
115
  token = await (timeoutMs ? Promise.race([provider, deadline]) : provider);
116
116
  }
117
117
  catch (e) {
118
+ // never the provider's own object or message (it may carry the bearer): a fresh error either way
118
119
  if (e?.name === "AbortError")
119
- throw e;
120
+ throw Object.assign(new Error("tokenProvider timed out"), { name: "AbortError" });
120
121
  throw new CogniaError(`Cognia ${method} ${path} → token provider failed`, 0, null);
121
122
  }
122
123
  finally {
@@ -128,7 +129,7 @@ export class Cognia {
128
129
  token = this.key;
129
130
  if (!token)
130
131
  throw new CogniaError(`Cognia ${method} ${path} → no credential`, 0, null);
131
- const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk/0.1.5" }, body: body === undefined ? undefined : JSON.stringify(body), signal: ac.signal });
132
+ const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk/0.1.6" }, body: body === undefined ? undefined : JSON.stringify(body), signal: ac.signal });
132
133
  let j = null;
133
134
  try {
134
135
  j = await r.json();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cognia-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Cognia for your model calls: one line gives any agent the Memories and Skills it may use, with provenance and honest receipts. Fails open.",
5
5
  "license": "MIT",
6
6
  "author": "Cognia",