@meshagent/meshagent 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 +7 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +3 -3
- package/dist/browser/containers-client.js +76 -76
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +3 -3
- package/dist/esm/containers-client.js +82 -87
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +3 -3
- package/dist/node/containers-client.js +76 -76
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
## [0.43.0]
|
|
2
|
+
- Split LiveKit helpers into `@meshagent/meshagent-livekit-ts` and added `@meshagent/meshagent-node-ts` for room websocket proxying and room-connect helpers.
|
|
3
|
+
- Updated `meshagent-ts` exports for ESM-aware resolution, moved LiveKit out of the core package, and added `RoomClient.withIAP()` and `WebSocketClientProtocol.withIAP()` for the new room-connect flow.
|
|
4
|
+
- Room websocket auth now uses bearer headers on Node and `meshagent-room.` subprotocol tokens in the browser, and the agents/thread APIs now carry backend metadata and attachment-aware prompts.
|
|
5
|
+
- React/auth/dev/tailwind packages now publish CJS main entries alongside ESM builds, and the new LiveKit package depends on `livekit-client@^2.15.5`.
|
|
6
|
+
|
|
1
7
|
## [0.42.2]
|
|
8
|
+
- Moved TypeScript LiveKit helpers into the new `@meshagent/meshagent-livekit` package so the core TypeScript SDK no longer depends on `livekit-client`.
|
|
2
9
|
- Added `ContainerExitStatus`, `RoomContainerStats`, and published build image metadata to the TypeScript container client models.
|
|
3
10
|
- Added `waitForExitStatus` while keeping `waitForExit` as the exit-code convenience wrapper.
|
|
4
11
|
- Container list parsing now preserves image IDs, runtime stats, and exit-status metadata from API responses.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RoomClient } from "./room-client";
|
|
2
|
-
import type { Content } from "./response";
|
|
3
|
-
import { ToolInput, type ToolCallOutput } from "./agent";
|
|
4
|
-
import { ToolContentSpec } from "./tool-content-type";
|
|
1
|
+
import { RoomClient } from "./room-client.js";
|
|
2
|
+
import type { Content } from "./response.js";
|
|
3
|
+
import { ToolInput, type ToolCallOutput } from "./agent.js";
|
|
4
|
+
import { ToolContentSpec } from "./tool-content-type.js";
|
|
5
5
|
export declare class ToolDescription {
|
|
6
6
|
title: string;
|
|
7
7
|
name: string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AgentsClient = exports.ToolkitDescription = exports.ToolDescription = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const agent_js_1 = require("./agent.js");
|
|
5
|
+
const tool_content_type_js_1 = require("./tool-content-type.js");
|
|
6
6
|
class ToolDescription {
|
|
7
7
|
constructor({ title, name, description, inputSchema, inputSpec, outputSpec, outputSchema, defs }) {
|
|
8
8
|
this.title = title;
|
|
9
9
|
this.name = name;
|
|
10
10
|
this.description = description;
|
|
11
11
|
if (inputSpec !== undefined && inputSchema !== undefined) {
|
|
12
|
-
this.inputSpec = new
|
|
12
|
+
this.inputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
13
13
|
types: [...inputSpec.types],
|
|
14
14
|
stream: inputSpec.stream,
|
|
15
15
|
schema: inputSchema,
|
|
@@ -19,14 +19,14 @@ class ToolDescription {
|
|
|
19
19
|
this.inputSpec = inputSpec;
|
|
20
20
|
}
|
|
21
21
|
else if (inputSchema !== undefined) {
|
|
22
|
-
this.inputSpec = new
|
|
22
|
+
this.inputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
23
23
|
types: ["json"],
|
|
24
24
|
stream: false,
|
|
25
25
|
schema: inputSchema,
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
if (outputSpec !== undefined && outputSchema !== undefined) {
|
|
29
|
-
this.outputSpec = new
|
|
29
|
+
this.outputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
30
30
|
types: [...outputSpec.types],
|
|
31
31
|
stream: outputSpec.stream,
|
|
32
32
|
schema: outputSchema,
|
|
@@ -36,7 +36,7 @@ class ToolDescription {
|
|
|
36
36
|
this.outputSpec = outputSpec;
|
|
37
37
|
}
|
|
38
38
|
else if (outputSchema !== undefined) {
|
|
39
|
-
this.outputSpec = new
|
|
39
|
+
this.outputSpec = new tool_content_type_js_1.ToolContentSpec({
|
|
40
40
|
types: ["json"],
|
|
41
41
|
stream: false,
|
|
42
42
|
schema: outputSchema,
|
|
@@ -96,9 +96,9 @@ class ToolkitDescription {
|
|
|
96
96
|
name: tool["name"],
|
|
97
97
|
description: tool["description"],
|
|
98
98
|
inputSchema: tool["input_schema"],
|
|
99
|
-
inputSpec:
|
|
99
|
+
inputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["input_spec"]),
|
|
100
100
|
outputSchema: tool["output_schema"],
|
|
101
|
-
outputSpec:
|
|
101
|
+
outputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["output_spec"]),
|
|
102
102
|
defs: tool["defs"],
|
|
103
103
|
}));
|
|
104
104
|
}
|
|
@@ -112,9 +112,9 @@ class ToolkitDescription {
|
|
|
112
112
|
name: toolName,
|
|
113
113
|
description: tool["description"],
|
|
114
114
|
inputSchema: tool["input_schema"],
|
|
115
|
-
inputSpec:
|
|
115
|
+
inputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["input_spec"]),
|
|
116
116
|
outputSchema: tool["output_schema"],
|
|
117
|
-
outputSpec:
|
|
117
|
+
outputSpec: tool_content_type_js_1.ToolContentSpec.fromJson(tool["output_spec"]),
|
|
118
118
|
defs: tool["defs"],
|
|
119
119
|
}));
|
|
120
120
|
}
|
|
@@ -149,7 +149,7 @@ class AgentsClient {
|
|
|
149
149
|
onBehalfOfId: params.onBehalfOfId,
|
|
150
150
|
});
|
|
151
151
|
}
|
|
152
|
-
if (params.input instanceof
|
|
152
|
+
if (params.input instanceof agent_js_1.ToolContentInput) {
|
|
153
153
|
const output = await this.client.invokeToolCall({
|
|
154
154
|
toolkit: params.toolkit,
|
|
155
155
|
tool: params.tool,
|
|
@@ -158,10 +158,10 @@ class AgentsClient {
|
|
|
158
158
|
onBehalfOfId: params.onBehalfOfId,
|
|
159
159
|
});
|
|
160
160
|
return output.kind === "content"
|
|
161
|
-
? new
|
|
162
|
-
: new
|
|
161
|
+
? new agent_js_1.ToolContentOutput(output.content)
|
|
162
|
+
: new agent_js_1.ToolStreamOutput(output.stream, { inputClosed: output.inputClosed });
|
|
163
163
|
}
|
|
164
|
-
if (params.input instanceof
|
|
164
|
+
if (params.input instanceof agent_js_1.ToolStreamInput) {
|
|
165
165
|
const output = await this.client.invokeToolCall({
|
|
166
166
|
toolkit: params.toolkit,
|
|
167
167
|
tool: params.tool,
|
|
@@ -171,8 +171,8 @@ class AgentsClient {
|
|
|
171
171
|
onBehalfOfId: params.onBehalfOfId,
|
|
172
172
|
});
|
|
173
173
|
return output.kind === "content"
|
|
174
|
-
? new
|
|
175
|
-
: new
|
|
174
|
+
? new agent_js_1.ToolContentOutput(output.content)
|
|
175
|
+
: new agent_js_1.ToolStreamOutput(output.stream, { inputClosed: output.inputClosed });
|
|
176
176
|
}
|
|
177
177
|
throw new Error("invokeTool input must be ToolContentInput or ToolStreamInput");
|
|
178
178
|
}
|
package/dist/browser/agent.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RoomClient } from "./room-client";
|
|
2
|
-
import { RequiredToolkit } from "./requirement";
|
|
3
|
-
import { type Content } from "./response";
|
|
4
|
-
import { RoomServerException } from "./room-server-client";
|
|
5
|
-
import { ToolContentSpec } from "./tool-content-type";
|
|
6
|
-
import { Participant } from "./participant";
|
|
1
|
+
import { RoomClient } from "./room-client.js";
|
|
2
|
+
import { RequiredToolkit } from "./requirement.js";
|
|
3
|
+
import { type Content } from "./response.js";
|
|
4
|
+
import { RoomServerException } from "./room-server-client.js";
|
|
5
|
+
import { ToolContentSpec } from "./tool-content-type.js";
|
|
6
|
+
import { Participant } from "./participant.js";
|
|
7
7
|
export type ValidationMode = "full" | "contentTypes" | "none";
|
|
8
8
|
export declare class InvalidToolDataException extends RoomServerException {
|
|
9
9
|
constructor(message: string);
|
package/dist/browser/agent.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
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;
|
|
4
4
|
exports.startHostedToolkit = startHostedToolkit;
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
class InvalidToolDataException extends
|
|
5
|
+
const response_js_1 = require("./response.js");
|
|
6
|
+
const room_server_client_js_1 = require("./room-server-client.js");
|
|
7
|
+
const tool_content_type_js_1 = require("./tool-content-type.js");
|
|
8
|
+
const utils_js_1 = require("./utils.js");
|
|
9
|
+
const room_event_js_1 = require("./room-event.js");
|
|
10
|
+
const participant_js_1 = require("./participant.js");
|
|
11
|
+
const stream_controller_js_1 = require("./stream-controller.js");
|
|
12
|
+
class InvalidToolDataException extends room_server_client_js_1.RoomServerException {
|
|
13
13
|
constructor(message) {
|
|
14
14
|
super(message);
|
|
15
15
|
this.name = "InvalidToolDataException";
|
|
@@ -90,10 +90,10 @@ exports.ContentTool = ContentTool;
|
|
|
90
90
|
class Tool extends BaseTool {
|
|
91
91
|
constructor(params) {
|
|
92
92
|
const inputSpec = params.inputSpec !== undefined && params.inputSchema !== undefined
|
|
93
|
-
? new
|
|
93
|
+
? new tool_content_type_js_1.ToolContentSpec({ types: [...params.inputSpec.types], stream: params.inputSpec.stream, schema: params.inputSchema })
|
|
94
94
|
: params.inputSpec;
|
|
95
95
|
const outputSpec = params.outputSpec !== undefined && params.outputSchema !== undefined
|
|
96
|
-
? new
|
|
96
|
+
? new tool_content_type_js_1.ToolContentSpec({ types: [...params.outputSpec.types], stream: params.outputSpec.stream, schema: params.outputSchema })
|
|
97
97
|
: params.outputSpec;
|
|
98
98
|
super({
|
|
99
99
|
name: params.name,
|
|
@@ -101,10 +101,10 @@ class Tool extends BaseTool {
|
|
|
101
101
|
title: params.title,
|
|
102
102
|
inputSchema: params.inputSchema,
|
|
103
103
|
inputSpec: inputSpec ?? (params.inputSchema !== undefined
|
|
104
|
-
? new
|
|
104
|
+
? new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: params.inputSchema })
|
|
105
105
|
: undefined),
|
|
106
106
|
outputSpec: outputSpec ?? (params.outputSchema !== undefined
|
|
107
|
-
? new
|
|
107
|
+
? new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: params.outputSchema })
|
|
108
108
|
: undefined),
|
|
109
109
|
outputSchema: params.outputSchema,
|
|
110
110
|
defs: params.defs,
|
|
@@ -116,38 +116,38 @@ function isRecord(value) {
|
|
|
116
116
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
117
117
|
}
|
|
118
118
|
function contentType(content) {
|
|
119
|
-
if (content instanceof
|
|
119
|
+
if (content instanceof response_js_1.BinaryContent)
|
|
120
120
|
return "binary";
|
|
121
|
-
if (content instanceof
|
|
121
|
+
if (content instanceof response_js_1.JsonContent)
|
|
122
122
|
return "json";
|
|
123
|
-
if (content instanceof
|
|
123
|
+
if (content instanceof response_js_1.TextContent)
|
|
124
124
|
return "text";
|
|
125
|
-
if (content instanceof
|
|
125
|
+
if (content instanceof response_js_1.FileContent)
|
|
126
126
|
return "file";
|
|
127
|
-
if (content instanceof
|
|
127
|
+
if (content instanceof response_js_1.LinkContent)
|
|
128
128
|
return "link";
|
|
129
|
-
if (content instanceof
|
|
129
|
+
if (content instanceof response_js_1.EmptyContent)
|
|
130
130
|
return "empty";
|
|
131
131
|
return undefined;
|
|
132
132
|
}
|
|
133
133
|
function schemaValue(content) {
|
|
134
|
-
if (content instanceof
|
|
134
|
+
if (content instanceof response_js_1.BinaryContent)
|
|
135
135
|
return content.headers;
|
|
136
|
-
if (content instanceof
|
|
136
|
+
if (content instanceof response_js_1.JsonContent)
|
|
137
137
|
return content.json;
|
|
138
|
-
if (content instanceof
|
|
138
|
+
if (content instanceof response_js_1.TextContent)
|
|
139
139
|
return content.text;
|
|
140
|
-
if (content instanceof
|
|
140
|
+
if (content instanceof response_js_1.EmptyContent)
|
|
141
141
|
return null;
|
|
142
|
-
if (content instanceof
|
|
142
|
+
if (content instanceof response_js_1.LinkContent)
|
|
143
143
|
return { name: content.name, url: content.url };
|
|
144
|
-
if (content instanceof
|
|
144
|
+
if (content instanceof response_js_1.FileContent)
|
|
145
145
|
return { name: content.name, mime_type: content.mimeType, size: content.data.length };
|
|
146
|
-
if (content instanceof
|
|
146
|
+
if (content instanceof response_js_1.ControlContent)
|
|
147
147
|
return { method: content.method };
|
|
148
|
-
if (content instanceof
|
|
148
|
+
if (content instanceof response_js_1.ErrorContent)
|
|
149
149
|
return content.code === undefined ? { text: content.text } : { text: content.text, code: content.code };
|
|
150
|
-
const [header] = (0,
|
|
150
|
+
const [header] = (0, utils_js_1.unpackMessage)(content.pack());
|
|
151
151
|
return header;
|
|
152
152
|
}
|
|
153
153
|
function schemaWithDefs(schema, defs) {
|
|
@@ -268,7 +268,7 @@ class Toolkit {
|
|
|
268
268
|
}
|
|
269
269
|
async execute(first, second, third) {
|
|
270
270
|
if (typeof first === "string") {
|
|
271
|
-
const output = await this.executeTool(new ToolContext(), first, new ToolContentInput(new
|
|
271
|
+
const output = await this.executeTool(new ToolContext(), first, new ToolContentInput(new response_js_1.JsonContent({ json: second })));
|
|
272
272
|
if (output instanceof ToolContentOutput) {
|
|
273
273
|
return output.content;
|
|
274
274
|
}
|
|
@@ -297,9 +297,9 @@ class Toolkit {
|
|
|
297
297
|
throw new Error(`tool ${name} has unsupported type`);
|
|
298
298
|
}
|
|
299
299
|
decodeFunctionToolArguments(toolName, input) {
|
|
300
|
-
if (input instanceof
|
|
300
|
+
if (input instanceof response_js_1.EmptyContent)
|
|
301
301
|
return {};
|
|
302
|
-
if (input instanceof
|
|
302
|
+
if (input instanceof response_js_1.JsonContent) {
|
|
303
303
|
if (!isRecord(input.json)) {
|
|
304
304
|
throw new Error(`tool ${toolName} requires JSON object input`);
|
|
305
305
|
}
|
|
@@ -318,18 +318,18 @@ class Toolkit {
|
|
|
318
318
|
return tool.inputSpec;
|
|
319
319
|
if (tool.inputSpec !== undefined)
|
|
320
320
|
return tool.inputSpec;
|
|
321
|
-
return new
|
|
321
|
+
return new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: tool.inputSchema ?? { type: "object", additionalProperties: true } });
|
|
322
322
|
}
|
|
323
323
|
resolveOutputSpec(tool) {
|
|
324
324
|
if (tool.outputSpec !== undefined) {
|
|
325
325
|
if (tool.outputSchema !== undefined && tool.outputSpec.schema === undefined && tool.outputSpec.types.includes("json")) {
|
|
326
|
-
return new
|
|
326
|
+
return new tool_content_type_js_1.ToolContentSpec({ types: [...tool.outputSpec.types], stream: tool.outputSpec.stream, schema: tool.outputSchema });
|
|
327
327
|
}
|
|
328
328
|
return tool.outputSpec;
|
|
329
329
|
}
|
|
330
330
|
if (tool.outputSchema === undefined)
|
|
331
331
|
return undefined;
|
|
332
|
-
return new
|
|
332
|
+
return new tool_content_type_js_1.ToolContentSpec({ types: ["json"], stream: false, schema: tool.outputSchema });
|
|
333
333
|
}
|
|
334
334
|
validateStreamMode({ tool, direction, spec, stream }) {
|
|
335
335
|
if (!this.shouldValidateContentTypes || spec === undefined)
|
|
@@ -399,7 +399,7 @@ class _RemoteToolkitWrapper {
|
|
|
399
399
|
}
|
|
400
400
|
async start({ public_: isPublic = false } = {}) {
|
|
401
401
|
if (this._started) {
|
|
402
|
-
throw new
|
|
402
|
+
throw new room_server_client_js_1.RoomServerException(`toolkit ${this.toolkit.name} is already started`);
|
|
403
403
|
}
|
|
404
404
|
this._public = isPublic;
|
|
405
405
|
this.client.protocol.addHandler(`room.tool_call.${this.toolkit.name}`, this._toolCallHandler);
|
|
@@ -425,7 +425,7 @@ class _RemoteToolkitWrapper {
|
|
|
425
425
|
this._started = false;
|
|
426
426
|
this.client.off("disconnected", this._roomEventHandler);
|
|
427
427
|
this.client.off("reconnected", this._roomEventHandler);
|
|
428
|
-
this._failActiveRequestStreams(new
|
|
428
|
+
this._failActiveRequestStreams(new room_server_client_js_1.RoomServerException("hosted toolkit stopped"));
|
|
429
429
|
try {
|
|
430
430
|
await this._unregister();
|
|
431
431
|
}
|
|
@@ -484,13 +484,13 @@ class _RemoteToolkitWrapper {
|
|
|
484
484
|
});
|
|
485
485
|
}
|
|
486
486
|
_onRoomEvent(event) {
|
|
487
|
-
if (!this._started || !(event instanceof
|
|
487
|
+
if (!this._started || !(event instanceof room_event_js_1.RoomStatusEvent)) {
|
|
488
488
|
return;
|
|
489
489
|
}
|
|
490
490
|
if (event.status === "disconnected") {
|
|
491
491
|
this._registrationId = undefined;
|
|
492
492
|
const message = event.message?.trim();
|
|
493
|
-
this._failActiveRequestStreams(new
|
|
493
|
+
this._failActiveRequestStreams(new room_server_client_js_1.RoomServerException(message == null || message.length === 0
|
|
494
494
|
? "room connection lost before streamed tool call request completed"
|
|
495
495
|
: `room connection lost before streamed tool call request completed: ${message}`));
|
|
496
496
|
return;
|
|
@@ -509,16 +509,16 @@ class _RemoteToolkitWrapper {
|
|
|
509
509
|
if (remote.id === participantId)
|
|
510
510
|
return remote;
|
|
511
511
|
}
|
|
512
|
-
return new
|
|
512
|
+
return new participant_js_1.RemoteParticipant(this.client, participantId, "user");
|
|
513
513
|
}
|
|
514
514
|
_contentFromToolCallArguments(rawArguments, payload) {
|
|
515
515
|
if (!isRecord(rawArguments)) {
|
|
516
516
|
throw new Error("arguments must be a content header object");
|
|
517
517
|
}
|
|
518
518
|
if (typeof rawArguments.type === "string") {
|
|
519
|
-
return (0,
|
|
519
|
+
return (0, response_js_1.unpackContent)((0, utils_js_1.packMessage)(rawArguments, payload.length > 0 ? payload : undefined));
|
|
520
520
|
}
|
|
521
|
-
return new
|
|
521
|
+
return new response_js_1.JsonContent({ json: rawArguments });
|
|
522
522
|
}
|
|
523
523
|
async _sendToolCallResponse(messageId, chunk) {
|
|
524
524
|
try {
|
|
@@ -531,9 +531,9 @@ class _RemoteToolkitWrapper {
|
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
async _sendToolCallResponseChunk(messageId, toolCallId, chunk) {
|
|
534
|
-
const [header, payload] = (0,
|
|
534
|
+
const [header, payload] = (0, utils_js_1.unpackMessage)(chunk.pack());
|
|
535
535
|
try {
|
|
536
|
-
await this.client.protocol.send("room.tool_call_response_chunk", (0,
|
|
536
|
+
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 : undefined), { id: messageId });
|
|
537
537
|
return true;
|
|
538
538
|
}
|
|
539
539
|
catch (error) {
|
|
@@ -553,7 +553,7 @@ class _RemoteToolkitWrapper {
|
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
555
|
_enqueueRequestStreamChunk(stream, chunk, tool) {
|
|
556
|
-
if (chunk instanceof
|
|
556
|
+
if (chunk instanceof response_js_1.ControlContent) {
|
|
557
557
|
if (chunk.method === "open")
|
|
558
558
|
return;
|
|
559
559
|
if (chunk.method === "close") {
|
|
@@ -582,7 +582,7 @@ class _RemoteToolkitWrapper {
|
|
|
582
582
|
let toolCallId = toolCallIdFallback;
|
|
583
583
|
let openedResponseStream = false;
|
|
584
584
|
try {
|
|
585
|
-
const [message, payload] = (0,
|
|
585
|
+
const [message, payload] = (0, utils_js_1.unpackMessage)(data);
|
|
586
586
|
const toolName = message["name"];
|
|
587
587
|
if (typeof toolName !== "string" || toolName.length === 0) {
|
|
588
588
|
throw new Error("tool call requires a tool name");
|
|
@@ -591,19 +591,19 @@ class _RemoteToolkitWrapper {
|
|
|
591
591
|
? message["tool_call_id"]
|
|
592
592
|
: toolCallIdFallback;
|
|
593
593
|
const inputChunk = this._contentFromToolCallArguments(message["arguments"], payload);
|
|
594
|
-
const requestStream = inputChunk instanceof
|
|
595
|
-
if (inputChunk instanceof
|
|
596
|
-
await this._sendToolCallResponse(messageId, new
|
|
594
|
+
const requestStream = inputChunk instanceof response_js_1.ControlContent && inputChunk.method === "open";
|
|
595
|
+
if (inputChunk instanceof response_js_1.ControlContent && !requestStream) {
|
|
596
|
+
await this._sendToolCallResponse(messageId, new response_js_1.ErrorContent({ text: "request stream must start with an open control chunk" }));
|
|
597
597
|
return;
|
|
598
598
|
}
|
|
599
599
|
const tool = this.toolkit.getTool(toolName);
|
|
600
600
|
this.toolkit.validateStreamMode({ tool, direction: "input", spec: this.toolkit.resolveInputSpec(tool), stream: requestStream });
|
|
601
601
|
let resolvedInput;
|
|
602
602
|
if (requestStream) {
|
|
603
|
-
const controller = new
|
|
603
|
+
const controller = new stream_controller_js_1.StreamController();
|
|
604
604
|
this._requestStreams.set(toolCallId, controller);
|
|
605
605
|
this._requestStreamTools.set(toolCallId, tool);
|
|
606
|
-
this._enqueueRequestStreamChunk(controller, new
|
|
606
|
+
this._enqueueRequestStreamChunk(controller, new response_js_1.ControlContent({ method: "open" }), tool);
|
|
607
607
|
const buffered = this._pendingRequestChunks.get(toolCallId) ?? [];
|
|
608
608
|
this._pendingRequestChunks.delete(toolCallId);
|
|
609
609
|
for (const chunk of buffered) {
|
|
@@ -630,29 +630,29 @@ class _RemoteToolkitWrapper {
|
|
|
630
630
|
if (output instanceof ToolStreamOutput) {
|
|
631
631
|
this.toolkit.validateStreamMode({ tool, direction: "output", spec: this.toolkit.resolveOutputSpec(tool), stream: true });
|
|
632
632
|
openedResponseStream = true;
|
|
633
|
-
if (!await this._sendToolCallResponse(messageId, new
|
|
633
|
+
if (!await this._sendToolCallResponse(messageId, new response_js_1.ControlContent({ method: "open" })))
|
|
634
634
|
return;
|
|
635
635
|
for await (const chunk of output.stream) {
|
|
636
636
|
this.toolkit.validateOutputContent(tool, chunk);
|
|
637
637
|
if (!await this._sendToolCallResponseChunk(messageId, toolCallId, chunk))
|
|
638
638
|
return;
|
|
639
639
|
}
|
|
640
|
-
await this._sendToolCallResponseChunk(messageId, toolCallId, new
|
|
640
|
+
await this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
641
641
|
return;
|
|
642
642
|
}
|
|
643
643
|
throw new Error(`tool ${toolName} returned unsupported output`);
|
|
644
644
|
}
|
|
645
645
|
catch (error) {
|
|
646
646
|
if (!openedResponseStream) {
|
|
647
|
-
await this._sendToolCallResponse(messageId, new
|
|
647
|
+
await this._sendToolCallResponse(messageId, new response_js_1.ErrorContent({ text: String(error) }));
|
|
648
648
|
return;
|
|
649
649
|
}
|
|
650
650
|
if (!(error instanceof InvalidToolDataException)) {
|
|
651
|
-
await this._sendToolCallResponseChunk(messageId, toolCallId, new
|
|
651
|
+
await this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ErrorContent({ text: String(error) }));
|
|
652
652
|
}
|
|
653
|
-
await this._sendToolCallResponseChunk(messageId, toolCallId, new
|
|
653
|
+
await this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({
|
|
654
654
|
method: "close",
|
|
655
|
-
statusCode: error instanceof InvalidToolDataException ?
|
|
655
|
+
statusCode: error instanceof InvalidToolDataException ? response_js_1.ControlCloseStatus.INVALID_DATA : undefined,
|
|
656
656
|
message: error instanceof InvalidToolDataException ? error.message : undefined,
|
|
657
657
|
}));
|
|
658
658
|
}
|
|
@@ -665,14 +665,14 @@ class _RemoteToolkitWrapper {
|
|
|
665
665
|
return;
|
|
666
666
|
}
|
|
667
667
|
try {
|
|
668
|
-
const [message, payload] = (0,
|
|
668
|
+
const [message, payload] = (0, utils_js_1.unpackMessage)(data);
|
|
669
669
|
const toolCallId = message["tool_call_id"];
|
|
670
670
|
if (typeof toolCallId !== "string" || toolCallId.length === 0)
|
|
671
671
|
return;
|
|
672
672
|
const chunkHeader = message["chunk"];
|
|
673
673
|
if (!isRecord(chunkHeader))
|
|
674
674
|
return;
|
|
675
|
-
const chunk = (0,
|
|
675
|
+
const chunk = (0, response_js_1.unpackContent)((0, utils_js_1.packMessage)(chunkHeader, payload.length > 0 ? payload : undefined));
|
|
676
676
|
const stream = this._requestStreams.get(toolCallId);
|
|
677
677
|
if (stream === undefined) {
|
|
678
678
|
const buffered = this._pendingRequestChunks.get(toolCallId) ?? [];
|
package/dist/browser/api_keys.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.base36Encode = base36Encode;
|
|
4
7
|
exports.base36Decode = base36Decode;
|
|
@@ -8,7 +11,8 @@ exports.base64CompressUuid = base64CompressUuid;
|
|
|
8
11
|
exports.base64DecompressUuid = base64DecompressUuid;
|
|
9
12
|
exports.parseApiKey = parseApiKey;
|
|
10
13
|
exports.encodeApiKey = encodeApiKey;
|
|
11
|
-
const base_64_1 = require("base-64");
|
|
14
|
+
const base_64_1 = __importDefault(require("base-64"));
|
|
15
|
+
const { encode: base64Encode, decode: base64Decode } = base_64_1.default;
|
|
12
16
|
const BASE36_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz";
|
|
13
17
|
const BASE36 = 36n;
|
|
14
18
|
const UUID_HEX_REGEX = /^[0-9a-f]{32}$/;
|
|
@@ -95,7 +99,7 @@ function bytesToBase64(bytes) {
|
|
|
95
99
|
if (globalScope.btoa) {
|
|
96
100
|
return globalScope.btoa(binary);
|
|
97
101
|
}
|
|
98
|
-
return (
|
|
102
|
+
return base64Encode(binary);
|
|
99
103
|
}
|
|
100
104
|
function base64ToBytes(base64) {
|
|
101
105
|
if (globalScope.Buffer) {
|
|
@@ -107,7 +111,7 @@ function base64ToBytes(base64) {
|
|
|
107
111
|
binary = globalScope.atob(base64);
|
|
108
112
|
}
|
|
109
113
|
else {
|
|
110
|
-
binary = (
|
|
114
|
+
binary = base64Decode(base64);
|
|
111
115
|
}
|
|
112
116
|
const bytes = new Uint8Array(binary.length);
|
|
113
117
|
for (let i = 0; i < binary.length; i += 1) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ContainerMountSpec } from "./meshagent-client";
|
|
2
|
-
import { type Content } from "./response";
|
|
3
|
-
import { RoomClient } from "./room-client";
|
|
1
|
+
import type { ContainerMountSpec } from "./meshagent-client.js";
|
|
2
|
+
import { type Content } from "./response.js";
|
|
3
|
+
import { RoomClient } from "./room-client.js";
|
|
4
4
|
export interface DockerSecret {
|
|
5
5
|
username: string;
|
|
6
6
|
password: string;
|