@covia/covia-sdk 1.7.0 → 1.7.1
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 +42 -3
- package/dist/index.d.ts +42 -3
- package/dist/index.js +76 -12
- package/dist/index.mjs +75 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -431,6 +431,7 @@ declare class AssetManager {
|
|
|
431
431
|
* @returns Returns either an Operation or DataAsset based on the asset's metadata
|
|
432
432
|
*/
|
|
433
433
|
get(assetId: AssetID): Promise<Asset>;
|
|
434
|
+
private _wrap;
|
|
434
435
|
/**
|
|
435
436
|
* List assets with pagination support
|
|
436
437
|
* @param options - Pagination options (offset, limit)
|
|
@@ -1006,6 +1007,14 @@ interface AgentCreateResult {
|
|
|
1006
1007
|
agentId: string;
|
|
1007
1008
|
status: string;
|
|
1008
1009
|
created: boolean;
|
|
1010
|
+
/** True when an existing SLEEPING/SUSPENDED record was updated in place
|
|
1011
|
+
* (mutually exclusive with created). Absent on venues before 0.4. */
|
|
1012
|
+
updated?: boolean;
|
|
1013
|
+
/** Non-fatal advisories (venue 0.5+): present only when the config looks
|
|
1014
|
+
* misconfigured but create still succeeded — e.g. an Ollama model whose
|
|
1015
|
+
* tool-calling can't be confirmed, or declared tools that don't resolve
|
|
1016
|
+
* on the venue. Each entry is a human-readable message. */
|
|
1017
|
+
warnings?: string[];
|
|
1009
1018
|
}
|
|
1010
1019
|
interface AgentRequestInput {
|
|
1011
1020
|
agentId: string;
|
|
@@ -1048,10 +1057,13 @@ interface AgentListInput {
|
|
|
1048
1057
|
includeTerminated?: boolean;
|
|
1049
1058
|
}
|
|
1050
1059
|
interface AgentListResult {
|
|
1060
|
+
/** Always objects. The invoke op returns enriched entries; the job-free GET
|
|
1061
|
+
* returns bare id strings, which the SDK normalises to `{agentId}` — so
|
|
1062
|
+
* `status`/`tasks` are present only when the venue supplied them. */
|
|
1051
1063
|
agents: Array<{
|
|
1052
1064
|
agentId: string;
|
|
1053
|
-
status
|
|
1054
|
-
tasks
|
|
1065
|
+
status?: string;
|
|
1066
|
+
tasks?: number;
|
|
1055
1067
|
}>;
|
|
1056
1068
|
}
|
|
1057
1069
|
interface AgentDeleteInput {
|
|
@@ -1466,6 +1478,33 @@ declare function didUrl(did: string | null, namespace: string, ...segments: stri
|
|
|
1466
1478
|
*/
|
|
1467
1479
|
declare function assetHash(ref: string): string | null;
|
|
1468
1480
|
|
|
1481
|
+
/**
|
|
1482
|
+
* Pluggable persistent store for content-addressed asset metadata.
|
|
1483
|
+
*
|
|
1484
|
+
* An asset id is the Convex value hash of its metadata (`AMap.getHash()`
|
|
1485
|
+
* venue-side), so hash → metadata is immutable: entries never go stale and are
|
|
1486
|
+
* safe to cache indefinitely, across sessions and across venues. Keys are the
|
|
1487
|
+
* normalised bare hash (lowercase, no `0x`), so `<hash>`, `0x<hash>` and
|
|
1488
|
+
* `<DID>/a/<hash>` refs all share one entry.
|
|
1489
|
+
*
|
|
1490
|
+
* Trust model: entries are cached as returned by the venue that served them.
|
|
1491
|
+
* Provable verification — recomputing the Convex value hash of the metadata
|
|
1492
|
+
* and rejecting mismatches — requires a canonical CVM cell encoder in
|
|
1493
|
+
* TypeScript, which does not exist yet; when it lands, verification will gate
|
|
1494
|
+
* admission to this cache so entries are correct by construction rather than
|
|
1495
|
+
* by trust. Until then this is a availability/performance cache with the same
|
|
1496
|
+
* trust as an uncached fetch from the same venue.
|
|
1497
|
+
*/
|
|
1498
|
+
interface AssetMetadataStore {
|
|
1499
|
+
get(hash: string): AssetMetadata | undefined;
|
|
1500
|
+
put(hash: string, metadata: AssetMetadata): void;
|
|
1501
|
+
clear(): void;
|
|
1502
|
+
}
|
|
1503
|
+
/** Replace the persistent metadata store (e.g. a file-backed store in Node),
|
|
1504
|
+
* or pass `null` to disable persistence. Browsers default to localStorage. */
|
|
1505
|
+
declare function setAssetMetadataStore(s: AssetMetadataStore | null): void;
|
|
1506
|
+
declare function getAssetMetadataStore(): AssetMetadataStore | null;
|
|
1507
|
+
|
|
1469
1508
|
/**
|
|
1470
1509
|
* Simple logger for the Covia SDK.
|
|
1471
1510
|
*
|
|
@@ -1599,4 +1638,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
1599
1638
|
*/
|
|
1600
1639
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
1601
1640
|
|
|
1602
|
-
export { type AdapterInfo, AdapterManager, 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 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, BasicAuth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, DataAsset, Ed25519Auth, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, Namespace, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, type OperationRunner, RateLimitError, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAggregateResult, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceCountResult, 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, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, venueBaseUrlCandidates };
|
|
1641
|
+
export { type AdapterInfo, AdapterManager, 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 AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, type AssetMetadataStore, AssetNotFoundError, type AssetPinResult, Auth, BasicAuth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, DataAsset, Ed25519Auth, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, Namespace, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, type OperationRunner, RateLimitError, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAggregateResult, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceCountResult, 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, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getAssetMetadataStore, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, setAssetMetadataStore, venueBaseUrlCandidates };
|
package/dist/index.d.ts
CHANGED
|
@@ -431,6 +431,7 @@ declare class AssetManager {
|
|
|
431
431
|
* @returns Returns either an Operation or DataAsset based on the asset's metadata
|
|
432
432
|
*/
|
|
433
433
|
get(assetId: AssetID): Promise<Asset>;
|
|
434
|
+
private _wrap;
|
|
434
435
|
/**
|
|
435
436
|
* List assets with pagination support
|
|
436
437
|
* @param options - Pagination options (offset, limit)
|
|
@@ -1006,6 +1007,14 @@ interface AgentCreateResult {
|
|
|
1006
1007
|
agentId: string;
|
|
1007
1008
|
status: string;
|
|
1008
1009
|
created: boolean;
|
|
1010
|
+
/** True when an existing SLEEPING/SUSPENDED record was updated in place
|
|
1011
|
+
* (mutually exclusive with created). Absent on venues before 0.4. */
|
|
1012
|
+
updated?: boolean;
|
|
1013
|
+
/** Non-fatal advisories (venue 0.5+): present only when the config looks
|
|
1014
|
+
* misconfigured but create still succeeded — e.g. an Ollama model whose
|
|
1015
|
+
* tool-calling can't be confirmed, or declared tools that don't resolve
|
|
1016
|
+
* on the venue. Each entry is a human-readable message. */
|
|
1017
|
+
warnings?: string[];
|
|
1009
1018
|
}
|
|
1010
1019
|
interface AgentRequestInput {
|
|
1011
1020
|
agentId: string;
|
|
@@ -1048,10 +1057,13 @@ interface AgentListInput {
|
|
|
1048
1057
|
includeTerminated?: boolean;
|
|
1049
1058
|
}
|
|
1050
1059
|
interface AgentListResult {
|
|
1060
|
+
/** Always objects. The invoke op returns enriched entries; the job-free GET
|
|
1061
|
+
* returns bare id strings, which the SDK normalises to `{agentId}` — so
|
|
1062
|
+
* `status`/`tasks` are present only when the venue supplied them. */
|
|
1051
1063
|
agents: Array<{
|
|
1052
1064
|
agentId: string;
|
|
1053
|
-
status
|
|
1054
|
-
tasks
|
|
1065
|
+
status?: string;
|
|
1066
|
+
tasks?: number;
|
|
1055
1067
|
}>;
|
|
1056
1068
|
}
|
|
1057
1069
|
interface AgentDeleteInput {
|
|
@@ -1466,6 +1478,33 @@ declare function didUrl(did: string | null, namespace: string, ...segments: stri
|
|
|
1466
1478
|
*/
|
|
1467
1479
|
declare function assetHash(ref: string): string | null;
|
|
1468
1480
|
|
|
1481
|
+
/**
|
|
1482
|
+
* Pluggable persistent store for content-addressed asset metadata.
|
|
1483
|
+
*
|
|
1484
|
+
* An asset id is the Convex value hash of its metadata (`AMap.getHash()`
|
|
1485
|
+
* venue-side), so hash → metadata is immutable: entries never go stale and are
|
|
1486
|
+
* safe to cache indefinitely, across sessions and across venues. Keys are the
|
|
1487
|
+
* normalised bare hash (lowercase, no `0x`), so `<hash>`, `0x<hash>` and
|
|
1488
|
+
* `<DID>/a/<hash>` refs all share one entry.
|
|
1489
|
+
*
|
|
1490
|
+
* Trust model: entries are cached as returned by the venue that served them.
|
|
1491
|
+
* Provable verification — recomputing the Convex value hash of the metadata
|
|
1492
|
+
* and rejecting mismatches — requires a canonical CVM cell encoder in
|
|
1493
|
+
* TypeScript, which does not exist yet; when it lands, verification will gate
|
|
1494
|
+
* admission to this cache so entries are correct by construction rather than
|
|
1495
|
+
* by trust. Until then this is a availability/performance cache with the same
|
|
1496
|
+
* trust as an uncached fetch from the same venue.
|
|
1497
|
+
*/
|
|
1498
|
+
interface AssetMetadataStore {
|
|
1499
|
+
get(hash: string): AssetMetadata | undefined;
|
|
1500
|
+
put(hash: string, metadata: AssetMetadata): void;
|
|
1501
|
+
clear(): void;
|
|
1502
|
+
}
|
|
1503
|
+
/** Replace the persistent metadata store (e.g. a file-backed store in Node),
|
|
1504
|
+
* or pass `null` to disable persistence. Browsers default to localStorage. */
|
|
1505
|
+
declare function setAssetMetadataStore(s: AssetMetadataStore | null): void;
|
|
1506
|
+
declare function getAssetMetadataStore(): AssetMetadataStore | null;
|
|
1507
|
+
|
|
1469
1508
|
/**
|
|
1470
1509
|
* Simple logger for the Covia SDK.
|
|
1471
1510
|
*
|
|
@@ -1599,4 +1638,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
1599
1638
|
*/
|
|
1600
1639
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
1601
1640
|
|
|
1602
|
-
export { type AdapterInfo, AdapterManager, 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 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, BasicAuth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, DataAsset, Ed25519Auth, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, Namespace, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, type OperationRunner, RateLimitError, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAggregateResult, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceCountResult, 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, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, venueBaseUrlCandidates };
|
|
1641
|
+
export { type AdapterInfo, AdapterManager, 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 AgentRequestInput, type AgentRequestResult, type AgentResumeInput, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListOptions, AssetManager, type AssetMetadata, type AssetMetadataStore, AssetNotFoundError, type AssetPinResult, Auth, BasicAuth, BearerAuth, ChatSession, type ContentDetails, type ContentHashResult, CoviaConnectionError, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, DataAsset, Ed25519Auth, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, Namespace, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, type OperationRunner, RateLimitError, RunStatus, type SSEEvent, type SecretExtractInput, type SecretExtractResult, SecretManager, type SecretSetInput, type SecretSetResult, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, type VenueInterface, type VenueOptions, type WorkspaceAggregateResult, type WorkspaceAppendInput, type WorkspaceAppendResult, type WorkspaceCopyResult, type WorkspaceCountResult, 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, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getAssetMetadataStore, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, setAssetMetadataStore, venueBaseUrlCandidates };
|
package/dist/index.js
CHANGED
|
@@ -1499,6 +1499,53 @@ async function* parseSSEStream(response) {
|
|
|
1499
1499
|
}
|
|
1500
1500
|
}
|
|
1501
1501
|
|
|
1502
|
+
// src/asset-cache.ts
|
|
1503
|
+
var PREFIX = "covia:asset-meta:";
|
|
1504
|
+
var LocalStorageMetadataStore = class {
|
|
1505
|
+
get(hash) {
|
|
1506
|
+
try {
|
|
1507
|
+
const raw = localStorage.getItem(PREFIX + hash);
|
|
1508
|
+
return raw ? JSON.parse(raw) : void 0;
|
|
1509
|
+
} catch {
|
|
1510
|
+
return void 0;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
put(hash, metadata) {
|
|
1514
|
+
try {
|
|
1515
|
+
localStorage.setItem(PREFIX + hash, JSON.stringify(metadata));
|
|
1516
|
+
} catch {
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
clear() {
|
|
1520
|
+
try {
|
|
1521
|
+
const doomed = [];
|
|
1522
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
1523
|
+
const key = localStorage.key(i);
|
|
1524
|
+
if (key?.startsWith(PREFIX)) doomed.push(key);
|
|
1525
|
+
}
|
|
1526
|
+
doomed.forEach((k) => localStorage.removeItem(k));
|
|
1527
|
+
} catch {
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
function detectDefaultStore() {
|
|
1532
|
+
try {
|
|
1533
|
+
return typeof localStorage !== "undefined" ? new LocalStorageMetadataStore() : null;
|
|
1534
|
+
} catch {
|
|
1535
|
+
return null;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
var store = detectDefaultStore();
|
|
1539
|
+
function setAssetMetadataStore(s) {
|
|
1540
|
+
store = s;
|
|
1541
|
+
}
|
|
1542
|
+
function getAssetMetadataStore() {
|
|
1543
|
+
return store;
|
|
1544
|
+
}
|
|
1545
|
+
function normaliseHash(hash) {
|
|
1546
|
+
return (hash.startsWith("0x") ? hash.slice(2) : hash).toLowerCase();
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1502
1549
|
// src/AdapterManager.ts
|
|
1503
1550
|
var ADAPTERS_PATH = "v/info/adapters";
|
|
1504
1551
|
var LIST_LIMIT = 1e3;
|
|
@@ -1585,6 +1632,8 @@ var AgentManager = class {
|
|
|
1585
1632
|
);
|
|
1586
1633
|
} catch (e) {
|
|
1587
1634
|
if (!(e instanceof NotFoundError)) throw e;
|
|
1635
|
+
const routeMissing = path === "" || /\bEndpoint (GET|POST|PUT|DELETE|PATCH|HEAD) /.test(e.message);
|
|
1636
|
+
if (!routeMissing) throw e;
|
|
1588
1637
|
this.agentsGetSupported = false;
|
|
1589
1638
|
}
|
|
1590
1639
|
}
|
|
@@ -1627,7 +1676,10 @@ var AgentManager = class {
|
|
|
1627
1676
|
* venues transparently fall back to the invoke path (one probe, remembered).
|
|
1628
1677
|
*/
|
|
1629
1678
|
async list(includeTerminated) {
|
|
1630
|
-
|
|
1679
|
+
const result = await this._agentsOr("", { includeTerminated }, () => this.venue.operations.run("v/ops/agent/list", { includeTerminated }));
|
|
1680
|
+
const raw = result?.agents ?? [];
|
|
1681
|
+
const agents = raw.map((a) => typeof a === "string" ? { agentId: a } : a);
|
|
1682
|
+
return { agents };
|
|
1631
1683
|
}
|
|
1632
1684
|
async delete(agentId, remove) {
|
|
1633
1685
|
return this.venue.operations.run("v/ops/agent/delete", { agentId, remove });
|
|
@@ -2004,21 +2056,23 @@ var AssetManager = class {
|
|
|
2004
2056
|
*/
|
|
2005
2057
|
async get(assetId) {
|
|
2006
2058
|
if (cache.has(assetId)) {
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2059
|
+
return this._wrap(assetId, cache.get(assetId));
|
|
2060
|
+
}
|
|
2061
|
+
const hash = assetHash(assetId);
|
|
2062
|
+
if (hash) {
|
|
2063
|
+
const persisted = getAssetMetadataStore()?.get(normaliseHash(hash));
|
|
2064
|
+
if (persisted) {
|
|
2065
|
+
cache.set(assetId, persisted);
|
|
2066
|
+
return this._wrap(assetId, persisted);
|
|
2012
2067
|
}
|
|
2013
2068
|
}
|
|
2014
2069
|
try {
|
|
2015
2070
|
const data = await fetchWithError(`${this.venue.baseUrl}/api/v1/assets/${assetId}`);
|
|
2016
|
-
if (
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
} else {
|
|
2020
|
-
return new DataAsset(assetId, this.venue, data);
|
|
2071
|
+
if (hash) {
|
|
2072
|
+
cache.set(assetId, data);
|
|
2073
|
+
getAssetMetadataStore()?.put(normaliseHash(hash), data);
|
|
2021
2074
|
}
|
|
2075
|
+
return this._wrap(assetId, data);
|
|
2022
2076
|
} catch (error) {
|
|
2023
2077
|
if (error instanceof NotFoundError) {
|
|
2024
2078
|
throw new AssetNotFoundError(assetId);
|
|
@@ -2026,6 +2080,12 @@ var AssetManager = class {
|
|
|
2026
2080
|
throw error;
|
|
2027
2081
|
}
|
|
2028
2082
|
}
|
|
2083
|
+
_wrap(assetId, data) {
|
|
2084
|
+
if (data.operation) {
|
|
2085
|
+
return new Operation(assetId, this.venue, data);
|
|
2086
|
+
}
|
|
2087
|
+
return new DataAsset(assetId, this.venue, data);
|
|
2088
|
+
}
|
|
2029
2089
|
/**
|
|
2030
2090
|
* List assets with pagination support
|
|
2031
2091
|
* @param options - Pagination options (offset, limit)
|
|
@@ -2111,6 +2171,7 @@ var AssetManager = class {
|
|
|
2111
2171
|
*/
|
|
2112
2172
|
clearCache() {
|
|
2113
2173
|
cache.clear();
|
|
2174
|
+
getAssetMetadataStore()?.clear();
|
|
2114
2175
|
}
|
|
2115
2176
|
// `contentType` defaults to JSON for the metadata/register endpoints. Pass
|
|
2116
2177
|
// `undefined` for binary content upload so fetch infers the type from the
|
|
@@ -2279,7 +2340,8 @@ var WorkspaceManager = class {
|
|
|
2279
2340
|
return this._valuesOr("read", { path, maxSize }, () => this.venue.operations.run("v/ops/covia/read", { path, maxSize }));
|
|
2280
2341
|
}
|
|
2281
2342
|
async list(path, limit, offset, ucans) {
|
|
2282
|
-
|
|
2343
|
+
path = path || "/";
|
|
2344
|
+
if (ucans?.length) return this.venue.operations.run("v/ops/covia/list", { path, limit, offset }, { ucans });
|
|
2283
2345
|
return this._valuesOr("list", { path, limit, offset }, () => this.venue.operations.run("v/ops/covia/list", { path, limit, offset }));
|
|
2284
2346
|
}
|
|
2285
2347
|
async slice(path, offset, limit, ucans) {
|
|
@@ -2854,6 +2916,7 @@ exports.fetchWithError = fetchWithError;
|
|
|
2854
2916
|
exports.generateKeyPair = generateKeyPair;
|
|
2855
2917
|
exports.getAssetIdFromPath = getAssetIdFromPath;
|
|
2856
2918
|
exports.getAssetIdFromVenueId = getAssetIdFromVenueId;
|
|
2919
|
+
exports.getAssetMetadataStore = getAssetMetadataStore;
|
|
2857
2920
|
exports.getParsedAssetId = getParsedAssetId;
|
|
2858
2921
|
exports.grant = grant;
|
|
2859
2922
|
exports.hexToPrivateKey = hexToPrivateKey;
|
|
@@ -2869,4 +2932,5 @@ exports.parseSSEStream = parseSSEStream;
|
|
|
2869
2932
|
exports.privateKeyToHex = privateKeyToHex;
|
|
2870
2933
|
exports.relayDelegation = relayDelegation;
|
|
2871
2934
|
exports.retryDelayMs = retryDelayMs;
|
|
2935
|
+
exports.setAssetMetadataStore = setAssetMetadataStore;
|
|
2872
2936
|
exports.venueBaseUrlCandidates = venueBaseUrlCandidates;
|
package/dist/index.mjs
CHANGED
|
@@ -1497,6 +1497,53 @@ async function* parseSSEStream(response) {
|
|
|
1497
1497
|
}
|
|
1498
1498
|
}
|
|
1499
1499
|
|
|
1500
|
+
// src/asset-cache.ts
|
|
1501
|
+
var PREFIX = "covia:asset-meta:";
|
|
1502
|
+
var LocalStorageMetadataStore = class {
|
|
1503
|
+
get(hash) {
|
|
1504
|
+
try {
|
|
1505
|
+
const raw = localStorage.getItem(PREFIX + hash);
|
|
1506
|
+
return raw ? JSON.parse(raw) : void 0;
|
|
1507
|
+
} catch {
|
|
1508
|
+
return void 0;
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
put(hash, metadata) {
|
|
1512
|
+
try {
|
|
1513
|
+
localStorage.setItem(PREFIX + hash, JSON.stringify(metadata));
|
|
1514
|
+
} catch {
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
clear() {
|
|
1518
|
+
try {
|
|
1519
|
+
const doomed = [];
|
|
1520
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
1521
|
+
const key = localStorage.key(i);
|
|
1522
|
+
if (key?.startsWith(PREFIX)) doomed.push(key);
|
|
1523
|
+
}
|
|
1524
|
+
doomed.forEach((k) => localStorage.removeItem(k));
|
|
1525
|
+
} catch {
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
function detectDefaultStore() {
|
|
1530
|
+
try {
|
|
1531
|
+
return typeof localStorage !== "undefined" ? new LocalStorageMetadataStore() : null;
|
|
1532
|
+
} catch {
|
|
1533
|
+
return null;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
var store = detectDefaultStore();
|
|
1537
|
+
function setAssetMetadataStore(s) {
|
|
1538
|
+
store = s;
|
|
1539
|
+
}
|
|
1540
|
+
function getAssetMetadataStore() {
|
|
1541
|
+
return store;
|
|
1542
|
+
}
|
|
1543
|
+
function normaliseHash(hash) {
|
|
1544
|
+
return (hash.startsWith("0x") ? hash.slice(2) : hash).toLowerCase();
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1500
1547
|
// src/AdapterManager.ts
|
|
1501
1548
|
var ADAPTERS_PATH = "v/info/adapters";
|
|
1502
1549
|
var LIST_LIMIT = 1e3;
|
|
@@ -1583,6 +1630,8 @@ var AgentManager = class {
|
|
|
1583
1630
|
);
|
|
1584
1631
|
} catch (e) {
|
|
1585
1632
|
if (!(e instanceof NotFoundError)) throw e;
|
|
1633
|
+
const routeMissing = path === "" || /\bEndpoint (GET|POST|PUT|DELETE|PATCH|HEAD) /.test(e.message);
|
|
1634
|
+
if (!routeMissing) throw e;
|
|
1586
1635
|
this.agentsGetSupported = false;
|
|
1587
1636
|
}
|
|
1588
1637
|
}
|
|
@@ -1625,7 +1674,10 @@ var AgentManager = class {
|
|
|
1625
1674
|
* venues transparently fall back to the invoke path (one probe, remembered).
|
|
1626
1675
|
*/
|
|
1627
1676
|
async list(includeTerminated) {
|
|
1628
|
-
|
|
1677
|
+
const result = await this._agentsOr("", { includeTerminated }, () => this.venue.operations.run("v/ops/agent/list", { includeTerminated }));
|
|
1678
|
+
const raw = result?.agents ?? [];
|
|
1679
|
+
const agents = raw.map((a) => typeof a === "string" ? { agentId: a } : a);
|
|
1680
|
+
return { agents };
|
|
1629
1681
|
}
|
|
1630
1682
|
async delete(agentId, remove) {
|
|
1631
1683
|
return this.venue.operations.run("v/ops/agent/delete", { agentId, remove });
|
|
@@ -2002,21 +2054,23 @@ var AssetManager = class {
|
|
|
2002
2054
|
*/
|
|
2003
2055
|
async get(assetId) {
|
|
2004
2056
|
if (cache.has(assetId)) {
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2057
|
+
return this._wrap(assetId, cache.get(assetId));
|
|
2058
|
+
}
|
|
2059
|
+
const hash = assetHash(assetId);
|
|
2060
|
+
if (hash) {
|
|
2061
|
+
const persisted = getAssetMetadataStore()?.get(normaliseHash(hash));
|
|
2062
|
+
if (persisted) {
|
|
2063
|
+
cache.set(assetId, persisted);
|
|
2064
|
+
return this._wrap(assetId, persisted);
|
|
2010
2065
|
}
|
|
2011
2066
|
}
|
|
2012
2067
|
try {
|
|
2013
2068
|
const data = await fetchWithError(`${this.venue.baseUrl}/api/v1/assets/${assetId}`);
|
|
2014
|
-
if (
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
} else {
|
|
2018
|
-
return new DataAsset(assetId, this.venue, data);
|
|
2069
|
+
if (hash) {
|
|
2070
|
+
cache.set(assetId, data);
|
|
2071
|
+
getAssetMetadataStore()?.put(normaliseHash(hash), data);
|
|
2019
2072
|
}
|
|
2073
|
+
return this._wrap(assetId, data);
|
|
2020
2074
|
} catch (error) {
|
|
2021
2075
|
if (error instanceof NotFoundError) {
|
|
2022
2076
|
throw new AssetNotFoundError(assetId);
|
|
@@ -2024,6 +2078,12 @@ var AssetManager = class {
|
|
|
2024
2078
|
throw error;
|
|
2025
2079
|
}
|
|
2026
2080
|
}
|
|
2081
|
+
_wrap(assetId, data) {
|
|
2082
|
+
if (data.operation) {
|
|
2083
|
+
return new Operation(assetId, this.venue, data);
|
|
2084
|
+
}
|
|
2085
|
+
return new DataAsset(assetId, this.venue, data);
|
|
2086
|
+
}
|
|
2027
2087
|
/**
|
|
2028
2088
|
* List assets with pagination support
|
|
2029
2089
|
* @param options - Pagination options (offset, limit)
|
|
@@ -2109,6 +2169,7 @@ var AssetManager = class {
|
|
|
2109
2169
|
*/
|
|
2110
2170
|
clearCache() {
|
|
2111
2171
|
cache.clear();
|
|
2172
|
+
getAssetMetadataStore()?.clear();
|
|
2112
2173
|
}
|
|
2113
2174
|
// `contentType` defaults to JSON for the metadata/register endpoints. Pass
|
|
2114
2175
|
// `undefined` for binary content upload so fetch infers the type from the
|
|
@@ -2277,7 +2338,8 @@ var WorkspaceManager = class {
|
|
|
2277
2338
|
return this._valuesOr("read", { path, maxSize }, () => this.venue.operations.run("v/ops/covia/read", { path, maxSize }));
|
|
2278
2339
|
}
|
|
2279
2340
|
async list(path, limit, offset, ucans) {
|
|
2280
|
-
|
|
2341
|
+
path = path || "/";
|
|
2342
|
+
if (ucans?.length) return this.venue.operations.run("v/ops/covia/list", { path, limit, offset }, { ucans });
|
|
2281
2343
|
return this._valuesOr("list", { path, limit, offset }, () => this.venue.operations.run("v/ops/covia/list", { path, limit, offset }));
|
|
2282
2344
|
}
|
|
2283
2345
|
async slice(path, offset, limit, ucans) {
|
|
@@ -2801,4 +2863,4 @@ function relayDelegation(privateKey, venueDID, lifetimeSeconds, caps = []) {
|
|
|
2801
2863
|
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
2802
2864
|
*/
|
|
2803
2865
|
|
|
2804
|
-
export { AdapterManager, Agent, AgentManager, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BasicAuth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DataAsset, Ed25519Auth, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, Namespace, NoAuth, NotFoundError, Operation, OperationManager, RateLimitError, RunStatus, SecretManager, UCANManager, VENUE_RELAY, Venue, WorkspaceManager, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, venueBaseUrlCandidates };
|
|
2866
|
+
export { AdapterManager, Agent, AgentManager, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BasicAuth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DataAsset, Ed25519Auth, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, Namespace, NoAuth, NotFoundError, Operation, OperationManager, RateLimitError, RunStatus, SecretManager, UCANManager, VENUE_RELAY, Venue, WorkspaceManager, assetHash, createSSEEvent, createUCANJWT, decodePublicKey, didFor, didFromPublicKey, didMethod, didUrl, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getAssetMetadataStore, getParsedAssetId, grant, hexToPrivateKey, identityToken, isDid, isJobComplete, isJobFinished, isJobPaused, logger, parseDidUrl, parseRetryAfterMs, parseSSEStream, privateKeyToHex, relayDelegation, retryDelayMs, setAssetMetadataStore, venueBaseUrlCandidates };
|