assistant-cloud 0.2.2 → 0.2.3
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/README.md +2 -2
- package/dist/AssistantCloud.d.ts +15 -17
- package/dist/AssistantCloud.d.ts.map +1 -1
- package/dist/AssistantCloud.js +7 -2
- package/dist/AssistantCloud.js.map +1 -1
- package/dist/AssistantCloudAPI.d.ts +69 -66
- package/dist/AssistantCloudAPI.d.ts.map +1 -1
- package/dist/AssistantCloudAPI.js.map +1 -1
- package/dist/AssistantCloudAuthStrategy.d.ts +23 -25
- package/dist/AssistantCloudAuthStrategy.d.ts.map +1 -1
- package/dist/AssistantCloudAuthTokens.d.ts +6 -7
- package/dist/AssistantCloudAuthTokens.d.ts.map +1 -1
- package/dist/AssistantCloudEvents.d.ts +32 -25
- package/dist/AssistantCloudEvents.d.ts.map +1 -1
- package/dist/AssistantCloudEvents.js +65 -16
- package/dist/AssistantCloudEvents.js.map +1 -1
- package/dist/AssistantCloudFiles.d.ts +25 -26
- package/dist/AssistantCloudFiles.d.ts.map +1 -1
- package/dist/AssistantCloudProjectThreadMessages.d.ts +10 -11
- package/dist/AssistantCloudProjectThreadMessages.d.ts.map +1 -1
- package/dist/AssistantCloudProjectThreads.d.ts +11 -12
- package/dist/AssistantCloudProjectThreads.d.ts.map +1 -1
- package/dist/AssistantCloudProjects.d.ts +3 -5
- package/dist/AssistantCloudProjects.d.ts.map +1 -1
- package/dist/AssistantCloudRuns.d.ts +65 -53
- package/dist/AssistantCloudRuns.d.ts.map +1 -1
- package/dist/AssistantCloudRuns.js +9 -4
- package/dist/AssistantCloudRuns.js.map +1 -1
- package/dist/AssistantCloudScores.d.ts +17 -19
- package/dist/AssistantCloudScores.d.ts.map +1 -1
- package/dist/AssistantCloudThreadMessages.d.ts +33 -31
- package/dist/AssistantCloudThreadMessages.d.ts.map +1 -1
- package/dist/AssistantCloudThreadMessages.js +9 -2
- package/dist/AssistantCloudThreadMessages.js.map +1 -1
- package/dist/AssistantCloudThreads.d.ts +37 -38
- package/dist/AssistantCloudThreads.d.ts.map +1 -1
- package/dist/CloudEngagementReporter.d.ts +53 -54
- package/dist/CloudEngagementReporter.d.ts.map +1 -1
- package/dist/CloudEngagementReporter.js +4 -1
- package/dist/CloudEngagementReporter.js.map +1 -1
- package/dist/CloudMessagePersistence.d.ts +55 -56
- package/dist/CloudMessagePersistence.d.ts.map +1 -1
- package/dist/CloudMessagePersistence.js +3 -0
- package/dist/CloudMessagePersistence.js.map +1 -1
- package/dist/CloudRunReporter.d.ts +6 -8
- package/dist/CloudRunReporter.d.ts.map +1 -1
- package/dist/FormattedCloudPersistence.d.ts +34 -36
- package/dist/FormattedCloudPersistence.d.ts.map +1 -1
- package/dist/ai-sdk/index.d.ts +10 -12
- package/dist/ai-sdk/index.d.ts.map +1 -1
- package/dist/cloudResponse.d.ts +2 -4
- package/dist/cloudResponse.d.ts.map +1 -1
- package/dist/generateThreadTitle.d.ts +8 -10
- package/dist/generateThreadTitle.d.ts.map +1 -1
- package/dist/index.d.ts +18 -17
- package/dist/index.d.ts.map +1 -0
- package/dist/instrumentMcpSampling.d.ts +30 -32
- package/dist/instrumentMcpSampling.d.ts.map +1 -1
- package/dist/runTelemetry.d.ts +86 -78
- package/dist/runTelemetry.d.ts.map +1 -1
- package/dist/runTelemetry.js +57 -15
- package/dist/runTelemetry.js.map +1 -1
- package/dist/telemetry/index.d.ts +13 -15
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/src/AssistantCloud.ts +17 -2
- package/src/AssistantCloudAPI.ts +4 -0
- package/src/AssistantCloudEvents.test.ts +116 -0
- package/src/AssistantCloudEvents.ts +81 -20
- package/src/AssistantCloudRuns.ts +35 -5
- package/src/AssistantCloudThreadMessages.ts +21 -1
- package/src/BackendTranscriptCopy.test.ts +79 -0
- package/src/CloudEngagementReporter.ts +9 -3
- package/src/CloudMessagePersistence.ts +4 -0
- package/src/ai-sdk/index.test.ts +2 -2
- package/src/runTelemetry.test.ts +226 -2
- package/src/runTelemetry.ts +121 -17
- package/src/tests/AssistantCloud.test.ts +22 -0
- package/src/tests/AssistantCloudRuns.test.ts +28 -0
- package/src/tests/CloudEngagementReporter.test.ts +45 -0
- package/src/tests/CloudRunReporter.test.ts +14 -2
- package/dist/tests/setup.d.ts +0 -1
- package/dist/tests/setup.js +0 -7
- package/dist/tests/setup.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudMessagePersistence.js","names":[],"sources":["../src/CloudMessagePersistence.ts"],"sourcesContent":["import type { ReadonlyJSONObject } from \"assistant-stream/utils\";\nimport type { AssistantCloud } from \"./AssistantCloud\";\nimport type { CloudMessage } from \"./AssistantCloudThreadMessages\";\n\nconst CLOUD_MESSAGE_PAGE_SIZE = 200;\n\n/**\n * Appends, updates and loads cloud messages while mapping local ids to cloud\n * ids and chaining parent_id. A parent that is still being created is awaited,\n * so concurrent appends land under the right parent.\n */\nexport class CloudMessagePersistence {\n private idMapping = new Map<string, string | Promise<string>>();\n private getCloud: () => AssistantCloud;\n\n constructor(cloud: AssistantCloud);\n constructor(getCloud: () => AssistantCloud);\n constructor(cloud: AssistantCloud | (() => AssistantCloud)) {\n this.getCloud = typeof cloud === \"function\" ? cloud : () => cloud;\n }\n\n /**\n * Persist a message to the cloud.\n *\n * @param threadId - Remote thread ID\n * @param messageId - Local message ID (used for tracking)\n * @param parentId - Local parent message ID (or null for first message)\n * @param format - Message format (e.g., \"aui/v0\", \"ai-sdk/v6\")\n * @param content - Message content (format-specific)\n */\n async append(\n threadId: string,\n messageId: string,\n parentId: string | null,\n format: string,\n content: ReadonlyJSONObject,\n ): Promise<void> {\n const cloud = this.getCloud();\n const existing = this.idMapping.get(messageId);\n if (existing instanceof Promise) {\n await existing;\n return;\n }\n\n const task = (async () => {\n const parentEntry = parentId ? this.idMapping.get(parentId) : undefined;\n const resolvedParentId = parentId\n ? ((await parentEntry) ?? parentId)\n : null;\n const { message_id } = await cloud.threads.messages.create(threadId, {\n parent_id: resolvedParentId,\n format,\n content,\n });\n return message_id;\n })();\n\n this.idMapping.set(messageId, task);\n try {\n const remoteId = await task;\n if (this.idMapping.get(messageId) === task) {\n this.idMapping.set(messageId, remoteId);\n }\n } catch (err) {\n if (this.idMapping.get(messageId) === task) {\n this.idMapping.delete(messageId);\n }\n throw err;\n }\n }\n\n /**\n * Update an already-persisted message in the cloud.\n */\n async update(\n threadId: string,\n messageId: string,\n _format: string,\n content: ReadonlyJSONObject,\n ): Promise<void> {\n const cloud = this.getCloud();\n const remoteId = await this.getRemoteId(messageId);\n if (!remoteId) {\n console.warn(\n `Skipping update for message ${messageId}: no remote id is mapped.`,\n );\n return;\n }\n await cloud.threads.messages.update(threadId, remoteId, { content });\n }\n\n /**\n * Check if a message has been persisted (or is currently being persisted).\n */\n isPersisted(messageId: string): boolean {\n return this.idMapping.has(messageId);\n }\n\n /**\n * Get the remote ID for a local message ID (resolved).\n * Returns undefined if not persisted.\n */\n async getRemoteId(messageId: string): Promise<string | undefined> {\n const entry = this.idMapping.get(messageId);\n if (!entry) return undefined;\n return entry;\n }\n\n getResolvedRemoteId(messageId: string): string | undefined {\n const entry = this.idMapping.get(messageId);\n return typeof entry === \"string\" ? entry : undefined;\n }\n\n /**\n * Load messages from the cloud and populate the ID mapping.\n *\n * The list endpoint caps a response at 200 rows, so pages are followed by\n * message ID cursor until a short page and concatenated in server order.\n *\n * The ID mapping is populated so that `isPersisted()` returns true for\n * loaded messages, preventing re-persistence of already-stored messages.\n *\n * A loaded ID that an append already maps keeps the remote ID from that append, and falls back to the loaded ID if the append fails.\n *\n * @param threadId - Remote thread ID\n * @param format - Optional format filter\n * @returns Array of cloud messages\n */\n async load(threadId: string, format?: string) {\n const idMapping = this.idMapping;\n const cloud = this.getCloud();\n const messages: CloudMessage[] = [];\n const seen = new Set<string>();\n let after: string | undefined;\n\n while (true) {\n const page = await cloud.threads.messages.list(threadId, {\n ...(format ? { format } : undefined),\n limit: CLOUD_MESSAGE_PAGE_SIZE,\n ...(after ? { after } : undefined),\n });\n const last = page.messages.at(-1);\n if (!last) break;\n\n // A cursor the server cannot resolve drops the keyset filter and replays\n // an earlier page, so already-seen rows end the walk instead of repeating.\n const fresh = page.messages.filter((m) => !seen.has(m.id));\n if (fresh.length === 0) break;\n for (const m of fresh) seen.add(m.id);\n\n messages.push(...fresh);\n if (page.messages.length < CLOUD_MESSAGE_PAGE_SIZE) break;\n after = last.id;\n }\n\n if (this.idMapping === idMapping) {\n for (const m of messages) {\n const entry = idMapping.get(m.id);\n if (entry === undefined) {\n idMapping.set(m.id, m.id);\n } else if (entry instanceof Promise) {\n void entry.catch(() => {\n const current = idMapping.get(m.id);\n if (current === undefined || current === entry) {\n idMapping.set(m.id, m.id);\n }\n });\n }\n }\n }\n return messages;\n }\n\n /**\n * Reset the ID mapping (call when switching threads).\n *\n * Pending `load()` and `append()` calls are not cancelled and still settle\n * normally, but their results no longer populate the ID mapping.\n */\n reset() {\n this.idMapping = new Map();\n }\n}\n"],"mappings":";AAIA,MAAM,0BAA0B;;;;;;AAOhC,IAAa,0BAAb,MAAqC;CACnC,4BAAoB,IAAI,IAAsC;CAC9D;CAIA,YAAY,OAAgD;EAC1D,KAAK,WAAW,OAAO,UAAU,aAAa,cAAc;CAC9D;;;;;;;;;;CAWA,MAAM,OACJ,UACA,WACA,UACA,QACA,SACe;EACf,MAAM,QAAQ,KAAK,SAAS;EAC5B,MAAM,WAAW,KAAK,UAAU,IAAI,SAAS;EAC7C,IAAI,oBAAoB,SAAS;GAC/B,MAAM;GACN;EACF;EAEA,MAAM,QAAQ,YAAY;GACxB,MAAM,cAAc,WAAW,KAAK,UAAU,IAAI,QAAQ,IAAI,KAAA;GAC9D,MAAM,mBAAmB,WACnB,MAAM,eAAgB,WACxB;GACJ,MAAM,EAAE,eAAe,MAAM,MAAM,QAAQ,SAAS,OAA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AE,MAAM,IAAI,KAAA;GAC1B,CAAC;GACD,MAAM,OAAO,KAAK,SAAS,GAAG,EAAE;GAChC,IAAI,CAAC,MAAM;GAIX,MAAM,QAAQ,KAAK,SAAS,QAAQ,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;GACzD,IAAI,MAAM,WAAW,GAAG;GACxB,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,EAAE,EAAE;GAEpC,SAAS,KAAK,GAAG,KAAK;GACtB,IAAI,KAAK,SAAS,SAAS,yBAAyB;GACpD,QAAQ,KAAK;EACf;EAEA,IAAI,KAAK,cAAc,WACrB,KAAK,MAAM,KAAK,UAAU;GACxB,MAAM,QAAQ,UAAU,IAAI,EAAE,EAAE;GAChC,IAAI,UAAU,KAAA,GACZ,UAAU,IAAI,EAAE,IAAI,EAAE,EAAE;QACnB,IAAI,iBAAiB,SAC1B,MAAW,YAAY;IACrB,MAAM,UAAU,UAAU,IAAI,EAAE,EAAE;IAClC,IAAI,YAAY,KAAA,KAAa,YAAY,OACvC,UAAU,IAAI,EAAE,IAAI,EAAE,EAAE;GAE5B,CAAC;EAEL;EAEF,OAAO;CACT;;;;;;;CAQA,QAAQ;EACN,KAAK,4BAAY,IAAI,IAAI;CAC3B;AACF"}
|
|
1
|
+
{"version":3,"file":"CloudMessagePersistence.js","names":[],"sources":["../src/CloudMessagePersistence.ts"],"sourcesContent":["import type { ReadonlyJSONObject } from \"assistant-stream/utils\";\nimport type { AssistantCloud } from \"./AssistantCloud\";\nimport type { CloudMessage } from \"./AssistantCloudThreadMessages\";\n\nconst CLOUD_MESSAGE_PAGE_SIZE = 200;\n\n/**\n * Appends, updates and loads cloud messages while mapping local ids to cloud\n * ids and chaining parent_id. A parent that is still being created is awaited,\n * so concurrent appends land under the right parent.\n */\nexport class CloudMessagePersistence {\n private idMapping = new Map<string, string | Promise<string>>();\n private getCloud: () => AssistantCloud;\n\n constructor(cloud: AssistantCloud);\n constructor(getCloud: () => AssistantCloud);\n constructor(cloud: AssistantCloud | (() => AssistantCloud)) {\n this.getCloud = typeof cloud === \"function\" ? cloud : () => cloud;\n }\n\n /**\n * Persist a message to the cloud.\n *\n * @param threadId - Remote thread ID\n * @param messageId - Local message ID (used for tracking)\n * @param parentId - Local parent message ID (or null for first message)\n * @param format - Message format (e.g., \"aui/v0\", \"ai-sdk/v6\")\n * @param content - Message content (format-specific)\n */\n async append(\n threadId: string,\n messageId: string,\n parentId: string | null,\n format: string,\n content: ReadonlyJSONObject,\n ): Promise<void> {\n const cloud = this.getCloud();\n const existing = this.idMapping.get(messageId);\n if (existing instanceof Promise) {\n await existing;\n return;\n }\n\n const task = (async () => {\n const parentEntry = parentId ? this.idMapping.get(parentId) : undefined;\n const resolvedParentId = parentId\n ? ((await parentEntry) ?? parentId)\n : null;\n const { message_id } = await cloud.threads.messages.create(threadId, {\n parent_id: resolvedParentId,\n format,\n content,\n });\n return message_id;\n })();\n\n this.idMapping.set(messageId, task);\n try {\n const remoteId = await task;\n if (this.idMapping.get(messageId) === task) {\n this.idMapping.set(messageId, remoteId);\n }\n } catch (err) {\n if (this.idMapping.get(messageId) === task) {\n this.idMapping.delete(messageId);\n }\n throw err;\n }\n }\n\n /**\n * Update an already-persisted message in the cloud.\n */\n async update(\n threadId: string,\n messageId: string,\n _format: string,\n content: ReadonlyJSONObject,\n ): Promise<void> {\n const cloud = this.getCloud();\n const remoteId = await this.getRemoteId(messageId);\n if (!remoteId) {\n console.warn(\n `Skipping update for message ${messageId}: no remote id is mapped.`,\n );\n return;\n }\n await cloud.threads.messages.update(threadId, remoteId, { content });\n }\n\n /**\n * Check if a message has been persisted (or is currently being persisted).\n */\n isPersisted(messageId: string): boolean {\n return this.idMapping.has(messageId);\n }\n\n /**\n * Get the remote ID for a local message ID (resolved).\n * Returns undefined if not persisted.\n */\n async getRemoteId(messageId: string): Promise<string | undefined> {\n const entry = this.idMapping.get(messageId);\n if (!entry) return undefined;\n return entry;\n }\n\n getResolvedRemoteId(messageId: string): string | undefined {\n const entry = this.idMapping.get(messageId);\n return typeof entry === \"string\" ? entry : undefined;\n }\n\n record(localId: string, remoteId: string): void {\n this.idMapping.set(localId, remoteId);\n }\n\n /**\n * Load messages from the cloud and populate the ID mapping.\n *\n * The list endpoint caps a response at 200 rows, so pages are followed by\n * message ID cursor until a short page and concatenated in server order.\n *\n * The ID mapping is populated so that `isPersisted()` returns true for\n * loaded messages, preventing re-persistence of already-stored messages.\n *\n * A loaded ID that an append already maps keeps the remote ID from that append, and falls back to the loaded ID if the append fails.\n *\n * @param threadId - Remote thread ID\n * @param format - Optional format filter\n * @returns Array of cloud messages\n */\n async load(threadId: string, format?: string) {\n const idMapping = this.idMapping;\n const cloud = this.getCloud();\n const messages: CloudMessage[] = [];\n const seen = new Set<string>();\n let after: string | undefined;\n\n while (true) {\n const page = await cloud.threads.messages.list(threadId, {\n ...(format ? { format } : undefined),\n limit: CLOUD_MESSAGE_PAGE_SIZE,\n ...(after ? { after } : undefined),\n });\n const last = page.messages.at(-1);\n if (!last) break;\n\n // A cursor the server cannot resolve drops the keyset filter and replays\n // an earlier page, so already-seen rows end the walk instead of repeating.\n const fresh = page.messages.filter((m) => !seen.has(m.id));\n if (fresh.length === 0) break;\n for (const m of fresh) seen.add(m.id);\n\n messages.push(...fresh);\n if (page.messages.length < CLOUD_MESSAGE_PAGE_SIZE) break;\n after = last.id;\n }\n\n if (this.idMapping === idMapping) {\n for (const m of messages) {\n const entry = idMapping.get(m.id);\n if (entry === undefined) {\n idMapping.set(m.id, m.id);\n } else if (entry instanceof Promise) {\n void entry.catch(() => {\n const current = idMapping.get(m.id);\n if (current === undefined || current === entry) {\n idMapping.set(m.id, m.id);\n }\n });\n }\n }\n }\n return messages;\n }\n\n /**\n * Reset the ID mapping (call when switching threads).\n *\n * Pending `load()` and `append()` calls are not cancelled and still settle\n * normally, but their results no longer populate the ID mapping.\n */\n reset() {\n this.idMapping = new Map();\n }\n}\n"],"mappings":";AAIA,MAAM,0BAA0B;;;;;;AAOhC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AAE,EAAE;GAE5B,CAAC;EAEL;EAEF,OAAO;CACT;;;;;;;CAQA,QAAQ;EACN,KAAK,4BAAY,IAAI,IAAI;CAC3B;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
//#region src/CloudRunReporter.d.ts
|
|
1
|
+
import type { AssistantCloud } from "./AssistantCloud.js";
|
|
2
|
+
import { type RunReportInit } from "./runTelemetry.js";
|
|
4
3
|
export type CloudRunReportInit = Omit<RunReportInit, "telemetry">;
|
|
5
4
|
/**
|
|
6
5
|
* Sends run reports the way every client integration has to: nothing while
|
|
@@ -10,10 +9,9 @@ export type CloudRunReportInit = Omit<RunReportInit, "telemetry">;
|
|
|
10
9
|
* rate-limited attempt releases the key so a later observation can try again.
|
|
11
10
|
*/
|
|
12
11
|
export declare class CloudRunReporter {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
private readonly reported;
|
|
13
|
+
private readonly getCloud;
|
|
14
|
+
constructor(cloud: AssistantCloud | (() => AssistantCloud));
|
|
15
|
+
report(init: CloudRunReportInit, key?: string): Promise<void>;
|
|
17
16
|
}
|
|
18
|
-
//#endregion
|
|
19
17
|
//# sourceMappingURL=CloudRunReporter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudRunReporter.d.ts","
|
|
1
|
+
{"version":3,"file":"CloudRunReporter.d.ts","sourceRoot":"","sources":["../src/CloudRunReporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAAyB;AAEvD,OAAO,EAAmB,KAAK,aAAa,EAAE,0BAAuB;AAErE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAElE;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAEpC,KAAK,EAAE,cAAc,GAAG,CAAC,MAAM,cAAc,CAAC;IAI7C,MAAM,CAAC,IAAI,EAAE,kBAAkB,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAwB3E"}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
2
|
-
//#region src/FormattedCloudPersistence.d.ts
|
|
1
|
+
import type { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
3
2
|
/**
|
|
4
3
|
* Format adapter shape — structurally identical to the MessageFormatAdapter
|
|
5
4
|
* in @assistant-ui/react, but defined here to avoid cross-package type moves.
|
|
6
5
|
* TypeScript's structural typing ensures these are interchangeable.
|
|
7
6
|
*/
|
|
8
7
|
export type MessageFormatAdapter<TMessage, TStorageFormat> = {
|
|
9
|
-
format: string;
|
|
10
|
-
encode(item: {
|
|
11
|
-
parentId: string | null;
|
|
12
|
-
message: TMessage;
|
|
13
|
-
}): TStorageFormat;
|
|
14
|
-
decode(stored: {
|
|
15
|
-
id: string;
|
|
16
|
-
parent_id: string | null;
|
|
17
8
|
format: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
9
|
+
encode(item: {
|
|
10
|
+
parentId: string | null;
|
|
11
|
+
message: TMessage;
|
|
12
|
+
}): TStorageFormat;
|
|
13
|
+
decode(stored: {
|
|
14
|
+
id: string;
|
|
15
|
+
parent_id: string | null;
|
|
16
|
+
format: string;
|
|
17
|
+
content: TStorageFormat;
|
|
18
|
+
}): {
|
|
19
|
+
parentId: string | null;
|
|
20
|
+
message: TMessage;
|
|
21
|
+
};
|
|
22
|
+
getId(message: TMessage): string;
|
|
24
23
|
};
|
|
25
24
|
/**
|
|
26
25
|
* Wraps a CloudMessagePersistence with a MessageFormatAdapter's encode and
|
|
@@ -28,26 +27,25 @@ export type MessageFormatAdapter<TMessage, TStorageFormat> = {
|
|
|
28
27
|
* not need to import the class.
|
|
29
28
|
*/
|
|
30
29
|
export declare const createFormattedPersistence: <TMessage, TStorageFormat>(persistence: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
append: (threadId: string, messageId: string, parentId: string | null, format: string, content: ReadonlyJSONObject) => Promise<void>;
|
|
31
|
+
load: (threadId: string, format?: string) => Promise<any[]>;
|
|
32
|
+
isPersisted: (messageId: string) => boolean;
|
|
33
|
+
update?: (threadId: string, messageId: string, format: string, content: ReadonlyJSONObject) => Promise<void>;
|
|
35
34
|
}, adapter: MessageFormatAdapter<TMessage, TStorageFormat>) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
append: (threadId: string, item: {
|
|
36
|
+
parentId: string | null;
|
|
37
|
+
message: TMessage;
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
update: ((threadId: string, item: {
|
|
40
|
+
parentId: string | null;
|
|
41
|
+
message: TMessage;
|
|
42
|
+
}, messageId: string) => Promise<void>) | undefined;
|
|
43
|
+
load: (threadId: string) => Promise<{
|
|
44
|
+
messages: {
|
|
45
|
+
parentId: string | null;
|
|
46
|
+
message: TMessage;
|
|
47
|
+
}[];
|
|
48
|
+
}>;
|
|
49
|
+
isPersisted: (messageId: string) => boolean;
|
|
51
50
|
};
|
|
52
|
-
//#endregion
|
|
53
51
|
//# sourceMappingURL=FormattedCloudPersistence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormattedCloudPersistence.d.ts","
|
|
1
|
+
{"version":3,"file":"FormattedCloudPersistence.d.ts","sourceRoot":"","sources":["../src/FormattedCloudPersistence.ts"],"names":[],"mappings":"AAA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oBAAoB,CAAC,QAAQ,EAAE,cAAc,CAAC;uBAG3C,MAAM,QACV;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,QAAQ,CAAA;KAAE,KACnD,OAAO,CAAC,IAAI,CAAC;wBAaA,MAAM,QACV;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,QAAQ,CAAA;KAAE,aACzC,MAAM,KAChB,OAAO,CAAC,IAAI,CAAC;qBAUG,MAAM;;sBA1Db,MAAM,GAAG,IAAI;;;;6BA0EJ,MAAM;CAC/B,CAAC"}
|
package/dist/ai-sdk/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MessageFormatAdapter } from "../FormattedCloudPersistence.js";
|
|
3
|
-
import {
|
|
4
|
-
//#region src/ai-sdk/index.d.ts
|
|
1
|
+
import type { UIMessage } from "ai";
|
|
2
|
+
import type { MessageFormatAdapter } from "../FormattedCloudPersistence.js";
|
|
3
|
+
import { type RunMessageTelemetry } from "../runTelemetry.js";
|
|
5
4
|
export type AISDKStorageFormat = Omit<UIMessage, "id">;
|
|
6
5
|
/** The stored form of an AI SDK message: the message without its id. */
|
|
7
6
|
export declare const aiSDKV6FormatAdapter: MessageFormatAdapter<UIMessage, AISDKStorageFormat>;
|
|
@@ -11,13 +10,13 @@ export declare const aiSDKV6FormatAdapter: MessageFormatAdapter<UIMessage, AISDK
|
|
|
11
10
|
* alone, so this shape and the telemetry read from it need nothing from `ai`.
|
|
12
11
|
*/
|
|
13
12
|
export type AISDKMessageLike = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
id?: string | undefined;
|
|
14
|
+
role: string;
|
|
15
|
+
parts: readonly {
|
|
16
|
+
type: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}[];
|
|
19
|
+
metadata?: unknown;
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
23
22
|
* Reads the run report fields out of the assistant messages of one run. A run
|
|
@@ -28,5 +27,4 @@ export type AISDKMessageLike = {
|
|
|
28
27
|
* an integration that observed the finish event overrides it.
|
|
29
28
|
*/
|
|
30
29
|
export declare function extractAISDKRunTelemetry(messages: readonly AISDKMessageLike[]): RunMessageTelemetry | null;
|
|
31
|
-
//#endregion
|
|
32
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai-sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAqC;AAEzE,OAAO,EAKL,KAAK,mBAAmB,EAKzB,2BAAwB;AAEzB,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAEvD,wEAAwE;AACxE,eAAO,MAAM,oBAAoB,EAAE,oBAAoB,CACrD,SAAS,EACT,kBAAkB,CASnB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,SAAS;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,EAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAuGF;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,GACpC,mBAAmB,GAAG,IAAI,CAmE5B"}
|
package/dist/cloudResponse.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
2
|
-
//#region src/cloudResponse.d.ts
|
|
1
|
+
import type { ReadonlyJSONObject } from "assistant-stream/utils";
|
|
3
2
|
export declare class CloudResponseError extends Error {
|
|
4
|
-
|
|
3
|
+
constructor(message: string);
|
|
5
4
|
}
|
|
6
5
|
export declare const readCloudRecord: (value: unknown, field: string) => Record<string, unknown>;
|
|
7
6
|
export declare const readCloudArray: (value: unknown, field: string) => unknown[];
|
|
@@ -14,5 +13,4 @@ export declare const readCloudBoolean: (value: unknown, field: string) => boolea
|
|
|
14
13
|
export declare const readCloudInteger: (value: unknown, field: string) => number;
|
|
15
14
|
export declare const readCloudTimestamp: (value: unknown, field: string) => Date;
|
|
16
15
|
export declare const readCloudJSONObject: (value: unknown, field: string) => ReadonlyJSONObject;
|
|
17
|
-
//#endregion
|
|
18
16
|
//# sourceMappingURL=cloudResponse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudResponse.d.ts","
|
|
1
|
+
{"version":3,"file":"cloudResponse.d.ts","sourceRoot":"","sources":["../src/cloudResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAOD,eAAO,MAAM,eAAe,GAC1B,OAAO,OAAO,EACd,OAAO,MAAM,KACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAKxB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,KAAG,OAAO,EAGrE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,KAAG,MAG/D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,KAAG,MAK/D,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,OAAO,EACd,OAAO,MAAM,KACZ,MAAM,GAAG,IAGX,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,KAAK,CAAC,CAAC,SAAS,SAAS,MAAM,EAAE,EAC7D,OAAO,OAAO,EACd,OAAO,MAAM,EACb,SAAS,CAAC,KACT,CAAC,CAAC,MAAM,CASV,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,OAAO,OAAO,EACd,OAAO,MAAM,KACZ,MAAM,GAAG,IAGX,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,KAAG,OAKhE,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,KAAG,MAGhE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,OAAO,EAAE,OAAO,MAAM,KAAG,IAYlE,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,OAAO,OAAO,EACd,OAAO,MAAM,KACZ,kBAAyE,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { AssistantCloud } from "./AssistantCloud.js";
|
|
2
|
-
//#region src/generateThreadTitle.d.ts
|
|
1
|
+
import type { AssistantCloud } from "./AssistantCloud.js";
|
|
3
2
|
export declare function generateThreadTitle(cloud: AssistantCloud, options: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
threadId: string;
|
|
4
|
+
messages: readonly {
|
|
5
|
+
role: string;
|
|
6
|
+
content: readonly {
|
|
7
|
+
type: "text";
|
|
8
|
+
text: string;
|
|
9
|
+
}[];
|
|
10
10
|
}[];
|
|
11
|
-
}[];
|
|
12
11
|
}): Promise<string | null>;
|
|
13
|
-
//#endregion
|
|
14
12
|
//# sourceMappingURL=generateThreadTitle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateThreadTitle.d.ts","
|
|
1
|
+
{"version":3,"file":"generateThreadTitle.d.ts","sourceRoot":"","sources":["../src/generateThreadTitle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,4BAAyB;AAEvD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE;IACP,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,SAAS;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACpD,EAAE,CAAC;CACL,GACA,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA2BxB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export {
|
|
1
|
+
export type { CloudMessage, AssistantCloudThreadMessageFeedbackBody, AssistantCloudThreadMessageFeedbackResponse, } from "./AssistantCloudThreadMessages.js";
|
|
2
|
+
export type { AssistantCloudTelemetryConfig, SdkIdentity, } from "./AssistantCloudAPI.js";
|
|
3
|
+
export { AssistantCloudEvents, type AssistantCloudEvent, type AssistantCloudEventKind, } from "./AssistantCloudEvents.js";
|
|
4
|
+
export { AssistantCloudScores, type AssistantCloudScoreBody, type AssistantCloudScoreResponse, } from "./AssistantCloudScores.js";
|
|
5
|
+
export type { GeneratePresignedDownloadUrlResponse } from "./AssistantCloudFiles.js";
|
|
6
|
+
export { CloudAPIError } from "./AssistantCloudAPI.js";
|
|
7
|
+
export { CloudResponseError } from "./cloudResponse.js";
|
|
8
|
+
export { generateThreadTitle } from "./generateThreadTitle.js";
|
|
9
|
+
export type { AssistantCloudRunReport } from "./AssistantCloudRuns.js";
|
|
10
|
+
export { createRunReport, createRunTelemetryToolCall, deriveRunOutcome, describeRunError, extractRunTelemetryModelId, normalizeRunTelemetryUsage, truncateRunTelemetryText, type AssistantCloudRunReportToolCall, type RunMessageTelemetry, type RunReportInit, type RunReportOutcome, type RunReportStepInit, type RunTelemetryToolCallInit, type RunTelemetryUsage, type RunTelemetryUsageInit, } from "./runTelemetry.js";
|
|
11
|
+
export { AssistantCloud } from "./AssistantCloud.js";
|
|
12
|
+
export { CloudRunReporter, type CloudRunReportInit } from "./CloudRunReporter.js";
|
|
13
|
+
export { CloudEngagementReporter, type EngagementEventIds, type EngagementIdResolver, } from "./CloudEngagementReporter.js";
|
|
14
|
+
export { readAnonymousRefreshToken } from "./AssistantCloudAuthStrategy.js";
|
|
15
|
+
export { CloudMessagePersistence } from "./CloudMessagePersistence.js";
|
|
16
|
+
export { createFormattedPersistence, type MessageFormatAdapter, } from "./FormattedCloudPersistence.js";
|
|
17
|
+
export { wrapSamplingHandler, createSamplingCollector, type SamplingCallData, type McpSamplingHandler, } from "./instrumentMcpSampling.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,uCAAuC,EACvC,2CAA2C,GAC5C,0CAAuC;AACxC,YAAY,EACV,6BAA6B,EAC7B,WAAW,GACZ,+BAA4B;AAC7B,OAAO,EACL,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,GAC7B,kCAA+B;AAChC,OAAO,EACL,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,GACjC,kCAA+B;AAChC,YAAY,EAAE,oCAAoC,EAAE,iCAA8B;AAClF,OAAO,EAAE,aAAa,EAAE,+BAA4B;AACpD,OAAO,EAAE,kBAAkB,EAAE,2BAAwB;AACrD,OAAO,EAAE,mBAAmB,EAAE,iCAA8B;AAC5D,YAAY,EAAE,uBAAuB,EAAE,gCAA6B;AACpE,OAAO,EACL,eAAe,EACf,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,wBAAwB,EACxB,KAAK,+BAA+B,EACpC,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B,0BAAuB;AACxB,OAAO,EAAE,cAAc,EAAE,4BAAyB;AAClD,OAAO,EAAE,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,8BAA2B;AAC/E,OAAO,EACL,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,qCAAkC;AACnC,OAAO,EAAE,yBAAyB,EAAE,wCAAqC;AACzE,OAAO,EAAE,uBAAuB,EAAE,qCAAkC;AACpE,OAAO,EACL,0BAA0B,EAC1B,KAAK,oBAAoB,GAC1B,uCAAoC;AACrC,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,mCAAgC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/instrumentMcpSampling.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* MCP sampling instrumentation utility.
|
|
4
3
|
*
|
|
@@ -7,39 +6,39 @@
|
|
|
7
6
|
* The captured data can be reported as child generation spans.
|
|
8
7
|
*/
|
|
9
8
|
export type SamplingCallData = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
model_id?: string;
|
|
10
|
+
input_tokens?: number;
|
|
11
|
+
output_tokens?: number;
|
|
12
|
+
reasoning_tokens?: number;
|
|
13
|
+
cached_input_tokens?: number;
|
|
14
|
+
duration_ms?: number;
|
|
16
15
|
};
|
|
17
16
|
export type McpSamplingHandler = (request: McpSamplingRequest) => Promise<McpSamplingResponse>;
|
|
18
17
|
export type McpSamplingRequest = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
method: "sampling/createMessage";
|
|
19
|
+
params: {
|
|
20
|
+
messages: unknown[];
|
|
21
|
+
modelPreferences?: {
|
|
22
|
+
hints?: {
|
|
23
|
+
name?: string;
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
maxTokens?: number;
|
|
27
|
+
[key: string]: unknown;
|
|
26
28
|
};
|
|
27
|
-
maxTokens?: number;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
};
|
|
30
29
|
};
|
|
31
30
|
export type McpSamplingResponse = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
model?: string;
|
|
32
|
+
content: unknown;
|
|
33
|
+
usage?: {
|
|
34
|
+
inputTokens?: number;
|
|
35
|
+
outputTokens?: number;
|
|
36
|
+
promptTokens?: number;
|
|
37
|
+
completionTokens?: number;
|
|
38
|
+
reasoningTokens?: number;
|
|
39
|
+
cachedInputTokens?: number;
|
|
40
|
+
};
|
|
41
|
+
[key: string]: unknown;
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
45
44
|
* Wraps an MCP sampling handler to intercept and measure sampling calls.
|
|
@@ -73,9 +72,8 @@ export declare function wrapSamplingHandler(handler: McpSamplingHandler, onSampl
|
|
|
73
72
|
* ```
|
|
74
73
|
*/
|
|
75
74
|
export declare function createSamplingCollector(): {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
collect: (data: SamplingCallData) => number;
|
|
76
|
+
getCalls: () => SamplingCallData[];
|
|
77
|
+
reset: () => void;
|
|
79
78
|
};
|
|
80
|
-
//#endregion
|
|
81
79
|
//# sourceMappingURL=instrumentMcpSampling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentMcpSampling.d.ts","
|
|
1
|
+
{"version":3,"file":"instrumentMcpSampling.d.ts","sourceRoot":"","sources":["../src/instrumentMcpSampling.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,kBAAkB,KACxB,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAElC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE;QACN,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,gBAAgB,CAAC,EAAE;YAAE,KAAK,CAAC,EAAE;gBAAE,IAAI,CAAC,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,CAAC;QACnD,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;QAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAWF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,kBAAkB,EAC3B,cAAc,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAC/C,kBAAkB,CAoCpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB;oBAGnB,gBAAgB;;;EAMnC"}
|
package/dist/runTelemetry.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { SamplingCallData } from "./instrumentMcpSampling.js";
|
|
2
|
-
import { AssistantCloudRunReport } from "./AssistantCloudRuns.js";
|
|
3
|
-
//#region src/runTelemetry.d.ts
|
|
1
|
+
import type { SamplingCallData } from "./instrumentMcpSampling.js";
|
|
2
|
+
import type { AssistantCloudRunReport } from "./AssistantCloudRuns.js";
|
|
4
3
|
export type AssistantCloudRunReportToolCall = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
tool_name: string;
|
|
5
|
+
tool_call_id: string;
|
|
6
|
+
tool_args?: string;
|
|
7
|
+
tool_result?: string;
|
|
8
|
+
tool_source?: "mcp" | "frontend" | "backend";
|
|
9
|
+
start_ms?: number;
|
|
10
|
+
end_ms?: number;
|
|
11
|
+
sampling_calls?: SamplingCallData[];
|
|
13
12
|
};
|
|
14
13
|
export type RunReportOutcome = "aborted" | "disconnected" | "length" | "content_filter";
|
|
15
14
|
/**
|
|
@@ -17,21 +16,21 @@ export type RunReportOutcome = "aborted" | "disconnected" | "length" | "content_
|
|
|
17
16
|
* applies when the event carries neither a finish reason nor a failure flag.
|
|
18
17
|
*/
|
|
19
18
|
export declare function deriveRunOutcome(input: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
finishReason?: string | undefined;
|
|
20
|
+
isAbort?: boolean | undefined;
|
|
21
|
+
isDisconnect?: boolean | undefined;
|
|
22
|
+
isError?: boolean | undefined;
|
|
24
23
|
}, fallbackStatus?: "completed" | "incomplete"): {
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
status: "completed" | "incomplete" | "error";
|
|
25
|
+
outcome?: RunReportOutcome;
|
|
27
26
|
};
|
|
28
27
|
/**
|
|
29
28
|
* Reads the message and code the runs endpoint stores for a failed run. The
|
|
30
29
|
* code is the error's `code` when it has one, else its class name.
|
|
31
30
|
*/
|
|
32
31
|
export declare function describeRunError(error: unknown): {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
error?: string;
|
|
33
|
+
errorCode?: string;
|
|
35
34
|
};
|
|
36
35
|
/**
|
|
37
36
|
* Clamps a string to the size the runs endpoint accepts for a single span
|
|
@@ -39,16 +38,16 @@ export declare function describeRunError(error: unknown): {
|
|
|
39
38
|
*/
|
|
40
39
|
export declare function truncateRunTelemetryText(value: string): string;
|
|
41
40
|
export type RunTelemetryToolCallInit = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
toolName: string;
|
|
42
|
+
toolCallId: string;
|
|
43
|
+
args?: unknown;
|
|
44
|
+
/**
|
|
45
|
+
* Pre-serialized arguments, used in place of serializing `args`. Values over
|
|
46
|
+
* the span size are clamped before they are included in the report.
|
|
47
|
+
*/
|
|
48
|
+
argsText?: string | undefined;
|
|
49
|
+
result?: unknown;
|
|
50
|
+
toolSource?: "mcp" | "frontend" | "backend" | undefined;
|
|
52
51
|
};
|
|
53
52
|
/**
|
|
54
53
|
* Serializes one tool call into the shape the runs endpoint accepts. An `mcp`
|
|
@@ -65,27 +64,28 @@ export declare function createRunTelemetryToolCall(init: RunTelemetryToolCallIni
|
|
|
65
64
|
*/
|
|
66
65
|
export declare function extractRunTelemetryModelId(metadata: Record<string, unknown> | undefined): string | undefined;
|
|
67
66
|
export type RunTelemetryUsage = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
inputTokens?: number | undefined;
|
|
68
|
+
outputTokens?: number | undefined;
|
|
69
|
+
reasoningTokens?: number | undefined;
|
|
70
|
+
cachedInputTokens?: number | undefined;
|
|
72
71
|
};
|
|
73
72
|
export type RunTelemetryUsageInit = RunTelemetryUsage & {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
promptTokens?: number | undefined;
|
|
74
|
+
completionTokens?: number | undefined;
|
|
75
|
+
inputTokenDetails?: {
|
|
76
|
+
cacheReadTokens?: number;
|
|
77
|
+
};
|
|
78
|
+
outputTokenDetails?: {
|
|
79
|
+
reasoningTokens?: number;
|
|
80
|
+
};
|
|
82
81
|
};
|
|
83
82
|
export type RunReportStepInit = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
usage?: RunTelemetryUsageInit | undefined;
|
|
84
|
+
toolCalls?: AssistantCloudRunReportToolCall[] | undefined;
|
|
85
|
+
startMs?: number | undefined;
|
|
86
|
+
endMs?: number | undefined;
|
|
87
|
+
finishReason?: string | undefined;
|
|
88
|
+
input?: string | undefined;
|
|
89
89
|
};
|
|
90
90
|
/**
|
|
91
91
|
* The run report fields read from the messages of one run, in whichever
|
|
@@ -93,39 +93,48 @@ export type RunReportStepInit = {
|
|
|
93
93
|
* steps, the text, the usage and the model.
|
|
94
94
|
*/
|
|
95
95
|
export type RunMessageTelemetry = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
96
|
+
assistantMessageId?: string;
|
|
97
|
+
status: "completed" | "incomplete";
|
|
98
|
+
toolCalls?: AssistantCloudRunReportToolCall[];
|
|
99
|
+
steps?: RunReportStepInit[];
|
|
100
|
+
totalSteps?: number;
|
|
101
|
+
outputText?: string;
|
|
102
|
+
usage?: RunTelemetryUsage;
|
|
103
|
+
modelId?: string;
|
|
104
|
+
metadata?: Record<string, unknown>;
|
|
105
105
|
};
|
|
106
106
|
export type RunReportInit = {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
107
|
+
threadId: string;
|
|
108
|
+
status: AssistantCloudRunReport["status"];
|
|
109
|
+
outcome?: AssistantCloudRunReport["outcome_type"] | undefined;
|
|
110
|
+
errorCode?: string | undefined;
|
|
111
|
+
error?: string | undefined;
|
|
112
|
+
messageId?: string | undefined;
|
|
113
|
+
traceId?: string | undefined;
|
|
114
|
+
rootSpanId?: string | undefined;
|
|
115
|
+
modelId?: string | undefined;
|
|
116
|
+
provider?: string | undefined;
|
|
117
|
+
usage?: RunTelemetryUsageInit | undefined;
|
|
118
|
+
steps?: RunReportStepInit[] | undefined;
|
|
119
|
+
totalSteps?: number | undefined;
|
|
120
|
+
toolCalls?: AssistantCloudRunReportToolCall[] | undefined;
|
|
121
|
+
durationMs?: number | undefined;
|
|
122
|
+
firstTokenMs?: number | undefined;
|
|
123
|
+
costUsd?: number | undefined;
|
|
124
|
+
costDetails?: {
|
|
125
|
+
input?: number | undefined;
|
|
126
|
+
inputCachedTokens?: number | undefined;
|
|
127
|
+
output?: number | undefined;
|
|
128
|
+
total?: number | undefined;
|
|
129
|
+
} | undefined;
|
|
130
|
+
outputText?: string | undefined;
|
|
131
|
+
attributes?: Record<string, unknown> | undefined;
|
|
132
|
+
metadata?: Record<string, unknown> | undefined;
|
|
133
|
+
telemetry?: {
|
|
134
|
+
environment?: string | undefined;
|
|
135
|
+
release?: string | undefined;
|
|
136
|
+
tags?: readonly string[] | undefined;
|
|
137
|
+
};
|
|
129
138
|
};
|
|
130
139
|
export declare function createRunReport(init: RunReportInit): AssistantCloudRunReport;
|
|
131
140
|
/**
|
|
@@ -135,5 +144,4 @@ export declare function createRunReport(init: RunReportInit): AssistantCloudRunR
|
|
|
135
144
|
* so callers can tell an empty usage object from a zeroed one.
|
|
136
145
|
*/
|
|
137
146
|
export declare function normalizeRunTelemetryUsage(usage: RunTelemetryUsageInit): RunTelemetryUsage | undefined;
|
|
138
|
-
//#endregion
|
|
139
147
|
//# sourceMappingURL=runTelemetry.d.ts.map
|