@hexis-ai/engram-sdk 0.11.1 → 0.13.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/dist/admin.d.ts +38 -0
- package/dist/admin.js +35 -0
- package/dist/buffered.d.ts +52 -0
- package/dist/buffered.js +41 -0
- package/dist/client.d.ts +19 -1
- package/dist/client.js +24 -0
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/admin.d.ts
CHANGED
|
@@ -48,6 +48,34 @@ export interface CreateWorkspaceResult {
|
|
|
48
48
|
/** Present when `issueKey !== false`. */
|
|
49
49
|
key?: IssuedKey;
|
|
50
50
|
}
|
|
51
|
+
export interface Org {
|
|
52
|
+
id: string;
|
|
53
|
+
name?: string | null;
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
createdAt: string;
|
|
56
|
+
}
|
|
57
|
+
export interface OrgMembership {
|
|
58
|
+
orgId: string;
|
|
59
|
+
userId: string;
|
|
60
|
+
role: string;
|
|
61
|
+
joinedAt: string;
|
|
62
|
+
}
|
|
63
|
+
export interface CreateOrgInput {
|
|
64
|
+
id?: string;
|
|
65
|
+
name?: string;
|
|
66
|
+
metadata?: Record<string, unknown>;
|
|
67
|
+
}
|
|
68
|
+
export interface UpsertMemberInput {
|
|
69
|
+
/** Provide one of these — userId wins when both are present. */
|
|
70
|
+
userId?: string;
|
|
71
|
+
email?: string;
|
|
72
|
+
role?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface OrgWorkspace {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string | null;
|
|
77
|
+
orgId: string;
|
|
78
|
+
}
|
|
51
79
|
export declare class EngramAdmin {
|
|
52
80
|
private readonly baseUrl;
|
|
53
81
|
private readonly adminToken;
|
|
@@ -63,6 +91,16 @@ export declare class EngramAdmin {
|
|
|
63
91
|
}): Promise<IssuedKey>;
|
|
64
92
|
listKeys(workspaceId: string): Promise<ApiKey[]>;
|
|
65
93
|
revokeKey(workspaceId: string, keyId: string): Promise<void>;
|
|
94
|
+
createOrg(input?: CreateOrgInput): Promise<Org>;
|
|
95
|
+
listOrgs(): Promise<Org[]>;
|
|
96
|
+
getOrg(id: string): Promise<Org>;
|
|
97
|
+
deleteOrg(id: string): Promise<void>;
|
|
98
|
+
listOrgMembers(orgId: string): Promise<OrgMembership[]>;
|
|
99
|
+
upsertOrgMember(orgId: string, input: UpsertMemberInput): Promise<OrgMembership>;
|
|
100
|
+
removeOrgMember(orgId: string, userId: string): Promise<void>;
|
|
101
|
+
/** Create a workspace under an org and (by default) issue an api key. */
|
|
102
|
+
createWorkspaceUnderOrg(orgId: string, input?: CreateWorkspaceInput): Promise<CreateWorkspaceResult>;
|
|
103
|
+
listOrgWorkspaces(orgId: string): Promise<OrgWorkspace[]>;
|
|
66
104
|
private request;
|
|
67
105
|
}
|
|
68
106
|
export declare function createAdminClient(opts: AdminClientOptions): EngramAdmin;
|
package/dist/admin.js
CHANGED
|
@@ -41,6 +41,41 @@ export class EngramAdmin {
|
|
|
41
41
|
async revokeKey(workspaceId, keyId) {
|
|
42
42
|
await this.request("DELETE", `/admin/v1/workspaces/${encodeURIComponent(workspaceId)}/keys/${encodeURIComponent(keyId)}`);
|
|
43
43
|
}
|
|
44
|
+
// ---------- orgs (Wave G) ---------------------------------
|
|
45
|
+
async createOrg(input = {}) {
|
|
46
|
+
const r = await this.request("POST", "/admin/v1/orgs", input);
|
|
47
|
+
return r.org;
|
|
48
|
+
}
|
|
49
|
+
async listOrgs() {
|
|
50
|
+
const r = await this.request("GET", "/admin/v1/orgs");
|
|
51
|
+
return r.orgs;
|
|
52
|
+
}
|
|
53
|
+
async getOrg(id) {
|
|
54
|
+
const r = await this.request("GET", `/admin/v1/orgs/${encodeURIComponent(id)}`);
|
|
55
|
+
return r.org;
|
|
56
|
+
}
|
|
57
|
+
async deleteOrg(id) {
|
|
58
|
+
await this.request("DELETE", `/admin/v1/orgs/${encodeURIComponent(id)}`);
|
|
59
|
+
}
|
|
60
|
+
async listOrgMembers(orgId) {
|
|
61
|
+
const r = await this.request("GET", `/admin/v1/orgs/${encodeURIComponent(orgId)}/members`);
|
|
62
|
+
return r.members;
|
|
63
|
+
}
|
|
64
|
+
async upsertOrgMember(orgId, input) {
|
|
65
|
+
const r = await this.request("POST", `/admin/v1/orgs/${encodeURIComponent(orgId)}/members`, input);
|
|
66
|
+
return r.member;
|
|
67
|
+
}
|
|
68
|
+
async removeOrgMember(orgId, userId) {
|
|
69
|
+
await this.request("DELETE", `/admin/v1/orgs/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`);
|
|
70
|
+
}
|
|
71
|
+
/** Create a workspace under an org and (by default) issue an api key. */
|
|
72
|
+
async createWorkspaceUnderOrg(orgId, input = {}) {
|
|
73
|
+
return this.request("POST", `/admin/v1/orgs/${encodeURIComponent(orgId)}/workspaces`, input);
|
|
74
|
+
}
|
|
75
|
+
async listOrgWorkspaces(orgId) {
|
|
76
|
+
const r = await this.request("GET", `/admin/v1/orgs/${encodeURIComponent(orgId)}/workspaces`);
|
|
77
|
+
return r.workspaces;
|
|
78
|
+
}
|
|
44
79
|
async request(method, path, body) {
|
|
45
80
|
const headers = {
|
|
46
81
|
"content-type": "application/json",
|
package/dist/buffered.d.ts
CHANGED
|
@@ -70,6 +70,47 @@ export type TelemetryEvent = {
|
|
|
70
70
|
type: "end";
|
|
71
71
|
at?: string;
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Person observation. Same Langfuse-style semantics as session():
|
|
75
|
+
* host-supplied id, idempotent on the engram side (PUT /v1/persons/:id).
|
|
76
|
+
* Subsequent calls with the same id COALESCE — partial-info updates
|
|
77
|
+
* never clobber richer fields set earlier.
|
|
78
|
+
*/
|
|
79
|
+
export interface TelemetryPerson {
|
|
80
|
+
id: string;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
role?: string | null;
|
|
83
|
+
team?: string | null;
|
|
84
|
+
source?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Identity observation — links a global ref like `slack:U12345` or
|
|
88
|
+
* `email:foo@bar.com` to a person id. Idempotent (PUT
|
|
89
|
+
* /v1/identities/:ref); writing a new person_id reroutes the ref.
|
|
90
|
+
*/
|
|
91
|
+
export interface TelemetryIdentity {
|
|
92
|
+
ref: string;
|
|
93
|
+
personId: string;
|
|
94
|
+
service: string;
|
|
95
|
+
externalId: string;
|
|
96
|
+
displayName?: string | null;
|
|
97
|
+
source?: string | null;
|
|
98
|
+
picture?: string | null;
|
|
99
|
+
isPrimary?: boolean | null;
|
|
100
|
+
linkedAt: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Alias observation — a name the person goes by. The engram side
|
|
104
|
+
* key-collapses on (person_id, lower(name)); same name twice with
|
|
105
|
+
* `increment: true` bumps usage_count (default).
|
|
106
|
+
*/
|
|
107
|
+
export interface TelemetryAlias {
|
|
108
|
+
personId: string;
|
|
109
|
+
name: string;
|
|
110
|
+
caller: string;
|
|
111
|
+
lastUsed: string;
|
|
112
|
+
increment?: boolean;
|
|
113
|
+
}
|
|
73
114
|
/**
|
|
74
115
|
* Internal coordinator that owns per-session buffers and gates flushes
|
|
75
116
|
* on session-creation acks. Exposed on the parent Engram via
|
|
@@ -94,6 +135,17 @@ export declare class BufferedTelemetry {
|
|
|
94
135
|
message(input: TelemetryMessage): void;
|
|
95
136
|
/** Observe an arbitrary session event (participant / title / step / end). */
|
|
96
137
|
event(input: TelemetryEvent): void;
|
|
138
|
+
/**
|
|
139
|
+
* Observe a person. Unlike session events these don't fan out to a
|
|
140
|
+
* per-session buffer — each call is an immediate fire-and-forget
|
|
141
|
+
* PUT via the SDK's low-level `persons.upsert`. Transport failures
|
|
142
|
+
* surface via onError and are not retried.
|
|
143
|
+
*/
|
|
144
|
+
person(input: TelemetryPerson): void;
|
|
145
|
+
/** Observe an identity (ref → person_id link). */
|
|
146
|
+
identity(input: TelemetryIdentity): void;
|
|
147
|
+
/** Observe an alias (person nickname). */
|
|
148
|
+
alias(input: TelemetryAlias): void;
|
|
97
149
|
/**
|
|
98
150
|
* Drain every per-session buffer in parallel. Safe to call at any
|
|
99
151
|
* point; failures route to onError, never thrown.
|
package/dist/buffered.js
CHANGED
|
@@ -76,6 +76,47 @@ export class BufferedTelemetry {
|
|
|
76
76
|
}
|
|
77
77
|
handle.event(input);
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Observe a person. Unlike session events these don't fan out to a
|
|
81
|
+
* per-session buffer — each call is an immediate fire-and-forget
|
|
82
|
+
* PUT via the SDK's low-level `persons.upsert`. Transport failures
|
|
83
|
+
* surface via onError and are not retried.
|
|
84
|
+
*/
|
|
85
|
+
person(input) {
|
|
86
|
+
void this.engram.persons
|
|
87
|
+
.upsert(input.id, {
|
|
88
|
+
...(input.displayName !== undefined ? { display_name: input.displayName } : {}),
|
|
89
|
+
...(input.role !== undefined ? { role: input.role } : {}),
|
|
90
|
+
...(input.team !== undefined ? { team: input.team } : {}),
|
|
91
|
+
...(input.source !== undefined ? { source: input.source } : {}),
|
|
92
|
+
})
|
|
93
|
+
.catch((e) => this.engram.config.onError(e));
|
|
94
|
+
}
|
|
95
|
+
/** Observe an identity (ref → person_id link). */
|
|
96
|
+
identity(input) {
|
|
97
|
+
void this.engram.identities
|
|
98
|
+
.upsert(input.ref, {
|
|
99
|
+
person_id: input.personId,
|
|
100
|
+
service: input.service,
|
|
101
|
+
external_id: input.externalId,
|
|
102
|
+
...(input.displayName !== undefined ? { display_name: input.displayName } : {}),
|
|
103
|
+
...(input.source !== undefined ? { source: input.source } : {}),
|
|
104
|
+
...(input.picture !== undefined ? { picture: input.picture } : {}),
|
|
105
|
+
...(input.isPrimary !== undefined ? { is_primary: input.isPrimary } : {}),
|
|
106
|
+
linked_at: input.linkedAt,
|
|
107
|
+
})
|
|
108
|
+
.catch((e) => this.engram.config.onError(e));
|
|
109
|
+
}
|
|
110
|
+
/** Observe an alias (person nickname). */
|
|
111
|
+
alias(input) {
|
|
112
|
+
void this.engram.persons
|
|
113
|
+
.upsertAlias(input.personId, input.name, {
|
|
114
|
+
caller: input.caller,
|
|
115
|
+
last_used: input.lastUsed,
|
|
116
|
+
...(input.increment !== undefined ? { increment: input.increment } : {}),
|
|
117
|
+
})
|
|
118
|
+
.catch((e) => this.engram.config.onError(e));
|
|
119
|
+
}
|
|
79
120
|
/**
|
|
80
121
|
* Drain every per-session buffer in parallel. Safe to call at any
|
|
81
122
|
* point; failures route to onError, never thrown.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ScoredSession, SearchOptions, Session, SessionStep } from "@hexis-ai/engram-core";
|
|
2
2
|
import { type RefCandidate } from "./extract";
|
|
3
3
|
import type { AliasInfo, AliasUpsert, EventBatch, IdentityInfo, IdentityUpsert, MessageContentBlock, PersonCreate, PersonInfo, PersonMap, PersonUpdate, SessionEvent, SessionInit, SessionUpdate } from "./types";
|
|
4
|
-
import { type TelemetryEvent, type TelemetryMessage, type TelemetrySession } from "./buffered";
|
|
4
|
+
import { type TelemetryAlias, type TelemetryEvent, type TelemetryIdentity, type TelemetryMessage, type TelemetryPerson, type TelemetrySession } from "./buffered";
|
|
5
5
|
/**
|
|
6
6
|
* Envelope returned by session endpoints. The persons map is deduped
|
|
7
7
|
* across whatever sessions the response carries so display info isn't
|
|
@@ -117,6 +117,24 @@ export declare class Engram {
|
|
|
117
117
|
* tool step, end). Same fire-and-forget contract.
|
|
118
118
|
*/
|
|
119
119
|
event(input: TelemetryEvent): void;
|
|
120
|
+
/**
|
|
121
|
+
* Observe a person record (display_name / role / team / source).
|
|
122
|
+
* Idempotent on the engram side — partial-info updates COALESCE.
|
|
123
|
+
* Fire-and-forget; transport failures route to `onError`.
|
|
124
|
+
*/
|
|
125
|
+
person(input: TelemetryPerson): void;
|
|
126
|
+
/**
|
|
127
|
+
* Observe an identity (`slack:U1`, `email:foo@bar.com`, …) and link
|
|
128
|
+
* it to a person id. Writing a new person_id to an existing ref
|
|
129
|
+
* reroutes the ref. Fire-and-forget.
|
|
130
|
+
*/
|
|
131
|
+
identity(input: TelemetryIdentity): void;
|
|
132
|
+
/**
|
|
133
|
+
* Observe an alias (a name the person goes by). Engram side
|
|
134
|
+
* collapses on (person_id, lower(name)); same name twice with
|
|
135
|
+
* `increment: true` bumps usage_count. Fire-and-forget.
|
|
136
|
+
*/
|
|
137
|
+
alias(input: TelemetryAlias): void;
|
|
120
138
|
/**
|
|
121
139
|
* Drain every per-session buffer. Call before short-lived processes
|
|
122
140
|
* exit; long-lived servers can rely on auto-flush (flushIntervalMs).
|
package/dist/client.js
CHANGED
|
@@ -60,6 +60,30 @@ export class Engram {
|
|
|
60
60
|
event(input) {
|
|
61
61
|
this.bufferedTelemetry.event(input);
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Observe a person record (display_name / role / team / source).
|
|
65
|
+
* Idempotent on the engram side — partial-info updates COALESCE.
|
|
66
|
+
* Fire-and-forget; transport failures route to `onError`.
|
|
67
|
+
*/
|
|
68
|
+
person(input) {
|
|
69
|
+
this.bufferedTelemetry.person(input);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Observe an identity (`slack:U1`, `email:foo@bar.com`, …) and link
|
|
73
|
+
* it to a person id. Writing a new person_id to an existing ref
|
|
74
|
+
* reroutes the ref. Fire-and-forget.
|
|
75
|
+
*/
|
|
76
|
+
identity(input) {
|
|
77
|
+
this.bufferedTelemetry.identity(input);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Observe an alias (a name the person goes by). Engram side
|
|
81
|
+
* collapses on (person_id, lower(name)); same name twice with
|
|
82
|
+
* `increment: true` bumps usage_count. Fire-and-forget.
|
|
83
|
+
*/
|
|
84
|
+
alias(input) {
|
|
85
|
+
this.bufferedTelemetry.alias(input);
|
|
86
|
+
}
|
|
63
87
|
/**
|
|
64
88
|
* Drain every per-session buffer. Call before short-lived processes
|
|
65
89
|
* exit; long-lived servers can rely on auto-flush (flushIntervalMs).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Engram, EngramSession, type EngramOptions, type RecordStepInput, type SearchRequest, type SearchResponse, type SearchEnvelope, type SessionEnvelope, type SessionListEnvelope, } from "./client";
|
|
2
2
|
export { extractReferences, encodeResourceId, type RefCandidate, type ReferenceService, type ReferenceAction, } from "./extract";
|
|
3
3
|
export { parseToolName, type ParsedToolName } from "./tool-name";
|
|
4
|
-
export { BufferedTelemetry, type TelemetrySession, type TelemetryMessage, type TelemetryEvent, } from "./buffered";
|
|
4
|
+
export { BufferedTelemetry, type TelemetrySession, type TelemetryMessage, type TelemetryEvent, type TelemetryPerson, type TelemetryIdentity, type TelemetryAlias, } from "./buffered";
|
|
5
5
|
export { fetchIdToken, cloudRunIdTokenAuth } from "./id-token";
|
|
6
|
-
export { EngramAdmin, createAdminClient, type AdminClientOptions, type CreateWorkspaceInput, type CreateWorkspaceResult, type Workspace as AdminWorkspace, type ApiKey as AdminApiKey, type IssuedKey as AdminIssuedKey, } from "./admin";
|
|
6
|
+
export { EngramAdmin, createAdminClient, type AdminClientOptions, type CreateWorkspaceInput, type CreateWorkspaceResult, type Workspace as AdminWorkspace, type ApiKey as AdminApiKey, type IssuedKey as AdminIssuedKey, type Org, type OrgMembership, type CreateOrgInput, type UpsertMemberInput, type OrgWorkspace, } from "./admin";
|
|
7
7
|
export type { SessionInit, SessionUpdate, SessionAck, SessionEvent, StepEvent, ParticipantEvent, TitleEvent, EndEvent, MessageContentBlock, MessageEvent, EventBatch, PersonInfo, PersonCreate, PersonUpdate, PersonMap, AliasInfo, AliasUpsert, IdentityInfo, IdentityUpsert, } from "./types";
|