@hexis-ai/engram-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.
- package/dist/admin.d.ts +8 -0
- package/dist/admin.js +9 -4
- package/package.json +9 -2
package/dist/admin.d.ts
CHANGED
|
@@ -7,6 +7,13 @@ export interface AdminClientOptions {
|
|
|
7
7
|
baseUrl: string;
|
|
8
8
|
adminToken: string;
|
|
9
9
|
fetch?: typeof fetch;
|
|
10
|
+
/**
|
|
11
|
+
* Async hook resolved per-request that returns additional headers.
|
|
12
|
+
* Use for short-lived credentials like Cloud Run ID tokens — the platform
|
|
13
|
+
* admin token already travels in `X-Admin-Token`, so the host can put a
|
|
14
|
+
* Google ID token in `Authorization` here without colliding.
|
|
15
|
+
*/
|
|
16
|
+
authHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
10
17
|
}
|
|
11
18
|
export interface Workspace {
|
|
12
19
|
id: string;
|
|
@@ -45,6 +52,7 @@ export declare class EngramAdmin {
|
|
|
45
52
|
private readonly baseUrl;
|
|
46
53
|
private readonly adminToken;
|
|
47
54
|
private readonly fetchImpl;
|
|
55
|
+
private readonly authHeaders?;
|
|
48
56
|
constructor(opts: AdminClientOptions);
|
|
49
57
|
createWorkspace(input?: CreateWorkspaceInput): Promise<CreateWorkspaceResult>;
|
|
50
58
|
listWorkspaces(): Promise<Workspace[]>;
|
package/dist/admin.js
CHANGED
|
@@ -7,6 +7,7 @@ export class EngramAdmin {
|
|
|
7
7
|
baseUrl;
|
|
8
8
|
adminToken;
|
|
9
9
|
fetchImpl;
|
|
10
|
+
authHeaders;
|
|
10
11
|
constructor(opts) {
|
|
11
12
|
if (!opts.baseUrl)
|
|
12
13
|
throw new Error("EngramAdmin: baseUrl is required");
|
|
@@ -15,6 +16,7 @@ export class EngramAdmin {
|
|
|
15
16
|
this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
|
|
16
17
|
this.adminToken = opts.adminToken;
|
|
17
18
|
this.fetchImpl = opts.fetch ?? globalThis.fetch.bind(globalThis);
|
|
19
|
+
this.authHeaders = opts.authHeaders;
|
|
18
20
|
}
|
|
19
21
|
async createWorkspace(input = {}) {
|
|
20
22
|
return this.request("POST", "/admin/v1/workspaces", input);
|
|
@@ -40,12 +42,15 @@ export class EngramAdmin {
|
|
|
40
42
|
await this.request("DELETE", `/admin/v1/workspaces/${encodeURIComponent(workspaceId)}/keys/${encodeURIComponent(keyId)}`);
|
|
41
43
|
}
|
|
42
44
|
async request(method, path, body) {
|
|
45
|
+
const headers = {
|
|
46
|
+
"content-type": "application/json",
|
|
47
|
+
"x-admin-token": this.adminToken,
|
|
48
|
+
};
|
|
49
|
+
if (this.authHeaders)
|
|
50
|
+
Object.assign(headers, await this.authHeaders());
|
|
43
51
|
const res = await this.fetchImpl(`${this.baseUrl}${path}`, {
|
|
44
52
|
method,
|
|
45
|
-
headers
|
|
46
|
-
"content-type": "application/json",
|
|
47
|
-
authorization: `Bearer ${this.adminToken}`,
|
|
48
|
-
},
|
|
53
|
+
headers,
|
|
49
54
|
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
50
55
|
});
|
|
51
56
|
if (!res.ok) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexis-ai/engram-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Host SDK for engram. Records agent session steps and ships them to an engram server.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"engram",
|
|
7
|
+
"agents",
|
|
8
|
+
"claude",
|
|
9
|
+
"anthropic",
|
|
10
|
+
"sdk",
|
|
11
|
+
"observability"
|
|
12
|
+
],
|
|
6
13
|
"homepage": "https://github.com/hexis-ltd/engram#readme",
|
|
7
14
|
"repository": {
|
|
8
15
|
"type": "git",
|