cognia-sdk 0.2.1 → 0.2.2
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 +4 -0
- package/dist/cjs/client.js +4 -3
- package/dist/esm/client.d.ts +3 -2
- package/dist/esm/client.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,6 +91,10 @@ A verified success needs a signal (a test, a check, a metric) or a human. Inject
|
|
|
91
91
|
counts as success. Your Cognia Cloud Overview shows the loop per week: turns with context → cited → used → verified, with
|
|
92
92
|
unverified reports listed apart.
|
|
93
93
|
|
|
94
|
+
**Router decision values** (`x-cognia-decision`): `INJECT`, `ABSTAIN`, `unavailable:timeout` (the context budget passed),
|
|
95
|
+
`unavailable:<status>` (Cognia answered an error), `unavailable:error`, `no_user_message`. Every `unavailable` means the
|
|
96
|
+
call was forwarded untouched.
|
|
97
|
+
|
|
94
98
|
**Credits.** Reporting on other owners' knowledge earns Cloud credits (verified outcomes most, used receipts a little,
|
|
95
99
|
context calls that injected a little), and your own memories earn when an independent agent's verified success lands on
|
|
96
100
|
them. Credits pay for Workbench messages beyond your plan. They are not money. `GET /v1/cloud/me/credits` lists them.
|
package/dist/cjs/client.js
CHANGED
|
@@ -43,7 +43,7 @@ function shapeContext(r) {
|
|
|
43
43
|
return { contextId: o.contextId, decision, ...(abstain ? { abstain } : {}), scope, items: items, receipts, metrics };
|
|
44
44
|
}
|
|
45
45
|
/** kept in step with package.json by the version test */
|
|
46
|
-
exports.SDK_VERSION = "0.2.
|
|
46
|
+
exports.SDK_VERSION = "0.2.2";
|
|
47
47
|
class CogniaError extends Error {
|
|
48
48
|
status;
|
|
49
49
|
body;
|
|
@@ -140,7 +140,7 @@ class Cognia {
|
|
|
140
140
|
token = this.key;
|
|
141
141
|
if (!token)
|
|
142
142
|
throw new CogniaError(`Cognia ${method} ${path} → no credential`, 0, null);
|
|
143
|
-
const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk
|
|
143
|
+
const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk/" + exports.SDK_VERSION }, body: body === undefined ? undefined : JSON.stringify(body), signal: ac.signal });
|
|
144
144
|
let j = null;
|
|
145
145
|
try {
|
|
146
146
|
j = await r.json();
|
|
@@ -227,7 +227,8 @@ class Cognia {
|
|
|
227
227
|
return null;
|
|
228
228
|
return (await this.receipt("used", contextId, { itemIds }));
|
|
229
229
|
}
|
|
230
|
-
/** Report what happened with one item: used or not, success / failure (/ neutral for a Skill).
|
|
230
|
+
/** Report what happened with one item: used or not, success / failure (/ neutral for a Skill). USED comes from this or from
|
|
231
|
+
* `used()`; success and failure come only from here. */
|
|
231
232
|
outcome(contextId, input) {
|
|
232
233
|
return this.call("POST", `/v1/context/${encodeURIComponent(contextId)}/outcome`, input);
|
|
233
234
|
}
|
package/dist/esm/client.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface CogniaOptions {
|
|
|
28
28
|
/** Accept only what the contract promises; anything else is treated as unavailable so the model call proceeds (fail-open). */
|
|
29
29
|
export declare function shapeContext(r: unknown): ContextResponse | null;
|
|
30
30
|
/** kept in step with package.json by the version test */
|
|
31
|
-
export declare const SDK_VERSION = "0.2.
|
|
31
|
+
export declare const SDK_VERSION = "0.2.2";
|
|
32
32
|
export declare class CogniaError extends Error {
|
|
33
33
|
readonly status: number;
|
|
34
34
|
readonly body: unknown;
|
|
@@ -67,7 +67,8 @@ export declare class Cognia {
|
|
|
67
67
|
cited(contextId: string, itemIds: string[]): Promise<void>;
|
|
68
68
|
/** USED: your agent actually used these items, whether or not you know yet how it turned out. The cheapest honest signal. */
|
|
69
69
|
used(contextId: string, itemIds: string[]): Promise<ReceiptResponse | null>;
|
|
70
|
-
/** Report what happened with one item: used or not, success / failure (/ neutral for a Skill).
|
|
70
|
+
/** Report what happened with one item: used or not, success / failure (/ neutral for a Skill). USED comes from this or from
|
|
71
|
+
* `used()`; success and failure come only from here. */
|
|
71
72
|
outcome(contextId: string, input: OutcomeInput): Promise<OutcomeResponse>;
|
|
72
73
|
/** One-liners for the two outcomes. Pass `verification` when a signal (a test, a check, a metric) or a human confirmed it;
|
|
73
74
|
* without it the report is recorded as agent-reported, which counts as used but never as verified success. */
|
package/dist/esm/client.js
CHANGED
|
@@ -39,7 +39,7 @@ export function shapeContext(r) {
|
|
|
39
39
|
return { contextId: o.contextId, decision, ...(abstain ? { abstain } : {}), scope, items: items, receipts, metrics };
|
|
40
40
|
}
|
|
41
41
|
/** kept in step with package.json by the version test */
|
|
42
|
-
export const SDK_VERSION = "0.2.
|
|
42
|
+
export const SDK_VERSION = "0.2.2";
|
|
43
43
|
export class CogniaError extends Error {
|
|
44
44
|
status;
|
|
45
45
|
body;
|
|
@@ -135,7 +135,7 @@ export class Cognia {
|
|
|
135
135
|
token = this.key;
|
|
136
136
|
if (!token)
|
|
137
137
|
throw new CogniaError(`Cognia ${method} ${path} → no credential`, 0, null);
|
|
138
|
-
const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk
|
|
138
|
+
const r = await this.f(this.baseUrl + path, { method, headers: { authorization: `Bearer ${token}`, "content-type": "application/json", "user-agent": "cognia-sdk/" + SDK_VERSION }, body: body === undefined ? undefined : JSON.stringify(body), signal: ac.signal });
|
|
139
139
|
let j = null;
|
|
140
140
|
try {
|
|
141
141
|
j = await r.json();
|
|
@@ -222,7 +222,8 @@ export class Cognia {
|
|
|
222
222
|
return null;
|
|
223
223
|
return (await this.receipt("used", contextId, { itemIds }));
|
|
224
224
|
}
|
|
225
|
-
/** Report what happened with one item: used or not, success / failure (/ neutral for a Skill).
|
|
225
|
+
/** Report what happened with one item: used or not, success / failure (/ neutral for a Skill). USED comes from this or from
|
|
226
|
+
* `used()`; success and failure come only from here. */
|
|
226
227
|
outcome(contextId, input) {
|
|
227
228
|
return this.call("POST", `/v1/context/${encodeURIComponent(contextId)}/outcome`, input);
|
|
228
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cognia-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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",
|