@amigo-ai/platform-sdk 0.17.1 → 0.17.2
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/api.md +3 -0
- package/dist/index.cjs +20 -13
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -13
- package/dist/index.mjs.map +2 -2
- package/dist/resources/conversations.js +14 -7
- package/dist/resources/conversations.js.map +1 -1
- package/dist/types/index.d.cts +23 -0
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +23 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/resources/conversations.d.ts +2 -1
- package/dist/types/resources/conversations.d.ts.map +1 -1
- package/package.json +1 -1
package/api.md
CHANGED
|
@@ -19,6 +19,7 @@ Configuration fields:
|
|
|
19
19
|
- `headers?: HeadersOptions`
|
|
20
20
|
- `hooks?: ClientHooks`
|
|
21
21
|
- `fetch?: typeof globalThis.fetch`
|
|
22
|
+
- `agentBaseUrl?: string`
|
|
22
23
|
|
|
23
24
|
Instance fields:
|
|
24
25
|
|
|
@@ -61,6 +62,8 @@ Notes:
|
|
|
61
62
|
|
|
62
63
|
All workspace-scoped resources also expose `withOptions(options)`.
|
|
63
64
|
|
|
65
|
+
### `agentBaseUrl`
|
|
66
|
+
|
|
64
67
|
### `workspaces`
|
|
65
68
|
|
|
66
69
|
- `create`
|
package/dist/index.cjs
CHANGED
|
@@ -1934,8 +1934,10 @@ var MAX_AUTH_TOKEN_CHARS = 4096;
|
|
|
1934
1934
|
var TEXT_STREAM_AUTH_TOKEN_RE = /^[-A-Za-z0-9._+=/:]+$/;
|
|
1935
1935
|
var WEB_SOCKET_PROTOCOL_TOKEN_RE = /^[!#$%&'*+\-.^_`|~A-Za-z0-9]+$/;
|
|
1936
1936
|
var ConversationsResource = class extends WorkspaceScopedResource {
|
|
1937
|
-
|
|
1937
|
+
agentBaseUrl;
|
|
1938
|
+
constructor(client, workspaceId2, agentBaseUrl) {
|
|
1938
1939
|
super(client, workspaceId2);
|
|
1940
|
+
this.agentBaseUrl = agentBaseUrl;
|
|
1939
1941
|
}
|
|
1940
1942
|
async list(params) {
|
|
1941
1943
|
return extractData(
|
|
@@ -1981,7 +1983,7 @@ var ConversationsResource = class extends WorkspaceScopedResource {
|
|
|
1981
1983
|
/** Build the real-time text WebSocket URL for browser or custom clients. */
|
|
1982
1984
|
textStreamUrl(params) {
|
|
1983
1985
|
const url = buildTextStreamUrl({
|
|
1984
|
-
baseUrl: this.platformBaseUrl,
|
|
1986
|
+
baseUrl: this.agentBaseUrl ?? this.platformBaseUrl,
|
|
1985
1987
|
workspaceId: this.workspaceId,
|
|
1986
1988
|
...params
|
|
1987
1989
|
});
|
|
@@ -2051,21 +2053,23 @@ function parseTextStreamUrlOverride(textStreamUrl) {
|
|
|
2051
2053
|
function deriveTextStreamUrl(baseUrl) {
|
|
2052
2054
|
if (!/^[a-z][a-z\d+.-]*:\/\//i.test(baseUrl)) {
|
|
2053
2055
|
throw new ConfigurationError(
|
|
2054
|
-
"textStreamUrl cannot be derived from a relative baseUrl; pass textStreamUrl explicitly"
|
|
2056
|
+
"textStreamUrl cannot be derived from a relative baseUrl; pass agentBaseUrl or textStreamUrl explicitly"
|
|
2055
2057
|
);
|
|
2056
2058
|
}
|
|
2057
2059
|
const url = new URL(baseUrl);
|
|
2058
|
-
if (url.protocol
|
|
2060
|
+
if (url.protocol === "ws:" || url.protocol === "wss:") {
|
|
2061
|
+
} else if (url.protocol === "http:" || url.protocol === "https:") {
|
|
2062
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
2063
|
+
} else {
|
|
2059
2064
|
throw new ConfigurationError(
|
|
2060
|
-
"textStreamUrl can only be derived from an http or
|
|
2065
|
+
"textStreamUrl can only be derived from an http, https, ws, or wss baseUrl; pass textStreamUrl explicitly"
|
|
2061
2066
|
);
|
|
2062
2067
|
}
|
|
2063
2068
|
if (url.pathname !== "/" && url.pathname !== "") {
|
|
2064
2069
|
throw new ConfigurationError(
|
|
2065
|
-
"textStreamUrl can only be derived from an origin-only
|
|
2070
|
+
"textStreamUrl can only be derived from an origin-only baseUrl; pass agentBaseUrl as an origin or textStreamUrl explicitly when using path-prefixed gateways"
|
|
2066
2071
|
);
|
|
2067
2072
|
}
|
|
2068
|
-
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
2069
2073
|
url.pathname = "/agent/text-stream";
|
|
2070
2074
|
url.search = "";
|
|
2071
2075
|
url.hash = "";
|
|
@@ -3781,6 +3785,7 @@ var DEFAULT_BASE_URL = "https://api.platform.amigo.ai";
|
|
|
3781
3785
|
var AmigoClient = class _AmigoClient {
|
|
3782
3786
|
workspaceId;
|
|
3783
3787
|
baseUrl;
|
|
3788
|
+
agentBaseUrl;
|
|
3784
3789
|
workspaces;
|
|
3785
3790
|
apiKeys;
|
|
3786
3791
|
agents;
|
|
@@ -3831,13 +3836,14 @@ var AmigoClient = class _AmigoClient {
|
|
|
3831
3836
|
hooks: config.hooks,
|
|
3832
3837
|
fetch: config.fetch
|
|
3833
3838
|
});
|
|
3834
|
-
_AmigoClient.hydrate(this, client, config.workspaceId, baseUrl);
|
|
3839
|
+
_AmigoClient.hydrate(this, client, config.workspaceId, baseUrl, config.agentBaseUrl);
|
|
3835
3840
|
}
|
|
3836
3841
|
withOptions(options) {
|
|
3837
3842
|
return _AmigoClient.fromPlatformClient(
|
|
3838
3843
|
scopePlatformClient(this.api, options),
|
|
3839
3844
|
this.workspaceId,
|
|
3840
|
-
this.baseUrl
|
|
3845
|
+
this.baseUrl,
|
|
3846
|
+
this.agentBaseUrl
|
|
3841
3847
|
);
|
|
3842
3848
|
}
|
|
3843
3849
|
async GET(path, ...[init]) {
|
|
@@ -3865,15 +3871,16 @@ var AmigoClient = class _AmigoClient {
|
|
|
3865
3871
|
allowEmptyBody: true
|
|
3866
3872
|
});
|
|
3867
3873
|
}
|
|
3868
|
-
static fromPlatformClient(client, workspaceId2, baseUrl) {
|
|
3874
|
+
static fromPlatformClient(client, workspaceId2, baseUrl, agentBaseUrl) {
|
|
3869
3875
|
const instance = Object.create(_AmigoClient.prototype);
|
|
3870
|
-
_AmigoClient.hydrate(instance, client, workspaceId2, baseUrl);
|
|
3876
|
+
_AmigoClient.hydrate(instance, client, workspaceId2, baseUrl, agentBaseUrl);
|
|
3871
3877
|
return instance;
|
|
3872
3878
|
}
|
|
3873
|
-
static hydrate(target, client, workspaceId2, baseUrl) {
|
|
3879
|
+
static hydrate(target, client, workspaceId2, baseUrl, agentBaseUrl) {
|
|
3874
3880
|
const mutable = target;
|
|
3875
3881
|
mutable.workspaceId = workspaceId2;
|
|
3876
3882
|
mutable.baseUrl = baseUrl;
|
|
3883
|
+
mutable.agentBaseUrl = agentBaseUrl;
|
|
3877
3884
|
target.api = client;
|
|
3878
3885
|
mutable.workspaces = new WorkspacesResource(client, workspaceId2);
|
|
3879
3886
|
mutable.apiKeys = new ApiKeysResource(client, workspaceId2);
|
|
@@ -3887,7 +3894,7 @@ var AmigoClient = class _AmigoClient {
|
|
|
3887
3894
|
mutable.dataSources = new DataSourcesResource(client, workspaceId2);
|
|
3888
3895
|
mutable.world = new WorldResource(client, workspaceId2);
|
|
3889
3896
|
mutable.calls = new CallsResource(client, workspaceId2);
|
|
3890
|
-
mutable.conversations = new ConversationsResource(client, workspaceId2);
|
|
3897
|
+
mutable.conversations = new ConversationsResource(client, workspaceId2, agentBaseUrl);
|
|
3891
3898
|
mutable.phoneNumbers = new PhoneNumbersResource(client, workspaceId2);
|
|
3892
3899
|
mutable.integrations = new IntegrationsResource(client, workspaceId2);
|
|
3893
3900
|
mutable.analytics = new AnalyticsResource(client, workspaceId2);
|