@distri/core 0.3.2 → 0.3.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/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +63 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -239,6 +239,15 @@ declare class DistriClient {
|
|
|
239
239
|
* Set the client ID for embed token issuance.
|
|
240
240
|
*/
|
|
241
241
|
set clientId(value: string | undefined);
|
|
242
|
+
/**
|
|
243
|
+
* Get the configured workspace ID.
|
|
244
|
+
*/
|
|
245
|
+
get workspaceId(): string | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Set the workspace ID for multi-tenant support.
|
|
248
|
+
* Updates the X-Workspace-Id header for all subsequent requests.
|
|
249
|
+
*/
|
|
250
|
+
set workspaceId(value: string | undefined);
|
|
242
251
|
/**
|
|
243
252
|
* Create a client with default cloud configuration.
|
|
244
253
|
*
|
|
@@ -361,6 +370,10 @@ declare class DistriClient {
|
|
|
361
370
|
* Send a streaming message to an agent
|
|
362
371
|
*/
|
|
363
372
|
sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData>;
|
|
373
|
+
/**
|
|
374
|
+
* Extract a user-friendly error message from potentially nested errors
|
|
375
|
+
*/
|
|
376
|
+
private extractErrorMessage;
|
|
364
377
|
/**
|
|
365
378
|
* Get task details
|
|
366
379
|
*/
|
|
@@ -558,7 +571,7 @@ declare class Agent {
|
|
|
558
571
|
/**
|
|
559
572
|
* Message roles supported by Distri
|
|
560
573
|
*/
|
|
561
|
-
type MessageRole = 'system' | 'assistant' | 'user' | 'tool';
|
|
574
|
+
type MessageRole = 'system' | 'assistant' | 'user' | 'tool' | 'developer';
|
|
562
575
|
/**
|
|
563
576
|
* Distri-specific message structure with parts
|
|
564
577
|
*/
|
|
@@ -1046,6 +1059,11 @@ interface DistriClientConfig {
|
|
|
1046
1059
|
* Client ID from Distri Cloud.
|
|
1047
1060
|
*/
|
|
1048
1061
|
clientId?: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Workspace ID for multi-tenant support (Distri Cloud).
|
|
1064
|
+
* When provided, all requests will include X-Workspace-Id header.
|
|
1065
|
+
*/
|
|
1066
|
+
workspaceId?: string;
|
|
1049
1067
|
}
|
|
1050
1068
|
interface LLMResponse {
|
|
1051
1069
|
finish_reason: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -239,6 +239,15 @@ declare class DistriClient {
|
|
|
239
239
|
* Set the client ID for embed token issuance.
|
|
240
240
|
*/
|
|
241
241
|
set clientId(value: string | undefined);
|
|
242
|
+
/**
|
|
243
|
+
* Get the configured workspace ID.
|
|
244
|
+
*/
|
|
245
|
+
get workspaceId(): string | undefined;
|
|
246
|
+
/**
|
|
247
|
+
* Set the workspace ID for multi-tenant support.
|
|
248
|
+
* Updates the X-Workspace-Id header for all subsequent requests.
|
|
249
|
+
*/
|
|
250
|
+
set workspaceId(value: string | undefined);
|
|
242
251
|
/**
|
|
243
252
|
* Create a client with default cloud configuration.
|
|
244
253
|
*
|
|
@@ -361,6 +370,10 @@ declare class DistriClient {
|
|
|
361
370
|
* Send a streaming message to an agent
|
|
362
371
|
*/
|
|
363
372
|
sendMessageStream(agentId: string, params: MessageSendParams): AsyncGenerator<A2AStreamEventData>;
|
|
373
|
+
/**
|
|
374
|
+
* Extract a user-friendly error message from potentially nested errors
|
|
375
|
+
*/
|
|
376
|
+
private extractErrorMessage;
|
|
364
377
|
/**
|
|
365
378
|
* Get task details
|
|
366
379
|
*/
|
|
@@ -558,7 +571,7 @@ declare class Agent {
|
|
|
558
571
|
/**
|
|
559
572
|
* Message roles supported by Distri
|
|
560
573
|
*/
|
|
561
|
-
type MessageRole = 'system' | 'assistant' | 'user' | 'tool';
|
|
574
|
+
type MessageRole = 'system' | 'assistant' | 'user' | 'tool' | 'developer';
|
|
562
575
|
/**
|
|
563
576
|
* Distri-specific message structure with parts
|
|
564
577
|
*/
|
|
@@ -1046,6 +1059,11 @@ interface DistriClientConfig {
|
|
|
1046
1059
|
* Client ID from Distri Cloud.
|
|
1047
1060
|
*/
|
|
1048
1061
|
clientId?: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Workspace ID for multi-tenant support (Distri Cloud).
|
|
1064
|
+
* When provided, all requests will include X-Workspace-Id header.
|
|
1065
|
+
*/
|
|
1066
|
+
workspaceId?: string;
|
|
1049
1067
|
}
|
|
1050
1068
|
interface LLMResponse {
|
|
1051
1069
|
finish_reason: string;
|
package/dist/index.js
CHANGED
|
@@ -819,6 +819,7 @@ function convertDistriMessageToA2A(distriMessage, context) {
|
|
|
819
819
|
break;
|
|
820
820
|
case "system":
|
|
821
821
|
case "tool":
|
|
822
|
+
case "developer":
|
|
822
823
|
role = "user";
|
|
823
824
|
break;
|
|
824
825
|
default:
|
|
@@ -915,6 +916,9 @@ var _DistriClient = class _DistriClient {
|
|
|
915
916
|
constructor(config) {
|
|
916
917
|
this.agentClients = /* @__PURE__ */ new Map();
|
|
917
918
|
const headers = { ...config.headers };
|
|
919
|
+
if (config.workspaceId) {
|
|
920
|
+
headers["X-Workspace-Id"] = config.workspaceId;
|
|
921
|
+
}
|
|
918
922
|
this.accessToken = config.accessToken;
|
|
919
923
|
this.refreshToken = config.refreshToken;
|
|
920
924
|
this.tokenRefreshSkewMs = config.tokenRefreshSkewMs ?? 6e4;
|
|
@@ -929,7 +933,8 @@ var _DistriClient = class _DistriClient {
|
|
|
929
933
|
headers,
|
|
930
934
|
interceptor: config.interceptor ?? (async (init) => Promise.resolve(init)),
|
|
931
935
|
onTokenRefresh: config.onTokenRefresh,
|
|
932
|
-
clientId: config.clientId
|
|
936
|
+
clientId: config.clientId,
|
|
937
|
+
workspaceId: config.workspaceId
|
|
933
938
|
};
|
|
934
939
|
}
|
|
935
940
|
/**
|
|
@@ -944,6 +949,24 @@ var _DistriClient = class _DistriClient {
|
|
|
944
949
|
set clientId(value) {
|
|
945
950
|
this.config.clientId = value;
|
|
946
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Get the configured workspace ID.
|
|
954
|
+
*/
|
|
955
|
+
get workspaceId() {
|
|
956
|
+
return this.config.workspaceId;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Set the workspace ID for multi-tenant support.
|
|
960
|
+
* Updates the X-Workspace-Id header for all subsequent requests.
|
|
961
|
+
*/
|
|
962
|
+
set workspaceId(value) {
|
|
963
|
+
this.config.workspaceId = value;
|
|
964
|
+
if (value) {
|
|
965
|
+
this.config.headers["X-Workspace-Id"] = value;
|
|
966
|
+
} else {
|
|
967
|
+
delete this.config.headers["X-Workspace-Id"];
|
|
968
|
+
}
|
|
969
|
+
}
|
|
947
970
|
/**
|
|
948
971
|
* Create a client with default cloud configuration.
|
|
949
972
|
*
|
|
@@ -1396,8 +1419,46 @@ var _DistriClient = class _DistriClient {
|
|
|
1396
1419
|
yield* await client.sendMessageStream(params);
|
|
1397
1420
|
} catch (error) {
|
|
1398
1421
|
console.error(error);
|
|
1399
|
-
|
|
1422
|
+
const errorMessage = this.extractErrorMessage(error);
|
|
1423
|
+
throw new DistriError(errorMessage, "STREAM_MESSAGE_ERROR", error);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* Extract a user-friendly error message from potentially nested errors
|
|
1428
|
+
*/
|
|
1429
|
+
extractErrorMessage(error) {
|
|
1430
|
+
if (!error) return "Unknown error occurred";
|
|
1431
|
+
if (typeof error === "object" && error !== null) {
|
|
1432
|
+
const err = error;
|
|
1433
|
+
if (err.error && typeof err.error === "object") {
|
|
1434
|
+
const jsonRpcError = err.error;
|
|
1435
|
+
if (typeof jsonRpcError.message === "string") {
|
|
1436
|
+
return jsonRpcError.message;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
if (err.message && typeof err.message === "string") {
|
|
1440
|
+
return err.message;
|
|
1441
|
+
}
|
|
1442
|
+
if (err.details && typeof err.details === "object") {
|
|
1443
|
+
const details = err.details;
|
|
1444
|
+
if (details.message && typeof details.message === "string") {
|
|
1445
|
+
return details.message;
|
|
1446
|
+
}
|
|
1447
|
+
if (details.error && typeof details.error === "object") {
|
|
1448
|
+
const nestedError = details.error;
|
|
1449
|
+
if (typeof nestedError.message === "string") {
|
|
1450
|
+
return nestedError.message;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
if (err.cause && typeof err.cause === "object") {
|
|
1455
|
+
return this.extractErrorMessage(err.cause);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
if (error instanceof Error) {
|
|
1459
|
+
return error.message;
|
|
1400
1460
|
}
|
|
1461
|
+
return String(error);
|
|
1401
1462
|
}
|
|
1402
1463
|
/**
|
|
1403
1464
|
* Get task details
|