@meshagent/meshagent 0.36.2 → 0.37.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/browser/agent-client.d.ts +2 -10
  3. package/dist/browser/agent-client.js +2 -30
  4. package/dist/browser/agent.d.ts +22 -22
  5. package/dist/browser/agent.js +36 -16
  6. package/dist/browser/containers-client.d.ts +7 -19
  7. package/dist/browser/containers-client.js +27 -21
  8. package/dist/browser/data-types.d.ts +12 -0
  9. package/dist/browser/data-types.js +39 -1
  10. package/dist/browser/database-client.d.ts +134 -47
  11. package/dist/browser/database-client.js +359 -133
  12. package/dist/browser/entrypoint.js +3 -3
  13. package/dist/browser/index.d.ts +1 -0
  14. package/dist/browser/index.js +1 -0
  15. package/dist/browser/meshagent-client.js +18 -5
  16. package/dist/browser/participant-token.d.ts +189 -22
  17. package/dist/browser/participant-token.js +1001 -189
  18. package/dist/browser/room-client.d.ts +1 -1
  19. package/dist/browser/room-event.d.ts +12 -0
  20. package/dist/browser/room-event.js +16 -1
  21. package/dist/browser/secrets-client.d.ts +5 -0
  22. package/dist/browser/secrets-client.js +11 -0
  23. package/dist/browser/services-client.d.ts +1 -1
  24. package/dist/browser/storage-client.d.ts +4 -0
  25. package/dist/browser/storage-client.js +18 -0
  26. package/dist/browser/version.d.ts +1 -0
  27. package/dist/browser/version.js +4 -0
  28. package/dist/esm/agent-client.d.ts +2 -10
  29. package/dist/esm/agent-client.js +1 -28
  30. package/dist/esm/agent.d.ts +22 -22
  31. package/dist/esm/agent.js +33 -14
  32. package/dist/esm/containers-client.d.ts +7 -19
  33. package/dist/esm/containers-client.js +27 -21
  34. package/dist/esm/data-types.d.ts +12 -0
  35. package/dist/esm/data-types.js +36 -0
  36. package/dist/esm/database-client.d.ts +134 -47
  37. package/dist/esm/database-client.js +352 -132
  38. package/dist/esm/index.d.ts +1 -0
  39. package/dist/esm/index.js +1 -0
  40. package/dist/esm/meshagent-client.js +18 -5
  41. package/dist/esm/participant-token.d.ts +189 -22
  42. package/dist/esm/participant-token.js +992 -188
  43. package/dist/esm/room-client.d.ts +1 -1
  44. package/dist/esm/room-event.d.ts +12 -0
  45. package/dist/esm/room-event.js +14 -0
  46. package/dist/esm/secrets-client.d.ts +5 -0
  47. package/dist/esm/secrets-client.js +11 -0
  48. package/dist/esm/services-client.d.ts +1 -1
  49. package/dist/esm/storage-client.d.ts +4 -0
  50. package/dist/esm/storage-client.js +19 -1
  51. package/dist/esm/version.d.ts +1 -0
  52. package/dist/esm/version.js +1 -0
  53. package/dist/node/agent-client.d.ts +2 -10
  54. package/dist/node/agent-client.js +2 -30
  55. package/dist/node/agent.d.ts +22 -22
  56. package/dist/node/agent.js +36 -16
  57. package/dist/node/containers-client.d.ts +7 -19
  58. package/dist/node/containers-client.js +27 -21
  59. package/dist/node/data-types.d.ts +12 -0
  60. package/dist/node/data-types.js +39 -1
  61. package/dist/node/database-client.d.ts +134 -47
  62. package/dist/node/database-client.js +359 -133
  63. package/dist/node/index.d.ts +1 -0
  64. package/dist/node/index.js +1 -0
  65. package/dist/node/meshagent-client.js +18 -5
  66. package/dist/node/participant-token.d.ts +189 -22
  67. package/dist/node/participant-token.js +1001 -189
  68. package/dist/node/room-client.d.ts +1 -1
  69. package/dist/node/room-event.d.ts +12 -0
  70. package/dist/node/room-event.js +16 -1
  71. package/dist/node/secrets-client.d.ts +5 -0
  72. package/dist/node/secrets-client.js +11 -0
  73. package/dist/node/services-client.d.ts +1 -1
  74. package/dist/node/storage-client.d.ts +4 -0
  75. package/dist/node/storage-client.js +18 -0
  76. package/dist/node/version.d.ts +1 -0
  77. package/dist/node/version.js +4 -0
  78. package/package.json +3 -3
@@ -12,7 +12,7 @@ import { ContainersClient } from "./containers-client";
12
12
  import { MemoryClient } from "./memory-client";
13
13
  import { ServicesClient } from "./services-client";
14
14
  import { RoomEvent } from "./room-event";
15
- import { Content } from "./response";
15
+ import { type Content } from "./response";
16
16
  interface RequestHeader {
17
17
  [key: string]: any;
18
18
  }
@@ -52,6 +52,18 @@ export declare class FileUpdatedEvent extends RoomEvent {
52
52
  get name(): string;
53
53
  get description(): string;
54
54
  }
55
+ export declare class FileMovedEvent extends RoomEvent {
56
+ sourcePath: string;
57
+ destinationPath: string;
58
+ participantId: string;
59
+ constructor({ sourcePath, destinationPath, participantId, }: {
60
+ sourcePath: string;
61
+ destinationPath: string;
62
+ participantId: string;
63
+ });
64
+ get name(): string;
65
+ get description(): string;
66
+ }
55
67
  export declare class RoomLogEvent extends RoomEvent {
56
68
  type: string;
57
69
  data: Record<string, any>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RoomLogEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomEvent = void 0;
3
+ exports.RoomLogEvent = exports.FileMovedEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomEvent = void 0;
4
4
  class RoomEvent {
5
5
  }
6
6
  exports.RoomEvent = RoomEvent;
@@ -68,6 +68,21 @@ class FileUpdatedEvent extends RoomEvent {
68
68
  }
69
69
  }
70
70
  exports.FileUpdatedEvent = FileUpdatedEvent;
71
+ class FileMovedEvent extends RoomEvent {
72
+ constructor({ sourcePath, destinationPath, participantId, }) {
73
+ super();
74
+ this.sourcePath = sourcePath;
75
+ this.destinationPath = destinationPath;
76
+ this.participantId = participantId;
77
+ }
78
+ get name() {
79
+ return "file moved";
80
+ }
81
+ get description() {
82
+ return `a file was moved from ${this.sourcePath} to ${this.destinationPath}`;
83
+ }
84
+ }
85
+ exports.FileMovedEvent = FileMovedEvent;
71
86
  class RoomLogEvent extends RoomEvent {
72
87
  constructor({ type, data }) {
73
88
  super();
@@ -73,6 +73,11 @@ export declare class SecretsClient {
73
73
  delegateTo?: string | null;
74
74
  }): Promise<string | null>;
75
75
  listSecrets(): Promise<SecretInfo[]>;
76
+ exists({ secretId, delegatedTo, forIdentity, }: {
77
+ secretId: string;
78
+ delegatedTo?: string | null;
79
+ forIdentity?: string | null;
80
+ }): Promise<boolean>;
76
81
  deleteSecret({ secretId, delegatedTo, }: {
77
82
  secretId: string;
78
83
  delegatedTo?: string | null;
@@ -215,6 +215,17 @@ class SecretsClient {
215
215
  }
216
216
  return secrets.map((item) => this.parseSecretInfo(item));
217
217
  }
218
+ async exists({ secretId, delegatedTo, forIdentity, }) {
219
+ const response = await this.invoke("exists", {
220
+ secret_id: secretId,
221
+ delegated_to: delegatedTo ?? null,
222
+ for_identity: forIdentity ?? null,
223
+ });
224
+ if (!(response instanceof response_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
225
+ throw this.unexpectedResponse("exists");
226
+ }
227
+ return response.json["exists"];
228
+ }
218
229
  async deleteSecret({ secretId, delegatedTo, }) {
219
230
  const response = await this.invoke("delete_secret", {
220
231
  id: secretId,
@@ -1,4 +1,4 @@
1
- import { ServiceSpec } from "./meshagent-client";
1
+ import type { ServiceSpec } from "./meshagent-client";
2
2
  import { RoomClient } from "./room-client";
3
3
  export interface ServiceRuntimeState {
4
4
  serviceId: string;
@@ -34,6 +34,7 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
34
34
  });
35
35
  private _handleFileUpdated;
36
36
  private _handleFileDeleted;
37
+ private _handleFileMoved;
37
38
  private _unexpectedResponseError;
38
39
  private _storageEntry;
39
40
  private _invoke;
@@ -42,6 +43,9 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
42
43
  delete(path: string, { recursive, }?: {
43
44
  recursive?: boolean | null;
44
45
  }): Promise<void>;
46
+ move(sourcePath: string, destinationPath: string, { overwrite, }?: {
47
+ overwrite?: boolean;
48
+ }): Promise<void>;
45
49
  exists(path: string): Promise<boolean>;
46
50
  private _defaultUploadName;
47
51
  private _defaultUploadMimeType;
@@ -85,6 +85,7 @@ class StorageClient extends event_emitter_1.EventEmitter {
85
85
  super();
86
86
  this.client = room;
87
87
  this.client.protocol.addHandler("storage.file.deleted", this._handleFileDeleted.bind(this));
88
+ this.client.protocol.addHandler("storage.file.moved", this._handleFileMoved.bind(this));
88
89
  this.client.protocol.addHandler("storage.file.updated", this._handleFileUpdated.bind(this));
89
90
  }
90
91
  async _handleFileUpdated(protocol, messageId, type, bytes) {
@@ -99,6 +100,16 @@ class StorageClient extends event_emitter_1.EventEmitter {
99
100
  this.client.emit(event);
100
101
  this.emit('file.deleted', event);
101
102
  }
103
+ async _handleFileMoved(protocol, messageId, type, bytes) {
104
+ const [data, _] = (0, utils_1.unpackMessage)(bytes || new Uint8Array());
105
+ const event = new room_event_1.FileMovedEvent({
106
+ sourcePath: data["source_path"],
107
+ destinationPath: data["destination_path"],
108
+ participantId: data["participant_id"],
109
+ });
110
+ this.client.emit(event);
111
+ this.emit("file.moved", event);
112
+ }
102
113
  _unexpectedResponseError(operation) {
103
114
  return _unexpectedStorageResponseError(operation);
104
115
  }
@@ -147,6 +158,13 @@ class StorageClient extends event_emitter_1.EventEmitter {
147
158
  async delete(path, { recursive = null, } = {}) {
148
159
  await this._invoke("delete", { path, recursive });
149
160
  }
161
+ async move(sourcePath, destinationPath, { overwrite = false, } = {}) {
162
+ await this._invoke("move", {
163
+ source_path: sourcePath,
164
+ destination_path: destinationPath,
165
+ overwrite,
166
+ });
167
+ }
150
168
  async exists(path) {
151
169
  const result = await this._invoke("exists", { path });
152
170
  if (!(result instanceof response_1.JsonContent)) {
@@ -0,0 +1 @@
1
+ export declare const __version__ = "0.36.3";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__version__ = void 0;
4
+ exports.__version__ = "0.36.3";
@@ -1,5 +1,5 @@
1
1
  import { RoomClient } from "./room-client";
2
- import { Content } from "./response";
2
+ import type { Content } from "./response";
3
3
  import { ToolContentSpec } from "./tool-content-type";
4
4
  export declare class ToolDescription {
5
5
  title: string;
@@ -10,8 +10,7 @@ export declare class ToolDescription {
10
10
  defs?: Record<string, any>;
11
11
  thumbnailUrl?: string;
12
12
  pricing?: string;
13
- supportsContext?: boolean;
14
- constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing, supportsContext }: {
13
+ constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing }: {
15
14
  title: string;
16
15
  name: string;
17
16
  description: string;
@@ -22,7 +21,6 @@ export declare class ToolDescription {
22
21
  thumbnailUrl?: string;
23
22
  defs?: Record<string, any>;
24
23
  pricing?: string;
25
- supportsContext?: boolean;
26
24
  });
27
25
  get inputSchema(): Record<string, any> | undefined;
28
26
  get outputSchema(): Record<string, any> | undefined;
@@ -49,12 +47,6 @@ export declare class ToolkitDescription {
49
47
  name?: string;
50
48
  }): ToolkitDescription;
51
49
  }
52
- export declare class ToolkitConfiguration {
53
- name: string;
54
- use?: string[] | undefined;
55
- constructor(name: string, use?: string[] | undefined);
56
- toJson(): Record<string, any>;
57
- }
58
50
  export declare class AgentsClient {
59
51
  private client;
60
52
  constructor({ room }: {
@@ -1,6 +1,6 @@
1
1
  import { ToolContentSpec } from "./tool-content-type";
2
2
  export class ToolDescription {
3
- constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing, supportsContext }) {
3
+ constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, thumbnailUrl, defs, pricing }) {
4
4
  this.title = title;
5
5
  this.name = name;
6
6
  this.description = description;
@@ -41,7 +41,6 @@ export class ToolDescription {
41
41
  this.thumbnailUrl = thumbnailUrl;
42
42
  this.defs = defs;
43
43
  this.pricing = pricing;
44
- this.supportsContext = supportsContext ?? false;
45
44
  }
46
45
  get inputSchema() {
47
46
  return this.inputSpec?.schema;
@@ -81,7 +80,6 @@ export class ToolkitDescription {
81
80
  thumbnail_url: tool.thumbnailUrl,
82
81
  defs: tool.defs,
83
82
  pricing: tool.pricing,
84
- supports_context: tool.supportsContext,
85
83
  })),
86
84
  };
87
85
  }
@@ -106,7 +104,6 @@ export class ToolkitDescription {
106
104
  thumbnailUrl: tool["thumbnail_url"],
107
105
  defs: tool["defs"],
108
106
  pricing: tool["pricing"],
109
- supportsContext: tool["supports_context"] ?? tool["supportsContext"],
110
107
  }));
111
108
  }
112
109
  }
@@ -125,7 +122,6 @@ export class ToolkitDescription {
125
122
  thumbnailUrl: tool["thumbnail_url"],
126
123
  defs: tool["defs"],
127
124
  pricing: tool["pricing"],
128
- supportsContext: tool["supports_context"] ?? tool["supportsContext"],
129
125
  }));
130
126
  }
131
127
  }
@@ -139,29 +135,6 @@ export class ToolkitDescription {
139
135
  });
140
136
  }
141
137
  }
142
- export class ToolkitConfiguration {
143
- constructor(name, use) {
144
- this.name = name;
145
- this.use = use;
146
- }
147
- toJson() {
148
- if (!this.use) {
149
- return {
150
- [this.name]: {},
151
- };
152
- }
153
- else {
154
- return {
155
- [this.name]: {
156
- use: this.use.reduce((acc, tool) => {
157
- acc[tool] = {};
158
- return acc;
159
- }, {}),
160
- },
161
- };
162
- }
163
- }
164
- }
165
138
  export class AgentsClient {
166
139
  constructor({ room }) {
167
140
  this.client = room;
@@ -1,6 +1,6 @@
1
1
  import { RoomClient } from "./room-client";
2
2
  import { RequiredToolkit } from "./requirement";
3
- import { Content } from "./response";
3
+ import { type Content } from "./response";
4
4
  import { ToolContentSpec } from "./tool-content-type";
5
5
  export declare abstract class Tool {
6
6
  readonly name: string;
@@ -23,10 +23,18 @@ export declare abstract class Tool {
23
23
  get outputSchema(): Record<string, any> | undefined;
24
24
  abstract execute(arguments_: Record<string, any>): Promise<Content>;
25
25
  }
26
- export declare abstract class Toolkit {
26
+ export declare class Toolkit {
27
+ readonly name: string;
28
+ readonly title: string;
29
+ readonly description: string;
30
+ readonly thumbnailUrl?: string;
27
31
  readonly tools: Tool[];
28
32
  readonly rules: string[];
29
- constructor({ tools, rules }: {
33
+ constructor({ name, title, description, thumbnailUrl, tools, rules }: {
34
+ name: string;
35
+ title?: string;
36
+ description?: string;
37
+ thumbnailUrl?: string;
30
38
  tools: Tool[];
31
39
  rules?: string[];
32
40
  });
@@ -34,28 +42,20 @@ export declare abstract class Toolkit {
34
42
  getTools(): Record<string, any>;
35
43
  execute(name: string, args: Record<string, any>): Promise<Content>;
36
44
  }
37
- export declare abstract class RemoteToolkit extends Toolkit {
38
- protected readonly client: RoomClient;
39
- protected readonly name: string;
40
- protected readonly title: string;
41
- protected readonly description: string;
42
- private _registrationId?;
43
- constructor({ name, title, description, room, tools, rules }: {
44
- name: string;
45
- title: string;
46
- description: string;
47
- room: RoomClient;
48
- tools: Tool[];
49
- rules?: string[];
45
+ export declare class HostedToolkit {
46
+ readonly toolkit: Toolkit;
47
+ private readonly _stopHostedToolkit;
48
+ constructor({ toolkit, stopHostedToolkit }: {
49
+ toolkit: Toolkit;
50
+ stopHostedToolkit: () => Promise<void>;
50
51
  });
51
- start({ public_: isPublic }?: {
52
- public_?: boolean;
53
- }): Promise<void>;
54
52
  stop(): Promise<void>;
55
- private _register;
56
- private _unregister;
57
- private _toolCall;
58
53
  }
54
+ export declare function startHostedToolkit({ room, toolkit, public_: isPublic }: {
55
+ room: RoomClient;
56
+ toolkit: Toolkit;
57
+ public_?: boolean;
58
+ }): Promise<HostedToolkit>;
59
59
  export declare abstract class RemoteTaskRunner {
60
60
  protected readonly client: RoomClient;
61
61
  protected readonly name: string;
package/dist/esm/agent.js CHANGED
@@ -50,7 +50,11 @@ export class Tool {
50
50
  }
51
51
  }
52
52
  export class Toolkit {
53
- constructor({ tools, rules = [] }) {
53
+ constructor({ name, title = name, description = "", thumbnailUrl, tools, rules = [] }) {
54
+ this.name = name;
55
+ this.title = title;
56
+ this.description = description;
57
+ this.thumbnailUrl = thumbnailUrl;
54
58
  this.tools = tools;
55
59
  this.rules = rules;
56
60
  }
@@ -78,30 +82,37 @@ export class Toolkit {
78
82
  return this.getTool(name).execute(args);
79
83
  }
80
84
  }
81
- export class RemoteToolkit extends Toolkit {
82
- constructor({ name, title, description, room, tools, rules = [] }) {
83
- super({ tools, rules });
85
+ export class HostedToolkit {
86
+ constructor({ toolkit, stopHostedToolkit }) {
87
+ this.toolkit = toolkit;
88
+ this._stopHostedToolkit = stopHostedToolkit;
89
+ }
90
+ async stop() {
91
+ await this._stopHostedToolkit();
92
+ }
93
+ }
94
+ class _RemoteToolkitWrapper {
95
+ constructor({ toolkit, room }) {
96
+ this.toolkit = toolkit;
84
97
  this.client = room;
85
- this.name = name;
86
- this.title = title;
87
- this.description = description;
88
98
  }
89
99
  async start({ public_: isPublic = false } = {}) {
90
100
  const handler = this._toolCall.bind(this);
91
- this.client.protocol.addHandler(`room.tool_call.${this.name}`, handler);
101
+ this.client.protocol.addHandler(`room.tool_call.${this.toolkit.name}`, handler);
92
102
  await this._register(isPublic);
93
103
  }
94
104
  async stop() {
95
105
  await this._unregister();
96
- this.client.protocol.removeHandler(`room.tool_call.${this.name}`);
106
+ this.client.protocol.removeHandler(`room.tool_call.${this.toolkit.name}`);
97
107
  }
98
108
  async _register(public_) {
99
109
  const response = await this.client.sendRequest("room.register_toolkit", {
100
- name: this.name,
101
- title: this.title,
102
- description: this.description,
103
- tools: this.getTools(),
110
+ name: this.toolkit.name,
111
+ title: this.toolkit.title,
112
+ description: this.toolkit.description,
113
+ tools: this.toolkit.getTools(),
104
114
  public: public_,
115
+ thumbnail_url: this.toolkit.thumbnailUrl,
105
116
  });
106
117
  const json = response.json;
107
118
  this._registrationId = json["id"];
@@ -138,7 +149,7 @@ export class RemoteToolkit extends Toolkit {
138
149
  else {
139
150
  args = rawArguments ?? {};
140
151
  }
141
- const response = await this.execute(toolName, args);
152
+ const response = await this.toolkit.execute(toolName, args);
142
153
  await this.client.protocol.send("room.tool_call_response", response.pack(), messageId);
143
154
  }
144
155
  catch (e) {
@@ -147,6 +158,14 @@ export class RemoteToolkit extends Toolkit {
147
158
  }
148
159
  }
149
160
  }
161
+ export async function startHostedToolkit({ room, toolkit, public_: isPublic = false }) {
162
+ const wrapper = new _RemoteToolkitWrapper({ toolkit, room });
163
+ await wrapper.start({ public_: isPublic });
164
+ return new HostedToolkit({
165
+ toolkit,
166
+ stopHostedToolkit: () => wrapper.stop(),
167
+ });
168
+ }
150
169
  export class RemoteTaskRunner {
151
170
  constructor({ name, description, client, inputSchema, outputSchema, supportsTools = false, required = [], }) {
152
171
  this.client = client;
@@ -1,5 +1,5 @@
1
- import { ContainerMountSpec } from "./meshagent-client";
2
- import { Content } from "./response";
1
+ import type { ContainerMountSpec } from "./meshagent-client";
2
+ import { type Content } from "./response";
3
3
  import { RoomClient } from "./room-client";
4
4
  export interface DockerSecret {
5
5
  username: string;
@@ -138,29 +138,17 @@ export declare class ContainersClient {
138
138
  writableRootFs?: boolean;
139
139
  private?: boolean;
140
140
  }): Promise<string>;
141
- startBuild(params: {
142
- tag: string;
143
- mounts: ContainerMountSpec[];
144
- contextPath: string;
145
- dockerfilePath?: string;
146
- private?: boolean;
147
- credentials?: DockerSecret[];
148
- contextArchivePath?: string;
149
- contextArchiveRef?: string;
150
- contextArchiveMountPath?: string;
151
- contextArchiveArch?: string;
152
- }): Promise<string>;
153
141
  build(params: {
154
142
  tag: string;
155
- mounts: ContainerMountSpec[];
143
+ mountPath: string;
156
144
  contextPath: string;
145
+ chunks: AsyncIterable<Uint8Array>;
157
146
  dockerfilePath?: string;
147
+ optimizeImage?: boolean;
158
148
  private?: boolean;
159
149
  credentials?: DockerSecret[];
160
- contextArchivePath?: string;
161
- contextArchiveRef?: string;
162
- contextArchiveMountPath?: string;
163
- contextArchiveArch?: string;
150
+ builderName?: string;
151
+ size?: number;
164
152
  }): Promise<string>;
165
153
  listBuilds(): Promise<BuildJob[]>;
166
154
  cancelBuild(params: {
@@ -131,19 +131,28 @@ function parseBuildJob(data, operation) {
131
131
  exitCode: readOptionalIntegerField(data, "exit_code", operation),
132
132
  };
133
133
  }
134
- function buildRequestPayload(params) {
135
- return {
136
- tag: params.tag,
137
- mounts: toMountList(params.mounts),
138
- context_path: params.contextPath,
139
- dockerfile_path: params.dockerfilePath ?? null,
140
- private: params.private ?? false,
141
- credentials: toCredentials(params.credentials ?? []),
142
- context_archive_path: params.contextArchivePath ?? null,
143
- context_archive_ref: params.contextArchiveRef ?? null,
144
- context_archive_mount_path: params.contextArchiveMountPath ?? null,
145
- context_archive_arch: params.contextArchiveArch ?? null,
146
- };
134
+ async function* buildInputStream(params) {
135
+ yield new BinaryContent({
136
+ data: new Uint8Array(0),
137
+ headers: {
138
+ kind: "start",
139
+ tag: params.tag,
140
+ mount_path: params.mountPath,
141
+ context_path: params.contextPath,
142
+ dockerfile_path: params.dockerfilePath ?? null,
143
+ optimize_image: params.optimizeImage ?? true,
144
+ private: params.private ?? false,
145
+ credentials: toCredentials(params.credentials ?? []),
146
+ builder_name: params.builderName ?? null,
147
+ size: params.size ?? null,
148
+ },
149
+ });
150
+ for await (const chunk of params.chunks) {
151
+ yield new BinaryContent({
152
+ data: new Uint8Array(chunk),
153
+ headers: { kind: "data" },
154
+ });
155
+ }
147
156
  }
148
157
  export class ExecSession {
149
158
  constructor(params) {
@@ -383,15 +392,12 @@ export class ContainersClient {
383
392
  }
384
393
  return readStringField(output.json, "container_id", "run");
385
394
  }
386
- async startBuild(params) {
387
- const output = await this.invoke("start_build", buildRequestPayload(params));
388
- if (!(output instanceof JsonContent) || !isRecord(output.json)) {
389
- throw this.unexpectedResponseError("start_build");
390
- }
391
- return readStringField(output.json, "build_id", "start_build");
392
- }
393
395
  async build(params) {
394
- const output = await this.invoke("build", buildRequestPayload(params));
396
+ const output = await this.room.invokeWithStreamInput({
397
+ toolkit: "containers",
398
+ tool: "build",
399
+ input: buildInputStream(params),
400
+ });
395
401
  if (!(output instanceof JsonContent) || !isRecord(output.json)) {
396
402
  throw this.unexpectedResponseError("build");
397
403
  }
@@ -11,6 +11,8 @@ export declare abstract class DataType {
11
11
  elementType: DataType;
12
12
  }): VectorDataType;
13
13
  static text(): TextDataType;
14
+ static json(): JsonDataType;
15
+ static uuid(): UuidDataType;
14
16
  static binary(): BinaryDataType;
15
17
  }
16
18
  export declare class BoolDataType extends DataType {
@@ -48,6 +50,16 @@ export declare class TextDataType extends DataType {
48
50
  static fromJson(data: any): TextDataType;
49
51
  toJson(): Record<string, unknown>;
50
52
  }
53
+ export declare class JsonDataType extends DataType {
54
+ constructor();
55
+ static fromJson(data: any): JsonDataType;
56
+ toJson(): Record<string, unknown>;
57
+ }
58
+ export declare class UuidDataType extends DataType {
59
+ constructor();
60
+ static fromJson(data: any): UuidDataType;
61
+ toJson(): Record<string, unknown>;
62
+ }
51
63
  export declare class BinaryDataType extends DataType {
52
64
  constructor();
53
65
  static fromJson(data: any): BinaryDataType;
@@ -23,6 +23,12 @@ export class DataType {
23
23
  static text() {
24
24
  return new TextDataType();
25
25
  }
26
+ static json() {
27
+ return new JsonDataType();
28
+ }
29
+ static uuid() {
30
+ return new UuidDataType();
31
+ }
26
32
  static binary() {
27
33
  return new BinaryDataType();
28
34
  }
@@ -126,6 +132,36 @@ export class TextDataType extends DataType {
126
132
  }
127
133
  }
128
134
  _dataTypes["text"] = TextDataType;
135
+ export class JsonDataType extends DataType {
136
+ constructor() {
137
+ super();
138
+ }
139
+ static fromJson(data) {
140
+ if (data.type !== "json") {
141
+ throw new Error(`Expected type 'json', got '${data.type}'`);
142
+ }
143
+ return new JsonDataType();
144
+ }
145
+ toJson() {
146
+ return { type: "json" };
147
+ }
148
+ }
149
+ _dataTypes["json"] = JsonDataType;
150
+ export class UuidDataType extends DataType {
151
+ constructor() {
152
+ super();
153
+ }
154
+ static fromJson(data) {
155
+ if (data.type !== "uuid") {
156
+ throw new Error(`Expected type 'uuid', got '${data.type}'`);
157
+ }
158
+ return new UuidDataType();
159
+ }
160
+ toJson() {
161
+ return { type: "uuid" };
162
+ }
163
+ }
164
+ _dataTypes["uuid"] = UuidDataType;
129
165
  export class BinaryDataType extends DataType {
130
166
  constructor() {
131
167
  super();