lemma-sdk 0.2.0 → 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.
Files changed (42) hide show
  1. package/README.md +108 -36
  2. package/dist/browser/lemma-client.js +2012 -1242
  3. package/dist/client.d.ts +23 -6
  4. package/dist/client.js +32 -11
  5. package/dist/http.d.ts +18 -5
  6. package/dist/http.js +77 -22
  7. package/dist/index.d.ts +16 -7
  8. package/dist/index.js +1 -0
  9. package/dist/namespaces/assistants.d.ts +61 -16
  10. package/dist/namespaces/assistants.js +130 -19
  11. package/dist/namespaces/icons.d.ts +7 -0
  12. package/dist/namespaces/icons.js +13 -0
  13. package/dist/namespaces/organizations.d.ts +46 -0
  14. package/dist/namespaces/organizations.js +51 -0
  15. package/dist/namespaces/pod-members.d.ts +15 -0
  16. package/dist/namespaces/pod-members.js +19 -0
  17. package/dist/namespaces/pod-surfaces.d.ts +16 -0
  18. package/dist/namespaces/pod-surfaces.js +22 -0
  19. package/dist/namespaces/pods.d.ts +26 -0
  20. package/dist/namespaces/pods.js +41 -0
  21. package/dist/namespaces/records.d.ts +7 -3
  22. package/dist/namespaces/records.js +34 -3
  23. package/dist/namespaces/resources.d.ts +16 -0
  24. package/dist/namespaces/resources.js +32 -0
  25. package/dist/namespaces/tables.d.ts +7 -1
  26. package/dist/namespaces/tables.js +11 -1
  27. package/dist/namespaces/tasks.d.ts +15 -9
  28. package/dist/namespaces/tasks.js +43 -11
  29. package/dist/namespaces/users.d.ts +9 -0
  30. package/dist/namespaces/users.js +16 -0
  31. package/dist/namespaces/workflows.d.ts +8 -1
  32. package/dist/namespaces/workflows.js +23 -1
  33. package/dist/react/index.d.ts +4 -0
  34. package/dist/react/index.js +2 -0
  35. package/dist/react/useAgentRun.d.ts +17 -0
  36. package/dist/react/useAgentRun.js +66 -0
  37. package/dist/react/useAssistantRun.d.ts +18 -0
  38. package/dist/react/useAssistantRun.js +82 -0
  39. package/dist/streams.d.ts +10 -0
  40. package/dist/streams.js +68 -0
  41. package/dist/types.d.ts +39 -1
  42. package/package.json +5 -5
package/dist/client.d.ts CHANGED
@@ -1,16 +1,23 @@
1
1
  import { type LemmaConfig } from "./config.js";
2
2
  import { AuthManager, type AuthState, type AuthListener } from "./auth.js";
3
+ import { AgentsNamespace } from "./namespaces/agents.js";
4
+ import { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
3
5
  import { DatastoresNamespace } from "./namespaces/datastores.js";
4
- import { TablesNamespace } from "./namespaces/tables.js";
5
- import { RecordsNamespace } from "./namespaces/records.js";
6
+ import { DesksNamespace } from "./namespaces/desks.js";
6
7
  import { FilesNamespace } from "./namespaces/files.js";
7
8
  import { FunctionsNamespace } from "./namespaces/functions.js";
8
- import { AgentsNamespace } from "./namespaces/agents.js";
9
+ import { IconsNamespace } from "./namespaces/icons.js";
10
+ import { IntegrationsNamespace } from "./namespaces/integrations.js";
11
+ import { OrganizationsNamespace } from "./namespaces/organizations.js";
12
+ import { PodMembersNamespace } from "./namespaces/pod-members.js";
13
+ import { PodsNamespace } from "./namespaces/pods.js";
14
+ import { PodSurfacesNamespace } from "./namespaces/pod-surfaces.js";
15
+ import { RecordsNamespace } from "./namespaces/records.js";
16
+ import { ResourcesNamespace } from "./namespaces/resources.js";
17
+ import { TablesNamespace } from "./namespaces/tables.js";
9
18
  import { TasksNamespace } from "./namespaces/tasks.js";
10
- import { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
19
+ import { UsersNamespace } from "./namespaces/users.js";
11
20
  import { WorkflowsNamespace } from "./namespaces/workflows.js";
12
- import { DesksNamespace } from "./namespaces/desks.js";
13
- import { IntegrationsNamespace } from "./namespaces/integrations.js";
14
21
  export type { LemmaConfig };
15
22
  export { AuthManager };
16
23
  export type { AuthState, AuthListener };
@@ -34,6 +41,13 @@ export declare class LemmaClient {
34
41
  readonly workflows: WorkflowsNamespace;
35
42
  readonly desks: DesksNamespace;
36
43
  readonly integrations: IntegrationsNamespace;
44
+ readonly resources: ResourcesNamespace;
45
+ readonly users: UsersNamespace;
46
+ readonly icons: IconsNamespace;
47
+ readonly pods: PodsNamespace;
48
+ readonly podMembers: PodMembersNamespace;
49
+ readonly organizations: OrganizationsNamespace;
50
+ readonly podSurfaces: PodSurfacesNamespace;
37
51
  constructor(overrides?: Partial<LemmaConfig>);
38
52
  /** Change the active pod ID for subsequent calls. */
39
53
  setPodId(podId: string): void;
@@ -51,5 +65,8 @@ export declare class LemmaClient {
51
65
  request<T = unknown>(method: string, path: string, options?: {
52
66
  params?: Record<string, string | number | boolean | undefined | null>;
53
67
  body?: unknown;
68
+ headers?: HeadersInit;
69
+ isFormData?: boolean;
70
+ signal?: AbortSignal;
54
71
  }): Promise<T>;
55
72
  }
package/dist/client.js CHANGED
@@ -2,17 +2,24 @@ import { resolveConfig } from "./config.js";
2
2
  import { AuthManager } from "./auth.js";
3
3
  import { GeneratedClientAdapter } from "./generated.js";
4
4
  import { HttpClient } from "./http.js";
5
+ import { AgentsNamespace } from "./namespaces/agents.js";
6
+ import { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
5
7
  import { DatastoresNamespace } from "./namespaces/datastores.js";
6
- import { TablesNamespace } from "./namespaces/tables.js";
7
- import { RecordsNamespace } from "./namespaces/records.js";
8
+ import { DesksNamespace } from "./namespaces/desks.js";
8
9
  import { FilesNamespace } from "./namespaces/files.js";
9
10
  import { FunctionsNamespace } from "./namespaces/functions.js";
10
- import { AgentsNamespace } from "./namespaces/agents.js";
11
+ import { IconsNamespace } from "./namespaces/icons.js";
12
+ import { IntegrationsNamespace } from "./namespaces/integrations.js";
13
+ import { OrganizationsNamespace } from "./namespaces/organizations.js";
14
+ import { PodMembersNamespace } from "./namespaces/pod-members.js";
15
+ import { PodsNamespace } from "./namespaces/pods.js";
16
+ import { PodSurfacesNamespace } from "./namespaces/pod-surfaces.js";
17
+ import { RecordsNamespace } from "./namespaces/records.js";
18
+ import { ResourcesNamespace } from "./namespaces/resources.js";
19
+ import { TablesNamespace } from "./namespaces/tables.js";
11
20
  import { TasksNamespace } from "./namespaces/tasks.js";
12
- import { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
21
+ import { UsersNamespace } from "./namespaces/users.js";
13
22
  import { WorkflowsNamespace } from "./namespaces/workflows.js";
14
- import { DesksNamespace } from "./namespaces/desks.js";
15
- import { IntegrationsNamespace } from "./namespaces/integrations.js";
16
23
  export { AuthManager };
17
24
  export class LemmaClient {
18
25
  _config;
@@ -35,6 +42,13 @@ export class LemmaClient {
35
42
  workflows;
36
43
  desks;
37
44
  integrations;
45
+ resources;
46
+ users;
47
+ icons;
48
+ pods;
49
+ podMembers;
50
+ organizations;
51
+ podSurfaces;
38
52
  constructor(overrides = {}) {
39
53
  this._config = resolveConfig(overrides);
40
54
  this._currentPodId = this._config.podId;
@@ -50,16 +64,23 @@ export class LemmaClient {
50
64
  };
51
65
  this.datastores = new DatastoresNamespace(this._generated, podIdFn);
52
66
  this.tables = new TablesNamespace(this._generated, podIdFn);
53
- this.records = new RecordsNamespace(this._generated, podIdFn);
67
+ this.records = new RecordsNamespace(this._generated, this._http, podIdFn);
54
68
  this.files = new FilesNamespace(this._generated, this._http, podIdFn);
55
69
  this.functions = new FunctionsNamespace(this._generated, podIdFn);
56
70
  this.agents = new AgentsNamespace(this._generated, podIdFn);
57
- this.tasks = new TasksNamespace(this._generated, podIdFn);
58
- this.assistants = new AssistantsNamespace(this._generated, podIdFn);
59
- this.conversations = new ConversationsNamespace(this._generated, podIdFn);
60
- this.workflows = new WorkflowsNamespace(this._generated, podIdFn);
71
+ this.tasks = new TasksNamespace(this._http, podIdFn);
72
+ this.assistants = new AssistantsNamespace(this._http, podIdFn);
73
+ this.conversations = new ConversationsNamespace(this._http, podIdFn);
74
+ this.workflows = new WorkflowsNamespace(this._generated, this._http, podIdFn);
61
75
  this.desks = new DesksNamespace(this._generated, this._http, podIdFn);
62
76
  this.integrations = new IntegrationsNamespace(this._generated);
77
+ this.resources = new ResourcesNamespace(this._http);
78
+ this.users = new UsersNamespace(this._generated);
79
+ this.icons = new IconsNamespace(this._generated);
80
+ this.pods = new PodsNamespace(this._generated, this._http);
81
+ this.podMembers = new PodMembersNamespace(this._generated);
82
+ this.organizations = new OrganizationsNamespace(this._generated, this._http);
83
+ this.podSurfaces = new PodSurfacesNamespace(this._generated);
63
84
  }
64
85
  /** Change the active pod ID for subsequent calls. */
65
86
  setPodId(podId) {
package/dist/http.d.ts CHANGED
@@ -3,6 +3,14 @@
3
3
  * and automatic 401→unauthenticated state propagation.
4
4
  */
5
5
  import type { AuthManager } from "./auth.js";
6
+ type RequestParams = Record<string, string | number | boolean | undefined | null>;
7
+ interface RequestOptions {
8
+ params?: RequestParams;
9
+ body?: unknown;
10
+ isFormData?: boolean;
11
+ headers?: HeadersInit;
12
+ signal?: AbortSignal;
13
+ }
6
14
  export declare class ApiError extends Error {
7
15
  readonly statusCode: number;
8
16
  readonly code?: string | undefined;
@@ -14,11 +22,16 @@ export declare class HttpClient {
14
22
  private readonly apiUrl;
15
23
  private readonly auth;
16
24
  constructor(apiUrl: string, auth: AuthManager);
25
+ getBaseUrl(): string;
26
+ private buildUrl;
27
+ private mergeHeaders;
17
28
  private parseError;
18
- request<T = unknown>(method: string, path: string, options?: {
19
- params?: Record<string, string | number | boolean | undefined | null>;
20
- body?: unknown;
21
- isFormData?: boolean;
22
- }): Promise<T>;
29
+ private getRequestBody;
30
+ private buildRequestInit;
31
+ request<T = unknown>(method: string, path: string, options?: RequestOptions): Promise<T>;
32
+ stream(path: string, options?: Omit<RequestOptions, "isFormData"> & {
33
+ method?: "GET" | "POST" | "PATCH";
34
+ }): Promise<ReadableStream<Uint8Array>>;
23
35
  requestBytes(method: string, path: string): Promise<Blob>;
24
36
  }
37
+ export {};
package/dist/http.js CHANGED
@@ -23,6 +23,35 @@ export class HttpClient {
23
23
  this.apiUrl = apiUrl;
24
24
  this.auth = auth;
25
25
  }
26
+ getBaseUrl() {
27
+ return this.apiUrl;
28
+ }
29
+ buildUrl(path, params) {
30
+ let url = `${this.apiUrl}${path}`;
31
+ if (!params) {
32
+ return url;
33
+ }
34
+ const qs = Object.entries(params)
35
+ .filter(([, value]) => value !== undefined && value !== null)
36
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`)
37
+ .join("&");
38
+ if (qs) {
39
+ url += `?${qs}`;
40
+ }
41
+ return url;
42
+ }
43
+ mergeHeaders(base, extra) {
44
+ if (!extra) {
45
+ return base;
46
+ }
47
+ const merged = new Headers(base.headers ?? {});
48
+ const extraHeaders = new Headers(extra);
49
+ extraHeaders.forEach((value, key) => merged.set(key, value));
50
+ return {
51
+ ...base,
52
+ headers: merged,
53
+ };
54
+ }
26
55
  async parseError(response) {
27
56
  let message = response.statusText || "Request failed";
28
57
  let code;
@@ -32,9 +61,14 @@ export class HttpClient {
32
61
  const body = await response.json();
33
62
  raw = body;
34
63
  if (body && typeof body === "object") {
35
- message = body.message ?? message;
36
- code = body.code;
37
- details = body.details;
64
+ const record = body;
65
+ if (typeof record.message === "string") {
66
+ message = record.message;
67
+ }
68
+ if (typeof record.code === "string") {
69
+ code = record.code;
70
+ }
71
+ details = record.details;
38
72
  }
39
73
  }
40
74
  catch {
@@ -42,31 +76,33 @@ export class HttpClient {
42
76
  }
43
77
  return new ApiError(response.status, message, code, details, raw);
44
78
  }
45
- async request(method, path, options = {}) {
46
- let url = `${this.apiUrl}${path}`;
47
- if (options.params) {
48
- const qs = Object.entries(options.params)
49
- .filter(([, v]) => v !== undefined && v !== null)
50
- .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
51
- .join("&");
52
- if (qs) {
53
- url += `?${qs}`;
54
- }
55
- }
56
- const initBase = { method };
57
- if (options.body !== undefined && !options.isFormData) {
58
- initBase.body = JSON.stringify(options.body);
79
+ getRequestBody(options) {
80
+ if (options.body === undefined) {
81
+ return undefined;
59
82
  }
60
- else if (options.isFormData && options.body instanceof FormData) {
61
- initBase.body = options.body;
83
+ if (options.isFormData && options.body instanceof FormData) {
84
+ return options.body;
62
85
  }
63
- // For FormData, let the browser set Content-Type with boundary
64
- const init = options.isFormData
86
+ return JSON.stringify(options.body);
87
+ }
88
+ buildRequestInit(method, options) {
89
+ const initBase = {
90
+ method,
91
+ body: this.getRequestBody(options),
92
+ signal: options.signal,
93
+ };
94
+ // For FormData, let the browser set Content-Type with boundary.
95
+ const withAuth = options.isFormData
65
96
  ? {
66
97
  ...this.auth.getRequestInit(initBase),
67
- headers: Object.fromEntries(Object.entries(this.auth.getRequestInit(initBase).headers ?? {}).filter(([k]) => k.toLowerCase() !== "content-type")),
98
+ headers: Object.fromEntries(Object.entries(this.auth.getRequestInit(initBase).headers ?? {}).filter(([key]) => key.toLowerCase() !== "content-type")),
68
99
  }
69
100
  : this.auth.getRequestInit(initBase);
101
+ return this.mergeHeaders(withAuth, options.headers);
102
+ }
103
+ async request(method, path, options = {}) {
104
+ const url = this.buildUrl(path, options.params);
105
+ const init = this.buildRequestInit(method, options);
70
106
  const response = await fetch(url, init);
71
107
  // Only 401 means the session is gone — 403 is a permission/RLS error, not an auth failure
72
108
  if (response.status === 401) {
@@ -84,6 +120,25 @@ export class HttpClient {
84
120
  }
85
121
  return response.text();
86
122
  }
123
+ async stream(path, options = {}) {
124
+ const response = await fetch(this.buildUrl(path, options.params), this.buildRequestInit(options.method ?? "GET", {
125
+ ...options,
126
+ headers: {
127
+ Accept: "text/event-stream",
128
+ ...options.headers,
129
+ },
130
+ }));
131
+ if (response.status === 401) {
132
+ this.auth.markUnauthenticated();
133
+ }
134
+ if (!response.ok) {
135
+ throw await this.parseError(response);
136
+ }
137
+ if (!response.body) {
138
+ throw new ApiError(response.status, "Stream response had no body.");
139
+ }
140
+ return response.body;
141
+ }
87
142
  async requestBytes(method, path) {
88
143
  const url = `${this.apiUrl}${path}`;
89
144
  const response = await fetch(url, this.auth.getRequestInit({ method }));
package/dist/index.d.ts CHANGED
@@ -3,16 +3,25 @@ export type { LemmaConfig } from "./client.js";
3
3
  export { AuthManager } from "./auth.js";
4
4
  export type { AuthState, AuthListener, AuthStatus, UserInfo } from "./auth.js";
5
5
  export { ApiError } from "./http.js";
6
- export type { ListRecordsOptions, RecordFilter, RecordSort, RunFunctionOptions, CreateTaskOptions, WorkflowRunInputs } from "./types.js";
6
+ export type { Agent, Assistant, Conversation, ConversationMessage, ConversationModel, CreateAgentInput, CreateAssistantInput, CreateTaskOptions, CursorPage, ListRecordsOptions, Organization, OrganizationInvitation, OrganizationMember, Pod, PodConfig, PodMember, RecordFilter, RecordSort, RunFunctionOptions, StreamOptions, Task, TaskMessage, UpdateAgentInput, UpdateAssistantInput, UploadedIcon, User, WorkflowRunInputs, } from "./types.js";
7
+ export { readSSE, parseSSEJson } from "./streams.js";
8
+ export type { SseRawEvent } from "./streams.js";
7
9
  export * from "./openapi_client/index.js";
10
+ export type { AgentsNamespace } from "./namespaces/agents.js";
11
+ export type { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
8
12
  export type { DatastoresNamespace } from "./namespaces/datastores.js";
9
- export type { TablesNamespace } from "./namespaces/tables.js";
10
- export type { RecordsNamespace } from "./namespaces/records.js";
13
+ export type { DesksNamespace } from "./namespaces/desks.js";
11
14
  export type { FilesNamespace } from "./namespaces/files.js";
12
15
  export type { FunctionsNamespace } from "./namespaces/functions.js";
13
- export type { AgentsNamespace } from "./namespaces/agents.js";
16
+ export type { IconsNamespace } from "./namespaces/icons.js";
17
+ export type { IntegrationsNamespace } from "./namespaces/integrations.js";
18
+ export type { OrganizationsNamespace } from "./namespaces/organizations.js";
19
+ export type { PodMembersNamespace } from "./namespaces/pod-members.js";
20
+ export type { PodsNamespace } from "./namespaces/pods.js";
21
+ export type { PodSurfacesNamespace } from "./namespaces/pod-surfaces.js";
22
+ export type { RecordsNamespace } from "./namespaces/records.js";
23
+ export type { ResourceType, ResourcesNamespace } from "./namespaces/resources.js";
24
+ export type { TablesNamespace } from "./namespaces/tables.js";
14
25
  export type { TasksNamespace } from "./namespaces/tasks.js";
15
- export type { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
26
+ export type { UsersNamespace } from "./namespaces/users.js";
16
27
  export type { WorkflowsNamespace } from "./namespaces/workflows.js";
17
- export type { DesksNamespace } from "./namespaces/desks.js";
18
- export type { IntegrationsNamespace } from "./namespaces/integrations.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { LemmaClient } from "./client.js";
2
2
  export { AuthManager } from "./auth.js";
3
3
  export { ApiError } from "./http.js";
4
+ export { readSSE, parseSSEJson } from "./streams.js";
4
5
  export * from "./openapi_client/index.js";
@@ -1,36 +1,81 @@
1
- import type { GeneratedClientAdapter } from "../generated.js";
1
+ import type { HttpClient } from "../http.js";
2
2
  import type { CreateAssistantRequest } from "../openapi_client/models/CreateAssistantRequest.js";
3
- import type { UpdateAssistantRequest } from "../openapi_client/models/UpdateAssistantRequest.js";
4
3
  import type { CreateConversationRequest } from "../openapi_client/models/CreateConversationRequest.js";
5
4
  import type { CreateMessageRequest } from "../openapi_client/models/CreateMessageRequest.js";
5
+ import type { UpdateAssistantRequest } from "../openapi_client/models/UpdateAssistantRequest.js";
6
6
  export declare class AssistantsNamespace {
7
- private readonly client;
7
+ private readonly http;
8
8
  private readonly podId;
9
- constructor(client: GeneratedClientAdapter, podId: () => string);
9
+ constructor(http: HttpClient, podId: () => string);
10
10
  list(options?: {
11
11
  limit?: number;
12
12
  pageToken?: string;
13
- }): Promise<import("../index.js").AssistantListResponse>;
14
- create(payload: CreateAssistantRequest): Promise<import("../index.js").AssistantResponse>;
15
- get(assistantName: string): Promise<import("../index.js").AssistantResponse>;
16
- update(assistantName: string, payload: UpdateAssistantRequest): Promise<import("../index.js").AssistantResponse>;
17
- delete(assistantName: string): Promise<void>;
13
+ cursor?: string;
14
+ }): Promise<unknown>;
15
+ create(payload: CreateAssistantRequest | Record<string, unknown>): Promise<unknown>;
16
+ get(assistantName: string): Promise<unknown>;
17
+ update(assistantName: string, payload: UpdateAssistantRequest | Record<string, unknown>): Promise<unknown>;
18
+ delete(assistantName: string): Promise<unknown>;
18
19
  }
19
20
  export declare class ConversationsNamespace {
20
- private readonly client;
21
+ private readonly http;
21
22
  private readonly podId;
22
- constructor(client: GeneratedClientAdapter, podId: () => string);
23
+ constructor(http: HttpClient, podId: () => string);
24
+ private resolvePodId;
25
+ private requirePodId;
23
26
  list(options?: {
27
+ assistantId?: string;
28
+ assistantName?: string;
29
+ podId?: string;
30
+ organizationId?: string;
31
+ limit?: number;
32
+ pageToken?: string;
33
+ cursor?: string;
34
+ }): Promise<unknown>;
35
+ listByAssistant(assistantName: string, options?: {
36
+ podId?: string;
37
+ organizationId?: string;
24
38
  limit?: number;
25
39
  pageToken?: string;
26
- }): Promise<import("../index.js").ConversationListResponse>;
27
- create(payload: Omit<CreateConversationRequest, "pod_id">): Promise<import("../index.js").ConversationResponse>;
28
- get(conversationId: string): Promise<import("../index.js").ConversationResponse>;
40
+ cursor?: string;
41
+ }): Promise<unknown>;
42
+ create(payload: Omit<CreateConversationRequest, "pod_id"> & {
43
+ pod_id?: string;
44
+ assistant_name?: string | null;
45
+ }): Promise<unknown>;
46
+ createForAssistant(assistantName: string, payload?: Omit<CreateConversationRequest, "pod_id" | "assistant_id"> & {
47
+ pod_id?: string;
48
+ }): Promise<unknown>;
49
+ get(conversationId: string, options?: {
50
+ podId?: string;
51
+ }): Promise<unknown>;
52
+ update(conversationId: string, payload: Record<string, unknown>, options?: {
53
+ podId?: string;
54
+ }): Promise<unknown>;
55
+ delete(conversationId: string, options?: {
56
+ podId?: string;
57
+ }): Promise<unknown>;
58
+ sendMessageStream(conversationId: string, payload: CreateMessageRequest, options?: {
59
+ podId?: string;
60
+ signal?: AbortSignal;
61
+ }): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
62
+ resumeStream(conversationId: string, options?: {
63
+ podId?: string;
64
+ signal?: AbortSignal;
65
+ }): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>;
66
+ stopRun(conversationId: string, options?: {
67
+ podId?: string;
68
+ }): Promise<unknown>;
29
69
  readonly messages: {
30
70
  list: (conversationId: string, options?: {
31
71
  limit?: number;
32
72
  pageToken?: string;
33
- }) => Promise<import("../index.js").ConversationMessageListResponse>;
34
- send: (conversationId: string, payload: CreateMessageRequest) => Promise<any>;
73
+ cursor?: string;
74
+ order?: "asc" | "desc" | string;
75
+ podId?: string;
76
+ }) => Promise<unknown>;
77
+ send: (conversationId: string, payload: CreateMessageRequest, options?: {
78
+ podId?: string;
79
+ }) => Promise<unknown>;
35
80
  };
36
81
  }
@@ -1,46 +1,157 @@
1
- import { AssistantsService } from "../openapi_client/services/AssistantsService.js";
2
- import { ConversationsService } from "../openapi_client/services/ConversationsService.js";
3
1
  export class AssistantsNamespace {
4
- client;
2
+ http;
5
3
  podId;
6
- constructor(client, podId) {
7
- this.client = client;
4
+ constructor(http, podId) {
5
+ this.http = http;
8
6
  this.podId = podId;
9
7
  }
10
8
  list(options = {}) {
11
- return this.client.request(() => AssistantsService.assistantList(this.podId(), options.limit ?? 100, options.pageToken));
9
+ return this.http.request("GET", `/pods/${this.podId()}/assistants`, {
10
+ params: {
11
+ limit: options.limit ?? 100,
12
+ page_token: options.pageToken ?? options.cursor,
13
+ cursor: options.cursor,
14
+ },
15
+ });
12
16
  }
13
17
  create(payload) {
14
- return this.client.request(() => AssistantsService.assistantCreate(this.podId(), payload));
18
+ return this.http.request("POST", `/pods/${this.podId()}/assistants`, { body: payload });
15
19
  }
16
20
  get(assistantName) {
17
- return this.client.request(() => AssistantsService.assistantGet(this.podId(), assistantName));
21
+ return this.http.request("GET", `/pods/${this.podId()}/assistants/${assistantName}`);
18
22
  }
19
23
  update(assistantName, payload) {
20
- return this.client.request(() => AssistantsService.assistantUpdate(this.podId(), assistantName, payload));
24
+ return this.http.request("PATCH", `/pods/${this.podId()}/assistants/${assistantName}`, {
25
+ body: payload,
26
+ });
21
27
  }
22
28
  delete(assistantName) {
23
- return this.client.request(() => AssistantsService.assistantDelete(this.podId(), assistantName));
29
+ return this.http.request("DELETE", `/pods/${this.podId()}/assistants/${assistantName}`);
24
30
  }
25
31
  }
26
32
  export class ConversationsNamespace {
27
- client;
33
+ http;
28
34
  podId;
29
- constructor(client, podId) {
30
- this.client = client;
35
+ constructor(http, podId) {
36
+ this.http = http;
31
37
  this.podId = podId;
32
38
  }
39
+ resolvePodId(explicitPodId) {
40
+ if (typeof explicitPodId === "string") {
41
+ return explicitPodId;
42
+ }
43
+ try {
44
+ return this.podId();
45
+ }
46
+ catch {
47
+ return undefined;
48
+ }
49
+ }
50
+ requirePodId(explicitPodId) {
51
+ const podId = this.resolvePodId(explicitPodId);
52
+ if (!podId) {
53
+ throw new Error("pod_id is required for this conversation operation.");
54
+ }
55
+ return podId;
56
+ }
33
57
  list(options = {}) {
34
- return this.client.request(() => ConversationsService.conversationList(undefined, this.podId(), undefined, options.pageToken, options.limit ?? 20));
58
+ return this.http.request("GET", "/conversations", {
59
+ params: {
60
+ assistant_id: options.assistantName ?? options.assistantId,
61
+ pod_id: this.resolvePodId(options.podId),
62
+ organization_id: options.organizationId,
63
+ limit: options.limit ?? 20,
64
+ page_token: options.pageToken ?? options.cursor,
65
+ cursor: options.cursor,
66
+ },
67
+ });
68
+ }
69
+ listByAssistant(assistantName, options = {}) {
70
+ return this.list({ ...options, assistantName });
35
71
  }
36
72
  create(payload) {
37
- return this.client.request(() => ConversationsService.conversationCreate({ ...payload, pod_id: this.podId() }));
73
+ return this.http.request("POST", "/conversations", {
74
+ body: {
75
+ ...payload,
76
+ assistant_id: payload.assistant_id ?? payload.assistant_name,
77
+ pod_id: this.resolvePodId(payload.pod_id),
78
+ },
79
+ });
80
+ }
81
+ createForAssistant(assistantName, payload = {}) {
82
+ return this.create({
83
+ ...payload,
84
+ assistant_name: assistantName,
85
+ pod_id: payload.pod_id,
86
+ });
87
+ }
88
+ get(conversationId, options = {}) {
89
+ return this.http.request("GET", `/conversations/${conversationId}`, {
90
+ params: {
91
+ pod_id: this.resolvePodId(options.podId),
92
+ },
93
+ });
94
+ }
95
+ update(conversationId, payload, options = {}) {
96
+ return this.http.request("PATCH", `/conversations/${conversationId}`, {
97
+ params: {
98
+ pod_id: this.resolvePodId(options.podId),
99
+ },
100
+ body: payload,
101
+ });
102
+ }
103
+ delete(conversationId, options = {}) {
104
+ const scopedPodId = this.requirePodId(options.podId);
105
+ return this.http.request("DELETE", `/pods/${scopedPodId}/conversations/${conversationId}`);
106
+ }
107
+ sendMessageStream(conversationId, payload, options = {}) {
108
+ return this.http.stream(`/conversations/${conversationId}/messages`, {
109
+ method: "POST",
110
+ params: {
111
+ pod_id: this.resolvePodId(options.podId),
112
+ },
113
+ body: payload,
114
+ signal: options.signal,
115
+ headers: {
116
+ "Content-Type": "application/json",
117
+ Accept: "text/event-stream",
118
+ },
119
+ });
120
+ }
121
+ resumeStream(conversationId, options = {}) {
122
+ return this.http.stream(`/conversations/${conversationId}/stream`, {
123
+ params: {
124
+ pod_id: this.resolvePodId(options.podId),
125
+ },
126
+ signal: options.signal,
127
+ headers: {
128
+ Accept: "text/event-stream",
129
+ },
130
+ });
38
131
  }
39
- get(conversationId) {
40
- return this.client.request(() => ConversationsService.conversationGet(conversationId, this.podId()));
132
+ stopRun(conversationId, options = {}) {
133
+ return this.http.request("PATCH", `/conversations/${conversationId}/stop`, {
134
+ params: {
135
+ pod_id: this.resolvePodId(options.podId),
136
+ },
137
+ body: {},
138
+ });
41
139
  }
42
140
  messages = {
43
- list: (conversationId, options = {}) => this.client.request(() => ConversationsService.conversationMessageList(conversationId, this.podId(), options.pageToken, options.limit ?? 20)),
44
- send: (conversationId, payload) => this.client.request(() => ConversationsService.conversationMessageCreate(conversationId, payload, this.podId())),
141
+ list: (conversationId, options = {}) => this.http.request("GET", `/conversations/${conversationId}/messages`, {
142
+ params: {
143
+ pod_id: this.resolvePodId(options.podId),
144
+ limit: options.limit ?? 20,
145
+ page_token: options.pageToken ?? options.cursor,
146
+ cursor: options.cursor,
147
+ order: options.order,
148
+ },
149
+ }),
150
+ send: (conversationId, payload, options = {}) => this.http.request("POST", `/conversations/${conversationId}/messages`, {
151
+ params: {
152
+ pod_id: this.resolvePodId(options.podId),
153
+ },
154
+ body: payload,
155
+ }),
45
156
  };
46
157
  }
@@ -0,0 +1,7 @@
1
+ import type { GeneratedClientAdapter } from "../generated.js";
2
+ export declare class IconsNamespace {
3
+ private readonly client;
4
+ constructor(client: GeneratedClientAdapter);
5
+ upload(file: Blob): Promise<import("../index.js").IconUploadResponse>;
6
+ getPublic(iconPath: string): Promise<any>;
7
+ }
@@ -0,0 +1,13 @@
1
+ import { IconsService } from "../openapi_client/services/IconsService.js";
2
+ export class IconsNamespace {
3
+ client;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ upload(file) {
8
+ return this.client.request(() => IconsService.iconUpload({ file }));
9
+ }
10
+ getPublic(iconPath) {
11
+ return this.client.request(() => IconsService.iconPublicGet(iconPath));
12
+ }
13
+ }