@mastra/client-js 1.58.0 → 1.59.0-alpha.1
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/dist/client.d.ts +15 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-client-js-observability.md +2 -0
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +58 -14
- package/dist/index.cjs +166 -73
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +166 -73
- package/dist/index.js.map +1 -1
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/index.d.ts +1 -0
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/knowledge.d.ts +78 -0
- package/dist/resources/knowledge.d.ts.map +1 -0
- package/dist/route-types.generated.d.ts +246 -19
- package/dist/route-types.generated.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './types.js';
|
|
|
4
4
|
export * from './tools.js';
|
|
5
5
|
export type { ChannelPlatformInfo, ChannelInstallationInfo, ChannelConnectOAuth, ChannelConnectDeepLink, ChannelConnectImmediate, ChannelConnectResult, } from './resources/channels.js';
|
|
6
6
|
export type { AgentCardSignatureKeyProviderInput, AgentCardVerificationKey, GetAgentCardOptions, VerifyAgentCardSignatureOptions, } from './resources/a2a.js';
|
|
7
|
+
export type { KnowledgeActivityResponse, KnowledgeChangeNotice, KnowledgeGraphResponse, KnowledgeInstanceSummary, KnowledgePageResponse, KnowledgeSearchResponse, KnowledgeTreeResponse, } from './resources/knowledge.js';
|
|
7
8
|
export { agentControllerMessageText, isKnownAgentControllerEvent } from './resources/agent-controller.js';
|
|
8
9
|
export type { MastraDBMessage, MastraMessageContentV2, MastraMessagePart, AgentControllerEvent, KnownAgentControllerEvent, OtherAgentControllerEvent, AgentControllerRequestOptions, SubscribeAgentControllerSessionOptions, AgentControllerSubscription, PlanResume, AgentControllerCommandAck, AgentControllerCommandRejection, } from './resources/agent-controller.js';
|
|
9
10
|
export { RequestContext } from '@mastra/core/request-context';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AACvG,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,sCAAsC,EACtC,2BAA2B,EAC3B,UAAU,EACV,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAC3D,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,kCAAkC,EAClC,uBAAuB,EACvB,6BAA6B,EAC7B,iCAAiC,EACjC,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAC/C,YAAY,EACV,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,kCAAkC,EAClC,wBAAwB,EACxB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AACvG,YAAY,EACV,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,sCAAsC,EACtC,2BAA2B,EAC3B,UAAU,EACV,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,EAClB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,eAAe,EACf,0BAA0B,EAC1B,mBAAmB,EACnB,6BAA6B,EAC7B,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAC3D,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC3B,kCAAkC,EAClC,uBAAuB,EACvB,6BAA6B,EAC7B,iCAAiC,EACjC,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,uCAAuC,CAAC;AAC/C,YAAY,EACV,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -341,6 +341,25 @@ function buildTenancyQuery(tenancy) {
|
|
|
341
341
|
return queryString ? `?${queryString}` : "";
|
|
342
342
|
}
|
|
343
343
|
/**
|
|
344
|
+
* Merges header records case-insensitively; later layers win and keep their casing.
|
|
345
|
+
* Spreading would keep `Authorization` and `authorization` apart, and fetch joins them into "a, b".
|
|
346
|
+
*/
|
|
347
|
+
function mergeHeaders(...layers) {
|
|
348
|
+
const merged = {};
|
|
349
|
+
const namesByLowercase = /* @__PURE__ */ new Map();
|
|
350
|
+
for (const layer of layers) {
|
|
351
|
+
if (!layer) continue;
|
|
352
|
+
for (const [name, value] of Object.entries(layer)) {
|
|
353
|
+
const lowercase = name.toLowerCase();
|
|
354
|
+
const previous = namesByLowercase.get(lowercase);
|
|
355
|
+
if (previous !== void 0) delete merged[previous];
|
|
356
|
+
namesByLowercase.set(lowercase, name);
|
|
357
|
+
merged[name] = value;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return merged;
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
344
363
|
* Merges multiple optional abort signals into one. Returns `undefined` when no
|
|
345
364
|
* signals are provided, the single signal when only one is provided, and a
|
|
346
365
|
* combined signal otherwise. Uses `AbortSignal.any` when available and falls
|
|
@@ -1193,11 +1212,7 @@ var BaseResource = class {
|
|
|
1193
1212
|
try {
|
|
1194
1213
|
const response = await fetchFn(`${baseUrl.replace(/\/$/, "")}${fullPath}`, {
|
|
1195
1214
|
...fetchOptions,
|
|
1196
|
-
headers: {
|
|
1197
|
-
...fetchOptions.body && !(fetchOptions.body instanceof FormData) && (fetchOptions.method === "POST" || fetchOptions.method === "PUT" || fetchOptions.method === "PATCH" || fetchOptions.method === "DELETE") ? { "content-type": "application/json" } : {},
|
|
1198
|
-
...headers,
|
|
1199
|
-
...fetchOptions.headers
|
|
1200
|
-
},
|
|
1215
|
+
headers: mergeHeaders(fetchOptions.body && !(fetchOptions.body instanceof FormData) && (fetchOptions.method === "POST" || fetchOptions.method === "PUT" || fetchOptions.method === "PATCH" || fetchOptions.method === "DELETE") ? { "content-type": "application/json" } : void 0, headers, fetchOptions.headers),
|
|
1201
1216
|
signal,
|
|
1202
1217
|
credentials: fetchOptions.credentials ?? credentials,
|
|
1203
1218
|
body: fetchOptions.body instanceof FormData ? fetchOptions.body : fetchOptions.body ? JSON.stringify(fetchOptions.body) : void 0
|
|
@@ -3861,6 +3876,137 @@ var Vector = class extends BaseResource {
|
|
|
3861
3876
|
});
|
|
3862
3877
|
}
|
|
3863
3878
|
};
|
|
3879
|
+
// src/utils/stream-transforms.ts
|
|
3880
|
+
const RECORD_SEPARATOR$1 = "";
|
|
3881
|
+
const SSE_FRAME_SEPARATOR = /\r?\n\r?\n/;
|
|
3882
|
+
/**
|
|
3883
|
+
* Parses UTF-8 JSON values delimited by the record separator character.
|
|
3884
|
+
*/
|
|
3885
|
+
function createRecordSeparatorJsonTransform() {
|
|
3886
|
+
const decoder = new TextDecoder();
|
|
3887
|
+
let buffer = "";
|
|
3888
|
+
const processCompleteRecords = (controller) => {
|
|
3889
|
+
let separatorIndex = buffer.indexOf(RECORD_SEPARATOR$1);
|
|
3890
|
+
while (separatorIndex !== -1) {
|
|
3891
|
+
const record = buffer.slice(0, separatorIndex);
|
|
3892
|
+
buffer = buffer.slice(separatorIndex + 1);
|
|
3893
|
+
if (record) controller.enqueue(JSON.parse(record));
|
|
3894
|
+
separatorIndex = buffer.indexOf(RECORD_SEPARATOR$1);
|
|
3895
|
+
}
|
|
3896
|
+
};
|
|
3897
|
+
return new TransformStream({
|
|
3898
|
+
transform(chunk, controller) {
|
|
3899
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
3900
|
+
processCompleteRecords(controller);
|
|
3901
|
+
},
|
|
3902
|
+
flush(controller) {
|
|
3903
|
+
buffer += decoder.decode();
|
|
3904
|
+
processCompleteRecords(controller);
|
|
3905
|
+
if (buffer) controller.enqueue(JSON.parse(buffer));
|
|
3906
|
+
}
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3909
|
+
/**
|
|
3910
|
+
* Parses UTF-8 JSON payloads from blank-line-delimited Server-Sent Events.
|
|
3911
|
+
*/
|
|
3912
|
+
function createSseJsonTransform() {
|
|
3913
|
+
const decoder = new TextDecoder();
|
|
3914
|
+
let buffer = "";
|
|
3915
|
+
const parseFrame = (frame, controller) => {
|
|
3916
|
+
const dataLines = [];
|
|
3917
|
+
for (const line of frame.split(/\r?\n/)) {
|
|
3918
|
+
if (line.startsWith(":") || !line.startsWith("data:")) continue;
|
|
3919
|
+
const value = line.slice(5);
|
|
3920
|
+
dataLines.push(value.startsWith(" ") ? value.slice(1) : value);
|
|
3921
|
+
}
|
|
3922
|
+
if (dataLines.length === 0) return;
|
|
3923
|
+
const payload = dataLines.join("\n");
|
|
3924
|
+
if (payload === "[DONE]") return;
|
|
3925
|
+
controller.enqueue(JSON.parse(payload));
|
|
3926
|
+
};
|
|
3927
|
+
const processCompleteFrames = (controller) => {
|
|
3928
|
+
let separatorMatch = SSE_FRAME_SEPARATOR.exec(buffer);
|
|
3929
|
+
while (separatorMatch) {
|
|
3930
|
+
parseFrame(buffer.slice(0, separatorMatch.index), controller);
|
|
3931
|
+
buffer = buffer.slice(separatorMatch.index + separatorMatch[0].length);
|
|
3932
|
+
separatorMatch = SSE_FRAME_SEPARATOR.exec(buffer);
|
|
3933
|
+
}
|
|
3934
|
+
};
|
|
3935
|
+
return new TransformStream({
|
|
3936
|
+
transform(chunk, controller) {
|
|
3937
|
+
buffer += decoder.decode(chunk, { stream: true });
|
|
3938
|
+
processCompleteFrames(controller);
|
|
3939
|
+
},
|
|
3940
|
+
flush(controller) {
|
|
3941
|
+
buffer += decoder.decode();
|
|
3942
|
+
processCompleteFrames(controller);
|
|
3943
|
+
if (buffer) parseFrame(buffer, controller);
|
|
3944
|
+
}
|
|
3945
|
+
});
|
|
3946
|
+
}
|
|
3947
|
+
// src/resources/knowledge.ts
|
|
3948
|
+
function query(params) {
|
|
3949
|
+
const search = new URLSearchParams();
|
|
3950
|
+
for (const [name, value] of Object.entries(params)) {
|
|
3951
|
+
if (value === void 0) continue;
|
|
3952
|
+
for (const item of Array.isArray(value) ? value : [value]) search.append(name, String(item));
|
|
3953
|
+
}
|
|
3954
|
+
const text = search.toString();
|
|
3955
|
+
return text ? `?${text}` : "";
|
|
3956
|
+
}
|
|
3957
|
+
/**
|
|
3958
|
+
* Read-only access to one Knowledge instance registered on the server. Reads return every page and note,
|
|
3959
|
+
* as the instance owner; the server's auth decides who may call them.
|
|
3960
|
+
*
|
|
3961
|
+
* @experimental Knowledge APIs are experimental and may change without notice.
|
|
3962
|
+
*/
|
|
3963
|
+
var Knowledge = class extends BaseResource {
|
|
3964
|
+
knowledgeKey;
|
|
3965
|
+
constructor(options, knowledgeKey) {
|
|
3966
|
+
super(options);
|
|
3967
|
+
this.knowledgeKey = knowledgeKey;
|
|
3968
|
+
}
|
|
3969
|
+
get base() {
|
|
3970
|
+
return `/knowledge/${encodeURIComponent(this.knowledgeKey)}`;
|
|
3971
|
+
}
|
|
3972
|
+
/** One level of the page tree: the root scopes, or `parentId`'s child scopes then its child pages (paged). */
|
|
3973
|
+
tree(params = {}) {
|
|
3974
|
+
return this.request(`${this.base}/tree${query(params)}`);
|
|
3975
|
+
}
|
|
3976
|
+
/** One page with its ancestors, notes, pin and references; rejects with 404 when it does not exist. */
|
|
3977
|
+
page(pageId, params = {}) {
|
|
3978
|
+
return this.request(`${this.base}/pages/${encodeURIComponent(pageId)}${query(params)}`);
|
|
3979
|
+
}
|
|
3980
|
+
/** A bounded page graph under `rootId`, or across every root scope. */
|
|
3981
|
+
graph(params = {}) {
|
|
3982
|
+
return this.request(`${this.base}/graph${query(params)}`);
|
|
3983
|
+
}
|
|
3984
|
+
/** Pages and notes matching `searchQuery`, optionally only within the given scope page ids. */
|
|
3985
|
+
search(searchQuery, params = {}) {
|
|
3986
|
+
return this.request(`${this.base}/search${query({
|
|
3987
|
+
q: searchQuery,
|
|
3988
|
+
scopeId: params.scopeIds,
|
|
3989
|
+
limit: params.limit
|
|
3990
|
+
})}`);
|
|
3991
|
+
}
|
|
3992
|
+
/** A newest-first page of activity, optionally for one scope or one page. */
|
|
3993
|
+
activity(params = {}) {
|
|
3994
|
+
return this.request(`${this.base}/activity${query(params)}`);
|
|
3995
|
+
}
|
|
3996
|
+
/**
|
|
3997
|
+
* A live stream of the writes the caller can read, from when it opens until `signal` aborts. Rejects
|
|
3998
|
+
* when the server can't stream them (for example 501 on an older @mastra/core).
|
|
3999
|
+
*/
|
|
4000
|
+
async events(params = {}) {
|
|
4001
|
+
const response = await this.request(`${this.base}/events`, {
|
|
4002
|
+
stream: true,
|
|
4003
|
+
retries: 0,
|
|
4004
|
+
signal: params.signal
|
|
4005
|
+
});
|
|
4006
|
+
if (!response.body) throw new Error("Response body is null");
|
|
4007
|
+
return response.body.pipeThrough(createSseJsonTransform());
|
|
4008
|
+
}
|
|
4009
|
+
};
|
|
3864
4010
|
// src/resources/tool.ts
|
|
3865
4011
|
var Tool = class extends BaseResource {
|
|
3866
4012
|
toolId;
|
|
@@ -3956,74 +4102,6 @@ var Conversations = class extends BaseResource {
|
|
|
3956
4102
|
return this.request(`/v1/conversations/${encodeURIComponent(conversationId)}${requestContextQueryString(requestContext)}`, { method: "DELETE" });
|
|
3957
4103
|
}
|
|
3958
4104
|
};
|
|
3959
|
-
// src/utils/stream-transforms.ts
|
|
3960
|
-
const RECORD_SEPARATOR$1 = "";
|
|
3961
|
-
const SSE_FRAME_SEPARATOR = /\r?\n\r?\n/;
|
|
3962
|
-
/**
|
|
3963
|
-
* Parses UTF-8 JSON values delimited by the record separator character.
|
|
3964
|
-
*/
|
|
3965
|
-
function createRecordSeparatorJsonTransform() {
|
|
3966
|
-
const decoder = new TextDecoder();
|
|
3967
|
-
let buffer = "";
|
|
3968
|
-
const processCompleteRecords = (controller) => {
|
|
3969
|
-
let separatorIndex = buffer.indexOf(RECORD_SEPARATOR$1);
|
|
3970
|
-
while (separatorIndex !== -1) {
|
|
3971
|
-
const record = buffer.slice(0, separatorIndex);
|
|
3972
|
-
buffer = buffer.slice(separatorIndex + 1);
|
|
3973
|
-
if (record) controller.enqueue(JSON.parse(record));
|
|
3974
|
-
separatorIndex = buffer.indexOf(RECORD_SEPARATOR$1);
|
|
3975
|
-
}
|
|
3976
|
-
};
|
|
3977
|
-
return new TransformStream({
|
|
3978
|
-
transform(chunk, controller) {
|
|
3979
|
-
buffer += decoder.decode(chunk, { stream: true });
|
|
3980
|
-
processCompleteRecords(controller);
|
|
3981
|
-
},
|
|
3982
|
-
flush(controller) {
|
|
3983
|
-
buffer += decoder.decode();
|
|
3984
|
-
processCompleteRecords(controller);
|
|
3985
|
-
if (buffer) controller.enqueue(JSON.parse(buffer));
|
|
3986
|
-
}
|
|
3987
|
-
});
|
|
3988
|
-
}
|
|
3989
|
-
/**
|
|
3990
|
-
* Parses UTF-8 JSON payloads from blank-line-delimited Server-Sent Events.
|
|
3991
|
-
*/
|
|
3992
|
-
function createSseJsonTransform() {
|
|
3993
|
-
const decoder = new TextDecoder();
|
|
3994
|
-
let buffer = "";
|
|
3995
|
-
const parseFrame = (frame, controller) => {
|
|
3996
|
-
const dataLines = [];
|
|
3997
|
-
for (const line of frame.split(/\r?\n/)) {
|
|
3998
|
-
if (line.startsWith(":") || !line.startsWith("data:")) continue;
|
|
3999
|
-
const value = line.slice(5);
|
|
4000
|
-
dataLines.push(value.startsWith(" ") ? value.slice(1) : value);
|
|
4001
|
-
}
|
|
4002
|
-
if (dataLines.length === 0) return;
|
|
4003
|
-
const payload = dataLines.join("\n");
|
|
4004
|
-
if (payload === "[DONE]") return;
|
|
4005
|
-
controller.enqueue(JSON.parse(payload));
|
|
4006
|
-
};
|
|
4007
|
-
const processCompleteFrames = (controller) => {
|
|
4008
|
-
let separatorMatch = SSE_FRAME_SEPARATOR.exec(buffer);
|
|
4009
|
-
while (separatorMatch) {
|
|
4010
|
-
parseFrame(buffer.slice(0, separatorMatch.index), controller);
|
|
4011
|
-
buffer = buffer.slice(separatorMatch.index + separatorMatch[0].length);
|
|
4012
|
-
separatorMatch = SSE_FRAME_SEPARATOR.exec(buffer);
|
|
4013
|
-
}
|
|
4014
|
-
};
|
|
4015
|
-
return new TransformStream({
|
|
4016
|
-
transform(chunk, controller) {
|
|
4017
|
-
buffer += decoder.decode(chunk, { stream: true });
|
|
4018
|
-
processCompleteFrames(controller);
|
|
4019
|
-
},
|
|
4020
|
-
flush(controller) {
|
|
4021
|
-
buffer += decoder.decode();
|
|
4022
|
-
processCompleteFrames(controller);
|
|
4023
|
-
if (buffer) parseFrame(buffer, controller);
|
|
4024
|
-
}
|
|
4025
|
-
});
|
|
4026
|
-
}
|
|
4027
4105
|
// src/resources/run.ts
|
|
4028
4106
|
/**
|
|
4029
4107
|
* Deserializes the error property in a workflow result back to an Error instance.
|
|
@@ -7859,6 +7937,21 @@ var MastraClient = class extends BaseResource {
|
|
|
7859
7937
|
return new Vector(this.options, vectorName);
|
|
7860
7938
|
}
|
|
7861
7939
|
/**
|
|
7940
|
+
* Lists the Knowledge instances registered on the server
|
|
7941
|
+
* @returns Promise containing each instance's application key and id
|
|
7942
|
+
*/
|
|
7943
|
+
listKnowledge() {
|
|
7944
|
+
return this.request("/knowledge");
|
|
7945
|
+
}
|
|
7946
|
+
/**
|
|
7947
|
+
* Gets read-only access to a registered Knowledge instance
|
|
7948
|
+
* @param knowledgeKey - Application key the instance is registered under
|
|
7949
|
+
* @returns Knowledge resource
|
|
7950
|
+
*/
|
|
7951
|
+
getKnowledge(knowledgeKey) {
|
|
7952
|
+
return new Knowledge(this.options, knowledgeKey);
|
|
7953
|
+
}
|
|
7954
|
+
/**
|
|
7862
7955
|
* Retrieves logs
|
|
7863
7956
|
* @param params - Parameters for filtering logs
|
|
7864
7957
|
* @returns Promise containing array of log messages
|