@operator-labs/sdk 0.1.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.
@@ -0,0 +1,13 @@
1
+ export class HealthResource {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Check authentication status and plan info.
8
+ */
9
+ async check() {
10
+ return this.http.get("/api/cli/health");
11
+ }
12
+ }
13
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/resources/health.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAiB,iBAAiB,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,48 @@
1
+ import type { HttpClient } from "../client.js";
2
+ import type { Instance, CreateInstanceOptions, LogEntry } from "../types.js";
3
+ export declare class InstancesResource {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /**
7
+ * List all instances for the authenticated user.
8
+ */
9
+ list(): Promise<Instance[]>;
10
+ /**
11
+ * Get a single instance by ID.
12
+ */
13
+ get(instanceId: string): Promise<Instance>;
14
+ /**
15
+ * Create a new instance. Returns immediately while provisioning happens in the background.
16
+ */
17
+ create(options: CreateInstanceOptions): Promise<Instance>;
18
+ /**
19
+ * Update an instance (name, config, allowUserConfig, avatarUrl).
20
+ */
21
+ update(instanceId: string, updates: {
22
+ name?: string;
23
+ config?: Record<string, unknown>;
24
+ allowUserConfig?: boolean;
25
+ avatarUrl?: string;
26
+ }): Promise<Instance>;
27
+ /**
28
+ * Delete an instance. The container is cleaned up asynchronously.
29
+ */
30
+ delete(instanceId: string): Promise<void>;
31
+ /**
32
+ * Restart an instance. Syncs config and secrets before restarting.
33
+ */
34
+ restart(instanceId: string): Promise<void>;
35
+ /**
36
+ * Get recent logs for an instance.
37
+ */
38
+ logs(instanceId: string): Promise<LogEntry[]>;
39
+ /**
40
+ * Get an instance's config.
41
+ */
42
+ getConfig(instanceId: string): Promise<Record<string, unknown> | null>;
43
+ /**
44
+ * Update an instance's config (full replace).
45
+ */
46
+ updateConfig(instanceId: string, config: Record<string, unknown>): Promise<Instance>;
47
+ }
48
+ //# sourceMappingURL=instances.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances.d.ts","sourceRoot":"","sources":["../../src/resources/instances.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,QAAQ,EACT,MAAM,aAAa,CAAC;AAErB,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAKjC;;OAEG;IACG,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOhD;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQ/D;;OAEG;IACG,MAAM,CACV,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACjC,eAAe,CAAC,EAAE,OAAO,CAAC;QAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GACA,OAAO,CAAC,QAAQ,CAAC;IAQpB;;OAEG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C;;OAEG;IACG,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIhD;;OAEG;IACG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAOnD;;OAEG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAO5E;;OAEG;IACG,YAAY,CAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,QAAQ,CAAC;CAOrB"}
@@ -0,0 +1,71 @@
1
+ export class InstancesResource {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * List all instances for the authenticated user.
8
+ */
9
+ async list() {
10
+ const data = await this.http.get("/api/instances");
11
+ return data.instances;
12
+ }
13
+ /**
14
+ * Get a single instance by ID.
15
+ */
16
+ async get(instanceId) {
17
+ const data = await this.http.get(`/api/instances/${instanceId}`);
18
+ return data.instance;
19
+ }
20
+ /**
21
+ * Create a new instance. Returns immediately while provisioning happens in the background.
22
+ */
23
+ async create(options) {
24
+ const data = await this.http.post("/api/instances", {
25
+ name: options.name,
26
+ ...(options.checkpointRepo ? { checkpointRepo: options.checkpointRepo } : {}),
27
+ });
28
+ return data.instance;
29
+ }
30
+ /**
31
+ * Update an instance (name, config, allowUserConfig, avatarUrl).
32
+ */
33
+ async update(instanceId, updates) {
34
+ const data = await this.http.patch(`/api/instances/${instanceId}`, updates);
35
+ return data.instance;
36
+ }
37
+ /**
38
+ * Delete an instance. The container is cleaned up asynchronously.
39
+ */
40
+ async delete(instanceId) {
41
+ await this.http.delete(`/api/instances/${instanceId}`);
42
+ }
43
+ /**
44
+ * Restart an instance. Syncs config and secrets before restarting.
45
+ */
46
+ async restart(instanceId) {
47
+ await this.http.post(`/api/instances/${instanceId}/restart`);
48
+ }
49
+ /**
50
+ * Get recent logs for an instance.
51
+ */
52
+ async logs(instanceId) {
53
+ const data = await this.http.get(`/api/instances/${instanceId}/logs`);
54
+ return data.logs;
55
+ }
56
+ /**
57
+ * Get an instance's config.
58
+ */
59
+ async getConfig(instanceId) {
60
+ const data = await this.http.get(`/api/instances/${instanceId}`);
61
+ return data.instance.config ?? null;
62
+ }
63
+ /**
64
+ * Update an instance's config (full replace).
65
+ */
66
+ async updateConfig(instanceId, config) {
67
+ const data = await this.http.put(`/api/instances/${instanceId}/config`, { config });
68
+ return data.instance;
69
+ }
70
+ }
71
+ //# sourceMappingURL=instances.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instances.js","sourceRoot":"","sources":["../../src/resources/instances.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAA4B,gBAAgB,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,UAAkB;QAC1B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9B,kBAAkB,UAAU,EAAE,CAC/B,CAAC;QACF,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,OAA8B;QACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAyB,gBAAgB,EAAE;YAC1E,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9E,CAAC,CAAC;QACH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HttpClient } from "../client.js";
2
+ import type { Webhook, CreateWebhookOptions, UpdateWebhookOptions } from "../types.js";
3
+ export declare class WebhooksResource {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /**
7
+ * List all webhooks for the authenticated user.
8
+ */
9
+ list(): Promise<Webhook[]>;
10
+ /**
11
+ * Get a single webhook by ID.
12
+ */
13
+ get(webhookId: string): Promise<Webhook>;
14
+ /**
15
+ * Create a new webhook. The promptTemplate must include {{payload}}.
16
+ */
17
+ create(options: CreateWebhookOptions): Promise<Webhook>;
18
+ /**
19
+ * Update an existing webhook.
20
+ */
21
+ update(webhookId: string, options: UpdateWebhookOptions): Promise<Webhook>;
22
+ /**
23
+ * Delete a webhook.
24
+ */
25
+ delete(webhookId: string): Promise<void>;
26
+ }
27
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EACV,OAAO,EACP,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAOhC;;OAEG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9C;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAW7D;;OAEG;IACG,MAAM,CACV,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC;IAQnB;;OAEG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/C"}
@@ -0,0 +1,43 @@
1
+ export class WebhooksResource {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * List all webhooks for the authenticated user.
8
+ */
9
+ async list() {
10
+ const data = await this.http.get("/api/webhooks");
11
+ return data.webhooks;
12
+ }
13
+ /**
14
+ * Get a single webhook by ID.
15
+ */
16
+ async get(webhookId) {
17
+ return this.http.get(`/api/webhooks/${webhookId}`);
18
+ }
19
+ /**
20
+ * Create a new webhook. The promptTemplate must include {{payload}}.
21
+ */
22
+ async create(options) {
23
+ const data = await this.http.post("/api/webhooks", {
24
+ name: options.name,
25
+ promptTemplate: options.promptTemplate,
26
+ });
27
+ return data.webhook;
28
+ }
29
+ /**
30
+ * Update an existing webhook.
31
+ */
32
+ async update(webhookId, options) {
33
+ const data = await this.http.put(`/api/webhooks/${webhookId}`, options);
34
+ return data.webhook;
35
+ }
36
+ /**
37
+ * Delete a webhook.
38
+ */
39
+ async delete(webhookId) {
40
+ await this.http.delete(`/api/webhooks/${webhookId}`);
41
+ }
42
+ }
43
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9B,eAAe,CAChB,CAAC;QACF,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,GAAG,CAAC,SAAiB;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,iBAAiB,SAAS,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,OAA6B;QACxC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAC/B,eAAe,EACf;YACE,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CACF,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CACV,SAAiB,EACjB,OAA6B;QAE7B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9B,iBAAiB,SAAS,EAAE,EAC5B,OAAO,CACR,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC5B,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,SAAS,EAAE,CAAC,CAAC;IACvD,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ import type { StreamEvent } from "./types.js";
2
+ /**
3
+ * ChatStream wraps the SSE response from the Vercel AI SDK's
4
+ * `toUIMessageStreamResponse()` into a consumable async iterable.
5
+ *
6
+ * Supports:
7
+ * - `for await (const event of stream)` — iterate over parsed events
8
+ * - `stream.textStream()` — iterate over text deltas only
9
+ * - `stream.toText()` — collect the full text response
10
+ */
11
+ export declare class ChatStream implements AsyncIterable<StreamEvent> {
12
+ private readonly response;
13
+ constructor(response: Response);
14
+ /**
15
+ * Iterate over all parsed stream events.
16
+ */
17
+ [Symbol.asyncIterator](): AsyncGenerator<StreamEvent>;
18
+ /**
19
+ * Iterate over text deltas only.
20
+ */
21
+ textStream(): AsyncGenerator<string>;
22
+ /**
23
+ * Collect the full text response.
24
+ */
25
+ toText(): Promise<string>;
26
+ }
27
+ //# sourceMappingURL=stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;;;GAQG;AACH,qBAAa,UAAW,YAAW,aAAa,CAAC,WAAW,CAAC;IAC3D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;gBAExB,QAAQ,EAAE,QAAQ;IAI9B;;OAEG;IACI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,cAAc,CAAC,WAAW,CAAC;IAqC5D;;OAEG;IACI,UAAU,IAAI,cAAc,CAAC,MAAM,CAAC;IAQ3C;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;CAOhC"}
package/dist/stream.js ADDED
@@ -0,0 +1,140 @@
1
+ /**
2
+ * ChatStream wraps the SSE response from the Vercel AI SDK's
3
+ * `toUIMessageStreamResponse()` into a consumable async iterable.
4
+ *
5
+ * Supports:
6
+ * - `for await (const event of stream)` — iterate over parsed events
7
+ * - `stream.textStream()` — iterate over text deltas only
8
+ * - `stream.toText()` — collect the full text response
9
+ */
10
+ export class ChatStream {
11
+ response;
12
+ constructor(response) {
13
+ this.response = response;
14
+ }
15
+ /**
16
+ * Iterate over all parsed stream events.
17
+ */
18
+ async *[Symbol.asyncIterator]() {
19
+ const body = this.response.body;
20
+ if (!body)
21
+ return;
22
+ const reader = body.getReader();
23
+ const decoder = new TextDecoder();
24
+ let buffer = "";
25
+ try {
26
+ while (true) {
27
+ const { done, value } = await reader.read();
28
+ if (done)
29
+ break;
30
+ buffer += decoder.decode(value, { stream: true });
31
+ const lines = buffer.split("\n");
32
+ // Keep the last incomplete line in the buffer
33
+ buffer = lines.pop() ?? "";
34
+ for (const line of lines) {
35
+ const trimmed = line.trim();
36
+ if (!trimmed)
37
+ continue;
38
+ const event = parseLine(trimmed);
39
+ if (event)
40
+ yield event;
41
+ }
42
+ }
43
+ // Process any remaining buffer
44
+ if (buffer.trim()) {
45
+ const event = parseLine(buffer.trim());
46
+ if (event)
47
+ yield event;
48
+ }
49
+ }
50
+ finally {
51
+ reader.releaseLock();
52
+ }
53
+ }
54
+ /**
55
+ * Iterate over text deltas only.
56
+ */
57
+ async *textStream() {
58
+ for await (const event of this) {
59
+ if (event.type === "text-delta") {
60
+ yield event.text;
61
+ }
62
+ }
63
+ }
64
+ /**
65
+ * Collect the full text response.
66
+ */
67
+ async toText() {
68
+ let result = "";
69
+ for await (const chunk of this.textStream()) {
70
+ result += chunk;
71
+ }
72
+ return result;
73
+ }
74
+ }
75
+ /**
76
+ * Parse a single line from the Vercel AI SDK UIMessage stream protocol.
77
+ *
78
+ * The protocol uses lines like:
79
+ * 0:"text chunk" — text delta
80
+ * 9:{...} — tool call
81
+ * a:{...} — tool result
82
+ * e:{...} — step finish
83
+ * d:{...} — finish
84
+ * 3:"error message" — error
85
+ */
86
+ function parseLine(line) {
87
+ // Format: TYPE_CODE:JSON_VALUE
88
+ const colonIdx = line.indexOf(":");
89
+ if (colonIdx < 1)
90
+ return null;
91
+ const code = line.slice(0, colonIdx);
92
+ const payload = line.slice(colonIdx + 1);
93
+ try {
94
+ switch (code) {
95
+ case "0": {
96
+ // Text delta — payload is a JSON string
97
+ const text = JSON.parse(payload);
98
+ return { type: "text-delta", text };
99
+ }
100
+ case "9": {
101
+ // Tool call
102
+ const data = JSON.parse(payload);
103
+ return {
104
+ type: "tool-call",
105
+ toolName: data.toolName ?? "unknown",
106
+ args: data.args ?? {},
107
+ };
108
+ }
109
+ case "a": {
110
+ // Tool result
111
+ const data = JSON.parse(payload);
112
+ return {
113
+ type: "tool-result",
114
+ toolName: data.toolName ?? "unknown",
115
+ result: data.result,
116
+ };
117
+ }
118
+ case "e": {
119
+ // Step finish
120
+ return { type: "step-finish" };
121
+ }
122
+ case "d": {
123
+ // Finish
124
+ const data = JSON.parse(payload);
125
+ return { type: "finish", messages: data.messages ?? [] };
126
+ }
127
+ case "3": {
128
+ // Error
129
+ const error = JSON.parse(payload);
130
+ return { type: "error", error };
131
+ }
132
+ default:
133
+ return { type: "unknown", raw: line };
134
+ }
135
+ }
136
+ catch {
137
+ return { type: "unknown", raw: line };
138
+ }
139
+ }
140
+ //# sourceMappingURL=stream.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.js","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IACJ,QAAQ,CAAW;IAEpC,YAAY,QAAkB;QAC5B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QAChC,IAAI,CAAC,IAAI;YAAE,OAAO;QAElB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,IAAI,MAAM,GAAG,EAAE,CAAC;QAEhB,IAAI,CAAC;YACH,OAAO,IAAI,EAAE,CAAC;gBACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5C,IAAI,IAAI;oBAAE,MAAM;gBAEhB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;gBAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjC,8CAA8C;gBAC9C,MAAM,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC;gBAE3B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;oBAC5B,IAAI,CAAC,OAAO;wBAAE,SAAS;oBAEvB,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;oBACjC,IAA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,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QAC1C,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;AACH,CAAC"}
@@ -0,0 +1,148 @@
1
+ export interface OperatorOptions {
2
+ /** Chat API key (ck_live_... or ck_dev_...) */
3
+ apiKey: string;
4
+ /** Base URL of the Operator app (defaults to https://www.operator.io) */
5
+ baseUrl?: string;
6
+ }
7
+ export interface HealthResponse {
8
+ authenticated: boolean;
9
+ userId?: string;
10
+ email?: string;
11
+ planSlug?: string | null;
12
+ planName?: string | null;
13
+ hasPlan?: boolean;
14
+ tokenLimit?: number;
15
+ error?: string;
16
+ }
17
+ export interface Chat {
18
+ id: string;
19
+ userId: string;
20
+ title: string;
21
+ automationId?: string | null;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ }
25
+ export interface ChatMessage {
26
+ id: string;
27
+ role: "user" | "assistant" | "system";
28
+ content: string;
29
+ parts: MessagePart[];
30
+ createdAt: string;
31
+ }
32
+ export interface MessagePart {
33
+ type: string;
34
+ text?: string;
35
+ [key: string]: unknown;
36
+ }
37
+ export interface ChatDetail {
38
+ chat: Chat;
39
+ messages: ChatMessage[];
40
+ }
41
+ export interface SendMessageOptions {
42
+ /** Existing chat ID to continue a conversation */
43
+ chatId?: string;
44
+ }
45
+ export interface SendMessageResponse {
46
+ /** The chat ID (new or existing) */
47
+ chatId: string;
48
+ /** The full text response from the AI */
49
+ text: string;
50
+ }
51
+ export type StreamEvent = {
52
+ type: "text-delta";
53
+ text: string;
54
+ } | {
55
+ type: "tool-call";
56
+ toolName: string;
57
+ args: Record<string, unknown>;
58
+ } | {
59
+ type: "tool-result";
60
+ toolName: string;
61
+ result: unknown;
62
+ } | {
63
+ type: "step-finish";
64
+ } | {
65
+ type: "finish";
66
+ messages: unknown[];
67
+ } | {
68
+ type: "error";
69
+ error: string;
70
+ } | {
71
+ type: "unknown";
72
+ raw: string;
73
+ };
74
+ export interface Instance {
75
+ id: string;
76
+ userId: string;
77
+ name: string;
78
+ status: string;
79
+ imageTag?: string | null;
80
+ azureServerName?: string | null;
81
+ allowUserConfig?: boolean;
82
+ config?: Record<string, unknown> | null;
83
+ checkpoint?: Record<string, unknown> | null;
84
+ createdAt: string;
85
+ updatedAt?: string;
86
+ }
87
+ export interface CreateInstanceOptions {
88
+ name: string;
89
+ checkpointRepo?: string;
90
+ }
91
+ export interface LogEntry {
92
+ timestamp: string;
93
+ message: string;
94
+ }
95
+ export interface Automation {
96
+ id: string;
97
+ userId: string;
98
+ name: string;
99
+ prompt: string;
100
+ cronExpression: string;
101
+ timezone: string;
102
+ enabled: boolean;
103
+ triggerScheduleId?: string | null;
104
+ chatId?: string | null;
105
+ lastRunAt?: string | null;
106
+ createdAt: string;
107
+ updatedAt?: string;
108
+ }
109
+ export interface CreateAutomationOptions {
110
+ name: string;
111
+ prompt: string;
112
+ cronExpression: string;
113
+ timezone?: string;
114
+ }
115
+ export interface UpdateAutomationOptions {
116
+ name?: string;
117
+ prompt?: string;
118
+ cronExpression?: string;
119
+ timezone?: string;
120
+ enabled?: boolean;
121
+ }
122
+ export interface Webhook {
123
+ id: string;
124
+ userId: string;
125
+ name: string;
126
+ promptTemplate: string;
127
+ enabled: boolean;
128
+ token: string;
129
+ triggerUrl?: string;
130
+ lastTriggeredAt?: string | null;
131
+ createdAt: string;
132
+ updatedAt?: string;
133
+ }
134
+ export interface CreateWebhookOptions {
135
+ name: string;
136
+ promptTemplate: string;
137
+ }
138
+ export interface UpdateWebhookOptions {
139
+ name?: string;
140
+ promptTemplate?: string;
141
+ enabled?: boolean;
142
+ }
143
+ export declare class OperatorApiError extends Error {
144
+ readonly status: number;
145
+ readonly body?: unknown | undefined;
146
+ constructor(message: string, status: number, body?: unknown | undefined);
147
+ }
148
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+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EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAID,qBAAa,gBAAiB,SAAQ,KAAK;aAGvB,MAAM,EAAE,MAAM;aACd,IAAI,CAAC,EAAE,OAAO;gBAF9B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,OAAO,YAAA;CAKjC"}
package/dist/types.js ADDED
@@ -0,0 +1,13 @@
1
+ // ─── Client Options ──────────────────────────────────────
2
+ // ─── API Error ───────────────────────────────────────────
3
+ export class OperatorApiError extends Error {
4
+ status;
5
+ body;
6
+ constructor(message, status, body) {
7
+ super(message);
8
+ this.status = status;
9
+ this.body = body;
10
+ this.name = "OperatorApiError";
11
+ }
12
+ }
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AA+J5D,4DAA4D;AAE5D,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAGvB;IACA;IAHlB,YACE,OAAe,EACC,MAAc,EACd,IAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@operator-labs/sdk",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the Operator platform — manage agents, chat, instances, automations, and webhooks programmatically.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsc --watch",
22
+ "clean": "rm -rf dist",
23
+ "test": "tsx tests/integration.test.ts"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.19.15",
27
+ "dotenv": "^16.4.5",
28
+ "tsx": "^4.19.0",
29
+ "typescript": "^5.9.3"
30
+ },
31
+ "engines": {
32
+ "node": ">=18"
33
+ },
34
+ "keywords": [
35
+ "operator",
36
+ "openclaw",
37
+ "sdk",
38
+ "ai",
39
+ "agents"
40
+ ]
41
+ }