@amigo-ai/platform-sdk 0.17.1 → 0.17.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/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,9 +62,12 @@ 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`
70
+ - `createSelfService`
67
71
  - `list`
68
72
  - `listAutoPaging`
69
73
  - `get`
package/dist/index.cjs CHANGED
@@ -881,7 +881,7 @@ function resolveScopedPlatformClient(client) {
881
881
 
882
882
  // src/resources/workspaces.ts
883
883
  var WorkspacesResource = class extends WorkspaceScopedResource {
884
- /** Create a new workspace */
884
+ /** Create a new workspace (unauthenticated — no owner membership created) */
885
885
  async create(body) {
886
886
  return extractData(
887
887
  await this.client.POST("/v1/workspaces", {
@@ -889,6 +889,14 @@ var WorkspacesResource = class extends WorkspaceScopedResource {
889
889
  })
890
890
  );
891
891
  }
892
+ /** Create a workspace for the authenticated user and attach owner access */
893
+ async createSelfService(body) {
894
+ return extractData(
895
+ await this.client.POST("/v1/workspaces/self-service", {
896
+ body
897
+ })
898
+ );
899
+ }
892
900
  /** List workspaces accessible to the current API key */
893
901
  async list(params) {
894
902
  return extractData(
@@ -1934,8 +1942,10 @@ var MAX_AUTH_TOKEN_CHARS = 4096;
1934
1942
  var TEXT_STREAM_AUTH_TOKEN_RE = /^[-A-Za-z0-9._+=/:]+$/;
1935
1943
  var WEB_SOCKET_PROTOCOL_TOKEN_RE = /^[!#$%&'*+\-.^_`|~A-Za-z0-9]+$/;
1936
1944
  var ConversationsResource = class extends WorkspaceScopedResource {
1937
- constructor(client, workspaceId2) {
1945
+ agentBaseUrl;
1946
+ constructor(client, workspaceId2, agentBaseUrl) {
1938
1947
  super(client, workspaceId2);
1948
+ this.agentBaseUrl = agentBaseUrl;
1939
1949
  }
1940
1950
  async list(params) {
1941
1951
  return extractData(
@@ -1981,7 +1991,7 @@ var ConversationsResource = class extends WorkspaceScopedResource {
1981
1991
  /** Build the real-time text WebSocket URL for browser or custom clients. */
1982
1992
  textStreamUrl(params) {
1983
1993
  const url = buildTextStreamUrl({
1984
- baseUrl: this.platformBaseUrl,
1994
+ baseUrl: this.agentBaseUrl ?? this.platformBaseUrl,
1985
1995
  workspaceId: this.workspaceId,
1986
1996
  ...params
1987
1997
  });
@@ -2051,21 +2061,23 @@ function parseTextStreamUrlOverride(textStreamUrl) {
2051
2061
  function deriveTextStreamUrl(baseUrl) {
2052
2062
  if (!/^[a-z][a-z\d+.-]*:\/\//i.test(baseUrl)) {
2053
2063
  throw new ConfigurationError(
2054
- "textStreamUrl cannot be derived from a relative baseUrl; pass textStreamUrl explicitly"
2064
+ "textStreamUrl cannot be derived from a relative baseUrl; pass agentBaseUrl or textStreamUrl explicitly"
2055
2065
  );
2056
2066
  }
2057
2067
  const url = new URL(baseUrl);
2058
- if (url.protocol !== "http:" && url.protocol !== "https:") {
2068
+ if (url.protocol === "ws:" || url.protocol === "wss:") {
2069
+ } else if (url.protocol === "http:" || url.protocol === "https:") {
2070
+ url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
2071
+ } else {
2059
2072
  throw new ConfigurationError(
2060
- "textStreamUrl can only be derived from an http or https baseUrl; pass textStreamUrl explicitly"
2073
+ "textStreamUrl can only be derived from an http, https, ws, or wss baseUrl; pass textStreamUrl explicitly"
2061
2074
  );
2062
2075
  }
2063
2076
  if (url.pathname !== "/" && url.pathname !== "") {
2064
2077
  throw new ConfigurationError(
2065
- "textStreamUrl can only be derived from an origin-only http or https baseUrl; pass textStreamUrl explicitly when using path-prefixed gateways"
2078
+ "textStreamUrl can only be derived from an origin-only baseUrl; pass agentBaseUrl as an origin or textStreamUrl explicitly when using path-prefixed gateways"
2066
2079
  );
2067
2080
  }
2068
- url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
2069
2081
  url.pathname = "/agent/text-stream";
2070
2082
  url.search = "";
2071
2083
  url.hash = "";
@@ -3781,6 +3793,7 @@ var DEFAULT_BASE_URL = "https://api.platform.amigo.ai";
3781
3793
  var AmigoClient = class _AmigoClient {
3782
3794
  workspaceId;
3783
3795
  baseUrl;
3796
+ agentBaseUrl;
3784
3797
  workspaces;
3785
3798
  apiKeys;
3786
3799
  agents;
@@ -3831,13 +3844,14 @@ var AmigoClient = class _AmigoClient {
3831
3844
  hooks: config.hooks,
3832
3845
  fetch: config.fetch
3833
3846
  });
3834
- _AmigoClient.hydrate(this, client, config.workspaceId, baseUrl);
3847
+ _AmigoClient.hydrate(this, client, config.workspaceId, baseUrl, config.agentBaseUrl);
3835
3848
  }
3836
3849
  withOptions(options) {
3837
3850
  return _AmigoClient.fromPlatformClient(
3838
3851
  scopePlatformClient(this.api, options),
3839
3852
  this.workspaceId,
3840
- this.baseUrl
3853
+ this.baseUrl,
3854
+ this.agentBaseUrl
3841
3855
  );
3842
3856
  }
3843
3857
  async GET(path, ...[init]) {
@@ -3865,15 +3879,16 @@ var AmigoClient = class _AmigoClient {
3865
3879
  allowEmptyBody: true
3866
3880
  });
3867
3881
  }
3868
- static fromPlatformClient(client, workspaceId2, baseUrl) {
3882
+ static fromPlatformClient(client, workspaceId2, baseUrl, agentBaseUrl) {
3869
3883
  const instance = Object.create(_AmigoClient.prototype);
3870
- _AmigoClient.hydrate(instance, client, workspaceId2, baseUrl);
3884
+ _AmigoClient.hydrate(instance, client, workspaceId2, baseUrl, agentBaseUrl);
3871
3885
  return instance;
3872
3886
  }
3873
- static hydrate(target, client, workspaceId2, baseUrl) {
3887
+ static hydrate(target, client, workspaceId2, baseUrl, agentBaseUrl) {
3874
3888
  const mutable = target;
3875
3889
  mutable.workspaceId = workspaceId2;
3876
3890
  mutable.baseUrl = baseUrl;
3891
+ mutable.agentBaseUrl = agentBaseUrl;
3877
3892
  target.api = client;
3878
3893
  mutable.workspaces = new WorkspacesResource(client, workspaceId2);
3879
3894
  mutable.apiKeys = new ApiKeysResource(client, workspaceId2);
@@ -3887,7 +3902,7 @@ var AmigoClient = class _AmigoClient {
3887
3902
  mutable.dataSources = new DataSourcesResource(client, workspaceId2);
3888
3903
  mutable.world = new WorldResource(client, workspaceId2);
3889
3904
  mutable.calls = new CallsResource(client, workspaceId2);
3890
- mutable.conversations = new ConversationsResource(client, workspaceId2);
3905
+ mutable.conversations = new ConversationsResource(client, workspaceId2, agentBaseUrl);
3891
3906
  mutable.phoneNumbers = new PhoneNumbersResource(client, workspaceId2);
3892
3907
  mutable.integrations = new IntegrationsResource(client, workspaceId2);
3893
3908
  mutable.analytics = new AnalyticsResource(client, workspaceId2);