@covia/covia-sdk 1.12.0 → 1.14.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 +218 -5
- package/dist/index.d.ts +218 -5
- package/dist/index.js +135 -8
- package/dist/index.mjs +135 -9
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -24,6 +24,12 @@ declare class Agent {
|
|
|
24
24
|
listSessions(options?: AgentSessionListOptions): Promise<AgentSessionPage>;
|
|
25
25
|
/** Read one session through the job-free workspace Values API. */
|
|
26
26
|
getSession(sessionId: string): Promise<AgentSession>;
|
|
27
|
+
/** Stream this agent's run-loop events. See `AgentManager.events`. */
|
|
28
|
+
events(options?: {
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
detail?: boolean;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): AsyncGenerator<AgentEvent>;
|
|
27
33
|
/**
|
|
28
34
|
* Fork this agent into a new agent.
|
|
29
35
|
* @param agentId - ID for the new forked agent
|
|
@@ -100,7 +106,9 @@ declare class Job {
|
|
|
100
106
|
* Stream server-sent events for this job.
|
|
101
107
|
* @returns AsyncGenerator yielding SSEEvent objects
|
|
102
108
|
*/
|
|
103
|
-
stream(
|
|
109
|
+
stream(options?: {
|
|
110
|
+
signal?: AbortSignal;
|
|
111
|
+
}): AsyncGenerator<SSEEvent>;
|
|
104
112
|
/**
|
|
105
113
|
* Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
|
|
106
114
|
*/
|
|
@@ -365,6 +373,7 @@ interface AgentManagerVenue extends VenueRequestContext {
|
|
|
365
373
|
declare class AgentManager {
|
|
366
374
|
private venue;
|
|
367
375
|
private agentsGetSupported;
|
|
376
|
+
private agentSseSupported;
|
|
368
377
|
constructor(venue: AgentManagerVenue);
|
|
369
378
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
370
379
|
* 404'd, or if the venue's last known status identifies it as pre-0.4. */
|
|
@@ -413,6 +422,20 @@ declare class AgentManager {
|
|
|
413
422
|
/** Agent info. **Job-free** on covia ≥ 0.4 (`GET /api/v1/agents/{id}`,
|
|
414
423
|
* covia#180); older venues require an explicit compatibility opt-in. */
|
|
415
424
|
info(agentId: string): Promise<AgentInfoResult>;
|
|
425
|
+
/**
|
|
426
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
427
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
428
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
429
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
430
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
431
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
432
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
433
|
+
*/
|
|
434
|
+
events(agentId: string, options?: {
|
|
435
|
+
sessionId?: string;
|
|
436
|
+
detail?: boolean;
|
|
437
|
+
signal?: AbortSignal;
|
|
438
|
+
}): AsyncGenerator<AgentEvent>;
|
|
416
439
|
/**
|
|
417
440
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
418
441
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -439,7 +462,9 @@ declare class JobManager {
|
|
|
439
462
|
pause(jobId: string): Promise<JobMetadata>;
|
|
440
463
|
resume(jobId: string): Promise<JobMetadata>;
|
|
441
464
|
sendMessage(jobId: string, message: unknown): Promise<unknown>;
|
|
442
|
-
stream(jobId: string
|
|
465
|
+
stream(jobId: string, options?: {
|
|
466
|
+
signal?: AbortSignal;
|
|
467
|
+
}): AsyncGenerator<SSEEvent>;
|
|
443
468
|
}
|
|
444
469
|
|
|
445
470
|
interface AssetManagerVenue extends VenueRequestContext {
|
|
@@ -764,6 +789,45 @@ declare class DLFSManager {
|
|
|
764
789
|
getContent(drive: string, path: string): Promise<ReadableStream<Uint8Array>>;
|
|
765
790
|
}
|
|
766
791
|
|
|
792
|
+
interface UserManagerVenue extends VenueRequestContext {
|
|
793
|
+
operations: OperationRunner;
|
|
794
|
+
lastKnownStatus?: StatusData;
|
|
795
|
+
}
|
|
796
|
+
declare class UserManager {
|
|
797
|
+
private venue;
|
|
798
|
+
private usersSupported;
|
|
799
|
+
constructor(venue: UserManagerVenue);
|
|
800
|
+
/** A job-free users GET that rejects when the endpoint is unavailable. */
|
|
801
|
+
private usersGet;
|
|
802
|
+
/**
|
|
803
|
+
* List registered venue users. **Job-free** on covia venues serving
|
|
804
|
+
* `GET /api/v1/users` (covia#255) — synchronous, no Job persisted.
|
|
805
|
+
* Operator-only: throws a `GridError` with `statusCode` 403 for a
|
|
806
|
+
* signed-in caller that is not the venue itself and holds no venue-issued
|
|
807
|
+
* delegation over `<venueDID>/users` — that is an expected, common
|
|
808
|
+
* outcome to branch on, not a bug.
|
|
809
|
+
*/
|
|
810
|
+
list(): Promise<UserListResult>;
|
|
811
|
+
/**
|
|
812
|
+
* Get one registered user. The caller's own DID needs no operator
|
|
813
|
+
* authority; any other DID does (403 otherwise).
|
|
814
|
+
*/
|
|
815
|
+
info(did: string): Promise<UserInfo>;
|
|
816
|
+
/**
|
|
817
|
+
* List a venue-managed user's authenticators, active and revoked
|
|
818
|
+
* tombstones alike — revocation is a status transition in place, never a
|
|
819
|
+
* deletion. The caller's own DID needs no operator authority; any other
|
|
820
|
+
* DID does (403 otherwise).
|
|
821
|
+
*/
|
|
822
|
+
listAuthenticators(did: string): Promise<AuthenticationKeysResult>;
|
|
823
|
+
/**
|
|
824
|
+
* Revoke one of a venue-managed user's authenticators. A mutation, so —
|
|
825
|
+
* unlike the reads above — this goes through `operations.run` and mints a
|
|
826
|
+
* Job, matching every other write in this SDK (e.g. `SecretManager.set`).
|
|
827
|
+
*/
|
|
828
|
+
revokeAuthenticator(key: string, did?: string, ucans?: string[]): Promise<AuthenticatorRevokeResult>;
|
|
829
|
+
}
|
|
830
|
+
|
|
767
831
|
/**
|
|
768
832
|
* Resolve a non-DID venue id into the ordered list of base URLs that
|
|
769
833
|
* {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
|
|
@@ -819,6 +883,7 @@ declare class Venue implements VenueInterface {
|
|
|
819
883
|
private _skills?;
|
|
820
884
|
private _memory?;
|
|
821
885
|
private _dlfs?;
|
|
886
|
+
private _users?;
|
|
822
887
|
get adapters(): AdapterManager;
|
|
823
888
|
get agents(): AgentManager;
|
|
824
889
|
get jobs(): JobManager;
|
|
@@ -830,6 +895,7 @@ declare class Venue implements VenueInterface {
|
|
|
830
895
|
get skills(): SkillManager;
|
|
831
896
|
get memory(): MemoryManager;
|
|
832
897
|
get dlfs(): DLFSManager;
|
|
898
|
+
get users(): UserManager;
|
|
833
899
|
constructor(options?: VenueOptions);
|
|
834
900
|
/**
|
|
835
901
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
@@ -1074,6 +1140,12 @@ interface StatusData {
|
|
|
1074
1140
|
/** Venue platform version (e.g. "0.3.0"). Absent on venues before 0.3. */
|
|
1075
1141
|
version?: string;
|
|
1076
1142
|
stats?: StatsData;
|
|
1143
|
+
/** Curated admission-policy fields (#255) — safe to state to any caller.
|
|
1144
|
+
* Absent on venues before this shipped; treat as unknown, not false. */
|
|
1145
|
+
access?: {
|
|
1146
|
+
public: boolean;
|
|
1147
|
+
userAutoCreate: boolean;
|
|
1148
|
+
};
|
|
1077
1149
|
}
|
|
1078
1150
|
interface StatsData {
|
|
1079
1151
|
assets?: number;
|
|
@@ -1337,6 +1409,99 @@ interface AgentFailTaskResult {
|
|
|
1337
1409
|
taskId: string;
|
|
1338
1410
|
status: string;
|
|
1339
1411
|
}
|
|
1412
|
+
/** Fields present on every agent run-loop event frame (covia#394). */
|
|
1413
|
+
interface AgentEventEnvelope {
|
|
1414
|
+
seq: number;
|
|
1415
|
+
ts: number;
|
|
1416
|
+
agentId: string;
|
|
1417
|
+
address: string;
|
|
1418
|
+
}
|
|
1419
|
+
interface AgentRunStartEvent extends AgentEventEnvelope {
|
|
1420
|
+
type: 'run:start';
|
|
1421
|
+
run: number;
|
|
1422
|
+
}
|
|
1423
|
+
interface AgentRunEndEvent extends AgentEventEnvelope {
|
|
1424
|
+
type: 'run:end';
|
|
1425
|
+
run: number;
|
|
1426
|
+
status: AgentStatus;
|
|
1427
|
+
cycles: number;
|
|
1428
|
+
}
|
|
1429
|
+
interface AgentCycleStartEvent extends AgentEventEnvelope {
|
|
1430
|
+
type: 'cycle:start';
|
|
1431
|
+
run: number;
|
|
1432
|
+
cycle: number;
|
|
1433
|
+
op?: string;
|
|
1434
|
+
sessionId?: string;
|
|
1435
|
+
jobId?: string;
|
|
1436
|
+
jobs?: string[];
|
|
1437
|
+
tasks: unknown;
|
|
1438
|
+
messages: unknown;
|
|
1439
|
+
pending: unknown;
|
|
1440
|
+
}
|
|
1441
|
+
interface AgentCycleEndEvent extends AgentEventEnvelope {
|
|
1442
|
+
type: 'cycle:end';
|
|
1443
|
+
run: number;
|
|
1444
|
+
cycle: number;
|
|
1445
|
+
ms: number;
|
|
1446
|
+
response?: unknown;
|
|
1447
|
+
error?: string;
|
|
1448
|
+
tokens?: unknown;
|
|
1449
|
+
timeline?: unknown;
|
|
1450
|
+
detail?: {
|
|
1451
|
+
turns: unknown;
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
interface AgentInferenceStartEvent extends AgentEventEnvelope {
|
|
1455
|
+
type: 'inference:start';
|
|
1456
|
+
op: string;
|
|
1457
|
+
model?: string;
|
|
1458
|
+
messages: unknown;
|
|
1459
|
+
tools: unknown;
|
|
1460
|
+
bytes: number;
|
|
1461
|
+
budget: unknown;
|
|
1462
|
+
depth?: number;
|
|
1463
|
+
}
|
|
1464
|
+
interface AgentInferenceEndEvent extends AgentEventEnvelope {
|
|
1465
|
+
type: 'inference:end';
|
|
1466
|
+
ms: number;
|
|
1467
|
+
model?: string;
|
|
1468
|
+
content?: unknown;
|
|
1469
|
+
toolCalls?: {
|
|
1470
|
+
id: string;
|
|
1471
|
+
name: string;
|
|
1472
|
+
}[];
|
|
1473
|
+
tokens?: unknown;
|
|
1474
|
+
error?: string;
|
|
1475
|
+
depth?: number;
|
|
1476
|
+
}
|
|
1477
|
+
interface AgentToolStartEvent extends AgentEventEnvelope {
|
|
1478
|
+
type: 'tool:start';
|
|
1479
|
+
id: string;
|
|
1480
|
+
name: string;
|
|
1481
|
+
depth?: number;
|
|
1482
|
+
detail: {
|
|
1483
|
+
input: unknown;
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
interface AgentToolResultEvent extends AgentEventEnvelope {
|
|
1487
|
+
type: 'tool:result';
|
|
1488
|
+
id: string;
|
|
1489
|
+
name: string;
|
|
1490
|
+
ms: number;
|
|
1491
|
+
isError?: boolean;
|
|
1492
|
+
depth?: number;
|
|
1493
|
+
detail: {
|
|
1494
|
+
result: unknown;
|
|
1495
|
+
};
|
|
1496
|
+
}
|
|
1497
|
+
interface AgentStatusEvent extends AgentEventEnvelope {
|
|
1498
|
+
type: 'status';
|
|
1499
|
+
status: AgentStatus;
|
|
1500
|
+
error?: string;
|
|
1501
|
+
}
|
|
1502
|
+
/** One frame from the venue's agent run-loop event stream (`GET
|
|
1503
|
+
* /agents/{id}/sse`, covia#394), discriminated on `type`. */
|
|
1504
|
+
type AgentEvent = AgentRunStartEvent | AgentRunEndEvent | AgentCycleStartEvent | AgentCycleEndEvent | AgentInferenceStartEvent | AgentInferenceEndEvent | AgentToolStartEvent | AgentToolResultEvent | AgentStatusEvent;
|
|
1340
1505
|
interface AssetPinResult {
|
|
1341
1506
|
path: string;
|
|
1342
1507
|
hash: string;
|
|
@@ -1527,6 +1692,50 @@ interface DLFSListResult {
|
|
|
1527
1692
|
entries: DLFSEntry[];
|
|
1528
1693
|
warnings?: string[];
|
|
1529
1694
|
}
|
|
1695
|
+
interface UserSummary {
|
|
1696
|
+
did: string;
|
|
1697
|
+
registered: boolean;
|
|
1698
|
+
/** True for a venue-managed named account (a did:web identity minted from
|
|
1699
|
+
* a username); false/absent for a plain registered DID. */
|
|
1700
|
+
managed?: boolean;
|
|
1701
|
+
meta?: Record<string, unknown>;
|
|
1702
|
+
}
|
|
1703
|
+
interface UserListResult {
|
|
1704
|
+
users: UserSummary[];
|
|
1705
|
+
total: number;
|
|
1706
|
+
}
|
|
1707
|
+
interface UserInfo {
|
|
1708
|
+
did: string;
|
|
1709
|
+
registered: boolean;
|
|
1710
|
+
managed?: boolean;
|
|
1711
|
+
meta?: Record<string, unknown>;
|
|
1712
|
+
}
|
|
1713
|
+
/** One authenticator's lifecycle record. Revocation is a status transition
|
|
1714
|
+
* in place — a revoked entry is retained forever, never deleted, so the
|
|
1715
|
+
* key's full add/revoke history stays visible as an audit tombstone. */
|
|
1716
|
+
interface AuthenticationKeyEntry {
|
|
1717
|
+
status: "active" | "revoked";
|
|
1718
|
+
/** Epoch millis. */
|
|
1719
|
+
addedAt: number;
|
|
1720
|
+
/** Actor DID that added this key. */
|
|
1721
|
+
addedBy: string;
|
|
1722
|
+
label?: string;
|
|
1723
|
+
/** Epoch millis, present only once status is "revoked". */
|
|
1724
|
+
revokedAt?: number;
|
|
1725
|
+
/** Actor DID that revoked this key, present only once status is "revoked". */
|
|
1726
|
+
revokedBy?: string;
|
|
1727
|
+
}
|
|
1728
|
+
/** Keyed by the authenticator's own `did:key:...` string. */
|
|
1729
|
+
type AuthenticationKeysMap = Record<string, AuthenticationKeyEntry>;
|
|
1730
|
+
interface AuthenticationKeysResult {
|
|
1731
|
+
did: string;
|
|
1732
|
+
authenticationKeys: AuthenticationKeysMap;
|
|
1733
|
+
}
|
|
1734
|
+
interface AuthenticatorRevokeResult {
|
|
1735
|
+
did: string;
|
|
1736
|
+
key: string;
|
|
1737
|
+
revoked: boolean;
|
|
1738
|
+
}
|
|
1530
1739
|
interface FunctionInfo {
|
|
1531
1740
|
name: string;
|
|
1532
1741
|
id: string;
|
|
@@ -1702,9 +1911,13 @@ declare function createSSEEvent(fields: {
|
|
|
1702
1911
|
}): SSEEvent;
|
|
1703
1912
|
/**
|
|
1704
1913
|
* Parse an SSE stream from a fetch Response body.
|
|
1705
|
-
* Yields SSEEvent objects as they arrive.
|
|
1914
|
+
* Yields SSEEvent objects as they arrive. On `signal` abort, iteration ends
|
|
1915
|
+
* as if the stream closed (no exception thrown); callers that must
|
|
1916
|
+
* distinguish should check `signal.aborted` after the loop.
|
|
1706
1917
|
*/
|
|
1707
|
-
declare function parseSSEStream(response: Response
|
|
1918
|
+
declare function parseSSEStream(response: Response, options?: {
|
|
1919
|
+
signal?: AbortSignal;
|
|
1920
|
+
}): AsyncGenerator<SSEEvent>;
|
|
1708
1921
|
|
|
1709
1922
|
/**
|
|
1710
1923
|
* DID and lattice-path helpers for the Covia grid.
|
|
@@ -1934,4 +2147,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
1934
2147
|
*/
|
|
1935
2148
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
1936
2149
|
|
|
1937
|
-
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 AgentRenameSessionResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, type AgentSession, type AgentSessionListOptions, type AgentSessionMetadata, AgentSessionNotFoundError, type AgentSessionPage, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListItem, type AssetListOptions, AssetManager, type AssetMetadata, type AssetMetadataStore, AssetNotFoundError, type AssetPinResult, type AssetSummary, Auth, BasicAuth, BearerAuth, ChatSession, type ConnectionAttempt, type ContentDetails, type ContentHashResult, CoviaConnectionError, type CoviaConnectionErrorOptions, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, type DLFSDrivesResult, type DLFSEntry, type DLFSListResult, DLFSManager, DataAsset, Ed25519Auth, type ExpandedAssetList, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, type MemoryChange, type MemoryEntry, MemoryManager, type MyAssetList, 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 Skill, type SkillFacet, SkillManager, type SkillMetadata, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, UnsupportedVenueFeatureError, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, VenueIdentityChangedError, 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 };
|
|
2150
|
+
export { type AdapterInfo, AdapterManager, type AdaptersResult, Agent, type AgentCancelTaskInput, type AgentCard, type AgentChatInput, type AgentChatResult, type AgentCompleteTaskResult, type AgentContextInput, type AgentCreateInput, type AgentCreateResult, type AgentCycleEndEvent, type AgentCycleStartEvent, type AgentDeleteInput, type AgentDeleteResult, type AgentEvent, type AgentEventEnvelope, type AgentFailTaskResult, type AgentForkInput, type AgentForkResult, type AgentInferenceEndEvent, type AgentInferenceStartEvent, type AgentInfoResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentRenameSessionResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, type AgentRunEndEvent, type AgentRunStartEvent, type AgentSession, type AgentSessionListOptions, type AgentSessionMetadata, AgentSessionNotFoundError, type AgentSessionPage, AgentStatus, type AgentStatusEvent, type AgentSuspendResult, type AgentToolResultEvent, type AgentToolStartEvent, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListItem, type AssetListOptions, AssetManager, type AssetMetadata, type AssetMetadataStore, AssetNotFoundError, type AssetPinResult, type AssetSummary, Auth, type AuthenticationKeyEntry, type AuthenticationKeysMap, type AuthenticationKeysResult, type AuthenticatorRevokeResult, BasicAuth, BearerAuth, ChatSession, type ConnectionAttempt, type ContentDetails, type ContentHashResult, CoviaConnectionError, type CoviaConnectionErrorOptions, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, type DLFSDrivesResult, type DLFSEntry, type DLFSListResult, DLFSManager, DataAsset, Ed25519Auth, type ExpandedAssetList, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, type MemoryChange, type MemoryEntry, MemoryManager, type MyAssetList, 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 Skill, type SkillFacet, SkillManager, type SkillMetadata, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, UnsupportedVenueFeatureError, type UserInfo, type UserListResult, UserManager, type UserSummary, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, VenueIdentityChangedError, 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
|
@@ -24,6 +24,12 @@ declare class Agent {
|
|
|
24
24
|
listSessions(options?: AgentSessionListOptions): Promise<AgentSessionPage>;
|
|
25
25
|
/** Read one session through the job-free workspace Values API. */
|
|
26
26
|
getSession(sessionId: string): Promise<AgentSession>;
|
|
27
|
+
/** Stream this agent's run-loop events. See `AgentManager.events`. */
|
|
28
|
+
events(options?: {
|
|
29
|
+
sessionId?: string;
|
|
30
|
+
detail?: boolean;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): AsyncGenerator<AgentEvent>;
|
|
27
33
|
/**
|
|
28
34
|
* Fork this agent into a new agent.
|
|
29
35
|
* @param agentId - ID for the new forked agent
|
|
@@ -100,7 +106,9 @@ declare class Job {
|
|
|
100
106
|
* Stream server-sent events for this job.
|
|
101
107
|
* @returns AsyncGenerator yielding SSEEvent objects
|
|
102
108
|
*/
|
|
103
|
-
stream(
|
|
109
|
+
stream(options?: {
|
|
110
|
+
signal?: AbortSignal;
|
|
111
|
+
}): AsyncGenerator<SSEEvent>;
|
|
104
112
|
/**
|
|
105
113
|
* Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
|
|
106
114
|
*/
|
|
@@ -365,6 +373,7 @@ interface AgentManagerVenue extends VenueRequestContext {
|
|
|
365
373
|
declare class AgentManager {
|
|
366
374
|
private venue;
|
|
367
375
|
private agentsGetSupported;
|
|
376
|
+
private agentSseSupported;
|
|
368
377
|
constructor(venue: AgentManagerVenue);
|
|
369
378
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
370
379
|
* 404'd, or if the venue's last known status identifies it as pre-0.4. */
|
|
@@ -413,6 +422,20 @@ declare class AgentManager {
|
|
|
413
422
|
/** Agent info. **Job-free** on covia ≥ 0.4 (`GET /api/v1/agents/{id}`,
|
|
414
423
|
* covia#180); older venues require an explicit compatibility opt-in. */
|
|
415
424
|
info(agentId: string): Promise<AgentInfoResult>;
|
|
425
|
+
/**
|
|
426
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
427
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
428
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
429
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
430
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
431
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
432
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
433
|
+
*/
|
|
434
|
+
events(agentId: string, options?: {
|
|
435
|
+
sessionId?: string;
|
|
436
|
+
detail?: boolean;
|
|
437
|
+
signal?: AbortSignal;
|
|
438
|
+
}): AsyncGenerator<AgentEvent>;
|
|
416
439
|
/**
|
|
417
440
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
418
441
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -439,7 +462,9 @@ declare class JobManager {
|
|
|
439
462
|
pause(jobId: string): Promise<JobMetadata>;
|
|
440
463
|
resume(jobId: string): Promise<JobMetadata>;
|
|
441
464
|
sendMessage(jobId: string, message: unknown): Promise<unknown>;
|
|
442
|
-
stream(jobId: string
|
|
465
|
+
stream(jobId: string, options?: {
|
|
466
|
+
signal?: AbortSignal;
|
|
467
|
+
}): AsyncGenerator<SSEEvent>;
|
|
443
468
|
}
|
|
444
469
|
|
|
445
470
|
interface AssetManagerVenue extends VenueRequestContext {
|
|
@@ -764,6 +789,45 @@ declare class DLFSManager {
|
|
|
764
789
|
getContent(drive: string, path: string): Promise<ReadableStream<Uint8Array>>;
|
|
765
790
|
}
|
|
766
791
|
|
|
792
|
+
interface UserManagerVenue extends VenueRequestContext {
|
|
793
|
+
operations: OperationRunner;
|
|
794
|
+
lastKnownStatus?: StatusData;
|
|
795
|
+
}
|
|
796
|
+
declare class UserManager {
|
|
797
|
+
private venue;
|
|
798
|
+
private usersSupported;
|
|
799
|
+
constructor(venue: UserManagerVenue);
|
|
800
|
+
/** A job-free users GET that rejects when the endpoint is unavailable. */
|
|
801
|
+
private usersGet;
|
|
802
|
+
/**
|
|
803
|
+
* List registered venue users. **Job-free** on covia venues serving
|
|
804
|
+
* `GET /api/v1/users` (covia#255) — synchronous, no Job persisted.
|
|
805
|
+
* Operator-only: throws a `GridError` with `statusCode` 403 for a
|
|
806
|
+
* signed-in caller that is not the venue itself and holds no venue-issued
|
|
807
|
+
* delegation over `<venueDID>/users` — that is an expected, common
|
|
808
|
+
* outcome to branch on, not a bug.
|
|
809
|
+
*/
|
|
810
|
+
list(): Promise<UserListResult>;
|
|
811
|
+
/**
|
|
812
|
+
* Get one registered user. The caller's own DID needs no operator
|
|
813
|
+
* authority; any other DID does (403 otherwise).
|
|
814
|
+
*/
|
|
815
|
+
info(did: string): Promise<UserInfo>;
|
|
816
|
+
/**
|
|
817
|
+
* List a venue-managed user's authenticators, active and revoked
|
|
818
|
+
* tombstones alike — revocation is a status transition in place, never a
|
|
819
|
+
* deletion. The caller's own DID needs no operator authority; any other
|
|
820
|
+
* DID does (403 otherwise).
|
|
821
|
+
*/
|
|
822
|
+
listAuthenticators(did: string): Promise<AuthenticationKeysResult>;
|
|
823
|
+
/**
|
|
824
|
+
* Revoke one of a venue-managed user's authenticators. A mutation, so —
|
|
825
|
+
* unlike the reads above — this goes through `operations.run` and mints a
|
|
826
|
+
* Job, matching every other write in this SDK (e.g. `SecretManager.set`).
|
|
827
|
+
*/
|
|
828
|
+
revokeAuthenticator(key: string, did?: string, ucans?: string[]): Promise<AuthenticatorRevokeResult>;
|
|
829
|
+
}
|
|
830
|
+
|
|
767
831
|
/**
|
|
768
832
|
* Resolve a non-DID venue id into the ordered list of base URLs that
|
|
769
833
|
* {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
|
|
@@ -819,6 +883,7 @@ declare class Venue implements VenueInterface {
|
|
|
819
883
|
private _skills?;
|
|
820
884
|
private _memory?;
|
|
821
885
|
private _dlfs?;
|
|
886
|
+
private _users?;
|
|
822
887
|
get adapters(): AdapterManager;
|
|
823
888
|
get agents(): AgentManager;
|
|
824
889
|
get jobs(): JobManager;
|
|
@@ -830,6 +895,7 @@ declare class Venue implements VenueInterface {
|
|
|
830
895
|
get skills(): SkillManager;
|
|
831
896
|
get memory(): MemoryManager;
|
|
832
897
|
get dlfs(): DLFSManager;
|
|
898
|
+
get users(): UserManager;
|
|
833
899
|
constructor(options?: VenueOptions);
|
|
834
900
|
/**
|
|
835
901
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
@@ -1074,6 +1140,12 @@ interface StatusData {
|
|
|
1074
1140
|
/** Venue platform version (e.g. "0.3.0"). Absent on venues before 0.3. */
|
|
1075
1141
|
version?: string;
|
|
1076
1142
|
stats?: StatsData;
|
|
1143
|
+
/** Curated admission-policy fields (#255) — safe to state to any caller.
|
|
1144
|
+
* Absent on venues before this shipped; treat as unknown, not false. */
|
|
1145
|
+
access?: {
|
|
1146
|
+
public: boolean;
|
|
1147
|
+
userAutoCreate: boolean;
|
|
1148
|
+
};
|
|
1077
1149
|
}
|
|
1078
1150
|
interface StatsData {
|
|
1079
1151
|
assets?: number;
|
|
@@ -1337,6 +1409,99 @@ interface AgentFailTaskResult {
|
|
|
1337
1409
|
taskId: string;
|
|
1338
1410
|
status: string;
|
|
1339
1411
|
}
|
|
1412
|
+
/** Fields present on every agent run-loop event frame (covia#394). */
|
|
1413
|
+
interface AgentEventEnvelope {
|
|
1414
|
+
seq: number;
|
|
1415
|
+
ts: number;
|
|
1416
|
+
agentId: string;
|
|
1417
|
+
address: string;
|
|
1418
|
+
}
|
|
1419
|
+
interface AgentRunStartEvent extends AgentEventEnvelope {
|
|
1420
|
+
type: 'run:start';
|
|
1421
|
+
run: number;
|
|
1422
|
+
}
|
|
1423
|
+
interface AgentRunEndEvent extends AgentEventEnvelope {
|
|
1424
|
+
type: 'run:end';
|
|
1425
|
+
run: number;
|
|
1426
|
+
status: AgentStatus;
|
|
1427
|
+
cycles: number;
|
|
1428
|
+
}
|
|
1429
|
+
interface AgentCycleStartEvent extends AgentEventEnvelope {
|
|
1430
|
+
type: 'cycle:start';
|
|
1431
|
+
run: number;
|
|
1432
|
+
cycle: number;
|
|
1433
|
+
op?: string;
|
|
1434
|
+
sessionId?: string;
|
|
1435
|
+
jobId?: string;
|
|
1436
|
+
jobs?: string[];
|
|
1437
|
+
tasks: unknown;
|
|
1438
|
+
messages: unknown;
|
|
1439
|
+
pending: unknown;
|
|
1440
|
+
}
|
|
1441
|
+
interface AgentCycleEndEvent extends AgentEventEnvelope {
|
|
1442
|
+
type: 'cycle:end';
|
|
1443
|
+
run: number;
|
|
1444
|
+
cycle: number;
|
|
1445
|
+
ms: number;
|
|
1446
|
+
response?: unknown;
|
|
1447
|
+
error?: string;
|
|
1448
|
+
tokens?: unknown;
|
|
1449
|
+
timeline?: unknown;
|
|
1450
|
+
detail?: {
|
|
1451
|
+
turns: unknown;
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
interface AgentInferenceStartEvent extends AgentEventEnvelope {
|
|
1455
|
+
type: 'inference:start';
|
|
1456
|
+
op: string;
|
|
1457
|
+
model?: string;
|
|
1458
|
+
messages: unknown;
|
|
1459
|
+
tools: unknown;
|
|
1460
|
+
bytes: number;
|
|
1461
|
+
budget: unknown;
|
|
1462
|
+
depth?: number;
|
|
1463
|
+
}
|
|
1464
|
+
interface AgentInferenceEndEvent extends AgentEventEnvelope {
|
|
1465
|
+
type: 'inference:end';
|
|
1466
|
+
ms: number;
|
|
1467
|
+
model?: string;
|
|
1468
|
+
content?: unknown;
|
|
1469
|
+
toolCalls?: {
|
|
1470
|
+
id: string;
|
|
1471
|
+
name: string;
|
|
1472
|
+
}[];
|
|
1473
|
+
tokens?: unknown;
|
|
1474
|
+
error?: string;
|
|
1475
|
+
depth?: number;
|
|
1476
|
+
}
|
|
1477
|
+
interface AgentToolStartEvent extends AgentEventEnvelope {
|
|
1478
|
+
type: 'tool:start';
|
|
1479
|
+
id: string;
|
|
1480
|
+
name: string;
|
|
1481
|
+
depth?: number;
|
|
1482
|
+
detail: {
|
|
1483
|
+
input: unknown;
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
interface AgentToolResultEvent extends AgentEventEnvelope {
|
|
1487
|
+
type: 'tool:result';
|
|
1488
|
+
id: string;
|
|
1489
|
+
name: string;
|
|
1490
|
+
ms: number;
|
|
1491
|
+
isError?: boolean;
|
|
1492
|
+
depth?: number;
|
|
1493
|
+
detail: {
|
|
1494
|
+
result: unknown;
|
|
1495
|
+
};
|
|
1496
|
+
}
|
|
1497
|
+
interface AgentStatusEvent extends AgentEventEnvelope {
|
|
1498
|
+
type: 'status';
|
|
1499
|
+
status: AgentStatus;
|
|
1500
|
+
error?: string;
|
|
1501
|
+
}
|
|
1502
|
+
/** One frame from the venue's agent run-loop event stream (`GET
|
|
1503
|
+
* /agents/{id}/sse`, covia#394), discriminated on `type`. */
|
|
1504
|
+
type AgentEvent = AgentRunStartEvent | AgentRunEndEvent | AgentCycleStartEvent | AgentCycleEndEvent | AgentInferenceStartEvent | AgentInferenceEndEvent | AgentToolStartEvent | AgentToolResultEvent | AgentStatusEvent;
|
|
1340
1505
|
interface AssetPinResult {
|
|
1341
1506
|
path: string;
|
|
1342
1507
|
hash: string;
|
|
@@ -1527,6 +1692,50 @@ interface DLFSListResult {
|
|
|
1527
1692
|
entries: DLFSEntry[];
|
|
1528
1693
|
warnings?: string[];
|
|
1529
1694
|
}
|
|
1695
|
+
interface UserSummary {
|
|
1696
|
+
did: string;
|
|
1697
|
+
registered: boolean;
|
|
1698
|
+
/** True for a venue-managed named account (a did:web identity minted from
|
|
1699
|
+
* a username); false/absent for a plain registered DID. */
|
|
1700
|
+
managed?: boolean;
|
|
1701
|
+
meta?: Record<string, unknown>;
|
|
1702
|
+
}
|
|
1703
|
+
interface UserListResult {
|
|
1704
|
+
users: UserSummary[];
|
|
1705
|
+
total: number;
|
|
1706
|
+
}
|
|
1707
|
+
interface UserInfo {
|
|
1708
|
+
did: string;
|
|
1709
|
+
registered: boolean;
|
|
1710
|
+
managed?: boolean;
|
|
1711
|
+
meta?: Record<string, unknown>;
|
|
1712
|
+
}
|
|
1713
|
+
/** One authenticator's lifecycle record. Revocation is a status transition
|
|
1714
|
+
* in place — a revoked entry is retained forever, never deleted, so the
|
|
1715
|
+
* key's full add/revoke history stays visible as an audit tombstone. */
|
|
1716
|
+
interface AuthenticationKeyEntry {
|
|
1717
|
+
status: "active" | "revoked";
|
|
1718
|
+
/** Epoch millis. */
|
|
1719
|
+
addedAt: number;
|
|
1720
|
+
/** Actor DID that added this key. */
|
|
1721
|
+
addedBy: string;
|
|
1722
|
+
label?: string;
|
|
1723
|
+
/** Epoch millis, present only once status is "revoked". */
|
|
1724
|
+
revokedAt?: number;
|
|
1725
|
+
/** Actor DID that revoked this key, present only once status is "revoked". */
|
|
1726
|
+
revokedBy?: string;
|
|
1727
|
+
}
|
|
1728
|
+
/** Keyed by the authenticator's own `did:key:...` string. */
|
|
1729
|
+
type AuthenticationKeysMap = Record<string, AuthenticationKeyEntry>;
|
|
1730
|
+
interface AuthenticationKeysResult {
|
|
1731
|
+
did: string;
|
|
1732
|
+
authenticationKeys: AuthenticationKeysMap;
|
|
1733
|
+
}
|
|
1734
|
+
interface AuthenticatorRevokeResult {
|
|
1735
|
+
did: string;
|
|
1736
|
+
key: string;
|
|
1737
|
+
revoked: boolean;
|
|
1738
|
+
}
|
|
1530
1739
|
interface FunctionInfo {
|
|
1531
1740
|
name: string;
|
|
1532
1741
|
id: string;
|
|
@@ -1702,9 +1911,13 @@ declare function createSSEEvent(fields: {
|
|
|
1702
1911
|
}): SSEEvent;
|
|
1703
1912
|
/**
|
|
1704
1913
|
* Parse an SSE stream from a fetch Response body.
|
|
1705
|
-
* Yields SSEEvent objects as they arrive.
|
|
1914
|
+
* Yields SSEEvent objects as they arrive. On `signal` abort, iteration ends
|
|
1915
|
+
* as if the stream closed (no exception thrown); callers that must
|
|
1916
|
+
* distinguish should check `signal.aborted` after the loop.
|
|
1706
1917
|
*/
|
|
1707
|
-
declare function parseSSEStream(response: Response
|
|
1918
|
+
declare function parseSSEStream(response: Response, options?: {
|
|
1919
|
+
signal?: AbortSignal;
|
|
1920
|
+
}): AsyncGenerator<SSEEvent>;
|
|
1708
1921
|
|
|
1709
1922
|
/**
|
|
1710
1923
|
* DID and lattice-path helpers for the Covia grid.
|
|
@@ -1934,4 +2147,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
1934
2147
|
*/
|
|
1935
2148
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
1936
2149
|
|
|
1937
|
-
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 AgentRenameSessionResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, type AgentSession, type AgentSessionListOptions, type AgentSessionMetadata, AgentSessionNotFoundError, type AgentSessionPage, AgentStatus, type AgentSuspendResult, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListItem, type AssetListOptions, AssetManager, type AssetMetadata, type AssetMetadataStore, AssetNotFoundError, type AssetPinResult, type AssetSummary, Auth, BasicAuth, BearerAuth, ChatSession, type ConnectionAttempt, type ContentDetails, type ContentHashResult, CoviaConnectionError, type CoviaConnectionErrorOptions, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, type DLFSDrivesResult, type DLFSEntry, type DLFSListResult, DLFSManager, DataAsset, Ed25519Auth, type ExpandedAssetList, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, type MemoryChange, type MemoryEntry, MemoryManager, type MyAssetList, 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 Skill, type SkillFacet, SkillManager, type SkillMetadata, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, UnsupportedVenueFeatureError, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, VenueIdentityChangedError, 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 };
|
|
2150
|
+
export { type AdapterInfo, AdapterManager, type AdaptersResult, Agent, type AgentCancelTaskInput, type AgentCard, type AgentChatInput, type AgentChatResult, type AgentCompleteTaskResult, type AgentContextInput, type AgentCreateInput, type AgentCreateResult, type AgentCycleEndEvent, type AgentCycleStartEvent, type AgentDeleteInput, type AgentDeleteResult, type AgentEvent, type AgentEventEnvelope, type AgentFailTaskResult, type AgentForkInput, type AgentForkResult, type AgentInferenceEndEvent, type AgentInferenceStartEvent, type AgentInfoResult, type AgentListInput, type AgentListResult, AgentManager, type AgentMessageInput, type AgentMessageResult, type AgentRenameSessionResult, type AgentRequestInput, type AgentRequestResult, type AgentResumeInput, type AgentRunEndEvent, type AgentRunStartEvent, type AgentSession, type AgentSessionListOptions, type AgentSessionMetadata, AgentSessionNotFoundError, type AgentSessionPage, AgentStatus, type AgentStatusEvent, type AgentSuspendResult, type AgentToolResultEvent, type AgentToolStartEvent, type AgentTriggerInput, type AgentTriggerResult, type AgentUpdateInput, Asset, type AssetID, type AssetList, type AssetListItem, type AssetListOptions, AssetManager, type AssetMetadata, type AssetMetadataStore, AssetNotFoundError, type AssetPinResult, type AssetSummary, Auth, type AuthenticationKeyEntry, type AuthenticationKeysMap, type AuthenticationKeysResult, type AuthenticatorRevokeResult, BasicAuth, BearerAuth, ChatSession, type ConnectionAttempt, type ContentDetails, type ContentHashResult, CoviaConnectionError, type CoviaConnectionErrorOptions, CoviaError, CoviaTimeoutError, type Credentials, CredentialsHTTP, type DIDDocument, type DIDURL, type DLFSDrivesResult, type DLFSEntry, type DLFSListResult, DLFSManager, DataAsset, Ed25519Auth, type ExpandedAssetList, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPDiscovery, type MemoryChange, type MemoryEntry, MemoryManager, type MyAssetList, 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 Skill, type SkillFacet, SkillManager, type SkillMetadata, type StatsData, type StatusData, type UCANAttenuation, type UCANCapability, type UCANIssueInput, type UCANIssueResult, UCANManager, type UCANVerifyResult, UnsupportedVenueFeatureError, type UserInfo, type UserListResult, UserManager, type UserSummary, VENUE_RELAY, Venue, type VenueConstructor, type VenueData, VenueIdentityChangedError, 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
|
@@ -1503,7 +1503,7 @@ function createSSEEvent(fields) {
|
|
|
1503
1503
|
}
|
|
1504
1504
|
};
|
|
1505
1505
|
}
|
|
1506
|
-
async function* parseSSEStream(response) {
|
|
1506
|
+
async function* parseSSEStream(response, options) {
|
|
1507
1507
|
const reader = response.body?.getReader();
|
|
1508
1508
|
if (!reader) return;
|
|
1509
1509
|
const decoder = new TextDecoder();
|
|
@@ -1512,9 +1512,26 @@ async function* parseSSEStream(response) {
|
|
|
1512
1512
|
let data = [];
|
|
1513
1513
|
let id;
|
|
1514
1514
|
let retry;
|
|
1515
|
+
const signal = options?.signal;
|
|
1516
|
+
const onAbort = () => {
|
|
1517
|
+
void reader.cancel(signal.reason).catch(() => {
|
|
1518
|
+
});
|
|
1519
|
+
};
|
|
1520
|
+
if (signal) {
|
|
1521
|
+
if (signal.aborted) void reader.cancel(signal.reason).catch(() => {
|
|
1522
|
+
});
|
|
1523
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
1524
|
+
}
|
|
1515
1525
|
try {
|
|
1516
1526
|
while (true) {
|
|
1517
|
-
|
|
1527
|
+
let result;
|
|
1528
|
+
try {
|
|
1529
|
+
result = await reader.read();
|
|
1530
|
+
} catch (err2) {
|
|
1531
|
+
if (signal?.aborted) break;
|
|
1532
|
+
throw err2;
|
|
1533
|
+
}
|
|
1534
|
+
const { done, value } = result;
|
|
1518
1535
|
if (done) break;
|
|
1519
1536
|
buffer += decoder.decode(value, { stream: true });
|
|
1520
1537
|
const lines = buffer.split("\n");
|
|
@@ -1569,7 +1586,9 @@ async function* parseSSEStream(response) {
|
|
|
1569
1586
|
yield createSSEEvent({ event, data: data.join("\n"), id, retry });
|
|
1570
1587
|
}
|
|
1571
1588
|
} finally {
|
|
1572
|
-
|
|
1589
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1590
|
+
await reader.cancel().catch(() => {
|
|
1591
|
+
});
|
|
1573
1592
|
}
|
|
1574
1593
|
}
|
|
1575
1594
|
|
|
@@ -1746,6 +1765,11 @@ var AgentManager = class {
|
|
|
1746
1765
|
// Whether this venue serves GET /api/v1/agents — flipped on the first 404 so
|
|
1747
1766
|
// pre-0.4 venues pay the probe once, not one failed GET per read (covia#180).
|
|
1748
1767
|
this.agentsGetSupported = true;
|
|
1768
|
+
// Whether this venue serves GET /api/v1/agents/{id}/sse — flipped on a
|
|
1769
|
+
// route-missing 404 (covia#394 landed in venue 0.9.7). No version fast-path:
|
|
1770
|
+
// versionAtLeast() only resolves major.minor, not the patch precision this
|
|
1771
|
+
// needs, so rely purely on the lazy 404 latch (matches UserManager.usersGet).
|
|
1772
|
+
this.agentSseSupported = true;
|
|
1749
1773
|
}
|
|
1750
1774
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
1751
1775
|
* 404'd, or if the venue's last known status identifies it as pre-0.4. */
|
|
@@ -1848,6 +1872,38 @@ var AgentManager = class {
|
|
|
1848
1872
|
async info(agentId) {
|
|
1849
1873
|
return this.agentsGet(`/${encodeURIComponent(agentId)}`, {});
|
|
1850
1874
|
}
|
|
1875
|
+
/**
|
|
1876
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
1877
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
1878
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
1879
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
1880
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
1881
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
1882
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
1883
|
+
*/
|
|
1884
|
+
async *events(agentId, options = {}) {
|
|
1885
|
+
if (!this.agentSseSupported) throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1886
|
+
const qs = new URLSearchParams();
|
|
1887
|
+
if (options.sessionId !== void 0) qs.set("sessionId", options.sessionId);
|
|
1888
|
+
if (options.detail !== void 0) qs.set("detail", String(options.detail));
|
|
1889
|
+
const q = qs.toString();
|
|
1890
|
+
let response;
|
|
1891
|
+
try {
|
|
1892
|
+
response = await venueStream(
|
|
1893
|
+
this.venue,
|
|
1894
|
+
`/api/v1/agents/${encodeURIComponent(agentId)}/sse${q ? `?${q}` : ""}`,
|
|
1895
|
+
{ headers: { "Accept": "text/event-stream" }, signal: options.signal }
|
|
1896
|
+
);
|
|
1897
|
+
} catch (e) {
|
|
1898
|
+
if (!(e instanceof NotFoundError)) throw e;
|
|
1899
|
+
if (!ROUTE_MISSING_404.test(e.message)) throw e;
|
|
1900
|
+
this.agentSseSupported = false;
|
|
1901
|
+
throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1902
|
+
}
|
|
1903
|
+
for await (const evt of parseSSEStream(response, { signal: options.signal })) {
|
|
1904
|
+
yield evt.json();
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1851
1907
|
/**
|
|
1852
1908
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
1853
1909
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -1998,8 +2054,8 @@ var Job = class {
|
|
|
1998
2054
|
* Stream server-sent events for this job.
|
|
1999
2055
|
* @returns AsyncGenerator yielding SSEEvent objects
|
|
2000
2056
|
*/
|
|
2001
|
-
async *stream() {
|
|
2002
|
-
yield* this._jobs.stream(this.id);
|
|
2057
|
+
async *stream(options) {
|
|
2058
|
+
yield* this._jobs.stream(this.id, options);
|
|
2003
2059
|
}
|
|
2004
2060
|
/**
|
|
2005
2061
|
* Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
|
|
@@ -2173,11 +2229,12 @@ var JobManager = class {
|
|
|
2173
2229
|
throw error;
|
|
2174
2230
|
}
|
|
2175
2231
|
}
|
|
2176
|
-
async *stream(jobId) {
|
|
2232
|
+
async *stream(jobId, options) {
|
|
2177
2233
|
const response = await venueStream(this.venue, `/api/v1/jobs/${jobId}/sse`, {
|
|
2178
|
-
headers: { "Accept": "text/event-stream" }
|
|
2234
|
+
headers: { "Accept": "text/event-stream" },
|
|
2235
|
+
signal: options?.signal
|
|
2179
2236
|
});
|
|
2180
|
-
yield* parseSSEStream(response);
|
|
2237
|
+
yield* parseSSEStream(response, { signal: options?.signal });
|
|
2181
2238
|
}
|
|
2182
2239
|
};
|
|
2183
2240
|
|
|
@@ -2851,6 +2908,68 @@ var DLFSManager = class {
|
|
|
2851
2908
|
}
|
|
2852
2909
|
};
|
|
2853
2910
|
|
|
2911
|
+
// src/UserManager.ts
|
|
2912
|
+
var UserManager = class {
|
|
2913
|
+
constructor(venue) {
|
|
2914
|
+
this.venue = venue;
|
|
2915
|
+
// Whether this venue serves GET /api/v1/users — flipped on a route-missing
|
|
2916
|
+
// 404 so a pre-#255 venue pays the probe once, not one failed GET per read.
|
|
2917
|
+
this.usersSupported = true;
|
|
2918
|
+
}
|
|
2919
|
+
/** A job-free users GET that rejects when the endpoint is unavailable. */
|
|
2920
|
+
async usersGet(path) {
|
|
2921
|
+
if (!this.usersSupported) throw new UnsupportedVenueFeatureError("venue users");
|
|
2922
|
+
try {
|
|
2923
|
+
return await venueJson(this.venue, `/api/v1/users${path}`);
|
|
2924
|
+
} catch (e) {
|
|
2925
|
+
if (!(e instanceof NotFoundError)) throw e;
|
|
2926
|
+
const routeMissing = path === "" || ROUTE_MISSING_404.test(e.message);
|
|
2927
|
+
if (!routeMissing) throw e;
|
|
2928
|
+
this.usersSupported = false;
|
|
2929
|
+
throw new UnsupportedVenueFeatureError("venue users");
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* List registered venue users. **Job-free** on covia venues serving
|
|
2934
|
+
* `GET /api/v1/users` (covia#255) — synchronous, no Job persisted.
|
|
2935
|
+
* Operator-only: throws a `GridError` with `statusCode` 403 for a
|
|
2936
|
+
* signed-in caller that is not the venue itself and holds no venue-issued
|
|
2937
|
+
* delegation over `<venueDID>/users` — that is an expected, common
|
|
2938
|
+
* outcome to branch on, not a bug.
|
|
2939
|
+
*/
|
|
2940
|
+
async list() {
|
|
2941
|
+
return this.usersGet("");
|
|
2942
|
+
}
|
|
2943
|
+
/**
|
|
2944
|
+
* Get one registered user. The caller's own DID needs no operator
|
|
2945
|
+
* authority; any other DID does (403 otherwise).
|
|
2946
|
+
*/
|
|
2947
|
+
async info(did) {
|
|
2948
|
+
return this.usersGet(`/${encodeURIComponent(did)}`);
|
|
2949
|
+
}
|
|
2950
|
+
/**
|
|
2951
|
+
* List a venue-managed user's authenticators, active and revoked
|
|
2952
|
+
* tombstones alike — revocation is a status transition in place, never a
|
|
2953
|
+
* deletion. The caller's own DID needs no operator authority; any other
|
|
2954
|
+
* DID does (403 otherwise).
|
|
2955
|
+
*/
|
|
2956
|
+
async listAuthenticators(did) {
|
|
2957
|
+
return this.usersGet(`/${encodeURIComponent(did)}/authentications`);
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* Revoke one of a venue-managed user's authenticators. A mutation, so —
|
|
2961
|
+
* unlike the reads above — this goes through `operations.run` and mints a
|
|
2962
|
+
* Job, matching every other write in this SDK (e.g. `SecretManager.set`).
|
|
2963
|
+
*/
|
|
2964
|
+
async revokeAuthenticator(key, did, ucans) {
|
|
2965
|
+
return this.venue.operations.run(
|
|
2966
|
+
"v/ops/user/authentication-revoke",
|
|
2967
|
+
{ did, key },
|
|
2968
|
+
{ ucans }
|
|
2969
|
+
);
|
|
2970
|
+
}
|
|
2971
|
+
};
|
|
2972
|
+
|
|
2854
2973
|
// src/Agent.ts
|
|
2855
2974
|
var Agent = class _Agent {
|
|
2856
2975
|
constructor(id, venue) {
|
|
@@ -2900,6 +3019,10 @@ var Agent = class _Agent {
|
|
|
2900
3019
|
async getSession(sessionId) {
|
|
2901
3020
|
return this._agents.getSession(this.id, sessionId);
|
|
2902
3021
|
}
|
|
3022
|
+
/** Stream this agent's run-loop events. See `AgentManager.events`. */
|
|
3023
|
+
async *events(options) {
|
|
3024
|
+
yield* this._agents.events(this.id, options);
|
|
3025
|
+
}
|
|
2903
3026
|
/**
|
|
2904
3027
|
* Fork this agent into a new agent.
|
|
2905
3028
|
* @param agentId - ID for the new forked agent
|
|
@@ -3052,6 +3175,9 @@ var Venue = class _Venue {
|
|
|
3052
3175
|
get dlfs() {
|
|
3053
3176
|
return this._dlfs ?? (this._dlfs = new DLFSManager(this));
|
|
3054
3177
|
}
|
|
3178
|
+
get users() {
|
|
3179
|
+
return this._users ?? (this._users = new UserManager(this));
|
|
3180
|
+
}
|
|
3055
3181
|
/**
|
|
3056
3182
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
3057
3183
|
* venue is auth-gated (status answers 401/403 — public access disabled), the
|
|
@@ -3422,6 +3548,7 @@ exports.SecretManager = SecretManager;
|
|
|
3422
3548
|
exports.SkillManager = SkillManager;
|
|
3423
3549
|
exports.UCANManager = UCANManager;
|
|
3424
3550
|
exports.UnsupportedVenueFeatureError = UnsupportedVenueFeatureError;
|
|
3551
|
+
exports.UserManager = UserManager;
|
|
3425
3552
|
exports.VENUE_RELAY = VENUE_RELAY;
|
|
3426
3553
|
exports.Venue = Venue;
|
|
3427
3554
|
exports.VenueIdentityChangedError = VenueIdentityChangedError;
|
package/dist/index.mjs
CHANGED
|
@@ -1501,7 +1501,7 @@ function createSSEEvent(fields) {
|
|
|
1501
1501
|
}
|
|
1502
1502
|
};
|
|
1503
1503
|
}
|
|
1504
|
-
async function* parseSSEStream(response) {
|
|
1504
|
+
async function* parseSSEStream(response, options) {
|
|
1505
1505
|
const reader = response.body?.getReader();
|
|
1506
1506
|
if (!reader) return;
|
|
1507
1507
|
const decoder = new TextDecoder();
|
|
@@ -1510,9 +1510,26 @@ async function* parseSSEStream(response) {
|
|
|
1510
1510
|
let data = [];
|
|
1511
1511
|
let id;
|
|
1512
1512
|
let retry;
|
|
1513
|
+
const signal = options?.signal;
|
|
1514
|
+
const onAbort = () => {
|
|
1515
|
+
void reader.cancel(signal.reason).catch(() => {
|
|
1516
|
+
});
|
|
1517
|
+
};
|
|
1518
|
+
if (signal) {
|
|
1519
|
+
if (signal.aborted) void reader.cancel(signal.reason).catch(() => {
|
|
1520
|
+
});
|
|
1521
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
1522
|
+
}
|
|
1513
1523
|
try {
|
|
1514
1524
|
while (true) {
|
|
1515
|
-
|
|
1525
|
+
let result;
|
|
1526
|
+
try {
|
|
1527
|
+
result = await reader.read();
|
|
1528
|
+
} catch (err2) {
|
|
1529
|
+
if (signal?.aborted) break;
|
|
1530
|
+
throw err2;
|
|
1531
|
+
}
|
|
1532
|
+
const { done, value } = result;
|
|
1516
1533
|
if (done) break;
|
|
1517
1534
|
buffer += decoder.decode(value, { stream: true });
|
|
1518
1535
|
const lines = buffer.split("\n");
|
|
@@ -1567,7 +1584,9 @@ async function* parseSSEStream(response) {
|
|
|
1567
1584
|
yield createSSEEvent({ event, data: data.join("\n"), id, retry });
|
|
1568
1585
|
}
|
|
1569
1586
|
} finally {
|
|
1570
|
-
|
|
1587
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1588
|
+
await reader.cancel().catch(() => {
|
|
1589
|
+
});
|
|
1571
1590
|
}
|
|
1572
1591
|
}
|
|
1573
1592
|
|
|
@@ -1744,6 +1763,11 @@ var AgentManager = class {
|
|
|
1744
1763
|
// Whether this venue serves GET /api/v1/agents — flipped on the first 404 so
|
|
1745
1764
|
// pre-0.4 venues pay the probe once, not one failed GET per read (covia#180).
|
|
1746
1765
|
this.agentsGetSupported = true;
|
|
1766
|
+
// Whether this venue serves GET /api/v1/agents/{id}/sse — flipped on a
|
|
1767
|
+
// route-missing 404 (covia#394 landed in venue 0.9.7). No version fast-path:
|
|
1768
|
+
// versionAtLeast() only resolves major.minor, not the patch precision this
|
|
1769
|
+
// needs, so rely purely on the lazy 404 latch (matches UserManager.usersGet).
|
|
1770
|
+
this.agentSseSupported = true;
|
|
1747
1771
|
}
|
|
1748
1772
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
1749
1773
|
* 404'd, or if the venue's last known status identifies it as pre-0.4. */
|
|
@@ -1846,6 +1870,38 @@ var AgentManager = class {
|
|
|
1846
1870
|
async info(agentId) {
|
|
1847
1871
|
return this.agentsGet(`/${encodeURIComponent(agentId)}`, {});
|
|
1848
1872
|
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
1875
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
1876
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
1877
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
1878
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
1879
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
1880
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
1881
|
+
*/
|
|
1882
|
+
async *events(agentId, options = {}) {
|
|
1883
|
+
if (!this.agentSseSupported) throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1884
|
+
const qs = new URLSearchParams();
|
|
1885
|
+
if (options.sessionId !== void 0) qs.set("sessionId", options.sessionId);
|
|
1886
|
+
if (options.detail !== void 0) qs.set("detail", String(options.detail));
|
|
1887
|
+
const q = qs.toString();
|
|
1888
|
+
let response;
|
|
1889
|
+
try {
|
|
1890
|
+
response = await venueStream(
|
|
1891
|
+
this.venue,
|
|
1892
|
+
`/api/v1/agents/${encodeURIComponent(agentId)}/sse${q ? `?${q}` : ""}`,
|
|
1893
|
+
{ headers: { "Accept": "text/event-stream" }, signal: options.signal }
|
|
1894
|
+
);
|
|
1895
|
+
} catch (e) {
|
|
1896
|
+
if (!(e instanceof NotFoundError)) throw e;
|
|
1897
|
+
if (!ROUTE_MISSING_404.test(e.message)) throw e;
|
|
1898
|
+
this.agentSseSupported = false;
|
|
1899
|
+
throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1900
|
+
}
|
|
1901
|
+
for await (const evt of parseSSEStream(response, { signal: options.signal })) {
|
|
1902
|
+
yield evt.json();
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1849
1905
|
/**
|
|
1850
1906
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
1851
1907
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -1996,8 +2052,8 @@ var Job = class {
|
|
|
1996
2052
|
* Stream server-sent events for this job.
|
|
1997
2053
|
* @returns AsyncGenerator yielding SSEEvent objects
|
|
1998
2054
|
*/
|
|
1999
|
-
async *stream() {
|
|
2000
|
-
yield* this._jobs.stream(this.id);
|
|
2055
|
+
async *stream(options) {
|
|
2056
|
+
yield* this._jobs.stream(this.id, options);
|
|
2001
2057
|
}
|
|
2002
2058
|
/**
|
|
2003
2059
|
* Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
|
|
@@ -2171,11 +2227,12 @@ var JobManager = class {
|
|
|
2171
2227
|
throw error;
|
|
2172
2228
|
}
|
|
2173
2229
|
}
|
|
2174
|
-
async *stream(jobId) {
|
|
2230
|
+
async *stream(jobId, options) {
|
|
2175
2231
|
const response = await venueStream(this.venue, `/api/v1/jobs/${jobId}/sse`, {
|
|
2176
|
-
headers: { "Accept": "text/event-stream" }
|
|
2232
|
+
headers: { "Accept": "text/event-stream" },
|
|
2233
|
+
signal: options?.signal
|
|
2177
2234
|
});
|
|
2178
|
-
yield* parseSSEStream(response);
|
|
2235
|
+
yield* parseSSEStream(response, { signal: options?.signal });
|
|
2179
2236
|
}
|
|
2180
2237
|
};
|
|
2181
2238
|
|
|
@@ -2849,6 +2906,68 @@ var DLFSManager = class {
|
|
|
2849
2906
|
}
|
|
2850
2907
|
};
|
|
2851
2908
|
|
|
2909
|
+
// src/UserManager.ts
|
|
2910
|
+
var UserManager = class {
|
|
2911
|
+
constructor(venue) {
|
|
2912
|
+
this.venue = venue;
|
|
2913
|
+
// Whether this venue serves GET /api/v1/users — flipped on a route-missing
|
|
2914
|
+
// 404 so a pre-#255 venue pays the probe once, not one failed GET per read.
|
|
2915
|
+
this.usersSupported = true;
|
|
2916
|
+
}
|
|
2917
|
+
/** A job-free users GET that rejects when the endpoint is unavailable. */
|
|
2918
|
+
async usersGet(path) {
|
|
2919
|
+
if (!this.usersSupported) throw new UnsupportedVenueFeatureError("venue users");
|
|
2920
|
+
try {
|
|
2921
|
+
return await venueJson(this.venue, `/api/v1/users${path}`);
|
|
2922
|
+
} catch (e) {
|
|
2923
|
+
if (!(e instanceof NotFoundError)) throw e;
|
|
2924
|
+
const routeMissing = path === "" || ROUTE_MISSING_404.test(e.message);
|
|
2925
|
+
if (!routeMissing) throw e;
|
|
2926
|
+
this.usersSupported = false;
|
|
2927
|
+
throw new UnsupportedVenueFeatureError("venue users");
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
/**
|
|
2931
|
+
* List registered venue users. **Job-free** on covia venues serving
|
|
2932
|
+
* `GET /api/v1/users` (covia#255) — synchronous, no Job persisted.
|
|
2933
|
+
* Operator-only: throws a `GridError` with `statusCode` 403 for a
|
|
2934
|
+
* signed-in caller that is not the venue itself and holds no venue-issued
|
|
2935
|
+
* delegation over `<venueDID>/users` — that is an expected, common
|
|
2936
|
+
* outcome to branch on, not a bug.
|
|
2937
|
+
*/
|
|
2938
|
+
async list() {
|
|
2939
|
+
return this.usersGet("");
|
|
2940
|
+
}
|
|
2941
|
+
/**
|
|
2942
|
+
* Get one registered user. The caller's own DID needs no operator
|
|
2943
|
+
* authority; any other DID does (403 otherwise).
|
|
2944
|
+
*/
|
|
2945
|
+
async info(did) {
|
|
2946
|
+
return this.usersGet(`/${encodeURIComponent(did)}`);
|
|
2947
|
+
}
|
|
2948
|
+
/**
|
|
2949
|
+
* List a venue-managed user's authenticators, active and revoked
|
|
2950
|
+
* tombstones alike — revocation is a status transition in place, never a
|
|
2951
|
+
* deletion. The caller's own DID needs no operator authority; any other
|
|
2952
|
+
* DID does (403 otherwise).
|
|
2953
|
+
*/
|
|
2954
|
+
async listAuthenticators(did) {
|
|
2955
|
+
return this.usersGet(`/${encodeURIComponent(did)}/authentications`);
|
|
2956
|
+
}
|
|
2957
|
+
/**
|
|
2958
|
+
* Revoke one of a venue-managed user's authenticators. A mutation, so —
|
|
2959
|
+
* unlike the reads above — this goes through `operations.run` and mints a
|
|
2960
|
+
* Job, matching every other write in this SDK (e.g. `SecretManager.set`).
|
|
2961
|
+
*/
|
|
2962
|
+
async revokeAuthenticator(key, did, ucans) {
|
|
2963
|
+
return this.venue.operations.run(
|
|
2964
|
+
"v/ops/user/authentication-revoke",
|
|
2965
|
+
{ did, key },
|
|
2966
|
+
{ ucans }
|
|
2967
|
+
);
|
|
2968
|
+
}
|
|
2969
|
+
};
|
|
2970
|
+
|
|
2852
2971
|
// src/Agent.ts
|
|
2853
2972
|
var Agent = class _Agent {
|
|
2854
2973
|
constructor(id, venue) {
|
|
@@ -2898,6 +3017,10 @@ var Agent = class _Agent {
|
|
|
2898
3017
|
async getSession(sessionId) {
|
|
2899
3018
|
return this._agents.getSession(this.id, sessionId);
|
|
2900
3019
|
}
|
|
3020
|
+
/** Stream this agent's run-loop events. See `AgentManager.events`. */
|
|
3021
|
+
async *events(options) {
|
|
3022
|
+
yield* this._agents.events(this.id, options);
|
|
3023
|
+
}
|
|
2901
3024
|
/**
|
|
2902
3025
|
* Fork this agent into a new agent.
|
|
2903
3026
|
* @param agentId - ID for the new forked agent
|
|
@@ -3050,6 +3173,9 @@ var Venue = class _Venue {
|
|
|
3050
3173
|
get dlfs() {
|
|
3051
3174
|
return this._dlfs ?? (this._dlfs = new DLFSManager(this));
|
|
3052
3175
|
}
|
|
3176
|
+
get users() {
|
|
3177
|
+
return this._users ?? (this._users = new UserManager(this));
|
|
3178
|
+
}
|
|
3053
3179
|
/**
|
|
3054
3180
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
3055
3181
|
* venue is auth-gated (status answers 401/403 — public access disabled), the
|
|
@@ -3381,4 +3507,4 @@ function relayDelegation(privateKey, venueDID, lifetimeSeconds, caps = []) {
|
|
|
3381
3507
|
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
3382
3508
|
*/
|
|
3383
3509
|
|
|
3384
|
-
export { AdapterManager, Agent, AgentManager, AgentSessionNotFoundError, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BasicAuth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DLFSManager, DataAsset, Ed25519Auth, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, MemoryManager, Namespace, NoAuth, NotFoundError, Operation, OperationManager, RateLimitError, RunStatus, SecretManager, SkillManager, UCANManager, UnsupportedVenueFeatureError, VENUE_RELAY, Venue, VenueIdentityChangedError, 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 };
|
|
3510
|
+
export { AdapterManager, Agent, AgentManager, AgentSessionNotFoundError, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BasicAuth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DLFSManager, DataAsset, Ed25519Auth, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, MemoryManager, Namespace, NoAuth, NotFoundError, Operation, OperationManager, RateLimitError, RunStatus, SecretManager, SkillManager, UCANManager, UnsupportedVenueFeatureError, UserManager, VENUE_RELAY, Venue, VenueIdentityChangedError, 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 };
|