@hexis-ai/engram-sdk 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/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ScoredSession, SearchOptions, Session, SessionStep } from "@hexis-ai/engram-core";
2
2
  import { type RefCandidate } from "./extract";
3
- import type { EventBatch, PersonCreate, PersonInfo, PersonMap, PersonUpdate, SessionEvent, SessionInit } from "./types";
3
+ import type { AliasInfo, AliasUpsert, EventBatch, IdentityInfo, IdentityUpsert, PersonCreate, PersonInfo, PersonMap, PersonUpdate, SessionEvent, SessionInit } from "./types";
4
4
  /**
5
5
  * Envelope returned by session endpoints. The persons map is deduped
6
6
  * across whatever sessions the response carries so display info isn't
@@ -142,6 +142,29 @@ export declare class Engram {
142
142
  channel?: string;
143
143
  scope?: "participant" | "viewable";
144
144
  }) => Promise<SessionListEnvelope>;
145
+ /**
146
+ * Upsert an alias for this person. Name comparisons are
147
+ * case-insensitive — writing `Yuuri` and `YUURI` hits the same row.
148
+ */
149
+ upsertAlias: (id: string, name: string, input: AliasUpsert) => Promise<AliasInfo>;
150
+ /** This person's aliases, newest-used-first. */
151
+ aliases: (id: string) => Promise<{
152
+ aliases: AliasInfo[];
153
+ }>;
154
+ /** This person's identities, newest-linked-first. */
155
+ identities: (id: string) => Promise<{
156
+ identities: IdentityInfo[];
157
+ }>;
158
+ };
159
+ /** Identity operations — resolve a global ref (`slack:U…`, `email:…`)
160
+ * to its identity record + person id. */
161
+ readonly identities: {
162
+ /** Upsert by ref. Refs are reassignable — writing with a new
163
+ * `person_id` reroutes the ref. Returns 404 if `person_id` is
164
+ * unknown. */
165
+ upsert: (ref: string, input: IdentityUpsert) => Promise<IdentityInfo>;
166
+ /** Look up by ref. Returns 404 if the ref is unknown. */
167
+ get: (ref: string) => Promise<IdentityInfo>;
145
168
  };
146
169
  /** Internal: ship an event batch to the server. */
147
170
  sendBatch(sessionId: string, batch: EventBatch): Promise<void>;
package/dist/client.js CHANGED
@@ -97,6 +97,25 @@ export class Engram {
97
97
  const tail = qs.toString();
98
98
  return this.request("GET", `/v1/persons/${encodeURIComponent(id)}/sessions${tail ? `?${tail}` : ""}`);
99
99
  },
100
+ /**
101
+ * Upsert an alias for this person. Name comparisons are
102
+ * case-insensitive — writing `Yuuri` and `YUURI` hits the same row.
103
+ */
104
+ upsertAlias: (id, name, input) => this.request("PUT", `/v1/persons/${encodeURIComponent(id)}/aliases/${encodeURIComponent(name)}`, input),
105
+ /** This person's aliases, newest-used-first. */
106
+ aliases: (id) => this.request("GET", `/v1/persons/${encodeURIComponent(id)}/aliases`),
107
+ /** This person's identities, newest-linked-first. */
108
+ identities: (id) => this.request("GET", `/v1/persons/${encodeURIComponent(id)}/identities`),
109
+ };
110
+ /** Identity operations — resolve a global ref (`slack:U…`, `email:…`)
111
+ * to its identity record + person id. */
112
+ identities = {
113
+ /** Upsert by ref. Refs are reassignable — writing with a new
114
+ * `person_id` reroutes the ref. Returns 404 if `person_id` is
115
+ * unknown. */
116
+ upsert: (ref, input) => this.request("PUT", `/v1/identities/${encodeURIComponent(ref)}`, input),
117
+ /** Look up by ref. Returns 404 if the ref is unknown. */
118
+ get: (ref) => this.request("GET", `/v1/identities/${encodeURIComponent(ref)}`),
100
119
  };
101
120
  /** Internal: ship an event batch to the server. */
102
121
  async sendBatch(sessionId, batch) {
package/dist/index.d.ts CHANGED
@@ -3,4 +3,4 @@ export { extractReferences, encodeResourceId, type RefCandidate, type ReferenceS
3
3
  export { parseToolName, type ParsedToolName } from "./tool-name";
4
4
  export { fetchIdToken, cloudRunIdTokenAuth } from "./id-token";
5
5
  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 type { SessionInit, SessionAck, SessionEvent, StepEvent, ParticipantEvent, TitleEvent, EndEvent, EventBatch, PersonInfo, PersonCreate, PersonUpdate, PersonMap, } from "./types";
6
+ export type { SessionInit, SessionAck, SessionEvent, StepEvent, ParticipantEvent, TitleEvent, EndEvent, EventBatch, PersonInfo, PersonCreate, PersonUpdate, PersonMap, AliasInfo, AliasUpsert, IdentityInfo, IdentityUpsert, } from "./types";
package/dist/types.d.ts CHANGED
@@ -76,6 +76,67 @@ export interface PersonCreate {
76
76
  export interface PersonUpdate {
77
77
  display_name?: string | null;
78
78
  }
79
+ /**
80
+ * One alias (alternate name) for a person, mirrored from monet's
81
+ * identity-resolution layer. Names are stored case-sensitively for
82
+ * display but compared lowercase, so writing "Yuuri" and "YUURI" hits
83
+ * the same row.
84
+ */
85
+ export interface AliasInfo {
86
+ person_id: string;
87
+ name: string;
88
+ /** Provenance tag — e.g. `slack-resolver`, `manual`, `gcal-attendee`. */
89
+ caller: string;
90
+ usage_count: number;
91
+ /** Calendar date (`YYYY-MM-DD`) of the most recent use. */
92
+ last_used: string;
93
+ created_at: string;
94
+ updated_at: string;
95
+ }
96
+ export interface AliasUpsert {
97
+ caller: string;
98
+ /** `YYYY-MM-DD`. */
99
+ last_used: string;
100
+ /**
101
+ * When the alias already exists, bump `usage_count` by 1 and replace
102
+ * `caller` / `last_used` with the new values. Default true. Pass
103
+ * `false` for idempotent backfills where you want the existing row
104
+ * untouched if it already exists.
105
+ */
106
+ increment?: boolean;
107
+ }
108
+ /**
109
+ * One external identity mapped to an engram person. Hosts (monet) use
110
+ * the same ref convention they always have — `slack:U12345`,
111
+ * `email:foo@bar.com`, `google:1234567890` — so engram can serve as
112
+ * the resolver for any system that already speaks that vocabulary.
113
+ */
114
+ export interface IdentityInfo {
115
+ /** Stable global handle, e.g. `slack:U12345`. */
116
+ ref: string;
117
+ person_id: string;
118
+ service: string;
119
+ external_id: string;
120
+ display_name: string | null;
121
+ source: string | null;
122
+ is_primary: boolean | null;
123
+ picture: string | null;
124
+ /** `YYYY-MM-DD`. */
125
+ linked_at: string;
126
+ created_at: string;
127
+ updated_at: string;
128
+ }
129
+ export interface IdentityUpsert {
130
+ person_id: string;
131
+ service: string;
132
+ external_id: string;
133
+ display_name?: string | null;
134
+ source?: string | null;
135
+ is_primary?: boolean | null;
136
+ picture?: string | null;
137
+ /** `YYYY-MM-DD`. */
138
+ linked_at: string;
139
+ }
79
140
  /**
80
141
  * Map of person_id → PersonInfo, deduped across whatever `Session`s the
81
142
  * response contains. Returned at the envelope level so list responses
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hexis-ai/engram-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Host SDK for engram. Records agent session steps and ships them to an engram server.",
5
5
  "keywords": [
6
6
  "engram",