@meshagent/meshagent-ts-auth 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/browser/access-token-provider.d.ts +1 -1
- package/dist/browser/browser-global.d.ts +1 -1
- package/dist/browser/index.d.ts +7 -7
- package/dist/browser/ma-auth.global.js +735 -661
- package/dist/browser/mauth-response.d.ts +2 -2
- package/dist/browser/meshagent-auth.d.ts +1 -1
- package/dist/browser/oauth-session-manager.d.ts +1 -1
- package/dist/browser/pkce-generator.d.ts +1 -1
- package/dist/cjs/access-token-provider.d.ts +1 -1
- package/dist/cjs/access-token-provider.js +2 -2
- package/dist/cjs/browser-global.d.ts +1 -1
- package/dist/cjs/ensure-login.js +14 -14
- package/dist/cjs/index.d.ts +7 -7
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/mauth-response.d.ts +2 -2
- package/dist/cjs/mauth-response.js +6 -6
- package/dist/cjs/meshagent-auth.d.ts +1 -1
- package/dist/cjs/meshagent-auth.js +2 -2
- package/dist/cjs/oauth-session-manager.d.ts +1 -1
- package/dist/cjs/oauth-session-manager.js +2 -2
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/pkce-generator.d.ts +1 -1
- package/dist/cjs/pkce-generator.js +2 -2
- package/dist/esm/access-token-provider.d.ts +1 -1
- package/dist/esm/access-token-provider.js +1 -1
- package/dist/esm/browser-global.d.ts +1 -1
- package/dist/esm/ensure-login.js +5 -5
- package/dist/esm/index.d.ts +7 -7
- package/dist/esm/index.js +7 -7
- package/dist/esm/mauth-response.d.ts +2 -2
- package/dist/esm/mauth-response.js +3 -3
- package/dist/esm/meshagent-auth.d.ts +1 -1
- package/dist/esm/meshagent-auth.js +1 -1
- package/dist/esm/oauth-session-manager.d.ts +1 -1
- package/dist/esm/oauth-session-manager.js +1 -1
- package/dist/esm/pkce-generator.d.ts +1 -1
- package/dist/esm/pkce-generator.js +1 -1
- package/package.json +4 -4
|
@@ -2742,7 +2742,7 @@ meshagent.auth = (() => {
|
|
|
2742
2742
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2743
2743
|
exports.ControlContent = exports.ControlCloseStatus = exports.EmptyContent = exports.ErrorContent = exports.JsonContent = exports.TextContent = exports.FileContent = exports.LinkContent = exports.BinaryContent = void 0;
|
|
2744
2744
|
exports.unpackContent = unpackContent;
|
|
2745
|
-
var
|
|
2745
|
+
var utils_js_1 = require_utils();
|
|
2746
2746
|
var BinaryContent = class _BinaryContent {
|
|
2747
2747
|
constructor({ data, headers = {} }) {
|
|
2748
2748
|
this.data = data;
|
|
@@ -2755,7 +2755,7 @@ meshagent.auth = (() => {
|
|
|
2755
2755
|
});
|
|
2756
2756
|
}
|
|
2757
2757
|
pack() {
|
|
2758
|
-
return (0,
|
|
2758
|
+
return (0, utils_js_1.packMessage)({
|
|
2759
2759
|
type: "binary",
|
|
2760
2760
|
headers: this.headers
|
|
2761
2761
|
}, this.data);
|
|
@@ -2777,7 +2777,7 @@ meshagent.auth = (() => {
|
|
|
2777
2777
|
});
|
|
2778
2778
|
}
|
|
2779
2779
|
pack() {
|
|
2780
|
-
return (0,
|
|
2780
|
+
return (0, utils_js_1.packMessage)({
|
|
2781
2781
|
type: "link",
|
|
2782
2782
|
name: this.name,
|
|
2783
2783
|
url: this.url
|
|
@@ -2802,7 +2802,7 @@ meshagent.auth = (() => {
|
|
|
2802
2802
|
});
|
|
2803
2803
|
}
|
|
2804
2804
|
pack() {
|
|
2805
|
-
return (0,
|
|
2805
|
+
return (0, utils_js_1.packMessage)({
|
|
2806
2806
|
type: "file",
|
|
2807
2807
|
name: this.name,
|
|
2808
2808
|
mime_type: this.mimeType
|
|
@@ -2823,7 +2823,7 @@ meshagent.auth = (() => {
|
|
|
2823
2823
|
});
|
|
2824
2824
|
}
|
|
2825
2825
|
pack() {
|
|
2826
|
-
return (0,
|
|
2826
|
+
return (0, utils_js_1.packMessage)({
|
|
2827
2827
|
type: "text",
|
|
2828
2828
|
text: this.text
|
|
2829
2829
|
});
|
|
@@ -2841,7 +2841,7 @@ meshagent.auth = (() => {
|
|
|
2841
2841
|
return new _JsonContent({ json: header["json"] });
|
|
2842
2842
|
}
|
|
2843
2843
|
pack() {
|
|
2844
|
-
return (0,
|
|
2844
|
+
return (0, utils_js_1.packMessage)({
|
|
2845
2845
|
type: "json",
|
|
2846
2846
|
json: this.json
|
|
2847
2847
|
});
|
|
@@ -2877,7 +2877,7 @@ meshagent.auth = (() => {
|
|
|
2877
2877
|
if (this.code !== void 0) {
|
|
2878
2878
|
header["code"] = this.code;
|
|
2879
2879
|
}
|
|
2880
|
-
return (0,
|
|
2880
|
+
return (0, utils_js_1.packMessage)(header);
|
|
2881
2881
|
}
|
|
2882
2882
|
toString() {
|
|
2883
2883
|
return this.code !== void 0 ? `ErrorContent: ${this.text} (${this.code})` : `ErrorContent: ${this.text}`;
|
|
@@ -2889,7 +2889,7 @@ meshagent.auth = (() => {
|
|
|
2889
2889
|
return new _EmptyContent();
|
|
2890
2890
|
}
|
|
2891
2891
|
pack() {
|
|
2892
|
-
return (0,
|
|
2892
|
+
return (0, utils_js_1.packMessage)({ type: "empty" });
|
|
2893
2893
|
}
|
|
2894
2894
|
toString() {
|
|
2895
2895
|
return `EmptyContent`;
|
|
@@ -2939,7 +2939,7 @@ meshagent.auth = (() => {
|
|
|
2939
2939
|
header["message"] = this.message;
|
|
2940
2940
|
}
|
|
2941
2941
|
}
|
|
2942
|
-
return (0,
|
|
2942
|
+
return (0, utils_js_1.packMessage)(header);
|
|
2943
2943
|
}
|
|
2944
2944
|
toString() {
|
|
2945
2945
|
return `ControlContent: ${this.method}`;
|
|
@@ -2957,8 +2957,8 @@ meshagent.auth = (() => {
|
|
|
2957
2957
|
text: TextContent.unpack
|
|
2958
2958
|
};
|
|
2959
2959
|
function unpackContent(data) {
|
|
2960
|
-
const header = JSON.parse((0,
|
|
2961
|
-
const payload = (0,
|
|
2960
|
+
const header = JSON.parse((0, utils_js_1.splitMessageHeader)(data));
|
|
2961
|
+
const payload = (0, utils_js_1.splitMessagePayload)(data);
|
|
2962
2962
|
const typeKey = header["type"];
|
|
2963
2963
|
if (!_contentTypes[typeKey]) {
|
|
2964
2964
|
throw new Error(`Unknown content type: ${typeKey}`);
|
|
@@ -3699,8 +3699,8 @@ meshagent.auth = (() => {
|
|
|
3699
3699
|
exports.tagNameFromJson = tagNameFromJson;
|
|
3700
3700
|
exports.attributesFromJson = attributesFromJson;
|
|
3701
3701
|
var uuid_1 = (init_dist(), __toCommonJS(dist_exports));
|
|
3702
|
-
var
|
|
3703
|
-
var RuntimeDocument = class extends
|
|
3702
|
+
var event_emitter_js_1 = require_event_emitter();
|
|
3703
|
+
var RuntimeDocument = class extends event_emitter_js_1.EventEmitter {
|
|
3704
3704
|
constructor({ id, schema, sendChanges, sendChangesToBackend }) {
|
|
3705
3705
|
super();
|
|
3706
3706
|
this._changeSubscribers = [];
|
|
@@ -3937,7 +3937,7 @@ meshagent.auth = (() => {
|
|
|
3937
3937
|
}
|
|
3938
3938
|
};
|
|
3939
3939
|
exports.RuntimeDocument = RuntimeDocument;
|
|
3940
|
-
var Node = class extends
|
|
3940
|
+
var Node = class extends event_emitter_js_1.EventEmitter {
|
|
3941
3941
|
constructor({ parent, doc }) {
|
|
3942
3942
|
super();
|
|
3943
3943
|
this.parent = parent;
|
|
@@ -13728,9 +13728,9 @@ ${err.toString()}`);
|
|
|
13728
13728
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13729
13729
|
exports.MeshDocument = exports.RoomServerException = void 0;
|
|
13730
13730
|
var uuid_1 = (init_dist(), __toCommonJS(dist_exports));
|
|
13731
|
-
var
|
|
13732
|
-
var
|
|
13733
|
-
var
|
|
13731
|
+
var document_js_1 = require_document();
|
|
13732
|
+
var completer_js_1 = require_completer();
|
|
13733
|
+
var runtime_js_1 = require_runtime();
|
|
13734
13734
|
var RoomServerException = class extends Error {
|
|
13735
13735
|
constructor(message2, code, { statusCode, retryable = false } = {}) {
|
|
13736
13736
|
super(message2);
|
|
@@ -13741,15 +13741,15 @@ ${err.toString()}`);
|
|
|
13741
13741
|
}
|
|
13742
13742
|
};
|
|
13743
13743
|
exports.RoomServerException = RoomServerException;
|
|
13744
|
-
var MeshDocument = class extends
|
|
13744
|
+
var MeshDocument = class extends document_js_1.RuntimeDocument {
|
|
13745
13745
|
constructor({ schema, sendChangesToBackend }) {
|
|
13746
13746
|
super({
|
|
13747
13747
|
id: (0, uuid_1.v4)(),
|
|
13748
13748
|
schema,
|
|
13749
|
-
sendChanges: (base64) => (0,
|
|
13749
|
+
sendChanges: (base64) => (0, runtime_js_1.applyChanges)(base64),
|
|
13750
13750
|
sendChangesToBackend
|
|
13751
13751
|
});
|
|
13752
|
-
this._synchronized = new
|
|
13752
|
+
this._synchronized = new completer_js_1.Completer();
|
|
13753
13753
|
this.onSendUpdateToBackend = (base64) => {
|
|
13754
13754
|
const parsed = JSON.parse(base64);
|
|
13755
13755
|
if (this.sendChangesToBackend) {
|
|
@@ -13760,13 +13760,13 @@ ${err.toString()}`);
|
|
|
13760
13760
|
const parsed = JSON.parse(base64);
|
|
13761
13761
|
this.receiveChanges(parsed.data);
|
|
13762
13762
|
};
|
|
13763
|
-
(0,
|
|
13763
|
+
(0, runtime_js_1.registerDocument)(this.id, null, false, this.onSendUpdateToBackend, this.onSendUpdateToClient);
|
|
13764
13764
|
}
|
|
13765
13765
|
getState(vector) {
|
|
13766
|
-
return (0,
|
|
13766
|
+
return (0, runtime_js_1.getState)(this.id, vector ?? null);
|
|
13767
13767
|
}
|
|
13768
13768
|
getStateVector() {
|
|
13769
|
-
return (0,
|
|
13769
|
+
return (0, runtime_js_1.getStateVector)(this.id);
|
|
13770
13770
|
}
|
|
13771
13771
|
get synchronized() {
|
|
13772
13772
|
return this._synchronized.fut;
|
|
@@ -13779,7 +13779,7 @@ ${err.toString()}`);
|
|
|
13779
13779
|
}
|
|
13780
13780
|
dispose() {
|
|
13781
13781
|
super.dispose();
|
|
13782
|
-
(0,
|
|
13782
|
+
(0, runtime_js_1.unregisterDocument)(this.id);
|
|
13783
13783
|
}
|
|
13784
13784
|
};
|
|
13785
13785
|
exports.MeshDocument = MeshDocument;
|
|
@@ -14136,14 +14136,14 @@ ${err.toString()}`);
|
|
|
14136
14136
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14137
14137
|
exports.RemoteTaskRunner = exports.HostedToolkit = exports.Toolkit = exports.Tool = exports.ContentTool = exports.FunctionTool = exports.BaseTool = exports.ToolStreamOutput = exports.ToolContentOutput = exports.ToolCallOutput = exports.ToolStreamInput = exports.ToolContentInput = exports.ToolInput = exports.RoomToolContext = exports.ToolContext = exports.InvalidToolDataException = void 0;
|
|
14138
14138
|
exports.startHostedToolkit = startHostedToolkit;
|
|
14139
|
-
var
|
|
14140
|
-
var
|
|
14141
|
-
var
|
|
14142
|
-
var
|
|
14143
|
-
var
|
|
14144
|
-
var
|
|
14145
|
-
var
|
|
14146
|
-
var InvalidToolDataException = class extends
|
|
14139
|
+
var response_js_1 = require_response();
|
|
14140
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
14141
|
+
var tool_content_type_js_1 = require_tool_content_type();
|
|
14142
|
+
var utils_js_1 = require_utils();
|
|
14143
|
+
var room_event_js_1 = require_room_event();
|
|
14144
|
+
var participant_js_1 = require_participant();
|
|
14145
|
+
var stream_controller_js_1 = require_stream_controller();
|
|
14146
|
+
var InvalidToolDataException = class extends room_server_client_js_1.RoomServerException {
|
|
14147
14147
|
constructor(message2) {
|
|
14148
14148
|
super(message2);
|
|
14149
14149
|
this.name = "InvalidToolDataException";
|
|
@@ -14223,15 +14223,15 @@ ${err.toString()}`);
|
|
|
14223
14223
|
exports.ContentTool = ContentTool;
|
|
14224
14224
|
var Tool = class extends BaseTool {
|
|
14225
14225
|
constructor(params) {
|
|
14226
|
-
const inputSpec = params.inputSpec !== void 0 && params.inputSchema !== void 0 ? new
|
|
14227
|
-
const outputSpec = params.outputSpec !== void 0 && params.outputSchema !== void 0 ? new
|
|
14226
|
+
const inputSpec = params.inputSpec !== void 0 && params.inputSchema !== void 0 ? new tool_content_type_js_1.ToolContentSpec({ types: [...params.inputSpec.types], stream: params.inputSpec.stream, schema: params.inputSchema }) : params.inputSpec;
|
|
14227
|
+
const outputSpec = params.outputSpec !== void 0 && params.outputSchema !== void 0 ? new tool_content_type_js_1.ToolContentSpec({ types: [...params.outputSpec.types], stream: params.outputSpec.stream, schema: params.outputSchema }) : params.outputSpec;
|
|
14228
14228
|
super({
|
|
14229
14229
|
name: params.name,
|
|
14230
14230
|
description: params.description,
|
|
14231
14231
|
title: params.title,
|
|
14232
14232
|
inputSchema: params.inputSchema,
|
|
14233
|
-
inputSpec: inputSpec ?? (params.inputSchema !== void 0 ? new
|
|
14234
|
-
outputSpec: outputSpec ?? (params.outputSchema !== void 0 ? new
|
|
14233
|
+
inputSpec: inputSpec ?? (params.inputSchema !== void 0 ? new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: params.inputSchema }) : void 0),
|
|
14234
|
+
outputSpec: outputSpec ?? (params.outputSchema !== void 0 ? new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: params.outputSchema }) : void 0),
|
|
14235
14235
|
outputSchema: params.outputSchema,
|
|
14236
14236
|
defs: params.defs
|
|
14237
14237
|
});
|
|
@@ -14242,38 +14242,38 @@ ${err.toString()}`);
|
|
|
14242
14242
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14243
14243
|
}
|
|
14244
14244
|
function contentType(content) {
|
|
14245
|
-
if (content instanceof
|
|
14245
|
+
if (content instanceof response_js_1.BinaryContent)
|
|
14246
14246
|
return "binary";
|
|
14247
|
-
if (content instanceof
|
|
14247
|
+
if (content instanceof response_js_1.JsonContent)
|
|
14248
14248
|
return "json";
|
|
14249
|
-
if (content instanceof
|
|
14249
|
+
if (content instanceof response_js_1.TextContent)
|
|
14250
14250
|
return "text";
|
|
14251
|
-
if (content instanceof
|
|
14251
|
+
if (content instanceof response_js_1.FileContent)
|
|
14252
14252
|
return "file";
|
|
14253
|
-
if (content instanceof
|
|
14253
|
+
if (content instanceof response_js_1.LinkContent)
|
|
14254
14254
|
return "link";
|
|
14255
|
-
if (content instanceof
|
|
14255
|
+
if (content instanceof response_js_1.EmptyContent)
|
|
14256
14256
|
return "empty";
|
|
14257
14257
|
return void 0;
|
|
14258
14258
|
}
|
|
14259
14259
|
function schemaValue(content) {
|
|
14260
|
-
if (content instanceof
|
|
14260
|
+
if (content instanceof response_js_1.BinaryContent)
|
|
14261
14261
|
return content.headers;
|
|
14262
|
-
if (content instanceof
|
|
14262
|
+
if (content instanceof response_js_1.JsonContent)
|
|
14263
14263
|
return content.json;
|
|
14264
|
-
if (content instanceof
|
|
14264
|
+
if (content instanceof response_js_1.TextContent)
|
|
14265
14265
|
return content.text;
|
|
14266
|
-
if (content instanceof
|
|
14266
|
+
if (content instanceof response_js_1.EmptyContent)
|
|
14267
14267
|
return null;
|
|
14268
|
-
if (content instanceof
|
|
14268
|
+
if (content instanceof response_js_1.LinkContent)
|
|
14269
14269
|
return { name: content.name, url: content.url };
|
|
14270
|
-
if (content instanceof
|
|
14270
|
+
if (content instanceof response_js_1.FileContent)
|
|
14271
14271
|
return { name: content.name, mime_type: content.mimeType, size: content.data.length };
|
|
14272
|
-
if (content instanceof
|
|
14272
|
+
if (content instanceof response_js_1.ControlContent)
|
|
14273
14273
|
return { method: content.method };
|
|
14274
|
-
if (content instanceof
|
|
14274
|
+
if (content instanceof response_js_1.ErrorContent)
|
|
14275
14275
|
return content.code === void 0 ? { text: content.text } : { text: content.text, code: content.code };
|
|
14276
|
-
const [header] = (0,
|
|
14276
|
+
const [header] = (0, utils_js_1.unpackMessage)(content.pack());
|
|
14277
14277
|
return header;
|
|
14278
14278
|
}
|
|
14279
14279
|
function schemaWithDefs(schema, defs) {
|
|
@@ -14402,7 +14402,7 @@ ${err.toString()}`);
|
|
|
14402
14402
|
}
|
|
14403
14403
|
async execute(first, second, third) {
|
|
14404
14404
|
if (typeof first === "string") {
|
|
14405
|
-
const output = await this.executeTool(new ToolContext(), first, new ToolContentInput(new
|
|
14405
|
+
const output = await this.executeTool(new ToolContext(), first, new ToolContentInput(new response_js_1.JsonContent({ json: second })));
|
|
14406
14406
|
if (output instanceof ToolContentOutput) {
|
|
14407
14407
|
return output.content;
|
|
14408
14408
|
}
|
|
@@ -14431,9 +14431,9 @@ ${err.toString()}`);
|
|
|
14431
14431
|
throw new Error(`tool ${name} has unsupported type`);
|
|
14432
14432
|
}
|
|
14433
14433
|
decodeFunctionToolArguments(toolName, input) {
|
|
14434
|
-
if (input instanceof
|
|
14434
|
+
if (input instanceof response_js_1.EmptyContent)
|
|
14435
14435
|
return {};
|
|
14436
|
-
if (input instanceof
|
|
14436
|
+
if (input instanceof response_js_1.JsonContent) {
|
|
14437
14437
|
if (!isRecord(input.json)) {
|
|
14438
14438
|
throw new Error(`tool ${toolName} requires JSON object input`);
|
|
14439
14439
|
}
|
|
@@ -14452,18 +14452,18 @@ ${err.toString()}`);
|
|
|
14452
14452
|
return tool.inputSpec;
|
|
14453
14453
|
if (tool.inputSpec !== void 0)
|
|
14454
14454
|
return tool.inputSpec;
|
|
14455
|
-
return new
|
|
14455
|
+
return new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: tool.inputSchema ?? { type: "object", additionalProperties: true } });
|
|
14456
14456
|
}
|
|
14457
14457
|
resolveOutputSpec(tool) {
|
|
14458
14458
|
if (tool.outputSpec !== void 0) {
|
|
14459
14459
|
if (tool.outputSchema !== void 0 && tool.outputSpec.schema === void 0 && tool.outputSpec.types.includes("json")) {
|
|
14460
|
-
return new
|
|
14460
|
+
return new tool_content_type_js_1.ToolContentSpec({ types: [...tool.outputSpec.types], stream: tool.outputSpec.stream, schema: tool.outputSchema });
|
|
14461
14461
|
}
|
|
14462
14462
|
return tool.outputSpec;
|
|
14463
14463
|
}
|
|
14464
14464
|
if (tool.outputSchema === void 0)
|
|
14465
14465
|
return void 0;
|
|
14466
|
-
return new
|
|
14466
|
+
return new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: tool.outputSchema });
|
|
14467
14467
|
}
|
|
14468
14468
|
validateStreamMode({ tool, direction, spec, stream }) {
|
|
14469
14469
|
if (!this.shouldValidateContentTypes || spec === void 0)
|
|
@@ -14533,7 +14533,7 @@ ${err.toString()}`);
|
|
|
14533
14533
|
}
|
|
14534
14534
|
async start({ public_: isPublic = false } = {}) {
|
|
14535
14535
|
if (this._started) {
|
|
14536
|
-
throw new
|
|
14536
|
+
throw new room_server_client_js_1.RoomServerException(`toolkit ${this.toolkit.name} is already started`);
|
|
14537
14537
|
}
|
|
14538
14538
|
this._public = isPublic;
|
|
14539
14539
|
this.client.protocol.addHandler(`room.tool_call.${this.toolkit.name}`, this._toolCallHandler);
|
|
@@ -14558,7 +14558,7 @@ ${err.toString()}`);
|
|
|
14558
14558
|
this._started = false;
|
|
14559
14559
|
this.client.off("disconnected", this._roomEventHandler);
|
|
14560
14560
|
this.client.off("reconnected", this._roomEventHandler);
|
|
14561
|
-
this._failActiveRequestStreams(new
|
|
14561
|
+
this._failActiveRequestStreams(new room_server_client_js_1.RoomServerException("hosted toolkit stopped"));
|
|
14562
14562
|
try {
|
|
14563
14563
|
await this._unregister();
|
|
14564
14564
|
} finally {
|
|
@@ -14614,13 +14614,13 @@ ${err.toString()}`);
|
|
|
14614
14614
|
});
|
|
14615
14615
|
}
|
|
14616
14616
|
_onRoomEvent(event) {
|
|
14617
|
-
if (!this._started || !(event instanceof
|
|
14617
|
+
if (!this._started || !(event instanceof room_event_js_1.RoomStatusEvent)) {
|
|
14618
14618
|
return;
|
|
14619
14619
|
}
|
|
14620
14620
|
if (event.status === "disconnected") {
|
|
14621
14621
|
this._registrationId = void 0;
|
|
14622
14622
|
const message2 = event.message?.trim();
|
|
14623
|
-
this._failActiveRequestStreams(new
|
|
14623
|
+
this._failActiveRequestStreams(new room_server_client_js_1.RoomServerException(message2 == null || message2.length === 0 ? "room connection lost before streamed tool call request completed" : `room connection lost before streamed tool call request completed: ${message2}`));
|
|
14624
14624
|
return;
|
|
14625
14625
|
}
|
|
14626
14626
|
if (event.status === "reconnected") {
|
|
@@ -14637,16 +14637,16 @@ ${err.toString()}`);
|
|
|
14637
14637
|
if (remote.id === participantId)
|
|
14638
14638
|
return remote;
|
|
14639
14639
|
}
|
|
14640
|
-
return new
|
|
14640
|
+
return new participant_js_1.RemoteParticipant(this.client, participantId, "user");
|
|
14641
14641
|
}
|
|
14642
14642
|
_contentFromToolCallArguments(rawArguments, payload) {
|
|
14643
14643
|
if (!isRecord(rawArguments)) {
|
|
14644
14644
|
throw new Error("arguments must be a content header object");
|
|
14645
14645
|
}
|
|
14646
14646
|
if (typeof rawArguments.type === "string") {
|
|
14647
|
-
return (0,
|
|
14647
|
+
return (0, response_js_1.unpackContent)((0, utils_js_1.packMessage)(rawArguments, payload.length > 0 ? payload : void 0));
|
|
14648
14648
|
}
|
|
14649
|
-
return new
|
|
14649
|
+
return new response_js_1.JsonContent({ json: rawArguments });
|
|
14650
14650
|
}
|
|
14651
14651
|
async _sendToolCallResponse(messageId, chunk) {
|
|
14652
14652
|
try {
|
|
@@ -14658,9 +14658,9 @@ ${err.toString()}`);
|
|
|
14658
14658
|
}
|
|
14659
14659
|
}
|
|
14660
14660
|
async _sendToolCallResponseChunk(messageId, toolCallId, chunk) {
|
|
14661
|
-
const [header, payload] = (0,
|
|
14661
|
+
const [header, payload] = (0, utils_js_1.unpackMessage)(chunk.pack());
|
|
14662
14662
|
try {
|
|
14663
|
-
await this.client.protocol.send("room.tool_call_response_chunk", (0,
|
|
14663
|
+
await this.client.protocol.send("room.tool_call_response_chunk", (0, utils_js_1.packMessage)({ tool_call_id: toolCallId, chunk: header }, payload.length > 0 ? payload : void 0), { id: messageId });
|
|
14664
14664
|
return true;
|
|
14665
14665
|
} catch (error) {
|
|
14666
14666
|
console.debug("unable to send tool call response chunk", error);
|
|
@@ -14679,7 +14679,7 @@ ${err.toString()}`);
|
|
|
14679
14679
|
};
|
|
14680
14680
|
}
|
|
14681
14681
|
_enqueueRequestStreamChunk(stream, chunk, tool) {
|
|
14682
|
-
if (chunk instanceof
|
|
14682
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
14683
14683
|
if (chunk.method === "open")
|
|
14684
14684
|
return;
|
|
14685
14685
|
if (chunk.method === "close") {
|
|
@@ -14707,26 +14707,26 @@ ${err.toString()}`);
|
|
|
14707
14707
|
let toolCallId = toolCallIdFallback;
|
|
14708
14708
|
let openedResponseStream = false;
|
|
14709
14709
|
try {
|
|
14710
|
-
const [message2, payload] = (0,
|
|
14710
|
+
const [message2, payload] = (0, utils_js_1.unpackMessage)(data);
|
|
14711
14711
|
const toolName = message2["name"];
|
|
14712
14712
|
if (typeof toolName !== "string" || toolName.length === 0) {
|
|
14713
14713
|
throw new Error("tool call requires a tool name");
|
|
14714
14714
|
}
|
|
14715
14715
|
toolCallId = typeof message2["tool_call_id"] === "string" && message2["tool_call_id"].length > 0 ? message2["tool_call_id"] : toolCallIdFallback;
|
|
14716
14716
|
const inputChunk = this._contentFromToolCallArguments(message2["arguments"], payload);
|
|
14717
|
-
const requestStream = inputChunk instanceof
|
|
14718
|
-
if (inputChunk instanceof
|
|
14719
|
-
await this._sendToolCallResponse(messageId, new
|
|
14717
|
+
const requestStream = inputChunk instanceof response_js_1.ControlContent && inputChunk.method === "open";
|
|
14718
|
+
if (inputChunk instanceof response_js_1.ControlContent && !requestStream) {
|
|
14719
|
+
await this._sendToolCallResponse(messageId, new response_js_1.ErrorContent({ text: "request stream must start with an open control chunk" }));
|
|
14720
14720
|
return;
|
|
14721
14721
|
}
|
|
14722
14722
|
const tool = this.toolkit.getTool(toolName);
|
|
14723
14723
|
this.toolkit.validateStreamMode({ tool, direction: "input", spec: this.toolkit.resolveInputSpec(tool), stream: requestStream });
|
|
14724
14724
|
let resolvedInput;
|
|
14725
14725
|
if (requestStream) {
|
|
14726
|
-
const controller = new
|
|
14726
|
+
const controller = new stream_controller_js_1.StreamController();
|
|
14727
14727
|
this._requestStreams.set(toolCallId, controller);
|
|
14728
14728
|
this._requestStreamTools.set(toolCallId, tool);
|
|
14729
|
-
this._enqueueRequestStreamChunk(controller, new
|
|
14729
|
+
this._enqueueRequestStreamChunk(controller, new response_js_1.ControlContent({ method: "open" }), tool);
|
|
14730
14730
|
const buffered = this._pendingRequestChunks.get(toolCallId) ?? [];
|
|
14731
14731
|
this._pendingRequestChunks.delete(toolCallId);
|
|
14732
14732
|
for (const chunk of buffered) {
|
|
@@ -14752,28 +14752,28 @@ ${err.toString()}`);
|
|
|
14752
14752
|
if (output instanceof ToolStreamOutput) {
|
|
14753
14753
|
this.toolkit.validateStreamMode({ tool, direction: "output", spec: this.toolkit.resolveOutputSpec(tool), stream: true });
|
|
14754
14754
|
openedResponseStream = true;
|
|
14755
|
-
if (!await this._sendToolCallResponse(messageId, new
|
|
14755
|
+
if (!await this._sendToolCallResponse(messageId, new response_js_1.ControlContent({ method: "open" })))
|
|
14756
14756
|
return;
|
|
14757
14757
|
for await (const chunk of output.stream) {
|
|
14758
14758
|
this.toolkit.validateOutputContent(tool, chunk);
|
|
14759
14759
|
if (!await this._sendToolCallResponseChunk(messageId, toolCallId, chunk))
|
|
14760
14760
|
return;
|
|
14761
14761
|
}
|
|
14762
|
-
await this._sendToolCallResponseChunk(messageId, toolCallId, new
|
|
14762
|
+
await this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
14763
14763
|
return;
|
|
14764
14764
|
}
|
|
14765
14765
|
throw new Error(`tool ${toolName} returned unsupported output`);
|
|
14766
14766
|
} catch (error) {
|
|
14767
14767
|
if (!openedResponseStream) {
|
|
14768
|
-
await this._sendToolCallResponse(messageId, new
|
|
14768
|
+
await this._sendToolCallResponse(messageId, new response_js_1.ErrorContent({ text: String(error) }));
|
|
14769
14769
|
return;
|
|
14770
14770
|
}
|
|
14771
14771
|
if (!(error instanceof InvalidToolDataException)) {
|
|
14772
|
-
await this._sendToolCallResponseChunk(messageId, toolCallId, new
|
|
14772
|
+
await this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ErrorContent({ text: String(error) }));
|
|
14773
14773
|
}
|
|
14774
|
-
await this._sendToolCallResponseChunk(messageId, toolCallId, new
|
|
14774
|
+
await this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({
|
|
14775
14775
|
method: "close",
|
|
14776
|
-
statusCode: error instanceof InvalidToolDataException ?
|
|
14776
|
+
statusCode: error instanceof InvalidToolDataException ? response_js_1.ControlCloseStatus.INVALID_DATA : void 0,
|
|
14777
14777
|
message: error instanceof InvalidToolDataException ? error.message : void 0
|
|
14778
14778
|
}));
|
|
14779
14779
|
} finally {
|
|
@@ -14785,14 +14785,14 @@ ${err.toString()}`);
|
|
|
14785
14785
|
return;
|
|
14786
14786
|
}
|
|
14787
14787
|
try {
|
|
14788
|
-
const [message2, payload] = (0,
|
|
14788
|
+
const [message2, payload] = (0, utils_js_1.unpackMessage)(data);
|
|
14789
14789
|
const toolCallId = message2["tool_call_id"];
|
|
14790
14790
|
if (typeof toolCallId !== "string" || toolCallId.length === 0)
|
|
14791
14791
|
return;
|
|
14792
14792
|
const chunkHeader = message2["chunk"];
|
|
14793
14793
|
if (!isRecord(chunkHeader))
|
|
14794
14794
|
return;
|
|
14795
|
-
const chunk = (0,
|
|
14795
|
+
const chunk = (0, response_js_1.unpackContent)((0, utils_js_1.packMessage)(chunkHeader, payload.length > 0 ? payload : void 0));
|
|
14796
14796
|
const stream = this._requestStreams.get(toolCallId);
|
|
14797
14797
|
if (stream === void 0) {
|
|
14798
14798
|
const buffered = this._pendingRequestChunks.get(toolCallId) ?? [];
|
|
@@ -14843,15 +14843,15 @@ ${err.toString()}`);
|
|
|
14843
14843
|
"use strict";
|
|
14844
14844
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14845
14845
|
exports.AgentsClient = exports.ToolkitDescription = exports.ToolDescription = void 0;
|
|
14846
|
-
var
|
|
14847
|
-
var
|
|
14846
|
+
var agent_js_1 = require_agent();
|
|
14847
|
+
var tool_content_type_js_1 = require_tool_content_type();
|
|
14848
14848
|
var ToolDescription = class {
|
|
14849
14849
|
constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, defs }) {
|
|
14850
14850
|
this.title = title;
|
|
14851
14851
|
this.name = name;
|
|
14852
14852
|
this.description = description;
|
|
14853
14853
|
if (inputSpec !== void 0 && inputSchema !== void 0) {
|
|
14854
|
-
this.inputSpec = new
|
|
14854
|
+
this.inputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
14855
14855
|
types: [...inputSpec.types],
|
|
14856
14856
|
stream: inputSpec.stream,
|
|
14857
14857
|
schema: inputSchema
|
|
@@ -14859,14 +14859,14 @@ ${err.toString()}`);
|
|
|
14859
14859
|
} else if (inputSpec !== void 0) {
|
|
14860
14860
|
this.inputSpec = inputSpec;
|
|
14861
14861
|
} else if (inputSchema !== void 0) {
|
|
14862
|
-
this.inputSpec = new
|
|
14862
|
+
this.inputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
14863
14863
|
types: ["json"],
|
|
14864
14864
|
stream: false,
|
|
14865
14865
|
schema: inputSchema
|
|
14866
14866
|
});
|
|
14867
14867
|
}
|
|
14868
14868
|
if (outputSpec !== void 0 && outputSchema !== void 0) {
|
|
14869
|
-
this.outputSpec = new
|
|
14869
|
+
this.outputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
14870
14870
|
types: [...outputSpec.types],
|
|
14871
14871
|
stream: outputSpec.stream,
|
|
14872
14872
|
schema: outputSchema
|
|
@@ -14874,7 +14874,7 @@ ${err.toString()}`);
|
|
|
14874
14874
|
} else if (outputSpec !== void 0) {
|
|
14875
14875
|
this.outputSpec = outputSpec;
|
|
14876
14876
|
} else if (outputSchema !== void 0) {
|
|
14877
|
-
this.outputSpec = new
|
|
14877
|
+
this.outputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
14878
14878
|
types: ["json"],
|
|
14879
14879
|
stream: false,
|
|
14880
14880
|
schema: outputSchema
|
|
@@ -14934,9 +14934,9 @@ ${err.toString()}`);
|
|
|
14934
14934
|
name: tool["name"],
|
|
14935
14935
|
description: tool["description"],
|
|
14936
14936
|
inputSchema: tool["input_schema"],
|
|
14937
|
-
inputSpec:
|
|
14937
|
+
inputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["input_spec"]),
|
|
14938
14938
|
outputSchema: tool["output_schema"],
|
|
14939
|
-
outputSpec:
|
|
14939
|
+
outputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["output_spec"]),
|
|
14940
14940
|
defs: tool["defs"]
|
|
14941
14941
|
}));
|
|
14942
14942
|
}
|
|
@@ -14949,9 +14949,9 @@ ${err.toString()}`);
|
|
|
14949
14949
|
name: toolName,
|
|
14950
14950
|
description: tool["description"],
|
|
14951
14951
|
inputSchema: tool["input_schema"],
|
|
14952
|
-
inputSpec:
|
|
14952
|
+
inputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["input_spec"]),
|
|
14953
14953
|
outputSchema: tool["output_schema"],
|
|
14954
|
-
outputSpec:
|
|
14954
|
+
outputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["output_spec"]),
|
|
14955
14955
|
defs: tool["defs"]
|
|
14956
14956
|
}));
|
|
14957
14957
|
}
|
|
@@ -14986,7 +14986,7 @@ ${err.toString()}`);
|
|
|
14986
14986
|
onBehalfOfId: params.onBehalfOfId
|
|
14987
14987
|
});
|
|
14988
14988
|
}
|
|
14989
|
-
if (params.input instanceof
|
|
14989
|
+
if (params.input instanceof agent_js_1.ToolContentInput) {
|
|
14990
14990
|
const output = await this.client.invokeToolCall({
|
|
14991
14991
|
toolkit: params.toolkit,
|
|
14992
14992
|
tool: params.tool,
|
|
@@ -14994,9 +14994,9 @@ ${err.toString()}`);
|
|
|
14994
14994
|
participantId: params.participantId,
|
|
14995
14995
|
onBehalfOfId: params.onBehalfOfId
|
|
14996
14996
|
});
|
|
14997
|
-
return output.kind === "content" ? new
|
|
14997
|
+
return output.kind === "content" ? new agent_js_1.ToolContentOutput(output.content) : new agent_js_1.ToolStreamOutput(output.stream, { inputClosed: output.inputClosed });
|
|
14998
14998
|
}
|
|
14999
|
-
if (params.input instanceof
|
|
14999
|
+
if (params.input instanceof agent_js_1.ToolStreamInput) {
|
|
15000
15000
|
const output = await this.client.invokeToolCall({
|
|
15001
15001
|
toolkit: params.toolkit,
|
|
15002
15002
|
tool: params.tool,
|
|
@@ -15005,7 +15005,7 @@ ${err.toString()}`);
|
|
|
15005
15005
|
participantId: params.participantId,
|
|
15006
15006
|
onBehalfOfId: params.onBehalfOfId
|
|
15007
15007
|
});
|
|
15008
|
-
return output.kind === "content" ? new
|
|
15008
|
+
return output.kind === "content" ? new agent_js_1.ToolContentOutput(output.content) : new agent_js_1.ToolStreamOutput(output.stream, { inputClosed: output.inputClosed });
|
|
15009
15009
|
}
|
|
15010
15010
|
throw new Error("invokeTool input must be ToolContentInput or ToolStreamInput");
|
|
15011
15011
|
}
|
|
@@ -15458,10 +15458,10 @@ ${err.toString()}`);
|
|
|
15458
15458
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15459
15459
|
exports.ContainersClient = exports.ExecSession = void 0;
|
|
15460
15460
|
var uuid_1 = (init_dist(), __toCommonJS(dist_exports));
|
|
15461
|
-
var
|
|
15462
|
-
var
|
|
15463
|
-
var
|
|
15464
|
-
var
|
|
15461
|
+
var completer_js_1 = require_completer();
|
|
15462
|
+
var response_js_1 = require_response();
|
|
15463
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
15464
|
+
var stream_controller_js_1 = require_stream_controller();
|
|
15465
15465
|
function isRecord(value) {
|
|
15466
15466
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15467
15467
|
}
|
|
@@ -15487,14 +15487,14 @@ ${err.toString()}`);
|
|
|
15487
15487
|
function readStringField(data, field, operation) {
|
|
15488
15488
|
const value = data[field];
|
|
15489
15489
|
if (typeof value !== "string") {
|
|
15490
|
-
throw new
|
|
15490
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15491
15491
|
}
|
|
15492
15492
|
return value;
|
|
15493
15493
|
}
|
|
15494
15494
|
function readIntegerField(data, field, operation) {
|
|
15495
15495
|
const value = data[field];
|
|
15496
15496
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
15497
|
-
throw new
|
|
15497
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15498
15498
|
}
|
|
15499
15499
|
return value;
|
|
15500
15500
|
}
|
|
@@ -15504,7 +15504,7 @@ ${err.toString()}`);
|
|
|
15504
15504
|
return void 0;
|
|
15505
15505
|
}
|
|
15506
15506
|
if (typeof value !== "number" || !Number.isInteger(value)) {
|
|
15507
|
-
throw new
|
|
15507
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15508
15508
|
}
|
|
15509
15509
|
return value;
|
|
15510
15510
|
}
|
|
@@ -15514,7 +15514,7 @@ ${err.toString()}`);
|
|
|
15514
15514
|
return void 0;
|
|
15515
15515
|
}
|
|
15516
15516
|
if (typeof value !== "string") {
|
|
15517
|
-
throw new
|
|
15517
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15518
15518
|
}
|
|
15519
15519
|
return value;
|
|
15520
15520
|
}
|
|
@@ -15524,11 +15524,11 @@ ${err.toString()}`);
|
|
|
15524
15524
|
return void 0;
|
|
15525
15525
|
}
|
|
15526
15526
|
if (typeof value !== "string") {
|
|
15527
|
-
throw new
|
|
15527
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15528
15528
|
}
|
|
15529
15529
|
const timestamp = new Date(value);
|
|
15530
15530
|
if (Number.isNaN(timestamp.getTime())) {
|
|
15531
|
-
throw new
|
|
15531
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15532
15532
|
}
|
|
15533
15533
|
return timestamp;
|
|
15534
15534
|
}
|
|
@@ -15536,7 +15536,7 @@ ${err.toString()}`);
|
|
|
15536
15536
|
try {
|
|
15537
15537
|
return new TextDecoder("utf-8", { fatal: true }).decode(data);
|
|
15538
15538
|
} catch {
|
|
15539
|
-
throw new
|
|
15539
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned invalid UTF-8 data`);
|
|
15540
15540
|
}
|
|
15541
15541
|
}
|
|
15542
15542
|
function decodeJsonStatus(data, operation) {
|
|
@@ -15545,14 +15545,14 @@ ${err.toString()}`);
|
|
|
15545
15545
|
try {
|
|
15546
15546
|
parsed = JSON.parse(text);
|
|
15547
15547
|
} catch {
|
|
15548
|
-
throw new
|
|
15548
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
15549
15549
|
}
|
|
15550
15550
|
if (!isRecord(parsed)) {
|
|
15551
|
-
throw new
|
|
15551
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
15552
15552
|
}
|
|
15553
15553
|
const status = parsed["status"];
|
|
15554
15554
|
if (typeof status !== "number" || !Number.isInteger(status)) {
|
|
15555
|
-
throw new
|
|
15555
|
+
throw new room_server_client_js_1.RoomServerException(`containers.${operation} returned an invalid status payload`);
|
|
15556
15556
|
}
|
|
15557
15557
|
return status;
|
|
15558
15558
|
}
|
|
@@ -15561,12 +15561,12 @@ ${err.toString()}`);
|
|
|
15561
15561
|
const labels = {};
|
|
15562
15562
|
for (const entry of labelsRaw) {
|
|
15563
15563
|
if (!isRecord(entry)) {
|
|
15564
|
-
throw new
|
|
15564
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15565
15565
|
}
|
|
15566
15566
|
const key = entry["key"];
|
|
15567
15567
|
const value = entry["value"];
|
|
15568
15568
|
if (typeof key !== "string" || typeof value !== "string") {
|
|
15569
|
-
throw new
|
|
15569
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15570
15570
|
}
|
|
15571
15571
|
labels[key] = value;
|
|
15572
15572
|
}
|
|
@@ -15576,7 +15576,7 @@ ${err.toString()}`);
|
|
|
15576
15576
|
const labels = {};
|
|
15577
15577
|
for (const [key, value] of Object.entries(labelsRaw)) {
|
|
15578
15578
|
if (typeof value !== "string") {
|
|
15579
|
-
throw new
|
|
15579
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15580
15580
|
}
|
|
15581
15581
|
labels[key] = value;
|
|
15582
15582
|
}
|
|
@@ -15585,14 +15585,14 @@ ${err.toString()}`);
|
|
|
15585
15585
|
if (labelsRaw === void 0 || labelsRaw === null) {
|
|
15586
15586
|
return {};
|
|
15587
15587
|
}
|
|
15588
|
-
throw new
|
|
15588
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15589
15589
|
}
|
|
15590
15590
|
function normalizeImageReferences(entry, operation) {
|
|
15591
15591
|
const referencesRaw = entry["references"];
|
|
15592
15592
|
if (Array.isArray(referencesRaw)) {
|
|
15593
15593
|
const references = referencesRaw.filter((item) => typeof item === "string");
|
|
15594
15594
|
if (references.length !== referencesRaw.length) {
|
|
15595
|
-
throw new
|
|
15595
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15596
15596
|
}
|
|
15597
15597
|
return references;
|
|
15598
15598
|
}
|
|
@@ -15600,14 +15600,14 @@ ${err.toString()}`);
|
|
|
15600
15600
|
if (Array.isArray(tagsRaw)) {
|
|
15601
15601
|
const references = tagsRaw.filter((item) => typeof item === "string");
|
|
15602
15602
|
if (references.length !== tagsRaw.length) {
|
|
15603
|
-
throw new
|
|
15603
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15604
15604
|
}
|
|
15605
15605
|
return references;
|
|
15606
15606
|
}
|
|
15607
15607
|
if (referencesRaw === void 0 || referencesRaw === null) {
|
|
15608
15608
|
return [];
|
|
15609
15609
|
}
|
|
15610
|
-
throw new
|
|
15610
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15611
15611
|
}
|
|
15612
15612
|
function parseContainerImage(entry, operation) {
|
|
15613
15613
|
const references = normalizeImageReferences(entry, operation);
|
|
@@ -15635,14 +15635,14 @@ ${err.toString()}`);
|
|
|
15635
15635
|
return void 0;
|
|
15636
15636
|
}
|
|
15637
15637
|
if (!isRecord(value)) {
|
|
15638
|
-
throw new
|
|
15638
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15639
15639
|
}
|
|
15640
15640
|
return parseContainerImageDescriptor(value, operation);
|
|
15641
15641
|
}
|
|
15642
15642
|
function parseContainerImageManifest(entry, operation) {
|
|
15643
15643
|
const descriptorRaw = entry["descriptor"];
|
|
15644
15644
|
if (!isRecord(descriptorRaw)) {
|
|
15645
|
-
throw new
|
|
15645
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15646
15646
|
}
|
|
15647
15647
|
return {
|
|
15648
15648
|
descriptor: parseContainerImageDescriptor(descriptorRaw, operation),
|
|
@@ -15657,7 +15657,7 @@ ${err.toString()}`);
|
|
|
15657
15657
|
const manifestsRaw = entry["manifests"];
|
|
15658
15658
|
const layersRaw = entry["layers"];
|
|
15659
15659
|
if (!isRecord(imageRaw) || !isRecord(targetRaw) || !Array.isArray(manifestsRaw) || !Array.isArray(layersRaw)) {
|
|
15660
|
-
throw new
|
|
15660
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15661
15661
|
}
|
|
15662
15662
|
return {
|
|
15663
15663
|
image: parseContainerImage(imageRaw, operation),
|
|
@@ -15665,14 +15665,14 @@ ${err.toString()}`);
|
|
|
15665
15665
|
selectedManifest: parseOptionalContainerImageDescriptor(entry["selected_manifest"], operation),
|
|
15666
15666
|
manifests: manifestsRaw.map((manifest) => {
|
|
15667
15667
|
if (!isRecord(manifest)) {
|
|
15668
|
-
throw new
|
|
15668
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15669
15669
|
}
|
|
15670
15670
|
return parseContainerImageManifest(manifest, operation);
|
|
15671
15671
|
}),
|
|
15672
15672
|
config: parseOptionalContainerImageDescriptor(entry["config"], operation),
|
|
15673
15673
|
layers: layersRaw.map((layer) => {
|
|
15674
15674
|
if (!isRecord(layer)) {
|
|
15675
|
-
throw new
|
|
15675
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15676
15676
|
}
|
|
15677
15677
|
return parseContainerImageDescriptor(layer, operation);
|
|
15678
15678
|
}),
|
|
@@ -15683,7 +15683,7 @@ ${err.toString()}`);
|
|
|
15683
15683
|
const resolvedRef = data["resolved_ref"];
|
|
15684
15684
|
const refsRaw = data["refs"];
|
|
15685
15685
|
if (typeof resolvedRef !== "string" || !Array.isArray(refsRaw) || refsRaw.some((entry) => typeof entry !== "string")) {
|
|
15686
|
-
throw new
|
|
15686
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15687
15687
|
}
|
|
15688
15688
|
return {
|
|
15689
15689
|
resolvedRef,
|
|
@@ -15695,7 +15695,7 @@ ${err.toString()}`);
|
|
|
15695
15695
|
const tag2 = readStringField(data, "tag", operation);
|
|
15696
15696
|
const status = readStringField(data, "status", operation);
|
|
15697
15697
|
if (!["queued", "running", "failed", "cancelled", "succeeded"].includes(status)) {
|
|
15698
|
-
throw new
|
|
15698
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15699
15699
|
}
|
|
15700
15700
|
return {
|
|
15701
15701
|
id,
|
|
@@ -15707,9 +15707,9 @@ ${err.toString()}`);
|
|
|
15707
15707
|
async function* buildInputStream(params) {
|
|
15708
15708
|
const tags = params.tags ?? (params.tag === void 0 ? [] : [params.tag]);
|
|
15709
15709
|
if (tags.length === 0) {
|
|
15710
|
-
throw new
|
|
15710
|
+
throw new room_server_client_js_1.RoomServerException("containers.build requires at least one tag");
|
|
15711
15711
|
}
|
|
15712
|
-
yield new
|
|
15712
|
+
yield new response_js_1.BinaryContent({
|
|
15713
15713
|
data: new Uint8Array(0),
|
|
15714
15714
|
headers: {
|
|
15715
15715
|
kind: "start",
|
|
@@ -15725,7 +15725,7 @@ ${err.toString()}`);
|
|
|
15725
15725
|
}
|
|
15726
15726
|
});
|
|
15727
15727
|
for await (const chunk of params.chunks) {
|
|
15728
|
-
yield new
|
|
15728
|
+
yield new response_js_1.BinaryContent({
|
|
15729
15729
|
data: new Uint8Array(chunk),
|
|
15730
15730
|
headers: { kind: "data" }
|
|
15731
15731
|
});
|
|
@@ -15735,9 +15735,9 @@ ${err.toString()}`);
|
|
|
15735
15735
|
constructor(params) {
|
|
15736
15736
|
this.previousOutput = [];
|
|
15737
15737
|
this.previousError = [];
|
|
15738
|
-
this.resultCompleter = new
|
|
15739
|
-
this.outputController = new
|
|
15740
|
-
this.errorController = new
|
|
15738
|
+
this.resultCompleter = new completer_js_1.Completer();
|
|
15739
|
+
this.outputController = new stream_controller_js_1.StreamController();
|
|
15740
|
+
this.errorController = new stream_controller_js_1.StreamController();
|
|
15741
15741
|
this.queuedInput = [];
|
|
15742
15742
|
this.inputClosed = false;
|
|
15743
15743
|
this.closed = false;
|
|
@@ -15751,7 +15751,7 @@ ${err.toString()}`);
|
|
|
15751
15751
|
this.stderr = this.errorController.stream;
|
|
15752
15752
|
}
|
|
15753
15753
|
async *inputStream() {
|
|
15754
|
-
yield new
|
|
15754
|
+
yield new response_js_1.BinaryContent({
|
|
15755
15755
|
data: new Uint8Array(0),
|
|
15756
15756
|
headers: {
|
|
15757
15757
|
kind: "start",
|
|
@@ -15771,7 +15771,7 @@ ${err.toString()}`);
|
|
|
15771
15771
|
if (this.inputClosed) {
|
|
15772
15772
|
return;
|
|
15773
15773
|
}
|
|
15774
|
-
this.inputWaiter = new
|
|
15774
|
+
this.inputWaiter = new completer_js_1.Completer();
|
|
15775
15775
|
await this.inputWaiter.fut;
|
|
15776
15776
|
this.inputWaiter = null;
|
|
15777
15777
|
}
|
|
@@ -15827,9 +15827,9 @@ ${err.toString()}`);
|
|
|
15827
15827
|
}
|
|
15828
15828
|
queueInput(params) {
|
|
15829
15829
|
if (this.inputClosed) {
|
|
15830
|
-
throw new
|
|
15830
|
+
throw new room_server_client_js_1.RoomServerException("container exec session is already closed");
|
|
15831
15831
|
}
|
|
15832
|
-
this.queuedInput.push(new
|
|
15832
|
+
this.queuedInput.push(new response_js_1.BinaryContent({
|
|
15833
15833
|
data: params.data ?? new Uint8Array(0),
|
|
15834
15834
|
headers: {
|
|
15835
15835
|
kind: "input",
|
|
@@ -15854,7 +15854,7 @@ ${err.toString()}`);
|
|
|
15854
15854
|
this.room = room;
|
|
15855
15855
|
}
|
|
15856
15856
|
unexpectedResponseError(operation) {
|
|
15857
|
-
return new
|
|
15857
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from containers.${operation}`);
|
|
15858
15858
|
}
|
|
15859
15859
|
async invoke(operation, input) {
|
|
15860
15860
|
return await this.room.invoke({
|
|
@@ -15865,7 +15865,7 @@ ${err.toString()}`);
|
|
|
15865
15865
|
}
|
|
15866
15866
|
async listImages() {
|
|
15867
15867
|
const output = await this.invoke("list_images", {});
|
|
15868
|
-
if (!(output instanceof
|
|
15868
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15869
15869
|
throw this.unexpectedResponseError("list_images");
|
|
15870
15870
|
}
|
|
15871
15871
|
const imagesRaw = output.json["images"];
|
|
@@ -15885,7 +15885,7 @@ ${err.toString()}`);
|
|
|
15885
15885
|
const output = await this.invoke("inspect_image", {
|
|
15886
15886
|
image_id: params.imageId
|
|
15887
15887
|
});
|
|
15888
|
-
if (!(output instanceof
|
|
15888
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15889
15889
|
throw this.unexpectedResponseError("inspect_image");
|
|
15890
15890
|
}
|
|
15891
15891
|
return parseContainerImageInspection(output.json, "inspect_image");
|
|
@@ -15907,7 +15907,7 @@ ${err.toString()}`);
|
|
|
15907
15907
|
credentials: toCredentials(params.credentials ?? []),
|
|
15908
15908
|
private: params.private ?? false
|
|
15909
15909
|
});
|
|
15910
|
-
if (!(output instanceof
|
|
15910
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15911
15911
|
throw this.unexpectedResponseError("push_image");
|
|
15912
15912
|
}
|
|
15913
15913
|
return readStringField(output.json, "container_id", "push_image");
|
|
@@ -15916,7 +15916,7 @@ ${err.toString()}`);
|
|
|
15916
15916
|
const output = await this.invoke("load", {
|
|
15917
15917
|
archive_path: params.archivePath
|
|
15918
15918
|
});
|
|
15919
|
-
if (!(output instanceof
|
|
15919
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15920
15920
|
throw this.unexpectedResponseError("load");
|
|
15921
15921
|
}
|
|
15922
15922
|
return parseImportedImage(output.json, "load");
|
|
@@ -15927,7 +15927,7 @@ ${err.toString()}`);
|
|
|
15927
15927
|
archive_path: params.archivePath,
|
|
15928
15928
|
private: params.private ?? false
|
|
15929
15929
|
});
|
|
15930
|
-
if (!(output instanceof
|
|
15930
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15931
15931
|
throw this.unexpectedResponseError("load_image");
|
|
15932
15932
|
}
|
|
15933
15933
|
return readStringField(output.json, "container_id", "load_image");
|
|
@@ -15939,7 +15939,7 @@ ${err.toString()}`);
|
|
|
15939
15939
|
archive_path: params.archivePath,
|
|
15940
15940
|
private: params.private ?? false
|
|
15941
15941
|
});
|
|
15942
|
-
if (!(output instanceof
|
|
15942
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15943
15943
|
throw this.unexpectedResponseError("save_image");
|
|
15944
15944
|
}
|
|
15945
15945
|
return readStringField(output.json, "container_id", "save_image");
|
|
@@ -15962,7 +15962,7 @@ ${err.toString()}`);
|
|
|
15962
15962
|
writable_root_fs: params.writableRootFs,
|
|
15963
15963
|
private: params.private
|
|
15964
15964
|
});
|
|
15965
|
-
if (!(output instanceof
|
|
15965
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15966
15966
|
throw this.unexpectedResponseError("run");
|
|
15967
15967
|
}
|
|
15968
15968
|
return readStringField(output.json, "container_id", "run");
|
|
@@ -15973,14 +15973,14 @@ ${err.toString()}`);
|
|
|
15973
15973
|
tool: "build",
|
|
15974
15974
|
input: buildInputStream(params)
|
|
15975
15975
|
});
|
|
15976
|
-
if (!(output instanceof
|
|
15976
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15977
15977
|
throw this.unexpectedResponseError("build");
|
|
15978
15978
|
}
|
|
15979
15979
|
return readStringField(output.json, "build_id", "build");
|
|
15980
15980
|
}
|
|
15981
15981
|
async listBuilds() {
|
|
15982
15982
|
const output = await this.invoke("list_builds", {});
|
|
15983
|
-
if (!(output instanceof
|
|
15983
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
15984
15984
|
throw this.unexpectedResponseError("list_builds");
|
|
15985
15985
|
}
|
|
15986
15986
|
const buildsRaw = output.json["builds"];
|
|
@@ -16009,7 +16009,7 @@ ${err.toString()}`);
|
|
|
16009
16009
|
service_id: params.serviceId,
|
|
16010
16010
|
env: toStringMapList(params.env ?? {})
|
|
16011
16011
|
});
|
|
16012
|
-
if (!(output instanceof
|
|
16012
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
16013
16013
|
throw this.unexpectedResponseError("run_service");
|
|
16014
16014
|
}
|
|
16015
16015
|
return readStringField(output.json, "container_id", "run_service");
|
|
@@ -16028,21 +16028,21 @@ ${err.toString()}`);
|
|
|
16028
16028
|
input: session.inputStream()
|
|
16029
16029
|
}).then(async (stream) => {
|
|
16030
16030
|
for await (const chunk of stream) {
|
|
16031
|
-
if (chunk instanceof
|
|
16032
|
-
throw new
|
|
16031
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
16032
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
16033
16033
|
}
|
|
16034
|
-
if (chunk instanceof
|
|
16034
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
16035
16035
|
if (chunk.method === "close") {
|
|
16036
16036
|
break;
|
|
16037
16037
|
}
|
|
16038
16038
|
throw this.unexpectedResponseError("exec");
|
|
16039
16039
|
}
|
|
16040
|
-
if (!(chunk instanceof
|
|
16040
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
16041
16041
|
throw this.unexpectedResponseError("exec");
|
|
16042
16042
|
}
|
|
16043
16043
|
const channel = chunk.headers["channel"];
|
|
16044
16044
|
if (typeof channel !== "number") {
|
|
16045
|
-
throw new
|
|
16045
|
+
throw new room_server_client_js_1.RoomServerException("containers.exec returned a chunk without a valid channel");
|
|
16046
16046
|
}
|
|
16047
16047
|
if (channel === 1) {
|
|
16048
16048
|
session.addOutput(chunk.data);
|
|
@@ -16057,7 +16057,7 @@ ${err.toString()}`);
|
|
|
16057
16057
|
return;
|
|
16058
16058
|
}
|
|
16059
16059
|
}
|
|
16060
|
-
throw new
|
|
16060
|
+
throw new room_server_client_js_1.RoomServerException("containers.exec stream closed before a status was returned");
|
|
16061
16061
|
}).catch((error) => {
|
|
16062
16062
|
session.closeError(error);
|
|
16063
16063
|
});
|
|
@@ -16069,14 +16069,27 @@ ${err.toString()}`);
|
|
|
16069
16069
|
force: params.force ?? false
|
|
16070
16070
|
});
|
|
16071
16071
|
}
|
|
16072
|
-
async
|
|
16072
|
+
async waitForExitStatus(params) {
|
|
16073
16073
|
const output = await this.invoke("wait_for_exit", {
|
|
16074
16074
|
container_id: params.containerId
|
|
16075
16075
|
});
|
|
16076
|
-
if (!(output instanceof
|
|
16076
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
16077
16077
|
throw this.unexpectedResponseError("wait_for_exit");
|
|
16078
16078
|
}
|
|
16079
|
-
|
|
16079
|
+
const exitCode = readIntegerField(output.json, "exit_code", "wait_for_exit");
|
|
16080
|
+
const reason = output.json["reason"];
|
|
16081
|
+
const message2 = output.json["message"];
|
|
16082
|
+
const oomKilled = output.json["oom_killed"];
|
|
16083
|
+
return {
|
|
16084
|
+
exitCode,
|
|
16085
|
+
reason: typeof reason === "string" ? reason : void 0,
|
|
16086
|
+
message: typeof message2 === "string" ? message2 : void 0,
|
|
16087
|
+
oomKilled: typeof oomKilled === "boolean" ? oomKilled : void 0
|
|
16088
|
+
};
|
|
16089
|
+
}
|
|
16090
|
+
async waitForExit(params) {
|
|
16091
|
+
const status = await this.waitForExitStatus(params);
|
|
16092
|
+
return status.exitCode;
|
|
16080
16093
|
}
|
|
16081
16094
|
async deleteContainer(params) {
|
|
16082
16095
|
await this.invoke("delete_container", {
|
|
@@ -16085,10 +16098,10 @@ ${err.toString()}`);
|
|
|
16085
16098
|
}
|
|
16086
16099
|
logs(params) {
|
|
16087
16100
|
const requestId = (0, uuid_1.v4)();
|
|
16088
|
-
const closeInput = new
|
|
16089
|
-
const progressController = new
|
|
16090
|
-
const streamController = new
|
|
16091
|
-
const result = new
|
|
16101
|
+
const closeInput = new completer_js_1.Completer();
|
|
16102
|
+
const progressController = new stream_controller_js_1.StreamController();
|
|
16103
|
+
const streamController = new stream_controller_js_1.StreamController();
|
|
16104
|
+
const result = new completer_js_1.Completer();
|
|
16092
16105
|
let inputClosed = false;
|
|
16093
16106
|
const closeInputStream = () => {
|
|
16094
16107
|
if (inputClosed) {
|
|
@@ -16100,7 +16113,7 @@ ${err.toString()}`);
|
|
|
16100
16113
|
}
|
|
16101
16114
|
};
|
|
16102
16115
|
const inputStream = async function* () {
|
|
16103
|
-
yield new
|
|
16116
|
+
yield new response_js_1.BinaryContent({
|
|
16104
16117
|
data: new Uint8Array(0),
|
|
16105
16118
|
headers: {
|
|
16106
16119
|
kind: "start",
|
|
@@ -16117,10 +16130,10 @@ ${err.toString()}`);
|
|
|
16117
16130
|
input: inputStream()
|
|
16118
16131
|
}).then(async (stream) => {
|
|
16119
16132
|
for await (const chunk of stream) {
|
|
16120
|
-
if (chunk instanceof
|
|
16121
|
-
throw new
|
|
16133
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
16134
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
16122
16135
|
}
|
|
16123
|
-
if (chunk instanceof
|
|
16136
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
16124
16137
|
if (chunk.method === "close") {
|
|
16125
16138
|
closeInputStream();
|
|
16126
16139
|
progressController.close();
|
|
@@ -16132,12 +16145,12 @@ ${err.toString()}`);
|
|
|
16132
16145
|
}
|
|
16133
16146
|
throw this.unexpectedResponseError("logs");
|
|
16134
16147
|
}
|
|
16135
|
-
if (!(chunk instanceof
|
|
16148
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
16136
16149
|
throw this.unexpectedResponseError("logs");
|
|
16137
16150
|
}
|
|
16138
16151
|
const channel = chunk.headers["channel"];
|
|
16139
16152
|
if (typeof channel !== "number") {
|
|
16140
|
-
throw new
|
|
16153
|
+
throw new room_server_client_js_1.RoomServerException("containers.logs returned a chunk without a valid channel");
|
|
16141
16154
|
}
|
|
16142
16155
|
if (channel !== 1) {
|
|
16143
16156
|
continue;
|
|
@@ -16191,9 +16204,9 @@ ${err.toString()}`);
|
|
|
16191
16204
|
}
|
|
16192
16205
|
getBuildLogs(params) {
|
|
16193
16206
|
const requestId = (0, uuid_1.v4)();
|
|
16194
|
-
const closeInput = new
|
|
16195
|
-
const streamController = new
|
|
16196
|
-
const result = new
|
|
16207
|
+
const closeInput = new completer_js_1.Completer();
|
|
16208
|
+
const streamController = new stream_controller_js_1.StreamController();
|
|
16209
|
+
const result = new completer_js_1.Completer();
|
|
16197
16210
|
let inputClosed = false;
|
|
16198
16211
|
const closeInputStream = () => {
|
|
16199
16212
|
if (inputClosed) {
|
|
@@ -16205,7 +16218,7 @@ ${err.toString()}`);
|
|
|
16205
16218
|
}
|
|
16206
16219
|
};
|
|
16207
16220
|
const inputStream = async function* () {
|
|
16208
|
-
yield new
|
|
16221
|
+
yield new response_js_1.BinaryContent({
|
|
16209
16222
|
data: new Uint8Array(0),
|
|
16210
16223
|
headers: {
|
|
16211
16224
|
kind: "start",
|
|
@@ -16222,10 +16235,10 @@ ${err.toString()}`);
|
|
|
16222
16235
|
input: inputStream()
|
|
16223
16236
|
}).then(async (stream) => {
|
|
16224
16237
|
for await (const chunk of stream) {
|
|
16225
|
-
if (chunk instanceof
|
|
16226
|
-
throw new
|
|
16238
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
16239
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
16227
16240
|
}
|
|
16228
|
-
if (chunk instanceof
|
|
16241
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
16229
16242
|
if (chunk.method === "close") {
|
|
16230
16243
|
closeInputStream();
|
|
16231
16244
|
streamController.close();
|
|
@@ -16236,12 +16249,12 @@ ${err.toString()}`);
|
|
|
16236
16249
|
}
|
|
16237
16250
|
throw this.unexpectedResponseError("get_build_logs");
|
|
16238
16251
|
}
|
|
16239
|
-
if (!(chunk instanceof
|
|
16252
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
16240
16253
|
throw this.unexpectedResponseError("get_build_logs");
|
|
16241
16254
|
}
|
|
16242
16255
|
const channel = chunk.headers["channel"];
|
|
16243
16256
|
if (typeof channel !== "number") {
|
|
16244
|
-
throw new
|
|
16257
|
+
throw new room_server_client_js_1.RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
|
|
16245
16258
|
}
|
|
16246
16259
|
if (channel === 1) {
|
|
16247
16260
|
streamController.add(decodeUtf8(chunk.data, "get_build_logs"));
|
|
@@ -16302,7 +16315,7 @@ ${err.toString()}`);
|
|
|
16302
16315
|
const output = await this.invoke("list_containers", {
|
|
16303
16316
|
all: params?.all
|
|
16304
16317
|
});
|
|
16305
|
-
if (!(output instanceof
|
|
16318
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
16306
16319
|
throw this.unexpectedResponseError("list");
|
|
16307
16320
|
}
|
|
16308
16321
|
const containersRaw = output.json["containers"];
|
|
@@ -16328,8 +16341,11 @@ ${err.toString()}`);
|
|
|
16328
16341
|
throw this.unexpectedResponseError("list");
|
|
16329
16342
|
}
|
|
16330
16343
|
const nameRaw = entry["name"];
|
|
16344
|
+
const imageIdRaw = entry["image_id"];
|
|
16331
16345
|
const portsRaw = entry["ports"];
|
|
16332
16346
|
const serviceIdRaw = entry["service_id"];
|
|
16347
|
+
const statsRaw = entry["stats"];
|
|
16348
|
+
const exitStatusRaw = entry["exit_status"];
|
|
16333
16349
|
if (!Array.isArray(portsRaw) || !portsRaw.every((port) => {
|
|
16334
16350
|
if (!isRecord(port)) {
|
|
16335
16351
|
return false;
|
|
@@ -16342,9 +16358,38 @@ ${err.toString()}`);
|
|
|
16342
16358
|
containerPort: port["container_port"],
|
|
16343
16359
|
hostPort: port["host_port"]
|
|
16344
16360
|
}));
|
|
16361
|
+
let stats;
|
|
16362
|
+
if (isRecord(statsRaw)) {
|
|
16363
|
+
const cpuUsageNanoCores = statsRaw["cpu_usage_nano_cores"];
|
|
16364
|
+
const memoryUsageBytes = statsRaw["memory_usage_bytes"];
|
|
16365
|
+
const memoryWorkingSetBytes = statsRaw["memory_working_set_bytes"];
|
|
16366
|
+
const timestampNs = statsRaw["timestamp_ns"];
|
|
16367
|
+
stats = {
|
|
16368
|
+
cpuUsageNanoCores: typeof cpuUsageNanoCores === "number" ? cpuUsageNanoCores : void 0,
|
|
16369
|
+
memoryUsageBytes: typeof memoryUsageBytes === "number" ? memoryUsageBytes : void 0,
|
|
16370
|
+
memoryWorkingSetBytes: typeof memoryWorkingSetBytes === "number" ? memoryWorkingSetBytes : void 0,
|
|
16371
|
+
timestampNs: typeof timestampNs === "number" ? timestampNs : void 0
|
|
16372
|
+
};
|
|
16373
|
+
}
|
|
16374
|
+
let exitStatus;
|
|
16375
|
+
if (isRecord(exitStatusRaw)) {
|
|
16376
|
+
const exitCode = exitStatusRaw["exit_code"];
|
|
16377
|
+
if (typeof exitCode === "number" && Number.isInteger(exitCode)) {
|
|
16378
|
+
const reason = exitStatusRaw["reason"];
|
|
16379
|
+
const message2 = exitStatusRaw["message"];
|
|
16380
|
+
const oomKilled = exitStatusRaw["oom_killed"];
|
|
16381
|
+
exitStatus = {
|
|
16382
|
+
exitCode,
|
|
16383
|
+
reason: typeof reason === "string" ? reason : void 0,
|
|
16384
|
+
message: typeof message2 === "string" ? message2 : void 0,
|
|
16385
|
+
oomKilled: typeof oomKilled === "boolean" ? oomKilled : void 0
|
|
16386
|
+
};
|
|
16387
|
+
}
|
|
16388
|
+
}
|
|
16345
16389
|
items.push({
|
|
16346
16390
|
id,
|
|
16347
16391
|
image,
|
|
16392
|
+
imageId: typeof imageIdRaw === "string" ? imageIdRaw : void 0,
|
|
16348
16393
|
name: typeof nameRaw === "string" ? nameRaw : void 0,
|
|
16349
16394
|
ports,
|
|
16350
16395
|
startedBy: {
|
|
@@ -16353,7 +16398,9 @@ ${err.toString()}`);
|
|
|
16353
16398
|
},
|
|
16354
16399
|
state,
|
|
16355
16400
|
private: privateFlag,
|
|
16356
|
-
serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : void 0
|
|
16401
|
+
serviceId: typeof serviceIdRaw === "string" ? serviceIdRaw : void 0,
|
|
16402
|
+
stats,
|
|
16403
|
+
exitStatus
|
|
16357
16404
|
});
|
|
16358
16405
|
}
|
|
16359
16406
|
return items;
|
|
@@ -33047,8 +33094,8 @@ return true;`);
|
|
|
33047
33094
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33048
33095
|
exports.DatasetsClient = exports.DatasetUuid = exports.DatasetJson = exports.DatasetStruct = exports.DatasetDate = exports.DatasetExpression = exports.DatasetValueEncoder = void 0;
|
|
33049
33096
|
var apache_arrow_1 = require_Arrow_dom();
|
|
33050
|
-
var
|
|
33051
|
-
var
|
|
33097
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
33098
|
+
var response_js_1 = require_response();
|
|
33052
33099
|
var ARROW_IPC_STREAM_MIME_TYPE = "application/vnd.apache.arrow.stream";
|
|
33053
33100
|
var DatasetValueEncoder = class {
|
|
33054
33101
|
};
|
|
@@ -33133,7 +33180,7 @@ return true;`);
|
|
|
33133
33180
|
function normalizeUuidHex(value) {
|
|
33134
33181
|
const normalized = value.trim().toLowerCase().replace(/-/g, "");
|
|
33135
33182
|
if (!UUID_HEX_REGEX.test(normalized)) {
|
|
33136
|
-
throw new
|
|
33183
|
+
throw new room_server_client_js_1.RoomServerException("invalid uuid format");
|
|
33137
33184
|
}
|
|
33138
33185
|
return normalized;
|
|
33139
33186
|
}
|
|
@@ -33228,7 +33275,7 @@ return true;`);
|
|
|
33228
33275
|
};
|
|
33229
33276
|
}
|
|
33230
33277
|
if (isRecord(value)) {
|
|
33231
|
-
throw new
|
|
33278
|
+
throw new room_server_client_js_1.RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
|
|
33232
33279
|
}
|
|
33233
33280
|
return value;
|
|
33234
33281
|
}
|
|
@@ -33253,62 +33300,62 @@ return true;`);
|
|
|
33253
33300
|
}
|
|
33254
33301
|
function decodeRecordValue(value) {
|
|
33255
33302
|
if (Array.isArray(value)) {
|
|
33256
|
-
throw new
|
|
33303
|
+
throw new room_server_client_js_1.RoomServerException("dataset list values must use a {'list': [...]} wrapper");
|
|
33257
33304
|
}
|
|
33258
33305
|
if (!isRecord(value)) {
|
|
33259
33306
|
return value;
|
|
33260
33307
|
}
|
|
33261
33308
|
const entries = Object.entries(value);
|
|
33262
33309
|
if (entries.length !== 1) {
|
|
33263
|
-
throw new
|
|
33310
|
+
throw new room_server_client_js_1.RoomServerException("dataset object values must use a single-key type wrapper");
|
|
33264
33311
|
}
|
|
33265
33312
|
const [wrapper, payload] = entries[0];
|
|
33266
33313
|
switch (wrapper) {
|
|
33267
33314
|
case "binary":
|
|
33268
33315
|
if (typeof payload !== "string") {
|
|
33269
|
-
throw new
|
|
33316
|
+
throw new room_server_client_js_1.RoomServerException("dataset binary values must be base64 strings");
|
|
33270
33317
|
}
|
|
33271
33318
|
return base64ToBytes(payload);
|
|
33272
33319
|
case "uuid":
|
|
33273
33320
|
if (typeof payload !== "string") {
|
|
33274
|
-
throw new
|
|
33321
|
+
throw new room_server_client_js_1.RoomServerException("dataset uuid values must be strings");
|
|
33275
33322
|
}
|
|
33276
33323
|
return new DatasetUuid(payload);
|
|
33277
33324
|
case "expression":
|
|
33278
33325
|
if (typeof payload !== "string") {
|
|
33279
|
-
throw new
|
|
33326
|
+
throw new room_server_client_js_1.RoomServerException("dataset expression values must be strings");
|
|
33280
33327
|
}
|
|
33281
33328
|
return new DatasetExpression(payload);
|
|
33282
33329
|
case "date":
|
|
33283
33330
|
if (typeof payload !== "string") {
|
|
33284
|
-
throw new
|
|
33331
|
+
throw new room_server_client_js_1.RoomServerException("dataset date values must be strings");
|
|
33285
33332
|
}
|
|
33286
33333
|
return new DatasetDate(payload);
|
|
33287
33334
|
case "timestamp":
|
|
33288
33335
|
if (typeof payload !== "string") {
|
|
33289
|
-
throw new
|
|
33336
|
+
throw new room_server_client_js_1.RoomServerException("dataset timestamp values must be strings");
|
|
33290
33337
|
}
|
|
33291
33338
|
{
|
|
33292
33339
|
const parsed = new Date(payload);
|
|
33293
33340
|
if (Number.isNaN(parsed.getTime())) {
|
|
33294
|
-
throw new
|
|
33341
|
+
throw new room_server_client_js_1.RoomServerException("dataset timestamp value is not valid");
|
|
33295
33342
|
}
|
|
33296
33343
|
return parsed;
|
|
33297
33344
|
}
|
|
33298
33345
|
case "list":
|
|
33299
33346
|
if (!Array.isArray(payload)) {
|
|
33300
|
-
throw new
|
|
33347
|
+
throw new room_server_client_js_1.RoomServerException("dataset list values must be arrays");
|
|
33301
33348
|
}
|
|
33302
33349
|
return payload.map((item) => decodeRecordValue(item));
|
|
33303
33350
|
case "struct":
|
|
33304
33351
|
if (!isRecord(payload)) {
|
|
33305
|
-
throw new
|
|
33352
|
+
throw new room_server_client_js_1.RoomServerException("dataset struct values must be objects");
|
|
33306
33353
|
}
|
|
33307
33354
|
return new DatasetStruct(Object.fromEntries(Object.entries(payload).map(([key, item]) => [key, decodeRecordValue(item)])));
|
|
33308
33355
|
case "json":
|
|
33309
33356
|
return new DatasetJson(normalizeDatasetJsonValue(payload));
|
|
33310
33357
|
default:
|
|
33311
|
-
throw new
|
|
33358
|
+
throw new room_server_client_js_1.RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
|
|
33312
33359
|
}
|
|
33313
33360
|
}
|
|
33314
33361
|
function rowsChunk(records) {
|
|
@@ -33324,27 +33371,27 @@ return true;`);
|
|
|
33324
33371
|
}
|
|
33325
33372
|
function recordsFromRowsChunk(payload, operation) {
|
|
33326
33373
|
if (!isRecord(payload) || payload.kind !== "rows" || !Array.isArray(payload.rows)) {
|
|
33327
|
-
throw new
|
|
33374
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33328
33375
|
}
|
|
33329
33376
|
return payload.rows.map((row) => {
|
|
33330
33377
|
if (!isRecord(row) || !Array.isArray(row.columns)) {
|
|
33331
|
-
throw new
|
|
33378
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33332
33379
|
}
|
|
33333
33380
|
return Object.fromEntries(row.columns.map((column) => {
|
|
33334
33381
|
if (!isRecord(column) || typeof column.name !== "string") {
|
|
33335
|
-
throw new
|
|
33382
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33336
33383
|
}
|
|
33337
33384
|
try {
|
|
33338
33385
|
return [column.name, decodeRecordValue(column.value)];
|
|
33339
33386
|
} catch {
|
|
33340
|
-
throw new
|
|
33387
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33341
33388
|
}
|
|
33342
33389
|
}));
|
|
33343
33390
|
});
|
|
33344
33391
|
}
|
|
33345
33392
|
function rowChunkList(records, rowsPerChunk = 128) {
|
|
33346
33393
|
if (rowsPerChunk <= 0) {
|
|
33347
|
-
throw new
|
|
33394
|
+
throw new room_server_client_js_1.RoomServerException("rowsPerChunk must be greater than zero");
|
|
33348
33395
|
}
|
|
33349
33396
|
const chunks = [];
|
|
33350
33397
|
for (let index = 0; index < records.length; index += rowsPerChunk) {
|
|
@@ -33377,14 +33424,14 @@ return true;`);
|
|
|
33377
33424
|
}
|
|
33378
33425
|
function tableIndexFromJson(value) {
|
|
33379
33426
|
if (!isRecord(value) || typeof value.name !== "string" || typeof value.type !== "string" || !Array.isArray(value.columns)) {
|
|
33380
|
-
throw new
|
|
33427
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_indexes");
|
|
33381
33428
|
}
|
|
33382
33429
|
return {
|
|
33383
33430
|
name: value.name,
|
|
33384
33431
|
type: value.type,
|
|
33385
33432
|
columns: value.columns.map((column) => {
|
|
33386
33433
|
if (typeof column !== "string") {
|
|
33387
|
-
throw new
|
|
33434
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_indexes");
|
|
33388
33435
|
}
|
|
33389
33436
|
return column;
|
|
33390
33437
|
}),
|
|
@@ -33399,7 +33446,7 @@ return true;`);
|
|
|
33399
33446
|
}
|
|
33400
33447
|
function optimizeResultFromJson(value) {
|
|
33401
33448
|
if (!isRecord(value)) {
|
|
33402
|
-
throw new
|
|
33449
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.optimize");
|
|
33403
33450
|
}
|
|
33404
33451
|
return {
|
|
33405
33452
|
compaction: typeof value.compaction_json === "string" ? JSON.parse(value.compaction_json) : isRecord(value.compaction) ? value.compaction : null,
|
|
@@ -33409,31 +33456,31 @@ return true;`);
|
|
|
33409
33456
|
}
|
|
33410
33457
|
function tableStatsFromJson(value) {
|
|
33411
33458
|
if (!isRecord(value)) {
|
|
33412
|
-
throw new
|
|
33459
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.stats");
|
|
33413
33460
|
}
|
|
33414
33461
|
const dataset = typeof value.dataset_json === "string" ? JSON.parse(value.dataset_json) : value.dataset;
|
|
33415
33462
|
const data = typeof value.data_json === "string" ? JSON.parse(value.data_json) : value.data;
|
|
33416
33463
|
if (!isRecord(dataset) || !isRecord(data)) {
|
|
33417
|
-
throw new
|
|
33464
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.stats");
|
|
33418
33465
|
}
|
|
33419
33466
|
return { dataset, data };
|
|
33420
33467
|
}
|
|
33421
33468
|
function tableVersionFromJson(value) {
|
|
33422
33469
|
if (!isRecord(value) || typeof value.metadata_json !== "string" || typeof value.timestamp !== "string" || typeof value.version !== "number") {
|
|
33423
|
-
throw new
|
|
33470
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33424
33471
|
}
|
|
33425
33472
|
const timestamp = new Date(value.timestamp);
|
|
33426
33473
|
if (Number.isNaN(timestamp.getTime())) {
|
|
33427
|
-
throw new
|
|
33474
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33428
33475
|
}
|
|
33429
33476
|
let metadata;
|
|
33430
33477
|
try {
|
|
33431
33478
|
metadata = JSON.parse(value.metadata_json);
|
|
33432
33479
|
} catch (_) {
|
|
33433
|
-
throw new
|
|
33480
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33434
33481
|
}
|
|
33435
33482
|
if (!isRecord(metadata)) {
|
|
33436
|
-
throw new
|
|
33483
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33437
33484
|
}
|
|
33438
33485
|
return {
|
|
33439
33486
|
version: value.version,
|
|
@@ -33443,25 +33490,25 @@ return true;`);
|
|
|
33443
33490
|
}
|
|
33444
33491
|
function tableBranchFromJson(value) {
|
|
33445
33492
|
if (!isRecord(value) || typeof value.name !== "string") {
|
|
33446
|
-
throw new
|
|
33493
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33447
33494
|
}
|
|
33448
33495
|
if (value.parent_branch != null && typeof value.parent_branch !== "string") {
|
|
33449
|
-
throw new
|
|
33496
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33450
33497
|
}
|
|
33451
33498
|
if (value.parent_version != null && (typeof value.parent_version !== "number" || !Number.isInteger(value.parent_version))) {
|
|
33452
|
-
throw new
|
|
33499
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33453
33500
|
}
|
|
33454
33501
|
if (value.manifest_size != null && (typeof value.manifest_size !== "number" || !Number.isInteger(value.manifest_size))) {
|
|
33455
|
-
throw new
|
|
33502
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33456
33503
|
}
|
|
33457
33504
|
let createdAt = null;
|
|
33458
33505
|
if (value.created_at != null) {
|
|
33459
33506
|
if (typeof value.created_at !== "string") {
|
|
33460
|
-
throw new
|
|
33507
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33461
33508
|
}
|
|
33462
33509
|
createdAt = new Date(value.created_at);
|
|
33463
33510
|
if (Number.isNaN(createdAt.getTime())) {
|
|
33464
|
-
throw new
|
|
33511
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33465
33512
|
}
|
|
33466
33513
|
}
|
|
33467
33514
|
return {
|
|
@@ -33527,7 +33574,7 @@ return true;`);
|
|
|
33527
33574
|
});
|
|
33528
33575
|
}
|
|
33529
33576
|
async *stream() {
|
|
33530
|
-
yield new
|
|
33577
|
+
yield new response_js_1.JsonContent({ json: this.start });
|
|
33531
33578
|
while (!this.closed) {
|
|
33532
33579
|
await this.waitForPull();
|
|
33533
33580
|
if (this.closed) {
|
|
@@ -33540,7 +33587,7 @@ return true;`);
|
|
|
33540
33587
|
if (nextChunk.value.length === 0) {
|
|
33541
33588
|
continue;
|
|
33542
33589
|
}
|
|
33543
|
-
yield new
|
|
33590
|
+
yield new response_js_1.JsonContent({ json: rowsChunk(nextChunk.value) });
|
|
33544
33591
|
}
|
|
33545
33592
|
}
|
|
33546
33593
|
};
|
|
@@ -33561,7 +33608,7 @@ return true;`);
|
|
|
33561
33608
|
function tableFromIPCBytes(data) {
|
|
33562
33609
|
const table = (0, apache_arrow_1.tableFromIPC)(data);
|
|
33563
33610
|
if (table instanceof Promise) {
|
|
33564
|
-
throw new
|
|
33611
|
+
throw new room_server_client_js_1.RoomServerException("unexpected async Arrow IPC result");
|
|
33565
33612
|
}
|
|
33566
33613
|
return table;
|
|
33567
33614
|
}
|
|
@@ -33619,7 +33666,7 @@ return true;`);
|
|
|
33619
33666
|
});
|
|
33620
33667
|
}
|
|
33621
33668
|
async *stream() {
|
|
33622
|
-
yield new
|
|
33669
|
+
yield new response_js_1.BinaryContent({
|
|
33623
33670
|
data: this.schema == null ? new Uint8Array() : schemaToIPC(this.schema),
|
|
33624
33671
|
headers: this.start
|
|
33625
33672
|
});
|
|
@@ -33635,7 +33682,7 @@ return true;`);
|
|
|
33635
33682
|
if (nextChunk.value.numRows === 0) {
|
|
33636
33683
|
continue;
|
|
33637
33684
|
}
|
|
33638
|
-
yield new
|
|
33685
|
+
yield new response_js_1.BinaryContent({
|
|
33639
33686
|
data: (0, apache_arrow_1.tableToIPC)(nextChunk.value, "stream"),
|
|
33640
33687
|
headers: { kind: "data", content_type: ARROW_IPC_STREAM_MIME_TYPE }
|
|
33641
33688
|
});
|
|
@@ -33683,13 +33730,13 @@ return true;`);
|
|
|
33683
33730
|
});
|
|
33684
33731
|
}
|
|
33685
33732
|
async *stream() {
|
|
33686
|
-
yield new
|
|
33733
|
+
yield new response_js_1.JsonContent({ json: this.start });
|
|
33687
33734
|
while (!this.closed) {
|
|
33688
33735
|
await this.waitForPull();
|
|
33689
33736
|
if (this.closed) {
|
|
33690
33737
|
return;
|
|
33691
33738
|
}
|
|
33692
|
-
yield new
|
|
33739
|
+
yield new response_js_1.JsonContent({ json: { kind: "pull" } });
|
|
33693
33740
|
}
|
|
33694
33741
|
}
|
|
33695
33742
|
};
|
|
@@ -33734,13 +33781,13 @@ return true;`);
|
|
|
33734
33781
|
});
|
|
33735
33782
|
}
|
|
33736
33783
|
async *stream() {
|
|
33737
|
-
yield new
|
|
33784
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: this.start });
|
|
33738
33785
|
while (!this.closed) {
|
|
33739
33786
|
await this.waitForPull();
|
|
33740
33787
|
if (this.closed) {
|
|
33741
33788
|
return;
|
|
33742
33789
|
}
|
|
33743
|
-
yield new
|
|
33790
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
|
|
33744
33791
|
}
|
|
33745
33792
|
}
|
|
33746
33793
|
};
|
|
@@ -33749,11 +33796,11 @@ return true;`);
|
|
|
33749
33796
|
this.room = room;
|
|
33750
33797
|
}
|
|
33751
33798
|
_unexpectedResponseError(operation) {
|
|
33752
|
-
return new
|
|
33799
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33753
33800
|
}
|
|
33754
33801
|
async invoke(operation, input) {
|
|
33755
33802
|
const response = await this.room.invoke({ toolkit: "dataset", tool: operation, input });
|
|
33756
|
-
if (response instanceof
|
|
33803
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
33757
33804
|
return response;
|
|
33758
33805
|
}
|
|
33759
33806
|
if (response == null) {
|
|
@@ -33771,23 +33818,23 @@ return true;`);
|
|
|
33771
33818
|
const response = await this.invokeStream(operation, input.stream());
|
|
33772
33819
|
try {
|
|
33773
33820
|
for await (const chunk of response) {
|
|
33774
|
-
if (chunk instanceof
|
|
33775
|
-
throw new
|
|
33821
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
33822
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
33776
33823
|
}
|
|
33777
|
-
if (chunk instanceof
|
|
33824
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
33778
33825
|
if (chunk.method === "close") {
|
|
33779
33826
|
return;
|
|
33780
33827
|
}
|
|
33781
33828
|
throw this._unexpectedResponseError(operation);
|
|
33782
33829
|
}
|
|
33783
|
-
if (chunk instanceof
|
|
33830
|
+
if (chunk instanceof response_js_1.BinaryContent) {
|
|
33784
33831
|
if (chunk.headers.kind !== "pull") {
|
|
33785
33832
|
throw this._unexpectedResponseError(operation);
|
|
33786
33833
|
}
|
|
33787
33834
|
input.requestNext();
|
|
33788
33835
|
continue;
|
|
33789
33836
|
}
|
|
33790
|
-
if (!(chunk instanceof
|
|
33837
|
+
if (!(chunk instanceof response_js_1.JsonContent) || chunk.json.kind !== "pull") {
|
|
33791
33838
|
throw this._unexpectedResponseError(operation);
|
|
33792
33839
|
}
|
|
33793
33840
|
input.requestNext();
|
|
@@ -33802,16 +33849,16 @@ return true;`);
|
|
|
33802
33849
|
input.requestNext();
|
|
33803
33850
|
try {
|
|
33804
33851
|
for await (const chunk of response) {
|
|
33805
|
-
if (chunk instanceof
|
|
33806
|
-
throw new
|
|
33852
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
33853
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
33807
33854
|
}
|
|
33808
|
-
if (chunk instanceof
|
|
33855
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
33809
33856
|
if (chunk.method === "close") {
|
|
33810
33857
|
return;
|
|
33811
33858
|
}
|
|
33812
33859
|
throw this._unexpectedResponseError(operation);
|
|
33813
33860
|
}
|
|
33814
|
-
if (!(chunk instanceof
|
|
33861
|
+
if (!(chunk instanceof response_js_1.JsonContent)) {
|
|
33815
33862
|
throw this._unexpectedResponseError(operation);
|
|
33816
33863
|
}
|
|
33817
33864
|
yield recordsFromRowsChunk(chunk.json, operation);
|
|
@@ -33827,16 +33874,16 @@ return true;`);
|
|
|
33827
33874
|
input.requestNext();
|
|
33828
33875
|
try {
|
|
33829
33876
|
for await (const chunk of response) {
|
|
33830
|
-
if (chunk instanceof
|
|
33831
|
-
throw new
|
|
33877
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
33878
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
33832
33879
|
}
|
|
33833
|
-
if (chunk instanceof
|
|
33880
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
33834
33881
|
if (chunk.method === "close") {
|
|
33835
33882
|
return;
|
|
33836
33883
|
}
|
|
33837
33884
|
throw this._unexpectedResponseError(operation);
|
|
33838
33885
|
}
|
|
33839
|
-
if (!(chunk instanceof
|
|
33886
|
+
if (!(chunk instanceof response_js_1.BinaryContent) || chunk.headers.kind !== "data") {
|
|
33840
33887
|
throw this._unexpectedResponseError(operation);
|
|
33841
33888
|
}
|
|
33842
33889
|
yield tableFromIPCBytes(chunk.data);
|
|
@@ -33851,7 +33898,7 @@ return true;`);
|
|
|
33851
33898
|
namespace: namespace ?? null,
|
|
33852
33899
|
branch: branch ?? null
|
|
33853
33900
|
});
|
|
33854
|
-
if (!(response instanceof
|
|
33901
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
33855
33902
|
throw this._unexpectedResponseError("list_tables");
|
|
33856
33903
|
}
|
|
33857
33904
|
return Array.isArray(response.json.tables) ? response.json.tables : [];
|
|
@@ -33998,7 +34045,7 @@ return true;`);
|
|
|
33998
34045
|
}
|
|
33999
34046
|
async addColumns({ table, newColumns, namespace, branch }) {
|
|
34000
34047
|
if (newColumns instanceof apache_arrow_1.Schema) {
|
|
34001
|
-
await this.invokeContent("add_columns", new
|
|
34048
|
+
await this.invokeContent("add_columns", new response_js_1.BinaryContent({
|
|
34002
34049
|
data: schemaToIPC(newColumns),
|
|
34003
34050
|
headers: {
|
|
34004
34051
|
table,
|
|
@@ -34089,7 +34136,7 @@ return true;`);
|
|
|
34089
34136
|
return tableFromChunks(await this.sql({ query, tables, params, namespace, branch }));
|
|
34090
34137
|
}
|
|
34091
34138
|
async openSqlQuery({ query, tables, params, namespace, branch }) {
|
|
34092
|
-
const response = await this.invokeContent("open_sql_query", new
|
|
34139
|
+
const response = await this.invokeContent("open_sql_query", new response_js_1.BinaryContent({
|
|
34093
34140
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
34094
34141
|
headers: {
|
|
34095
34142
|
query,
|
|
@@ -34098,7 +34145,7 @@ return true;`);
|
|
|
34098
34145
|
branch: branch ?? null
|
|
34099
34146
|
}
|
|
34100
34147
|
}));
|
|
34101
|
-
if (!(response instanceof
|
|
34148
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
34102
34149
|
throw this._unexpectedResponseError("open_sql_query");
|
|
34103
34150
|
}
|
|
34104
34151
|
const queryId = response.headers.query_id;
|
|
@@ -34112,7 +34159,7 @@ return true;`);
|
|
|
34112
34159
|
};
|
|
34113
34160
|
}
|
|
34114
34161
|
async executeSql({ query, tables, params, namespace, branch }) {
|
|
34115
|
-
const response = await this.invokeContent("execute_sql", new
|
|
34162
|
+
const response = await this.invokeContent("execute_sql", new response_js_1.BinaryContent({
|
|
34116
34163
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
34117
34164
|
headers: {
|
|
34118
34165
|
query,
|
|
@@ -34121,7 +34168,7 @@ return true;`);
|
|
|
34121
34168
|
branch: branch ?? null
|
|
34122
34169
|
}
|
|
34123
34170
|
}));
|
|
34124
|
-
if (response instanceof
|
|
34171
|
+
if (response instanceof response_js_1.BinaryContent) {
|
|
34125
34172
|
if (response.headers.kind !== "query") {
|
|
34126
34173
|
throw this._unexpectedResponseError("execute_sql");
|
|
34127
34174
|
}
|
|
@@ -34135,7 +34182,7 @@ return true;`);
|
|
|
34135
34182
|
queryId
|
|
34136
34183
|
};
|
|
34137
34184
|
}
|
|
34138
|
-
if (response instanceof
|
|
34185
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
34139
34186
|
if (response.json.kind !== "statement" || typeof response.json.rows_affected !== "number" || !Number.isInteger(response.json.rows_affected)) {
|
|
34140
34187
|
throw this._unexpectedResponseError("execute_sql");
|
|
34141
34188
|
}
|
|
@@ -34149,7 +34196,7 @@ return true;`);
|
|
|
34149
34196
|
async *sqlStream({ query, tables, params, namespace, branch }) {
|
|
34150
34197
|
const result = await this.executeSql({ query, tables, params, namespace, branch });
|
|
34151
34198
|
if (result.kind === "statement") {
|
|
34152
|
-
throw new
|
|
34199
|
+
throw new room_server_client_js_1.RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
|
|
34153
34200
|
}
|
|
34154
34201
|
const opened = result;
|
|
34155
34202
|
try {
|
|
@@ -34166,19 +34213,19 @@ return true;`);
|
|
|
34166
34213
|
}
|
|
34167
34214
|
async closeSqlQuery({ queryId }) {
|
|
34168
34215
|
const response = await this.room.invoke({ toolkit: "dataset", tool: "close_sql_query", input: { query_id: queryId } });
|
|
34169
|
-
if (!(response instanceof
|
|
34216
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
34170
34217
|
throw this._unexpectedResponseError("close_sql_query");
|
|
34171
34218
|
}
|
|
34172
34219
|
}
|
|
34173
34220
|
async cancelSqlQuery({ queryId }) {
|
|
34174
34221
|
const response = await this.room.invoke({ toolkit: "dataset", tool: "cancel_sql_query", input: { query_id: queryId } });
|
|
34175
|
-
if (!(response instanceof
|
|
34222
|
+
if (!(response instanceof response_js_1.JsonContent) || !["cancelled", "cancelling", "not_cancellable"].includes(response.json.status)) {
|
|
34176
34223
|
throw this._unexpectedResponseError("cancel_sql_query");
|
|
34177
34224
|
}
|
|
34178
34225
|
return { status: response.json.status };
|
|
34179
34226
|
}
|
|
34180
34227
|
async executeSqlStatement({ query, tables, params, namespace, branch }) {
|
|
34181
|
-
const response = await this.invokeContent("execute_sql_statement", new
|
|
34228
|
+
const response = await this.invokeContent("execute_sql_statement", new response_js_1.BinaryContent({
|
|
34182
34229
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
34183
34230
|
headers: {
|
|
34184
34231
|
query,
|
|
@@ -34187,7 +34234,7 @@ return true;`);
|
|
|
34187
34234
|
branch: branch ?? null
|
|
34188
34235
|
}
|
|
34189
34236
|
}));
|
|
34190
|
-
if (!(response instanceof
|
|
34237
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.rows_affected !== "number" || !Number.isInteger(response.json.rows_affected)) {
|
|
34191
34238
|
throw this._unexpectedResponseError("execute_sql_statement");
|
|
34192
34239
|
}
|
|
34193
34240
|
return response.json.rows_affected;
|
|
@@ -34252,16 +34299,16 @@ return true;`);
|
|
|
34252
34299
|
input.requestNext();
|
|
34253
34300
|
try {
|
|
34254
34301
|
for await (const chunk of response) {
|
|
34255
|
-
if (chunk instanceof
|
|
34256
|
-
throw new
|
|
34302
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
34303
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
34257
34304
|
}
|
|
34258
|
-
if (chunk instanceof
|
|
34305
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
34259
34306
|
if (chunk.method === "close") {
|
|
34260
34307
|
return;
|
|
34261
34308
|
}
|
|
34262
34309
|
throw this._unexpectedResponseError("watch_table");
|
|
34263
34310
|
}
|
|
34264
|
-
if (chunk instanceof
|
|
34311
|
+
if (chunk instanceof response_js_1.BinaryContent) {
|
|
34265
34312
|
if (chunk.headers.kind !== "data") {
|
|
34266
34313
|
throw this._unexpectedResponseError("watch_table");
|
|
34267
34314
|
}
|
|
@@ -34279,7 +34326,7 @@ return true;`);
|
|
|
34279
34326
|
input.requestNext();
|
|
34280
34327
|
continue;
|
|
34281
34328
|
}
|
|
34282
|
-
if (chunk instanceof
|
|
34329
|
+
if (chunk instanceof response_js_1.JsonContent) {
|
|
34283
34330
|
if (!isRecord(chunk.json)) {
|
|
34284
34331
|
throw this._unexpectedResponseError("watch_table");
|
|
34285
34332
|
}
|
|
@@ -34315,7 +34362,7 @@ return true;`);
|
|
|
34315
34362
|
branch: branch ?? null,
|
|
34316
34363
|
version: version2 ?? null
|
|
34317
34364
|
});
|
|
34318
|
-
if (!(response instanceof
|
|
34365
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
|
|
34319
34366
|
throw this._unexpectedResponseError("count");
|
|
34320
34367
|
}
|
|
34321
34368
|
return response.json.count;
|
|
@@ -34331,7 +34378,7 @@ return true;`);
|
|
|
34331
34378
|
version: version2 ?? null
|
|
34332
34379
|
}
|
|
34333
34380
|
});
|
|
34334
|
-
if (!(response instanceof
|
|
34381
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
34335
34382
|
throw this._unexpectedResponseError("inspect");
|
|
34336
34383
|
}
|
|
34337
34384
|
return tableFromIPCBytes(response.data).schema;
|
|
@@ -34347,7 +34394,7 @@ return true;`);
|
|
|
34347
34394
|
branch: branch ?? null,
|
|
34348
34395
|
config: config ?? null
|
|
34349
34396
|
});
|
|
34350
|
-
if (!(response instanceof
|
|
34397
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
34351
34398
|
throw this._unexpectedResponseError("optimize");
|
|
34352
34399
|
}
|
|
34353
34400
|
return optimizeResultFromJson(response.json);
|
|
@@ -34360,7 +34407,7 @@ return true;`);
|
|
|
34360
34407
|
version: version2 ?? null,
|
|
34361
34408
|
max_rows_per_group: maxRowsPerGroup ?? null
|
|
34362
34409
|
});
|
|
34363
|
-
if (!(response instanceof
|
|
34410
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
34364
34411
|
throw this._unexpectedResponseError("stats");
|
|
34365
34412
|
}
|
|
34366
34413
|
return tableStatsFromJson(response.json);
|
|
@@ -34378,7 +34425,7 @@ return true;`);
|
|
|
34378
34425
|
namespace: namespace ?? null,
|
|
34379
34426
|
branch: branch ?? null
|
|
34380
34427
|
});
|
|
34381
|
-
if (!(response instanceof
|
|
34428
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.versions)) {
|
|
34382
34429
|
throw this._unexpectedResponseError("list_versions");
|
|
34383
34430
|
}
|
|
34384
34431
|
return response.json.versions.map((version2) => tableVersionFromJson(version2));
|
|
@@ -34397,7 +34444,7 @@ return true;`);
|
|
|
34397
34444
|
branch: branch ?? null,
|
|
34398
34445
|
version: version2 ?? null
|
|
34399
34446
|
});
|
|
34400
|
-
if (!(response instanceof
|
|
34447
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.indexes)) {
|
|
34401
34448
|
throw this._unexpectedResponseError("list_indexes");
|
|
34402
34449
|
}
|
|
34403
34450
|
return response.json.indexes.map((index) => tableIndexFromJson(index));
|
|
@@ -34406,7 +34453,7 @@ return true;`);
|
|
|
34406
34453
|
const response = await this.invoke("list_branches", {
|
|
34407
34454
|
namespace: namespace ?? null
|
|
34408
34455
|
});
|
|
34409
|
-
if (!(response instanceof
|
|
34456
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.branches)) {
|
|
34410
34457
|
throw this._unexpectedResponseError("list_branches");
|
|
34411
34458
|
}
|
|
34412
34459
|
return response.json.branches.map((branch) => tableBranchFromJson(branch));
|
|
@@ -34440,18 +34487,18 @@ return true;`);
|
|
|
34440
34487
|
"use strict";
|
|
34441
34488
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34442
34489
|
exports.DeveloperClient = void 0;
|
|
34443
|
-
var
|
|
34444
|
-
var
|
|
34445
|
-
var
|
|
34446
|
-
var
|
|
34447
|
-
var DeveloperClient = class extends
|
|
34490
|
+
var event_emitter_js_1 = require_event_emitter();
|
|
34491
|
+
var response_js_1 = require_response();
|
|
34492
|
+
var utils_js_1 = require_utils();
|
|
34493
|
+
var room_event_js_1 = require_room_event();
|
|
34494
|
+
var DeveloperClient = class extends event_emitter_js_1.EventEmitter {
|
|
34448
34495
|
constructor({ room }) {
|
|
34449
34496
|
super();
|
|
34450
34497
|
this.client = room;
|
|
34451
34498
|
this.client.protocol.addHandler("developer.log", this._handleDeveloperLog.bind(this));
|
|
34452
34499
|
}
|
|
34453
34500
|
_emitDeveloperLog(type, data) {
|
|
34454
|
-
const event = new
|
|
34501
|
+
const event = new room_event_js_1.RoomLogEvent({ type, data });
|
|
34455
34502
|
this.client.emit(event);
|
|
34456
34503
|
this.emit("log", event);
|
|
34457
34504
|
}
|
|
@@ -34459,7 +34506,7 @@ return true;`);
|
|
|
34459
34506
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
34460
34507
|
return;
|
|
34461
34508
|
}
|
|
34462
|
-
const [rawJson, _] = (0,
|
|
34509
|
+
const [rawJson, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
34463
34510
|
this._emitDeveloperLog(rawJson["type"], rawJson["data"]);
|
|
34464
34511
|
}
|
|
34465
34512
|
async log(type, data) {
|
|
@@ -34484,16 +34531,16 @@ return true;`);
|
|
|
34484
34531
|
});
|
|
34485
34532
|
try {
|
|
34486
34533
|
for await (const chunk of stream) {
|
|
34487
|
-
if (chunk instanceof
|
|
34534
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
34488
34535
|
throw new Error(chunk.text);
|
|
34489
34536
|
}
|
|
34490
|
-
if (chunk instanceof
|
|
34537
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
34491
34538
|
if (chunk.method === "close") {
|
|
34492
34539
|
return;
|
|
34493
34540
|
}
|
|
34494
34541
|
throw new Error("unexpected return type from developer.logs");
|
|
34495
34542
|
}
|
|
34496
|
-
if (!(chunk instanceof
|
|
34543
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
34497
34544
|
throw new Error("unexpected return type from developer.logs");
|
|
34498
34545
|
}
|
|
34499
34546
|
const logType = chunk.headers["type"];
|
|
@@ -34504,7 +34551,7 @@ return true;`);
|
|
|
34504
34551
|
if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) {
|
|
34505
34552
|
throw new Error("developer.logs returned invalid JSON data");
|
|
34506
34553
|
}
|
|
34507
|
-
const event = new
|
|
34554
|
+
const event = new room_event_js_1.RoomLogEvent({ type: logType, data: decoded });
|
|
34508
34555
|
this.client.emit(event);
|
|
34509
34556
|
this.emit("log", event);
|
|
34510
34557
|
yield event;
|
|
@@ -39258,6 +39305,9 @@ ${newlined}
|
|
|
39258
39305
|
var require_api_keys = __commonJS({
|
|
39259
39306
|
"../meshagent-ts/dist/browser/api_keys.js"(exports) {
|
|
39260
39307
|
"use strict";
|
|
39308
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
39309
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39310
|
+
};
|
|
39261
39311
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39262
39312
|
exports.base36Encode = base36Encode;
|
|
39263
39313
|
exports.base36Decode = base36Decode;
|
|
@@ -39267,7 +39317,8 @@ ${newlined}
|
|
|
39267
39317
|
exports.base64DecompressUuid = base64DecompressUuid;
|
|
39268
39318
|
exports.parseApiKey = parseApiKey;
|
|
39269
39319
|
exports.encodeApiKey = encodeApiKey;
|
|
39270
|
-
var base_64_1 = require_base64();
|
|
39320
|
+
var base_64_1 = __importDefault(require_base64());
|
|
39321
|
+
var { encode: base64Encode, decode: base64Decode } = base_64_1.default;
|
|
39271
39322
|
var BASE36_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
39272
39323
|
var BASE36 = 36n;
|
|
39273
39324
|
var UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
|
|
@@ -39350,7 +39401,7 @@ ${newlined}
|
|
|
39350
39401
|
if (globalScope.btoa) {
|
|
39351
39402
|
return globalScope.btoa(binary);
|
|
39352
39403
|
}
|
|
39353
|
-
return (
|
|
39404
|
+
return base64Encode(binary);
|
|
39354
39405
|
}
|
|
39355
39406
|
function base64ToBytes(base64) {
|
|
39356
39407
|
if (globalScope.Buffer) {
|
|
@@ -39361,7 +39412,7 @@ ${newlined}
|
|
|
39361
39412
|
if (globalScope.atob) {
|
|
39362
39413
|
binary = globalScope.atob(base64);
|
|
39363
39414
|
} else {
|
|
39364
|
-
binary = (
|
|
39415
|
+
binary = base64Decode(base64);
|
|
39365
39416
|
}
|
|
39366
39417
|
const bytes = new Uint8Array(binary.length);
|
|
39367
39418
|
for (let i = 0; i < binary.length; i += 1) {
|
|
@@ -39450,8 +39501,8 @@ ${newlined}
|
|
|
39450
39501
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39451
39502
|
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.OAuthEndpoint = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.DatasetGrant = exports.TableGrant = exports.MessagingGrant = exports.QueuesGrant = exports.LivekitGrant = exports.AgentsGrant = void 0;
|
|
39452
39503
|
var jose_1 = (init_webapi(), __toCommonJS(webapi_exports));
|
|
39453
|
-
var
|
|
39454
|
-
var
|
|
39504
|
+
var api_keys_js_1 = require_api_keys();
|
|
39505
|
+
var version_js_1 = require_version();
|
|
39455
39506
|
function matchesGrantPattern(patterns, value, allowIfUnset) {
|
|
39456
39507
|
if (!patterns) {
|
|
39457
39508
|
return allowIfUnset;
|
|
@@ -40527,7 +40578,7 @@ ${newlined}
|
|
|
40527
40578
|
this.name = name;
|
|
40528
40579
|
this.projectId = projectId;
|
|
40529
40580
|
this.apiKeyId = apiKeyId;
|
|
40530
|
-
this.version = version2 ??
|
|
40581
|
+
this.version = version2 ?? version_js_1.__version__;
|
|
40531
40582
|
this.extra = extra ?? {};
|
|
40532
40583
|
this.grants = grants ?? [];
|
|
40533
40584
|
}
|
|
@@ -40611,7 +40662,7 @@ ${newlined}
|
|
|
40611
40662
|
const resolvedApiKey = apiKey ?? getEnvValue("MESHAGENT_API_KEY");
|
|
40612
40663
|
let resolvedSecret = token;
|
|
40613
40664
|
if (resolvedApiKey !== void 0) {
|
|
40614
|
-
const parsed = (0,
|
|
40665
|
+
const parsed = (0, api_keys_js_1.parseApiKey)(resolvedApiKey);
|
|
40615
40666
|
resolvedSecret = parsed.secret;
|
|
40616
40667
|
payload["kid"] = parsed.id;
|
|
40617
40668
|
payload["sub"] = parsed.projectId;
|
|
@@ -40643,7 +40694,7 @@ ${newlined}
|
|
|
40643
40694
|
delete data.sub;
|
|
40644
40695
|
const apiKeyId = typeof data.kid === "string" ? data.kid : void 0;
|
|
40645
40696
|
delete data.kid;
|
|
40646
|
-
const version2 = typeof data.version === "string" ? data.version :
|
|
40697
|
+
const version2 = typeof data.version === "string" ? data.version : version_js_1.__version__;
|
|
40647
40698
|
delete data.version;
|
|
40648
40699
|
return new _ParticipantToken({
|
|
40649
40700
|
name,
|
|
@@ -40712,14 +40763,14 @@ ${newlined}
|
|
|
40712
40763
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40713
40764
|
exports.WebSocketClientProtocol = exports.Protocol = exports.ProtocolMessageStream = exports.WebSocketProtocolChannel = exports.StreamProtocolChannel = exports.ProtocolHandshakeException = exports.ProtocolCloseException = exports.ProtocolReconnectUnsupportedException = exports.ProtocolCloseKind = void 0;
|
|
40714
40765
|
var isomorphic_ws_1 = __importDefault((init_browser(), __toCommonJS(browser_exports)));
|
|
40715
|
-
var
|
|
40716
|
-
var
|
|
40766
|
+
var completer_js_1 = require_completer();
|
|
40767
|
+
var utils_js_1 = require_utils();
|
|
40717
40768
|
var ProtocolMessage = class {
|
|
40718
40769
|
constructor({ id, type, data }) {
|
|
40719
40770
|
this.id = id;
|
|
40720
40771
|
this.type = type;
|
|
40721
40772
|
this.data = data;
|
|
40722
|
-
this.sent = new
|
|
40773
|
+
this.sent = new completer_js_1.Completer();
|
|
40723
40774
|
}
|
|
40724
40775
|
};
|
|
40725
40776
|
var ProtocolCloseKind;
|
|
@@ -40757,6 +40808,16 @@ ${newlined}
|
|
|
40757
40808
|
function isNodeRuntime() {
|
|
40758
40809
|
return typeof process !== "undefined" && process.release?.name === "node";
|
|
40759
40810
|
}
|
|
40811
|
+
function resolveWebSocketUrl(url) {
|
|
40812
|
+
const baseUrl = globalThis.location?.href;
|
|
40813
|
+
const resolved = baseUrl == null ? new URL(url) : new URL(url, baseUrl);
|
|
40814
|
+
if (resolved.protocol === "https:") {
|
|
40815
|
+
resolved.protocol = "wss:";
|
|
40816
|
+
} else if (resolved.protocol === "http:") {
|
|
40817
|
+
resolved.protocol = "ws:";
|
|
40818
|
+
}
|
|
40819
|
+
return resolved;
|
|
40820
|
+
}
|
|
40760
40821
|
var StreamProtocolChannel = class {
|
|
40761
40822
|
constructor({ input, output }) {
|
|
40762
40823
|
this.started = false;
|
|
@@ -40798,7 +40859,7 @@ ${newlined}
|
|
|
40798
40859
|
var WebSocketProtocolChannel = class {
|
|
40799
40860
|
constructor({ url, jwt }) {
|
|
40800
40861
|
this.webSocket = null;
|
|
40801
|
-
this._opened = new
|
|
40862
|
+
this._opened = new completer_js_1.Completer();
|
|
40802
40863
|
this._finished = false;
|
|
40803
40864
|
this._onUnexpectedResponse = (_request, response) => {
|
|
40804
40865
|
const statusCode = response.statusCode;
|
|
@@ -40825,7 +40886,7 @@ ${newlined}
|
|
|
40825
40886
|
return;
|
|
40826
40887
|
}
|
|
40827
40888
|
if (typeof data === "string") {
|
|
40828
|
-
this._onDataReceived?.(
|
|
40889
|
+
this._onDataReceived?.(utils_js_1.encoder.encode(data));
|
|
40829
40890
|
return;
|
|
40830
40891
|
}
|
|
40831
40892
|
if (data instanceof ArrayBuffer) {
|
|
@@ -40855,14 +40916,16 @@ ${newlined}
|
|
|
40855
40916
|
this.jwt = jwt;
|
|
40856
40917
|
}
|
|
40857
40918
|
start(onDataReceived, { onDone, onError }) {
|
|
40858
|
-
const url =
|
|
40859
|
-
|
|
40860
|
-
this._opened = new completer_1.Completer();
|
|
40919
|
+
const url = resolveWebSocketUrl(this.url);
|
|
40920
|
+
this._opened = new completer_js_1.Completer();
|
|
40861
40921
|
this._finished = false;
|
|
40862
40922
|
this._onDataReceived = onDataReceived;
|
|
40863
40923
|
this._doneHandler = onDone;
|
|
40864
40924
|
this._errorHandler = onError;
|
|
40865
|
-
const socket = isNodeRuntime() ? new isomorphic_ws_1.default(url.toString(), [], {
|
|
40925
|
+
const socket = isNodeRuntime() ? new isomorphic_ws_1.default(url.toString(), [], {
|
|
40926
|
+
headers: this.jwt == null ? void 0 : { Authorization: `Bearer ${this.jwt}` },
|
|
40927
|
+
perMessageDeflate: true
|
|
40928
|
+
}) : new isomorphic_ws_1.default(url.toString(), this.jwt == null ? [] : [`meshagent-room.${this.jwt}`]);
|
|
40866
40929
|
this.webSocket = socket;
|
|
40867
40930
|
if (isNodeRuntime()) {
|
|
40868
40931
|
socket.on("unexpected-response", this._onUnexpectedResponse);
|
|
@@ -40914,7 +40977,7 @@ ${newlined}
|
|
|
40914
40977
|
var ProtocolMessageStream = class {
|
|
40915
40978
|
constructor() {
|
|
40916
40979
|
this._messages = [];
|
|
40917
|
-
this._messageAdded = new
|
|
40980
|
+
this._messageAdded = new completer_js_1.Completer();
|
|
40918
40981
|
this._closed = false;
|
|
40919
40982
|
}
|
|
40920
40983
|
add(message2) {
|
|
@@ -40932,7 +40995,7 @@ ${newlined}
|
|
|
40932
40995
|
async *stream() {
|
|
40933
40996
|
while (!this._closed) {
|
|
40934
40997
|
await this._messageAdded.fut;
|
|
40935
|
-
this._messageAdded = new
|
|
40998
|
+
this._messageAdded = new completer_js_1.Completer();
|
|
40936
40999
|
while (this._messages.length > 0 && !this._closed) {
|
|
40937
41000
|
const message2 = this._messages.shift();
|
|
40938
41001
|
if (message2 !== void 0) {
|
|
@@ -40948,7 +41011,7 @@ ${newlined}
|
|
|
40948
41011
|
this.handlers = {};
|
|
40949
41012
|
this._id = 0;
|
|
40950
41013
|
this._send = new ProtocolMessageStream();
|
|
40951
|
-
this._done = new
|
|
41014
|
+
this._done = new completer_js_1.Completer();
|
|
40952
41015
|
this._sendLoop = null;
|
|
40953
41016
|
this._open = false;
|
|
40954
41017
|
this._closed = false;
|
|
@@ -41027,7 +41090,7 @@ ${newlined}
|
|
|
41027
41090
|
async handleMessage(messageId, type, data) {
|
|
41028
41091
|
const handler = this.handlers[type] ?? this.handlers["*"];
|
|
41029
41092
|
if (handler == null) {
|
|
41030
|
-
const unpacked = (0,
|
|
41093
|
+
const unpacked = (0, utils_js_1.unpackMessage)(data);
|
|
41031
41094
|
console.warn(`No handler for message type ${type}; data:`, unpacked);
|
|
41032
41095
|
return;
|
|
41033
41096
|
}
|
|
@@ -41059,7 +41122,7 @@ ${newlined}
|
|
|
41059
41122
|
await message2.sent.fut;
|
|
41060
41123
|
}
|
|
41061
41124
|
async sendJson(object) {
|
|
41062
|
-
await this.send("application/json",
|
|
41125
|
+
await this.send("application/json", utils_js_1.encoder.encode(JSON.stringify(object)));
|
|
41063
41126
|
}
|
|
41064
41127
|
start({ onMessage, onDone, onError } = {}) {
|
|
41065
41128
|
if (this._sendLoop != null) {
|
|
@@ -41121,14 +41184,14 @@ ${newlined}
|
|
|
41121
41184
|
headerView.setUint32(4, message2.id & 4294967295, false);
|
|
41122
41185
|
headerView.setUint32(8, 0, false);
|
|
41123
41186
|
headerView.setUint32(12, packets, false);
|
|
41124
|
-
await this.channel.sendData((0,
|
|
41187
|
+
await this.channel.sendData((0, utils_js_1.mergeUint8Arrays)(header, utils_js_1.encoder.encode(message2.type)));
|
|
41125
41188
|
for (let i = 0; i < packets; i += 1) {
|
|
41126
41189
|
const packetHeader = new Uint8Array(12);
|
|
41127
41190
|
const packetHeaderView = new DataView(packetHeader.buffer);
|
|
41128
41191
|
packetHeaderView.setUint32(0, Math.floor(message2.id / 2 ** 32), false);
|
|
41129
41192
|
packetHeaderView.setUint32(4, message2.id & 4294967295, false);
|
|
41130
41193
|
packetHeaderView.setUint32(8, i + 1, false);
|
|
41131
|
-
await this.channel.sendData((0,
|
|
41194
|
+
await this.channel.sendData((0, utils_js_1.mergeUint8Arrays)(packetHeader, message2.data.subarray(i * 1024, Math.min((i + 1) * 1024, message2.data.length))));
|
|
41132
41195
|
}
|
|
41133
41196
|
if (!message2.sent.completed) {
|
|
41134
41197
|
message2.sent.complete();
|
|
@@ -41162,10 +41225,10 @@ ${newlined}
|
|
|
41162
41225
|
if (this._recvState === "ready" || this._recvState === "error") {
|
|
41163
41226
|
this._recvPacketTotal = dataView.getUint32(12, false);
|
|
41164
41227
|
this._recvMessageId = messageId;
|
|
41165
|
-
this._recvType =
|
|
41228
|
+
this._recvType = utils_js_1.decoder.decode(dataPacket.subarray(16));
|
|
41166
41229
|
if (this._recvPacketTotal === 0) {
|
|
41167
41230
|
try {
|
|
41168
|
-
const merged = (0,
|
|
41231
|
+
const merged = (0, utils_js_1.mergeUint8Arrays)(...this._recvPackets);
|
|
41169
41232
|
this._recvPackets.length = 0;
|
|
41170
41233
|
this._dispatchMessage({ messageId, type: this._recvType, data: merged });
|
|
41171
41234
|
} finally {
|
|
@@ -41196,7 +41259,7 @@ ${newlined}
|
|
|
41196
41259
|
this._recvPackets.push(dataPacket.subarray(12));
|
|
41197
41260
|
if (this._recvPacketTotal === this._recvPacketId) {
|
|
41198
41261
|
try {
|
|
41199
|
-
const merged = (0,
|
|
41262
|
+
const merged = (0, utils_js_1.mergeUint8Arrays)(...this._recvPackets);
|
|
41200
41263
|
this._recvPackets.length = 0;
|
|
41201
41264
|
this._dispatchMessage({ messageId, type: this._recvType, data: merged });
|
|
41202
41265
|
} finally {
|
|
@@ -41216,7 +41279,7 @@ ${newlined}
|
|
|
41216
41279
|
}
|
|
41217
41280
|
};
|
|
41218
41281
|
exports.Protocol = Protocol;
|
|
41219
|
-
var WebSocketClientProtocol = class extends Protocol {
|
|
41282
|
+
var WebSocketClientProtocol = class _WebSocketClientProtocol extends Protocol {
|
|
41220
41283
|
constructor({ url, token }) {
|
|
41221
41284
|
super({
|
|
41222
41285
|
channel: new WebSocketProtocolChannel({ url, jwt: token })
|
|
@@ -41224,6 +41287,9 @@ ${newlined}
|
|
|
41224
41287
|
this._url = url;
|
|
41225
41288
|
this._token = token;
|
|
41226
41289
|
}
|
|
41290
|
+
static withIAP({ url = "./.well-known/meshagent/room/connect" } = {}) {
|
|
41291
|
+
return new _WebSocketClientProtocol({ url, token: null });
|
|
41292
|
+
}
|
|
41227
41293
|
get url() {
|
|
41228
41294
|
return this._url;
|
|
41229
41295
|
}
|
|
@@ -41246,13 +41312,13 @@ ${newlined}
|
|
|
41246
41312
|
exports.websocketRoomUrl = websocketRoomUrl;
|
|
41247
41313
|
exports.participantToken = participantToken;
|
|
41248
41314
|
exports.websocketProtocol = websocketProtocol;
|
|
41249
|
-
var
|
|
41250
|
-
var
|
|
41251
|
-
var
|
|
41252
|
-
var
|
|
41315
|
+
var schema_js_1 = require_schema3();
|
|
41316
|
+
var participant_token_js_1 = require_participant_token();
|
|
41317
|
+
var protocol_js_1 = require_protocol();
|
|
41318
|
+
var api_keys_js_1 = require_api_keys();
|
|
41253
41319
|
function validateSchemaName(name) {
|
|
41254
41320
|
if (name.includes(".")) {
|
|
41255
|
-
throw new
|
|
41321
|
+
throw new schema_js_1.MeshSchemaValidationException("schema name cannot contain '.'");
|
|
41256
41322
|
}
|
|
41257
41323
|
}
|
|
41258
41324
|
async function deploySchema({ room, schema, name, overwrite = true }) {
|
|
@@ -41283,11 +41349,11 @@ ${newlined}
|
|
|
41283
41349
|
let resolvedProjectId = projectId;
|
|
41284
41350
|
let resolvedApiKeyId = apiKeyId;
|
|
41285
41351
|
if (apiKey) {
|
|
41286
|
-
const parsed = (0,
|
|
41352
|
+
const parsed = (0, api_keys_js_1.parseApiKey)(apiKey);
|
|
41287
41353
|
resolvedProjectId ?? (resolvedProjectId = parsed.projectId);
|
|
41288
41354
|
resolvedApiKeyId ?? (resolvedApiKeyId = parsed.id);
|
|
41289
41355
|
}
|
|
41290
|
-
const token = new
|
|
41356
|
+
const token = new participant_token_js_1.ParticipantToken({
|
|
41291
41357
|
name: participantName,
|
|
41292
41358
|
projectId: resolvedProjectId,
|
|
41293
41359
|
apiKeyId: resolvedApiKeyId
|
|
@@ -41296,14 +41362,14 @@ ${newlined}
|
|
|
41296
41362
|
if (role) {
|
|
41297
41363
|
token.addRoleGrant(role);
|
|
41298
41364
|
}
|
|
41299
|
-
token.addApiGrant(
|
|
41365
|
+
token.addApiGrant(participant_token_js_1.ApiScope.agentDefault());
|
|
41300
41366
|
return token;
|
|
41301
41367
|
}
|
|
41302
41368
|
async function websocketProtocol({ participantName, roomName, role, projectId, apiKeyId, apiKey, secret, apiUrl }) {
|
|
41303
41369
|
const url = websocketRoomUrl({ roomName, apiUrl });
|
|
41304
41370
|
const token = participantToken({ participantName, roomName, role, projectId, apiKeyId, apiKey });
|
|
41305
41371
|
const jwt = await token.toJwt({ token: secret, apiKey });
|
|
41306
|
-
return
|
|
41372
|
+
return protocol_js_1.WebSocketClientProtocol.createFactory({ url, token: jwt });
|
|
41307
41373
|
}
|
|
41308
41374
|
}
|
|
41309
41375
|
});
|
|
@@ -41375,10 +41441,10 @@ ${newlined}
|
|
|
41375
41441
|
"use strict";
|
|
41376
41442
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41377
41443
|
exports.Meshagent = void 0;
|
|
41378
|
-
var
|
|
41379
|
-
var
|
|
41380
|
-
var
|
|
41381
|
-
var
|
|
41444
|
+
var helpers_js_1 = require_helpers();
|
|
41445
|
+
var requirement_js_1 = require_requirement();
|
|
41446
|
+
var participant_token_js_1 = require_participant_token();
|
|
41447
|
+
var utils_js_1 = require_utils();
|
|
41382
41448
|
function pruneUndefinedValues(value) {
|
|
41383
41449
|
if (Array.isArray(value)) {
|
|
41384
41450
|
const prunedItems = value.map((item) => pruneUndefinedValues(item)).filter((item) => item !== void 0);
|
|
@@ -41467,7 +41533,7 @@ ${newlined}
|
|
|
41467
41533
|
}
|
|
41468
41534
|
var Meshagent2 = class {
|
|
41469
41535
|
constructor({ baseUrl, token } = {}) {
|
|
41470
|
-
const resolvedBaseUrl = (0,
|
|
41536
|
+
const resolvedBaseUrl = (0, helpers_js_1.meshagentBaseUrl)(baseUrl).replace(/\/+$/, "");
|
|
41471
41537
|
this.baseUrl = resolvedBaseUrl || "https://api.meshagent.com";
|
|
41472
41538
|
const envToken = typeof process !== "undefined" ? process.env?.MESHAGENT_API_KEY : void 0;
|
|
41473
41539
|
this.token = token ?? envToken ?? void 0;
|
|
@@ -41519,7 +41585,7 @@ ${newlined}
|
|
|
41519
41585
|
} catch {
|
|
41520
41586
|
message2 = "<unable to read body>";
|
|
41521
41587
|
}
|
|
41522
|
-
throw new
|
|
41588
|
+
throw new requirement_js_1.RoomException(`Failed to ${action}. Status code: ${response.status}, body: ${message2}`);
|
|
41523
41589
|
}
|
|
41524
41590
|
switch (responseType) {
|
|
41525
41591
|
case "json":
|
|
@@ -41538,15 +41604,15 @@ ${newlined}
|
|
|
41538
41604
|
}
|
|
41539
41605
|
parseRoomShare(data) {
|
|
41540
41606
|
if (!data || typeof data !== "object") {
|
|
41541
|
-
throw new
|
|
41607
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: expected object");
|
|
41542
41608
|
}
|
|
41543
41609
|
const { id, project_id: projectId, projectId: projectIdAlt, settings } = data;
|
|
41544
41610
|
if (typeof id !== "string") {
|
|
41545
|
-
throw new
|
|
41611
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: missing id");
|
|
41546
41612
|
}
|
|
41547
41613
|
const finalProjectId = typeof projectIdAlt === "string" ? projectIdAlt : typeof projectId === "string" ? projectId : void 0;
|
|
41548
41614
|
if (!finalProjectId) {
|
|
41549
|
-
throw new
|
|
41615
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: missing project id");
|
|
41550
41616
|
}
|
|
41551
41617
|
return {
|
|
41552
41618
|
id,
|
|
@@ -41556,23 +41622,23 @@ ${newlined}
|
|
|
41556
41622
|
}
|
|
41557
41623
|
parseRoomSession(data) {
|
|
41558
41624
|
if (!data || typeof data !== "object") {
|
|
41559
|
-
throw new
|
|
41625
|
+
throw new requirement_js_1.RoomException("Invalid room session payload");
|
|
41560
41626
|
}
|
|
41561
41627
|
const { id, room_id: roomIdRaw, roomId, room_name: roomNameRaw, roomName, created_at: createdRaw, createdAt, is_active: isActiveRaw, isActive, participants } = data;
|
|
41562
41628
|
if (typeof id !== "string") {
|
|
41563
|
-
throw new
|
|
41629
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing id");
|
|
41564
41630
|
}
|
|
41565
41631
|
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
41566
41632
|
if (typeof roomNameValue !== "string") {
|
|
41567
|
-
throw new
|
|
41633
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing room name");
|
|
41568
41634
|
}
|
|
41569
41635
|
const created = typeof createdAt === "string" ? createdAt : createdRaw;
|
|
41570
41636
|
if (typeof created !== "string") {
|
|
41571
|
-
throw new
|
|
41637
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing created_at");
|
|
41572
41638
|
}
|
|
41573
41639
|
const isActiveValue = typeof isActive === "boolean" ? isActive : isActiveRaw;
|
|
41574
41640
|
if (typeof isActiveValue !== "boolean") {
|
|
41575
|
-
throw new
|
|
41641
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing is_active");
|
|
41576
41642
|
}
|
|
41577
41643
|
return {
|
|
41578
41644
|
id,
|
|
@@ -41585,11 +41651,11 @@ ${newlined}
|
|
|
41585
41651
|
}
|
|
41586
41652
|
parseRoom(data) {
|
|
41587
41653
|
if (!data || typeof data !== "object") {
|
|
41588
|
-
throw new
|
|
41654
|
+
throw new requirement_js_1.RoomException("Invalid room payload");
|
|
41589
41655
|
}
|
|
41590
41656
|
const { id, name, metadata, annotations } = data;
|
|
41591
41657
|
if (typeof id !== "string" || typeof name !== "string") {
|
|
41592
|
-
throw new
|
|
41658
|
+
throw new requirement_js_1.RoomException("Invalid room payload: missing id or name");
|
|
41593
41659
|
}
|
|
41594
41660
|
return {
|
|
41595
41661
|
id,
|
|
@@ -41600,7 +41666,7 @@ ${newlined}
|
|
|
41600
41666
|
}
|
|
41601
41667
|
parseRoute(data) {
|
|
41602
41668
|
if (!data || typeof data !== "object") {
|
|
41603
|
-
throw new
|
|
41669
|
+
throw new requirement_js_1.RoomException("Invalid route payload: expected object");
|
|
41604
41670
|
}
|
|
41605
41671
|
if (data.spec && typeof data.spec === "object") {
|
|
41606
41672
|
return { domain: String(data.domain ?? data.spec.domain), spec: data.spec };
|
|
@@ -41618,11 +41684,11 @@ ${newlined}
|
|
|
41618
41684
|
}
|
|
41619
41685
|
};
|
|
41620
41686
|
}
|
|
41621
|
-
throw new
|
|
41687
|
+
throw new requirement_js_1.RoomException("Invalid route payload: missing spec");
|
|
41622
41688
|
}
|
|
41623
41689
|
parseFeed(data) {
|
|
41624
41690
|
if (!data || typeof data !== "object") {
|
|
41625
|
-
throw new
|
|
41691
|
+
throw new requirement_js_1.RoomException("Invalid feed payload");
|
|
41626
41692
|
}
|
|
41627
41693
|
const { id, project_id: projectIdRaw, projectId, created_at: createdAtRaw, createdAt, name, description, visibility, paused, annotations, message_schema: messageSchemaRaw, messageSchema } = data;
|
|
41628
41694
|
const projectIdValue = typeof projectId === "string" ? projectId : typeof projectIdRaw === "string" ? projectIdRaw : void 0;
|
|
@@ -41630,7 +41696,7 @@ ${newlined}
|
|
|
41630
41696
|
const visibilityValue = visibility === "public" || visibility === "project" || visibility === "private" ? visibility : void 0;
|
|
41631
41697
|
const messageSchemaValue = typeof messageSchema === "boolean" || messageSchema && typeof messageSchema === "object" ? messageSchema : typeof messageSchemaRaw === "boolean" || messageSchemaRaw && typeof messageSchemaRaw === "object" ? messageSchemaRaw : null;
|
|
41632
41698
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof createdAtValue !== "string" || typeof name !== "string" || visibilityValue === void 0) {
|
|
41633
|
-
throw new
|
|
41699
|
+
throw new requirement_js_1.RoomException("Invalid feed payload: missing required fields");
|
|
41634
41700
|
}
|
|
41635
41701
|
return {
|
|
41636
41702
|
id,
|
|
@@ -41646,7 +41712,7 @@ ${newlined}
|
|
|
41646
41712
|
}
|
|
41647
41713
|
parseFeedSubscription(data) {
|
|
41648
41714
|
if (!data || typeof data !== "object") {
|
|
41649
|
-
throw new
|
|
41715
|
+
throw new requirement_js_1.RoomException("Invalid feed subscription payload");
|
|
41650
41716
|
}
|
|
41651
41717
|
const { id, feed_id: feedIdRaw, feedId, project_id: projectIdRaw, projectId, room, room_id: roomIdRaw, roomId, path, filename_datetime_format: filenameDatetimeFormatRaw, filenameDatetimeFormat, created_at: createdAtRaw, createdAt, annotations } = data;
|
|
41652
41718
|
const feedIdValue = typeof feedId === "string" ? feedId : feedIdRaw;
|
|
@@ -41655,7 +41721,7 @@ ${newlined}
|
|
|
41655
41721
|
const roomIdValue = typeof roomId === "string" ? roomId : roomIdRaw;
|
|
41656
41722
|
const filenameDatetimeFormatValue = typeof filenameDatetimeFormat === "string" ? filenameDatetimeFormat : typeof filenameDatetimeFormatRaw === "string" ? filenameDatetimeFormatRaw : void 0;
|
|
41657
41723
|
if (typeof id !== "string" || typeof feedIdValue !== "string" || typeof projectIdValue !== "string" || typeof room !== "string" || typeof path !== "string" || typeof createdAtValue !== "string") {
|
|
41658
|
-
throw new
|
|
41724
|
+
throw new requirement_js_1.RoomException("Invalid feed subscription payload: missing required fields");
|
|
41659
41725
|
}
|
|
41660
41726
|
return {
|
|
41661
41727
|
id,
|
|
@@ -41671,7 +41737,7 @@ ${newlined}
|
|
|
41671
41737
|
}
|
|
41672
41738
|
parseLLMLogger(data) {
|
|
41673
41739
|
if (!data || typeof data !== "object") {
|
|
41674
|
-
throw new
|
|
41740
|
+
throw new requirement_js_1.RoomException("Invalid LLM logger payload");
|
|
41675
41741
|
}
|
|
41676
41742
|
const { id, project_id: projectIdRaw, projectId, destination_feed_id: destinationFeedIdRaw, destinationFeedId, filter_expression: filterExpressionRaw, filterExpression, paused, created_at: createdAtRaw, createdAt, annotations } = data;
|
|
41677
41743
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
@@ -41679,7 +41745,7 @@ ${newlined}
|
|
|
41679
41745
|
const filterExpressionValue = typeof filterExpression === "string" ? filterExpression : filterExpressionRaw;
|
|
41680
41746
|
const createdAtValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
41681
41747
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof destinationFeedIdValue !== "string" || typeof filterExpressionValue !== "string" || typeof createdAtValue !== "string") {
|
|
41682
|
-
throw new
|
|
41748
|
+
throw new requirement_js_1.RoomException("Invalid LLM logger payload: missing required fields");
|
|
41683
41749
|
}
|
|
41684
41750
|
return {
|
|
41685
41751
|
id,
|
|
@@ -41693,13 +41759,13 @@ ${newlined}
|
|
|
41693
41759
|
}
|
|
41694
41760
|
parseProjectRepository(data) {
|
|
41695
41761
|
if (!data || typeof data !== "object") {
|
|
41696
|
-
throw new
|
|
41762
|
+
throw new requirement_js_1.RoomException("Invalid repository payload");
|
|
41697
41763
|
}
|
|
41698
41764
|
const { id, project_id: projectIdRaw, projectId, name, description, annotations, created_at: createdAtRaw, createdAt } = data;
|
|
41699
41765
|
const projectIdValue = typeof projectId === "string" ? projectId : typeof projectIdRaw === "string" ? projectIdRaw : void 0;
|
|
41700
41766
|
const createdAtValue = typeof createdAt === "string" ? createdAt : typeof createdAtRaw === "string" ? createdAtRaw : void 0;
|
|
41701
41767
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof name !== "string" || typeof createdAtValue !== "string") {
|
|
41702
|
-
throw new
|
|
41768
|
+
throw new requirement_js_1.RoomException("Invalid repository payload: missing required fields");
|
|
41703
41769
|
}
|
|
41704
41770
|
return {
|
|
41705
41771
|
id,
|
|
@@ -41712,44 +41778,44 @@ ${newlined}
|
|
|
41712
41778
|
}
|
|
41713
41779
|
parseProjectRoomGrant(data) {
|
|
41714
41780
|
if (!data || typeof data !== "object") {
|
|
41715
|
-
throw new
|
|
41781
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload");
|
|
41716
41782
|
}
|
|
41717
41783
|
const roomData = data.room;
|
|
41718
41784
|
const room = this.parseRoom(roomData);
|
|
41719
41785
|
const userId = data.user_id ?? data.userId;
|
|
41720
41786
|
if (typeof userId !== "string") {
|
|
41721
|
-
throw new
|
|
41787
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload: missing user_id");
|
|
41722
41788
|
}
|
|
41723
41789
|
const permissionsRaw = data.permissions;
|
|
41724
|
-
const permissions = permissionsRaw && typeof permissionsRaw === "object" ?
|
|
41790
|
+
const permissions = permissionsRaw && typeof permissionsRaw === "object" ? participant_token_js_1.ApiScope.fromJSON(permissionsRaw) : new participant_token_js_1.ApiScope();
|
|
41725
41791
|
return { room, userId, permissions };
|
|
41726
41792
|
}
|
|
41727
41793
|
parseProjectRoomGrantCount(data) {
|
|
41728
41794
|
const roomData = data && typeof data === "object" ? data.room ?? { id: data.room_id, name: data.room_name, metadata: data.metadata ?? {} } : void 0;
|
|
41729
41795
|
if (!roomData) {
|
|
41730
|
-
throw new
|
|
41796
|
+
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing room");
|
|
41731
41797
|
}
|
|
41732
41798
|
const room = this.parseRoom(roomData);
|
|
41733
41799
|
const count = data.count;
|
|
41734
41800
|
if (typeof count !== "number") {
|
|
41735
|
-
throw new
|
|
41801
|
+
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing count");
|
|
41736
41802
|
}
|
|
41737
41803
|
return { room, count };
|
|
41738
41804
|
}
|
|
41739
41805
|
parseProjectUserGrantCount(data) {
|
|
41740
41806
|
if (!data || typeof data !== "object") {
|
|
41741
|
-
throw new
|
|
41807
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload");
|
|
41742
41808
|
}
|
|
41743
41809
|
const { user_id: userIdRaw, userId, count, first_name: firstNameRaw, firstName, last_name: lastNameRaw, lastName, email } = data;
|
|
41744
41810
|
const userIdValue = typeof userId === "string" ? userId : userIdRaw;
|
|
41745
41811
|
if (typeof userIdValue !== "string") {
|
|
41746
|
-
throw new
|
|
41812
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing user_id");
|
|
41747
41813
|
}
|
|
41748
41814
|
if (typeof count !== "number") {
|
|
41749
|
-
throw new
|
|
41815
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing count");
|
|
41750
41816
|
}
|
|
41751
41817
|
if (typeof email !== "string") {
|
|
41752
|
-
throw new
|
|
41818
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing email");
|
|
41753
41819
|
}
|
|
41754
41820
|
return {
|
|
41755
41821
|
userId: userIdValue,
|
|
@@ -41761,11 +41827,11 @@ ${newlined}
|
|
|
41761
41827
|
}
|
|
41762
41828
|
parseBalance(data) {
|
|
41763
41829
|
if (!data || typeof data !== "object") {
|
|
41764
|
-
throw new
|
|
41830
|
+
throw new requirement_js_1.RoomException("Invalid balance payload");
|
|
41765
41831
|
}
|
|
41766
41832
|
const balanceValue = data.balance;
|
|
41767
41833
|
if (typeof balanceValue !== "number") {
|
|
41768
|
-
throw new
|
|
41834
|
+
throw new requirement_js_1.RoomException("Invalid balance payload: missing balance");
|
|
41769
41835
|
}
|
|
41770
41836
|
const threshold = data.auto_recharge_threshold ?? data.autoRechargeThreshold;
|
|
41771
41837
|
const amount = data.auto_recharge_amount ?? data.autoRechargeAmount;
|
|
@@ -41785,15 +41851,15 @@ ${newlined}
|
|
|
41785
41851
|
}
|
|
41786
41852
|
parseTransaction(data) {
|
|
41787
41853
|
if (!data || typeof data !== "object") {
|
|
41788
|
-
throw new
|
|
41854
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload");
|
|
41789
41855
|
}
|
|
41790
41856
|
const { id, amount, reference, referenceType, reference_type: referenceTypeRaw, description, created_at: createdAtRaw, createdAt } = data;
|
|
41791
41857
|
if (typeof id !== "string" || typeof amount !== "number" || typeof description !== "string") {
|
|
41792
|
-
throw new
|
|
41858
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload: missing fields");
|
|
41793
41859
|
}
|
|
41794
41860
|
const createdValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
41795
41861
|
if (typeof createdValue !== "string") {
|
|
41796
|
-
throw new
|
|
41862
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload: missing created_at");
|
|
41797
41863
|
}
|
|
41798
41864
|
const referenceTypeValue = typeof referenceType === "string" ? referenceType : referenceTypeRaw;
|
|
41799
41865
|
return {
|
|
@@ -41807,7 +41873,7 @@ ${newlined}
|
|
|
41807
41873
|
}
|
|
41808
41874
|
parseSecret(data) {
|
|
41809
41875
|
if (!data || typeof data !== "object") {
|
|
41810
|
-
throw new
|
|
41876
|
+
throw new requirement_js_1.RoomException("Invalid secret payload");
|
|
41811
41877
|
}
|
|
41812
41878
|
const type = data.type;
|
|
41813
41879
|
if (type === "docker") {
|
|
@@ -41815,7 +41881,7 @@ ${newlined}
|
|
|
41815
41881
|
const username = data.username;
|
|
41816
41882
|
const password = data.password;
|
|
41817
41883
|
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
41818
|
-
throw new
|
|
41884
|
+
throw new requirement_js_1.RoomException("Invalid docker secret payload");
|
|
41819
41885
|
}
|
|
41820
41886
|
return {
|
|
41821
41887
|
id: typeof data.id === "string" ? data.id : void 0,
|
|
@@ -41830,7 +41896,7 @@ ${newlined}
|
|
|
41830
41896
|
if (type === "keys") {
|
|
41831
41897
|
const record = data.data;
|
|
41832
41898
|
if (!record || typeof record !== "object") {
|
|
41833
|
-
throw new
|
|
41899
|
+
throw new requirement_js_1.RoomException("Invalid keys secret payload");
|
|
41834
41900
|
}
|
|
41835
41901
|
return {
|
|
41836
41902
|
id: typeof data.id === "string" ? data.id : void 0,
|
|
@@ -41839,15 +41905,15 @@ ${newlined}
|
|
|
41839
41905
|
data: record
|
|
41840
41906
|
};
|
|
41841
41907
|
}
|
|
41842
|
-
throw new
|
|
41908
|
+
throw new requirement_js_1.RoomException(`Unknown secret type: ${type}`);
|
|
41843
41909
|
}
|
|
41844
41910
|
parseManagedSecretInfo(data) {
|
|
41845
41911
|
if (!data || typeof data !== "object") {
|
|
41846
|
-
throw new
|
|
41912
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload");
|
|
41847
41913
|
}
|
|
41848
41914
|
const { id, type, name, delegated_to: delegatedToRaw, delegatedTo } = data;
|
|
41849
41915
|
if (typeof id !== "string" || typeof type !== "string" || typeof name !== "string") {
|
|
41850
|
-
throw new
|
|
41916
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing id, type, or name");
|
|
41851
41917
|
}
|
|
41852
41918
|
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : typeof delegatedToRaw === "string" ? delegatedToRaw : null;
|
|
41853
41919
|
return {
|
|
@@ -41861,7 +41927,7 @@ ${newlined}
|
|
|
41861
41927
|
const secret = this.parseManagedSecretInfo(data);
|
|
41862
41928
|
const dataBase64 = data.data_base64 ?? data.dataBase64;
|
|
41863
41929
|
if (typeof dataBase64 !== "string") {
|
|
41864
|
-
throw new
|
|
41930
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing data_base64");
|
|
41865
41931
|
}
|
|
41866
41932
|
return {
|
|
41867
41933
|
...secret,
|
|
@@ -41872,17 +41938,17 @@ ${newlined}
|
|
|
41872
41938
|
parseSecretPayload(secret, rawData) {
|
|
41873
41939
|
let payload;
|
|
41874
41940
|
try {
|
|
41875
|
-
payload = JSON.parse(
|
|
41941
|
+
payload = JSON.parse(utils_js_1.decoder.decode(rawData));
|
|
41876
41942
|
} catch {
|
|
41877
|
-
throw new
|
|
41943
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41878
41944
|
}
|
|
41879
41945
|
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
41880
|
-
throw new
|
|
41946
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41881
41947
|
}
|
|
41882
41948
|
if (secret.type === "docker") {
|
|
41883
41949
|
const { server, username, password, email } = payload;
|
|
41884
41950
|
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
41885
|
-
throw new
|
|
41951
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41886
41952
|
}
|
|
41887
41953
|
return {
|
|
41888
41954
|
id: secret.id,
|
|
@@ -41896,7 +41962,7 @@ ${newlined}
|
|
|
41896
41962
|
}
|
|
41897
41963
|
const entries = Object.entries(payload);
|
|
41898
41964
|
if (entries.some(([, value]) => typeof value !== "string")) {
|
|
41899
|
-
throw new
|
|
41965
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41900
41966
|
}
|
|
41901
41967
|
return {
|
|
41902
41968
|
id: secret.id,
|
|
@@ -41929,7 +41995,7 @@ ${newlined}
|
|
|
41929
41995
|
return null;
|
|
41930
41996
|
}
|
|
41931
41997
|
if (typeof data !== "object") {
|
|
41932
|
-
throw new
|
|
41998
|
+
throw new requirement_js_1.RoomException("Invalid connector payload");
|
|
41933
41999
|
}
|
|
41934
42000
|
const { openai_connector_id: openaiConnectorIdRaw, openaiConnectorId, server_url: serverUrlRaw, serverUrl, client_secret_id: clientSecretIdRaw, clientSecretId } = data;
|
|
41935
42001
|
return {
|
|
@@ -41956,14 +42022,14 @@ ${newlined}
|
|
|
41956
42022
|
}
|
|
41957
42023
|
parseExternalOAuthClientRegistration(data) {
|
|
41958
42024
|
if (!data || typeof data !== "object") {
|
|
41959
|
-
throw new
|
|
42025
|
+
throw new requirement_js_1.RoomException("Invalid external oauth registration payload");
|
|
41960
42026
|
}
|
|
41961
42027
|
const { id, delegated_to: delegatedToRaw, delegatedTo, connector, oauth, client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret } = data;
|
|
41962
42028
|
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : delegatedToRaw;
|
|
41963
42029
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
41964
42030
|
const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
|
|
41965
42031
|
if (typeof id !== "string" || typeof delegatedToValue !== "string" || typeof clientIdValue !== "string") {
|
|
41966
|
-
throw new
|
|
42032
|
+
throw new requirement_js_1.RoomException("Invalid external oauth registration payload: missing fields");
|
|
41967
42033
|
}
|
|
41968
42034
|
return {
|
|
41969
42035
|
id,
|
|
@@ -41976,7 +42042,7 @@ ${newlined}
|
|
|
41976
42042
|
}
|
|
41977
42043
|
parseOAuthClient(data) {
|
|
41978
42044
|
if (!data || typeof data !== "object") {
|
|
41979
|
-
throw new
|
|
42045
|
+
throw new requirement_js_1.RoomException("Invalid OAuth client payload");
|
|
41980
42046
|
}
|
|
41981
42047
|
const { client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, grant_types: grantTypesRaw, grantTypes, response_types: responseTypesRaw, responseTypes, redirect_uris: redirectUrisRaw, redirectUris, scope, project_id: projectIdRaw, projectId, metadata } = data;
|
|
41982
42048
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
@@ -41986,7 +42052,7 @@ ${newlined}
|
|
|
41986
42052
|
const redirectUrisValue = Array.isArray(redirectUris) ? redirectUris : redirectUrisRaw;
|
|
41987
42053
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
41988
42054
|
if (typeof clientIdValue !== "string" || typeof clientSecretValue !== "string" || !Array.isArray(grantTypesValue) || !Array.isArray(responseTypesValue) || !Array.isArray(redirectUrisValue) || typeof scope !== "string" || typeof projectIdValue !== "string") {
|
|
41989
|
-
throw new
|
|
42055
|
+
throw new requirement_js_1.RoomException("Invalid OAuth client payload: missing required fields");
|
|
41990
42056
|
}
|
|
41991
42057
|
return {
|
|
41992
42058
|
clientId: clientIdValue,
|
|
@@ -42001,14 +42067,14 @@ ${newlined}
|
|
|
42001
42067
|
}
|
|
42002
42068
|
parseRoomConnectionInfo(data) {
|
|
42003
42069
|
if (!data || typeof data !== "object") {
|
|
42004
|
-
throw new
|
|
42070
|
+
throw new requirement_js_1.RoomException("Invalid room connection payload");
|
|
42005
42071
|
}
|
|
42006
42072
|
const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, room_url: roomUrlRaw, roomUrl } = data;
|
|
42007
42073
|
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
42008
42074
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
42009
42075
|
const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
|
|
42010
42076
|
if (typeof jwt !== "string" || typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
|
|
42011
|
-
throw new
|
|
42077
|
+
throw new requirement_js_1.RoomException("Invalid room connection payload: missing fields");
|
|
42012
42078
|
}
|
|
42013
42079
|
return { jwt, roomName: roomNameValue, projectId: projectIdValue, roomUrl: roomUrlValue };
|
|
42014
42080
|
}
|
|
@@ -42043,7 +42109,7 @@ ${newlined}
|
|
|
42043
42109
|
});
|
|
42044
42110
|
const role = payload?.role;
|
|
42045
42111
|
if (role !== "member" && role !== "admin" && role !== "developer") {
|
|
42046
|
-
throw new
|
|
42112
|
+
throw new requirement_js_1.RoomException("Invalid role payload");
|
|
42047
42113
|
}
|
|
42048
42114
|
return role;
|
|
42049
42115
|
}
|
|
@@ -42180,7 +42246,7 @@ ${newlined}
|
|
|
42180
42246
|
});
|
|
42181
42247
|
const enabled = data?.["enabled"];
|
|
42182
42248
|
if (typeof enabled !== "boolean") {
|
|
42183
|
-
throw new
|
|
42249
|
+
throw new requirement_js_1.RoomException("Invalid status payload: expected boolean 'enabled'");
|
|
42184
42250
|
}
|
|
42185
42251
|
return enabled;
|
|
42186
42252
|
}
|
|
@@ -42213,7 +42279,7 @@ ${newlined}
|
|
|
42213
42279
|
});
|
|
42214
42280
|
const url = data?.["checkout_url"];
|
|
42215
42281
|
if (typeof url !== "string") {
|
|
42216
|
-
throw new
|
|
42282
|
+
throw new requirement_js_1.RoomException("Invalid subscription payload: expected 'checkout_url' string");
|
|
42217
42283
|
}
|
|
42218
42284
|
return url;
|
|
42219
42285
|
}
|
|
@@ -42225,7 +42291,7 @@ ${newlined}
|
|
|
42225
42291
|
});
|
|
42226
42292
|
const url = data?.["checkout_url"];
|
|
42227
42293
|
if (typeof url !== "string") {
|
|
42228
|
-
throw new
|
|
42294
|
+
throw new requirement_js_1.RoomException("Invalid credits payload: expected 'checkout_url' string");
|
|
42229
42295
|
}
|
|
42230
42296
|
return url;
|
|
42231
42297
|
}
|
|
@@ -42254,7 +42320,7 @@ ${newlined}
|
|
|
42254
42320
|
});
|
|
42255
42321
|
const usage = data?.["usage"];
|
|
42256
42322
|
if (!Array.isArray(usage)) {
|
|
42257
|
-
throw new
|
|
42323
|
+
throw new requirement_js_1.RoomException("Invalid usage payload: expected 'usage' to be a list");
|
|
42258
42324
|
}
|
|
42259
42325
|
return usage.filter((item) => item && typeof item === "object");
|
|
42260
42326
|
}
|
|
@@ -42353,14 +42419,14 @@ ${newlined}
|
|
|
42353
42419
|
}
|
|
42354
42420
|
parseMailbox(item) {
|
|
42355
42421
|
if (!item || typeof item !== "object") {
|
|
42356
|
-
throw new
|
|
42422
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload");
|
|
42357
42423
|
}
|
|
42358
42424
|
const { address, room, room_id, queue } = item;
|
|
42359
42425
|
if (typeof address !== "string" || typeof room !== "string" || typeof queue !== "string") {
|
|
42360
|
-
throw new
|
|
42426
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload: missing fields");
|
|
42361
42427
|
}
|
|
42362
42428
|
if (room_id !== void 0 && typeof room_id !== "string") {
|
|
42363
|
-
throw new
|
|
42429
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload: invalid room_id");
|
|
42364
42430
|
}
|
|
42365
42431
|
return { address, room, roomId: room_id, queue };
|
|
42366
42432
|
}
|
|
@@ -42614,7 +42680,7 @@ ${newlined}
|
|
|
42614
42680
|
action: "create service"
|
|
42615
42681
|
});
|
|
42616
42682
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
42617
|
-
throw new
|
|
42683
|
+
throw new requirement_js_1.RoomException("Invalid create service response payload");
|
|
42618
42684
|
}
|
|
42619
42685
|
return data.id;
|
|
42620
42686
|
}
|
|
@@ -42625,7 +42691,7 @@ ${newlined}
|
|
|
42625
42691
|
action: "create room service"
|
|
42626
42692
|
});
|
|
42627
42693
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
42628
|
-
throw new
|
|
42694
|
+
throw new requirement_js_1.RoomException("Invalid create room service response payload");
|
|
42629
42695
|
}
|
|
42630
42696
|
return data.id;
|
|
42631
42697
|
}
|
|
@@ -42659,7 +42725,7 @@ ${newlined}
|
|
|
42659
42725
|
}
|
|
42660
42726
|
async updateService(projectId, serviceId, service) {
|
|
42661
42727
|
if (!service.id) {
|
|
42662
|
-
throw new
|
|
42728
|
+
throw new requirement_js_1.RoomException("Service id must be set to update a service");
|
|
42663
42729
|
}
|
|
42664
42730
|
await this.request(`/accounts/projects/${projectId}/services/${serviceId}`, {
|
|
42665
42731
|
method: "PUT",
|
|
@@ -42700,7 +42766,7 @@ ${newlined}
|
|
|
42700
42766
|
action: "create project secret"
|
|
42701
42767
|
});
|
|
42702
42768
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42703
|
-
throw new
|
|
42769
|
+
throw new requirement_js_1.RoomException("Invalid create project secret response payload");
|
|
42704
42770
|
}
|
|
42705
42771
|
return payload.id;
|
|
42706
42772
|
}
|
|
@@ -42752,7 +42818,7 @@ ${newlined}
|
|
|
42752
42818
|
action: "create room secret"
|
|
42753
42819
|
});
|
|
42754
42820
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42755
|
-
throw new
|
|
42821
|
+
throw new requirement_js_1.RoomException("Invalid create room secret response payload");
|
|
42756
42822
|
}
|
|
42757
42823
|
return payload.id;
|
|
42758
42824
|
}
|
|
@@ -42810,19 +42876,19 @@ ${newlined}
|
|
|
42810
42876
|
projectId,
|
|
42811
42877
|
name: secret.name,
|
|
42812
42878
|
type: secret.type,
|
|
42813
|
-
data:
|
|
42879
|
+
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data))
|
|
42814
42880
|
});
|
|
42815
42881
|
}
|
|
42816
42882
|
async updateSecret(projectId, secret) {
|
|
42817
42883
|
if (!secret.id) {
|
|
42818
|
-
throw new
|
|
42884
|
+
throw new requirement_js_1.RoomException("Secret id is required to update a secret");
|
|
42819
42885
|
}
|
|
42820
42886
|
await this.updateProjectSecret({
|
|
42821
42887
|
projectId,
|
|
42822
42888
|
secretId: secret.id,
|
|
42823
42889
|
name: secret.name,
|
|
42824
42890
|
type: secret.type,
|
|
42825
|
-
data:
|
|
42891
|
+
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data))
|
|
42826
42892
|
});
|
|
42827
42893
|
}
|
|
42828
42894
|
async deleteSecret(projectId, secretId) {
|
|
@@ -42850,7 +42916,7 @@ ${newlined}
|
|
|
42850
42916
|
action: "create project external oauth registration"
|
|
42851
42917
|
});
|
|
42852
42918
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42853
|
-
throw new
|
|
42919
|
+
throw new requirement_js_1.RoomException("Invalid create project external oauth registration response payload");
|
|
42854
42920
|
}
|
|
42855
42921
|
return payload.id;
|
|
42856
42922
|
}
|
|
@@ -42905,7 +42971,7 @@ ${newlined}
|
|
|
42905
42971
|
action: "create room external oauth registration"
|
|
42906
42972
|
});
|
|
42907
42973
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42908
|
-
throw new
|
|
42974
|
+
throw new requirement_js_1.RoomException("Invalid create room external oauth registration response payload");
|
|
42909
42975
|
}
|
|
42910
42976
|
return payload.id;
|
|
42911
42977
|
}
|
|
@@ -42957,7 +43023,7 @@ ${newlined}
|
|
|
42957
43023
|
if (permissions) {
|
|
42958
43024
|
const serialized = {};
|
|
42959
43025
|
for (const [key, value] of Object.entries(permissions)) {
|
|
42960
|
-
serialized[key] = value instanceof
|
|
43026
|
+
serialized[key] = value instanceof participant_token_js_1.ApiScope ? value.toJSON() : value;
|
|
42961
43027
|
}
|
|
42962
43028
|
payload["permissions"] = serialized;
|
|
42963
43029
|
}
|
|
@@ -43257,13 +43323,13 @@ ${newlined}
|
|
|
43257
43323
|
"use strict";
|
|
43258
43324
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43259
43325
|
exports.MessagingClient = void 0;
|
|
43260
|
-
var
|
|
43261
|
-
var
|
|
43262
|
-
var
|
|
43263
|
-
var
|
|
43264
|
-
var
|
|
43265
|
-
var
|
|
43266
|
-
var
|
|
43326
|
+
var completer_js_1 = require_completer();
|
|
43327
|
+
var event_emitter_js_1 = require_event_emitter();
|
|
43328
|
+
var participant_js_1 = require_participant();
|
|
43329
|
+
var response_js_1 = require_response();
|
|
43330
|
+
var room_event_js_1 = require_room_event();
|
|
43331
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
43332
|
+
var utils_js_1 = require_utils();
|
|
43267
43333
|
var globalScope = globalThis;
|
|
43268
43334
|
function bytesToBase64(bytes) {
|
|
43269
43335
|
if (globalScope.Buffer != null) {
|
|
@@ -43278,7 +43344,7 @@ ${newlined}
|
|
|
43278
43344
|
}
|
|
43279
43345
|
return globalScope.btoa(binary);
|
|
43280
43346
|
}
|
|
43281
|
-
var MessagingClient = class extends
|
|
43347
|
+
var MessagingClient = class extends event_emitter_js_1.EventEmitter {
|
|
43282
43348
|
constructor({ room }) {
|
|
43283
43349
|
super();
|
|
43284
43350
|
this._messageHandler = this._handleMessageSend.bind(this);
|
|
@@ -43319,14 +43385,14 @@ ${newlined}
|
|
|
43319
43385
|
await this.client.invoke({
|
|
43320
43386
|
toolkit: "messaging",
|
|
43321
43387
|
tool: operation,
|
|
43322
|
-
input: new
|
|
43388
|
+
input: new response_js_1.JsonContent({ json: input })
|
|
43323
43389
|
});
|
|
43324
43390
|
}
|
|
43325
43391
|
_invokeNowait({ operation, input }) {
|
|
43326
43392
|
this.client.invokeNowait({
|
|
43327
43393
|
toolkit: "messaging",
|
|
43328
43394
|
tool: operation,
|
|
43329
|
-
input: new
|
|
43395
|
+
input: new response_js_1.JsonContent({ json: input })
|
|
43330
43396
|
});
|
|
43331
43397
|
}
|
|
43332
43398
|
start() {
|
|
@@ -43360,7 +43426,7 @@ ${newlined}
|
|
|
43360
43426
|
if (this._messageQueueClosed) {
|
|
43361
43427
|
return null;
|
|
43362
43428
|
}
|
|
43363
|
-
this._messageQueued ?? (this._messageQueued = new
|
|
43429
|
+
this._messageQueued ?? (this._messageQueued = new completer_js_1.Completer());
|
|
43364
43430
|
await this._messageQueued.fut;
|
|
43365
43431
|
}
|
|
43366
43432
|
}
|
|
@@ -43373,7 +43439,7 @@ ${newlined}
|
|
|
43373
43439
|
}
|
|
43374
43440
|
_queueMessage(message2) {
|
|
43375
43441
|
if (this._messageQueueClosed) {
|
|
43376
|
-
throw new
|
|
43442
|
+
throw new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has been stopped");
|
|
43377
43443
|
}
|
|
43378
43444
|
this._messageQueue.push(message2);
|
|
43379
43445
|
this._wakeMessageQueue();
|
|
@@ -43429,7 +43495,7 @@ ${newlined}
|
|
|
43429
43495
|
return participant;
|
|
43430
43496
|
}
|
|
43431
43497
|
_markParticipantOffline(participant) {
|
|
43432
|
-
if (!(participant instanceof
|
|
43498
|
+
if (!(participant instanceof participant_js_1.RemoteParticipant)) {
|
|
43433
43499
|
return;
|
|
43434
43500
|
}
|
|
43435
43501
|
participant._setOnline(false);
|
|
@@ -43441,7 +43507,7 @@ ${newlined}
|
|
|
43441
43507
|
if (to == null) {
|
|
43442
43508
|
return null;
|
|
43443
43509
|
}
|
|
43444
|
-
if (!(to instanceof
|
|
43510
|
+
if (!(to instanceof participant_js_1.RemoteParticipant)) {
|
|
43445
43511
|
return to;
|
|
43446
43512
|
}
|
|
43447
43513
|
if (to.online === false) {
|
|
@@ -43474,11 +43540,11 @@ ${newlined}
|
|
|
43474
43540
|
await this._waitUntilOnline();
|
|
43475
43541
|
}
|
|
43476
43542
|
} catch (error) {
|
|
43477
|
-
if (error instanceof
|
|
43543
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
43478
43544
|
this._dropQueuedMessage({ message: message2, error });
|
|
43479
43545
|
this._drainQueuedMessages({ error });
|
|
43480
43546
|
} else {
|
|
43481
|
-
const wrapped = new
|
|
43547
|
+
const wrapped = new room_server_client_js_1.RoomServerException(String(error));
|
|
43482
43548
|
this._dropQueuedMessage({ message: message2, error: wrapped });
|
|
43483
43549
|
this._drainQueuedMessages({ error: wrapped });
|
|
43484
43550
|
}
|
|
@@ -43488,7 +43554,7 @@ ${newlined}
|
|
|
43488
43554
|
if (resolvedTo == null) {
|
|
43489
43555
|
this._dropQueuedMessage({
|
|
43490
43556
|
message: message2,
|
|
43491
|
-
error: new
|
|
43557
|
+
error: new room_server_client_js_1.RoomServerException("the participant was not found")
|
|
43492
43558
|
});
|
|
43493
43559
|
continue;
|
|
43494
43560
|
}
|
|
@@ -43506,7 +43572,7 @@ ${newlined}
|
|
|
43506
43572
|
message2.completer.complete();
|
|
43507
43573
|
}
|
|
43508
43574
|
} catch (error) {
|
|
43509
|
-
if (error instanceof
|
|
43575
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
43510
43576
|
const wrapped = this.client._coerceMessageSendError(error);
|
|
43511
43577
|
if (wrapped.message === "the participant was not found") {
|
|
43512
43578
|
this._markParticipantOffline(message2.to);
|
|
@@ -43524,7 +43590,7 @@ ${newlined}
|
|
|
43524
43590
|
}
|
|
43525
43591
|
async sendMessage({ to, type, message: message2, attachment, ignoreOffline = false }) {
|
|
43526
43592
|
if (this._sendTask == null) {
|
|
43527
|
-
throw new
|
|
43593
|
+
throw new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has not been started");
|
|
43528
43594
|
}
|
|
43529
43595
|
const queued = {
|
|
43530
43596
|
to,
|
|
@@ -43532,7 +43598,7 @@ ${newlined}
|
|
|
43532
43598
|
message: message2,
|
|
43533
43599
|
attachment,
|
|
43534
43600
|
dropIfOffline: ignoreOffline,
|
|
43535
|
-
completer: ignoreOffline ? void 0 : new
|
|
43601
|
+
completer: ignoreOffline ? void 0 : new completer_js_1.Completer()
|
|
43536
43602
|
};
|
|
43537
43603
|
this._queueMessage(queued);
|
|
43538
43604
|
if (queued.completer != null) {
|
|
@@ -43564,7 +43630,7 @@ ${newlined}
|
|
|
43564
43630
|
}
|
|
43565
43631
|
async broadcastMessage({ type, message: message2, attachment }) {
|
|
43566
43632
|
if (this._sendTask == null) {
|
|
43567
|
-
throw new
|
|
43633
|
+
throw new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has not been started");
|
|
43568
43634
|
}
|
|
43569
43635
|
await this.client._waitUntilConnectedForMessages();
|
|
43570
43636
|
if (this._desiredEnabled) {
|
|
@@ -43576,7 +43642,7 @@ ${newlined}
|
|
|
43576
43642
|
input: this._messageInput({ type, message: message2, attachment })
|
|
43577
43643
|
});
|
|
43578
43644
|
} catch (error) {
|
|
43579
|
-
if (error instanceof
|
|
43645
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
43580
43646
|
throw this.client._coerceMessageSendError(error);
|
|
43581
43647
|
}
|
|
43582
43648
|
throw error;
|
|
@@ -43600,10 +43666,10 @@ ${newlined}
|
|
|
43600
43666
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
43601
43667
|
return;
|
|
43602
43668
|
}
|
|
43603
|
-
const headerStr = (0,
|
|
43604
|
-
const payload = (0,
|
|
43669
|
+
const headerStr = (0, utils_js_1.splitMessageHeader)(bytes);
|
|
43670
|
+
const payload = (0, utils_js_1.splitMessagePayload)(bytes);
|
|
43605
43671
|
const header = JSON.parse(headerStr);
|
|
43606
|
-
const message2 = new
|
|
43672
|
+
const message2 = new room_event_js_1.RoomMessage({
|
|
43607
43673
|
fromParticipantId: header["from_participant_id"],
|
|
43608
43674
|
type: header["type"],
|
|
43609
43675
|
message: header["message"],
|
|
@@ -43625,16 +43691,16 @@ ${newlined}
|
|
|
43625
43691
|
default:
|
|
43626
43692
|
break;
|
|
43627
43693
|
}
|
|
43628
|
-
const event = new
|
|
43694
|
+
const event = new room_event_js_1.RoomMessageEvent({ message: message2 });
|
|
43629
43695
|
this.client.emit(event);
|
|
43630
43696
|
this.emit("message", event);
|
|
43631
43697
|
}
|
|
43632
43698
|
_onParticipantEnabled(message2) {
|
|
43633
43699
|
const data = message2.message;
|
|
43634
|
-
const participant = new
|
|
43700
|
+
const participant = new participant_js_1.RemoteParticipant(this.client, data.id, data.role, true);
|
|
43635
43701
|
participant._setAttributes(data.attributes ?? {});
|
|
43636
43702
|
this._participants[data.id] = participant;
|
|
43637
|
-
this.emit("participant_added", new
|
|
43703
|
+
this.emit("participant_added", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43638
43704
|
}
|
|
43639
43705
|
_onParticipantAttributes(message2) {
|
|
43640
43706
|
const participant = this._participants[message2.fromParticipantId];
|
|
@@ -43642,12 +43708,12 @@ ${newlined}
|
|
|
43642
43708
|
return;
|
|
43643
43709
|
}
|
|
43644
43710
|
participant._setAttributes(message2.message["attributes"]);
|
|
43645
|
-
this.emit("participant_attributes_updated", new
|
|
43711
|
+
this.emit("participant_attributes_updated", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43646
43712
|
}
|
|
43647
43713
|
_onParticipantDisabled(message2) {
|
|
43648
43714
|
const removed = this._removeParticipant(String(message2.message["id"]));
|
|
43649
43715
|
if (removed != null) {
|
|
43650
|
-
this.emit("participant_removed", new
|
|
43716
|
+
this.emit("participant_removed", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43651
43717
|
}
|
|
43652
43718
|
}
|
|
43653
43719
|
_onMessagingEnabled(message2) {
|
|
@@ -43657,7 +43723,7 @@ ${newlined}
|
|
|
43657
43723
|
}
|
|
43658
43724
|
const participants = message2.message["participants"];
|
|
43659
43725
|
for (const data of participants) {
|
|
43660
|
-
const participant = new
|
|
43726
|
+
const participant = new participant_js_1.RemoteParticipant(this.client, data.id, data.role, true);
|
|
43661
43727
|
participant._setAttributes(data.attributes ?? {});
|
|
43662
43728
|
this._participants[data.id] = participant;
|
|
43663
43729
|
}
|
|
@@ -43667,10 +43733,10 @@ ${newlined}
|
|
|
43667
43733
|
this._clearCurrentConnectionState();
|
|
43668
43734
|
return;
|
|
43669
43735
|
}
|
|
43670
|
-
this.emit("messaging_enabled", new
|
|
43736
|
+
this.emit("messaging_enabled", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43671
43737
|
}
|
|
43672
43738
|
dispose() {
|
|
43673
|
-
const error = new
|
|
43739
|
+
const error = new room_server_client_js_1.RoomServerException("messaging client disposed");
|
|
43674
43740
|
this._messageQueueClosed = true;
|
|
43675
43741
|
this._wakeMessageQueue();
|
|
43676
43742
|
this._drainQueuedMessages({ error });
|
|
@@ -43690,8 +43756,8 @@ ${newlined}
|
|
|
43690
43756
|
"use strict";
|
|
43691
43757
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43692
43758
|
exports.MemoryClient = void 0;
|
|
43693
|
-
var
|
|
43694
|
-
var
|
|
43759
|
+
var response_js_1 = require_response();
|
|
43760
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
43695
43761
|
var globalScope = globalThis;
|
|
43696
43762
|
function bytesToBase64(bytes) {
|
|
43697
43763
|
if (globalScope.Buffer) {
|
|
@@ -43724,7 +43790,7 @@ ${newlined}
|
|
|
43724
43790
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43725
43791
|
}
|
|
43726
43792
|
function unexpectedResponse(operation) {
|
|
43727
|
-
return new
|
|
43793
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from memory.${operation}`);
|
|
43728
43794
|
}
|
|
43729
43795
|
function requireString(value, operation) {
|
|
43730
43796
|
if (typeof value !== "string") {
|
|
@@ -44020,16 +44086,16 @@ ${newlined}
|
|
|
44020
44086
|
tool: operation,
|
|
44021
44087
|
input
|
|
44022
44088
|
});
|
|
44023
|
-
if (response instanceof
|
|
44089
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
44024
44090
|
return response;
|
|
44025
44091
|
}
|
|
44026
|
-
if (response instanceof
|
|
44092
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44027
44093
|
return null;
|
|
44028
44094
|
}
|
|
44029
44095
|
throw this.unexpectedResponse(operation);
|
|
44030
44096
|
}
|
|
44031
44097
|
expectJsonResponse(response, operation) {
|
|
44032
|
-
if (!(response instanceof
|
|
44098
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44033
44099
|
throw this.unexpectedResponse(operation);
|
|
44034
44100
|
}
|
|
44035
44101
|
return response;
|
|
@@ -44245,8 +44311,8 @@ ${newlined}
|
|
|
44245
44311
|
"use strict";
|
|
44246
44312
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44247
44313
|
exports.QueuesClient = exports.Queue = void 0;
|
|
44248
|
-
var
|
|
44249
|
-
var
|
|
44314
|
+
var response_js_1 = require_response();
|
|
44315
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44250
44316
|
var Queue = class {
|
|
44251
44317
|
constructor({ name, size }) {
|
|
44252
44318
|
this.name = name;
|
|
@@ -44259,7 +44325,7 @@ ${newlined}
|
|
|
44259
44325
|
this.client = room;
|
|
44260
44326
|
}
|
|
44261
44327
|
_unexpectedResponseError(operation) {
|
|
44262
|
-
return new
|
|
44328
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from queues.${operation}`);
|
|
44263
44329
|
}
|
|
44264
44330
|
async _invoke(operation, arguments_) {
|
|
44265
44331
|
return await this.client.invoke({
|
|
@@ -44270,7 +44336,7 @@ ${newlined}
|
|
|
44270
44336
|
}
|
|
44271
44337
|
async list() {
|
|
44272
44338
|
const response = await this._invoke("list", {});
|
|
44273
|
-
if (!(response instanceof
|
|
44339
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44274
44340
|
throw this._unexpectedResponseError("list");
|
|
44275
44341
|
}
|
|
44276
44342
|
const queues = response.json["queues"];
|
|
@@ -44278,25 +44344,25 @@ ${newlined}
|
|
|
44278
44344
|
}
|
|
44279
44345
|
async open(name) {
|
|
44280
44346
|
const response = await this._invoke("open", { name });
|
|
44281
|
-
if (!(response instanceof
|
|
44347
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44282
44348
|
throw this._unexpectedResponseError("open");
|
|
44283
44349
|
}
|
|
44284
44350
|
}
|
|
44285
44351
|
async drain(name) {
|
|
44286
44352
|
const response = await this._invoke("drain", { name });
|
|
44287
|
-
if (!(response instanceof
|
|
44353
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44288
44354
|
throw this._unexpectedResponseError("drain");
|
|
44289
44355
|
}
|
|
44290
44356
|
}
|
|
44291
44357
|
async close(name) {
|
|
44292
44358
|
const response = await this._invoke("close", { name });
|
|
44293
|
-
if (!(response instanceof
|
|
44359
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44294
44360
|
throw this._unexpectedResponseError("close");
|
|
44295
44361
|
}
|
|
44296
44362
|
}
|
|
44297
44363
|
async send(name, message2, { create = true }) {
|
|
44298
44364
|
const response = await this._invoke("send", { name, create, message: message2 });
|
|
44299
|
-
if (!(response instanceof
|
|
44365
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44300
44366
|
throw this._unexpectedResponseError("send");
|
|
44301
44367
|
}
|
|
44302
44368
|
}
|
|
@@ -44306,10 +44372,10 @@ ${newlined}
|
|
|
44306
44372
|
create,
|
|
44307
44373
|
wait
|
|
44308
44374
|
});
|
|
44309
|
-
if (response instanceof
|
|
44375
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44310
44376
|
return null;
|
|
44311
44377
|
}
|
|
44312
|
-
if (response instanceof
|
|
44378
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
44313
44379
|
return response.json;
|
|
44314
44380
|
}
|
|
44315
44381
|
throw this._unexpectedResponseError("receive");
|
|
@@ -44325,9 +44391,9 @@ ${newlined}
|
|
|
44325
44391
|
"use strict";
|
|
44326
44392
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44327
44393
|
exports.SecretsClient = void 0;
|
|
44328
|
-
var
|
|
44329
|
-
var
|
|
44330
|
-
var
|
|
44394
|
+
var response_js_1 = require_response();
|
|
44395
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44396
|
+
var utils_js_1 = require_utils();
|
|
44331
44397
|
function isRecord(value) {
|
|
44332
44398
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44333
44399
|
}
|
|
@@ -44342,7 +44408,7 @@ ${newlined}
|
|
|
44342
44408
|
this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
|
|
44343
44409
|
}
|
|
44344
44410
|
unexpectedResponse(operation) {
|
|
44345
|
-
return new
|
|
44411
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from secrets.${operation}`);
|
|
44346
44412
|
}
|
|
44347
44413
|
async invoke(operation, input) {
|
|
44348
44414
|
return await this.client.invoke({
|
|
@@ -44375,7 +44441,7 @@ ${newlined}
|
|
|
44375
44441
|
};
|
|
44376
44442
|
}
|
|
44377
44443
|
parseAccessToken(operation, response) {
|
|
44378
|
-
if (!(response instanceof
|
|
44444
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44379
44445
|
throw this.unexpectedResponse(operation);
|
|
44380
44446
|
}
|
|
44381
44447
|
const token = response.json["access_token"];
|
|
@@ -44406,25 +44472,25 @@ ${newlined}
|
|
|
44406
44472
|
void messageId;
|
|
44407
44473
|
void type;
|
|
44408
44474
|
if (bytes == null) {
|
|
44409
|
-
throw new
|
|
44475
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44410
44476
|
}
|
|
44411
44477
|
if (this.oauthTokenRequestHandler == null) {
|
|
44412
|
-
throw new
|
|
44478
|
+
throw new room_server_client_js_1.RoomServerException("No oauth token handler registered");
|
|
44413
44479
|
}
|
|
44414
|
-
const [request] = (0,
|
|
44480
|
+
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
44415
44481
|
const requestId = request["request_id"];
|
|
44416
44482
|
const challenge = request["challenge"];
|
|
44417
44483
|
const requestPayload = request["request"];
|
|
44418
44484
|
if (typeof requestId !== "string" || !isRecord(requestPayload)) {
|
|
44419
|
-
throw new
|
|
44485
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44420
44486
|
}
|
|
44421
44487
|
const oauth = requestPayload["oauth"];
|
|
44422
44488
|
if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
|
|
44423
|
-
throw new
|
|
44489
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44424
44490
|
}
|
|
44425
44491
|
const scopes = oauth["scopes"];
|
|
44426
44492
|
if (scopes !== void 0 && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
|
|
44427
|
-
throw new
|
|
44493
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44428
44494
|
}
|
|
44429
44495
|
Promise.resolve(this.oauthTokenRequestHandler({
|
|
44430
44496
|
requestId,
|
|
@@ -44444,16 +44510,16 @@ ${newlined}
|
|
|
44444
44510
|
void messageId;
|
|
44445
44511
|
void type;
|
|
44446
44512
|
if (bytes == null) {
|
|
44447
|
-
throw new
|
|
44513
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
44448
44514
|
}
|
|
44449
44515
|
if (this.secretRequestHandler == null) {
|
|
44450
|
-
throw new
|
|
44516
|
+
throw new room_server_client_js_1.RoomServerException("No secret handler registered");
|
|
44451
44517
|
}
|
|
44452
|
-
const [request] = (0,
|
|
44518
|
+
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
44453
44519
|
const requestId = request["request_id"];
|
|
44454
44520
|
const requestPayload = request["request"];
|
|
44455
44521
|
if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
|
|
44456
|
-
throw new
|
|
44522
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
44457
44523
|
}
|
|
44458
44524
|
Promise.resolve(this.secretRequestHandler({
|
|
44459
44525
|
requestId,
|
|
@@ -44470,7 +44536,7 @@ ${newlined}
|
|
|
44470
44536
|
code,
|
|
44471
44537
|
error: null
|
|
44472
44538
|
});
|
|
44473
|
-
if (response instanceof
|
|
44539
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44474
44540
|
return;
|
|
44475
44541
|
}
|
|
44476
44542
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
@@ -44481,33 +44547,33 @@ ${newlined}
|
|
|
44481
44547
|
code: null,
|
|
44482
44548
|
error
|
|
44483
44549
|
});
|
|
44484
|
-
if (response instanceof
|
|
44550
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44485
44551
|
return;
|
|
44486
44552
|
}
|
|
44487
44553
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
44488
44554
|
}
|
|
44489
44555
|
async provideSecret({ requestId, data }) {
|
|
44490
|
-
const response = await this.invoke("provide_secret", new
|
|
44556
|
+
const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
|
|
44491
44557
|
data,
|
|
44492
44558
|
headers: {
|
|
44493
44559
|
request_id: requestId,
|
|
44494
44560
|
error: null
|
|
44495
44561
|
}
|
|
44496
44562
|
}));
|
|
44497
|
-
if (response instanceof
|
|
44563
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44498
44564
|
return;
|
|
44499
44565
|
}
|
|
44500
44566
|
throw this.unexpectedResponse("provide_secret");
|
|
44501
44567
|
}
|
|
44502
44568
|
async rejectSecret({ requestId, error }) {
|
|
44503
|
-
const response = await this.invoke("provide_secret", new
|
|
44569
|
+
const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
|
|
44504
44570
|
data: new Uint8Array(0),
|
|
44505
44571
|
headers: {
|
|
44506
44572
|
request_id: requestId,
|
|
44507
44573
|
error
|
|
44508
44574
|
}
|
|
44509
44575
|
}));
|
|
44510
|
-
if (response instanceof
|
|
44576
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44511
44577
|
return;
|
|
44512
44578
|
}
|
|
44513
44579
|
throw this.unexpectedResponse("provide_secret");
|
|
@@ -44534,7 +44600,7 @@ ${newlined}
|
|
|
44534
44600
|
}
|
|
44535
44601
|
async listSecrets() {
|
|
44536
44602
|
const response = await this.invoke("list_secrets", {});
|
|
44537
|
-
if (!(response instanceof
|
|
44603
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44538
44604
|
throw this.unexpectedResponse("list_secrets");
|
|
44539
44605
|
}
|
|
44540
44606
|
const secrets = response.json["secrets"];
|
|
@@ -44549,7 +44615,7 @@ ${newlined}
|
|
|
44549
44615
|
delegated_to: delegatedTo ?? null,
|
|
44550
44616
|
for_identity: forIdentity ?? null
|
|
44551
44617
|
});
|
|
44552
|
-
if (!(response instanceof
|
|
44618
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
44553
44619
|
throw this.unexpectedResponse("exists");
|
|
44554
44620
|
}
|
|
44555
44621
|
return response.json["exists"];
|
|
@@ -44559,7 +44625,7 @@ ${newlined}
|
|
|
44559
44625
|
id: secretId,
|
|
44560
44626
|
delegated_to: delegatedTo ?? null
|
|
44561
44627
|
});
|
|
44562
|
-
if (response instanceof
|
|
44628
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44563
44629
|
return;
|
|
44564
44630
|
}
|
|
44565
44631
|
throw this.unexpectedResponse("delete_secret");
|
|
@@ -44570,7 +44636,7 @@ ${newlined}
|
|
|
44570
44636
|
type,
|
|
44571
44637
|
delegated_to: delegatedTo ?? null
|
|
44572
44638
|
});
|
|
44573
|
-
if (response instanceof
|
|
44639
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44574
44640
|
return;
|
|
44575
44641
|
}
|
|
44576
44642
|
throw this.unexpectedResponse("delete_requested_secret");
|
|
@@ -44583,13 +44649,13 @@ ${newlined}
|
|
|
44583
44649
|
timeout,
|
|
44584
44650
|
delegate_to: delegateTo ?? null
|
|
44585
44651
|
});
|
|
44586
|
-
if (response instanceof
|
|
44652
|
+
if (response instanceof response_js_1.FileContent) {
|
|
44587
44653
|
return response.data;
|
|
44588
44654
|
}
|
|
44589
44655
|
throw this.unexpectedResponse("request_secret");
|
|
44590
44656
|
}
|
|
44591
44657
|
async setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data }) {
|
|
44592
|
-
const response = await this.invoke("set_secret", new
|
|
44658
|
+
const response = await this.invoke("set_secret", new response_js_1.BinaryContent({
|
|
44593
44659
|
data,
|
|
44594
44660
|
headers: {
|
|
44595
44661
|
secret_id: secretId ?? null,
|
|
@@ -44600,7 +44666,7 @@ ${newlined}
|
|
|
44600
44666
|
has_data: true
|
|
44601
44667
|
}
|
|
44602
44668
|
}));
|
|
44603
|
-
if (response instanceof
|
|
44669
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44604
44670
|
return;
|
|
44605
44671
|
}
|
|
44606
44672
|
throw this.unexpectedResponse("set_secret");
|
|
@@ -44612,10 +44678,10 @@ ${newlined}
|
|
|
44612
44678
|
name: name ?? null,
|
|
44613
44679
|
delegated_to: delegatedTo ?? null
|
|
44614
44680
|
});
|
|
44615
|
-
if (response instanceof
|
|
44681
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44616
44682
|
return null;
|
|
44617
44683
|
}
|
|
44618
|
-
if (response instanceof
|
|
44684
|
+
if (response instanceof response_js_1.FileContent) {
|
|
44619
44685
|
return response;
|
|
44620
44686
|
}
|
|
44621
44687
|
throw this.unexpectedResponse("get_secret");
|
|
@@ -44631,8 +44697,8 @@ ${newlined}
|
|
|
44631
44697
|
"use strict";
|
|
44632
44698
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44633
44699
|
exports.ServicesClient = void 0;
|
|
44634
|
-
var
|
|
44635
|
-
var
|
|
44700
|
+
var response_js_1 = require_response();
|
|
44701
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44636
44702
|
function isRecord(value) {
|
|
44637
44703
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44638
44704
|
}
|
|
@@ -44644,7 +44710,7 @@ ${newlined}
|
|
|
44644
44710
|
}
|
|
44645
44711
|
function parseServiceRuntimeState(value) {
|
|
44646
44712
|
if (!isRecord(value) || typeof value["service_id"] !== "string") {
|
|
44647
|
-
throw new
|
|
44713
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
44648
44714
|
}
|
|
44649
44715
|
const state = value["state"];
|
|
44650
44716
|
const containerId = value["container_id"];
|
|
@@ -44663,12 +44729,12 @@ ${newlined}
|
|
|
44663
44729
|
if (typeof value === "string") {
|
|
44664
44730
|
const parsed = JSON.parse(value);
|
|
44665
44731
|
if (!isRecord(parsed)) {
|
|
44666
|
-
throw new
|
|
44732
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
44667
44733
|
}
|
|
44668
44734
|
return parsed;
|
|
44669
44735
|
}
|
|
44670
44736
|
if (!isRecord(value)) {
|
|
44671
|
-
throw new
|
|
44737
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
44672
44738
|
}
|
|
44673
44739
|
return value;
|
|
44674
44740
|
}
|
|
@@ -44677,7 +44743,7 @@ ${newlined}
|
|
|
44677
44743
|
this.room = room;
|
|
44678
44744
|
}
|
|
44679
44745
|
unexpectedResponse(operation) {
|
|
44680
|
-
return new
|
|
44746
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from services.${operation}`);
|
|
44681
44747
|
}
|
|
44682
44748
|
async list() {
|
|
44683
44749
|
return (await this.listWithState()).services;
|
|
@@ -44688,7 +44754,7 @@ ${newlined}
|
|
|
44688
44754
|
tool: "list",
|
|
44689
44755
|
input: {}
|
|
44690
44756
|
});
|
|
44691
|
-
if (!(response instanceof
|
|
44757
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44692
44758
|
throw this.unexpectedResponse("list");
|
|
44693
44759
|
}
|
|
44694
44760
|
const servicesRaw = response.json["services_json"];
|
|
@@ -44714,7 +44780,7 @@ ${newlined}
|
|
|
44714
44780
|
service_id: params.serviceId
|
|
44715
44781
|
}
|
|
44716
44782
|
});
|
|
44717
|
-
if (response instanceof
|
|
44783
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44718
44784
|
return;
|
|
44719
44785
|
}
|
|
44720
44786
|
throw this.unexpectedResponse("restart");
|
|
@@ -44730,11 +44796,11 @@ ${newlined}
|
|
|
44730
44796
|
"use strict";
|
|
44731
44797
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44732
44798
|
exports.StorageClient = exports.StorageEntry = exports.FileHandle = void 0;
|
|
44733
|
-
var
|
|
44734
|
-
var
|
|
44735
|
-
var
|
|
44736
|
-
var
|
|
44737
|
-
var
|
|
44799
|
+
var room_event_js_1 = require_room_event();
|
|
44800
|
+
var response_js_1 = require_response();
|
|
44801
|
+
var utils_js_1 = require_utils();
|
|
44802
|
+
var event_emitter_js_1 = require_event_emitter();
|
|
44803
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44738
44804
|
var _DEFAULT_UPLOAD_MIME_TYPE = "application/octet-stream";
|
|
44739
44805
|
var _UPLOAD_MIME_TYPES_BY_SUFFIX = /* @__PURE__ */ new Map([
|
|
44740
44806
|
[".tar.gz", "application/x-tar"],
|
|
@@ -44770,7 +44836,7 @@ ${newlined}
|
|
|
44770
44836
|
[".zip", "application/zip"]
|
|
44771
44837
|
]);
|
|
44772
44838
|
function _unexpectedStorageResponseError(operation) {
|
|
44773
|
-
return new
|
|
44839
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from storage.${operation}`);
|
|
44774
44840
|
}
|
|
44775
44841
|
function _parseStorageTimestamp(value, operation) {
|
|
44776
44842
|
if (value == null) {
|
|
@@ -44805,7 +44871,7 @@ ${newlined}
|
|
|
44805
44871
|
}
|
|
44806
44872
|
};
|
|
44807
44873
|
exports.StorageEntry = StorageEntry;
|
|
44808
|
-
var StorageClient = class extends
|
|
44874
|
+
var StorageClient = class extends event_emitter_js_1.EventEmitter {
|
|
44809
44875
|
constructor({ room }) {
|
|
44810
44876
|
super();
|
|
44811
44877
|
this.client = room;
|
|
@@ -44817,8 +44883,8 @@ ${newlined}
|
|
|
44817
44883
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
44818
44884
|
return;
|
|
44819
44885
|
}
|
|
44820
|
-
const [data, _] = (0,
|
|
44821
|
-
const event = new
|
|
44886
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
44887
|
+
const event = new room_event_js_1.FileUpdatedEvent({ path: data["path"], participantId: data["participant_id"] });
|
|
44822
44888
|
this.client.emit(event);
|
|
44823
44889
|
this.emit("file.updated", event);
|
|
44824
44890
|
}
|
|
@@ -44826,8 +44892,8 @@ ${newlined}
|
|
|
44826
44892
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
44827
44893
|
return;
|
|
44828
44894
|
}
|
|
44829
|
-
const [data, _] = (0,
|
|
44830
|
-
const event = new
|
|
44895
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
44896
|
+
const event = new room_event_js_1.FileDeletedEvent({ path: data["path"], participantId: data["participant_id"] });
|
|
44831
44897
|
this.client.emit(event);
|
|
44832
44898
|
this.emit("file.deleted", event);
|
|
44833
44899
|
}
|
|
@@ -44835,8 +44901,8 @@ ${newlined}
|
|
|
44835
44901
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
44836
44902
|
return;
|
|
44837
44903
|
}
|
|
44838
|
-
const [data, _] = (0,
|
|
44839
|
-
const event = new
|
|
44904
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
44905
|
+
const event = new room_event_js_1.FileMovedEvent({
|
|
44840
44906
|
sourcePath: data["source_path"],
|
|
44841
44907
|
destinationPath: data["destination_path"],
|
|
44842
44908
|
participantId: data["participant_id"]
|
|
@@ -44868,7 +44934,7 @@ ${newlined}
|
|
|
44868
44934
|
}
|
|
44869
44935
|
async list(path) {
|
|
44870
44936
|
const response = await this._invoke("list", { path });
|
|
44871
|
-
if (!(response instanceof
|
|
44937
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json["files"])) {
|
|
44872
44938
|
throw this._unexpectedResponseError("list");
|
|
44873
44939
|
}
|
|
44874
44940
|
const files = response.json["files"];
|
|
@@ -44878,7 +44944,7 @@ ${newlined}
|
|
|
44878
44944
|
}
|
|
44879
44945
|
async stat(path) {
|
|
44880
44946
|
const response = await this._invoke("stat", { path });
|
|
44881
|
-
if (!(response instanceof
|
|
44947
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
44882
44948
|
throw this._unexpectedResponseError("stat");
|
|
44883
44949
|
}
|
|
44884
44950
|
if (!response.json["exists"]) {
|
|
@@ -44898,7 +44964,7 @@ ${newlined}
|
|
|
44898
44964
|
}
|
|
44899
44965
|
async exists(path) {
|
|
44900
44966
|
const result = await this._invoke("exists", { path });
|
|
44901
|
-
if (!(result instanceof
|
|
44967
|
+
if (!(result instanceof response_js_1.JsonContent)) {
|
|
44902
44968
|
throw this._unexpectedResponseError("exists");
|
|
44903
44969
|
}
|
|
44904
44970
|
return result.json["exists"];
|
|
@@ -44957,16 +45023,16 @@ ${newlined}
|
|
|
44957
45023
|
});
|
|
44958
45024
|
try {
|
|
44959
45025
|
for await (const chunk of response) {
|
|
44960
|
-
if (chunk instanceof
|
|
44961
|
-
throw new
|
|
45026
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45027
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
44962
45028
|
}
|
|
44963
|
-
if (chunk instanceof
|
|
45029
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
44964
45030
|
if (chunk.method === "close") {
|
|
44965
45031
|
return;
|
|
44966
45032
|
}
|
|
44967
45033
|
throw this._unexpectedResponseError("upload");
|
|
44968
45034
|
}
|
|
44969
|
-
if (!(chunk instanceof
|
|
45035
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
44970
45036
|
throw this._unexpectedResponseError("upload");
|
|
44971
45037
|
}
|
|
44972
45038
|
if (chunk.headers["kind"] !== "pull") {
|
|
@@ -45016,7 +45082,7 @@ ${newlined}
|
|
|
45016
45082
|
data.set(part, offset);
|
|
45017
45083
|
offset += part.length;
|
|
45018
45084
|
}
|
|
45019
|
-
return new
|
|
45085
|
+
return new response_js_1.FileContent({ data, name, mimeType });
|
|
45020
45086
|
}
|
|
45021
45087
|
async downloadStream(path, { chunkSize = 64 * 1024 } = {}) {
|
|
45022
45088
|
const input = new _StorageDownloadInputStream({ path, chunkSize });
|
|
@@ -45033,10 +45099,10 @@ ${newlined}
|
|
|
45033
45099
|
let bytesReceived = 0;
|
|
45034
45100
|
try {
|
|
45035
45101
|
for await (const chunk of response) {
|
|
45036
|
-
if (chunk instanceof
|
|
45037
|
-
throw new
|
|
45102
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45103
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45038
45104
|
}
|
|
45039
|
-
if (chunk instanceof
|
|
45105
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45040
45106
|
if (chunk.method === "close") {
|
|
45041
45107
|
if (!metadataReceived || expectedSize == null || bytesReceived !== expectedSize) {
|
|
45042
45108
|
throw self2._unexpectedResponseError("download");
|
|
@@ -45045,7 +45111,7 @@ ${newlined}
|
|
|
45045
45111
|
}
|
|
45046
45112
|
throw self2._unexpectedResponseError("download");
|
|
45047
45113
|
}
|
|
45048
|
-
if (!(chunk instanceof
|
|
45114
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
45049
45115
|
throw self2._unexpectedResponseError("download");
|
|
45050
45116
|
}
|
|
45051
45117
|
const kind = chunk.headers["kind"];
|
|
@@ -45090,7 +45156,7 @@ ${newlined}
|
|
|
45090
45156
|
path,
|
|
45091
45157
|
download: options.download ?? false
|
|
45092
45158
|
});
|
|
45093
|
-
if (!(response instanceof
|
|
45159
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
45094
45160
|
throw this._unexpectedResponseError("download_url");
|
|
45095
45161
|
}
|
|
45096
45162
|
return response.json["url"];
|
|
@@ -45128,7 +45194,7 @@ ${newlined}
|
|
|
45128
45194
|
}
|
|
45129
45195
|
}
|
|
45130
45196
|
async *stream() {
|
|
45131
|
-
yield new
|
|
45197
|
+
yield new response_js_1.BinaryContent({
|
|
45132
45198
|
data: new Uint8Array(0),
|
|
45133
45199
|
headers: {
|
|
45134
45200
|
kind: "start",
|
|
@@ -45149,7 +45215,7 @@ ${newlined}
|
|
|
45149
45215
|
continue;
|
|
45150
45216
|
}
|
|
45151
45217
|
this.pendingPulls -= 1;
|
|
45152
|
-
yield new
|
|
45218
|
+
yield new response_js_1.BinaryContent({
|
|
45153
45219
|
data: new Uint8Array(0),
|
|
45154
45220
|
headers: { kind: "pull" }
|
|
45155
45221
|
});
|
|
@@ -45236,7 +45302,7 @@ ${newlined}
|
|
|
45236
45302
|
return combined;
|
|
45237
45303
|
}
|
|
45238
45304
|
async *stream() {
|
|
45239
|
-
yield new
|
|
45305
|
+
yield new response_js_1.BinaryContent({
|
|
45240
45306
|
data: new Uint8Array(0),
|
|
45241
45307
|
headers: {
|
|
45242
45308
|
kind: "start",
|
|
@@ -45264,7 +45330,7 @@ ${newlined}
|
|
|
45264
45330
|
if (chunk == null) {
|
|
45265
45331
|
return;
|
|
45266
45332
|
}
|
|
45267
|
-
yield new
|
|
45333
|
+
yield new response_js_1.BinaryContent({
|
|
45268
45334
|
data: chunk,
|
|
45269
45335
|
headers: { kind: "data" }
|
|
45270
45336
|
});
|
|
@@ -45280,13 +45346,13 @@ ${newlined}
|
|
|
45280
45346
|
"use strict";
|
|
45281
45347
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45282
45348
|
exports.SyncClient = void 0;
|
|
45283
|
-
var
|
|
45284
|
-
var
|
|
45285
|
-
var
|
|
45286
|
-
var
|
|
45287
|
-
var
|
|
45288
|
-
var
|
|
45289
|
-
var
|
|
45349
|
+
var completer_js_1 = require_completer();
|
|
45350
|
+
var event_emitter_js_1 = require_event_emitter();
|
|
45351
|
+
var schema_js_1 = require_schema3();
|
|
45352
|
+
var response_js_1 = require_response();
|
|
45353
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
45354
|
+
var runtime_js_1 = require_runtime();
|
|
45355
|
+
var utils_js_1 = require_utils();
|
|
45290
45356
|
function normalizeSyncPath(path) {
|
|
45291
45357
|
let normalized = path;
|
|
45292
45358
|
while (normalized.startsWith("./")) {
|
|
@@ -45302,7 +45368,7 @@ ${newlined}
|
|
|
45302
45368
|
}
|
|
45303
45369
|
function parseSyncOpenStateChunkHeaders(headers) {
|
|
45304
45370
|
if (headers["kind"] !== "state" || typeof headers["path"] !== "string" || typeof headers["schema"] !== "object" || headers["schema"] == null || Array.isArray(headers["schema"])) {
|
|
45305
|
-
throw new
|
|
45371
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from sync.open");
|
|
45306
45372
|
}
|
|
45307
45373
|
return {
|
|
45308
45374
|
kind: "state",
|
|
@@ -45313,7 +45379,7 @@ ${newlined}
|
|
|
45313
45379
|
function parseSyncOpenOutputChunkHeaders(headers) {
|
|
45314
45380
|
const kind = headers["kind"];
|
|
45315
45381
|
if (kind !== "state" && kind !== "sync" || typeof headers["path"] !== "string") {
|
|
45316
|
-
throw new
|
|
45382
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from sync.open");
|
|
45317
45383
|
}
|
|
45318
45384
|
return {
|
|
45319
45385
|
kind,
|
|
@@ -45345,7 +45411,7 @@ ${newlined}
|
|
|
45345
45411
|
});
|
|
45346
45412
|
}
|
|
45347
45413
|
async *inputStream() {
|
|
45348
|
-
yield new
|
|
45414
|
+
yield new response_js_1.BinaryContent({
|
|
45349
45415
|
data: new Uint8Array(),
|
|
45350
45416
|
headers: {
|
|
45351
45417
|
kind: "start",
|
|
@@ -45386,12 +45452,12 @@ ${newlined}
|
|
|
45386
45452
|
throw this._error;
|
|
45387
45453
|
}
|
|
45388
45454
|
if (this._error !== void 0) {
|
|
45389
|
-
throw new
|
|
45455
|
+
throw new room_server_client_js_1.RoomServerException(`sync stream failed: ${String(this._error)}`);
|
|
45390
45456
|
}
|
|
45391
45457
|
if (this._inputClosed) {
|
|
45392
|
-
throw new
|
|
45458
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
45393
45459
|
}
|
|
45394
|
-
this._enqueueChunk(new
|
|
45460
|
+
this._enqueueChunk(new response_js_1.BinaryContent({
|
|
45395
45461
|
data,
|
|
45396
45462
|
headers: { kind: "sync" }
|
|
45397
45463
|
}));
|
|
@@ -45401,7 +45467,7 @@ ${newlined}
|
|
|
45401
45467
|
}
|
|
45402
45468
|
};
|
|
45403
45469
|
SyncOpenStreamState.INPUT_STREAM_CLOSE = /* @__PURE__ */ Symbol("sync-open-input-close");
|
|
45404
|
-
var SyncClient = class extends
|
|
45470
|
+
var SyncClient = class extends event_emitter_js_1.EventEmitter {
|
|
45405
45471
|
constructor({ room }) {
|
|
45406
45472
|
super();
|
|
45407
45473
|
this._connectingDocuments = {};
|
|
@@ -45414,7 +45480,7 @@ ${newlined}
|
|
|
45414
45480
|
}
|
|
45415
45481
|
start() {
|
|
45416
45482
|
if (this._started) {
|
|
45417
|
-
throw new
|
|
45483
|
+
throw new room_server_client_js_1.RoomServerException("client already started");
|
|
45418
45484
|
}
|
|
45419
45485
|
this._started = true;
|
|
45420
45486
|
}
|
|
@@ -45424,7 +45490,7 @@ ${newlined}
|
|
|
45424
45490
|
streamState.closeInputStream();
|
|
45425
45491
|
}
|
|
45426
45492
|
for (const doc of Object.values(this._connectedDocuments)) {
|
|
45427
|
-
(0,
|
|
45493
|
+
(0, runtime_js_1.unregisterDocument)(doc.ref.id);
|
|
45428
45494
|
}
|
|
45429
45495
|
Object.keys(this._documentStreams).forEach((key) => delete this._documentStreams[key]);
|
|
45430
45496
|
Object.keys(this._documentConfigs).forEach((key) => delete this._documentConfigs[key]);
|
|
@@ -45434,7 +45500,7 @@ ${newlined}
|
|
|
45434
45500
|
this._started = false;
|
|
45435
45501
|
}
|
|
45436
45502
|
_unexpectedResponseError(operation) {
|
|
45437
|
-
return new
|
|
45503
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from sync.${operation}`);
|
|
45438
45504
|
}
|
|
45439
45505
|
async _invoke(operation, input) {
|
|
45440
45506
|
return await this.room.invoke({
|
|
@@ -45445,7 +45511,7 @@ ${newlined}
|
|
|
45445
45511
|
}
|
|
45446
45512
|
_applySyncPayload(rc, payload) {
|
|
45447
45513
|
if (payload.length > 0) {
|
|
45448
|
-
(0,
|
|
45514
|
+
(0, runtime_js_1.applyBackendChanges)(rc.ref.id, utils_js_1.decoder.decode(payload));
|
|
45449
45515
|
}
|
|
45450
45516
|
if (!rc.ref.isSynchronized) {
|
|
45451
45517
|
rc.ref.setSynchronizedComplete();
|
|
@@ -45475,7 +45541,7 @@ ${newlined}
|
|
|
45475
45541
|
connected.count += 1;
|
|
45476
45542
|
return connected.ref;
|
|
45477
45543
|
}
|
|
45478
|
-
const connecting = new
|
|
45544
|
+
const connecting = new completer_js_1.Completer();
|
|
45479
45545
|
this._connectingDocuments[normalizedPath] = connecting.fut;
|
|
45480
45546
|
try {
|
|
45481
45547
|
const config = {
|
|
@@ -45489,8 +45555,8 @@ ${newlined}
|
|
|
45489
45555
|
vector: null,
|
|
45490
45556
|
initialJson: initialJson ?? null
|
|
45491
45557
|
});
|
|
45492
|
-
const resolvedSchema =
|
|
45493
|
-
const doc = new
|
|
45558
|
+
const resolvedSchema = schema_js_1.MeshSchema.fromJson(openResult.stateHeaders.schema);
|
|
45559
|
+
const doc = new room_server_client_js_1.MeshDocument({
|
|
45494
45560
|
schema: resolvedSchema,
|
|
45495
45561
|
sendChangesToBackend: (base64) => {
|
|
45496
45562
|
const currentStream = this._documentStreams[normalizedPath];
|
|
@@ -45498,12 +45564,12 @@ ${newlined}
|
|
|
45498
45564
|
return;
|
|
45499
45565
|
}
|
|
45500
45566
|
try {
|
|
45501
|
-
currentStream.queueSync(
|
|
45567
|
+
currentStream.queueSync(utils_js_1.encoder.encode(base64));
|
|
45502
45568
|
} catch {
|
|
45503
45569
|
}
|
|
45504
45570
|
}
|
|
45505
45571
|
});
|
|
45506
|
-
const rc = new
|
|
45572
|
+
const rc = new utils_js_1.RefCount(doc);
|
|
45507
45573
|
this._connectedDocuments[normalizedPath] = rc;
|
|
45508
45574
|
this._documentConfigs[normalizedPath] = config;
|
|
45509
45575
|
this._documentStreams[normalizedPath] = openResult.streamState;
|
|
@@ -45529,7 +45595,7 @@ ${newlined}
|
|
|
45529
45595
|
const normalizedPath = normalizeSyncPath(path);
|
|
45530
45596
|
const rc = this._connectedDocuments[normalizedPath];
|
|
45531
45597
|
if (rc == null) {
|
|
45532
|
-
throw new
|
|
45598
|
+
throw new room_server_client_js_1.RoomServerException(`Not connected to ${normalizedPath}`);
|
|
45533
45599
|
}
|
|
45534
45600
|
rc.count -= 1;
|
|
45535
45601
|
if (rc.count === 0) {
|
|
@@ -45543,10 +45609,10 @@ ${newlined}
|
|
|
45543
45609
|
try {
|
|
45544
45610
|
await streamState.wait();
|
|
45545
45611
|
} finally {
|
|
45546
|
-
(0,
|
|
45612
|
+
(0, runtime_js_1.unregisterDocument)(rc.ref.id);
|
|
45547
45613
|
}
|
|
45548
45614
|
} else {
|
|
45549
|
-
(0,
|
|
45615
|
+
(0, runtime_js_1.unregisterDocument)(rc.ref.id);
|
|
45550
45616
|
}
|
|
45551
45617
|
})();
|
|
45552
45618
|
this._closingDocuments[normalizedPath] = closeFuture;
|
|
@@ -45563,11 +45629,11 @@ ${newlined}
|
|
|
45563
45629
|
async sync(path, data) {
|
|
45564
45630
|
const normalizedPath = normalizeSyncPath(path);
|
|
45565
45631
|
if (this._connectedDocuments[normalizedPath] == null) {
|
|
45566
|
-
throw new
|
|
45632
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
45567
45633
|
}
|
|
45568
45634
|
const streamState = this._documentStreams[normalizedPath];
|
|
45569
45635
|
if (streamState == null) {
|
|
45570
|
-
throw new
|
|
45636
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
45571
45637
|
}
|
|
45572
45638
|
streamState.queueSync(data);
|
|
45573
45639
|
}
|
|
@@ -45579,21 +45645,21 @@ ${newlined}
|
|
|
45579
45645
|
return;
|
|
45580
45646
|
}
|
|
45581
45647
|
const chunk = next.value;
|
|
45582
|
-
if (chunk instanceof
|
|
45583
|
-
throw new
|
|
45648
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45649
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45584
45650
|
}
|
|
45585
|
-
if (chunk instanceof
|
|
45651
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45586
45652
|
if (chunk.method === "close") {
|
|
45587
45653
|
return;
|
|
45588
45654
|
}
|
|
45589
45655
|
throw this._unexpectedResponseError("open");
|
|
45590
45656
|
}
|
|
45591
|
-
if (!(chunk instanceof
|
|
45657
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
45592
45658
|
throw this._unexpectedResponseError("open");
|
|
45593
45659
|
}
|
|
45594
45660
|
const headers = parseSyncOpenOutputChunkHeaders(chunk.headers);
|
|
45595
45661
|
if (normalizeSyncPath(headers.path) !== path) {
|
|
45596
|
-
throw new
|
|
45662
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream returned a mismatched path");
|
|
45597
45663
|
}
|
|
45598
45664
|
this._applySyncPayload(rc, chunk.data);
|
|
45599
45665
|
}
|
|
@@ -45621,18 +45687,18 @@ ${newlined}
|
|
|
45621
45687
|
iterator = responseStream[Symbol.asyncIterator]();
|
|
45622
45688
|
const first = await iterator.next();
|
|
45623
45689
|
if (first.done || first.value === void 0) {
|
|
45624
|
-
throw new
|
|
45690
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream closed before the initial document state was returned");
|
|
45625
45691
|
}
|
|
45626
45692
|
const firstChunk = first.value;
|
|
45627
|
-
if (firstChunk instanceof
|
|
45628
|
-
throw new
|
|
45693
|
+
if (firstChunk instanceof response_js_1.ErrorContent) {
|
|
45694
|
+
throw new room_server_client_js_1.RoomServerException(firstChunk.text, firstChunk.code);
|
|
45629
45695
|
}
|
|
45630
|
-
if (!(firstChunk instanceof
|
|
45696
|
+
if (!(firstChunk instanceof response_js_1.BinaryContent)) {
|
|
45631
45697
|
throw this._unexpectedResponseError("open");
|
|
45632
45698
|
}
|
|
45633
45699
|
const stateHeaders = parseSyncOpenStateChunkHeaders(firstChunk.headers);
|
|
45634
45700
|
if (normalizeSyncPath(stateHeaders.path) !== path) {
|
|
45635
|
-
throw new
|
|
45701
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream returned a mismatched path");
|
|
45636
45702
|
}
|
|
45637
45703
|
return {
|
|
45638
45704
|
streamState,
|
|
@@ -45696,26 +45762,26 @@ ${newlined}
|
|
|
45696
45762
|
"use strict";
|
|
45697
45763
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45698
45764
|
exports.RoomClient = exports.RoomProtocolProxy = void 0;
|
|
45699
|
-
var
|
|
45700
|
-
var
|
|
45701
|
-
var
|
|
45702
|
-
var
|
|
45703
|
-
var
|
|
45704
|
-
var
|
|
45705
|
-
var
|
|
45706
|
-
var
|
|
45707
|
-
var
|
|
45708
|
-
var
|
|
45709
|
-
var
|
|
45710
|
-
var
|
|
45711
|
-
var
|
|
45712
|
-
var
|
|
45713
|
-
var
|
|
45714
|
-
var
|
|
45715
|
-
var
|
|
45716
|
-
var
|
|
45717
|
-
var
|
|
45718
|
-
var
|
|
45765
|
+
var completer_js_1 = require_completer();
|
|
45766
|
+
var datasets_client_js_1 = require_datasets_client();
|
|
45767
|
+
var developer_client_js_1 = require_developer_client();
|
|
45768
|
+
var event_emitter_js_1 = require_event_emitter();
|
|
45769
|
+
var messaging_client_js_1 = require_messaging_client();
|
|
45770
|
+
var memory_client_js_1 = require_memory_client();
|
|
45771
|
+
var participant_js_1 = require_participant();
|
|
45772
|
+
var protocol_js_1 = require_protocol();
|
|
45773
|
+
var queues_client_js_1 = require_queues_client();
|
|
45774
|
+
var response_js_1 = require_response();
|
|
45775
|
+
var room_event_js_1 = require_room_event();
|
|
45776
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
45777
|
+
var secrets_client_js_1 = require_secrets_client();
|
|
45778
|
+
var services_client_js_1 = require_services_client();
|
|
45779
|
+
var storage_client_js_1 = require_storage_client();
|
|
45780
|
+
var stream_controller_js_1 = require_stream_controller();
|
|
45781
|
+
var sync_client_js_1 = require_sync_client();
|
|
45782
|
+
var utils_js_1 = require_utils();
|
|
45783
|
+
var agent_client_js_1 = require_agent_client();
|
|
45784
|
+
var containers_client_js_1 = require_containers_client();
|
|
45719
45785
|
var ProtocolStartupFailure = class extends Error {
|
|
45720
45786
|
constructor({ kind, reason }) {
|
|
45721
45787
|
super(reason ?? kind);
|
|
@@ -45725,7 +45791,7 @@ ${newlined}
|
|
|
45725
45791
|
}
|
|
45726
45792
|
};
|
|
45727
45793
|
function isRetryableStartupClose({ kind, reason }) {
|
|
45728
|
-
if (kind ===
|
|
45794
|
+
if (kind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
45729
45795
|
return true;
|
|
45730
45796
|
}
|
|
45731
45797
|
return (reason ?? "").toLowerCase().includes("1013");
|
|
@@ -45737,16 +45803,16 @@ ${newlined}
|
|
|
45737
45803
|
this.messageSendMessage = messageSendMessage;
|
|
45738
45804
|
}
|
|
45739
45805
|
requestError() {
|
|
45740
|
-
return new
|
|
45806
|
+
return new room_server_client_js_1.RoomServerException(this.requestMessage);
|
|
45741
45807
|
}
|
|
45742
45808
|
toolCallError() {
|
|
45743
|
-
return new
|
|
45809
|
+
return new room_server_client_js_1.RoomServerException(this.toolCallMessage);
|
|
45744
45810
|
}
|
|
45745
45811
|
messageSendError() {
|
|
45746
|
-
return new
|
|
45812
|
+
return new room_server_client_js_1.RoomServerException(this.messageSendMessage);
|
|
45747
45813
|
}
|
|
45748
45814
|
};
|
|
45749
|
-
var RoomConnectionStatusException = class extends
|
|
45815
|
+
var RoomConnectionStatusException = class extends room_server_client_js_1.RoomServerException {
|
|
45750
45816
|
constructor({ statusCode, statusText }) {
|
|
45751
45817
|
const normalizedStatusText = statusText?.trim();
|
|
45752
45818
|
super(normalizedStatusText == null || normalizedStatusText.length === 0 ? `websocket connect failed with status ${statusCode}` : `websocket connect failed with status ${statusCode}: ${normalizedStatusText}`);
|
|
@@ -45762,19 +45828,19 @@ ${newlined}
|
|
|
45762
45828
|
return normalized.length === 0 ? null : normalized;
|
|
45763
45829
|
}
|
|
45764
45830
|
function wrapRoomConnectionError(error) {
|
|
45765
|
-
if (error instanceof
|
|
45831
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
45766
45832
|
return error;
|
|
45767
45833
|
}
|
|
45768
|
-
if (error instanceof
|
|
45834
|
+
if (error instanceof protocol_js_1.ProtocolHandshakeException) {
|
|
45769
45835
|
return new RoomConnectionStatusException({
|
|
45770
45836
|
statusCode: error.statusCode,
|
|
45771
45837
|
statusText: error.statusText
|
|
45772
45838
|
});
|
|
45773
45839
|
}
|
|
45774
|
-
if (error instanceof
|
|
45775
|
-
return new
|
|
45840
|
+
if (error instanceof protocol_js_1.ProtocolCloseException) {
|
|
45841
|
+
return new room_server_client_js_1.RoomServerException(normalizeCloseReason(error.reason) ?? `room connection closed with status ${error.closeCode}`);
|
|
45776
45842
|
}
|
|
45777
|
-
return new
|
|
45843
|
+
return new room_server_client_js_1.RoomServerException(`room connection error: ${String(error)}`);
|
|
45778
45844
|
}
|
|
45779
45845
|
function nonRetryableConnectFailureReason(error) {
|
|
45780
45846
|
if (error instanceof RoomConnectionStatusException && (error.statusCode === 403 || error.statusCode === 404)) {
|
|
@@ -45783,7 +45849,7 @@ ${newlined}
|
|
|
45783
45849
|
return null;
|
|
45784
45850
|
}
|
|
45785
45851
|
function roomClosedBeforeReadyError(protocol) {
|
|
45786
|
-
return new
|
|
45852
|
+
return new room_server_client_js_1.RoomServerException(normalizeCloseReason(protocol.closeReason) ?? "room connection closed before request completed");
|
|
45787
45853
|
}
|
|
45788
45854
|
function getEnvironmentValue(name) {
|
|
45789
45855
|
if (typeof process === "undefined") {
|
|
@@ -45807,7 +45873,7 @@ ${newlined}
|
|
|
45807
45873
|
if (roomName == null || roomName.trim().length === 0 || token == null || token.trim().length === 0) {
|
|
45808
45874
|
throw new Error("protocolFactory must be configured or MESHAGENT_ROOM and MESHAGENT_TOKEN must be set in the environment");
|
|
45809
45875
|
}
|
|
45810
|
-
return
|
|
45876
|
+
return protocol_js_1.WebSocketClientProtocol.createFactory({
|
|
45811
45877
|
url: websocketRoomUrlFromEnvironment(roomName),
|
|
45812
45878
|
token
|
|
45813
45879
|
});
|
|
@@ -45901,15 +45967,15 @@ ${newlined}
|
|
|
45901
45967
|
constructor({ protocolFactory = null, reconnectTimeout = null, oauthTokenRequestHandler, secretRequestHandler } = {}) {
|
|
45902
45968
|
this._entered = false;
|
|
45903
45969
|
this._allowDisconnectedRequests = false;
|
|
45904
|
-
this._eventsController = new
|
|
45905
|
-
this._eventEmitter = new
|
|
45970
|
+
this._eventsController = new stream_controller_js_1.StreamController();
|
|
45971
|
+
this._eventEmitter = new event_emitter_js_1.EventEmitter();
|
|
45906
45972
|
this._pendingRequests = /* @__PURE__ */ new Map();
|
|
45907
45973
|
this._toolCallStreams = /* @__PURE__ */ new Map();
|
|
45908
45974
|
this._ignoredResponseLabels = /* @__PURE__ */ new Map();
|
|
45909
|
-
this._ready = new
|
|
45910
|
-
this._roomClosed = new
|
|
45911
|
-
this._connectionReady = new
|
|
45912
|
-
this._localParticipantReady = new
|
|
45975
|
+
this._ready = new completer_js_1.Completer();
|
|
45976
|
+
this._roomClosed = new completer_js_1.Completer();
|
|
45977
|
+
this._connectionReady = new completer_js_1.Completer();
|
|
45978
|
+
this._localParticipantReady = new completer_js_1.Completer();
|
|
45913
45979
|
this._connected = false;
|
|
45914
45980
|
this._closing = false;
|
|
45915
45981
|
this._localParticipant = null;
|
|
@@ -45938,21 +46004,29 @@ ${newlined}
|
|
|
45938
46004
|
this.protocol.addHandler("connected", this._handleParticipantBound);
|
|
45939
46005
|
this.protocol.addHandler("__response__", this._handleResponseBound);
|
|
45940
46006
|
this.protocol.addHandler("room.tool_call_response_chunk", this._handleToolCallResponseChunkBound);
|
|
45941
|
-
this.sync = new
|
|
45942
|
-
this.storage = new
|
|
45943
|
-
this.developer = new
|
|
45944
|
-
this.messaging = new
|
|
45945
|
-
this.queues = new
|
|
45946
|
-
this.datasets = new
|
|
45947
|
-
this.agents = new
|
|
45948
|
-
this.secrets = new
|
|
46007
|
+
this.sync = new sync_client_js_1.SyncClient({ room: this });
|
|
46008
|
+
this.storage = new storage_client_js_1.StorageClient({ room: this });
|
|
46009
|
+
this.developer = new developer_client_js_1.DeveloperClient({ room: this });
|
|
46010
|
+
this.messaging = new messaging_client_js_1.MessagingClient({ room: this });
|
|
46011
|
+
this.queues = new queues_client_js_1.QueuesClient({ room: this });
|
|
46012
|
+
this.datasets = new datasets_client_js_1.DatasetsClient({ room: this });
|
|
46013
|
+
this.agents = new agent_client_js_1.AgentsClient({ room: this });
|
|
46014
|
+
this.secrets = new secrets_client_js_1.SecretsClient({
|
|
45949
46015
|
room: this,
|
|
45950
46016
|
oauthTokenRequestHandler,
|
|
45951
46017
|
secretRequestHandler
|
|
45952
46018
|
});
|
|
45953
|
-
this.containers = new
|
|
45954
|
-
this.memory = new
|
|
45955
|
-
this.services = new
|
|
46019
|
+
this.containers = new containers_client_js_1.ContainersClient({ room: this });
|
|
46020
|
+
this.memory = new memory_client_js_1.MemoryClient({ room: this });
|
|
46021
|
+
this.services = new services_client_js_1.ServicesClient({ room: this });
|
|
46022
|
+
}
|
|
46023
|
+
static withIAP({ url = "./.well-known/meshagent/room/connect", reconnectTimeout = null, oauthTokenRequestHandler, secretRequestHandler } = {}) {
|
|
46024
|
+
return new _RoomClient({
|
|
46025
|
+
protocolFactory: () => protocol_js_1.WebSocketClientProtocol.withIAP({ url }),
|
|
46026
|
+
reconnectTimeout,
|
|
46027
|
+
oauthTokenRequestHandler,
|
|
46028
|
+
secretRequestHandler
|
|
46029
|
+
});
|
|
45956
46030
|
}
|
|
45957
46031
|
get localParticipant() {
|
|
45958
46032
|
return this._localParticipant;
|
|
@@ -46126,7 +46200,7 @@ ${newlined}
|
|
|
46126
46200
|
return `${baseMessage}: ${normalized}`;
|
|
46127
46201
|
}
|
|
46128
46202
|
_connectionFailureReason(error) {
|
|
46129
|
-
if (error instanceof
|
|
46203
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
46130
46204
|
return normalizeCloseReason(error.message);
|
|
46131
46205
|
}
|
|
46132
46206
|
return normalizeCloseReason(String(error));
|
|
@@ -46174,11 +46248,11 @@ ${newlined}
|
|
|
46174
46248
|
const normalizedCloseReason = normalizeCloseReason(closeReason);
|
|
46175
46249
|
this._closeKind = closeKind;
|
|
46176
46250
|
this._closeReason = normalizedCloseReason;
|
|
46177
|
-
if (closeKind ===
|
|
46251
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46178
46252
|
this._setTerminalState({
|
|
46179
46253
|
state: this._unexpectedCloseTerminalState({ closeReason: normalizedCloseReason })
|
|
46180
46254
|
});
|
|
46181
|
-
} else if (closeKind ===
|
|
46255
|
+
} else if (closeKind === protocol_js_1.ProtocolCloseKind.CLIENT) {
|
|
46182
46256
|
this._setTerminalState({ state: this._clientClosedTerminalState() });
|
|
46183
46257
|
} else {
|
|
46184
46258
|
this._setTerminalState({ state: this._protocolTerminalState({ protocol }) });
|
|
@@ -46209,18 +46283,18 @@ ${newlined}
|
|
|
46209
46283
|
}
|
|
46210
46284
|
}
|
|
46211
46285
|
_disconnectedError({ baseMessage }) {
|
|
46212
|
-
return new
|
|
46286
|
+
return new room_server_client_js_1.RoomServerException(this._formatClosedMessage({
|
|
46213
46287
|
baseMessage
|
|
46214
46288
|
}));
|
|
46215
46289
|
}
|
|
46216
46290
|
_messageDisconnectedError({ baseMessage }) {
|
|
46217
|
-
return new
|
|
46291
|
+
return new room_server_client_js_1.RoomServerException(this._formatClosedMessage({
|
|
46218
46292
|
baseMessage
|
|
46219
46293
|
}));
|
|
46220
46294
|
}
|
|
46221
46295
|
_startupException({ closeKind, closeReason, protocol }) {
|
|
46222
|
-
const baseMessage = closeKind ===
|
|
46223
|
-
return new
|
|
46296
|
+
const baseMessage = closeKind === protocol_js_1.ProtocolCloseKind.ERROR ? "room connection unexpectedly closed before the room became ready" : closeKind === protocol_js_1.ProtocolCloseKind.CLIENT ? "room client was closed before the room became ready" : "room connection closed before the room became ready";
|
|
46297
|
+
return new room_server_client_js_1.RoomServerException(this._formatClosedMessage({
|
|
46224
46298
|
baseMessage,
|
|
46225
46299
|
protocol,
|
|
46226
46300
|
closeReason
|
|
@@ -46255,7 +46329,7 @@ ${newlined}
|
|
|
46255
46329
|
if (this._closing && this._terminalState != null) {
|
|
46256
46330
|
return this._terminalState.messageSendError();
|
|
46257
46331
|
}
|
|
46258
|
-
return new
|
|
46332
|
+
return new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has been stopped");
|
|
46259
46333
|
}
|
|
46260
46334
|
_failPendingRequests(error) {
|
|
46261
46335
|
if (this._pendingRequests.size === 0) {
|
|
@@ -46276,7 +46350,7 @@ ${newlined}
|
|
|
46276
46350
|
const streams = [...this._toolCallStreams.values()];
|
|
46277
46351
|
this._toolCallStreams.clear();
|
|
46278
46352
|
for (const stream of streams) {
|
|
46279
|
-
stream.add(new
|
|
46353
|
+
stream.add(new response_js_1.ErrorContent({ text: error.message }));
|
|
46280
46354
|
stream.close();
|
|
46281
46355
|
}
|
|
46282
46356
|
}
|
|
@@ -46286,8 +46360,8 @@ ${newlined}
|
|
|
46286
46360
|
}
|
|
46287
46361
|
async _openProtocol({ initial }) {
|
|
46288
46362
|
const protocol = this._protocolInstance;
|
|
46289
|
-
this._connectionReady = new
|
|
46290
|
-
this._localParticipantReady = new
|
|
46363
|
+
this._connectionReady = new completer_js_1.Completer();
|
|
46364
|
+
this._localParticipantReady = new completer_js_1.Completer();
|
|
46291
46365
|
protocol.start({
|
|
46292
46366
|
onDone: () => {
|
|
46293
46367
|
const error = roomClosedBeforeReadyError(protocol);
|
|
@@ -46317,8 +46391,8 @@ ${newlined}
|
|
|
46317
46391
|
try {
|
|
46318
46392
|
await Promise.all([this._connectionReady.fut, this._localParticipantReady.fut]);
|
|
46319
46393
|
} catch (error) {
|
|
46320
|
-
const kind = protocol.closeKind ??
|
|
46321
|
-
if (!initial && kind !==
|
|
46394
|
+
const kind = protocol.closeKind ?? protocol_js_1.ProtocolCloseKind.ERROR;
|
|
46395
|
+
if (!initial && kind !== protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46322
46396
|
throw new ProtocolStartupFailure({
|
|
46323
46397
|
kind,
|
|
46324
46398
|
reason: normalizeCloseReason(protocol.closeReason)
|
|
@@ -46329,7 +46403,7 @@ ${newlined}
|
|
|
46329
46403
|
}
|
|
46330
46404
|
async start({ onDone, onError } = {}) {
|
|
46331
46405
|
if (this._entered) {
|
|
46332
|
-
throw new
|
|
46406
|
+
throw new room_server_client_js_1.RoomServerException("room client already started");
|
|
46333
46407
|
}
|
|
46334
46408
|
this._doneHandler = onDone;
|
|
46335
46409
|
this._errorHandler = onError;
|
|
@@ -46366,7 +46440,7 @@ ${newlined}
|
|
|
46366
46440
|
this._finalizeInitialStartupRetryFailure({
|
|
46367
46441
|
retryResult: {
|
|
46368
46442
|
connected: false,
|
|
46369
|
-
closeKind:
|
|
46443
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46370
46444
|
closeReason: nonRetryableCloseReason
|
|
46371
46445
|
}
|
|
46372
46446
|
});
|
|
@@ -46388,12 +46462,12 @@ ${newlined}
|
|
|
46388
46462
|
const closeReason = this._connectionFailureReason(error);
|
|
46389
46463
|
if (this._reconnectTimeout === 0) {
|
|
46390
46464
|
this._setStartupTerminalState({
|
|
46391
|
-
closeKind:
|
|
46465
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46392
46466
|
closeReason,
|
|
46393
46467
|
protocol: this._protocolInstance
|
|
46394
46468
|
});
|
|
46395
46469
|
throw this._startupException({
|
|
46396
|
-
closeKind:
|
|
46470
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46397
46471
|
closeReason,
|
|
46398
46472
|
protocol: this._protocolInstance
|
|
46399
46473
|
});
|
|
@@ -46516,14 +46590,14 @@ ${newlined}
|
|
|
46516
46590
|
}
|
|
46517
46591
|
return {
|
|
46518
46592
|
connected: false,
|
|
46519
|
-
closeKind:
|
|
46593
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46520
46594
|
closeReason: this._reconnectTimeoutReason({ disconnectReason })
|
|
46521
46595
|
};
|
|
46522
46596
|
}
|
|
46523
46597
|
async _closeAfterUnexpectedDisconnect({ closeReason }) {
|
|
46524
46598
|
const normalized = normalizeCloseReason(closeReason);
|
|
46525
46599
|
const state = this._unexpectedCloseTerminalState({ closeReason: normalized });
|
|
46526
|
-
this._closeKind =
|
|
46600
|
+
this._closeKind = protocol_js_1.ProtocolCloseKind.ERROR;
|
|
46527
46601
|
this._closeReason = normalized;
|
|
46528
46602
|
this._setTerminalState({ state });
|
|
46529
46603
|
this._completeRoomClosed();
|
|
@@ -46574,10 +46648,10 @@ ${newlined}
|
|
|
46574
46648
|
try {
|
|
46575
46649
|
nextProtocol = this._protocolFactory();
|
|
46576
46650
|
} catch (error) {
|
|
46577
|
-
if (error instanceof
|
|
46651
|
+
if (error instanceof protocol_js_1.ProtocolReconnectUnsupportedException) {
|
|
46578
46652
|
return {
|
|
46579
46653
|
connected: false,
|
|
46580
|
-
closeKind:
|
|
46654
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46581
46655
|
closeReason: failureReason
|
|
46582
46656
|
};
|
|
46583
46657
|
}
|
|
@@ -46611,7 +46685,7 @@ ${newlined}
|
|
|
46611
46685
|
await this._closeProtocol(nextProtocol);
|
|
46612
46686
|
return {
|
|
46613
46687
|
connected: false,
|
|
46614
|
-
closeKind:
|
|
46688
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46615
46689
|
closeReason: nonRetryableCloseReason
|
|
46616
46690
|
};
|
|
46617
46691
|
}
|
|
@@ -46624,7 +46698,7 @@ ${newlined}
|
|
|
46624
46698
|
}
|
|
46625
46699
|
return {
|
|
46626
46700
|
connected: false,
|
|
46627
|
-
closeKind:
|
|
46701
|
+
closeKind: protocol_js_1.ProtocolCloseKind.CLIENT,
|
|
46628
46702
|
closeReason: this.closeReason
|
|
46629
46703
|
};
|
|
46630
46704
|
}
|
|
@@ -46643,7 +46717,7 @@ ${newlined}
|
|
|
46643
46717
|
return true;
|
|
46644
46718
|
}
|
|
46645
46719
|
const closeKind = retryResult.closeKind ?? null;
|
|
46646
|
-
if (closeKind ===
|
|
46720
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46647
46721
|
const closeReason = retryResult.closeReason ?? null;
|
|
46648
46722
|
if (closeReason != null && closeReason.startsWith("room reconnect timed out after")) {
|
|
46649
46723
|
console.warn(`${closeReason}; closing room client`);
|
|
@@ -46666,14 +46740,14 @@ ${newlined}
|
|
|
46666
46740
|
while (true) {
|
|
46667
46741
|
const protocol = this._protocolInstance;
|
|
46668
46742
|
await protocol.done;
|
|
46669
|
-
const closeKind = protocol.closeKind ??
|
|
46743
|
+
const closeKind = protocol.closeKind ?? protocol_js_1.ProtocolCloseKind.ERROR;
|
|
46670
46744
|
const closeReason = normalizeCloseReason(protocol.closeReason);
|
|
46671
46745
|
const state = this._protocolTerminalState({ protocol });
|
|
46672
46746
|
if (this._closing) {
|
|
46673
46747
|
this._completeRoomClosed();
|
|
46674
46748
|
return;
|
|
46675
46749
|
}
|
|
46676
|
-
if (closeKind !==
|
|
46750
|
+
if (closeKind !== protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46677
46751
|
this._setTerminalState({ state });
|
|
46678
46752
|
}
|
|
46679
46753
|
this._markDisconnected({ reason: closeReason, kind: closeKind });
|
|
@@ -46685,7 +46759,7 @@ ${newlined}
|
|
|
46685
46759
|
this.messaging._onRoomDisconnect({ reason: closeReason });
|
|
46686
46760
|
await this._failPendingWork({ state });
|
|
46687
46761
|
await this._closeProtocol(protocol);
|
|
46688
|
-
if (closeKind ===
|
|
46762
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46689
46763
|
if (this._reconnectTimeout === 0) {
|
|
46690
46764
|
if (closeReason == null) {
|
|
46691
46765
|
console.warn("room connection lost; automatic reconnect disabled");
|
|
@@ -46716,7 +46790,7 @@ ${newlined}
|
|
|
46716
46790
|
this._closing = true;
|
|
46717
46791
|
this._markDisconnected({
|
|
46718
46792
|
reason: this.closeReason,
|
|
46719
|
-
kind: this.closeKind ??
|
|
46793
|
+
kind: this.closeKind ?? protocol_js_1.ProtocolCloseKind.CLIENT
|
|
46720
46794
|
});
|
|
46721
46795
|
const closingState = this._clientClosedTerminalState();
|
|
46722
46796
|
this._setTerminalState({ state: closingState });
|
|
@@ -46726,7 +46800,7 @@ ${newlined}
|
|
|
46726
46800
|
void this.messaging.stop();
|
|
46727
46801
|
this._protocolInstance.dispose();
|
|
46728
46802
|
this._entered = false;
|
|
46729
|
-
this._closeKind =
|
|
46803
|
+
this._closeKind = protocol_js_1.ProtocolCloseKind.CLIENT;
|
|
46730
46804
|
this._completeRoomClosed();
|
|
46731
46805
|
this._invokeTerminalCallbacks({ useErrorCallback: false });
|
|
46732
46806
|
this._localParticipant = null;
|
|
@@ -46763,14 +46837,14 @@ ${newlined}
|
|
|
46763
46837
|
_sendRoomRequestNowait(type, request, { data, label, expectResponse = false }) {
|
|
46764
46838
|
return this._sendProtocolNowait({
|
|
46765
46839
|
type,
|
|
46766
|
-
data: (0,
|
|
46840
|
+
data: (0, utils_js_1.packMessage)(request, data),
|
|
46767
46841
|
label,
|
|
46768
46842
|
expectResponse
|
|
46769
46843
|
});
|
|
46770
46844
|
}
|
|
46771
46845
|
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId }) {
|
|
46772
|
-
const resolvedInput = input ?? new
|
|
46773
|
-
const packedInput = (0,
|
|
46846
|
+
const resolvedInput = input ?? new response_js_1.EmptyContent();
|
|
46847
|
+
const packedInput = (0, utils_js_1.unpackMessage)(resolvedInput.pack());
|
|
46774
46848
|
const request = {
|
|
46775
46849
|
toolkit,
|
|
46776
46850
|
tool,
|
|
@@ -46788,7 +46862,7 @@ ${newlined}
|
|
|
46788
46862
|
_sendLocalAttributesNowait(attributes) {
|
|
46789
46863
|
this._sendProtocolNowait({
|
|
46790
46864
|
type: "set_attributes",
|
|
46791
|
-
data: (0,
|
|
46865
|
+
data: (0, utils_js_1.packMessage)(attributes),
|
|
46792
46866
|
label: "local participant attribute update"
|
|
46793
46867
|
});
|
|
46794
46868
|
}
|
|
@@ -46809,10 +46883,10 @@ ${newlined}
|
|
|
46809
46883
|
throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
|
|
46810
46884
|
}
|
|
46811
46885
|
const requestId = this._protocolInstance.getNextMessageId();
|
|
46812
|
-
const completer = new
|
|
46886
|
+
const completer = new completer_js_1.Completer();
|
|
46813
46887
|
this._pendingRequests.set(requestId, completer);
|
|
46814
46888
|
try {
|
|
46815
|
-
await this._protocolInstance.send(type, (0,
|
|
46889
|
+
await this._protocolInstance.send(type, (0, utils_js_1.packMessage)(request, data), requestId);
|
|
46816
46890
|
return await completer.fut;
|
|
46817
46891
|
} catch (error) {
|
|
46818
46892
|
this._pendingRequests.delete(requestId);
|
|
@@ -46834,33 +46908,33 @@ ${newlined}
|
|
|
46834
46908
|
request["timeout"] = params.timeout;
|
|
46835
46909
|
}
|
|
46836
46910
|
const result = await this.sendRequest("room.list_toolkits", request);
|
|
46837
|
-
if (!(result instanceof
|
|
46838
|
-
throw new
|
|
46911
|
+
if (!(result instanceof response_js_1.JsonContent)) {
|
|
46912
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
46839
46913
|
}
|
|
46840
46914
|
const tools = result.json["tools"];
|
|
46841
46915
|
if (typeof tools !== "object" || tools === null || Array.isArray(tools)) {
|
|
46842
|
-
throw new
|
|
46916
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
46843
46917
|
}
|
|
46844
46918
|
const toolkits = [];
|
|
46845
46919
|
for (const [name, data] of Object.entries(tools)) {
|
|
46846
46920
|
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
46847
|
-
throw new
|
|
46921
|
+
throw new room_server_client_js_1.RoomServerException("unexpected toolkit description from room.list_toolkits");
|
|
46848
46922
|
}
|
|
46849
|
-
toolkits.push(
|
|
46923
|
+
toolkits.push(agent_client_js_1.ToolkitDescription.fromJson(data, { name }));
|
|
46850
46924
|
}
|
|
46851
46925
|
return toolkits;
|
|
46852
46926
|
}
|
|
46853
46927
|
async invoke(params) {
|
|
46854
|
-
const input = params.input ?? params.arguments ?? new
|
|
46928
|
+
const input = params.input ?? params.arguments ?? new response_js_1.EmptyContent();
|
|
46855
46929
|
const request = {
|
|
46856
46930
|
toolkit: params.toolkit,
|
|
46857
46931
|
tool: params.tool
|
|
46858
46932
|
};
|
|
46859
46933
|
let requestData;
|
|
46860
|
-
if (input instanceof
|
|
46934
|
+
if (input instanceof response_js_1.BinaryContent || input instanceof response_js_1.EmptyContent || input instanceof response_js_1.ErrorContent || input instanceof response_js_1.FileContent || input instanceof response_js_1.JsonContent || input instanceof response_js_1.LinkContent || input instanceof response_js_1.TextContent) {
|
|
46861
46935
|
const packed = input.pack();
|
|
46862
|
-
request["arguments"] = JSON.parse((0,
|
|
46863
|
-
const payload = (0,
|
|
46936
|
+
request["arguments"] = JSON.parse((0, utils_js_1.splitMessageHeader)(packed));
|
|
46937
|
+
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
46864
46938
|
if (payload.length > 0) {
|
|
46865
46939
|
requestData = payload;
|
|
46866
46940
|
}
|
|
@@ -46870,7 +46944,7 @@ ${newlined}
|
|
|
46870
46944
|
json: input
|
|
46871
46945
|
};
|
|
46872
46946
|
} else {
|
|
46873
|
-
throw new
|
|
46947
|
+
throw new room_server_client_js_1.RoomServerException("invoke input must be a content value or JSON object");
|
|
46874
46948
|
}
|
|
46875
46949
|
if (params.participantId != null) {
|
|
46876
46950
|
request["participant_id"] = params.participantId;
|
|
@@ -46882,7 +46956,7 @@ ${newlined}
|
|
|
46882
46956
|
}
|
|
46883
46957
|
async invokeToolCall(params) {
|
|
46884
46958
|
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
46885
|
-
const controller = new
|
|
46959
|
+
const controller = new stream_controller_js_1.StreamController();
|
|
46886
46960
|
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
46887
46961
|
this._toolCallStreams.set(toolCallId, controller);
|
|
46888
46962
|
const request = {
|
|
@@ -46898,8 +46972,8 @@ ${newlined}
|
|
|
46898
46972
|
} else {
|
|
46899
46973
|
const input = params.input;
|
|
46900
46974
|
const packed = input.pack();
|
|
46901
|
-
request["arguments"] = JSON.parse((0,
|
|
46902
|
-
const payload = (0,
|
|
46975
|
+
request["arguments"] = JSON.parse((0, utils_js_1.splitMessageHeader)(packed));
|
|
46976
|
+
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
46903
46977
|
if (payload.length > 0) {
|
|
46904
46978
|
requestData = payload;
|
|
46905
46979
|
}
|
|
@@ -46912,14 +46986,14 @@ ${newlined}
|
|
|
46912
46986
|
}
|
|
46913
46987
|
try {
|
|
46914
46988
|
const response = await this.sendRequest("room.invoke_tool", request, requestData);
|
|
46915
|
-
if (response instanceof
|
|
46989
|
+
if (response instanceof response_js_1.ControlContent && response.method === "open") {
|
|
46916
46990
|
if (requestTask != null) {
|
|
46917
46991
|
void requestTask.catch((error) => {
|
|
46918
46992
|
const stream = this._toolCallStreams.get(toolCallId);
|
|
46919
46993
|
if (stream == null) {
|
|
46920
46994
|
return;
|
|
46921
46995
|
}
|
|
46922
|
-
stream.add(new
|
|
46996
|
+
stream.add(new response_js_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
46923
46997
|
stream.close();
|
|
46924
46998
|
this._toolCallStreams.delete(toolCallId);
|
|
46925
46999
|
});
|
|
@@ -46965,8 +47039,8 @@ ${newlined}
|
|
|
46965
47039
|
try {
|
|
46966
47040
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
46967
47041
|
await requestTask;
|
|
46968
|
-
if (response instanceof
|
|
46969
|
-
throw new
|
|
47042
|
+
if (response instanceof response_js_1.ControlContent && response.method === "open") {
|
|
47043
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
46970
47044
|
}
|
|
46971
47045
|
return response;
|
|
46972
47046
|
} catch (error) {
|
|
@@ -46976,7 +47050,7 @@ ${newlined}
|
|
|
46976
47050
|
}
|
|
46977
47051
|
async invokeStream(params) {
|
|
46978
47052
|
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
46979
|
-
const controller = new
|
|
47053
|
+
const controller = new stream_controller_js_1.StreamController();
|
|
46980
47054
|
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
46981
47055
|
this._toolCallStreams.set(toolCallId, controller);
|
|
46982
47056
|
const request = {
|
|
@@ -46997,15 +47071,15 @@ ${newlined}
|
|
|
46997
47071
|
if (stream == null) {
|
|
46998
47072
|
return;
|
|
46999
47073
|
}
|
|
47000
|
-
stream.add(new
|
|
47074
|
+
stream.add(new response_js_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
47001
47075
|
stream.close();
|
|
47002
47076
|
this._toolCallStreams.delete(toolCallId);
|
|
47003
47077
|
});
|
|
47004
47078
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
47005
|
-
if (!(response instanceof
|
|
47079
|
+
if (!(response instanceof response_js_1.ControlContent) || response.method !== "open") {
|
|
47006
47080
|
this._toolCallStreams.delete(toolCallId);
|
|
47007
47081
|
controller.close();
|
|
47008
|
-
throw new
|
|
47082
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
47009
47083
|
}
|
|
47010
47084
|
return {
|
|
47011
47085
|
[Symbol.asyncIterator]() {
|
|
@@ -47017,9 +47091,9 @@ ${newlined}
|
|
|
47017
47091
|
const packed = chunk.pack();
|
|
47018
47092
|
const request = {
|
|
47019
47093
|
tool_call_id: toolCallId,
|
|
47020
|
-
chunk: JSON.parse((0,
|
|
47094
|
+
chunk: JSON.parse((0, utils_js_1.splitMessageHeader)(packed))
|
|
47021
47095
|
};
|
|
47022
|
-
const payload = (0,
|
|
47096
|
+
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
47023
47097
|
await this.sendRequest("room.tool_call_request_chunk", request, payload.length > 0 ? payload : void 0);
|
|
47024
47098
|
}
|
|
47025
47099
|
async _streamInvokeToolRequestChunks(toolCallId, input) {
|
|
@@ -47029,7 +47103,7 @@ ${newlined}
|
|
|
47029
47103
|
await this._sendToolCallRequestChunk(toolCallId, item);
|
|
47030
47104
|
}
|
|
47031
47105
|
} finally {
|
|
47032
|
-
await this._sendToolCallRequestChunk(toolCallId, new
|
|
47106
|
+
await this._sendToolCallRequestChunk(toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
47033
47107
|
}
|
|
47034
47108
|
}
|
|
47035
47109
|
_decodeToolCallContent(params) {
|
|
@@ -47037,17 +47111,17 @@ ${newlined}
|
|
|
47037
47111
|
if (typeof chunk === "object" && chunk !== null && !Array.isArray(chunk)) {
|
|
47038
47112
|
const chunkMap = chunk;
|
|
47039
47113
|
if (typeof chunkMap["type"] === "string") {
|
|
47040
|
-
return (0,
|
|
47114
|
+
return (0, response_js_1.unpackContent)((0, utils_js_1.packMessage)(chunkMap, params.payload.length > 0 ? params.payload : void 0));
|
|
47041
47115
|
}
|
|
47042
|
-
return new
|
|
47116
|
+
return new response_js_1.JsonContent({ json: chunkMap });
|
|
47043
47117
|
}
|
|
47044
|
-
return new
|
|
47118
|
+
return new response_js_1.JsonContent({ json: { chunk } });
|
|
47045
47119
|
}
|
|
47046
47120
|
async _handleToolCallResponseChunk(protocol, _messageId, _type, data) {
|
|
47047
47121
|
if (!this.isActiveProtocol(protocol)) {
|
|
47048
47122
|
return;
|
|
47049
47123
|
}
|
|
47050
|
-
const [header, payload] = (0,
|
|
47124
|
+
const [header, payload] = (0, utils_js_1.unpackMessage)(data);
|
|
47051
47125
|
const toolCallId = header["tool_call_id"];
|
|
47052
47126
|
if (typeof toolCallId !== "string" || toolCallId.length === 0) {
|
|
47053
47127
|
return;
|
|
@@ -47058,7 +47132,7 @@ ${newlined}
|
|
|
47058
47132
|
}
|
|
47059
47133
|
const content = this._decodeToolCallContent({ header, payload });
|
|
47060
47134
|
stream.add(content);
|
|
47061
|
-
if (content instanceof
|
|
47135
|
+
if (content instanceof response_js_1.ControlContent && content.method === "close") {
|
|
47062
47136
|
stream.close();
|
|
47063
47137
|
this._toolCallStreams.delete(toolCallId);
|
|
47064
47138
|
}
|
|
@@ -47067,12 +47141,12 @@ ${newlined}
|
|
|
47067
47141
|
if (!this.isActiveProtocol(protocol)) {
|
|
47068
47142
|
return;
|
|
47069
47143
|
}
|
|
47070
|
-
const response = (0,
|
|
47144
|
+
const response = (0, response_js_1.unpackContent)(data);
|
|
47071
47145
|
const pending = this._pendingRequests.get(messageId);
|
|
47072
47146
|
if (pending != null) {
|
|
47073
47147
|
this._pendingRequests.delete(messageId);
|
|
47074
|
-
if (response instanceof
|
|
47075
|
-
pending.completeError(new
|
|
47148
|
+
if (response instanceof response_js_1.ErrorContent) {
|
|
47149
|
+
pending.completeError(new room_server_client_js_1.RoomServerException(response.text, response.code));
|
|
47076
47150
|
} else {
|
|
47077
47151
|
pending.complete(response);
|
|
47078
47152
|
}
|
|
@@ -47081,7 +47155,7 @@ ${newlined}
|
|
|
47081
47155
|
const ignoredLabel = this._ignoredResponseLabels.get(messageId);
|
|
47082
47156
|
if (ignoredLabel != null) {
|
|
47083
47157
|
this._ignoredResponseLabels.delete(messageId);
|
|
47084
|
-
if (response instanceof
|
|
47158
|
+
if (response instanceof response_js_1.ErrorContent) {
|
|
47085
47159
|
console.warn(`one-way room request failed for ${ignoredLabel}: ${response.text}`);
|
|
47086
47160
|
}
|
|
47087
47161
|
}
|
|
@@ -47090,14 +47164,14 @@ ${newlined}
|
|
|
47090
47164
|
if (!this.isActiveProtocol(protocol)) {
|
|
47091
47165
|
return;
|
|
47092
47166
|
}
|
|
47093
|
-
const [payload] = (0,
|
|
47094
|
-
this.emit(
|
|
47167
|
+
const [payload] = (0, utils_js_1.unpackMessage)(data);
|
|
47168
|
+
this.emit(room_event_js_1.RoomStatusEvent.fromJson(payload));
|
|
47095
47169
|
}
|
|
47096
47170
|
async _handleRoomReady(protocol, _messageId, _type, data) {
|
|
47097
47171
|
if (!this.isActiveProtocol(protocol)) {
|
|
47098
47172
|
return;
|
|
47099
47173
|
}
|
|
47100
|
-
const [message2] = (0,
|
|
47174
|
+
const [message2] = (0, utils_js_1.unpackMessage)(data);
|
|
47101
47175
|
this._roomName = typeof message2["room_name"] === "string" ? message2["room_name"] : null;
|
|
47102
47176
|
this._roomUrl = typeof message2["room_url"] === "string" ? message2["room_url"] : null;
|
|
47103
47177
|
this._sessionId = typeof message2["session_id"] === "string" ? message2["session_id"] : null;
|
|
@@ -47110,7 +47184,7 @@ ${newlined}
|
|
|
47110
47184
|
}
|
|
47111
47185
|
_onParticipantInit(participantId, attributes) {
|
|
47112
47186
|
if (this._localParticipant == null) {
|
|
47113
|
-
this._localParticipant = new
|
|
47187
|
+
this._localParticipant = new participant_js_1.LocalParticipant(this, participantId);
|
|
47114
47188
|
this._localParticipant._setAttributes(attributes);
|
|
47115
47189
|
} else {
|
|
47116
47190
|
const merged = { ...attributes, ...this._localParticipant._attributesSnapshot() };
|
|
@@ -47127,7 +47201,7 @@ ${newlined}
|
|
|
47127
47201
|
if (!this.isActiveProtocol(protocol)) {
|
|
47128
47202
|
return;
|
|
47129
47203
|
}
|
|
47130
|
-
const [message2] = (0,
|
|
47204
|
+
const [message2] = (0, utils_js_1.unpackMessage)(data);
|
|
47131
47205
|
switch (message2["type"]) {
|
|
47132
47206
|
case "init": {
|
|
47133
47207
|
const participantId = message2["participantId"];
|
|
@@ -47142,7 +47216,7 @@ ${newlined}
|
|
|
47142
47216
|
}
|
|
47143
47217
|
}
|
|
47144
47218
|
_emitStatus({ status, message: message2 }) {
|
|
47145
|
-
this.emit(new
|
|
47219
|
+
this.emit(new room_event_js_1.RoomStatusEvent({ status, message: message2 }));
|
|
47146
47220
|
}
|
|
47147
47221
|
};
|
|
47148
47222
|
exports.RoomClient = RoomClient;
|