@meshagent/meshagent-ts-auth 0.42.2 → 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 +6 -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 +685 -658
- 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
|
});
|
|
@@ -16073,7 +16073,7 @@ ${err.toString()}`);
|
|
|
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");
|
|
@@ -16098,10 +16098,10 @@ ${err.toString()}`);
|
|
|
16098
16098
|
}
|
|
16099
16099
|
logs(params) {
|
|
16100
16100
|
const requestId = (0, uuid_1.v4)();
|
|
16101
|
-
const closeInput = new
|
|
16102
|
-
const progressController = new
|
|
16103
|
-
const streamController = new
|
|
16104
|
-
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();
|
|
16105
16105
|
let inputClosed = false;
|
|
16106
16106
|
const closeInputStream = () => {
|
|
16107
16107
|
if (inputClosed) {
|
|
@@ -16113,7 +16113,7 @@ ${err.toString()}`);
|
|
|
16113
16113
|
}
|
|
16114
16114
|
};
|
|
16115
16115
|
const inputStream = async function* () {
|
|
16116
|
-
yield new
|
|
16116
|
+
yield new response_js_1.BinaryContent({
|
|
16117
16117
|
data: new Uint8Array(0),
|
|
16118
16118
|
headers: {
|
|
16119
16119
|
kind: "start",
|
|
@@ -16130,10 +16130,10 @@ ${err.toString()}`);
|
|
|
16130
16130
|
input: inputStream()
|
|
16131
16131
|
}).then(async (stream) => {
|
|
16132
16132
|
for await (const chunk of stream) {
|
|
16133
|
-
if (chunk instanceof
|
|
16134
|
-
throw new
|
|
16133
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
16134
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
16135
16135
|
}
|
|
16136
|
-
if (chunk instanceof
|
|
16136
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
16137
16137
|
if (chunk.method === "close") {
|
|
16138
16138
|
closeInputStream();
|
|
16139
16139
|
progressController.close();
|
|
@@ -16145,12 +16145,12 @@ ${err.toString()}`);
|
|
|
16145
16145
|
}
|
|
16146
16146
|
throw this.unexpectedResponseError("logs");
|
|
16147
16147
|
}
|
|
16148
|
-
if (!(chunk instanceof
|
|
16148
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
16149
16149
|
throw this.unexpectedResponseError("logs");
|
|
16150
16150
|
}
|
|
16151
16151
|
const channel = chunk.headers["channel"];
|
|
16152
16152
|
if (typeof channel !== "number") {
|
|
16153
|
-
throw new
|
|
16153
|
+
throw new room_server_client_js_1.RoomServerException("containers.logs returned a chunk without a valid channel");
|
|
16154
16154
|
}
|
|
16155
16155
|
if (channel !== 1) {
|
|
16156
16156
|
continue;
|
|
@@ -16204,9 +16204,9 @@ ${err.toString()}`);
|
|
|
16204
16204
|
}
|
|
16205
16205
|
getBuildLogs(params) {
|
|
16206
16206
|
const requestId = (0, uuid_1.v4)();
|
|
16207
|
-
const closeInput = new
|
|
16208
|
-
const streamController = new
|
|
16209
|
-
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();
|
|
16210
16210
|
let inputClosed = false;
|
|
16211
16211
|
const closeInputStream = () => {
|
|
16212
16212
|
if (inputClosed) {
|
|
@@ -16218,7 +16218,7 @@ ${err.toString()}`);
|
|
|
16218
16218
|
}
|
|
16219
16219
|
};
|
|
16220
16220
|
const inputStream = async function* () {
|
|
16221
|
-
yield new
|
|
16221
|
+
yield new response_js_1.BinaryContent({
|
|
16222
16222
|
data: new Uint8Array(0),
|
|
16223
16223
|
headers: {
|
|
16224
16224
|
kind: "start",
|
|
@@ -16235,10 +16235,10 @@ ${err.toString()}`);
|
|
|
16235
16235
|
input: inputStream()
|
|
16236
16236
|
}).then(async (stream) => {
|
|
16237
16237
|
for await (const chunk of stream) {
|
|
16238
|
-
if (chunk instanceof
|
|
16239
|
-
throw new
|
|
16238
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
16239
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
16240
16240
|
}
|
|
16241
|
-
if (chunk instanceof
|
|
16241
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
16242
16242
|
if (chunk.method === "close") {
|
|
16243
16243
|
closeInputStream();
|
|
16244
16244
|
streamController.close();
|
|
@@ -16249,12 +16249,12 @@ ${err.toString()}`);
|
|
|
16249
16249
|
}
|
|
16250
16250
|
throw this.unexpectedResponseError("get_build_logs");
|
|
16251
16251
|
}
|
|
16252
|
-
if (!(chunk instanceof
|
|
16252
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
16253
16253
|
throw this.unexpectedResponseError("get_build_logs");
|
|
16254
16254
|
}
|
|
16255
16255
|
const channel = chunk.headers["channel"];
|
|
16256
16256
|
if (typeof channel !== "number") {
|
|
16257
|
-
throw new
|
|
16257
|
+
throw new room_server_client_js_1.RoomServerException("containers.get_build_logs returned a chunk without a valid channel");
|
|
16258
16258
|
}
|
|
16259
16259
|
if (channel === 1) {
|
|
16260
16260
|
streamController.add(decodeUtf8(chunk.data, "get_build_logs"));
|
|
@@ -16315,7 +16315,7 @@ ${err.toString()}`);
|
|
|
16315
16315
|
const output = await this.invoke("list_containers", {
|
|
16316
16316
|
all: params?.all
|
|
16317
16317
|
});
|
|
16318
|
-
if (!(output instanceof
|
|
16318
|
+
if (!(output instanceof response_js_1.JsonContent) || !isRecord(output.json)) {
|
|
16319
16319
|
throw this.unexpectedResponseError("list");
|
|
16320
16320
|
}
|
|
16321
16321
|
const containersRaw = output.json["containers"];
|
|
@@ -33094,8 +33094,8 @@ return true;`);
|
|
|
33094
33094
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33095
33095
|
exports.DatasetsClient = exports.DatasetUuid = exports.DatasetJson = exports.DatasetStruct = exports.DatasetDate = exports.DatasetExpression = exports.DatasetValueEncoder = void 0;
|
|
33096
33096
|
var apache_arrow_1 = require_Arrow_dom();
|
|
33097
|
-
var
|
|
33098
|
-
var
|
|
33097
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
33098
|
+
var response_js_1 = require_response();
|
|
33099
33099
|
var ARROW_IPC_STREAM_MIME_TYPE = "application/vnd.apache.arrow.stream";
|
|
33100
33100
|
var DatasetValueEncoder = class {
|
|
33101
33101
|
};
|
|
@@ -33180,7 +33180,7 @@ return true;`);
|
|
|
33180
33180
|
function normalizeUuidHex(value) {
|
|
33181
33181
|
const normalized = value.trim().toLowerCase().replace(/-/g, "");
|
|
33182
33182
|
if (!UUID_HEX_REGEX.test(normalized)) {
|
|
33183
|
-
throw new
|
|
33183
|
+
throw new room_server_client_js_1.RoomServerException("invalid uuid format");
|
|
33184
33184
|
}
|
|
33185
33185
|
return normalized;
|
|
33186
33186
|
}
|
|
@@ -33275,7 +33275,7 @@ return true;`);
|
|
|
33275
33275
|
};
|
|
33276
33276
|
}
|
|
33277
33277
|
if (isRecord(value)) {
|
|
33278
|
-
throw new
|
|
33278
|
+
throw new room_server_client_js_1.RoomServerException("dataset object values must use DatasetStruct or DatasetJson");
|
|
33279
33279
|
}
|
|
33280
33280
|
return value;
|
|
33281
33281
|
}
|
|
@@ -33300,62 +33300,62 @@ return true;`);
|
|
|
33300
33300
|
}
|
|
33301
33301
|
function decodeRecordValue(value) {
|
|
33302
33302
|
if (Array.isArray(value)) {
|
|
33303
|
-
throw new
|
|
33303
|
+
throw new room_server_client_js_1.RoomServerException("dataset list values must use a {'list': [...]} wrapper");
|
|
33304
33304
|
}
|
|
33305
33305
|
if (!isRecord(value)) {
|
|
33306
33306
|
return value;
|
|
33307
33307
|
}
|
|
33308
33308
|
const entries = Object.entries(value);
|
|
33309
33309
|
if (entries.length !== 1) {
|
|
33310
|
-
throw new
|
|
33310
|
+
throw new room_server_client_js_1.RoomServerException("dataset object values must use a single-key type wrapper");
|
|
33311
33311
|
}
|
|
33312
33312
|
const [wrapper, payload] = entries[0];
|
|
33313
33313
|
switch (wrapper) {
|
|
33314
33314
|
case "binary":
|
|
33315
33315
|
if (typeof payload !== "string") {
|
|
33316
|
-
throw new
|
|
33316
|
+
throw new room_server_client_js_1.RoomServerException("dataset binary values must be base64 strings");
|
|
33317
33317
|
}
|
|
33318
33318
|
return base64ToBytes(payload);
|
|
33319
33319
|
case "uuid":
|
|
33320
33320
|
if (typeof payload !== "string") {
|
|
33321
|
-
throw new
|
|
33321
|
+
throw new room_server_client_js_1.RoomServerException("dataset uuid values must be strings");
|
|
33322
33322
|
}
|
|
33323
33323
|
return new DatasetUuid(payload);
|
|
33324
33324
|
case "expression":
|
|
33325
33325
|
if (typeof payload !== "string") {
|
|
33326
|
-
throw new
|
|
33326
|
+
throw new room_server_client_js_1.RoomServerException("dataset expression values must be strings");
|
|
33327
33327
|
}
|
|
33328
33328
|
return new DatasetExpression(payload);
|
|
33329
33329
|
case "date":
|
|
33330
33330
|
if (typeof payload !== "string") {
|
|
33331
|
-
throw new
|
|
33331
|
+
throw new room_server_client_js_1.RoomServerException("dataset date values must be strings");
|
|
33332
33332
|
}
|
|
33333
33333
|
return new DatasetDate(payload);
|
|
33334
33334
|
case "timestamp":
|
|
33335
33335
|
if (typeof payload !== "string") {
|
|
33336
|
-
throw new
|
|
33336
|
+
throw new room_server_client_js_1.RoomServerException("dataset timestamp values must be strings");
|
|
33337
33337
|
}
|
|
33338
33338
|
{
|
|
33339
33339
|
const parsed = new Date(payload);
|
|
33340
33340
|
if (Number.isNaN(parsed.getTime())) {
|
|
33341
|
-
throw new
|
|
33341
|
+
throw new room_server_client_js_1.RoomServerException("dataset timestamp value is not valid");
|
|
33342
33342
|
}
|
|
33343
33343
|
return parsed;
|
|
33344
33344
|
}
|
|
33345
33345
|
case "list":
|
|
33346
33346
|
if (!Array.isArray(payload)) {
|
|
33347
|
-
throw new
|
|
33347
|
+
throw new room_server_client_js_1.RoomServerException("dataset list values must be arrays");
|
|
33348
33348
|
}
|
|
33349
33349
|
return payload.map((item) => decodeRecordValue(item));
|
|
33350
33350
|
case "struct":
|
|
33351
33351
|
if (!isRecord(payload)) {
|
|
33352
|
-
throw new
|
|
33352
|
+
throw new room_server_client_js_1.RoomServerException("dataset struct values must be objects");
|
|
33353
33353
|
}
|
|
33354
33354
|
return new DatasetStruct(Object.fromEntries(Object.entries(payload).map(([key, item]) => [key, decodeRecordValue(item)])));
|
|
33355
33355
|
case "json":
|
|
33356
33356
|
return new DatasetJson(normalizeDatasetJsonValue(payload));
|
|
33357
33357
|
default:
|
|
33358
|
-
throw new
|
|
33358
|
+
throw new room_server_client_js_1.RoomServerException(`unsupported dataset value wrapper '${wrapper}'`);
|
|
33359
33359
|
}
|
|
33360
33360
|
}
|
|
33361
33361
|
function rowsChunk(records) {
|
|
@@ -33371,27 +33371,27 @@ return true;`);
|
|
|
33371
33371
|
}
|
|
33372
33372
|
function recordsFromRowsChunk(payload, operation) {
|
|
33373
33373
|
if (!isRecord(payload) || payload.kind !== "rows" || !Array.isArray(payload.rows)) {
|
|
33374
|
-
throw new
|
|
33374
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33375
33375
|
}
|
|
33376
33376
|
return payload.rows.map((row) => {
|
|
33377
33377
|
if (!isRecord(row) || !Array.isArray(row.columns)) {
|
|
33378
|
-
throw new
|
|
33378
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33379
33379
|
}
|
|
33380
33380
|
return Object.fromEntries(row.columns.map((column) => {
|
|
33381
33381
|
if (!isRecord(column) || typeof column.name !== "string") {
|
|
33382
|
-
throw new
|
|
33382
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33383
33383
|
}
|
|
33384
33384
|
try {
|
|
33385
33385
|
return [column.name, decodeRecordValue(column.value)];
|
|
33386
33386
|
} catch {
|
|
33387
|
-
throw new
|
|
33387
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33388
33388
|
}
|
|
33389
33389
|
}));
|
|
33390
33390
|
});
|
|
33391
33391
|
}
|
|
33392
33392
|
function rowChunkList(records, rowsPerChunk = 128) {
|
|
33393
33393
|
if (rowsPerChunk <= 0) {
|
|
33394
|
-
throw new
|
|
33394
|
+
throw new room_server_client_js_1.RoomServerException("rowsPerChunk must be greater than zero");
|
|
33395
33395
|
}
|
|
33396
33396
|
const chunks = [];
|
|
33397
33397
|
for (let index = 0; index < records.length; index += rowsPerChunk) {
|
|
@@ -33424,14 +33424,14 @@ return true;`);
|
|
|
33424
33424
|
}
|
|
33425
33425
|
function tableIndexFromJson(value) {
|
|
33426
33426
|
if (!isRecord(value) || typeof value.name !== "string" || typeof value.type !== "string" || !Array.isArray(value.columns)) {
|
|
33427
|
-
throw new
|
|
33427
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_indexes");
|
|
33428
33428
|
}
|
|
33429
33429
|
return {
|
|
33430
33430
|
name: value.name,
|
|
33431
33431
|
type: value.type,
|
|
33432
33432
|
columns: value.columns.map((column) => {
|
|
33433
33433
|
if (typeof column !== "string") {
|
|
33434
|
-
throw new
|
|
33434
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_indexes");
|
|
33435
33435
|
}
|
|
33436
33436
|
return column;
|
|
33437
33437
|
}),
|
|
@@ -33446,7 +33446,7 @@ return true;`);
|
|
|
33446
33446
|
}
|
|
33447
33447
|
function optimizeResultFromJson(value) {
|
|
33448
33448
|
if (!isRecord(value)) {
|
|
33449
|
-
throw new
|
|
33449
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.optimize");
|
|
33450
33450
|
}
|
|
33451
33451
|
return {
|
|
33452
33452
|
compaction: typeof value.compaction_json === "string" ? JSON.parse(value.compaction_json) : isRecord(value.compaction) ? value.compaction : null,
|
|
@@ -33456,31 +33456,31 @@ return true;`);
|
|
|
33456
33456
|
}
|
|
33457
33457
|
function tableStatsFromJson(value) {
|
|
33458
33458
|
if (!isRecord(value)) {
|
|
33459
|
-
throw new
|
|
33459
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.stats");
|
|
33460
33460
|
}
|
|
33461
33461
|
const dataset = typeof value.dataset_json === "string" ? JSON.parse(value.dataset_json) : value.dataset;
|
|
33462
33462
|
const data = typeof value.data_json === "string" ? JSON.parse(value.data_json) : value.data;
|
|
33463
33463
|
if (!isRecord(dataset) || !isRecord(data)) {
|
|
33464
|
-
throw new
|
|
33464
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.stats");
|
|
33465
33465
|
}
|
|
33466
33466
|
return { dataset, data };
|
|
33467
33467
|
}
|
|
33468
33468
|
function tableVersionFromJson(value) {
|
|
33469
33469
|
if (!isRecord(value) || typeof value.metadata_json !== "string" || typeof value.timestamp !== "string" || typeof value.version !== "number") {
|
|
33470
|
-
throw new
|
|
33470
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33471
33471
|
}
|
|
33472
33472
|
const timestamp = new Date(value.timestamp);
|
|
33473
33473
|
if (Number.isNaN(timestamp.getTime())) {
|
|
33474
|
-
throw new
|
|
33474
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33475
33475
|
}
|
|
33476
33476
|
let metadata;
|
|
33477
33477
|
try {
|
|
33478
33478
|
metadata = JSON.parse(value.metadata_json);
|
|
33479
33479
|
} catch (_) {
|
|
33480
|
-
throw new
|
|
33480
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33481
33481
|
}
|
|
33482
33482
|
if (!isRecord(metadata)) {
|
|
33483
|
-
throw new
|
|
33483
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_versions");
|
|
33484
33484
|
}
|
|
33485
33485
|
return {
|
|
33486
33486
|
version: value.version,
|
|
@@ -33490,25 +33490,25 @@ return true;`);
|
|
|
33490
33490
|
}
|
|
33491
33491
|
function tableBranchFromJson(value) {
|
|
33492
33492
|
if (!isRecord(value) || typeof value.name !== "string") {
|
|
33493
|
-
throw new
|
|
33493
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33494
33494
|
}
|
|
33495
33495
|
if (value.parent_branch != null && typeof value.parent_branch !== "string") {
|
|
33496
|
-
throw new
|
|
33496
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33497
33497
|
}
|
|
33498
33498
|
if (value.parent_version != null && (typeof value.parent_version !== "number" || !Number.isInteger(value.parent_version))) {
|
|
33499
|
-
throw new
|
|
33499
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33500
33500
|
}
|
|
33501
33501
|
if (value.manifest_size != null && (typeof value.manifest_size !== "number" || !Number.isInteger(value.manifest_size))) {
|
|
33502
|
-
throw new
|
|
33502
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33503
33503
|
}
|
|
33504
33504
|
let createdAt = null;
|
|
33505
33505
|
if (value.created_at != null) {
|
|
33506
33506
|
if (typeof value.created_at !== "string") {
|
|
33507
|
-
throw new
|
|
33507
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33508
33508
|
}
|
|
33509
33509
|
createdAt = new Date(value.created_at);
|
|
33510
33510
|
if (Number.isNaN(createdAt.getTime())) {
|
|
33511
|
-
throw new
|
|
33511
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from datasets.list_branches");
|
|
33512
33512
|
}
|
|
33513
33513
|
}
|
|
33514
33514
|
return {
|
|
@@ -33574,7 +33574,7 @@ return true;`);
|
|
|
33574
33574
|
});
|
|
33575
33575
|
}
|
|
33576
33576
|
async *stream() {
|
|
33577
|
-
yield new
|
|
33577
|
+
yield new response_js_1.JsonContent({ json: this.start });
|
|
33578
33578
|
while (!this.closed) {
|
|
33579
33579
|
await this.waitForPull();
|
|
33580
33580
|
if (this.closed) {
|
|
@@ -33587,7 +33587,7 @@ return true;`);
|
|
|
33587
33587
|
if (nextChunk.value.length === 0) {
|
|
33588
33588
|
continue;
|
|
33589
33589
|
}
|
|
33590
|
-
yield new
|
|
33590
|
+
yield new response_js_1.JsonContent({ json: rowsChunk(nextChunk.value) });
|
|
33591
33591
|
}
|
|
33592
33592
|
}
|
|
33593
33593
|
};
|
|
@@ -33608,7 +33608,7 @@ return true;`);
|
|
|
33608
33608
|
function tableFromIPCBytes(data) {
|
|
33609
33609
|
const table = (0, apache_arrow_1.tableFromIPC)(data);
|
|
33610
33610
|
if (table instanceof Promise) {
|
|
33611
|
-
throw new
|
|
33611
|
+
throw new room_server_client_js_1.RoomServerException("unexpected async Arrow IPC result");
|
|
33612
33612
|
}
|
|
33613
33613
|
return table;
|
|
33614
33614
|
}
|
|
@@ -33666,7 +33666,7 @@ return true;`);
|
|
|
33666
33666
|
});
|
|
33667
33667
|
}
|
|
33668
33668
|
async *stream() {
|
|
33669
|
-
yield new
|
|
33669
|
+
yield new response_js_1.BinaryContent({
|
|
33670
33670
|
data: this.schema == null ? new Uint8Array() : schemaToIPC(this.schema),
|
|
33671
33671
|
headers: this.start
|
|
33672
33672
|
});
|
|
@@ -33682,7 +33682,7 @@ return true;`);
|
|
|
33682
33682
|
if (nextChunk.value.numRows === 0) {
|
|
33683
33683
|
continue;
|
|
33684
33684
|
}
|
|
33685
|
-
yield new
|
|
33685
|
+
yield new response_js_1.BinaryContent({
|
|
33686
33686
|
data: (0, apache_arrow_1.tableToIPC)(nextChunk.value, "stream"),
|
|
33687
33687
|
headers: { kind: "data", content_type: ARROW_IPC_STREAM_MIME_TYPE }
|
|
33688
33688
|
});
|
|
@@ -33730,13 +33730,13 @@ return true;`);
|
|
|
33730
33730
|
});
|
|
33731
33731
|
}
|
|
33732
33732
|
async *stream() {
|
|
33733
|
-
yield new
|
|
33733
|
+
yield new response_js_1.JsonContent({ json: this.start });
|
|
33734
33734
|
while (!this.closed) {
|
|
33735
33735
|
await this.waitForPull();
|
|
33736
33736
|
if (this.closed) {
|
|
33737
33737
|
return;
|
|
33738
33738
|
}
|
|
33739
|
-
yield new
|
|
33739
|
+
yield new response_js_1.JsonContent({ json: { kind: "pull" } });
|
|
33740
33740
|
}
|
|
33741
33741
|
}
|
|
33742
33742
|
};
|
|
@@ -33781,13 +33781,13 @@ return true;`);
|
|
|
33781
33781
|
});
|
|
33782
33782
|
}
|
|
33783
33783
|
async *stream() {
|
|
33784
|
-
yield new
|
|
33784
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: this.start });
|
|
33785
33785
|
while (!this.closed) {
|
|
33786
33786
|
await this.waitForPull();
|
|
33787
33787
|
if (this.closed) {
|
|
33788
33788
|
return;
|
|
33789
33789
|
}
|
|
33790
|
-
yield new
|
|
33790
|
+
yield new response_js_1.BinaryContent({ data: new Uint8Array(), headers: { kind: "pull" } });
|
|
33791
33791
|
}
|
|
33792
33792
|
}
|
|
33793
33793
|
};
|
|
@@ -33796,11 +33796,11 @@ return true;`);
|
|
|
33796
33796
|
this.room = room;
|
|
33797
33797
|
}
|
|
33798
33798
|
_unexpectedResponseError(operation) {
|
|
33799
|
-
return new
|
|
33799
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from datasets.${operation}`);
|
|
33800
33800
|
}
|
|
33801
33801
|
async invoke(operation, input) {
|
|
33802
33802
|
const response = await this.room.invoke({ toolkit: "dataset", tool: operation, input });
|
|
33803
|
-
if (response instanceof
|
|
33803
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
33804
33804
|
return response;
|
|
33805
33805
|
}
|
|
33806
33806
|
if (response == null) {
|
|
@@ -33818,23 +33818,23 @@ return true;`);
|
|
|
33818
33818
|
const response = await this.invokeStream(operation, input.stream());
|
|
33819
33819
|
try {
|
|
33820
33820
|
for await (const chunk of response) {
|
|
33821
|
-
if (chunk instanceof
|
|
33822
|
-
throw new
|
|
33821
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
33822
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
33823
33823
|
}
|
|
33824
|
-
if (chunk instanceof
|
|
33824
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
33825
33825
|
if (chunk.method === "close") {
|
|
33826
33826
|
return;
|
|
33827
33827
|
}
|
|
33828
33828
|
throw this._unexpectedResponseError(operation);
|
|
33829
33829
|
}
|
|
33830
|
-
if (chunk instanceof
|
|
33830
|
+
if (chunk instanceof response_js_1.BinaryContent) {
|
|
33831
33831
|
if (chunk.headers.kind !== "pull") {
|
|
33832
33832
|
throw this._unexpectedResponseError(operation);
|
|
33833
33833
|
}
|
|
33834
33834
|
input.requestNext();
|
|
33835
33835
|
continue;
|
|
33836
33836
|
}
|
|
33837
|
-
if (!(chunk instanceof
|
|
33837
|
+
if (!(chunk instanceof response_js_1.JsonContent) || chunk.json.kind !== "pull") {
|
|
33838
33838
|
throw this._unexpectedResponseError(operation);
|
|
33839
33839
|
}
|
|
33840
33840
|
input.requestNext();
|
|
@@ -33849,16 +33849,16 @@ return true;`);
|
|
|
33849
33849
|
input.requestNext();
|
|
33850
33850
|
try {
|
|
33851
33851
|
for await (const chunk of response) {
|
|
33852
|
-
if (chunk instanceof
|
|
33853
|
-
throw new
|
|
33852
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
33853
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
33854
33854
|
}
|
|
33855
|
-
if (chunk instanceof
|
|
33855
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
33856
33856
|
if (chunk.method === "close") {
|
|
33857
33857
|
return;
|
|
33858
33858
|
}
|
|
33859
33859
|
throw this._unexpectedResponseError(operation);
|
|
33860
33860
|
}
|
|
33861
|
-
if (!(chunk instanceof
|
|
33861
|
+
if (!(chunk instanceof response_js_1.JsonContent)) {
|
|
33862
33862
|
throw this._unexpectedResponseError(operation);
|
|
33863
33863
|
}
|
|
33864
33864
|
yield recordsFromRowsChunk(chunk.json, operation);
|
|
@@ -33874,16 +33874,16 @@ return true;`);
|
|
|
33874
33874
|
input.requestNext();
|
|
33875
33875
|
try {
|
|
33876
33876
|
for await (const chunk of response) {
|
|
33877
|
-
if (chunk instanceof
|
|
33878
|
-
throw new
|
|
33877
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
33878
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
33879
33879
|
}
|
|
33880
|
-
if (chunk instanceof
|
|
33880
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
33881
33881
|
if (chunk.method === "close") {
|
|
33882
33882
|
return;
|
|
33883
33883
|
}
|
|
33884
33884
|
throw this._unexpectedResponseError(operation);
|
|
33885
33885
|
}
|
|
33886
|
-
if (!(chunk instanceof
|
|
33886
|
+
if (!(chunk instanceof response_js_1.BinaryContent) || chunk.headers.kind !== "data") {
|
|
33887
33887
|
throw this._unexpectedResponseError(operation);
|
|
33888
33888
|
}
|
|
33889
33889
|
yield tableFromIPCBytes(chunk.data);
|
|
@@ -33898,7 +33898,7 @@ return true;`);
|
|
|
33898
33898
|
namespace: namespace ?? null,
|
|
33899
33899
|
branch: branch ?? null
|
|
33900
33900
|
});
|
|
33901
|
-
if (!(response instanceof
|
|
33901
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
33902
33902
|
throw this._unexpectedResponseError("list_tables");
|
|
33903
33903
|
}
|
|
33904
33904
|
return Array.isArray(response.json.tables) ? response.json.tables : [];
|
|
@@ -34045,7 +34045,7 @@ return true;`);
|
|
|
34045
34045
|
}
|
|
34046
34046
|
async addColumns({ table, newColumns, namespace, branch }) {
|
|
34047
34047
|
if (newColumns instanceof apache_arrow_1.Schema) {
|
|
34048
|
-
await this.invokeContent("add_columns", new
|
|
34048
|
+
await this.invokeContent("add_columns", new response_js_1.BinaryContent({
|
|
34049
34049
|
data: schemaToIPC(newColumns),
|
|
34050
34050
|
headers: {
|
|
34051
34051
|
table,
|
|
@@ -34136,7 +34136,7 @@ return true;`);
|
|
|
34136
34136
|
return tableFromChunks(await this.sql({ query, tables, params, namespace, branch }));
|
|
34137
34137
|
}
|
|
34138
34138
|
async openSqlQuery({ query, tables, params, namespace, branch }) {
|
|
34139
|
-
const response = await this.invokeContent("open_sql_query", new
|
|
34139
|
+
const response = await this.invokeContent("open_sql_query", new response_js_1.BinaryContent({
|
|
34140
34140
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
34141
34141
|
headers: {
|
|
34142
34142
|
query,
|
|
@@ -34145,7 +34145,7 @@ return true;`);
|
|
|
34145
34145
|
branch: branch ?? null
|
|
34146
34146
|
}
|
|
34147
34147
|
}));
|
|
34148
|
-
if (!(response instanceof
|
|
34148
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
34149
34149
|
throw this._unexpectedResponseError("open_sql_query");
|
|
34150
34150
|
}
|
|
34151
34151
|
const queryId = response.headers.query_id;
|
|
@@ -34159,7 +34159,7 @@ return true;`);
|
|
|
34159
34159
|
};
|
|
34160
34160
|
}
|
|
34161
34161
|
async executeSql({ query, tables, params, namespace, branch }) {
|
|
34162
|
-
const response = await this.invokeContent("execute_sql", new
|
|
34162
|
+
const response = await this.invokeContent("execute_sql", new response_js_1.BinaryContent({
|
|
34163
34163
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
34164
34164
|
headers: {
|
|
34165
34165
|
query,
|
|
@@ -34168,7 +34168,7 @@ return true;`);
|
|
|
34168
34168
|
branch: branch ?? null
|
|
34169
34169
|
}
|
|
34170
34170
|
}));
|
|
34171
|
-
if (response instanceof
|
|
34171
|
+
if (response instanceof response_js_1.BinaryContent) {
|
|
34172
34172
|
if (response.headers.kind !== "query") {
|
|
34173
34173
|
throw this._unexpectedResponseError("execute_sql");
|
|
34174
34174
|
}
|
|
@@ -34182,7 +34182,7 @@ return true;`);
|
|
|
34182
34182
|
queryId
|
|
34183
34183
|
};
|
|
34184
34184
|
}
|
|
34185
|
-
if (response instanceof
|
|
34185
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
34186
34186
|
if (response.json.kind !== "statement" || typeof response.json.rows_affected !== "number" || !Number.isInteger(response.json.rows_affected)) {
|
|
34187
34187
|
throw this._unexpectedResponseError("execute_sql");
|
|
34188
34188
|
}
|
|
@@ -34196,7 +34196,7 @@ return true;`);
|
|
|
34196
34196
|
async *sqlStream({ query, tables, params, namespace, branch }) {
|
|
34197
34197
|
const result = await this.executeSql({ query, tables, params, namespace, branch });
|
|
34198
34198
|
if (result.kind === "statement") {
|
|
34199
|
-
throw new
|
|
34199
|
+
throw new room_server_client_js_1.RoomServerException(`SQL statement did not return rows; rows_affected=${result.rowsAffected}`);
|
|
34200
34200
|
}
|
|
34201
34201
|
const opened = result;
|
|
34202
34202
|
try {
|
|
@@ -34213,19 +34213,19 @@ return true;`);
|
|
|
34213
34213
|
}
|
|
34214
34214
|
async closeSqlQuery({ queryId }) {
|
|
34215
34215
|
const response = await this.room.invoke({ toolkit: "dataset", tool: "close_sql_query", input: { query_id: queryId } });
|
|
34216
|
-
if (!(response instanceof
|
|
34216
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
34217
34217
|
throw this._unexpectedResponseError("close_sql_query");
|
|
34218
34218
|
}
|
|
34219
34219
|
}
|
|
34220
34220
|
async cancelSqlQuery({ queryId }) {
|
|
34221
34221
|
const response = await this.room.invoke({ toolkit: "dataset", tool: "cancel_sql_query", input: { query_id: queryId } });
|
|
34222
|
-
if (!(response instanceof
|
|
34222
|
+
if (!(response instanceof response_js_1.JsonContent) || !["cancelled", "cancelling", "not_cancellable"].includes(response.json.status)) {
|
|
34223
34223
|
throw this._unexpectedResponseError("cancel_sql_query");
|
|
34224
34224
|
}
|
|
34225
34225
|
return { status: response.json.status };
|
|
34226
34226
|
}
|
|
34227
34227
|
async executeSqlStatement({ query, tables, params, namespace, branch }) {
|
|
34228
|
-
const response = await this.invokeContent("execute_sql_statement", new
|
|
34228
|
+
const response = await this.invokeContent("execute_sql_statement", new response_js_1.BinaryContent({
|
|
34229
34229
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
34230
34230
|
headers: {
|
|
34231
34231
|
query,
|
|
@@ -34234,7 +34234,7 @@ return true;`);
|
|
|
34234
34234
|
branch: branch ?? null
|
|
34235
34235
|
}
|
|
34236
34236
|
}));
|
|
34237
|
-
if (!(response instanceof
|
|
34237
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.rows_affected !== "number" || !Number.isInteger(response.json.rows_affected)) {
|
|
34238
34238
|
throw this._unexpectedResponseError("execute_sql_statement");
|
|
34239
34239
|
}
|
|
34240
34240
|
return response.json.rows_affected;
|
|
@@ -34299,16 +34299,16 @@ return true;`);
|
|
|
34299
34299
|
input.requestNext();
|
|
34300
34300
|
try {
|
|
34301
34301
|
for await (const chunk of response) {
|
|
34302
|
-
if (chunk instanceof
|
|
34303
|
-
throw new
|
|
34302
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
34303
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
34304
34304
|
}
|
|
34305
|
-
if (chunk instanceof
|
|
34305
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
34306
34306
|
if (chunk.method === "close") {
|
|
34307
34307
|
return;
|
|
34308
34308
|
}
|
|
34309
34309
|
throw this._unexpectedResponseError("watch_table");
|
|
34310
34310
|
}
|
|
34311
|
-
if (chunk instanceof
|
|
34311
|
+
if (chunk instanceof response_js_1.BinaryContent) {
|
|
34312
34312
|
if (chunk.headers.kind !== "data") {
|
|
34313
34313
|
throw this._unexpectedResponseError("watch_table");
|
|
34314
34314
|
}
|
|
@@ -34326,7 +34326,7 @@ return true;`);
|
|
|
34326
34326
|
input.requestNext();
|
|
34327
34327
|
continue;
|
|
34328
34328
|
}
|
|
34329
|
-
if (chunk instanceof
|
|
34329
|
+
if (chunk instanceof response_js_1.JsonContent) {
|
|
34330
34330
|
if (!isRecord(chunk.json)) {
|
|
34331
34331
|
throw this._unexpectedResponseError("watch_table");
|
|
34332
34332
|
}
|
|
@@ -34362,7 +34362,7 @@ return true;`);
|
|
|
34362
34362
|
branch: branch ?? null,
|
|
34363
34363
|
version: version2 ?? null
|
|
34364
34364
|
});
|
|
34365
|
-
if (!(response instanceof
|
|
34365
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json.count !== "number" || !Number.isInteger(response.json.count)) {
|
|
34366
34366
|
throw this._unexpectedResponseError("count");
|
|
34367
34367
|
}
|
|
34368
34368
|
return response.json.count;
|
|
@@ -34378,7 +34378,7 @@ return true;`);
|
|
|
34378
34378
|
version: version2 ?? null
|
|
34379
34379
|
}
|
|
34380
34380
|
});
|
|
34381
|
-
if (!(response instanceof
|
|
34381
|
+
if (!(response instanceof response_js_1.BinaryContent)) {
|
|
34382
34382
|
throw this._unexpectedResponseError("inspect");
|
|
34383
34383
|
}
|
|
34384
34384
|
return tableFromIPCBytes(response.data).schema;
|
|
@@ -34394,7 +34394,7 @@ return true;`);
|
|
|
34394
34394
|
branch: branch ?? null,
|
|
34395
34395
|
config: config ?? null
|
|
34396
34396
|
});
|
|
34397
|
-
if (!(response instanceof
|
|
34397
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
34398
34398
|
throw this._unexpectedResponseError("optimize");
|
|
34399
34399
|
}
|
|
34400
34400
|
return optimizeResultFromJson(response.json);
|
|
@@ -34407,7 +34407,7 @@ return true;`);
|
|
|
34407
34407
|
version: version2 ?? null,
|
|
34408
34408
|
max_rows_per_group: maxRowsPerGroup ?? null
|
|
34409
34409
|
});
|
|
34410
|
-
if (!(response instanceof
|
|
34410
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
34411
34411
|
throw this._unexpectedResponseError("stats");
|
|
34412
34412
|
}
|
|
34413
34413
|
return tableStatsFromJson(response.json);
|
|
@@ -34425,7 +34425,7 @@ return true;`);
|
|
|
34425
34425
|
namespace: namespace ?? null,
|
|
34426
34426
|
branch: branch ?? null
|
|
34427
34427
|
});
|
|
34428
|
-
if (!(response instanceof
|
|
34428
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.versions)) {
|
|
34429
34429
|
throw this._unexpectedResponseError("list_versions");
|
|
34430
34430
|
}
|
|
34431
34431
|
return response.json.versions.map((version2) => tableVersionFromJson(version2));
|
|
@@ -34444,7 +34444,7 @@ return true;`);
|
|
|
34444
34444
|
branch: branch ?? null,
|
|
34445
34445
|
version: version2 ?? null
|
|
34446
34446
|
});
|
|
34447
|
-
if (!(response instanceof
|
|
34447
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.indexes)) {
|
|
34448
34448
|
throw this._unexpectedResponseError("list_indexes");
|
|
34449
34449
|
}
|
|
34450
34450
|
return response.json.indexes.map((index) => tableIndexFromJson(index));
|
|
@@ -34453,7 +34453,7 @@ return true;`);
|
|
|
34453
34453
|
const response = await this.invoke("list_branches", {
|
|
34454
34454
|
namespace: namespace ?? null
|
|
34455
34455
|
});
|
|
34456
|
-
if (!(response instanceof
|
|
34456
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json.branches)) {
|
|
34457
34457
|
throw this._unexpectedResponseError("list_branches");
|
|
34458
34458
|
}
|
|
34459
34459
|
return response.json.branches.map((branch) => tableBranchFromJson(branch));
|
|
@@ -34487,18 +34487,18 @@ return true;`);
|
|
|
34487
34487
|
"use strict";
|
|
34488
34488
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34489
34489
|
exports.DeveloperClient = void 0;
|
|
34490
|
-
var
|
|
34491
|
-
var
|
|
34492
|
-
var
|
|
34493
|
-
var
|
|
34494
|
-
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 {
|
|
34495
34495
|
constructor({ room }) {
|
|
34496
34496
|
super();
|
|
34497
34497
|
this.client = room;
|
|
34498
34498
|
this.client.protocol.addHandler("developer.log", this._handleDeveloperLog.bind(this));
|
|
34499
34499
|
}
|
|
34500
34500
|
_emitDeveloperLog(type, data) {
|
|
34501
|
-
const event = new
|
|
34501
|
+
const event = new room_event_js_1.RoomLogEvent({ type, data });
|
|
34502
34502
|
this.client.emit(event);
|
|
34503
34503
|
this.emit("log", event);
|
|
34504
34504
|
}
|
|
@@ -34506,7 +34506,7 @@ return true;`);
|
|
|
34506
34506
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
34507
34507
|
return;
|
|
34508
34508
|
}
|
|
34509
|
-
const [rawJson, _] = (0,
|
|
34509
|
+
const [rawJson, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
34510
34510
|
this._emitDeveloperLog(rawJson["type"], rawJson["data"]);
|
|
34511
34511
|
}
|
|
34512
34512
|
async log(type, data) {
|
|
@@ -34531,16 +34531,16 @@ return true;`);
|
|
|
34531
34531
|
});
|
|
34532
34532
|
try {
|
|
34533
34533
|
for await (const chunk of stream) {
|
|
34534
|
-
if (chunk instanceof
|
|
34534
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
34535
34535
|
throw new Error(chunk.text);
|
|
34536
34536
|
}
|
|
34537
|
-
if (chunk instanceof
|
|
34537
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
34538
34538
|
if (chunk.method === "close") {
|
|
34539
34539
|
return;
|
|
34540
34540
|
}
|
|
34541
34541
|
throw new Error("unexpected return type from developer.logs");
|
|
34542
34542
|
}
|
|
34543
|
-
if (!(chunk instanceof
|
|
34543
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
34544
34544
|
throw new Error("unexpected return type from developer.logs");
|
|
34545
34545
|
}
|
|
34546
34546
|
const logType = chunk.headers["type"];
|
|
@@ -34551,7 +34551,7 @@ return true;`);
|
|
|
34551
34551
|
if (typeof decoded !== "object" || decoded === null || Array.isArray(decoded)) {
|
|
34552
34552
|
throw new Error("developer.logs returned invalid JSON data");
|
|
34553
34553
|
}
|
|
34554
|
-
const event = new
|
|
34554
|
+
const event = new room_event_js_1.RoomLogEvent({ type: logType, data: decoded });
|
|
34555
34555
|
this.client.emit(event);
|
|
34556
34556
|
this.emit("log", event);
|
|
34557
34557
|
yield event;
|
|
@@ -39305,6 +39305,9 @@ ${newlined}
|
|
|
39305
39305
|
var require_api_keys = __commonJS({
|
|
39306
39306
|
"../meshagent-ts/dist/browser/api_keys.js"(exports) {
|
|
39307
39307
|
"use strict";
|
|
39308
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
39309
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
39310
|
+
};
|
|
39308
39311
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39309
39312
|
exports.base36Encode = base36Encode;
|
|
39310
39313
|
exports.base36Decode = base36Decode;
|
|
@@ -39314,7 +39317,8 @@ ${newlined}
|
|
|
39314
39317
|
exports.base64DecompressUuid = base64DecompressUuid;
|
|
39315
39318
|
exports.parseApiKey = parseApiKey;
|
|
39316
39319
|
exports.encodeApiKey = encodeApiKey;
|
|
39317
|
-
var base_64_1 = require_base64();
|
|
39320
|
+
var base_64_1 = __importDefault(require_base64());
|
|
39321
|
+
var { encode: base64Encode, decode: base64Decode } = base_64_1.default;
|
|
39318
39322
|
var BASE36_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
39319
39323
|
var BASE36 = 36n;
|
|
39320
39324
|
var UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
|
|
@@ -39397,7 +39401,7 @@ ${newlined}
|
|
|
39397
39401
|
if (globalScope.btoa) {
|
|
39398
39402
|
return globalScope.btoa(binary);
|
|
39399
39403
|
}
|
|
39400
|
-
return (
|
|
39404
|
+
return base64Encode(binary);
|
|
39401
39405
|
}
|
|
39402
39406
|
function base64ToBytes(base64) {
|
|
39403
39407
|
if (globalScope.Buffer) {
|
|
@@ -39408,7 +39412,7 @@ ${newlined}
|
|
|
39408
39412
|
if (globalScope.atob) {
|
|
39409
39413
|
binary = globalScope.atob(base64);
|
|
39410
39414
|
} else {
|
|
39411
|
-
binary = (
|
|
39415
|
+
binary = base64Decode(base64);
|
|
39412
39416
|
}
|
|
39413
39417
|
const bytes = new Uint8Array(binary.length);
|
|
39414
39418
|
for (let i = 0; i < binary.length; i += 1) {
|
|
@@ -39497,8 +39501,8 @@ ${newlined}
|
|
|
39497
39501
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39498
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;
|
|
39499
39503
|
var jose_1 = (init_webapi(), __toCommonJS(webapi_exports));
|
|
39500
|
-
var
|
|
39501
|
-
var
|
|
39504
|
+
var api_keys_js_1 = require_api_keys();
|
|
39505
|
+
var version_js_1 = require_version();
|
|
39502
39506
|
function matchesGrantPattern(patterns, value, allowIfUnset) {
|
|
39503
39507
|
if (!patterns) {
|
|
39504
39508
|
return allowIfUnset;
|
|
@@ -40574,7 +40578,7 @@ ${newlined}
|
|
|
40574
40578
|
this.name = name;
|
|
40575
40579
|
this.projectId = projectId;
|
|
40576
40580
|
this.apiKeyId = apiKeyId;
|
|
40577
|
-
this.version = version2 ??
|
|
40581
|
+
this.version = version2 ?? version_js_1.__version__;
|
|
40578
40582
|
this.extra = extra ?? {};
|
|
40579
40583
|
this.grants = grants ?? [];
|
|
40580
40584
|
}
|
|
@@ -40658,7 +40662,7 @@ ${newlined}
|
|
|
40658
40662
|
const resolvedApiKey = apiKey ?? getEnvValue("MESHAGENT_API_KEY");
|
|
40659
40663
|
let resolvedSecret = token;
|
|
40660
40664
|
if (resolvedApiKey !== void 0) {
|
|
40661
|
-
const parsed = (0,
|
|
40665
|
+
const parsed = (0, api_keys_js_1.parseApiKey)(resolvedApiKey);
|
|
40662
40666
|
resolvedSecret = parsed.secret;
|
|
40663
40667
|
payload["kid"] = parsed.id;
|
|
40664
40668
|
payload["sub"] = parsed.projectId;
|
|
@@ -40690,7 +40694,7 @@ ${newlined}
|
|
|
40690
40694
|
delete data.sub;
|
|
40691
40695
|
const apiKeyId = typeof data.kid === "string" ? data.kid : void 0;
|
|
40692
40696
|
delete data.kid;
|
|
40693
|
-
const version2 = typeof data.version === "string" ? data.version :
|
|
40697
|
+
const version2 = typeof data.version === "string" ? data.version : version_js_1.__version__;
|
|
40694
40698
|
delete data.version;
|
|
40695
40699
|
return new _ParticipantToken({
|
|
40696
40700
|
name,
|
|
@@ -40759,14 +40763,14 @@ ${newlined}
|
|
|
40759
40763
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40760
40764
|
exports.WebSocketClientProtocol = exports.Protocol = exports.ProtocolMessageStream = exports.WebSocketProtocolChannel = exports.StreamProtocolChannel = exports.ProtocolHandshakeException = exports.ProtocolCloseException = exports.ProtocolReconnectUnsupportedException = exports.ProtocolCloseKind = void 0;
|
|
40761
40765
|
var isomorphic_ws_1 = __importDefault((init_browser(), __toCommonJS(browser_exports)));
|
|
40762
|
-
var
|
|
40763
|
-
var
|
|
40766
|
+
var completer_js_1 = require_completer();
|
|
40767
|
+
var utils_js_1 = require_utils();
|
|
40764
40768
|
var ProtocolMessage = class {
|
|
40765
40769
|
constructor({ id, type, data }) {
|
|
40766
40770
|
this.id = id;
|
|
40767
40771
|
this.type = type;
|
|
40768
40772
|
this.data = data;
|
|
40769
|
-
this.sent = new
|
|
40773
|
+
this.sent = new completer_js_1.Completer();
|
|
40770
40774
|
}
|
|
40771
40775
|
};
|
|
40772
40776
|
var ProtocolCloseKind;
|
|
@@ -40804,6 +40808,16 @@ ${newlined}
|
|
|
40804
40808
|
function isNodeRuntime() {
|
|
40805
40809
|
return typeof process !== "undefined" && process.release?.name === "node";
|
|
40806
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
|
+
}
|
|
40807
40821
|
var StreamProtocolChannel = class {
|
|
40808
40822
|
constructor({ input, output }) {
|
|
40809
40823
|
this.started = false;
|
|
@@ -40845,7 +40859,7 @@ ${newlined}
|
|
|
40845
40859
|
var WebSocketProtocolChannel = class {
|
|
40846
40860
|
constructor({ url, jwt }) {
|
|
40847
40861
|
this.webSocket = null;
|
|
40848
|
-
this._opened = new
|
|
40862
|
+
this._opened = new completer_js_1.Completer();
|
|
40849
40863
|
this._finished = false;
|
|
40850
40864
|
this._onUnexpectedResponse = (_request, response) => {
|
|
40851
40865
|
const statusCode = response.statusCode;
|
|
@@ -40872,7 +40886,7 @@ ${newlined}
|
|
|
40872
40886
|
return;
|
|
40873
40887
|
}
|
|
40874
40888
|
if (typeof data === "string") {
|
|
40875
|
-
this._onDataReceived?.(
|
|
40889
|
+
this._onDataReceived?.(utils_js_1.encoder.encode(data));
|
|
40876
40890
|
return;
|
|
40877
40891
|
}
|
|
40878
40892
|
if (data instanceof ArrayBuffer) {
|
|
@@ -40902,14 +40916,16 @@ ${newlined}
|
|
|
40902
40916
|
this.jwt = jwt;
|
|
40903
40917
|
}
|
|
40904
40918
|
start(onDataReceived, { onDone, onError }) {
|
|
40905
|
-
const url =
|
|
40906
|
-
|
|
40907
|
-
this._opened = new completer_1.Completer();
|
|
40919
|
+
const url = resolveWebSocketUrl(this.url);
|
|
40920
|
+
this._opened = new completer_js_1.Completer();
|
|
40908
40921
|
this._finished = false;
|
|
40909
40922
|
this._onDataReceived = onDataReceived;
|
|
40910
40923
|
this._doneHandler = onDone;
|
|
40911
40924
|
this._errorHandler = onError;
|
|
40912
|
-
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}`]);
|
|
40913
40929
|
this.webSocket = socket;
|
|
40914
40930
|
if (isNodeRuntime()) {
|
|
40915
40931
|
socket.on("unexpected-response", this._onUnexpectedResponse);
|
|
@@ -40961,7 +40977,7 @@ ${newlined}
|
|
|
40961
40977
|
var ProtocolMessageStream = class {
|
|
40962
40978
|
constructor() {
|
|
40963
40979
|
this._messages = [];
|
|
40964
|
-
this._messageAdded = new
|
|
40980
|
+
this._messageAdded = new completer_js_1.Completer();
|
|
40965
40981
|
this._closed = false;
|
|
40966
40982
|
}
|
|
40967
40983
|
add(message2) {
|
|
@@ -40979,7 +40995,7 @@ ${newlined}
|
|
|
40979
40995
|
async *stream() {
|
|
40980
40996
|
while (!this._closed) {
|
|
40981
40997
|
await this._messageAdded.fut;
|
|
40982
|
-
this._messageAdded = new
|
|
40998
|
+
this._messageAdded = new completer_js_1.Completer();
|
|
40983
40999
|
while (this._messages.length > 0 && !this._closed) {
|
|
40984
41000
|
const message2 = this._messages.shift();
|
|
40985
41001
|
if (message2 !== void 0) {
|
|
@@ -40995,7 +41011,7 @@ ${newlined}
|
|
|
40995
41011
|
this.handlers = {};
|
|
40996
41012
|
this._id = 0;
|
|
40997
41013
|
this._send = new ProtocolMessageStream();
|
|
40998
|
-
this._done = new
|
|
41014
|
+
this._done = new completer_js_1.Completer();
|
|
40999
41015
|
this._sendLoop = null;
|
|
41000
41016
|
this._open = false;
|
|
41001
41017
|
this._closed = false;
|
|
@@ -41074,7 +41090,7 @@ ${newlined}
|
|
|
41074
41090
|
async handleMessage(messageId, type, data) {
|
|
41075
41091
|
const handler = this.handlers[type] ?? this.handlers["*"];
|
|
41076
41092
|
if (handler == null) {
|
|
41077
|
-
const unpacked = (0,
|
|
41093
|
+
const unpacked = (0, utils_js_1.unpackMessage)(data);
|
|
41078
41094
|
console.warn(`No handler for message type ${type}; data:`, unpacked);
|
|
41079
41095
|
return;
|
|
41080
41096
|
}
|
|
@@ -41106,7 +41122,7 @@ ${newlined}
|
|
|
41106
41122
|
await message2.sent.fut;
|
|
41107
41123
|
}
|
|
41108
41124
|
async sendJson(object) {
|
|
41109
|
-
await this.send("application/json",
|
|
41125
|
+
await this.send("application/json", utils_js_1.encoder.encode(JSON.stringify(object)));
|
|
41110
41126
|
}
|
|
41111
41127
|
start({ onMessage, onDone, onError } = {}) {
|
|
41112
41128
|
if (this._sendLoop != null) {
|
|
@@ -41168,14 +41184,14 @@ ${newlined}
|
|
|
41168
41184
|
headerView.setUint32(4, message2.id & 4294967295, false);
|
|
41169
41185
|
headerView.setUint32(8, 0, false);
|
|
41170
41186
|
headerView.setUint32(12, packets, false);
|
|
41171
|
-
await this.channel.sendData((0,
|
|
41187
|
+
await this.channel.sendData((0, utils_js_1.mergeUint8Arrays)(header, utils_js_1.encoder.encode(message2.type)));
|
|
41172
41188
|
for (let i = 0; i < packets; i += 1) {
|
|
41173
41189
|
const packetHeader = new Uint8Array(12);
|
|
41174
41190
|
const packetHeaderView = new DataView(packetHeader.buffer);
|
|
41175
41191
|
packetHeaderView.setUint32(0, Math.floor(message2.id / 2 ** 32), false);
|
|
41176
41192
|
packetHeaderView.setUint32(4, message2.id & 4294967295, false);
|
|
41177
41193
|
packetHeaderView.setUint32(8, i + 1, false);
|
|
41178
|
-
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))));
|
|
41179
41195
|
}
|
|
41180
41196
|
if (!message2.sent.completed) {
|
|
41181
41197
|
message2.sent.complete();
|
|
@@ -41209,10 +41225,10 @@ ${newlined}
|
|
|
41209
41225
|
if (this._recvState === "ready" || this._recvState === "error") {
|
|
41210
41226
|
this._recvPacketTotal = dataView.getUint32(12, false);
|
|
41211
41227
|
this._recvMessageId = messageId;
|
|
41212
|
-
this._recvType =
|
|
41228
|
+
this._recvType = utils_js_1.decoder.decode(dataPacket.subarray(16));
|
|
41213
41229
|
if (this._recvPacketTotal === 0) {
|
|
41214
41230
|
try {
|
|
41215
|
-
const merged = (0,
|
|
41231
|
+
const merged = (0, utils_js_1.mergeUint8Arrays)(...this._recvPackets);
|
|
41216
41232
|
this._recvPackets.length = 0;
|
|
41217
41233
|
this._dispatchMessage({ messageId, type: this._recvType, data: merged });
|
|
41218
41234
|
} finally {
|
|
@@ -41243,7 +41259,7 @@ ${newlined}
|
|
|
41243
41259
|
this._recvPackets.push(dataPacket.subarray(12));
|
|
41244
41260
|
if (this._recvPacketTotal === this._recvPacketId) {
|
|
41245
41261
|
try {
|
|
41246
|
-
const merged = (0,
|
|
41262
|
+
const merged = (0, utils_js_1.mergeUint8Arrays)(...this._recvPackets);
|
|
41247
41263
|
this._recvPackets.length = 0;
|
|
41248
41264
|
this._dispatchMessage({ messageId, type: this._recvType, data: merged });
|
|
41249
41265
|
} finally {
|
|
@@ -41263,7 +41279,7 @@ ${newlined}
|
|
|
41263
41279
|
}
|
|
41264
41280
|
};
|
|
41265
41281
|
exports.Protocol = Protocol;
|
|
41266
|
-
var WebSocketClientProtocol = class extends Protocol {
|
|
41282
|
+
var WebSocketClientProtocol = class _WebSocketClientProtocol extends Protocol {
|
|
41267
41283
|
constructor({ url, token }) {
|
|
41268
41284
|
super({
|
|
41269
41285
|
channel: new WebSocketProtocolChannel({ url, jwt: token })
|
|
@@ -41271,6 +41287,9 @@ ${newlined}
|
|
|
41271
41287
|
this._url = url;
|
|
41272
41288
|
this._token = token;
|
|
41273
41289
|
}
|
|
41290
|
+
static withIAP({ url = "./.well-known/meshagent/room/connect" } = {}) {
|
|
41291
|
+
return new _WebSocketClientProtocol({ url, token: null });
|
|
41292
|
+
}
|
|
41274
41293
|
get url() {
|
|
41275
41294
|
return this._url;
|
|
41276
41295
|
}
|
|
@@ -41293,13 +41312,13 @@ ${newlined}
|
|
|
41293
41312
|
exports.websocketRoomUrl = websocketRoomUrl;
|
|
41294
41313
|
exports.participantToken = participantToken;
|
|
41295
41314
|
exports.websocketProtocol = websocketProtocol;
|
|
41296
|
-
var
|
|
41297
|
-
var
|
|
41298
|
-
var
|
|
41299
|
-
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();
|
|
41300
41319
|
function validateSchemaName(name) {
|
|
41301
41320
|
if (name.includes(".")) {
|
|
41302
|
-
throw new
|
|
41321
|
+
throw new schema_js_1.MeshSchemaValidationException("schema name cannot contain '.'");
|
|
41303
41322
|
}
|
|
41304
41323
|
}
|
|
41305
41324
|
async function deploySchema({ room, schema, name, overwrite = true }) {
|
|
@@ -41330,11 +41349,11 @@ ${newlined}
|
|
|
41330
41349
|
let resolvedProjectId = projectId;
|
|
41331
41350
|
let resolvedApiKeyId = apiKeyId;
|
|
41332
41351
|
if (apiKey) {
|
|
41333
|
-
const parsed = (0,
|
|
41352
|
+
const parsed = (0, api_keys_js_1.parseApiKey)(apiKey);
|
|
41334
41353
|
resolvedProjectId ?? (resolvedProjectId = parsed.projectId);
|
|
41335
41354
|
resolvedApiKeyId ?? (resolvedApiKeyId = parsed.id);
|
|
41336
41355
|
}
|
|
41337
|
-
const token = new
|
|
41356
|
+
const token = new participant_token_js_1.ParticipantToken({
|
|
41338
41357
|
name: participantName,
|
|
41339
41358
|
projectId: resolvedProjectId,
|
|
41340
41359
|
apiKeyId: resolvedApiKeyId
|
|
@@ -41343,14 +41362,14 @@ ${newlined}
|
|
|
41343
41362
|
if (role) {
|
|
41344
41363
|
token.addRoleGrant(role);
|
|
41345
41364
|
}
|
|
41346
|
-
token.addApiGrant(
|
|
41365
|
+
token.addApiGrant(participant_token_js_1.ApiScope.agentDefault());
|
|
41347
41366
|
return token;
|
|
41348
41367
|
}
|
|
41349
41368
|
async function websocketProtocol({ participantName, roomName, role, projectId, apiKeyId, apiKey, secret, apiUrl }) {
|
|
41350
41369
|
const url = websocketRoomUrl({ roomName, apiUrl });
|
|
41351
41370
|
const token = participantToken({ participantName, roomName, role, projectId, apiKeyId, apiKey });
|
|
41352
41371
|
const jwt = await token.toJwt({ token: secret, apiKey });
|
|
41353
|
-
return
|
|
41372
|
+
return protocol_js_1.WebSocketClientProtocol.createFactory({ url, token: jwt });
|
|
41354
41373
|
}
|
|
41355
41374
|
}
|
|
41356
41375
|
});
|
|
@@ -41422,10 +41441,10 @@ ${newlined}
|
|
|
41422
41441
|
"use strict";
|
|
41423
41442
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41424
41443
|
exports.Meshagent = void 0;
|
|
41425
|
-
var
|
|
41426
|
-
var
|
|
41427
|
-
var
|
|
41428
|
-
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();
|
|
41429
41448
|
function pruneUndefinedValues(value) {
|
|
41430
41449
|
if (Array.isArray(value)) {
|
|
41431
41450
|
const prunedItems = value.map((item) => pruneUndefinedValues(item)).filter((item) => item !== void 0);
|
|
@@ -41514,7 +41533,7 @@ ${newlined}
|
|
|
41514
41533
|
}
|
|
41515
41534
|
var Meshagent2 = class {
|
|
41516
41535
|
constructor({ baseUrl, token } = {}) {
|
|
41517
|
-
const resolvedBaseUrl = (0,
|
|
41536
|
+
const resolvedBaseUrl = (0, helpers_js_1.meshagentBaseUrl)(baseUrl).replace(/\/+$/, "");
|
|
41518
41537
|
this.baseUrl = resolvedBaseUrl || "https://api.meshagent.com";
|
|
41519
41538
|
const envToken = typeof process !== "undefined" ? process.env?.MESHAGENT_API_KEY : void 0;
|
|
41520
41539
|
this.token = token ?? envToken ?? void 0;
|
|
@@ -41566,7 +41585,7 @@ ${newlined}
|
|
|
41566
41585
|
} catch {
|
|
41567
41586
|
message2 = "<unable to read body>";
|
|
41568
41587
|
}
|
|
41569
|
-
throw new
|
|
41588
|
+
throw new requirement_js_1.RoomException(`Failed to ${action}. Status code: ${response.status}, body: ${message2}`);
|
|
41570
41589
|
}
|
|
41571
41590
|
switch (responseType) {
|
|
41572
41591
|
case "json":
|
|
@@ -41585,15 +41604,15 @@ ${newlined}
|
|
|
41585
41604
|
}
|
|
41586
41605
|
parseRoomShare(data) {
|
|
41587
41606
|
if (!data || typeof data !== "object") {
|
|
41588
|
-
throw new
|
|
41607
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: expected object");
|
|
41589
41608
|
}
|
|
41590
41609
|
const { id, project_id: projectId, projectId: projectIdAlt, settings } = data;
|
|
41591
41610
|
if (typeof id !== "string") {
|
|
41592
|
-
throw new
|
|
41611
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: missing id");
|
|
41593
41612
|
}
|
|
41594
41613
|
const finalProjectId = typeof projectIdAlt === "string" ? projectIdAlt : typeof projectId === "string" ? projectId : void 0;
|
|
41595
41614
|
if (!finalProjectId) {
|
|
41596
|
-
throw new
|
|
41615
|
+
throw new requirement_js_1.RoomException("Invalid room share payload: missing project id");
|
|
41597
41616
|
}
|
|
41598
41617
|
return {
|
|
41599
41618
|
id,
|
|
@@ -41603,23 +41622,23 @@ ${newlined}
|
|
|
41603
41622
|
}
|
|
41604
41623
|
parseRoomSession(data) {
|
|
41605
41624
|
if (!data || typeof data !== "object") {
|
|
41606
|
-
throw new
|
|
41625
|
+
throw new requirement_js_1.RoomException("Invalid room session payload");
|
|
41607
41626
|
}
|
|
41608
41627
|
const { id, room_id: roomIdRaw, roomId, room_name: roomNameRaw, roomName, created_at: createdRaw, createdAt, is_active: isActiveRaw, isActive, participants } = data;
|
|
41609
41628
|
if (typeof id !== "string") {
|
|
41610
|
-
throw new
|
|
41629
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing id");
|
|
41611
41630
|
}
|
|
41612
41631
|
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
41613
41632
|
if (typeof roomNameValue !== "string") {
|
|
41614
|
-
throw new
|
|
41633
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing room name");
|
|
41615
41634
|
}
|
|
41616
41635
|
const created = typeof createdAt === "string" ? createdAt : createdRaw;
|
|
41617
41636
|
if (typeof created !== "string") {
|
|
41618
|
-
throw new
|
|
41637
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing created_at");
|
|
41619
41638
|
}
|
|
41620
41639
|
const isActiveValue = typeof isActive === "boolean" ? isActive : isActiveRaw;
|
|
41621
41640
|
if (typeof isActiveValue !== "boolean") {
|
|
41622
|
-
throw new
|
|
41641
|
+
throw new requirement_js_1.RoomException("Invalid room session payload: missing is_active");
|
|
41623
41642
|
}
|
|
41624
41643
|
return {
|
|
41625
41644
|
id,
|
|
@@ -41632,11 +41651,11 @@ ${newlined}
|
|
|
41632
41651
|
}
|
|
41633
41652
|
parseRoom(data) {
|
|
41634
41653
|
if (!data || typeof data !== "object") {
|
|
41635
|
-
throw new
|
|
41654
|
+
throw new requirement_js_1.RoomException("Invalid room payload");
|
|
41636
41655
|
}
|
|
41637
41656
|
const { id, name, metadata, annotations } = data;
|
|
41638
41657
|
if (typeof id !== "string" || typeof name !== "string") {
|
|
41639
|
-
throw new
|
|
41658
|
+
throw new requirement_js_1.RoomException("Invalid room payload: missing id or name");
|
|
41640
41659
|
}
|
|
41641
41660
|
return {
|
|
41642
41661
|
id,
|
|
@@ -41647,7 +41666,7 @@ ${newlined}
|
|
|
41647
41666
|
}
|
|
41648
41667
|
parseRoute(data) {
|
|
41649
41668
|
if (!data || typeof data !== "object") {
|
|
41650
|
-
throw new
|
|
41669
|
+
throw new requirement_js_1.RoomException("Invalid route payload: expected object");
|
|
41651
41670
|
}
|
|
41652
41671
|
if (data.spec && typeof data.spec === "object") {
|
|
41653
41672
|
return { domain: String(data.domain ?? data.spec.domain), spec: data.spec };
|
|
@@ -41665,11 +41684,11 @@ ${newlined}
|
|
|
41665
41684
|
}
|
|
41666
41685
|
};
|
|
41667
41686
|
}
|
|
41668
|
-
throw new
|
|
41687
|
+
throw new requirement_js_1.RoomException("Invalid route payload: missing spec");
|
|
41669
41688
|
}
|
|
41670
41689
|
parseFeed(data) {
|
|
41671
41690
|
if (!data || typeof data !== "object") {
|
|
41672
|
-
throw new
|
|
41691
|
+
throw new requirement_js_1.RoomException("Invalid feed payload");
|
|
41673
41692
|
}
|
|
41674
41693
|
const { id, project_id: projectIdRaw, projectId, created_at: createdAtRaw, createdAt, name, description, visibility, paused, annotations, message_schema: messageSchemaRaw, messageSchema } = data;
|
|
41675
41694
|
const projectIdValue = typeof projectId === "string" ? projectId : typeof projectIdRaw === "string" ? projectIdRaw : void 0;
|
|
@@ -41677,7 +41696,7 @@ ${newlined}
|
|
|
41677
41696
|
const visibilityValue = visibility === "public" || visibility === "project" || visibility === "private" ? visibility : void 0;
|
|
41678
41697
|
const messageSchemaValue = typeof messageSchema === "boolean" || messageSchema && typeof messageSchema === "object" ? messageSchema : typeof messageSchemaRaw === "boolean" || messageSchemaRaw && typeof messageSchemaRaw === "object" ? messageSchemaRaw : null;
|
|
41679
41698
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof createdAtValue !== "string" || typeof name !== "string" || visibilityValue === void 0) {
|
|
41680
|
-
throw new
|
|
41699
|
+
throw new requirement_js_1.RoomException("Invalid feed payload: missing required fields");
|
|
41681
41700
|
}
|
|
41682
41701
|
return {
|
|
41683
41702
|
id,
|
|
@@ -41693,7 +41712,7 @@ ${newlined}
|
|
|
41693
41712
|
}
|
|
41694
41713
|
parseFeedSubscription(data) {
|
|
41695
41714
|
if (!data || typeof data !== "object") {
|
|
41696
|
-
throw new
|
|
41715
|
+
throw new requirement_js_1.RoomException("Invalid feed subscription payload");
|
|
41697
41716
|
}
|
|
41698
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;
|
|
41699
41718
|
const feedIdValue = typeof feedId === "string" ? feedId : feedIdRaw;
|
|
@@ -41702,7 +41721,7 @@ ${newlined}
|
|
|
41702
41721
|
const roomIdValue = typeof roomId === "string" ? roomId : roomIdRaw;
|
|
41703
41722
|
const filenameDatetimeFormatValue = typeof filenameDatetimeFormat === "string" ? filenameDatetimeFormat : typeof filenameDatetimeFormatRaw === "string" ? filenameDatetimeFormatRaw : void 0;
|
|
41704
41723
|
if (typeof id !== "string" || typeof feedIdValue !== "string" || typeof projectIdValue !== "string" || typeof room !== "string" || typeof path !== "string" || typeof createdAtValue !== "string") {
|
|
41705
|
-
throw new
|
|
41724
|
+
throw new requirement_js_1.RoomException("Invalid feed subscription payload: missing required fields");
|
|
41706
41725
|
}
|
|
41707
41726
|
return {
|
|
41708
41727
|
id,
|
|
@@ -41718,7 +41737,7 @@ ${newlined}
|
|
|
41718
41737
|
}
|
|
41719
41738
|
parseLLMLogger(data) {
|
|
41720
41739
|
if (!data || typeof data !== "object") {
|
|
41721
|
-
throw new
|
|
41740
|
+
throw new requirement_js_1.RoomException("Invalid LLM logger payload");
|
|
41722
41741
|
}
|
|
41723
41742
|
const { id, project_id: projectIdRaw, projectId, destination_feed_id: destinationFeedIdRaw, destinationFeedId, filter_expression: filterExpressionRaw, filterExpression, paused, created_at: createdAtRaw, createdAt, annotations } = data;
|
|
41724
41743
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
@@ -41726,7 +41745,7 @@ ${newlined}
|
|
|
41726
41745
|
const filterExpressionValue = typeof filterExpression === "string" ? filterExpression : filterExpressionRaw;
|
|
41727
41746
|
const createdAtValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
41728
41747
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof destinationFeedIdValue !== "string" || typeof filterExpressionValue !== "string" || typeof createdAtValue !== "string") {
|
|
41729
|
-
throw new
|
|
41748
|
+
throw new requirement_js_1.RoomException("Invalid LLM logger payload: missing required fields");
|
|
41730
41749
|
}
|
|
41731
41750
|
return {
|
|
41732
41751
|
id,
|
|
@@ -41740,13 +41759,13 @@ ${newlined}
|
|
|
41740
41759
|
}
|
|
41741
41760
|
parseProjectRepository(data) {
|
|
41742
41761
|
if (!data || typeof data !== "object") {
|
|
41743
|
-
throw new
|
|
41762
|
+
throw new requirement_js_1.RoomException("Invalid repository payload");
|
|
41744
41763
|
}
|
|
41745
41764
|
const { id, project_id: projectIdRaw, projectId, name, description, annotations, created_at: createdAtRaw, createdAt } = data;
|
|
41746
41765
|
const projectIdValue = typeof projectId === "string" ? projectId : typeof projectIdRaw === "string" ? projectIdRaw : void 0;
|
|
41747
41766
|
const createdAtValue = typeof createdAt === "string" ? createdAt : typeof createdAtRaw === "string" ? createdAtRaw : void 0;
|
|
41748
41767
|
if (typeof id !== "string" || typeof projectIdValue !== "string" || typeof name !== "string" || typeof createdAtValue !== "string") {
|
|
41749
|
-
throw new
|
|
41768
|
+
throw new requirement_js_1.RoomException("Invalid repository payload: missing required fields");
|
|
41750
41769
|
}
|
|
41751
41770
|
return {
|
|
41752
41771
|
id,
|
|
@@ -41759,44 +41778,44 @@ ${newlined}
|
|
|
41759
41778
|
}
|
|
41760
41779
|
parseProjectRoomGrant(data) {
|
|
41761
41780
|
if (!data || typeof data !== "object") {
|
|
41762
|
-
throw new
|
|
41781
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload");
|
|
41763
41782
|
}
|
|
41764
41783
|
const roomData = data.room;
|
|
41765
41784
|
const room = this.parseRoom(roomData);
|
|
41766
41785
|
const userId = data.user_id ?? data.userId;
|
|
41767
41786
|
if (typeof userId !== "string") {
|
|
41768
|
-
throw new
|
|
41787
|
+
throw new requirement_js_1.RoomException("Invalid room grant payload: missing user_id");
|
|
41769
41788
|
}
|
|
41770
41789
|
const permissionsRaw = data.permissions;
|
|
41771
|
-
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();
|
|
41772
41791
|
return { room, userId, permissions };
|
|
41773
41792
|
}
|
|
41774
41793
|
parseProjectRoomGrantCount(data) {
|
|
41775
41794
|
const roomData = data && typeof data === "object" ? data.room ?? { id: data.room_id, name: data.room_name, metadata: data.metadata ?? {} } : void 0;
|
|
41776
41795
|
if (!roomData) {
|
|
41777
|
-
throw new
|
|
41796
|
+
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing room");
|
|
41778
41797
|
}
|
|
41779
41798
|
const room = this.parseRoom(roomData);
|
|
41780
41799
|
const count = data.count;
|
|
41781
41800
|
if (typeof count !== "number") {
|
|
41782
|
-
throw new
|
|
41801
|
+
throw new requirement_js_1.RoomException("Invalid room grant count payload: missing count");
|
|
41783
41802
|
}
|
|
41784
41803
|
return { room, count };
|
|
41785
41804
|
}
|
|
41786
41805
|
parseProjectUserGrantCount(data) {
|
|
41787
41806
|
if (!data || typeof data !== "object") {
|
|
41788
|
-
throw new
|
|
41807
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload");
|
|
41789
41808
|
}
|
|
41790
41809
|
const { user_id: userIdRaw, userId, count, first_name: firstNameRaw, firstName, last_name: lastNameRaw, lastName, email } = data;
|
|
41791
41810
|
const userIdValue = typeof userId === "string" ? userId : userIdRaw;
|
|
41792
41811
|
if (typeof userIdValue !== "string") {
|
|
41793
|
-
throw new
|
|
41812
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing user_id");
|
|
41794
41813
|
}
|
|
41795
41814
|
if (typeof count !== "number") {
|
|
41796
|
-
throw new
|
|
41815
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing count");
|
|
41797
41816
|
}
|
|
41798
41817
|
if (typeof email !== "string") {
|
|
41799
|
-
throw new
|
|
41818
|
+
throw new requirement_js_1.RoomException("Invalid room grant user count payload: missing email");
|
|
41800
41819
|
}
|
|
41801
41820
|
return {
|
|
41802
41821
|
userId: userIdValue,
|
|
@@ -41808,11 +41827,11 @@ ${newlined}
|
|
|
41808
41827
|
}
|
|
41809
41828
|
parseBalance(data) {
|
|
41810
41829
|
if (!data || typeof data !== "object") {
|
|
41811
|
-
throw new
|
|
41830
|
+
throw new requirement_js_1.RoomException("Invalid balance payload");
|
|
41812
41831
|
}
|
|
41813
41832
|
const balanceValue = data.balance;
|
|
41814
41833
|
if (typeof balanceValue !== "number") {
|
|
41815
|
-
throw new
|
|
41834
|
+
throw new requirement_js_1.RoomException("Invalid balance payload: missing balance");
|
|
41816
41835
|
}
|
|
41817
41836
|
const threshold = data.auto_recharge_threshold ?? data.autoRechargeThreshold;
|
|
41818
41837
|
const amount = data.auto_recharge_amount ?? data.autoRechargeAmount;
|
|
@@ -41832,15 +41851,15 @@ ${newlined}
|
|
|
41832
41851
|
}
|
|
41833
41852
|
parseTransaction(data) {
|
|
41834
41853
|
if (!data || typeof data !== "object") {
|
|
41835
|
-
throw new
|
|
41854
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload");
|
|
41836
41855
|
}
|
|
41837
41856
|
const { id, amount, reference, referenceType, reference_type: referenceTypeRaw, description, created_at: createdAtRaw, createdAt } = data;
|
|
41838
41857
|
if (typeof id !== "string" || typeof amount !== "number" || typeof description !== "string") {
|
|
41839
|
-
throw new
|
|
41858
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload: missing fields");
|
|
41840
41859
|
}
|
|
41841
41860
|
const createdValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
41842
41861
|
if (typeof createdValue !== "string") {
|
|
41843
|
-
throw new
|
|
41862
|
+
throw new requirement_js_1.RoomException("Invalid transaction payload: missing created_at");
|
|
41844
41863
|
}
|
|
41845
41864
|
const referenceTypeValue = typeof referenceType === "string" ? referenceType : referenceTypeRaw;
|
|
41846
41865
|
return {
|
|
@@ -41854,7 +41873,7 @@ ${newlined}
|
|
|
41854
41873
|
}
|
|
41855
41874
|
parseSecret(data) {
|
|
41856
41875
|
if (!data || typeof data !== "object") {
|
|
41857
|
-
throw new
|
|
41876
|
+
throw new requirement_js_1.RoomException("Invalid secret payload");
|
|
41858
41877
|
}
|
|
41859
41878
|
const type = data.type;
|
|
41860
41879
|
if (type === "docker") {
|
|
@@ -41862,7 +41881,7 @@ ${newlined}
|
|
|
41862
41881
|
const username = data.username;
|
|
41863
41882
|
const password = data.password;
|
|
41864
41883
|
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
41865
|
-
throw new
|
|
41884
|
+
throw new requirement_js_1.RoomException("Invalid docker secret payload");
|
|
41866
41885
|
}
|
|
41867
41886
|
return {
|
|
41868
41887
|
id: typeof data.id === "string" ? data.id : void 0,
|
|
@@ -41877,7 +41896,7 @@ ${newlined}
|
|
|
41877
41896
|
if (type === "keys") {
|
|
41878
41897
|
const record = data.data;
|
|
41879
41898
|
if (!record || typeof record !== "object") {
|
|
41880
|
-
throw new
|
|
41899
|
+
throw new requirement_js_1.RoomException("Invalid keys secret payload");
|
|
41881
41900
|
}
|
|
41882
41901
|
return {
|
|
41883
41902
|
id: typeof data.id === "string" ? data.id : void 0,
|
|
@@ -41886,15 +41905,15 @@ ${newlined}
|
|
|
41886
41905
|
data: record
|
|
41887
41906
|
};
|
|
41888
41907
|
}
|
|
41889
|
-
throw new
|
|
41908
|
+
throw new requirement_js_1.RoomException(`Unknown secret type: ${type}`);
|
|
41890
41909
|
}
|
|
41891
41910
|
parseManagedSecretInfo(data) {
|
|
41892
41911
|
if (!data || typeof data !== "object") {
|
|
41893
|
-
throw new
|
|
41912
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload");
|
|
41894
41913
|
}
|
|
41895
41914
|
const { id, type, name, delegated_to: delegatedToRaw, delegatedTo } = data;
|
|
41896
41915
|
if (typeof id !== "string" || typeof type !== "string" || typeof name !== "string") {
|
|
41897
|
-
throw new
|
|
41916
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing id, type, or name");
|
|
41898
41917
|
}
|
|
41899
41918
|
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : typeof delegatedToRaw === "string" ? delegatedToRaw : null;
|
|
41900
41919
|
return {
|
|
@@ -41908,7 +41927,7 @@ ${newlined}
|
|
|
41908
41927
|
const secret = this.parseManagedSecretInfo(data);
|
|
41909
41928
|
const dataBase64 = data.data_base64 ?? data.dataBase64;
|
|
41910
41929
|
if (typeof dataBase64 !== "string") {
|
|
41911
|
-
throw new
|
|
41930
|
+
throw new requirement_js_1.RoomException("Invalid managed secret payload: missing data_base64");
|
|
41912
41931
|
}
|
|
41913
41932
|
return {
|
|
41914
41933
|
...secret,
|
|
@@ -41919,17 +41938,17 @@ ${newlined}
|
|
|
41919
41938
|
parseSecretPayload(secret, rawData) {
|
|
41920
41939
|
let payload;
|
|
41921
41940
|
try {
|
|
41922
|
-
payload = JSON.parse(
|
|
41941
|
+
payload = JSON.parse(utils_js_1.decoder.decode(rawData));
|
|
41923
41942
|
} catch {
|
|
41924
|
-
throw new
|
|
41943
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41925
41944
|
}
|
|
41926
41945
|
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
41927
|
-
throw new
|
|
41946
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41928
41947
|
}
|
|
41929
41948
|
if (secret.type === "docker") {
|
|
41930
41949
|
const { server, username, password, email } = payload;
|
|
41931
41950
|
if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
|
|
41932
|
-
throw new
|
|
41951
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41933
41952
|
}
|
|
41934
41953
|
return {
|
|
41935
41954
|
id: secret.id,
|
|
@@ -41943,7 +41962,7 @@ ${newlined}
|
|
|
41943
41962
|
}
|
|
41944
41963
|
const entries = Object.entries(payload);
|
|
41945
41964
|
if (entries.some(([, value]) => typeof value !== "string")) {
|
|
41946
|
-
throw new
|
|
41965
|
+
throw new requirement_js_1.RoomException(`Invalid secret payload for ${secret.id}`);
|
|
41947
41966
|
}
|
|
41948
41967
|
return {
|
|
41949
41968
|
id: secret.id,
|
|
@@ -41976,7 +41995,7 @@ ${newlined}
|
|
|
41976
41995
|
return null;
|
|
41977
41996
|
}
|
|
41978
41997
|
if (typeof data !== "object") {
|
|
41979
|
-
throw new
|
|
41998
|
+
throw new requirement_js_1.RoomException("Invalid connector payload");
|
|
41980
41999
|
}
|
|
41981
42000
|
const { openai_connector_id: openaiConnectorIdRaw, openaiConnectorId, server_url: serverUrlRaw, serverUrl, client_secret_id: clientSecretIdRaw, clientSecretId } = data;
|
|
41982
42001
|
return {
|
|
@@ -42003,14 +42022,14 @@ ${newlined}
|
|
|
42003
42022
|
}
|
|
42004
42023
|
parseExternalOAuthClientRegistration(data) {
|
|
42005
42024
|
if (!data || typeof data !== "object") {
|
|
42006
|
-
throw new
|
|
42025
|
+
throw new requirement_js_1.RoomException("Invalid external oauth registration payload");
|
|
42007
42026
|
}
|
|
42008
42027
|
const { id, delegated_to: delegatedToRaw, delegatedTo, connector, oauth, client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret } = data;
|
|
42009
42028
|
const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : delegatedToRaw;
|
|
42010
42029
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
42011
42030
|
const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
|
|
42012
42031
|
if (typeof id !== "string" || typeof delegatedToValue !== "string" || typeof clientIdValue !== "string") {
|
|
42013
|
-
throw new
|
|
42032
|
+
throw new requirement_js_1.RoomException("Invalid external oauth registration payload: missing fields");
|
|
42014
42033
|
}
|
|
42015
42034
|
return {
|
|
42016
42035
|
id,
|
|
@@ -42023,7 +42042,7 @@ ${newlined}
|
|
|
42023
42042
|
}
|
|
42024
42043
|
parseOAuthClient(data) {
|
|
42025
42044
|
if (!data || typeof data !== "object") {
|
|
42026
|
-
throw new
|
|
42045
|
+
throw new requirement_js_1.RoomException("Invalid OAuth client payload");
|
|
42027
42046
|
}
|
|
42028
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;
|
|
42029
42048
|
const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
|
|
@@ -42033,7 +42052,7 @@ ${newlined}
|
|
|
42033
42052
|
const redirectUrisValue = Array.isArray(redirectUris) ? redirectUris : redirectUrisRaw;
|
|
42034
42053
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
42035
42054
|
if (typeof clientIdValue !== "string" || typeof clientSecretValue !== "string" || !Array.isArray(grantTypesValue) || !Array.isArray(responseTypesValue) || !Array.isArray(redirectUrisValue) || typeof scope !== "string" || typeof projectIdValue !== "string") {
|
|
42036
|
-
throw new
|
|
42055
|
+
throw new requirement_js_1.RoomException("Invalid OAuth client payload: missing required fields");
|
|
42037
42056
|
}
|
|
42038
42057
|
return {
|
|
42039
42058
|
clientId: clientIdValue,
|
|
@@ -42048,14 +42067,14 @@ ${newlined}
|
|
|
42048
42067
|
}
|
|
42049
42068
|
parseRoomConnectionInfo(data) {
|
|
42050
42069
|
if (!data || typeof data !== "object") {
|
|
42051
|
-
throw new
|
|
42070
|
+
throw new requirement_js_1.RoomException("Invalid room connection payload");
|
|
42052
42071
|
}
|
|
42053
42072
|
const { jwt, room_name: roomNameRaw, roomName, project_id: projectIdRaw, projectId, room_url: roomUrlRaw, roomUrl } = data;
|
|
42054
42073
|
const roomNameValue = typeof roomName === "string" ? roomName : roomNameRaw;
|
|
42055
42074
|
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
42056
42075
|
const roomUrlValue = typeof roomUrl === "string" ? roomUrl : roomUrlRaw;
|
|
42057
42076
|
if (typeof jwt !== "string" || typeof roomNameValue !== "string" || typeof projectIdValue !== "string" || typeof roomUrlValue !== "string") {
|
|
42058
|
-
throw new
|
|
42077
|
+
throw new requirement_js_1.RoomException("Invalid room connection payload: missing fields");
|
|
42059
42078
|
}
|
|
42060
42079
|
return { jwt, roomName: roomNameValue, projectId: projectIdValue, roomUrl: roomUrlValue };
|
|
42061
42080
|
}
|
|
@@ -42090,7 +42109,7 @@ ${newlined}
|
|
|
42090
42109
|
});
|
|
42091
42110
|
const role = payload?.role;
|
|
42092
42111
|
if (role !== "member" && role !== "admin" && role !== "developer") {
|
|
42093
|
-
throw new
|
|
42112
|
+
throw new requirement_js_1.RoomException("Invalid role payload");
|
|
42094
42113
|
}
|
|
42095
42114
|
return role;
|
|
42096
42115
|
}
|
|
@@ -42227,7 +42246,7 @@ ${newlined}
|
|
|
42227
42246
|
});
|
|
42228
42247
|
const enabled = data?.["enabled"];
|
|
42229
42248
|
if (typeof enabled !== "boolean") {
|
|
42230
|
-
throw new
|
|
42249
|
+
throw new requirement_js_1.RoomException("Invalid status payload: expected boolean 'enabled'");
|
|
42231
42250
|
}
|
|
42232
42251
|
return enabled;
|
|
42233
42252
|
}
|
|
@@ -42260,7 +42279,7 @@ ${newlined}
|
|
|
42260
42279
|
});
|
|
42261
42280
|
const url = data?.["checkout_url"];
|
|
42262
42281
|
if (typeof url !== "string") {
|
|
42263
|
-
throw new
|
|
42282
|
+
throw new requirement_js_1.RoomException("Invalid subscription payload: expected 'checkout_url' string");
|
|
42264
42283
|
}
|
|
42265
42284
|
return url;
|
|
42266
42285
|
}
|
|
@@ -42272,7 +42291,7 @@ ${newlined}
|
|
|
42272
42291
|
});
|
|
42273
42292
|
const url = data?.["checkout_url"];
|
|
42274
42293
|
if (typeof url !== "string") {
|
|
42275
|
-
throw new
|
|
42294
|
+
throw new requirement_js_1.RoomException("Invalid credits payload: expected 'checkout_url' string");
|
|
42276
42295
|
}
|
|
42277
42296
|
return url;
|
|
42278
42297
|
}
|
|
@@ -42301,7 +42320,7 @@ ${newlined}
|
|
|
42301
42320
|
});
|
|
42302
42321
|
const usage = data?.["usage"];
|
|
42303
42322
|
if (!Array.isArray(usage)) {
|
|
42304
|
-
throw new
|
|
42323
|
+
throw new requirement_js_1.RoomException("Invalid usage payload: expected 'usage' to be a list");
|
|
42305
42324
|
}
|
|
42306
42325
|
return usage.filter((item) => item && typeof item === "object");
|
|
42307
42326
|
}
|
|
@@ -42400,14 +42419,14 @@ ${newlined}
|
|
|
42400
42419
|
}
|
|
42401
42420
|
parseMailbox(item) {
|
|
42402
42421
|
if (!item || typeof item !== "object") {
|
|
42403
|
-
throw new
|
|
42422
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload");
|
|
42404
42423
|
}
|
|
42405
42424
|
const { address, room, room_id, queue } = item;
|
|
42406
42425
|
if (typeof address !== "string" || typeof room !== "string" || typeof queue !== "string") {
|
|
42407
|
-
throw new
|
|
42426
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload: missing fields");
|
|
42408
42427
|
}
|
|
42409
42428
|
if (room_id !== void 0 && typeof room_id !== "string") {
|
|
42410
|
-
throw new
|
|
42429
|
+
throw new requirement_js_1.RoomException("Invalid mailbox payload: invalid room_id");
|
|
42411
42430
|
}
|
|
42412
42431
|
return { address, room, roomId: room_id, queue };
|
|
42413
42432
|
}
|
|
@@ -42661,7 +42680,7 @@ ${newlined}
|
|
|
42661
42680
|
action: "create service"
|
|
42662
42681
|
});
|
|
42663
42682
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
42664
|
-
throw new
|
|
42683
|
+
throw new requirement_js_1.RoomException("Invalid create service response payload");
|
|
42665
42684
|
}
|
|
42666
42685
|
return data.id;
|
|
42667
42686
|
}
|
|
@@ -42672,7 +42691,7 @@ ${newlined}
|
|
|
42672
42691
|
action: "create room service"
|
|
42673
42692
|
});
|
|
42674
42693
|
if (!data || typeof data !== "object" || typeof data.id !== "string") {
|
|
42675
|
-
throw new
|
|
42694
|
+
throw new requirement_js_1.RoomException("Invalid create room service response payload");
|
|
42676
42695
|
}
|
|
42677
42696
|
return data.id;
|
|
42678
42697
|
}
|
|
@@ -42706,7 +42725,7 @@ ${newlined}
|
|
|
42706
42725
|
}
|
|
42707
42726
|
async updateService(projectId, serviceId, service) {
|
|
42708
42727
|
if (!service.id) {
|
|
42709
|
-
throw new
|
|
42728
|
+
throw new requirement_js_1.RoomException("Service id must be set to update a service");
|
|
42710
42729
|
}
|
|
42711
42730
|
await this.request(`/accounts/projects/${projectId}/services/${serviceId}`, {
|
|
42712
42731
|
method: "PUT",
|
|
@@ -42747,7 +42766,7 @@ ${newlined}
|
|
|
42747
42766
|
action: "create project secret"
|
|
42748
42767
|
});
|
|
42749
42768
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42750
|
-
throw new
|
|
42769
|
+
throw new requirement_js_1.RoomException("Invalid create project secret response payload");
|
|
42751
42770
|
}
|
|
42752
42771
|
return payload.id;
|
|
42753
42772
|
}
|
|
@@ -42799,7 +42818,7 @@ ${newlined}
|
|
|
42799
42818
|
action: "create room secret"
|
|
42800
42819
|
});
|
|
42801
42820
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42802
|
-
throw new
|
|
42821
|
+
throw new requirement_js_1.RoomException("Invalid create room secret response payload");
|
|
42803
42822
|
}
|
|
42804
42823
|
return payload.id;
|
|
42805
42824
|
}
|
|
@@ -42857,19 +42876,19 @@ ${newlined}
|
|
|
42857
42876
|
projectId,
|
|
42858
42877
|
name: secret.name,
|
|
42859
42878
|
type: secret.type,
|
|
42860
|
-
data:
|
|
42879
|
+
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data))
|
|
42861
42880
|
});
|
|
42862
42881
|
}
|
|
42863
42882
|
async updateSecret(projectId, secret) {
|
|
42864
42883
|
if (!secret.id) {
|
|
42865
|
-
throw new
|
|
42884
|
+
throw new requirement_js_1.RoomException("Secret id is required to update a secret");
|
|
42866
42885
|
}
|
|
42867
42886
|
await this.updateProjectSecret({
|
|
42868
42887
|
projectId,
|
|
42869
42888
|
secretId: secret.id,
|
|
42870
42889
|
name: secret.name,
|
|
42871
42890
|
type: secret.type,
|
|
42872
|
-
data:
|
|
42891
|
+
data: utils_js_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data))
|
|
42873
42892
|
});
|
|
42874
42893
|
}
|
|
42875
42894
|
async deleteSecret(projectId, secretId) {
|
|
@@ -42897,7 +42916,7 @@ ${newlined}
|
|
|
42897
42916
|
action: "create project external oauth registration"
|
|
42898
42917
|
});
|
|
42899
42918
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42900
|
-
throw new
|
|
42919
|
+
throw new requirement_js_1.RoomException("Invalid create project external oauth registration response payload");
|
|
42901
42920
|
}
|
|
42902
42921
|
return payload.id;
|
|
42903
42922
|
}
|
|
@@ -42952,7 +42971,7 @@ ${newlined}
|
|
|
42952
42971
|
action: "create room external oauth registration"
|
|
42953
42972
|
});
|
|
42954
42973
|
if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
|
|
42955
|
-
throw new
|
|
42974
|
+
throw new requirement_js_1.RoomException("Invalid create room external oauth registration response payload");
|
|
42956
42975
|
}
|
|
42957
42976
|
return payload.id;
|
|
42958
42977
|
}
|
|
@@ -43004,7 +43023,7 @@ ${newlined}
|
|
|
43004
43023
|
if (permissions) {
|
|
43005
43024
|
const serialized = {};
|
|
43006
43025
|
for (const [key, value] of Object.entries(permissions)) {
|
|
43007
|
-
serialized[key] = value instanceof
|
|
43026
|
+
serialized[key] = value instanceof participant_token_js_1.ApiScope ? value.toJSON() : value;
|
|
43008
43027
|
}
|
|
43009
43028
|
payload["permissions"] = serialized;
|
|
43010
43029
|
}
|
|
@@ -43304,13 +43323,13 @@ ${newlined}
|
|
|
43304
43323
|
"use strict";
|
|
43305
43324
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43306
43325
|
exports.MessagingClient = void 0;
|
|
43307
|
-
var
|
|
43308
|
-
var
|
|
43309
|
-
var
|
|
43310
|
-
var
|
|
43311
|
-
var
|
|
43312
|
-
var
|
|
43313
|
-
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();
|
|
43314
43333
|
var globalScope = globalThis;
|
|
43315
43334
|
function bytesToBase64(bytes) {
|
|
43316
43335
|
if (globalScope.Buffer != null) {
|
|
@@ -43325,7 +43344,7 @@ ${newlined}
|
|
|
43325
43344
|
}
|
|
43326
43345
|
return globalScope.btoa(binary);
|
|
43327
43346
|
}
|
|
43328
|
-
var MessagingClient = class extends
|
|
43347
|
+
var MessagingClient = class extends event_emitter_js_1.EventEmitter {
|
|
43329
43348
|
constructor({ room }) {
|
|
43330
43349
|
super();
|
|
43331
43350
|
this._messageHandler = this._handleMessageSend.bind(this);
|
|
@@ -43366,14 +43385,14 @@ ${newlined}
|
|
|
43366
43385
|
await this.client.invoke({
|
|
43367
43386
|
toolkit: "messaging",
|
|
43368
43387
|
tool: operation,
|
|
43369
|
-
input: new
|
|
43388
|
+
input: new response_js_1.JsonContent({ json: input })
|
|
43370
43389
|
});
|
|
43371
43390
|
}
|
|
43372
43391
|
_invokeNowait({ operation, input }) {
|
|
43373
43392
|
this.client.invokeNowait({
|
|
43374
43393
|
toolkit: "messaging",
|
|
43375
43394
|
tool: operation,
|
|
43376
|
-
input: new
|
|
43395
|
+
input: new response_js_1.JsonContent({ json: input })
|
|
43377
43396
|
});
|
|
43378
43397
|
}
|
|
43379
43398
|
start() {
|
|
@@ -43407,7 +43426,7 @@ ${newlined}
|
|
|
43407
43426
|
if (this._messageQueueClosed) {
|
|
43408
43427
|
return null;
|
|
43409
43428
|
}
|
|
43410
|
-
this._messageQueued ?? (this._messageQueued = new
|
|
43429
|
+
this._messageQueued ?? (this._messageQueued = new completer_js_1.Completer());
|
|
43411
43430
|
await this._messageQueued.fut;
|
|
43412
43431
|
}
|
|
43413
43432
|
}
|
|
@@ -43420,7 +43439,7 @@ ${newlined}
|
|
|
43420
43439
|
}
|
|
43421
43440
|
_queueMessage(message2) {
|
|
43422
43441
|
if (this._messageQueueClosed) {
|
|
43423
|
-
throw new
|
|
43442
|
+
throw new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has been stopped");
|
|
43424
43443
|
}
|
|
43425
43444
|
this._messageQueue.push(message2);
|
|
43426
43445
|
this._wakeMessageQueue();
|
|
@@ -43476,7 +43495,7 @@ ${newlined}
|
|
|
43476
43495
|
return participant;
|
|
43477
43496
|
}
|
|
43478
43497
|
_markParticipantOffline(participant) {
|
|
43479
|
-
if (!(participant instanceof
|
|
43498
|
+
if (!(participant instanceof participant_js_1.RemoteParticipant)) {
|
|
43480
43499
|
return;
|
|
43481
43500
|
}
|
|
43482
43501
|
participant._setOnline(false);
|
|
@@ -43488,7 +43507,7 @@ ${newlined}
|
|
|
43488
43507
|
if (to == null) {
|
|
43489
43508
|
return null;
|
|
43490
43509
|
}
|
|
43491
|
-
if (!(to instanceof
|
|
43510
|
+
if (!(to instanceof participant_js_1.RemoteParticipant)) {
|
|
43492
43511
|
return to;
|
|
43493
43512
|
}
|
|
43494
43513
|
if (to.online === false) {
|
|
@@ -43521,11 +43540,11 @@ ${newlined}
|
|
|
43521
43540
|
await this._waitUntilOnline();
|
|
43522
43541
|
}
|
|
43523
43542
|
} catch (error) {
|
|
43524
|
-
if (error instanceof
|
|
43543
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
43525
43544
|
this._dropQueuedMessage({ message: message2, error });
|
|
43526
43545
|
this._drainQueuedMessages({ error });
|
|
43527
43546
|
} else {
|
|
43528
|
-
const wrapped = new
|
|
43547
|
+
const wrapped = new room_server_client_js_1.RoomServerException(String(error));
|
|
43529
43548
|
this._dropQueuedMessage({ message: message2, error: wrapped });
|
|
43530
43549
|
this._drainQueuedMessages({ error: wrapped });
|
|
43531
43550
|
}
|
|
@@ -43535,7 +43554,7 @@ ${newlined}
|
|
|
43535
43554
|
if (resolvedTo == null) {
|
|
43536
43555
|
this._dropQueuedMessage({
|
|
43537
43556
|
message: message2,
|
|
43538
|
-
error: new
|
|
43557
|
+
error: new room_server_client_js_1.RoomServerException("the participant was not found")
|
|
43539
43558
|
});
|
|
43540
43559
|
continue;
|
|
43541
43560
|
}
|
|
@@ -43553,7 +43572,7 @@ ${newlined}
|
|
|
43553
43572
|
message2.completer.complete();
|
|
43554
43573
|
}
|
|
43555
43574
|
} catch (error) {
|
|
43556
|
-
if (error instanceof
|
|
43575
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
43557
43576
|
const wrapped = this.client._coerceMessageSendError(error);
|
|
43558
43577
|
if (wrapped.message === "the participant was not found") {
|
|
43559
43578
|
this._markParticipantOffline(message2.to);
|
|
@@ -43571,7 +43590,7 @@ ${newlined}
|
|
|
43571
43590
|
}
|
|
43572
43591
|
async sendMessage({ to, type, message: message2, attachment, ignoreOffline = false }) {
|
|
43573
43592
|
if (this._sendTask == null) {
|
|
43574
|
-
throw new
|
|
43593
|
+
throw new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has not been started");
|
|
43575
43594
|
}
|
|
43576
43595
|
const queued = {
|
|
43577
43596
|
to,
|
|
@@ -43579,7 +43598,7 @@ ${newlined}
|
|
|
43579
43598
|
message: message2,
|
|
43580
43599
|
attachment,
|
|
43581
43600
|
dropIfOffline: ignoreOffline,
|
|
43582
|
-
completer: ignoreOffline ? void 0 : new
|
|
43601
|
+
completer: ignoreOffline ? void 0 : new completer_js_1.Completer()
|
|
43583
43602
|
};
|
|
43584
43603
|
this._queueMessage(queued);
|
|
43585
43604
|
if (queued.completer != null) {
|
|
@@ -43611,7 +43630,7 @@ ${newlined}
|
|
|
43611
43630
|
}
|
|
43612
43631
|
async broadcastMessage({ type, message: message2, attachment }) {
|
|
43613
43632
|
if (this._sendTask == null) {
|
|
43614
|
-
throw new
|
|
43633
|
+
throw new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has not been started");
|
|
43615
43634
|
}
|
|
43616
43635
|
await this.client._waitUntilConnectedForMessages();
|
|
43617
43636
|
if (this._desiredEnabled) {
|
|
@@ -43623,7 +43642,7 @@ ${newlined}
|
|
|
43623
43642
|
input: this._messageInput({ type, message: message2, attachment })
|
|
43624
43643
|
});
|
|
43625
43644
|
} catch (error) {
|
|
43626
|
-
if (error instanceof
|
|
43645
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
43627
43646
|
throw this.client._coerceMessageSendError(error);
|
|
43628
43647
|
}
|
|
43629
43648
|
throw error;
|
|
@@ -43647,10 +43666,10 @@ ${newlined}
|
|
|
43647
43666
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
43648
43667
|
return;
|
|
43649
43668
|
}
|
|
43650
|
-
const headerStr = (0,
|
|
43651
|
-
const payload = (0,
|
|
43669
|
+
const headerStr = (0, utils_js_1.splitMessageHeader)(bytes);
|
|
43670
|
+
const payload = (0, utils_js_1.splitMessagePayload)(bytes);
|
|
43652
43671
|
const header = JSON.parse(headerStr);
|
|
43653
|
-
const message2 = new
|
|
43672
|
+
const message2 = new room_event_js_1.RoomMessage({
|
|
43654
43673
|
fromParticipantId: header["from_participant_id"],
|
|
43655
43674
|
type: header["type"],
|
|
43656
43675
|
message: header["message"],
|
|
@@ -43672,16 +43691,16 @@ ${newlined}
|
|
|
43672
43691
|
default:
|
|
43673
43692
|
break;
|
|
43674
43693
|
}
|
|
43675
|
-
const event = new
|
|
43694
|
+
const event = new room_event_js_1.RoomMessageEvent({ message: message2 });
|
|
43676
43695
|
this.client.emit(event);
|
|
43677
43696
|
this.emit("message", event);
|
|
43678
43697
|
}
|
|
43679
43698
|
_onParticipantEnabled(message2) {
|
|
43680
43699
|
const data = message2.message;
|
|
43681
|
-
const participant = new
|
|
43700
|
+
const participant = new participant_js_1.RemoteParticipant(this.client, data.id, data.role, true);
|
|
43682
43701
|
participant._setAttributes(data.attributes ?? {});
|
|
43683
43702
|
this._participants[data.id] = participant;
|
|
43684
|
-
this.emit("participant_added", new
|
|
43703
|
+
this.emit("participant_added", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43685
43704
|
}
|
|
43686
43705
|
_onParticipantAttributes(message2) {
|
|
43687
43706
|
const participant = this._participants[message2.fromParticipantId];
|
|
@@ -43689,12 +43708,12 @@ ${newlined}
|
|
|
43689
43708
|
return;
|
|
43690
43709
|
}
|
|
43691
43710
|
participant._setAttributes(message2.message["attributes"]);
|
|
43692
|
-
this.emit("participant_attributes_updated", new
|
|
43711
|
+
this.emit("participant_attributes_updated", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43693
43712
|
}
|
|
43694
43713
|
_onParticipantDisabled(message2) {
|
|
43695
43714
|
const removed = this._removeParticipant(String(message2.message["id"]));
|
|
43696
43715
|
if (removed != null) {
|
|
43697
|
-
this.emit("participant_removed", new
|
|
43716
|
+
this.emit("participant_removed", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43698
43717
|
}
|
|
43699
43718
|
}
|
|
43700
43719
|
_onMessagingEnabled(message2) {
|
|
@@ -43704,7 +43723,7 @@ ${newlined}
|
|
|
43704
43723
|
}
|
|
43705
43724
|
const participants = message2.message["participants"];
|
|
43706
43725
|
for (const data of participants) {
|
|
43707
|
-
const participant = new
|
|
43726
|
+
const participant = new participant_js_1.RemoteParticipant(this.client, data.id, data.role, true);
|
|
43708
43727
|
participant._setAttributes(data.attributes ?? {});
|
|
43709
43728
|
this._participants[data.id] = participant;
|
|
43710
43729
|
}
|
|
@@ -43714,10 +43733,10 @@ ${newlined}
|
|
|
43714
43733
|
this._clearCurrentConnectionState();
|
|
43715
43734
|
return;
|
|
43716
43735
|
}
|
|
43717
|
-
this.emit("messaging_enabled", new
|
|
43736
|
+
this.emit("messaging_enabled", new room_event_js_1.RoomMessageEvent({ message: message2 }));
|
|
43718
43737
|
}
|
|
43719
43738
|
dispose() {
|
|
43720
|
-
const error = new
|
|
43739
|
+
const error = new room_server_client_js_1.RoomServerException("messaging client disposed");
|
|
43721
43740
|
this._messageQueueClosed = true;
|
|
43722
43741
|
this._wakeMessageQueue();
|
|
43723
43742
|
this._drainQueuedMessages({ error });
|
|
@@ -43737,8 +43756,8 @@ ${newlined}
|
|
|
43737
43756
|
"use strict";
|
|
43738
43757
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43739
43758
|
exports.MemoryClient = void 0;
|
|
43740
|
-
var
|
|
43741
|
-
var
|
|
43759
|
+
var response_js_1 = require_response();
|
|
43760
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
43742
43761
|
var globalScope = globalThis;
|
|
43743
43762
|
function bytesToBase64(bytes) {
|
|
43744
43763
|
if (globalScope.Buffer) {
|
|
@@ -43771,7 +43790,7 @@ ${newlined}
|
|
|
43771
43790
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
43772
43791
|
}
|
|
43773
43792
|
function unexpectedResponse(operation) {
|
|
43774
|
-
return new
|
|
43793
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from memory.${operation}`);
|
|
43775
43794
|
}
|
|
43776
43795
|
function requireString(value, operation) {
|
|
43777
43796
|
if (typeof value !== "string") {
|
|
@@ -44067,16 +44086,16 @@ ${newlined}
|
|
|
44067
44086
|
tool: operation,
|
|
44068
44087
|
input
|
|
44069
44088
|
});
|
|
44070
|
-
if (response instanceof
|
|
44089
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
44071
44090
|
return response;
|
|
44072
44091
|
}
|
|
44073
|
-
if (response instanceof
|
|
44092
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44074
44093
|
return null;
|
|
44075
44094
|
}
|
|
44076
44095
|
throw this.unexpectedResponse(operation);
|
|
44077
44096
|
}
|
|
44078
44097
|
expectJsonResponse(response, operation) {
|
|
44079
|
-
if (!(response instanceof
|
|
44098
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44080
44099
|
throw this.unexpectedResponse(operation);
|
|
44081
44100
|
}
|
|
44082
44101
|
return response;
|
|
@@ -44292,8 +44311,8 @@ ${newlined}
|
|
|
44292
44311
|
"use strict";
|
|
44293
44312
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44294
44313
|
exports.QueuesClient = exports.Queue = void 0;
|
|
44295
|
-
var
|
|
44296
|
-
var
|
|
44314
|
+
var response_js_1 = require_response();
|
|
44315
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44297
44316
|
var Queue = class {
|
|
44298
44317
|
constructor({ name, size }) {
|
|
44299
44318
|
this.name = name;
|
|
@@ -44306,7 +44325,7 @@ ${newlined}
|
|
|
44306
44325
|
this.client = room;
|
|
44307
44326
|
}
|
|
44308
44327
|
_unexpectedResponseError(operation) {
|
|
44309
|
-
return new
|
|
44328
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from queues.${operation}`);
|
|
44310
44329
|
}
|
|
44311
44330
|
async _invoke(operation, arguments_) {
|
|
44312
44331
|
return await this.client.invoke({
|
|
@@ -44317,7 +44336,7 @@ ${newlined}
|
|
|
44317
44336
|
}
|
|
44318
44337
|
async list() {
|
|
44319
44338
|
const response = await this._invoke("list", {});
|
|
44320
|
-
if (!(response instanceof
|
|
44339
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44321
44340
|
throw this._unexpectedResponseError("list");
|
|
44322
44341
|
}
|
|
44323
44342
|
const queues = response.json["queues"];
|
|
@@ -44325,25 +44344,25 @@ ${newlined}
|
|
|
44325
44344
|
}
|
|
44326
44345
|
async open(name) {
|
|
44327
44346
|
const response = await this._invoke("open", { name });
|
|
44328
|
-
if (!(response instanceof
|
|
44347
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44329
44348
|
throw this._unexpectedResponseError("open");
|
|
44330
44349
|
}
|
|
44331
44350
|
}
|
|
44332
44351
|
async drain(name) {
|
|
44333
44352
|
const response = await this._invoke("drain", { name });
|
|
44334
|
-
if (!(response instanceof
|
|
44353
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44335
44354
|
throw this._unexpectedResponseError("drain");
|
|
44336
44355
|
}
|
|
44337
44356
|
}
|
|
44338
44357
|
async close(name) {
|
|
44339
44358
|
const response = await this._invoke("close", { name });
|
|
44340
|
-
if (!(response instanceof
|
|
44359
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44341
44360
|
throw this._unexpectedResponseError("close");
|
|
44342
44361
|
}
|
|
44343
44362
|
}
|
|
44344
44363
|
async send(name, message2, { create = true }) {
|
|
44345
44364
|
const response = await this._invoke("send", { name, create, message: message2 });
|
|
44346
|
-
if (!(response instanceof
|
|
44365
|
+
if (!(response instanceof response_js_1.EmptyContent)) {
|
|
44347
44366
|
throw this._unexpectedResponseError("send");
|
|
44348
44367
|
}
|
|
44349
44368
|
}
|
|
@@ -44353,10 +44372,10 @@ ${newlined}
|
|
|
44353
44372
|
create,
|
|
44354
44373
|
wait
|
|
44355
44374
|
});
|
|
44356
|
-
if (response instanceof
|
|
44375
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44357
44376
|
return null;
|
|
44358
44377
|
}
|
|
44359
|
-
if (response instanceof
|
|
44378
|
+
if (response instanceof response_js_1.JsonContent) {
|
|
44360
44379
|
return response.json;
|
|
44361
44380
|
}
|
|
44362
44381
|
throw this._unexpectedResponseError("receive");
|
|
@@ -44372,9 +44391,9 @@ ${newlined}
|
|
|
44372
44391
|
"use strict";
|
|
44373
44392
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44374
44393
|
exports.SecretsClient = void 0;
|
|
44375
|
-
var
|
|
44376
|
-
var
|
|
44377
|
-
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();
|
|
44378
44397
|
function isRecord(value) {
|
|
44379
44398
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44380
44399
|
}
|
|
@@ -44389,7 +44408,7 @@ ${newlined}
|
|
|
44389
44408
|
this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
|
|
44390
44409
|
}
|
|
44391
44410
|
unexpectedResponse(operation) {
|
|
44392
|
-
return new
|
|
44411
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from secrets.${operation}`);
|
|
44393
44412
|
}
|
|
44394
44413
|
async invoke(operation, input) {
|
|
44395
44414
|
return await this.client.invoke({
|
|
@@ -44422,7 +44441,7 @@ ${newlined}
|
|
|
44422
44441
|
};
|
|
44423
44442
|
}
|
|
44424
44443
|
parseAccessToken(operation, response) {
|
|
44425
|
-
if (!(response instanceof
|
|
44444
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44426
44445
|
throw this.unexpectedResponse(operation);
|
|
44427
44446
|
}
|
|
44428
44447
|
const token = response.json["access_token"];
|
|
@@ -44453,25 +44472,25 @@ ${newlined}
|
|
|
44453
44472
|
void messageId;
|
|
44454
44473
|
void type;
|
|
44455
44474
|
if (bytes == null) {
|
|
44456
|
-
throw new
|
|
44475
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44457
44476
|
}
|
|
44458
44477
|
if (this.oauthTokenRequestHandler == null) {
|
|
44459
|
-
throw new
|
|
44478
|
+
throw new room_server_client_js_1.RoomServerException("No oauth token handler registered");
|
|
44460
44479
|
}
|
|
44461
|
-
const [request] = (0,
|
|
44480
|
+
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
44462
44481
|
const requestId = request["request_id"];
|
|
44463
44482
|
const challenge = request["challenge"];
|
|
44464
44483
|
const requestPayload = request["request"];
|
|
44465
44484
|
if (typeof requestId !== "string" || !isRecord(requestPayload)) {
|
|
44466
|
-
throw new
|
|
44485
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44467
44486
|
}
|
|
44468
44487
|
const oauth = requestPayload["oauth"];
|
|
44469
44488
|
if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
|
|
44470
|
-
throw new
|
|
44489
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44471
44490
|
}
|
|
44472
44491
|
const scopes = oauth["scopes"];
|
|
44473
44492
|
if (scopes !== void 0 && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
|
|
44474
|
-
throw new
|
|
44493
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
|
|
44475
44494
|
}
|
|
44476
44495
|
Promise.resolve(this.oauthTokenRequestHandler({
|
|
44477
44496
|
requestId,
|
|
@@ -44491,16 +44510,16 @@ ${newlined}
|
|
|
44491
44510
|
void messageId;
|
|
44492
44511
|
void type;
|
|
44493
44512
|
if (bytes == null) {
|
|
44494
|
-
throw new
|
|
44513
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
44495
44514
|
}
|
|
44496
44515
|
if (this.secretRequestHandler == null) {
|
|
44497
|
-
throw new
|
|
44516
|
+
throw new room_server_client_js_1.RoomServerException("No secret handler registered");
|
|
44498
44517
|
}
|
|
44499
|
-
const [request] = (0,
|
|
44518
|
+
const [request] = (0, utils_js_1.unpackMessage)(bytes);
|
|
44500
44519
|
const requestId = request["request_id"];
|
|
44501
44520
|
const requestPayload = request["request"];
|
|
44502
44521
|
if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
|
|
44503
|
-
throw new
|
|
44522
|
+
throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
|
|
44504
44523
|
}
|
|
44505
44524
|
Promise.resolve(this.secretRequestHandler({
|
|
44506
44525
|
requestId,
|
|
@@ -44517,7 +44536,7 @@ ${newlined}
|
|
|
44517
44536
|
code,
|
|
44518
44537
|
error: null
|
|
44519
44538
|
});
|
|
44520
|
-
if (response instanceof
|
|
44539
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44521
44540
|
return;
|
|
44522
44541
|
}
|
|
44523
44542
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
@@ -44528,33 +44547,33 @@ ${newlined}
|
|
|
44528
44547
|
code: null,
|
|
44529
44548
|
error
|
|
44530
44549
|
});
|
|
44531
|
-
if (response instanceof
|
|
44550
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44532
44551
|
return;
|
|
44533
44552
|
}
|
|
44534
44553
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
44535
44554
|
}
|
|
44536
44555
|
async provideSecret({ requestId, data }) {
|
|
44537
|
-
const response = await this.invoke("provide_secret", new
|
|
44556
|
+
const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
|
|
44538
44557
|
data,
|
|
44539
44558
|
headers: {
|
|
44540
44559
|
request_id: requestId,
|
|
44541
44560
|
error: null
|
|
44542
44561
|
}
|
|
44543
44562
|
}));
|
|
44544
|
-
if (response instanceof
|
|
44563
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44545
44564
|
return;
|
|
44546
44565
|
}
|
|
44547
44566
|
throw this.unexpectedResponse("provide_secret");
|
|
44548
44567
|
}
|
|
44549
44568
|
async rejectSecret({ requestId, error }) {
|
|
44550
|
-
const response = await this.invoke("provide_secret", new
|
|
44569
|
+
const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
|
|
44551
44570
|
data: new Uint8Array(0),
|
|
44552
44571
|
headers: {
|
|
44553
44572
|
request_id: requestId,
|
|
44554
44573
|
error
|
|
44555
44574
|
}
|
|
44556
44575
|
}));
|
|
44557
|
-
if (response instanceof
|
|
44576
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44558
44577
|
return;
|
|
44559
44578
|
}
|
|
44560
44579
|
throw this.unexpectedResponse("provide_secret");
|
|
@@ -44581,7 +44600,7 @@ ${newlined}
|
|
|
44581
44600
|
}
|
|
44582
44601
|
async listSecrets() {
|
|
44583
44602
|
const response = await this.invoke("list_secrets", {});
|
|
44584
|
-
if (!(response instanceof
|
|
44603
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44585
44604
|
throw this.unexpectedResponse("list_secrets");
|
|
44586
44605
|
}
|
|
44587
44606
|
const secrets = response.json["secrets"];
|
|
@@ -44596,7 +44615,7 @@ ${newlined}
|
|
|
44596
44615
|
delegated_to: delegatedTo ?? null,
|
|
44597
44616
|
for_identity: forIdentity ?? null
|
|
44598
44617
|
});
|
|
44599
|
-
if (!(response instanceof
|
|
44618
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
44600
44619
|
throw this.unexpectedResponse("exists");
|
|
44601
44620
|
}
|
|
44602
44621
|
return response.json["exists"];
|
|
@@ -44606,7 +44625,7 @@ ${newlined}
|
|
|
44606
44625
|
id: secretId,
|
|
44607
44626
|
delegated_to: delegatedTo ?? null
|
|
44608
44627
|
});
|
|
44609
|
-
if (response instanceof
|
|
44628
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44610
44629
|
return;
|
|
44611
44630
|
}
|
|
44612
44631
|
throw this.unexpectedResponse("delete_secret");
|
|
@@ -44617,7 +44636,7 @@ ${newlined}
|
|
|
44617
44636
|
type,
|
|
44618
44637
|
delegated_to: delegatedTo ?? null
|
|
44619
44638
|
});
|
|
44620
|
-
if (response instanceof
|
|
44639
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44621
44640
|
return;
|
|
44622
44641
|
}
|
|
44623
44642
|
throw this.unexpectedResponse("delete_requested_secret");
|
|
@@ -44630,13 +44649,13 @@ ${newlined}
|
|
|
44630
44649
|
timeout,
|
|
44631
44650
|
delegate_to: delegateTo ?? null
|
|
44632
44651
|
});
|
|
44633
|
-
if (response instanceof
|
|
44652
|
+
if (response instanceof response_js_1.FileContent) {
|
|
44634
44653
|
return response.data;
|
|
44635
44654
|
}
|
|
44636
44655
|
throw this.unexpectedResponse("request_secret");
|
|
44637
44656
|
}
|
|
44638
44657
|
async setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data }) {
|
|
44639
|
-
const response = await this.invoke("set_secret", new
|
|
44658
|
+
const response = await this.invoke("set_secret", new response_js_1.BinaryContent({
|
|
44640
44659
|
data,
|
|
44641
44660
|
headers: {
|
|
44642
44661
|
secret_id: secretId ?? null,
|
|
@@ -44647,7 +44666,7 @@ ${newlined}
|
|
|
44647
44666
|
has_data: true
|
|
44648
44667
|
}
|
|
44649
44668
|
}));
|
|
44650
|
-
if (response instanceof
|
|
44669
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44651
44670
|
return;
|
|
44652
44671
|
}
|
|
44653
44672
|
throw this.unexpectedResponse("set_secret");
|
|
@@ -44659,10 +44678,10 @@ ${newlined}
|
|
|
44659
44678
|
name: name ?? null,
|
|
44660
44679
|
delegated_to: delegatedTo ?? null
|
|
44661
44680
|
});
|
|
44662
|
-
if (response instanceof
|
|
44681
|
+
if (response instanceof response_js_1.EmptyContent) {
|
|
44663
44682
|
return null;
|
|
44664
44683
|
}
|
|
44665
|
-
if (response instanceof
|
|
44684
|
+
if (response instanceof response_js_1.FileContent) {
|
|
44666
44685
|
return response;
|
|
44667
44686
|
}
|
|
44668
44687
|
throw this.unexpectedResponse("get_secret");
|
|
@@ -44678,8 +44697,8 @@ ${newlined}
|
|
|
44678
44697
|
"use strict";
|
|
44679
44698
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44680
44699
|
exports.ServicesClient = void 0;
|
|
44681
|
-
var
|
|
44682
|
-
var
|
|
44700
|
+
var response_js_1 = require_response();
|
|
44701
|
+
var room_server_client_js_1 = require_room_server_client();
|
|
44683
44702
|
function isRecord(value) {
|
|
44684
44703
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
44685
44704
|
}
|
|
@@ -44691,7 +44710,7 @@ ${newlined}
|
|
|
44691
44710
|
}
|
|
44692
44711
|
function parseServiceRuntimeState(value) {
|
|
44693
44712
|
if (!isRecord(value) || typeof value["service_id"] !== "string") {
|
|
44694
|
-
throw new
|
|
44713
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
44695
44714
|
}
|
|
44696
44715
|
const state = value["state"];
|
|
44697
44716
|
const containerId = value["container_id"];
|
|
@@ -44710,12 +44729,12 @@ ${newlined}
|
|
|
44710
44729
|
if (typeof value === "string") {
|
|
44711
44730
|
const parsed = JSON.parse(value);
|
|
44712
44731
|
if (!isRecord(parsed)) {
|
|
44713
|
-
throw new
|
|
44732
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
44714
44733
|
}
|
|
44715
44734
|
return parsed;
|
|
44716
44735
|
}
|
|
44717
44736
|
if (!isRecord(value)) {
|
|
44718
|
-
throw new
|
|
44737
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from services.list");
|
|
44719
44738
|
}
|
|
44720
44739
|
return value;
|
|
44721
44740
|
}
|
|
@@ -44724,7 +44743,7 @@ ${newlined}
|
|
|
44724
44743
|
this.room = room;
|
|
44725
44744
|
}
|
|
44726
44745
|
unexpectedResponse(operation) {
|
|
44727
|
-
return new
|
|
44746
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from services.${operation}`);
|
|
44728
44747
|
}
|
|
44729
44748
|
async list() {
|
|
44730
44749
|
return (await this.listWithState()).services;
|
|
@@ -44735,7 +44754,7 @@ ${newlined}
|
|
|
44735
44754
|
tool: "list",
|
|
44736
44755
|
input: {}
|
|
44737
44756
|
});
|
|
44738
|
-
if (!(response instanceof
|
|
44757
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
44739
44758
|
throw this.unexpectedResponse("list");
|
|
44740
44759
|
}
|
|
44741
44760
|
const servicesRaw = response.json["services_json"];
|
|
@@ -44761,7 +44780,7 @@ ${newlined}
|
|
|
44761
44780
|
service_id: params.serviceId
|
|
44762
44781
|
}
|
|
44763
44782
|
});
|
|
44764
|
-
if (response instanceof
|
|
44783
|
+
if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
|
|
44765
44784
|
return;
|
|
44766
44785
|
}
|
|
44767
44786
|
throw this.unexpectedResponse("restart");
|
|
@@ -44777,11 +44796,11 @@ ${newlined}
|
|
|
44777
44796
|
"use strict";
|
|
44778
44797
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44779
44798
|
exports.StorageClient = exports.StorageEntry = exports.FileHandle = void 0;
|
|
44780
|
-
var
|
|
44781
|
-
var
|
|
44782
|
-
var
|
|
44783
|
-
var
|
|
44784
|
-
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();
|
|
44785
44804
|
var _DEFAULT_UPLOAD_MIME_TYPE = "application/octet-stream";
|
|
44786
44805
|
var _UPLOAD_MIME_TYPES_BY_SUFFIX = /* @__PURE__ */ new Map([
|
|
44787
44806
|
[".tar.gz", "application/x-tar"],
|
|
@@ -44817,7 +44836,7 @@ ${newlined}
|
|
|
44817
44836
|
[".zip", "application/zip"]
|
|
44818
44837
|
]);
|
|
44819
44838
|
function _unexpectedStorageResponseError(operation) {
|
|
44820
|
-
return new
|
|
44839
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from storage.${operation}`);
|
|
44821
44840
|
}
|
|
44822
44841
|
function _parseStorageTimestamp(value, operation) {
|
|
44823
44842
|
if (value == null) {
|
|
@@ -44852,7 +44871,7 @@ ${newlined}
|
|
|
44852
44871
|
}
|
|
44853
44872
|
};
|
|
44854
44873
|
exports.StorageEntry = StorageEntry;
|
|
44855
|
-
var StorageClient = class extends
|
|
44874
|
+
var StorageClient = class extends event_emitter_js_1.EventEmitter {
|
|
44856
44875
|
constructor({ room }) {
|
|
44857
44876
|
super();
|
|
44858
44877
|
this.client = room;
|
|
@@ -44864,8 +44883,8 @@ ${newlined}
|
|
|
44864
44883
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
44865
44884
|
return;
|
|
44866
44885
|
}
|
|
44867
|
-
const [data, _] = (0,
|
|
44868
|
-
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"] });
|
|
44869
44888
|
this.client.emit(event);
|
|
44870
44889
|
this.emit("file.updated", event);
|
|
44871
44890
|
}
|
|
@@ -44873,8 +44892,8 @@ ${newlined}
|
|
|
44873
44892
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
44874
44893
|
return;
|
|
44875
44894
|
}
|
|
44876
|
-
const [data, _] = (0,
|
|
44877
|
-
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"] });
|
|
44878
44897
|
this.client.emit(event);
|
|
44879
44898
|
this.emit("file.deleted", event);
|
|
44880
44899
|
}
|
|
@@ -44882,8 +44901,8 @@ ${newlined}
|
|
|
44882
44901
|
if (!this.client.isActiveProtocol(protocol)) {
|
|
44883
44902
|
return;
|
|
44884
44903
|
}
|
|
44885
|
-
const [data, _] = (0,
|
|
44886
|
-
const event = new
|
|
44904
|
+
const [data, _] = (0, utils_js_1.unpackMessage)(bytes || new Uint8Array());
|
|
44905
|
+
const event = new room_event_js_1.FileMovedEvent({
|
|
44887
44906
|
sourcePath: data["source_path"],
|
|
44888
44907
|
destinationPath: data["destination_path"],
|
|
44889
44908
|
participantId: data["participant_id"]
|
|
@@ -44915,7 +44934,7 @@ ${newlined}
|
|
|
44915
44934
|
}
|
|
44916
44935
|
async list(path) {
|
|
44917
44936
|
const response = await this._invoke("list", { path });
|
|
44918
|
-
if (!(response instanceof
|
|
44937
|
+
if (!(response instanceof response_js_1.JsonContent) || !Array.isArray(response.json["files"])) {
|
|
44919
44938
|
throw this._unexpectedResponseError("list");
|
|
44920
44939
|
}
|
|
44921
44940
|
const files = response.json["files"];
|
|
@@ -44925,7 +44944,7 @@ ${newlined}
|
|
|
44925
44944
|
}
|
|
44926
44945
|
async stat(path) {
|
|
44927
44946
|
const response = await this._invoke("stat", { path });
|
|
44928
|
-
if (!(response instanceof
|
|
44947
|
+
if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
44929
44948
|
throw this._unexpectedResponseError("stat");
|
|
44930
44949
|
}
|
|
44931
44950
|
if (!response.json["exists"]) {
|
|
@@ -44945,7 +44964,7 @@ ${newlined}
|
|
|
44945
44964
|
}
|
|
44946
44965
|
async exists(path) {
|
|
44947
44966
|
const result = await this._invoke("exists", { path });
|
|
44948
|
-
if (!(result instanceof
|
|
44967
|
+
if (!(result instanceof response_js_1.JsonContent)) {
|
|
44949
44968
|
throw this._unexpectedResponseError("exists");
|
|
44950
44969
|
}
|
|
44951
44970
|
return result.json["exists"];
|
|
@@ -45004,16 +45023,16 @@ ${newlined}
|
|
|
45004
45023
|
});
|
|
45005
45024
|
try {
|
|
45006
45025
|
for await (const chunk of response) {
|
|
45007
|
-
if (chunk instanceof
|
|
45008
|
-
throw new
|
|
45026
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45027
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45009
45028
|
}
|
|
45010
|
-
if (chunk instanceof
|
|
45029
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45011
45030
|
if (chunk.method === "close") {
|
|
45012
45031
|
return;
|
|
45013
45032
|
}
|
|
45014
45033
|
throw this._unexpectedResponseError("upload");
|
|
45015
45034
|
}
|
|
45016
|
-
if (!(chunk instanceof
|
|
45035
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
45017
45036
|
throw this._unexpectedResponseError("upload");
|
|
45018
45037
|
}
|
|
45019
45038
|
if (chunk.headers["kind"] !== "pull") {
|
|
@@ -45063,7 +45082,7 @@ ${newlined}
|
|
|
45063
45082
|
data.set(part, offset);
|
|
45064
45083
|
offset += part.length;
|
|
45065
45084
|
}
|
|
45066
|
-
return new
|
|
45085
|
+
return new response_js_1.FileContent({ data, name, mimeType });
|
|
45067
45086
|
}
|
|
45068
45087
|
async downloadStream(path, { chunkSize = 64 * 1024 } = {}) {
|
|
45069
45088
|
const input = new _StorageDownloadInputStream({ path, chunkSize });
|
|
@@ -45080,10 +45099,10 @@ ${newlined}
|
|
|
45080
45099
|
let bytesReceived = 0;
|
|
45081
45100
|
try {
|
|
45082
45101
|
for await (const chunk of response) {
|
|
45083
|
-
if (chunk instanceof
|
|
45084
|
-
throw new
|
|
45102
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45103
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45085
45104
|
}
|
|
45086
|
-
if (chunk instanceof
|
|
45105
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45087
45106
|
if (chunk.method === "close") {
|
|
45088
45107
|
if (!metadataReceived || expectedSize == null || bytesReceived !== expectedSize) {
|
|
45089
45108
|
throw self2._unexpectedResponseError("download");
|
|
@@ -45092,7 +45111,7 @@ ${newlined}
|
|
|
45092
45111
|
}
|
|
45093
45112
|
throw self2._unexpectedResponseError("download");
|
|
45094
45113
|
}
|
|
45095
|
-
if (!(chunk instanceof
|
|
45114
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
45096
45115
|
throw self2._unexpectedResponseError("download");
|
|
45097
45116
|
}
|
|
45098
45117
|
const kind = chunk.headers["kind"];
|
|
@@ -45137,7 +45156,7 @@ ${newlined}
|
|
|
45137
45156
|
path,
|
|
45138
45157
|
download: options.download ?? false
|
|
45139
45158
|
});
|
|
45140
|
-
if (!(response instanceof
|
|
45159
|
+
if (!(response instanceof response_js_1.JsonContent)) {
|
|
45141
45160
|
throw this._unexpectedResponseError("download_url");
|
|
45142
45161
|
}
|
|
45143
45162
|
return response.json["url"];
|
|
@@ -45175,7 +45194,7 @@ ${newlined}
|
|
|
45175
45194
|
}
|
|
45176
45195
|
}
|
|
45177
45196
|
async *stream() {
|
|
45178
|
-
yield new
|
|
45197
|
+
yield new response_js_1.BinaryContent({
|
|
45179
45198
|
data: new Uint8Array(0),
|
|
45180
45199
|
headers: {
|
|
45181
45200
|
kind: "start",
|
|
@@ -45196,7 +45215,7 @@ ${newlined}
|
|
|
45196
45215
|
continue;
|
|
45197
45216
|
}
|
|
45198
45217
|
this.pendingPulls -= 1;
|
|
45199
|
-
yield new
|
|
45218
|
+
yield new response_js_1.BinaryContent({
|
|
45200
45219
|
data: new Uint8Array(0),
|
|
45201
45220
|
headers: { kind: "pull" }
|
|
45202
45221
|
});
|
|
@@ -45283,7 +45302,7 @@ ${newlined}
|
|
|
45283
45302
|
return combined;
|
|
45284
45303
|
}
|
|
45285
45304
|
async *stream() {
|
|
45286
|
-
yield new
|
|
45305
|
+
yield new response_js_1.BinaryContent({
|
|
45287
45306
|
data: new Uint8Array(0),
|
|
45288
45307
|
headers: {
|
|
45289
45308
|
kind: "start",
|
|
@@ -45311,7 +45330,7 @@ ${newlined}
|
|
|
45311
45330
|
if (chunk == null) {
|
|
45312
45331
|
return;
|
|
45313
45332
|
}
|
|
45314
|
-
yield new
|
|
45333
|
+
yield new response_js_1.BinaryContent({
|
|
45315
45334
|
data: chunk,
|
|
45316
45335
|
headers: { kind: "data" }
|
|
45317
45336
|
});
|
|
@@ -45327,13 +45346,13 @@ ${newlined}
|
|
|
45327
45346
|
"use strict";
|
|
45328
45347
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45329
45348
|
exports.SyncClient = void 0;
|
|
45330
|
-
var
|
|
45331
|
-
var
|
|
45332
|
-
var
|
|
45333
|
-
var
|
|
45334
|
-
var
|
|
45335
|
-
var
|
|
45336
|
-
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();
|
|
45337
45356
|
function normalizeSyncPath(path) {
|
|
45338
45357
|
let normalized = path;
|
|
45339
45358
|
while (normalized.startsWith("./")) {
|
|
@@ -45349,7 +45368,7 @@ ${newlined}
|
|
|
45349
45368
|
}
|
|
45350
45369
|
function parseSyncOpenStateChunkHeaders(headers) {
|
|
45351
45370
|
if (headers["kind"] !== "state" || typeof headers["path"] !== "string" || typeof headers["schema"] !== "object" || headers["schema"] == null || Array.isArray(headers["schema"])) {
|
|
45352
|
-
throw new
|
|
45371
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from sync.open");
|
|
45353
45372
|
}
|
|
45354
45373
|
return {
|
|
45355
45374
|
kind: "state",
|
|
@@ -45360,7 +45379,7 @@ ${newlined}
|
|
|
45360
45379
|
function parseSyncOpenOutputChunkHeaders(headers) {
|
|
45361
45380
|
const kind = headers["kind"];
|
|
45362
45381
|
if (kind !== "state" && kind !== "sync" || typeof headers["path"] !== "string") {
|
|
45363
|
-
throw new
|
|
45382
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from sync.open");
|
|
45364
45383
|
}
|
|
45365
45384
|
return {
|
|
45366
45385
|
kind,
|
|
@@ -45392,7 +45411,7 @@ ${newlined}
|
|
|
45392
45411
|
});
|
|
45393
45412
|
}
|
|
45394
45413
|
async *inputStream() {
|
|
45395
|
-
yield new
|
|
45414
|
+
yield new response_js_1.BinaryContent({
|
|
45396
45415
|
data: new Uint8Array(),
|
|
45397
45416
|
headers: {
|
|
45398
45417
|
kind: "start",
|
|
@@ -45433,12 +45452,12 @@ ${newlined}
|
|
|
45433
45452
|
throw this._error;
|
|
45434
45453
|
}
|
|
45435
45454
|
if (this._error !== void 0) {
|
|
45436
|
-
throw new
|
|
45455
|
+
throw new room_server_client_js_1.RoomServerException(`sync stream failed: ${String(this._error)}`);
|
|
45437
45456
|
}
|
|
45438
45457
|
if (this._inputClosed) {
|
|
45439
|
-
throw new
|
|
45458
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
45440
45459
|
}
|
|
45441
|
-
this._enqueueChunk(new
|
|
45460
|
+
this._enqueueChunk(new response_js_1.BinaryContent({
|
|
45442
45461
|
data,
|
|
45443
45462
|
headers: { kind: "sync" }
|
|
45444
45463
|
}));
|
|
@@ -45448,7 +45467,7 @@ ${newlined}
|
|
|
45448
45467
|
}
|
|
45449
45468
|
};
|
|
45450
45469
|
SyncOpenStreamState.INPUT_STREAM_CLOSE = /* @__PURE__ */ Symbol("sync-open-input-close");
|
|
45451
|
-
var SyncClient = class extends
|
|
45470
|
+
var SyncClient = class extends event_emitter_js_1.EventEmitter {
|
|
45452
45471
|
constructor({ room }) {
|
|
45453
45472
|
super();
|
|
45454
45473
|
this._connectingDocuments = {};
|
|
@@ -45461,7 +45480,7 @@ ${newlined}
|
|
|
45461
45480
|
}
|
|
45462
45481
|
start() {
|
|
45463
45482
|
if (this._started) {
|
|
45464
|
-
throw new
|
|
45483
|
+
throw new room_server_client_js_1.RoomServerException("client already started");
|
|
45465
45484
|
}
|
|
45466
45485
|
this._started = true;
|
|
45467
45486
|
}
|
|
@@ -45471,7 +45490,7 @@ ${newlined}
|
|
|
45471
45490
|
streamState.closeInputStream();
|
|
45472
45491
|
}
|
|
45473
45492
|
for (const doc of Object.values(this._connectedDocuments)) {
|
|
45474
|
-
(0,
|
|
45493
|
+
(0, runtime_js_1.unregisterDocument)(doc.ref.id);
|
|
45475
45494
|
}
|
|
45476
45495
|
Object.keys(this._documentStreams).forEach((key) => delete this._documentStreams[key]);
|
|
45477
45496
|
Object.keys(this._documentConfigs).forEach((key) => delete this._documentConfigs[key]);
|
|
@@ -45481,7 +45500,7 @@ ${newlined}
|
|
|
45481
45500
|
this._started = false;
|
|
45482
45501
|
}
|
|
45483
45502
|
_unexpectedResponseError(operation) {
|
|
45484
|
-
return new
|
|
45503
|
+
return new room_server_client_js_1.RoomServerException(`unexpected return type from sync.${operation}`);
|
|
45485
45504
|
}
|
|
45486
45505
|
async _invoke(operation, input) {
|
|
45487
45506
|
return await this.room.invoke({
|
|
@@ -45492,7 +45511,7 @@ ${newlined}
|
|
|
45492
45511
|
}
|
|
45493
45512
|
_applySyncPayload(rc, payload) {
|
|
45494
45513
|
if (payload.length > 0) {
|
|
45495
|
-
(0,
|
|
45514
|
+
(0, runtime_js_1.applyBackendChanges)(rc.ref.id, utils_js_1.decoder.decode(payload));
|
|
45496
45515
|
}
|
|
45497
45516
|
if (!rc.ref.isSynchronized) {
|
|
45498
45517
|
rc.ref.setSynchronizedComplete();
|
|
@@ -45522,7 +45541,7 @@ ${newlined}
|
|
|
45522
45541
|
connected.count += 1;
|
|
45523
45542
|
return connected.ref;
|
|
45524
45543
|
}
|
|
45525
|
-
const connecting = new
|
|
45544
|
+
const connecting = new completer_js_1.Completer();
|
|
45526
45545
|
this._connectingDocuments[normalizedPath] = connecting.fut;
|
|
45527
45546
|
try {
|
|
45528
45547
|
const config = {
|
|
@@ -45536,8 +45555,8 @@ ${newlined}
|
|
|
45536
45555
|
vector: null,
|
|
45537
45556
|
initialJson: initialJson ?? null
|
|
45538
45557
|
});
|
|
45539
|
-
const resolvedSchema =
|
|
45540
|
-
const doc = new
|
|
45558
|
+
const resolvedSchema = schema_js_1.MeshSchema.fromJson(openResult.stateHeaders.schema);
|
|
45559
|
+
const doc = new room_server_client_js_1.MeshDocument({
|
|
45541
45560
|
schema: resolvedSchema,
|
|
45542
45561
|
sendChangesToBackend: (base64) => {
|
|
45543
45562
|
const currentStream = this._documentStreams[normalizedPath];
|
|
@@ -45545,12 +45564,12 @@ ${newlined}
|
|
|
45545
45564
|
return;
|
|
45546
45565
|
}
|
|
45547
45566
|
try {
|
|
45548
|
-
currentStream.queueSync(
|
|
45567
|
+
currentStream.queueSync(utils_js_1.encoder.encode(base64));
|
|
45549
45568
|
} catch {
|
|
45550
45569
|
}
|
|
45551
45570
|
}
|
|
45552
45571
|
});
|
|
45553
|
-
const rc = new
|
|
45572
|
+
const rc = new utils_js_1.RefCount(doc);
|
|
45554
45573
|
this._connectedDocuments[normalizedPath] = rc;
|
|
45555
45574
|
this._documentConfigs[normalizedPath] = config;
|
|
45556
45575
|
this._documentStreams[normalizedPath] = openResult.streamState;
|
|
@@ -45576,7 +45595,7 @@ ${newlined}
|
|
|
45576
45595
|
const normalizedPath = normalizeSyncPath(path);
|
|
45577
45596
|
const rc = this._connectedDocuments[normalizedPath];
|
|
45578
45597
|
if (rc == null) {
|
|
45579
|
-
throw new
|
|
45598
|
+
throw new room_server_client_js_1.RoomServerException(`Not connected to ${normalizedPath}`);
|
|
45580
45599
|
}
|
|
45581
45600
|
rc.count -= 1;
|
|
45582
45601
|
if (rc.count === 0) {
|
|
@@ -45590,10 +45609,10 @@ ${newlined}
|
|
|
45590
45609
|
try {
|
|
45591
45610
|
await streamState.wait();
|
|
45592
45611
|
} finally {
|
|
45593
|
-
(0,
|
|
45612
|
+
(0, runtime_js_1.unregisterDocument)(rc.ref.id);
|
|
45594
45613
|
}
|
|
45595
45614
|
} else {
|
|
45596
|
-
(0,
|
|
45615
|
+
(0, runtime_js_1.unregisterDocument)(rc.ref.id);
|
|
45597
45616
|
}
|
|
45598
45617
|
})();
|
|
45599
45618
|
this._closingDocuments[normalizedPath] = closeFuture;
|
|
@@ -45610,11 +45629,11 @@ ${newlined}
|
|
|
45610
45629
|
async sync(path, data) {
|
|
45611
45630
|
const normalizedPath = normalizeSyncPath(path);
|
|
45612
45631
|
if (this._connectedDocuments[normalizedPath] == null) {
|
|
45613
|
-
throw new
|
|
45632
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
45614
45633
|
}
|
|
45615
45634
|
const streamState = this._documentStreams[normalizedPath];
|
|
45616
45635
|
if (streamState == null) {
|
|
45617
|
-
throw new
|
|
45636
|
+
throw new room_server_client_js_1.RoomServerException("attempted to sync to a document that is not connected");
|
|
45618
45637
|
}
|
|
45619
45638
|
streamState.queueSync(data);
|
|
45620
45639
|
}
|
|
@@ -45626,21 +45645,21 @@ ${newlined}
|
|
|
45626
45645
|
return;
|
|
45627
45646
|
}
|
|
45628
45647
|
const chunk = next.value;
|
|
45629
|
-
if (chunk instanceof
|
|
45630
|
-
throw new
|
|
45648
|
+
if (chunk instanceof response_js_1.ErrorContent) {
|
|
45649
|
+
throw new room_server_client_js_1.RoomServerException(chunk.text, chunk.code);
|
|
45631
45650
|
}
|
|
45632
|
-
if (chunk instanceof
|
|
45651
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
45633
45652
|
if (chunk.method === "close") {
|
|
45634
45653
|
return;
|
|
45635
45654
|
}
|
|
45636
45655
|
throw this._unexpectedResponseError("open");
|
|
45637
45656
|
}
|
|
45638
|
-
if (!(chunk instanceof
|
|
45657
|
+
if (!(chunk instanceof response_js_1.BinaryContent)) {
|
|
45639
45658
|
throw this._unexpectedResponseError("open");
|
|
45640
45659
|
}
|
|
45641
45660
|
const headers = parseSyncOpenOutputChunkHeaders(chunk.headers);
|
|
45642
45661
|
if (normalizeSyncPath(headers.path) !== path) {
|
|
45643
|
-
throw new
|
|
45662
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream returned a mismatched path");
|
|
45644
45663
|
}
|
|
45645
45664
|
this._applySyncPayload(rc, chunk.data);
|
|
45646
45665
|
}
|
|
@@ -45668,18 +45687,18 @@ ${newlined}
|
|
|
45668
45687
|
iterator = responseStream[Symbol.asyncIterator]();
|
|
45669
45688
|
const first = await iterator.next();
|
|
45670
45689
|
if (first.done || first.value === void 0) {
|
|
45671
|
-
throw new
|
|
45690
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream closed before the initial document state was returned");
|
|
45672
45691
|
}
|
|
45673
45692
|
const firstChunk = first.value;
|
|
45674
|
-
if (firstChunk instanceof
|
|
45675
|
-
throw new
|
|
45693
|
+
if (firstChunk instanceof response_js_1.ErrorContent) {
|
|
45694
|
+
throw new room_server_client_js_1.RoomServerException(firstChunk.text, firstChunk.code);
|
|
45676
45695
|
}
|
|
45677
|
-
if (!(firstChunk instanceof
|
|
45696
|
+
if (!(firstChunk instanceof response_js_1.BinaryContent)) {
|
|
45678
45697
|
throw this._unexpectedResponseError("open");
|
|
45679
45698
|
}
|
|
45680
45699
|
const stateHeaders = parseSyncOpenStateChunkHeaders(firstChunk.headers);
|
|
45681
45700
|
if (normalizeSyncPath(stateHeaders.path) !== path) {
|
|
45682
|
-
throw new
|
|
45701
|
+
throw new room_server_client_js_1.RoomServerException("sync.open stream returned a mismatched path");
|
|
45683
45702
|
}
|
|
45684
45703
|
return {
|
|
45685
45704
|
streamState,
|
|
@@ -45743,26 +45762,26 @@ ${newlined}
|
|
|
45743
45762
|
"use strict";
|
|
45744
45763
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45745
45764
|
exports.RoomClient = exports.RoomProtocolProxy = void 0;
|
|
45746
|
-
var
|
|
45747
|
-
var
|
|
45748
|
-
var
|
|
45749
|
-
var
|
|
45750
|
-
var
|
|
45751
|
-
var
|
|
45752
|
-
var
|
|
45753
|
-
var
|
|
45754
|
-
var
|
|
45755
|
-
var
|
|
45756
|
-
var
|
|
45757
|
-
var
|
|
45758
|
-
var
|
|
45759
|
-
var
|
|
45760
|
-
var
|
|
45761
|
-
var
|
|
45762
|
-
var
|
|
45763
|
-
var
|
|
45764
|
-
var
|
|
45765
|
-
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();
|
|
45766
45785
|
var ProtocolStartupFailure = class extends Error {
|
|
45767
45786
|
constructor({ kind, reason }) {
|
|
45768
45787
|
super(reason ?? kind);
|
|
@@ -45772,7 +45791,7 @@ ${newlined}
|
|
|
45772
45791
|
}
|
|
45773
45792
|
};
|
|
45774
45793
|
function isRetryableStartupClose({ kind, reason }) {
|
|
45775
|
-
if (kind ===
|
|
45794
|
+
if (kind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
45776
45795
|
return true;
|
|
45777
45796
|
}
|
|
45778
45797
|
return (reason ?? "").toLowerCase().includes("1013");
|
|
@@ -45784,16 +45803,16 @@ ${newlined}
|
|
|
45784
45803
|
this.messageSendMessage = messageSendMessage;
|
|
45785
45804
|
}
|
|
45786
45805
|
requestError() {
|
|
45787
|
-
return new
|
|
45806
|
+
return new room_server_client_js_1.RoomServerException(this.requestMessage);
|
|
45788
45807
|
}
|
|
45789
45808
|
toolCallError() {
|
|
45790
|
-
return new
|
|
45809
|
+
return new room_server_client_js_1.RoomServerException(this.toolCallMessage);
|
|
45791
45810
|
}
|
|
45792
45811
|
messageSendError() {
|
|
45793
|
-
return new
|
|
45812
|
+
return new room_server_client_js_1.RoomServerException(this.messageSendMessage);
|
|
45794
45813
|
}
|
|
45795
45814
|
};
|
|
45796
|
-
var RoomConnectionStatusException = class extends
|
|
45815
|
+
var RoomConnectionStatusException = class extends room_server_client_js_1.RoomServerException {
|
|
45797
45816
|
constructor({ statusCode, statusText }) {
|
|
45798
45817
|
const normalizedStatusText = statusText?.trim();
|
|
45799
45818
|
super(normalizedStatusText == null || normalizedStatusText.length === 0 ? `websocket connect failed with status ${statusCode}` : `websocket connect failed with status ${statusCode}: ${normalizedStatusText}`);
|
|
@@ -45809,19 +45828,19 @@ ${newlined}
|
|
|
45809
45828
|
return normalized.length === 0 ? null : normalized;
|
|
45810
45829
|
}
|
|
45811
45830
|
function wrapRoomConnectionError(error) {
|
|
45812
|
-
if (error instanceof
|
|
45831
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
45813
45832
|
return error;
|
|
45814
45833
|
}
|
|
45815
|
-
if (error instanceof
|
|
45834
|
+
if (error instanceof protocol_js_1.ProtocolHandshakeException) {
|
|
45816
45835
|
return new RoomConnectionStatusException({
|
|
45817
45836
|
statusCode: error.statusCode,
|
|
45818
45837
|
statusText: error.statusText
|
|
45819
45838
|
});
|
|
45820
45839
|
}
|
|
45821
|
-
if (error instanceof
|
|
45822
|
-
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}`);
|
|
45823
45842
|
}
|
|
45824
|
-
return new
|
|
45843
|
+
return new room_server_client_js_1.RoomServerException(`room connection error: ${String(error)}`);
|
|
45825
45844
|
}
|
|
45826
45845
|
function nonRetryableConnectFailureReason(error) {
|
|
45827
45846
|
if (error instanceof RoomConnectionStatusException && (error.statusCode === 403 || error.statusCode === 404)) {
|
|
@@ -45830,7 +45849,7 @@ ${newlined}
|
|
|
45830
45849
|
return null;
|
|
45831
45850
|
}
|
|
45832
45851
|
function roomClosedBeforeReadyError(protocol) {
|
|
45833
|
-
return new
|
|
45852
|
+
return new room_server_client_js_1.RoomServerException(normalizeCloseReason(protocol.closeReason) ?? "room connection closed before request completed");
|
|
45834
45853
|
}
|
|
45835
45854
|
function getEnvironmentValue(name) {
|
|
45836
45855
|
if (typeof process === "undefined") {
|
|
@@ -45854,7 +45873,7 @@ ${newlined}
|
|
|
45854
45873
|
if (roomName == null || roomName.trim().length === 0 || token == null || token.trim().length === 0) {
|
|
45855
45874
|
throw new Error("protocolFactory must be configured or MESHAGENT_ROOM and MESHAGENT_TOKEN must be set in the environment");
|
|
45856
45875
|
}
|
|
45857
|
-
return
|
|
45876
|
+
return protocol_js_1.WebSocketClientProtocol.createFactory({
|
|
45858
45877
|
url: websocketRoomUrlFromEnvironment(roomName),
|
|
45859
45878
|
token
|
|
45860
45879
|
});
|
|
@@ -45948,15 +45967,15 @@ ${newlined}
|
|
|
45948
45967
|
constructor({ protocolFactory = null, reconnectTimeout = null, oauthTokenRequestHandler, secretRequestHandler } = {}) {
|
|
45949
45968
|
this._entered = false;
|
|
45950
45969
|
this._allowDisconnectedRequests = false;
|
|
45951
|
-
this._eventsController = new
|
|
45952
|
-
this._eventEmitter = new
|
|
45970
|
+
this._eventsController = new stream_controller_js_1.StreamController();
|
|
45971
|
+
this._eventEmitter = new event_emitter_js_1.EventEmitter();
|
|
45953
45972
|
this._pendingRequests = /* @__PURE__ */ new Map();
|
|
45954
45973
|
this._toolCallStreams = /* @__PURE__ */ new Map();
|
|
45955
45974
|
this._ignoredResponseLabels = /* @__PURE__ */ new Map();
|
|
45956
|
-
this._ready = new
|
|
45957
|
-
this._roomClosed = new
|
|
45958
|
-
this._connectionReady = new
|
|
45959
|
-
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();
|
|
45960
45979
|
this._connected = false;
|
|
45961
45980
|
this._closing = false;
|
|
45962
45981
|
this._localParticipant = null;
|
|
@@ -45985,21 +46004,29 @@ ${newlined}
|
|
|
45985
46004
|
this.protocol.addHandler("connected", this._handleParticipantBound);
|
|
45986
46005
|
this.protocol.addHandler("__response__", this._handleResponseBound);
|
|
45987
46006
|
this.protocol.addHandler("room.tool_call_response_chunk", this._handleToolCallResponseChunkBound);
|
|
45988
|
-
this.sync = new
|
|
45989
|
-
this.storage = new
|
|
45990
|
-
this.developer = new
|
|
45991
|
-
this.messaging = new
|
|
45992
|
-
this.queues = new
|
|
45993
|
-
this.datasets = new
|
|
45994
|
-
this.agents = new
|
|
45995
|
-
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({
|
|
45996
46015
|
room: this,
|
|
45997
46016
|
oauthTokenRequestHandler,
|
|
45998
46017
|
secretRequestHandler
|
|
45999
46018
|
});
|
|
46000
|
-
this.containers = new
|
|
46001
|
-
this.memory = new
|
|
46002
|
-
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
|
+
});
|
|
46003
46030
|
}
|
|
46004
46031
|
get localParticipant() {
|
|
46005
46032
|
return this._localParticipant;
|
|
@@ -46173,7 +46200,7 @@ ${newlined}
|
|
|
46173
46200
|
return `${baseMessage}: ${normalized}`;
|
|
46174
46201
|
}
|
|
46175
46202
|
_connectionFailureReason(error) {
|
|
46176
|
-
if (error instanceof
|
|
46203
|
+
if (error instanceof room_server_client_js_1.RoomServerException) {
|
|
46177
46204
|
return normalizeCloseReason(error.message);
|
|
46178
46205
|
}
|
|
46179
46206
|
return normalizeCloseReason(String(error));
|
|
@@ -46221,11 +46248,11 @@ ${newlined}
|
|
|
46221
46248
|
const normalizedCloseReason = normalizeCloseReason(closeReason);
|
|
46222
46249
|
this._closeKind = closeKind;
|
|
46223
46250
|
this._closeReason = normalizedCloseReason;
|
|
46224
|
-
if (closeKind ===
|
|
46251
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46225
46252
|
this._setTerminalState({
|
|
46226
46253
|
state: this._unexpectedCloseTerminalState({ closeReason: normalizedCloseReason })
|
|
46227
46254
|
});
|
|
46228
|
-
} else if (closeKind ===
|
|
46255
|
+
} else if (closeKind === protocol_js_1.ProtocolCloseKind.CLIENT) {
|
|
46229
46256
|
this._setTerminalState({ state: this._clientClosedTerminalState() });
|
|
46230
46257
|
} else {
|
|
46231
46258
|
this._setTerminalState({ state: this._protocolTerminalState({ protocol }) });
|
|
@@ -46256,18 +46283,18 @@ ${newlined}
|
|
|
46256
46283
|
}
|
|
46257
46284
|
}
|
|
46258
46285
|
_disconnectedError({ baseMessage }) {
|
|
46259
|
-
return new
|
|
46286
|
+
return new room_server_client_js_1.RoomServerException(this._formatClosedMessage({
|
|
46260
46287
|
baseMessage
|
|
46261
46288
|
}));
|
|
46262
46289
|
}
|
|
46263
46290
|
_messageDisconnectedError({ baseMessage }) {
|
|
46264
|
-
return new
|
|
46291
|
+
return new room_server_client_js_1.RoomServerException(this._formatClosedMessage({
|
|
46265
46292
|
baseMessage
|
|
46266
46293
|
}));
|
|
46267
46294
|
}
|
|
46268
46295
|
_startupException({ closeKind, closeReason, protocol }) {
|
|
46269
|
-
const baseMessage = closeKind ===
|
|
46270
|
-
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({
|
|
46271
46298
|
baseMessage,
|
|
46272
46299
|
protocol,
|
|
46273
46300
|
closeReason
|
|
@@ -46302,7 +46329,7 @@ ${newlined}
|
|
|
46302
46329
|
if (this._closing && this._terminalState != null) {
|
|
46303
46330
|
return this._terminalState.messageSendError();
|
|
46304
46331
|
}
|
|
46305
|
-
return new
|
|
46332
|
+
return new room_server_client_js_1.RoomServerException("Cannot send messages because messaging has been stopped");
|
|
46306
46333
|
}
|
|
46307
46334
|
_failPendingRequests(error) {
|
|
46308
46335
|
if (this._pendingRequests.size === 0) {
|
|
@@ -46323,7 +46350,7 @@ ${newlined}
|
|
|
46323
46350
|
const streams = [...this._toolCallStreams.values()];
|
|
46324
46351
|
this._toolCallStreams.clear();
|
|
46325
46352
|
for (const stream of streams) {
|
|
46326
|
-
stream.add(new
|
|
46353
|
+
stream.add(new response_js_1.ErrorContent({ text: error.message }));
|
|
46327
46354
|
stream.close();
|
|
46328
46355
|
}
|
|
46329
46356
|
}
|
|
@@ -46333,8 +46360,8 @@ ${newlined}
|
|
|
46333
46360
|
}
|
|
46334
46361
|
async _openProtocol({ initial }) {
|
|
46335
46362
|
const protocol = this._protocolInstance;
|
|
46336
|
-
this._connectionReady = new
|
|
46337
|
-
this._localParticipantReady = new
|
|
46363
|
+
this._connectionReady = new completer_js_1.Completer();
|
|
46364
|
+
this._localParticipantReady = new completer_js_1.Completer();
|
|
46338
46365
|
protocol.start({
|
|
46339
46366
|
onDone: () => {
|
|
46340
46367
|
const error = roomClosedBeforeReadyError(protocol);
|
|
@@ -46364,8 +46391,8 @@ ${newlined}
|
|
|
46364
46391
|
try {
|
|
46365
46392
|
await Promise.all([this._connectionReady.fut, this._localParticipantReady.fut]);
|
|
46366
46393
|
} catch (error) {
|
|
46367
|
-
const kind = protocol.closeKind ??
|
|
46368
|
-
if (!initial && kind !==
|
|
46394
|
+
const kind = protocol.closeKind ?? protocol_js_1.ProtocolCloseKind.ERROR;
|
|
46395
|
+
if (!initial && kind !== protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46369
46396
|
throw new ProtocolStartupFailure({
|
|
46370
46397
|
kind,
|
|
46371
46398
|
reason: normalizeCloseReason(protocol.closeReason)
|
|
@@ -46376,7 +46403,7 @@ ${newlined}
|
|
|
46376
46403
|
}
|
|
46377
46404
|
async start({ onDone, onError } = {}) {
|
|
46378
46405
|
if (this._entered) {
|
|
46379
|
-
throw new
|
|
46406
|
+
throw new room_server_client_js_1.RoomServerException("room client already started");
|
|
46380
46407
|
}
|
|
46381
46408
|
this._doneHandler = onDone;
|
|
46382
46409
|
this._errorHandler = onError;
|
|
@@ -46413,7 +46440,7 @@ ${newlined}
|
|
|
46413
46440
|
this._finalizeInitialStartupRetryFailure({
|
|
46414
46441
|
retryResult: {
|
|
46415
46442
|
connected: false,
|
|
46416
|
-
closeKind:
|
|
46443
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46417
46444
|
closeReason: nonRetryableCloseReason
|
|
46418
46445
|
}
|
|
46419
46446
|
});
|
|
@@ -46435,12 +46462,12 @@ ${newlined}
|
|
|
46435
46462
|
const closeReason = this._connectionFailureReason(error);
|
|
46436
46463
|
if (this._reconnectTimeout === 0) {
|
|
46437
46464
|
this._setStartupTerminalState({
|
|
46438
|
-
closeKind:
|
|
46465
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46439
46466
|
closeReason,
|
|
46440
46467
|
protocol: this._protocolInstance
|
|
46441
46468
|
});
|
|
46442
46469
|
throw this._startupException({
|
|
46443
|
-
closeKind:
|
|
46470
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46444
46471
|
closeReason,
|
|
46445
46472
|
protocol: this._protocolInstance
|
|
46446
46473
|
});
|
|
@@ -46563,14 +46590,14 @@ ${newlined}
|
|
|
46563
46590
|
}
|
|
46564
46591
|
return {
|
|
46565
46592
|
connected: false,
|
|
46566
|
-
closeKind:
|
|
46593
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46567
46594
|
closeReason: this._reconnectTimeoutReason({ disconnectReason })
|
|
46568
46595
|
};
|
|
46569
46596
|
}
|
|
46570
46597
|
async _closeAfterUnexpectedDisconnect({ closeReason }) {
|
|
46571
46598
|
const normalized = normalizeCloseReason(closeReason);
|
|
46572
46599
|
const state = this._unexpectedCloseTerminalState({ closeReason: normalized });
|
|
46573
|
-
this._closeKind =
|
|
46600
|
+
this._closeKind = protocol_js_1.ProtocolCloseKind.ERROR;
|
|
46574
46601
|
this._closeReason = normalized;
|
|
46575
46602
|
this._setTerminalState({ state });
|
|
46576
46603
|
this._completeRoomClosed();
|
|
@@ -46621,10 +46648,10 @@ ${newlined}
|
|
|
46621
46648
|
try {
|
|
46622
46649
|
nextProtocol = this._protocolFactory();
|
|
46623
46650
|
} catch (error) {
|
|
46624
|
-
if (error instanceof
|
|
46651
|
+
if (error instanceof protocol_js_1.ProtocolReconnectUnsupportedException) {
|
|
46625
46652
|
return {
|
|
46626
46653
|
connected: false,
|
|
46627
|
-
closeKind:
|
|
46654
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46628
46655
|
closeReason: failureReason
|
|
46629
46656
|
};
|
|
46630
46657
|
}
|
|
@@ -46658,7 +46685,7 @@ ${newlined}
|
|
|
46658
46685
|
await this._closeProtocol(nextProtocol);
|
|
46659
46686
|
return {
|
|
46660
46687
|
connected: false,
|
|
46661
|
-
closeKind:
|
|
46688
|
+
closeKind: protocol_js_1.ProtocolCloseKind.ERROR,
|
|
46662
46689
|
closeReason: nonRetryableCloseReason
|
|
46663
46690
|
};
|
|
46664
46691
|
}
|
|
@@ -46671,7 +46698,7 @@ ${newlined}
|
|
|
46671
46698
|
}
|
|
46672
46699
|
return {
|
|
46673
46700
|
connected: false,
|
|
46674
|
-
closeKind:
|
|
46701
|
+
closeKind: protocol_js_1.ProtocolCloseKind.CLIENT,
|
|
46675
46702
|
closeReason: this.closeReason
|
|
46676
46703
|
};
|
|
46677
46704
|
}
|
|
@@ -46690,7 +46717,7 @@ ${newlined}
|
|
|
46690
46717
|
return true;
|
|
46691
46718
|
}
|
|
46692
46719
|
const closeKind = retryResult.closeKind ?? null;
|
|
46693
|
-
if (closeKind ===
|
|
46720
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46694
46721
|
const closeReason = retryResult.closeReason ?? null;
|
|
46695
46722
|
if (closeReason != null && closeReason.startsWith("room reconnect timed out after")) {
|
|
46696
46723
|
console.warn(`${closeReason}; closing room client`);
|
|
@@ -46713,14 +46740,14 @@ ${newlined}
|
|
|
46713
46740
|
while (true) {
|
|
46714
46741
|
const protocol = this._protocolInstance;
|
|
46715
46742
|
await protocol.done;
|
|
46716
|
-
const closeKind = protocol.closeKind ??
|
|
46743
|
+
const closeKind = protocol.closeKind ?? protocol_js_1.ProtocolCloseKind.ERROR;
|
|
46717
46744
|
const closeReason = normalizeCloseReason(protocol.closeReason);
|
|
46718
46745
|
const state = this._protocolTerminalState({ protocol });
|
|
46719
46746
|
if (this._closing) {
|
|
46720
46747
|
this._completeRoomClosed();
|
|
46721
46748
|
return;
|
|
46722
46749
|
}
|
|
46723
|
-
if (closeKind !==
|
|
46750
|
+
if (closeKind !== protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46724
46751
|
this._setTerminalState({ state });
|
|
46725
46752
|
}
|
|
46726
46753
|
this._markDisconnected({ reason: closeReason, kind: closeKind });
|
|
@@ -46732,7 +46759,7 @@ ${newlined}
|
|
|
46732
46759
|
this.messaging._onRoomDisconnect({ reason: closeReason });
|
|
46733
46760
|
await this._failPendingWork({ state });
|
|
46734
46761
|
await this._closeProtocol(protocol);
|
|
46735
|
-
if (closeKind ===
|
|
46762
|
+
if (closeKind === protocol_js_1.ProtocolCloseKind.ERROR) {
|
|
46736
46763
|
if (this._reconnectTimeout === 0) {
|
|
46737
46764
|
if (closeReason == null) {
|
|
46738
46765
|
console.warn("room connection lost; automatic reconnect disabled");
|
|
@@ -46763,7 +46790,7 @@ ${newlined}
|
|
|
46763
46790
|
this._closing = true;
|
|
46764
46791
|
this._markDisconnected({
|
|
46765
46792
|
reason: this.closeReason,
|
|
46766
|
-
kind: this.closeKind ??
|
|
46793
|
+
kind: this.closeKind ?? protocol_js_1.ProtocolCloseKind.CLIENT
|
|
46767
46794
|
});
|
|
46768
46795
|
const closingState = this._clientClosedTerminalState();
|
|
46769
46796
|
this._setTerminalState({ state: closingState });
|
|
@@ -46773,7 +46800,7 @@ ${newlined}
|
|
|
46773
46800
|
void this.messaging.stop();
|
|
46774
46801
|
this._protocolInstance.dispose();
|
|
46775
46802
|
this._entered = false;
|
|
46776
|
-
this._closeKind =
|
|
46803
|
+
this._closeKind = protocol_js_1.ProtocolCloseKind.CLIENT;
|
|
46777
46804
|
this._completeRoomClosed();
|
|
46778
46805
|
this._invokeTerminalCallbacks({ useErrorCallback: false });
|
|
46779
46806
|
this._localParticipant = null;
|
|
@@ -46810,14 +46837,14 @@ ${newlined}
|
|
|
46810
46837
|
_sendRoomRequestNowait(type, request, { data, label, expectResponse = false }) {
|
|
46811
46838
|
return this._sendProtocolNowait({
|
|
46812
46839
|
type,
|
|
46813
|
-
data: (0,
|
|
46840
|
+
data: (0, utils_js_1.packMessage)(request, data),
|
|
46814
46841
|
label,
|
|
46815
46842
|
expectResponse
|
|
46816
46843
|
});
|
|
46817
46844
|
}
|
|
46818
46845
|
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId }) {
|
|
46819
|
-
const resolvedInput = input ?? new
|
|
46820
|
-
const packedInput = (0,
|
|
46846
|
+
const resolvedInput = input ?? new response_js_1.EmptyContent();
|
|
46847
|
+
const packedInput = (0, utils_js_1.unpackMessage)(resolvedInput.pack());
|
|
46821
46848
|
const request = {
|
|
46822
46849
|
toolkit,
|
|
46823
46850
|
tool,
|
|
@@ -46835,7 +46862,7 @@ ${newlined}
|
|
|
46835
46862
|
_sendLocalAttributesNowait(attributes) {
|
|
46836
46863
|
this._sendProtocolNowait({
|
|
46837
46864
|
type: "set_attributes",
|
|
46838
|
-
data: (0,
|
|
46865
|
+
data: (0, utils_js_1.packMessage)(attributes),
|
|
46839
46866
|
label: "local participant attribute update"
|
|
46840
46867
|
});
|
|
46841
46868
|
}
|
|
@@ -46856,10 +46883,10 @@ ${newlined}
|
|
|
46856
46883
|
throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
|
|
46857
46884
|
}
|
|
46858
46885
|
const requestId = this._protocolInstance.getNextMessageId();
|
|
46859
|
-
const completer = new
|
|
46886
|
+
const completer = new completer_js_1.Completer();
|
|
46860
46887
|
this._pendingRequests.set(requestId, completer);
|
|
46861
46888
|
try {
|
|
46862
|
-
await this._protocolInstance.send(type, (0,
|
|
46889
|
+
await this._protocolInstance.send(type, (0, utils_js_1.packMessage)(request, data), requestId);
|
|
46863
46890
|
return await completer.fut;
|
|
46864
46891
|
} catch (error) {
|
|
46865
46892
|
this._pendingRequests.delete(requestId);
|
|
@@ -46881,33 +46908,33 @@ ${newlined}
|
|
|
46881
46908
|
request["timeout"] = params.timeout;
|
|
46882
46909
|
}
|
|
46883
46910
|
const result = await this.sendRequest("room.list_toolkits", request);
|
|
46884
|
-
if (!(result instanceof
|
|
46885
|
-
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");
|
|
46886
46913
|
}
|
|
46887
46914
|
const tools = result.json["tools"];
|
|
46888
46915
|
if (typeof tools !== "object" || tools === null || Array.isArray(tools)) {
|
|
46889
|
-
throw new
|
|
46916
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
46890
46917
|
}
|
|
46891
46918
|
const toolkits = [];
|
|
46892
46919
|
for (const [name, data] of Object.entries(tools)) {
|
|
46893
46920
|
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
46894
|
-
throw new
|
|
46921
|
+
throw new room_server_client_js_1.RoomServerException("unexpected toolkit description from room.list_toolkits");
|
|
46895
46922
|
}
|
|
46896
|
-
toolkits.push(
|
|
46923
|
+
toolkits.push(agent_client_js_1.ToolkitDescription.fromJson(data, { name }));
|
|
46897
46924
|
}
|
|
46898
46925
|
return toolkits;
|
|
46899
46926
|
}
|
|
46900
46927
|
async invoke(params) {
|
|
46901
|
-
const input = params.input ?? params.arguments ?? new
|
|
46928
|
+
const input = params.input ?? params.arguments ?? new response_js_1.EmptyContent();
|
|
46902
46929
|
const request = {
|
|
46903
46930
|
toolkit: params.toolkit,
|
|
46904
46931
|
tool: params.tool
|
|
46905
46932
|
};
|
|
46906
46933
|
let requestData;
|
|
46907
|
-
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) {
|
|
46908
46935
|
const packed = input.pack();
|
|
46909
|
-
request["arguments"] = JSON.parse((0,
|
|
46910
|
-
const payload = (0,
|
|
46936
|
+
request["arguments"] = JSON.parse((0, utils_js_1.splitMessageHeader)(packed));
|
|
46937
|
+
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
46911
46938
|
if (payload.length > 0) {
|
|
46912
46939
|
requestData = payload;
|
|
46913
46940
|
}
|
|
@@ -46917,7 +46944,7 @@ ${newlined}
|
|
|
46917
46944
|
json: input
|
|
46918
46945
|
};
|
|
46919
46946
|
} else {
|
|
46920
|
-
throw new
|
|
46947
|
+
throw new room_server_client_js_1.RoomServerException("invoke input must be a content value or JSON object");
|
|
46921
46948
|
}
|
|
46922
46949
|
if (params.participantId != null) {
|
|
46923
46950
|
request["participant_id"] = params.participantId;
|
|
@@ -46929,7 +46956,7 @@ ${newlined}
|
|
|
46929
46956
|
}
|
|
46930
46957
|
async invokeToolCall(params) {
|
|
46931
46958
|
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
46932
|
-
const controller = new
|
|
46959
|
+
const controller = new stream_controller_js_1.StreamController();
|
|
46933
46960
|
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
46934
46961
|
this._toolCallStreams.set(toolCallId, controller);
|
|
46935
46962
|
const request = {
|
|
@@ -46945,8 +46972,8 @@ ${newlined}
|
|
|
46945
46972
|
} else {
|
|
46946
46973
|
const input = params.input;
|
|
46947
46974
|
const packed = input.pack();
|
|
46948
|
-
request["arguments"] = JSON.parse((0,
|
|
46949
|
-
const payload = (0,
|
|
46975
|
+
request["arguments"] = JSON.parse((0, utils_js_1.splitMessageHeader)(packed));
|
|
46976
|
+
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
46950
46977
|
if (payload.length > 0) {
|
|
46951
46978
|
requestData = payload;
|
|
46952
46979
|
}
|
|
@@ -46959,14 +46986,14 @@ ${newlined}
|
|
|
46959
46986
|
}
|
|
46960
46987
|
try {
|
|
46961
46988
|
const response = await this.sendRequest("room.invoke_tool", request, requestData);
|
|
46962
|
-
if (response instanceof
|
|
46989
|
+
if (response instanceof response_js_1.ControlContent && response.method === "open") {
|
|
46963
46990
|
if (requestTask != null) {
|
|
46964
46991
|
void requestTask.catch((error) => {
|
|
46965
46992
|
const stream = this._toolCallStreams.get(toolCallId);
|
|
46966
46993
|
if (stream == null) {
|
|
46967
46994
|
return;
|
|
46968
46995
|
}
|
|
46969
|
-
stream.add(new
|
|
46996
|
+
stream.add(new response_js_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
46970
46997
|
stream.close();
|
|
46971
46998
|
this._toolCallStreams.delete(toolCallId);
|
|
46972
46999
|
});
|
|
@@ -47012,8 +47039,8 @@ ${newlined}
|
|
|
47012
47039
|
try {
|
|
47013
47040
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
47014
47041
|
await requestTask;
|
|
47015
|
-
if (response instanceof
|
|
47016
|
-
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}`);
|
|
47017
47044
|
}
|
|
47018
47045
|
return response;
|
|
47019
47046
|
} catch (error) {
|
|
@@ -47023,7 +47050,7 @@ ${newlined}
|
|
|
47023
47050
|
}
|
|
47024
47051
|
async invokeStream(params) {
|
|
47025
47052
|
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
47026
|
-
const controller = new
|
|
47053
|
+
const controller = new stream_controller_js_1.StreamController();
|
|
47027
47054
|
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
47028
47055
|
this._toolCallStreams.set(toolCallId, controller);
|
|
47029
47056
|
const request = {
|
|
@@ -47044,15 +47071,15 @@ ${newlined}
|
|
|
47044
47071
|
if (stream == null) {
|
|
47045
47072
|
return;
|
|
47046
47073
|
}
|
|
47047
|
-
stream.add(new
|
|
47074
|
+
stream.add(new response_js_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
47048
47075
|
stream.close();
|
|
47049
47076
|
this._toolCallStreams.delete(toolCallId);
|
|
47050
47077
|
});
|
|
47051
47078
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
47052
|
-
if (!(response instanceof
|
|
47079
|
+
if (!(response instanceof response_js_1.ControlContent) || response.method !== "open") {
|
|
47053
47080
|
this._toolCallStreams.delete(toolCallId);
|
|
47054
47081
|
controller.close();
|
|
47055
|
-
throw new
|
|
47082
|
+
throw new room_server_client_js_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
47056
47083
|
}
|
|
47057
47084
|
return {
|
|
47058
47085
|
[Symbol.asyncIterator]() {
|
|
@@ -47064,9 +47091,9 @@ ${newlined}
|
|
|
47064
47091
|
const packed = chunk.pack();
|
|
47065
47092
|
const request = {
|
|
47066
47093
|
tool_call_id: toolCallId,
|
|
47067
|
-
chunk: JSON.parse((0,
|
|
47094
|
+
chunk: JSON.parse((0, utils_js_1.splitMessageHeader)(packed))
|
|
47068
47095
|
};
|
|
47069
|
-
const payload = (0,
|
|
47096
|
+
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
47070
47097
|
await this.sendRequest("room.tool_call_request_chunk", request, payload.length > 0 ? payload : void 0);
|
|
47071
47098
|
}
|
|
47072
47099
|
async _streamInvokeToolRequestChunks(toolCallId, input) {
|
|
@@ -47076,7 +47103,7 @@ ${newlined}
|
|
|
47076
47103
|
await this._sendToolCallRequestChunk(toolCallId, item);
|
|
47077
47104
|
}
|
|
47078
47105
|
} finally {
|
|
47079
|
-
await this._sendToolCallRequestChunk(toolCallId, new
|
|
47106
|
+
await this._sendToolCallRequestChunk(toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
47080
47107
|
}
|
|
47081
47108
|
}
|
|
47082
47109
|
_decodeToolCallContent(params) {
|
|
@@ -47084,17 +47111,17 @@ ${newlined}
|
|
|
47084
47111
|
if (typeof chunk === "object" && chunk !== null && !Array.isArray(chunk)) {
|
|
47085
47112
|
const chunkMap = chunk;
|
|
47086
47113
|
if (typeof chunkMap["type"] === "string") {
|
|
47087
|
-
return (0,
|
|
47114
|
+
return (0, response_js_1.unpackContent)((0, utils_js_1.packMessage)(chunkMap, params.payload.length > 0 ? params.payload : void 0));
|
|
47088
47115
|
}
|
|
47089
|
-
return new
|
|
47116
|
+
return new response_js_1.JsonContent({ json: chunkMap });
|
|
47090
47117
|
}
|
|
47091
|
-
return new
|
|
47118
|
+
return new response_js_1.JsonContent({ json: { chunk } });
|
|
47092
47119
|
}
|
|
47093
47120
|
async _handleToolCallResponseChunk(protocol, _messageId, _type, data) {
|
|
47094
47121
|
if (!this.isActiveProtocol(protocol)) {
|
|
47095
47122
|
return;
|
|
47096
47123
|
}
|
|
47097
|
-
const [header, payload] = (0,
|
|
47124
|
+
const [header, payload] = (0, utils_js_1.unpackMessage)(data);
|
|
47098
47125
|
const toolCallId = header["tool_call_id"];
|
|
47099
47126
|
if (typeof toolCallId !== "string" || toolCallId.length === 0) {
|
|
47100
47127
|
return;
|
|
@@ -47105,7 +47132,7 @@ ${newlined}
|
|
|
47105
47132
|
}
|
|
47106
47133
|
const content = this._decodeToolCallContent({ header, payload });
|
|
47107
47134
|
stream.add(content);
|
|
47108
|
-
if (content instanceof
|
|
47135
|
+
if (content instanceof response_js_1.ControlContent && content.method === "close") {
|
|
47109
47136
|
stream.close();
|
|
47110
47137
|
this._toolCallStreams.delete(toolCallId);
|
|
47111
47138
|
}
|
|
@@ -47114,12 +47141,12 @@ ${newlined}
|
|
|
47114
47141
|
if (!this.isActiveProtocol(protocol)) {
|
|
47115
47142
|
return;
|
|
47116
47143
|
}
|
|
47117
|
-
const response = (0,
|
|
47144
|
+
const response = (0, response_js_1.unpackContent)(data);
|
|
47118
47145
|
const pending = this._pendingRequests.get(messageId);
|
|
47119
47146
|
if (pending != null) {
|
|
47120
47147
|
this._pendingRequests.delete(messageId);
|
|
47121
|
-
if (response instanceof
|
|
47122
|
-
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));
|
|
47123
47150
|
} else {
|
|
47124
47151
|
pending.complete(response);
|
|
47125
47152
|
}
|
|
@@ -47128,7 +47155,7 @@ ${newlined}
|
|
|
47128
47155
|
const ignoredLabel = this._ignoredResponseLabels.get(messageId);
|
|
47129
47156
|
if (ignoredLabel != null) {
|
|
47130
47157
|
this._ignoredResponseLabels.delete(messageId);
|
|
47131
|
-
if (response instanceof
|
|
47158
|
+
if (response instanceof response_js_1.ErrorContent) {
|
|
47132
47159
|
console.warn(`one-way room request failed for ${ignoredLabel}: ${response.text}`);
|
|
47133
47160
|
}
|
|
47134
47161
|
}
|
|
@@ -47137,14 +47164,14 @@ ${newlined}
|
|
|
47137
47164
|
if (!this.isActiveProtocol(protocol)) {
|
|
47138
47165
|
return;
|
|
47139
47166
|
}
|
|
47140
|
-
const [payload] = (0,
|
|
47141
|
-
this.emit(
|
|
47167
|
+
const [payload] = (0, utils_js_1.unpackMessage)(data);
|
|
47168
|
+
this.emit(room_event_js_1.RoomStatusEvent.fromJson(payload));
|
|
47142
47169
|
}
|
|
47143
47170
|
async _handleRoomReady(protocol, _messageId, _type, data) {
|
|
47144
47171
|
if (!this.isActiveProtocol(protocol)) {
|
|
47145
47172
|
return;
|
|
47146
47173
|
}
|
|
47147
|
-
const [message2] = (0,
|
|
47174
|
+
const [message2] = (0, utils_js_1.unpackMessage)(data);
|
|
47148
47175
|
this._roomName = typeof message2["room_name"] === "string" ? message2["room_name"] : null;
|
|
47149
47176
|
this._roomUrl = typeof message2["room_url"] === "string" ? message2["room_url"] : null;
|
|
47150
47177
|
this._sessionId = typeof message2["session_id"] === "string" ? message2["session_id"] : null;
|
|
@@ -47157,7 +47184,7 @@ ${newlined}
|
|
|
47157
47184
|
}
|
|
47158
47185
|
_onParticipantInit(participantId, attributes) {
|
|
47159
47186
|
if (this._localParticipant == null) {
|
|
47160
|
-
this._localParticipant = new
|
|
47187
|
+
this._localParticipant = new participant_js_1.LocalParticipant(this, participantId);
|
|
47161
47188
|
this._localParticipant._setAttributes(attributes);
|
|
47162
47189
|
} else {
|
|
47163
47190
|
const merged = { ...attributes, ...this._localParticipant._attributesSnapshot() };
|
|
@@ -47174,7 +47201,7 @@ ${newlined}
|
|
|
47174
47201
|
if (!this.isActiveProtocol(protocol)) {
|
|
47175
47202
|
return;
|
|
47176
47203
|
}
|
|
47177
|
-
const [message2] = (0,
|
|
47204
|
+
const [message2] = (0, utils_js_1.unpackMessage)(data);
|
|
47178
47205
|
switch (message2["type"]) {
|
|
47179
47206
|
case "init": {
|
|
47180
47207
|
const participantId = message2["participantId"];
|
|
@@ -47189,7 +47216,7 @@ ${newlined}
|
|
|
47189
47216
|
}
|
|
47190
47217
|
}
|
|
47191
47218
|
_emitStatus({ status, message: message2 }) {
|
|
47192
|
-
this.emit(new
|
|
47219
|
+
this.emit(new room_event_js_1.RoomStatusEvent({ status, message: message2 }));
|
|
47193
47220
|
}
|
|
47194
47221
|
};
|
|
47195
47222
|
exports.RoomClient = RoomClient;
|