@withgateway/sdk 0.1.3 → 0.1.5

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.
Files changed (49) hide show
  1. package/dist/context/index.mjs +3 -0
  2. package/dist/context/index.mjs.map +1 -1
  3. package/dist/experiments/index.mjs +2 -0
  4. package/dist/experiments/index.mjs.map +1 -1
  5. package/dist/index-DnowA8MG.d.mts +447 -0
  6. package/dist/index-DnowA8MG.d.ts +447 -0
  7. package/dist/index.d.mts +6 -1
  8. package/dist/index.d.ts +6 -1
  9. package/dist/index.js +1715 -20
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +1686 -19
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/memory/index.mjs +3 -0
  14. package/dist/memory/index.mjs.map +1 -1
  15. package/dist/personas/index.d.mts +102 -0
  16. package/dist/personas/index.d.ts +102 -0
  17. package/dist/personas/index.js +205 -0
  18. package/dist/personas/index.js.map +1 -0
  19. package/dist/personas/index.mjs +180 -0
  20. package/dist/personas/index.mjs.map +1 -0
  21. package/dist/replay/index.d.mts +351 -0
  22. package/dist/replay/index.d.ts +351 -0
  23. package/dist/replay/index.js +1094 -0
  24. package/dist/replay/index.js.map +1 -0
  25. package/dist/replay/index.mjs +1057 -0
  26. package/dist/replay/index.mjs.map +1 -0
  27. package/dist/security/index.mjs +2 -0
  28. package/dist/security/index.mjs.map +1 -1
  29. package/dist/sessions/index.d.mts +143 -0
  30. package/dist/sessions/index.d.ts +143 -0
  31. package/dist/sessions/index.js +320 -0
  32. package/dist/sessions/index.js.map +1 -0
  33. package/dist/sessions/index.mjs +288 -0
  34. package/dist/sessions/index.mjs.map +1 -0
  35. package/dist/tracing/index.d.mts +3 -1
  36. package/dist/tracing/index.d.ts +3 -1
  37. package/dist/tracing/index.js +435 -8
  38. package/dist/tracing/index.js.map +1 -1
  39. package/dist/tracing/index.mjs +431 -8
  40. package/dist/tracing/index.mjs.map +1 -1
  41. package/dist/users/index.d.mts +81 -0
  42. package/dist/users/index.d.ts +81 -0
  43. package/dist/users/index.js +168 -0
  44. package/dist/users/index.js.map +1 -0
  45. package/dist/users/index.mjs +144 -0
  46. package/dist/users/index.mjs.map +1 -0
  47. package/package.json +25 -1
  48. package/dist/index-Caw3XVub.d.mts +0 -193
  49. package/dist/index-Caw3XVub.d.ts +0 -193
@@ -1,3 +1,6 @@
1
+ import { createRequire as __gatewayCreateRequire } from "module";
2
+ const require = __gatewayCreateRequire(import.meta.url);
3
+
1
4
  // src/memory/index.ts
2
5
  var GatewayMemoryError = class extends Error {
3
6
  constructor(message, options) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/memory/index.ts"],"sourcesContent":["type MemoryWritePolicy = \"read_only\" | \"propose\" | \"commit\";\n\ntype MemoryFileEntry =\n | {\n type: \"file\";\n content: string;\n mimeType: string;\n mime_type: string;\n }\n | {\n type: \"agent\" | \"skill\";\n repoHandle: string;\n repo_handle: string;\n commitId?: string | null;\n commit_id?: string | null;\n };\n\ntype MemoryRepo = {\n id: string;\n repoHandle: string;\n repo_handle: string;\n ownerHandle: string;\n owner_handle: string;\n kind: \"memory\";\n description: string;\n readme: string;\n tags: string[];\n writePolicy: MemoryWritePolicy;\n write_policy: MemoryWritePolicy;\n isPublic: boolean;\n is_public: boolean;\n isArchived: boolean;\n is_archived: boolean;\n url?: string;\n createdAt: string;\n created_at: string;\n updatedAt: string;\n updated_at: string;\n};\n\ntype MemoryCommit = {\n id: string;\n commitHash: string;\n commit_hash: string;\n parentCommitHash: string | null;\n parent_commit_hash: string | null;\n createdAt: string;\n created_at: string;\n};\n\ntype MemorySnapshot = {\n repo: MemoryRepo;\n commit: MemoryCommit;\n files: Record<string, MemoryFileEntry>;\n};\n\ntype MemoryPushResponse = {\n url: string;\n status: \"committed\" | \"proposed\";\n repoId: string;\n repo_id: string;\n commitId: string | null;\n commit_id: string | null;\n commitHash: string | null;\n commit_hash: string | null;\n proposalId?: string | null;\n proposal_id?: string | null;\n};\n\ntype MemoryRuntimeContext = {\n source?: \"sdk\" | \"agent\" | \"dream\" | \"api\" | \"platform\";\n actorType?: \"api_key\" | \"agent\" | \"process\" | \"user\";\n proposedBy?: string;\n agentId?: string;\n agentStableId?: string;\n processId?: string;\n traceId?: string;\n spanId?: string;\n sessionId?: string;\n userId?: string;\n teamId?: string;\n metadata?: Record<string, unknown>;\n};\n\ntype MemoryPullOptions = {\n version?: string;\n};\n\ntype MemoryWriteOptions = MemoryRuntimeContext & {\n parentCommit?: string;\n message?: string;\n mimeType?: string;\n};\n\ntype MemoryDeleteOptions = MemoryRuntimeContext & {\n parentCommit?: string;\n message?: string;\n};\n\ntype GatewayMemoryConfig = {\n host: string;\n publicKey: string;\n secretKey: string;\n debug?: boolean;\n};\n\ntype GatewayMemoryFromEnvConfig = Partial<GatewayMemoryConfig>;\n\nexport class GatewayMemoryError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message);\n this.name = \"GatewayMemoryError\";\n this.cause = options?.cause;\n }\n}\n\nexport class GatewayMemoryConflictError extends GatewayMemoryError {\n readonly latestCommit: unknown;\n\n constructor(message: string, latestCommit: unknown) {\n super(message);\n this.name = \"GatewayMemoryConflictError\";\n this.latestCommit = latestCommit;\n }\n}\n\nexport class GatewayMemory {\n private readonly host: string;\n private readonly publicKey: string;\n private readonly secretKey: string;\n private readonly debug: boolean;\n\n constructor(config: GatewayMemoryConfig) {\n this.host = config.host.replace(/\\/$/, \"\");\n this.publicKey = config.publicKey;\n this.secretKey = config.secretKey;\n this.debug = config.debug ?? false;\n }\n\n static fromEnv(config: GatewayMemoryFromEnvConfig = {}) {\n const host = config.host ?? process.env.GATEWAY_HOST;\n const publicKey = config.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;\n const secretKey = config.secretKey ?? process.env.GATEWAY_SECRET_KEY;\n\n const missing = [\n [\"host\", host],\n [\"publicKey\", publicKey],\n [\"secretKey\", secretKey],\n ]\n .filter(([, value]) => !value)\n .map(([name]) => name);\n\n if (missing.length > 0) {\n throw new GatewayMemoryError(\n `Missing Gateway memory configuration: ${missing.join(\", \")}`,\n );\n }\n\n return new GatewayMemory({\n ...config,\n host: host!,\n publicKey: publicKey!,\n secretKey: secretKey!,\n });\n }\n\n async pull(\n identifier: string,\n options: MemoryPullOptions = {},\n ): Promise<MemorySnapshot> {\n const query = new URLSearchParams();\n if (options.version) query.set(\"version\", options.version);\n const suffix = query.toString() ? `?${query.toString()}` : \"\";\n return this.requestJson<MemorySnapshot>(\n \"GET\",\n `/api/public/context/memory/${encodeIdentifier(identifier)}${suffix}`,\n );\n }\n\n async read(\n target: string | MemorySnapshot,\n path: string,\n options: MemoryPullOptions = {},\n ): Promise<string | null> {\n const snapshot =\n typeof target === \"string\" ? await this.pull(target, options) : target;\n const file = snapshot.files[path];\n return file?.type === \"file\" ? file.content : null;\n }\n\n async write(\n target: string | MemorySnapshot,\n path: string,\n content: string,\n options: MemoryWriteOptions = {},\n ) {\n const snapshot =\n typeof target === \"string\" ? await this.pull(target) : target;\n return this.push(snapshot.repo.repoHandle, {\n files: {\n [path]: {\n content,\n ...(options.mimeType ? { mimeType: options.mimeType } : {}),\n },\n },\n parentCommit: options.parentCommit ?? snapshot.commit.commitHash,\n message: options.message,\n ...runtimeContextPayload(options),\n });\n }\n\n async delete(\n target: string | MemorySnapshot,\n path: string,\n options: MemoryDeleteOptions = {},\n ) {\n const snapshot =\n typeof target === \"string\" ? await this.pull(target) : target;\n return this.push(snapshot.repo.repoHandle, {\n files: { [path]: null },\n parentCommit: options.parentCommit ?? snapshot.commit.commitHash,\n message: options.message,\n ...runtimeContextPayload(options),\n });\n }\n\n private async push(\n identifier: string,\n payload: Record<string, unknown>,\n ): Promise<MemoryPushResponse> {\n return this.requestJson<MemoryPushResponse>(\n \"POST\",\n `/api/public/context/memory/${encodeIdentifier(identifier)}`,\n payload,\n );\n }\n\n private async requestJson<TResponse>(\n method: \"GET\" | \"POST\",\n path: string,\n payload?: Record<string, unknown>,\n ): Promise<TResponse> {\n const response = await fetch(`${this.host}${path}`, {\n method,\n headers: {\n Authorization: this.authHeader(),\n ...(payload ? { \"Content-Type\": \"application/json\" } : {}),\n },\n ...(payload ? { body: JSON.stringify(payload) } : {}),\n });\n\n const text = await response.text();\n const body = text ? safeJson(text) : {};\n if (!response.ok) {\n const message =\n typeof body.message === \"string\"\n ? body.message\n : `Gateway API ${response.status} on ${path}`;\n if (response.status === 409) {\n throw new GatewayMemoryConflictError(\n message,\n body.latestCommit ?? null,\n );\n }\n throw new GatewayMemoryError(message);\n }\n\n this.log(\"%s %s -> %s\", method, path, response.status);\n return body as TResponse;\n }\n\n private authHeader() {\n return `Basic ${Buffer.from(`${this.publicKey}:${this.secretKey}`).toString(\n \"base64\",\n )}`;\n }\n\n private log(message: string, ...args: unknown[]) {\n if (this.debug) {\n console.log(`[gateway.memory] ${message}`, ...args);\n }\n }\n}\n\nfunction runtimeContextPayload(options: MemoryRuntimeContext) {\n return {\n ...(options.source ? { source: options.source } : {}),\n ...(options.actorType ? { actorType: options.actorType } : {}),\n ...(options.proposedBy ? { proposedBy: options.proposedBy } : {}),\n ...(options.agentId ? { agentId: options.agentId } : {}),\n ...(options.agentStableId ? { agentStableId: options.agentStableId } : {}),\n ...(options.processId ? { processId: options.processId } : {}),\n ...(options.traceId ? { traceId: options.traceId } : {}),\n ...(options.spanId ? { spanId: options.spanId } : {}),\n ...(options.sessionId ? { sessionId: options.sessionId } : {}),\n ...(options.userId ? { userId: options.userId } : {}),\n ...(options.teamId ? { teamId: options.teamId } : {}),\n ...(options.metadata ? { metadata: options.metadata } : {}),\n };\n}\n\nfunction encodeIdentifier(identifier: string) {\n return identifier\n .split(\"/\")\n .filter(Boolean)\n .map((part) => encodeURIComponent(part))\n .join(\"/\");\n}\n\nfunction safeJson(value: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(value);\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n}\n\nexport const memory = {\n fromEnv: GatewayMemory.fromEnv,\n};\n\nexport type {\n GatewayMemoryConfig,\n MemoryCommit as GatewayMemoryCommit,\n MemoryDeleteOptions as GatewayMemoryDeleteOptions,\n MemoryFileEntry as GatewayMemoryFileEntry,\n MemoryPullOptions as GatewayMemoryPullOptions,\n MemoryPushResponse as GatewayMemoryPushResponse,\n MemoryRepo as GatewayMemoryRepo,\n MemoryRuntimeContext as GatewayMemoryRuntimeContext,\n MemorySnapshot as GatewayMemorySnapshot,\n MemoryWriteOptions as GatewayMemoryWriteOptions,\n MemoryWritePolicy as GatewayMemoryWritePolicy,\n};\n"],"mappings":";AA4GO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,YAAY,SAAiB,SAA+B;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ,SAAS;AAAA,EACxB;AACF;AAEO,IAAM,6BAAN,cAAyC,mBAAmB;AAAA,EACxD;AAAA,EAET,YAAY,SAAiB,cAAuB;AAClD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe;AAAA,EACtB;AACF;AAEO,IAAM,gBAAN,MAAM,eAAc;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,QAA6B;AACvC,SAAK,OAAO,OAAO,KAAK,QAAQ,OAAO,EAAE;AACzC,SAAK,YAAY,OAAO;AACxB,SAAK,YAAY,OAAO;AACxB,SAAK,QAAQ,OAAO,SAAS;AAAA,EAC/B;AAAA,EAEA,OAAO,QAAQ,SAAqC,CAAC,GAAG;AACtD,UAAM,OAAO,OAAO,QAAQ,QAAQ,IAAI;AACxC,UAAM,YAAY,OAAO,aAAa,QAAQ,IAAI;AAClD,UAAM,YAAY,OAAO,aAAa,QAAQ,IAAI;AAElD,UAAM,UAAU;AAAA,MACd,CAAC,QAAQ,IAAI;AAAA,MACb,CAAC,aAAa,SAAS;AAAA,MACvB,CAAC,aAAa,SAAS;AAAA,IACzB,EACG,OA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B,YAAoB;AAC5C,SAAO,WACJ,MAAM,GAAG,EACT,OAAO,OAAO,EACd,IAAI,CAAC,SAAS,mBAAmB,IAAI,CAAC,EACtC,KAAK,GAAG;AACb;AAEA,SAAS,SAAS,OAAwC;AACxD,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,KAAK;AAC/B,WAAO,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,IAC/D,SACD,CAAC;AAAA,EACP,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEO,IAAM,SAAS;AAAA,EACpB,SAAS,cAAc;AACzB;","names":[]}
1
+ {"version":3,"sources":["../../src/memory/index.ts"],"sourcesContent":["type MemoryWritePolicy = \"read_only\" | \"propose\" | \"commit\";\n\ntype MemoryFileEntry =\n | {\n type: \"file\";\n content: string;\n mimeType: string;\n mime_type: string;\n }\n | {\n type: \"agent\" | \"skill\";\n repoHandle: string;\n repo_handle: string;\n commitId?: string | null;\n commit_id?: string | null;\n };\n\ntype MemoryRepo = {\n id: string;\n repoHandle: string;\n repo_handle: string;\n ownerHandle: string;\n owner_handle: string;\n kind: \"memory\";\n description: string;\n readme: string;\n tags: string[];\n writePolicy: MemoryWritePolicy;\n write_policy: MemoryWritePolicy;\n isPublic: boolean;\n is_public: boolean;\n isArchived: boolean;\n is_archived: boolean;\n url?: string;\n createdAt: string;\n created_at: string;\n updatedAt: string;\n updated_at: string;\n};\n\ntype MemoryCommit = {\n id: string;\n commitHash: string;\n commit_hash: string;\n parentCommitHash: string | null;\n parent_commit_hash: string | null;\n createdAt: string;\n created_at: string;\n};\n\ntype MemorySnapshot = {\n repo: MemoryRepo;\n commit: MemoryCommit;\n files: Record<string, MemoryFileEntry>;\n};\n\ntype MemoryPushResponse = {\n url: string;\n status: \"committed\" | \"proposed\";\n repoId: string;\n repo_id: string;\n commitId: string | null;\n commit_id: string | null;\n commitHash: string | null;\n commit_hash: string | null;\n proposalId?: string | null;\n proposal_id?: string | null;\n};\n\ntype MemoryRuntimeContext = {\n source?: \"sdk\" | \"agent\" | \"dream\" | \"api\" | \"platform\";\n actorType?: \"api_key\" | \"agent\" | \"process\" | \"user\";\n proposedBy?: string;\n agentId?: string;\n agentStableId?: string;\n processId?: string;\n traceId?: string;\n spanId?: string;\n sessionId?: string;\n userId?: string;\n teamId?: string;\n metadata?: Record<string, unknown>;\n};\n\ntype MemoryPullOptions = {\n version?: string;\n};\n\ntype MemoryWriteOptions = MemoryRuntimeContext & {\n parentCommit?: string;\n message?: string;\n mimeType?: string;\n};\n\ntype MemoryDeleteOptions = MemoryRuntimeContext & {\n parentCommit?: string;\n message?: string;\n};\n\ntype GatewayMemoryConfig = {\n host: string;\n publicKey: string;\n secretKey: string;\n debug?: boolean;\n};\n\ntype GatewayMemoryFromEnvConfig = Partial<GatewayMemoryConfig>;\n\nexport class GatewayMemoryError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message);\n this.name = \"GatewayMemoryError\";\n this.cause = options?.cause;\n }\n}\n\nexport class GatewayMemoryConflictError extends GatewayMemoryError {\n readonly latestCommit: unknown;\n\n constructor(message: string, latestCommit: unknown) {\n super(message);\n this.name = \"GatewayMemoryConflictError\";\n this.latestCommit = latestCommit;\n }\n}\n\nexport class GatewayMemory {\n private readonly host: string;\n private readonly publicKey: string;\n private readonly secretKey: string;\n private readonly debug: boolean;\n\n constructor(config: GatewayMemoryConfig) {\n this.host = config.host.replace(/\\/$/, \"\");\n this.publicKey = config.publicKey;\n this.secretKey = config.secretKey;\n this.debug = config.debug ?? false;\n }\n\n static fromEnv(config: GatewayMemoryFromEnvConfig = {}) {\n const host = config.host ?? process.env.GATEWAY_HOST;\n const publicKey = config.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;\n const secretKey = config.secretKey ?? process.env.GATEWAY_SECRET_KEY;\n\n const missing = [\n [\"host\", host],\n [\"publicKey\", publicKey],\n [\"secretKey\", secretKey],\n ]\n .filter(([, value]) => !value)\n .map(([name]) => name);\n\n if (missing.length > 0) {\n throw new GatewayMemoryError(\n `Missing Gateway memory configuration: ${missing.join(\", \")}`,\n );\n }\n\n return new GatewayMemory({\n ...config,\n host: host!,\n publicKey: publicKey!,\n secretKey: secretKey!,\n });\n }\n\n async pull(\n identifier: string,\n options: MemoryPullOptions = {},\n ): Promise<MemorySnapshot> {\n const query = new URLSearchParams();\n if (options.version) query.set(\"version\", options.version);\n const suffix = query.toString() ? `?${query.toString()}` : \"\";\n return this.requestJson<MemorySnapshot>(\n \"GET\",\n `/api/public/context/memory/${encodeIdentifier(identifier)}${suffix}`,\n );\n }\n\n async read(\n target: string | MemorySnapshot,\n path: string,\n options: MemoryPullOptions = {},\n ): Promise<string | null> {\n const snapshot =\n typeof target === \"string\" ? await this.pull(target, options) : target;\n const file = snapshot.files[path];\n return file?.type === \"file\" ? file.content : null;\n }\n\n async write(\n target: string | MemorySnapshot,\n path: string,\n content: string,\n options: MemoryWriteOptions = {},\n ) {\n const snapshot =\n typeof target === \"string\" ? await this.pull(target) : target;\n return this.push(snapshot.repo.repoHandle, {\n files: {\n [path]: {\n content,\n ...(options.mimeType ? { mimeType: options.mimeType } : {}),\n },\n },\n parentCommit: options.parentCommit ?? snapshot.commit.commitHash,\n message: options.message,\n ...runtimeContextPayload(options),\n });\n }\n\n async delete(\n target: string | MemorySnapshot,\n path: string,\n options: MemoryDeleteOptions = {},\n ) {\n const snapshot =\n typeof target === \"string\" ? await this.pull(target) : target;\n return this.push(snapshot.repo.repoHandle, {\n files: { [path]: null },\n parentCommit: options.parentCommit ?? snapshot.commit.commitHash,\n message: options.message,\n ...runtimeContextPayload(options),\n });\n }\n\n private async push(\n identifier: string,\n payload: Record<string, unknown>,\n ): Promise<MemoryPushResponse> {\n return this.requestJson<MemoryPushResponse>(\n \"POST\",\n `/api/public/context/memory/${encodeIdentifier(identifier)}`,\n payload,\n );\n }\n\n private async requestJson<TResponse>(\n method: \"GET\" | \"POST\",\n path: string,\n payload?: Record<string, unknown>,\n ): Promise<TResponse> {\n const response = await fetch(`${this.host}${path}`, {\n method,\n headers: {\n Authorization: this.authHeader(),\n ...(payload ? { \"Content-Type\": \"application/json\" } : {}),\n },\n ...(payload ? { body: JSON.stringify(payload) } : {}),\n });\n\n const text = await response.text();\n const body = text ? safeJson(text) : {};\n if (!response.ok) {\n const message =\n typeof body.message === \"string\"\n ? body.message\n : `Gateway API ${response.status} on ${path}`;\n if (response.status === 409) {\n throw new GatewayMemoryConflictError(\n message,\n body.latestCommit ?? null,\n );\n }\n throw new GatewayMemoryError(message);\n }\n\n this.log(\"%s %s -> %s\", method, path, response.status);\n return body as TResponse;\n }\n\n private authHeader() {\n return `Basic ${Buffer.from(`${this.publicKey}:${this.secretKey}`).toString(\n \"base64\",\n )}`;\n }\n\n private log(message: string, ...args: unknown[]) {\n if (this.debug) {\n console.log(`[gateway.memory] ${message}`, ...args);\n }\n }\n}\n\nfunction runtimeContextPayload(options: MemoryRuntimeContext) {\n return {\n ...(options.source ? { source: options.source } : {}),\n ...(options.actorType ? { actorType: options.actorType } : {}),\n ...(options.proposedBy ? { proposedBy: options.proposedBy } : {}),\n ...(options.agentId ? { agentId: options.agentId } : {}),\n ...(options.agentStableId ? { agentStableId: options.agentStableId } : {}),\n ...(options.processId ? { processId: options.processId } : {}),\n ...(options.traceId ? { traceId: options.traceId } : {}),\n ...(options.spanId ? { spanId: options.spanId } : {}),\n ...(options.sessionId ? { sessionId: options.sessionId } : {}),\n ...(options.userId ? { userId: options.userId } : {}),\n ...(options.teamId ? { teamId: options.teamId } : {}),\n ...(options.metadata ? { metadata: options.metadata } : {}),\n };\n}\n\nfunction encodeIdentifier(identifier: string) {\n return identifier\n .split(\"/\")\n .filter(Boolean)\n .map((part) => encodeURIComponent(part))\n .join(\"/\");\n}\n\nfunction safeJson(value: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(value);\n return parsed && typeof parsed === \"object\" && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n}\n\nexport const memory = {\n fromEnv: GatewayMemory.fromEnv,\n};\n\nexport type {\n GatewayMemoryConfig,\n MemoryCommit as GatewayMemoryCommit,\n MemoryDeleteOptions as GatewayMemoryDeleteOptions,\n MemoryFileEntry as GatewayMemoryFileEntry,\n MemoryPullOptions as GatewayMemoryPullOptions,\n MemoryPushResponse as GatewayMemoryPushResponse,\n MemoryRepo as GatewayMemoryRepo,\n MemoryRuntimeContext as GatewayMemoryRuntimeContext,\n MemorySnapshot as GatewayMemorySnapshot,\n MemoryWriteOptions as GatewayMemoryWriteOptions,\n MemoryWritePolicy as GatewayMemoryWritePolicy,\n};\n"],"mappings":";;;;AA4GO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,YAAY,SAAiB,SAA+B;AAC1D,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,QAAQ,SAAS;AAAA,EACxB;AACF;AAEO,IAAM,6BAAN,cAAyC,mBAAmB;AAAA,EACxD;AAAA,EAET,YAAY,SAAiB,cAAuB;AAClD,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,eAAe;AAAA,EACtB;AACF;AAEO,IAAM,gBAAN,MAAM,eAAc;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,QAA6B;AACvC,SAAK,OAAO,OAAO,KAAK,QAAQ,OAAO,EAAE;AACzC,SAAK,YAAY,OAAO;AACxB,SAAK,YAAY,OAAO;AACxB,SAAK,QAAQ,OAAO,SAAS;AAAA,EAC/B;AAAA,EAEA,OAAO,QAAQ,SAAqC,CAAC,GAAG;AACtD,UAAM,OAAO,OAAO,QAAQ,QAAQ,IAAI;AACxC,UAAM,YAAY,OAAO,aAAa,QAAQ,IAAI;AAClD,UAAM,YAAY,OAAO,aAAa,QAAQ,IAAI;AAElD,UAAM,UAAU;AAAA,MACd,CAAC,QAAQ,IAAI;AAAA,MACb,CAAC,aAAa,SAAS;AAAA,MACvB,CAAC,aAAa,SAAS;AAAA,IACzB,EACG,OAAO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YAAoB;AAC5C,SAAO,WACJ,MAAM,GAAG,EACT,OAAO,OAAO,EACd,IAAI,CAAC,SAAS,mBAAmB,IAAI,CAAC,EACtC,KAAK,GAAG;AACb;AAEA,SAAS,SAAS,OAAwC;AACxD,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,KAAK;AAC/B,WAAO,UAAU,OAAO,WAAW,YAAY,CAAC,MAAM,QAAQ,MAAM,IAC/D,SACD,CAAC;AAAA,EACP,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEO,IAAM,SAAS;AAAA,EACpB,SAAS,cAAc;AACzB;","names":[]}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Personas — simulated users served by the Gateway platform.
3
+ *
4
+ * A persona is a crafted user profile (usually derived from real sessions on
5
+ * the platform) that Gateway serves as an endpoint. Use it to drive your agent
6
+ * in tests: the persona plays the user, your agent plays itself.
7
+ *
8
+ * Example:
9
+ * ```ts
10
+ * import { PersonasClient } from "@withgateway/sdk/personas";
11
+ *
12
+ * const personas = PersonasClient.fromEnv();
13
+ * const persona = await personas.get("persona_id");
14
+ *
15
+ * const messages: PersonaMessage[] = [];
16
+ * let reply = await persona.respond(messages); // persona opens the conversation
17
+ * while (!reply.done) {
18
+ * messages.push({ role: "user", content: reply.content });
19
+ * const agentAnswer = await myAgent(messages); // your agent under test
20
+ * messages.push({ role: "assistant", content: agentAnswer });
21
+ * reply = await persona.respond(messages);
22
+ * }
23
+ * ```
24
+ *
25
+ * Message roles are from YOUR agent's perspective: `user` = the simulated
26
+ * user's turns, `assistant` = your agent's turns.
27
+ */
28
+ type PersonaMessage = {
29
+ role: "user" | "assistant";
30
+ content: string;
31
+ };
32
+ /** One simulated-user turn. */
33
+ type PersonaReply = {
34
+ content: string;
35
+ done: boolean;
36
+ };
37
+ type PersonasClientConfig = {
38
+ host: string;
39
+ publicKey: string;
40
+ secretKey: string;
41
+ timeoutSeconds?: number;
42
+ debug?: boolean;
43
+ };
44
+ type PersonasClientFromEnvConfig = Partial<PersonasClientConfig>;
45
+ /** Raised when the Gateway personas API cannot complete a request. */
46
+ declare class PersonaError extends Error {
47
+ constructor(message: string, options?: {
48
+ cause?: unknown;
49
+ });
50
+ }
51
+ /** A persona definition plus a bound `respond` helper. */
52
+ declare class Persona {
53
+ readonly id: string;
54
+ readonly name: string;
55
+ readonly description: string | null;
56
+ readonly version: number;
57
+ readonly instructions: string;
58
+ readonly examples: string[];
59
+ private readonly client;
60
+ constructor(fields: {
61
+ id: string;
62
+ name: string;
63
+ description: string | null;
64
+ version: number;
65
+ instructions: string;
66
+ examples?: string[];
67
+ client?: PersonasClient | null;
68
+ });
69
+ /**
70
+ * Get the persona's next user message for a conversation.
71
+ *
72
+ * `messages` use your agent's perspective: role `user` for the simulated
73
+ * user's prior turns, `assistant` for your agent's turns.
74
+ * `done` is true when the persona considers its goal met.
75
+ */
76
+ respond(messages: PersonaMessage[]): Promise<PersonaReply>;
77
+ }
78
+ /** Client for Gateway's persona endpoints (HTTP Basic project keys). */
79
+ declare class PersonasClient {
80
+ private readonly host;
81
+ private readonly publicKey;
82
+ private readonly secretKey;
83
+ private readonly timeoutSeconds;
84
+ private readonly debug;
85
+ constructor(config: PersonasClientConfig);
86
+ /** Create a client from GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY. */
87
+ static fromEnv(config?: PersonasClientFromEnvConfig): PersonasClient;
88
+ /** List the project's personas (without full instructions). */
89
+ list(): Promise<Persona[]>;
90
+ /** Fetch a persona (full definition) bound to this client. */
91
+ get(personaId: string): Promise<Persona>;
92
+ /** Play one persona turn. See {@link Persona.respond}. */
93
+ chat(personaId: string, messages: PersonaMessage[]): Promise<PersonaReply>;
94
+ private requestJson;
95
+ private authHeader;
96
+ private log;
97
+ }
98
+ declare const personas: {
99
+ fromEnv: typeof PersonasClient.fromEnv;
100
+ };
101
+
102
+ export { Persona, PersonaError, type PersonaMessage, type PersonaReply, PersonasClient, type PersonasClientConfig, type PersonasClientFromEnvConfig, personas };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Personas — simulated users served by the Gateway platform.
3
+ *
4
+ * A persona is a crafted user profile (usually derived from real sessions on
5
+ * the platform) that Gateway serves as an endpoint. Use it to drive your agent
6
+ * in tests: the persona plays the user, your agent plays itself.
7
+ *
8
+ * Example:
9
+ * ```ts
10
+ * import { PersonasClient } from "@withgateway/sdk/personas";
11
+ *
12
+ * const personas = PersonasClient.fromEnv();
13
+ * const persona = await personas.get("persona_id");
14
+ *
15
+ * const messages: PersonaMessage[] = [];
16
+ * let reply = await persona.respond(messages); // persona opens the conversation
17
+ * while (!reply.done) {
18
+ * messages.push({ role: "user", content: reply.content });
19
+ * const agentAnswer = await myAgent(messages); // your agent under test
20
+ * messages.push({ role: "assistant", content: agentAnswer });
21
+ * reply = await persona.respond(messages);
22
+ * }
23
+ * ```
24
+ *
25
+ * Message roles are from YOUR agent's perspective: `user` = the simulated
26
+ * user's turns, `assistant` = your agent's turns.
27
+ */
28
+ type PersonaMessage = {
29
+ role: "user" | "assistant";
30
+ content: string;
31
+ };
32
+ /** One simulated-user turn. */
33
+ type PersonaReply = {
34
+ content: string;
35
+ done: boolean;
36
+ };
37
+ type PersonasClientConfig = {
38
+ host: string;
39
+ publicKey: string;
40
+ secretKey: string;
41
+ timeoutSeconds?: number;
42
+ debug?: boolean;
43
+ };
44
+ type PersonasClientFromEnvConfig = Partial<PersonasClientConfig>;
45
+ /** Raised when the Gateway personas API cannot complete a request. */
46
+ declare class PersonaError extends Error {
47
+ constructor(message: string, options?: {
48
+ cause?: unknown;
49
+ });
50
+ }
51
+ /** A persona definition plus a bound `respond` helper. */
52
+ declare class Persona {
53
+ readonly id: string;
54
+ readonly name: string;
55
+ readonly description: string | null;
56
+ readonly version: number;
57
+ readonly instructions: string;
58
+ readonly examples: string[];
59
+ private readonly client;
60
+ constructor(fields: {
61
+ id: string;
62
+ name: string;
63
+ description: string | null;
64
+ version: number;
65
+ instructions: string;
66
+ examples?: string[];
67
+ client?: PersonasClient | null;
68
+ });
69
+ /**
70
+ * Get the persona's next user message for a conversation.
71
+ *
72
+ * `messages` use your agent's perspective: role `user` for the simulated
73
+ * user's prior turns, `assistant` for your agent's turns.
74
+ * `done` is true when the persona considers its goal met.
75
+ */
76
+ respond(messages: PersonaMessage[]): Promise<PersonaReply>;
77
+ }
78
+ /** Client for Gateway's persona endpoints (HTTP Basic project keys). */
79
+ declare class PersonasClient {
80
+ private readonly host;
81
+ private readonly publicKey;
82
+ private readonly secretKey;
83
+ private readonly timeoutSeconds;
84
+ private readonly debug;
85
+ constructor(config: PersonasClientConfig);
86
+ /** Create a client from GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY. */
87
+ static fromEnv(config?: PersonasClientFromEnvConfig): PersonasClient;
88
+ /** List the project's personas (without full instructions). */
89
+ list(): Promise<Persona[]>;
90
+ /** Fetch a persona (full definition) bound to this client. */
91
+ get(personaId: string): Promise<Persona>;
92
+ /** Play one persona turn. See {@link Persona.respond}. */
93
+ chat(personaId: string, messages: PersonaMessage[]): Promise<PersonaReply>;
94
+ private requestJson;
95
+ private authHeader;
96
+ private log;
97
+ }
98
+ declare const personas: {
99
+ fromEnv: typeof PersonasClient.fromEnv;
100
+ };
101
+
102
+ export { Persona, PersonaError, type PersonaMessage, type PersonaReply, PersonasClient, type PersonasClientConfig, type PersonasClientFromEnvConfig, personas };
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/personas/index.ts
21
+ var personas_exports = {};
22
+ __export(personas_exports, {
23
+ Persona: () => Persona,
24
+ PersonaError: () => PersonaError,
25
+ PersonasClient: () => PersonasClient,
26
+ personas: () => personas
27
+ });
28
+ module.exports = __toCommonJS(personas_exports);
29
+ var PersonaError = class extends Error {
30
+ constructor(message, options) {
31
+ super(message);
32
+ this.name = "PersonaError";
33
+ this.cause = options?.cause;
34
+ }
35
+ };
36
+ var Persona = class {
37
+ id;
38
+ name;
39
+ description;
40
+ version;
41
+ instructions;
42
+ examples;
43
+ client;
44
+ constructor(fields) {
45
+ this.id = fields.id;
46
+ this.name = fields.name;
47
+ this.description = fields.description;
48
+ this.version = fields.version;
49
+ this.instructions = fields.instructions;
50
+ this.examples = fields.examples ?? [];
51
+ this.client = fields.client ?? null;
52
+ }
53
+ /**
54
+ * Get the persona's next user message for a conversation.
55
+ *
56
+ * `messages` use your agent's perspective: role `user` for the simulated
57
+ * user's prior turns, `assistant` for your agent's turns.
58
+ * `done` is true when the persona considers its goal met.
59
+ */
60
+ respond(messages) {
61
+ if (this.client === null) {
62
+ throw new PersonaError("Persona is not bound to a client.");
63
+ }
64
+ return this.client.chat(this.id, messages);
65
+ }
66
+ };
67
+ var PersonasClient = class _PersonasClient {
68
+ host;
69
+ publicKey;
70
+ secretKey;
71
+ timeoutSeconds;
72
+ debug;
73
+ constructor(config) {
74
+ this.host = config.host.replace(/\/$/, "");
75
+ this.publicKey = config.publicKey;
76
+ this.secretKey = config.secretKey;
77
+ this.timeoutSeconds = config.timeoutSeconds ?? 120;
78
+ this.debug = config.debug ?? false;
79
+ }
80
+ /** Create a client from GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY. */
81
+ static fromEnv(config = {}) {
82
+ const host = config.host ?? process.env.GATEWAY_HOST;
83
+ const publicKey = config.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;
84
+ const secretKey = config.secretKey ?? process.env.GATEWAY_SECRET_KEY;
85
+ const missing = [
86
+ ["host", host],
87
+ ["publicKey", publicKey],
88
+ ["secretKey", secretKey]
89
+ ].filter(([, value]) => !value).map(([name]) => name);
90
+ if (missing.length > 0) {
91
+ throw new PersonaError(
92
+ `Missing Gateway persona configuration: ${missing.join(", ")}`
93
+ );
94
+ }
95
+ return new _PersonasClient({
96
+ ...config,
97
+ host,
98
+ publicKey,
99
+ secretKey
100
+ });
101
+ }
102
+ /** List the project's personas (without full instructions). */
103
+ async list() {
104
+ const payload = await this.requestJson("GET", "/api/public/personas");
105
+ const items = Array.isArray(payload.data) ? payload.data : [];
106
+ return items.filter(isRecord).map(
107
+ (item) => new Persona({
108
+ id: String(item.id),
109
+ name: String(item.name),
110
+ description: item.description ?? null,
111
+ version: typeof item.version === "number" ? item.version : 1,
112
+ instructions: "",
113
+ client: this
114
+ })
115
+ );
116
+ }
117
+ /** Fetch a persona (full definition) bound to this client. */
118
+ async get(personaId) {
119
+ const item = await this.requestJson(
120
+ "GET",
121
+ `/api/public/personas/${encodeURIComponent(personaId)}/chat`
122
+ );
123
+ return new Persona({
124
+ id: String(item.id),
125
+ name: String(item.name),
126
+ description: item.description ?? null,
127
+ version: typeof item.version === "number" ? item.version : 1,
128
+ instructions: typeof item.instructions === "string" ? item.instructions : "",
129
+ examples: Array.isArray(item.examples) ? item.examples.map((example) => String(example)) : [],
130
+ client: this
131
+ });
132
+ }
133
+ /** Play one persona turn. See {@link Persona.respond}. */
134
+ async chat(personaId, messages) {
135
+ const payload = await this.requestJson(
136
+ "POST",
137
+ `/api/public/personas/${encodeURIComponent(personaId)}/chat`,
138
+ { messages }
139
+ );
140
+ return {
141
+ content: typeof payload.content === "string" ? payload.content : "",
142
+ done: Boolean(payload.done)
143
+ };
144
+ }
145
+ async requestJson(method, path, payload) {
146
+ let response;
147
+ try {
148
+ response = await fetch(`${this.host}${path}`, {
149
+ method,
150
+ headers: {
151
+ Authorization: this.authHeader(),
152
+ "Content-Type": "application/json"
153
+ },
154
+ ...payload ? { body: JSON.stringify(payload) } : {},
155
+ signal: AbortSignal.timeout(this.timeoutSeconds * 1e3)
156
+ });
157
+ } catch (error) {
158
+ const reason = error instanceof Error ? error.message : String(error);
159
+ throw new PersonaError(`${method} ${path} failed: ${reason}`, {
160
+ cause: error
161
+ });
162
+ }
163
+ const text = await response.text();
164
+ if (!response.ok) {
165
+ const detail = text.slice(0, 500);
166
+ throw new PersonaError(
167
+ `${method} ${path} failed (${response.status}): ${detail}`
168
+ );
169
+ }
170
+ this.log("%s %s -> %s", method, path, response.status);
171
+ return safeJson(text);
172
+ }
173
+ authHeader() {
174
+ return `Basic ${Buffer.from(`${this.publicKey}:${this.secretKey}`).toString(
175
+ "base64"
176
+ )}`;
177
+ }
178
+ log(message, ...args) {
179
+ if (this.debug) {
180
+ console.log(`[gateway.personas] ${message}`, ...args);
181
+ }
182
+ }
183
+ };
184
+ function isRecord(value) {
185
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
186
+ }
187
+ function safeJson(value) {
188
+ try {
189
+ const parsed = JSON.parse(value);
190
+ return isRecord(parsed) ? parsed : {};
191
+ } catch {
192
+ return {};
193
+ }
194
+ }
195
+ var personas = {
196
+ fromEnv: PersonasClient.fromEnv
197
+ };
198
+ // Annotate the CommonJS export names for ESM import in node:
199
+ 0 && (module.exports = {
200
+ Persona,
201
+ PersonaError,
202
+ PersonasClient,
203
+ personas
204
+ });
205
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/personas/index.ts"],"sourcesContent":["/**\n * Personas — simulated users served by the Gateway platform.\n *\n * A persona is a crafted user profile (usually derived from real sessions on\n * the platform) that Gateway serves as an endpoint. Use it to drive your agent\n * in tests: the persona plays the user, your agent plays itself.\n *\n * Example:\n * ```ts\n * import { PersonasClient } from \"@withgateway/sdk/personas\";\n *\n * const personas = PersonasClient.fromEnv();\n * const persona = await personas.get(\"persona_id\");\n *\n * const messages: PersonaMessage[] = [];\n * let reply = await persona.respond(messages); // persona opens the conversation\n * while (!reply.done) {\n * messages.push({ role: \"user\", content: reply.content });\n * const agentAnswer = await myAgent(messages); // your agent under test\n * messages.push({ role: \"assistant\", content: agentAnswer });\n * reply = await persona.respond(messages);\n * }\n * ```\n *\n * Message roles are from YOUR agent's perspective: `user` = the simulated\n * user's turns, `assistant` = your agent's turns.\n */\n\ntype PersonaMessage = {\n role: \"user\" | \"assistant\";\n content: string;\n};\n\n/** One simulated-user turn. */\ntype PersonaReply = {\n content: string;\n done: boolean;\n};\n\ntype PersonasClientConfig = {\n host: string;\n publicKey: string;\n secretKey: string;\n timeoutSeconds?: number;\n debug?: boolean;\n};\n\ntype PersonasClientFromEnvConfig = Partial<PersonasClientConfig>;\n\n/** Raised when the Gateway personas API cannot complete a request. */\nexport class PersonaError extends Error {\n constructor(message: string, options?: { cause?: unknown }) {\n super(message);\n this.name = \"PersonaError\";\n this.cause = options?.cause;\n }\n}\n\n/** A persona definition plus a bound `respond` helper. */\nexport class Persona {\n readonly id: string;\n readonly name: string;\n readonly description: string | null;\n readonly version: number;\n readonly instructions: string;\n readonly examples: string[];\n private readonly client: PersonasClient | null;\n\n constructor(fields: {\n id: string;\n name: string;\n description: string | null;\n version: number;\n instructions: string;\n examples?: string[];\n client?: PersonasClient | null;\n }) {\n this.id = fields.id;\n this.name = fields.name;\n this.description = fields.description;\n this.version = fields.version;\n this.instructions = fields.instructions;\n this.examples = fields.examples ?? [];\n this.client = fields.client ?? null;\n }\n\n /**\n * Get the persona's next user message for a conversation.\n *\n * `messages` use your agent's perspective: role `user` for the simulated\n * user's prior turns, `assistant` for your agent's turns.\n * `done` is true when the persona considers its goal met.\n */\n respond(messages: PersonaMessage[]): Promise<PersonaReply> {\n if (this.client === null) {\n throw new PersonaError(\"Persona is not bound to a client.\");\n }\n return this.client.chat(this.id, messages);\n }\n}\n\n/** Client for Gateway's persona endpoints (HTTP Basic project keys). */\nexport class PersonasClient {\n private readonly host: string;\n private readonly publicKey: string;\n private readonly secretKey: string;\n private readonly timeoutSeconds: number;\n private readonly debug: boolean;\n\n constructor(config: PersonasClientConfig) {\n this.host = config.host.replace(/\\/$/, \"\");\n this.publicKey = config.publicKey;\n this.secretKey = config.secretKey;\n this.timeoutSeconds = config.timeoutSeconds ?? 120;\n this.debug = config.debug ?? false;\n }\n\n /** Create a client from GATEWAY_HOST / GATEWAY_PUBLIC_KEY / GATEWAY_SECRET_KEY. */\n static fromEnv(config: PersonasClientFromEnvConfig = {}) {\n const host = config.host ?? process.env.GATEWAY_HOST;\n const publicKey = config.publicKey ?? process.env.GATEWAY_PUBLIC_KEY;\n const secretKey = config.secretKey ?? process.env.GATEWAY_SECRET_KEY;\n\n const missing = [\n [\"host\", host],\n [\"publicKey\", publicKey],\n [\"secretKey\", secretKey],\n ]\n .filter(([, value]) => !value)\n .map(([name]) => name);\n\n if (missing.length > 0) {\n throw new PersonaError(\n `Missing Gateway persona configuration: ${missing.join(\", \")}`,\n );\n }\n\n return new PersonasClient({\n ...config,\n host: host!,\n publicKey: publicKey!,\n secretKey: secretKey!,\n });\n }\n\n /** List the project's personas (without full instructions). */\n async list(): Promise<Persona[]> {\n const payload = await this.requestJson(\"GET\", \"/api/public/personas\");\n const items = Array.isArray(payload.data) ? payload.data : [];\n return items\n .filter(isRecord)\n .map(\n (item) =>\n new Persona({\n id: String(item.id),\n name: String(item.name),\n description: (item.description as string | null | undefined) ?? null,\n version: typeof item.version === \"number\" ? item.version : 1,\n instructions: \"\",\n client: this,\n }),\n );\n }\n\n /** Fetch a persona (full definition) bound to this client. */\n async get(personaId: string): Promise<Persona> {\n const item = await this.requestJson(\n \"GET\",\n `/api/public/personas/${encodeURIComponent(personaId)}/chat`,\n );\n return new Persona({\n id: String(item.id),\n name: String(item.name),\n description: (item.description as string | null | undefined) ?? null,\n version: typeof item.version === \"number\" ? item.version : 1,\n instructions: typeof item.instructions === \"string\" ? item.instructions : \"\",\n examples: Array.isArray(item.examples)\n ? item.examples.map((example) => String(example))\n : [],\n client: this,\n });\n }\n\n /** Play one persona turn. See {@link Persona.respond}. */\n async chat(\n personaId: string,\n messages: PersonaMessage[],\n ): Promise<PersonaReply> {\n const payload = await this.requestJson(\n \"POST\",\n `/api/public/personas/${encodeURIComponent(personaId)}/chat`,\n { messages },\n );\n return {\n content: typeof payload.content === \"string\" ? payload.content : \"\",\n done: Boolean(payload.done),\n };\n }\n\n private async requestJson(\n method: \"GET\" | \"POST\",\n path: string,\n payload?: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n let response: Response;\n try {\n response = await fetch(`${this.host}${path}`, {\n method,\n headers: {\n Authorization: this.authHeader(),\n \"Content-Type\": \"application/json\",\n },\n ...(payload ? { body: JSON.stringify(payload) } : {}),\n signal: AbortSignal.timeout(this.timeoutSeconds * 1000),\n });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n throw new PersonaError(`${method} ${path} failed: ${reason}`, {\n cause: error,\n });\n }\n\n const text = await response.text();\n if (!response.ok) {\n const detail = text.slice(0, 500);\n throw new PersonaError(\n `${method} ${path} failed (${response.status}): ${detail}`,\n );\n }\n\n this.log(\"%s %s -> %s\", method, path, response.status);\n return safeJson(text);\n }\n\n private authHeader() {\n return `Basic ${Buffer.from(`${this.publicKey}:${this.secretKey}`).toString(\n \"base64\",\n )}`;\n }\n\n private log(message: string, ...args: unknown[]) {\n if (this.debug) {\n console.log(`[gateway.personas] ${message}`, ...args);\n }\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === \"object\" && !Array.isArray(value);\n}\n\nfunction safeJson(value: string): Record<string, unknown> {\n try {\n const parsed = JSON.parse(value);\n return isRecord(parsed) ? parsed : {};\n } catch {\n return {};\n }\n}\n\nexport const personas = {\n fromEnv: PersonasClient.fromEnv,\n};\n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