@covia/covia-sdk 1.5.0 → 1.6.0-next.0

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 CHANGED
@@ -467,6 +467,15 @@ declare class SecretManager {
467
467
  delete(name: string): Promise<void>;
468
468
  }
469
469
 
470
+ /**
471
+ * Resolve a non-DID venue id into the ordered list of base URLs that
472
+ * {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
473
+ * honoured as given (trailing slash trimmed, single candidate, no fallback);
474
+ * schemeless inputs (bare host / IP / host:port) pick a scheme by host — local
475
+ * hosts (loopback, private ranges, mDNS) try http then https, public hosts stay
476
+ * https-only. `did:*` ids are resolved separately and are not handled here.
477
+ */
478
+ declare function venueBaseUrlCandidates(venueId: string): string[];
470
479
  declare class Venue implements VenueInterface {
471
480
  baseUrl: string;
472
481
  venueId: string;
@@ -877,7 +886,10 @@ interface AssetPinResult {
877
886
  hash: string;
878
887
  }
879
888
  interface WorkspaceCopyResult {
880
- copied: boolean;
889
+ /** 0.2.x: present and true only if a new parent path was built at the destination. */
890
+ pathCreated?: boolean;
891
+ /** @deprecated pre-0.2.x: constant true. Success is the job status. */
892
+ copied?: boolean;
881
893
  }
882
894
  interface WorkspaceInspectInput {
883
895
  paths: string | string[];
@@ -895,6 +907,9 @@ interface WorkspaceReadResult {
895
907
  exists: boolean;
896
908
  value?: any;
897
909
  truncated?: boolean;
910
+ /** 0.2.x: encoding size in bytes (always present). */
911
+ valueBytes?: number;
912
+ /** @deprecated pre-0.2.x: bytes, only on truncation. Use valueBytes. */
898
913
  size?: number;
899
914
  }
900
915
  interface WorkspaceWriteInput {
@@ -902,20 +917,29 @@ interface WorkspaceWriteInput {
902
917
  value: any;
903
918
  }
904
919
  interface WorkspaceWriteResult {
905
- written: boolean;
920
+ /** 0.2.x: true iff the write built a new parent path; omitted otherwise. */
921
+ pathCreated?: boolean;
922
+ /** @deprecated pre-0.2.x: constant true. Success is the job status. */
923
+ written?: boolean;
906
924
  }
907
925
  interface WorkspaceDeleteInput {
908
926
  path: string;
909
927
  }
910
928
  interface WorkspaceDeleteResult {
911
- deleted: boolean;
929
+ /** @deprecated pre-0.2.x: constant true. 0.2.x returns an empty object (success is the job status). */
930
+ deleted?: boolean;
912
931
  }
913
932
  interface WorkspaceAppendInput {
914
933
  path: string;
915
934
  value: any;
916
935
  }
917
936
  interface WorkspaceAppendResult {
918
- appended: boolean;
937
+ /** 0.2.x: vector element count after the append. */
938
+ newSize?: number;
939
+ /** 0.2.x: true iff a new parent path was built. */
940
+ pathCreated?: boolean;
941
+ /** @deprecated pre-0.2.x: constant true. */
942
+ appended?: boolean;
919
943
  }
920
944
  interface WorkspaceListInput {
921
945
  path?: string;
@@ -925,10 +949,13 @@ interface WorkspaceListInput {
925
949
  interface WorkspaceListResult {
926
950
  exists: boolean;
927
951
  type: string;
928
- count?: number;
952
+ /** 0.2.x: total entries in the collection. */
953
+ totalSize?: number;
929
954
  keys?: string[];
930
955
  values?: any[];
931
956
  offset?: number;
957
+ /** @deprecated pre-0.2.x name for totalSize. */
958
+ count?: number;
932
959
  }
933
960
  interface WorkspaceSliceInput {
934
961
  path: string;
@@ -937,10 +964,13 @@ interface WorkspaceSliceInput {
937
964
  }
938
965
  interface WorkspaceSliceResult {
939
966
  exists: boolean;
940
- type: string;
941
- values: any[];
942
- count: number;
943
- offset: number;
967
+ type?: string;
968
+ values?: any[];
969
+ /** 0.2.x: total entries in the collection. */
970
+ totalSize?: number;
971
+ offset?: number;
972
+ /** @deprecated pre-0.2.x name for totalSize. */
973
+ count?: number;
944
974
  }
945
975
  interface UCANAttenuation {
946
976
  with: string;
@@ -1163,4 +1193,4 @@ declare function decodePublicKey(multikey: string): Uint8Array;
1163
1193
  */
1164
1194
  declare function didFromPublicKey(publicKey: Uint8Array): string;
1165
1195
 
1166
- export { type AdapterInfo, type AdaptersResult, Agent, type AgentCancelTaskInput, type AgentCard, type AgentChatInput, type AgentChatResult, type AgentCompleteTaskResult, type AgentContextInput, type AgentCreateInput, type AgentCreateResult, type AgentDeleteInput, type AgentDeleteResult, type AgentFailTaskResult, type AgentForkInput, type AgentForkResult, type AgentInfoResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentQueryInput, type AgentQueryResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, AssetNotFoundError, type AssetPinResult, Auth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, DataAsset, type FunctionInfo, type FunctionsResult, Grid, GridError, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANIssueInput, type UCANIssueResult, UCANManager, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceDeleteInput, type WorkspaceDeleteResult, type WorkspaceInspectInput, type WorkspaceInspectResult, type WorkspaceListInput, type WorkspaceListResult, WorkspaceManager, type WorkspaceReadInput, type WorkspaceReadResult, type WorkspaceSliceInput, type WorkspaceSliceResult, type WorkspaceWriteInput, type WorkspaceWriteResult, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex };
1196
+ export { type AdapterInfo, type AdaptersResult, Agent, type AgentCancelTaskInput, type AgentCard, type AgentChatInput, type AgentChatResult, type AgentCompleteTaskResult, type AgentContextInput, type AgentCreateInput, type AgentCreateResult, type AgentDeleteInput, type AgentDeleteResult, type AgentFailTaskResult, type AgentForkInput, type AgentForkResult, type AgentInfoResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentQueryInput, type AgentQueryResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, AssetNotFoundError, type AssetPinResult, Auth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, DataAsset, type FunctionInfo, type FunctionsResult, Grid, GridError, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANIssueInput, type UCANIssueResult, UCANManager, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceDeleteInput, type WorkspaceDeleteResult, type WorkspaceInspectInput, type WorkspaceInspectResult, type WorkspaceListInput, type WorkspaceListResult, WorkspaceManager, type WorkspaceReadInput, type WorkspaceReadResult, type WorkspaceSliceInput, type WorkspaceSliceResult, type WorkspaceWriteInput, type WorkspaceWriteResult, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex, venueBaseUrlCandidates };
package/dist/index.d.ts CHANGED
@@ -467,6 +467,15 @@ declare class SecretManager {
467
467
  delete(name: string): Promise<void>;
468
468
  }
469
469
 
470
+ /**
471
+ * Resolve a non-DID venue id into the ordered list of base URLs that
472
+ * {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
473
+ * honoured as given (trailing slash trimmed, single candidate, no fallback);
474
+ * schemeless inputs (bare host / IP / host:port) pick a scheme by host — local
475
+ * hosts (loopback, private ranges, mDNS) try http then https, public hosts stay
476
+ * https-only. `did:*` ids are resolved separately and are not handled here.
477
+ */
478
+ declare function venueBaseUrlCandidates(venueId: string): string[];
470
479
  declare class Venue implements VenueInterface {
471
480
  baseUrl: string;
472
481
  venueId: string;
@@ -877,7 +886,10 @@ interface AssetPinResult {
877
886
  hash: string;
878
887
  }
879
888
  interface WorkspaceCopyResult {
880
- copied: boolean;
889
+ /** 0.2.x: present and true only if a new parent path was built at the destination. */
890
+ pathCreated?: boolean;
891
+ /** @deprecated pre-0.2.x: constant true. Success is the job status. */
892
+ copied?: boolean;
881
893
  }
882
894
  interface WorkspaceInspectInput {
883
895
  paths: string | string[];
@@ -895,6 +907,9 @@ interface WorkspaceReadResult {
895
907
  exists: boolean;
896
908
  value?: any;
897
909
  truncated?: boolean;
910
+ /** 0.2.x: encoding size in bytes (always present). */
911
+ valueBytes?: number;
912
+ /** @deprecated pre-0.2.x: bytes, only on truncation. Use valueBytes. */
898
913
  size?: number;
899
914
  }
900
915
  interface WorkspaceWriteInput {
@@ -902,20 +917,29 @@ interface WorkspaceWriteInput {
902
917
  value: any;
903
918
  }
904
919
  interface WorkspaceWriteResult {
905
- written: boolean;
920
+ /** 0.2.x: true iff the write built a new parent path; omitted otherwise. */
921
+ pathCreated?: boolean;
922
+ /** @deprecated pre-0.2.x: constant true. Success is the job status. */
923
+ written?: boolean;
906
924
  }
907
925
  interface WorkspaceDeleteInput {
908
926
  path: string;
909
927
  }
910
928
  interface WorkspaceDeleteResult {
911
- deleted: boolean;
929
+ /** @deprecated pre-0.2.x: constant true. 0.2.x returns an empty object (success is the job status). */
930
+ deleted?: boolean;
912
931
  }
913
932
  interface WorkspaceAppendInput {
914
933
  path: string;
915
934
  value: any;
916
935
  }
917
936
  interface WorkspaceAppendResult {
918
- appended: boolean;
937
+ /** 0.2.x: vector element count after the append. */
938
+ newSize?: number;
939
+ /** 0.2.x: true iff a new parent path was built. */
940
+ pathCreated?: boolean;
941
+ /** @deprecated pre-0.2.x: constant true. */
942
+ appended?: boolean;
919
943
  }
920
944
  interface WorkspaceListInput {
921
945
  path?: string;
@@ -925,10 +949,13 @@ interface WorkspaceListInput {
925
949
  interface WorkspaceListResult {
926
950
  exists: boolean;
927
951
  type: string;
928
- count?: number;
952
+ /** 0.2.x: total entries in the collection. */
953
+ totalSize?: number;
929
954
  keys?: string[];
930
955
  values?: any[];
931
956
  offset?: number;
957
+ /** @deprecated pre-0.2.x name for totalSize. */
958
+ count?: number;
932
959
  }
933
960
  interface WorkspaceSliceInput {
934
961
  path: string;
@@ -937,10 +964,13 @@ interface WorkspaceSliceInput {
937
964
  }
938
965
  interface WorkspaceSliceResult {
939
966
  exists: boolean;
940
- type: string;
941
- values: any[];
942
- count: number;
943
- offset: number;
967
+ type?: string;
968
+ values?: any[];
969
+ /** 0.2.x: total entries in the collection. */
970
+ totalSize?: number;
971
+ offset?: number;
972
+ /** @deprecated pre-0.2.x name for totalSize. */
973
+ count?: number;
944
974
  }
945
975
  interface UCANAttenuation {
946
976
  with: string;
@@ -1163,4 +1193,4 @@ declare function decodePublicKey(multikey: string): Uint8Array;
1163
1193
  */
1164
1194
  declare function didFromPublicKey(publicKey: Uint8Array): string;
1165
1195
 
1166
- export { type AdapterInfo, type AdaptersResult, Agent, type AgentCancelTaskInput, type AgentCard, type AgentChatInput, type AgentChatResult, type AgentCompleteTaskResult, type AgentContextInput, type AgentCreateInput, type AgentCreateResult, type AgentDeleteInput, type AgentDeleteResult, type AgentFailTaskResult, type AgentForkInput, type AgentForkResult, type AgentInfoResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentQueryInput, type AgentQueryResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, AssetNotFoundError, type AssetPinResult, Auth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, DataAsset, type FunctionInfo, type FunctionsResult, Grid, GridError, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANIssueInput, type UCANIssueResult, UCANManager, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceDeleteInput, type WorkspaceDeleteResult, type WorkspaceInspectInput, type WorkspaceInspectResult, type WorkspaceListInput, type WorkspaceListResult, WorkspaceManager, type WorkspaceReadInput, type WorkspaceReadResult, type WorkspaceSliceInput, type WorkspaceSliceResult, type WorkspaceWriteInput, type WorkspaceWriteResult, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex };
1196
+ export { type AdapterInfo, type AdaptersResult, Agent, type AgentCancelTaskInput, type AgentCard, type AgentChatInput, type AgentChatResult, type AgentCompleteTaskResult, type AgentContextInput, type AgentCreateInput, type AgentCreateResult, type AgentDeleteInput, type AgentDeleteResult, type AgentFailTaskResult, type AgentForkInput, type AgentForkResult, type AgentInfoResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentQueryInput, type AgentQueryResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, AssetNotFoundError, type AssetPinResult, Auth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, DataAsset, type FunctionInfo, type FunctionsResult, Grid, GridError, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANIssueInput, type UCANIssueResult, UCANManager, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceDeleteInput, type WorkspaceDeleteResult, type WorkspaceInspectInput, type WorkspaceInspectResult, type WorkspaceListInput, type WorkspaceListResult, WorkspaceManager, type WorkspaceReadInput, type WorkspaceReadResult, type WorkspaceSliceInput, type WorkspaceSliceResult, type WorkspaceWriteInput, type WorkspaceWriteResult, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex, venueBaseUrlCandidates };
package/dist/index.js CHANGED
@@ -91,7 +91,7 @@ var JobNotFoundError = class extends NotFoundError {
91
91
  }
92
92
  };
93
93
 
94
- // node_modules/@noble/ed25519/index.js
94
+ // node_modules/.pnpm/@noble+ed25519@2.3.0/node_modules/@noble/ed25519/index.js
95
95
  var ed25519_CURVE = {
96
96
  p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
97
97
  n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
@@ -537,7 +537,7 @@ var wNAF = (n) => {
537
537
  return { p, f };
538
538
  };
539
539
 
540
- // node_modules/@noble/hashes/esm/utils.js
540
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
541
541
  function isBytes2(a) {
542
542
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
543
543
  }
@@ -590,7 +590,7 @@ function createHasher(hashCons) {
590
590
  return hashC;
591
591
  }
592
592
 
593
- // node_modules/@noble/hashes/esm/_md.js
593
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
594
594
  function setBigUint64(view, byteOffset, value, isLE) {
595
595
  if (typeof view.setBigUint64 === "function")
596
596
  return view.setBigUint64(byteOffset, value, isLE);
@@ -712,7 +712,7 @@ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
712
712
  327033209
713
713
  ]);
714
714
 
715
- // node_modules/@noble/hashes/esm/_u64.js
715
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
716
716
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
717
717
  var _32n = /* @__PURE__ */ BigInt(32);
718
718
  function fromBig(n, le = false) {
@@ -747,7 +747,7 @@ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0
747
747
  var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
748
748
  var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
749
749
 
750
- // node_modules/@noble/hashes/esm/sha2.js
750
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
751
751
  var K512 = /* @__PURE__ */ (() => split([
752
752
  "0x428a2f98d728ae22",
753
753
  "0x7137449123ef65cd",
@@ -947,7 +947,7 @@ var SHA512 = class extends HashMD {
947
947
  };
948
948
  var sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
949
949
 
950
- // node_modules/@noble/hashes/esm/sha512.js
950
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha512.js
951
951
  var sha5122 = sha512;
952
952
 
953
953
  // src/crypto/keys.ts
@@ -2089,6 +2089,33 @@ var ChatSession = class {
2089
2089
  // src/Venue.ts
2090
2090
  var webResolver = webDidResolver.getResolver();
2091
2091
  var resolver = new didResolver.Resolver(webResolver);
2092
+ function stripTrailingSlash(value) {
2093
+ return value.endsWith("/") ? value.slice(0, -1) : value;
2094
+ }
2095
+ function hostIsLocal(host) {
2096
+ const h2 = host.toLowerCase();
2097
+ if (h2 === "localhost" || h2.endsWith(".localhost") || h2.endsWith(".local")) return true;
2098
+ if (h2 === "::1" || h2 === "0.0.0.0") return true;
2099
+ if (/^127\./.test(h2)) return true;
2100
+ if (/^10\./.test(h2)) return true;
2101
+ if (/^192\.168\./.test(h2)) return true;
2102
+ if (/^172\.(1[6-9]|2\d|3[01])\./.test(h2)) return true;
2103
+ if (/^169\.254\./.test(h2)) return true;
2104
+ return false;
2105
+ }
2106
+ function schemelessVenueCandidates(venueId) {
2107
+ const authority = venueId.split("/")[0];
2108
+ const v6 = authority.match(/^\[([^\]]+)\]/);
2109
+ const host = v6 ? v6[1] : authority.split(":")[0];
2110
+ const bare = stripTrailingSlash(venueId);
2111
+ return hostIsLocal(host) ? [`http://${bare}`, `https://${bare}`] : [`https://${bare}`];
2112
+ }
2113
+ function venueBaseUrlCandidates(venueId) {
2114
+ if (venueId.startsWith("http:") || venueId.startsWith("https:")) {
2115
+ return [stripTrailingSlash(venueId)];
2116
+ }
2117
+ return schemelessVenueCandidates(venueId);
2118
+ }
2092
2119
  var Venue = class _Venue {
2093
2120
  get agents() {
2094
2121
  return this._agents ?? (this._agents = new AgentManager(this));
@@ -2136,12 +2163,8 @@ var Venue = class _Venue {
2136
2163
  });
2137
2164
  }
2138
2165
  if (typeof venueId === "string") {
2139
- let baseUrl;
2140
- if (venueId.startsWith("http:") || venueId.startsWith("https:")) {
2141
- baseUrl = venueId;
2142
- if (baseUrl.endsWith("/"))
2143
- baseUrl = baseUrl.substring(0, baseUrl.length - 1);
2144
- } else if (venueId.startsWith("did:web:")) {
2166
+ let candidates;
2167
+ if (venueId.startsWith("did:web:")) {
2145
2168
  const didDoc = await resolver.resolve(venueId);
2146
2169
  if (!didDoc.didDocument) {
2147
2170
  throw new CoviaError("Invalid DID document");
@@ -2150,17 +2173,25 @@ var Venue = class _Venue {
2150
2173
  if (!endpoint) {
2151
2174
  throw new CoviaError("No endpoint found for DID");
2152
2175
  }
2153
- baseUrl = endpoint.toString().replace(/\/api\/v1/, "");
2176
+ candidates = [endpoint.toString().replace(/\/api\/v1/, "")];
2154
2177
  } else {
2155
- baseUrl = `https://${venueId}`;
2178
+ candidates = venueBaseUrlCandidates(venueId);
2156
2179
  }
2157
- const data = await fetchWithError(baseUrl + "/api/v1/status");
2158
- return new _Venue({
2159
- baseUrl,
2160
- venueId: data.did,
2161
- name: data.name,
2162
- auth
2163
- });
2180
+ let lastError;
2181
+ for (const baseUrl of candidates) {
2182
+ try {
2183
+ const data = await fetchWithError(baseUrl + "/api/v1/status");
2184
+ return new _Venue({
2185
+ baseUrl,
2186
+ venueId: data.did,
2187
+ name: data.name,
2188
+ auth
2189
+ });
2190
+ } catch (error) {
2191
+ lastError = error;
2192
+ }
2193
+ }
2194
+ throw lastError ?? new CoviaError(`Could not connect to venue: ${venueId}`);
2164
2195
  }
2165
2196
  throw new CoviaError("Invalid venue ID parameter. Must be a string (URL/DNS) or Venue instance.");
2166
2197
  }
@@ -2358,3 +2389,4 @@ exports.isJobPaused = isJobPaused;
2358
2389
  exports.logger = logger;
2359
2390
  exports.parseSSEStream = parseSSEStream;
2360
2391
  exports.privateKeyToHex = privateKeyToHex;
2392
+ exports.venueBaseUrlCandidates = venueBaseUrlCandidates;
package/dist/index.mjs CHANGED
@@ -89,7 +89,7 @@ var JobNotFoundError = class extends NotFoundError {
89
89
  }
90
90
  };
91
91
 
92
- // node_modules/@noble/ed25519/index.js
92
+ // node_modules/.pnpm/@noble+ed25519@2.3.0/node_modules/@noble/ed25519/index.js
93
93
  var ed25519_CURVE = {
94
94
  p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
95
95
  n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
@@ -535,7 +535,7 @@ var wNAF = (n) => {
535
535
  return { p, f };
536
536
  };
537
537
 
538
- // node_modules/@noble/hashes/esm/utils.js
538
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
539
539
  function isBytes2(a) {
540
540
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
541
541
  }
@@ -588,7 +588,7 @@ function createHasher(hashCons) {
588
588
  return hashC;
589
589
  }
590
590
 
591
- // node_modules/@noble/hashes/esm/_md.js
591
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
592
592
  function setBigUint64(view, byteOffset, value, isLE) {
593
593
  if (typeof view.setBigUint64 === "function")
594
594
  return view.setBigUint64(byteOffset, value, isLE);
@@ -710,7 +710,7 @@ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
710
710
  327033209
711
711
  ]);
712
712
 
713
- // node_modules/@noble/hashes/esm/_u64.js
713
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
714
714
  var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
715
715
  var _32n = /* @__PURE__ */ BigInt(32);
716
716
  function fromBig(n, le = false) {
@@ -745,7 +745,7 @@ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0
745
745
  var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
746
746
  var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
747
747
 
748
- // node_modules/@noble/hashes/esm/sha2.js
748
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
749
749
  var K512 = /* @__PURE__ */ (() => split([
750
750
  "0x428a2f98d728ae22",
751
751
  "0x7137449123ef65cd",
@@ -945,7 +945,7 @@ var SHA512 = class extends HashMD {
945
945
  };
946
946
  var sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
947
947
 
948
- // node_modules/@noble/hashes/esm/sha512.js
948
+ // node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha512.js
949
949
  var sha5122 = sha512;
950
950
 
951
951
  // src/crypto/keys.ts
@@ -2087,6 +2087,33 @@ var ChatSession = class {
2087
2087
  // src/Venue.ts
2088
2088
  var webResolver = getResolver();
2089
2089
  var resolver = new Resolver(webResolver);
2090
+ function stripTrailingSlash(value) {
2091
+ return value.endsWith("/") ? value.slice(0, -1) : value;
2092
+ }
2093
+ function hostIsLocal(host) {
2094
+ const h2 = host.toLowerCase();
2095
+ if (h2 === "localhost" || h2.endsWith(".localhost") || h2.endsWith(".local")) return true;
2096
+ if (h2 === "::1" || h2 === "0.0.0.0") return true;
2097
+ if (/^127\./.test(h2)) return true;
2098
+ if (/^10\./.test(h2)) return true;
2099
+ if (/^192\.168\./.test(h2)) return true;
2100
+ if (/^172\.(1[6-9]|2\d|3[01])\./.test(h2)) return true;
2101
+ if (/^169\.254\./.test(h2)) return true;
2102
+ return false;
2103
+ }
2104
+ function schemelessVenueCandidates(venueId) {
2105
+ const authority = venueId.split("/")[0];
2106
+ const v6 = authority.match(/^\[([^\]]+)\]/);
2107
+ const host = v6 ? v6[1] : authority.split(":")[0];
2108
+ const bare = stripTrailingSlash(venueId);
2109
+ return hostIsLocal(host) ? [`http://${bare}`, `https://${bare}`] : [`https://${bare}`];
2110
+ }
2111
+ function venueBaseUrlCandidates(venueId) {
2112
+ if (venueId.startsWith("http:") || venueId.startsWith("https:")) {
2113
+ return [stripTrailingSlash(venueId)];
2114
+ }
2115
+ return schemelessVenueCandidates(venueId);
2116
+ }
2090
2117
  var Venue = class _Venue {
2091
2118
  get agents() {
2092
2119
  return this._agents ?? (this._agents = new AgentManager(this));
@@ -2134,12 +2161,8 @@ var Venue = class _Venue {
2134
2161
  });
2135
2162
  }
2136
2163
  if (typeof venueId === "string") {
2137
- let baseUrl;
2138
- if (venueId.startsWith("http:") || venueId.startsWith("https:")) {
2139
- baseUrl = venueId;
2140
- if (baseUrl.endsWith("/"))
2141
- baseUrl = baseUrl.substring(0, baseUrl.length - 1);
2142
- } else if (venueId.startsWith("did:web:")) {
2164
+ let candidates;
2165
+ if (venueId.startsWith("did:web:")) {
2143
2166
  const didDoc = await resolver.resolve(venueId);
2144
2167
  if (!didDoc.didDocument) {
2145
2168
  throw new CoviaError("Invalid DID document");
@@ -2148,17 +2171,25 @@ var Venue = class _Venue {
2148
2171
  if (!endpoint) {
2149
2172
  throw new CoviaError("No endpoint found for DID");
2150
2173
  }
2151
- baseUrl = endpoint.toString().replace(/\/api\/v1/, "");
2174
+ candidates = [endpoint.toString().replace(/\/api\/v1/, "")];
2152
2175
  } else {
2153
- baseUrl = `https://${venueId}`;
2176
+ candidates = venueBaseUrlCandidates(venueId);
2154
2177
  }
2155
- const data = await fetchWithError(baseUrl + "/api/v1/status");
2156
- return new _Venue({
2157
- baseUrl,
2158
- venueId: data.did,
2159
- name: data.name,
2160
- auth
2161
- });
2178
+ let lastError;
2179
+ for (const baseUrl of candidates) {
2180
+ try {
2181
+ const data = await fetchWithError(baseUrl + "/api/v1/status");
2182
+ return new _Venue({
2183
+ baseUrl,
2184
+ venueId: data.did,
2185
+ name: data.name,
2186
+ auth
2187
+ });
2188
+ } catch (error) {
2189
+ lastError = error;
2190
+ }
2191
+ }
2192
+ throw lastError ?? new CoviaError(`Could not connect to venue: ${venueId}`);
2162
2193
  }
2163
2194
  throw new CoviaError("Invalid venue ID parameter. Must be a string (URL/DNS) or Venue instance.");
2164
2195
  }
@@ -2308,4 +2339,4 @@ var Grid = class {
2308
2339
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2309
2340
  */
2310
2341
 
2311
- export { Agent, AgentManager, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DataAsset, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, NoAuth, NotFoundError, Operation, OperationManager, RunStatus, SecretManager, UCANManager, Venue, WorkspaceManager, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex };
2342
+ export { Agent, AgentManager, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DataAsset, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, NoAuth, NotFoundError, Operation, OperationManager, RunStatus, SecretManager, UCANManager, Venue, WorkspaceManager, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex, venueBaseUrlCandidates };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@covia/covia-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.6.0-next.0",
4
4
  "description": "Typescript library for covia-ai",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -25,6 +25,12 @@
25
25
  "prepublishOnly": "npm run build && npm run test:unit",
26
26
  "prepare": "npm run build"
27
27
  },
28
+ "pnpm": {
29
+ "onlyBuiltDependencies": [
30
+ "esbuild",
31
+ "unrs-resolver"
32
+ ]
33
+ },
28
34
  "keywords": [
29
35
  "covia",
30
36
  "grid",