@covia/covia-sdk 1.13.0 → 1.15.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 +239 -11
- package/dist/index.d.ts +239 -11
- package/dist/index.js +119 -28
- package/dist/index.mjs +119 -29
- 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
|
*/
|
|
@@ -360,14 +368,17 @@ interface AgentManagerVenue extends VenueRequestContext {
|
|
|
360
368
|
read(path: string, maxSize?: number): Promise<WorkspaceReadResult>;
|
|
361
369
|
slice(path: string, offset?: number, limit?: number): Promise<WorkspaceSliceResult>;
|
|
362
370
|
};
|
|
363
|
-
lastKnownStatus?: StatusData;
|
|
364
371
|
}
|
|
365
372
|
declare class AgentManager {
|
|
366
373
|
private venue;
|
|
367
374
|
private agentsGetSupported;
|
|
375
|
+
private agentSseSupported;
|
|
368
376
|
constructor(venue: AgentManagerVenue);
|
|
369
377
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
370
|
-
* 404'd
|
|
378
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
379
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
380
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
381
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet. */
|
|
371
382
|
private supportsAgentsGet;
|
|
372
383
|
/** A job-free agents GET that rejects when the endpoint is unavailable. */
|
|
373
384
|
private agentsGet;
|
|
@@ -413,6 +424,20 @@ declare class AgentManager {
|
|
|
413
424
|
/** Agent info. **Job-free** on covia ≥ 0.4 (`GET /api/v1/agents/{id}`,
|
|
414
425
|
* covia#180); older venues require an explicit compatibility opt-in. */
|
|
415
426
|
info(agentId: string): Promise<AgentInfoResult>;
|
|
427
|
+
/**
|
|
428
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
429
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
430
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
431
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
432
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
433
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
434
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
435
|
+
*/
|
|
436
|
+
events(agentId: string, options?: {
|
|
437
|
+
sessionId?: string;
|
|
438
|
+
detail?: boolean;
|
|
439
|
+
signal?: AbortSignal;
|
|
440
|
+
}): AsyncGenerator<AgentEvent>;
|
|
416
441
|
/**
|
|
417
442
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
418
443
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -439,7 +464,9 @@ declare class JobManager {
|
|
|
439
464
|
pause(jobId: string): Promise<JobMetadata>;
|
|
440
465
|
resume(jobId: string): Promise<JobMetadata>;
|
|
441
466
|
sendMessage(jobId: string, message: unknown): Promise<unknown>;
|
|
442
|
-
stream(jobId: string
|
|
467
|
+
stream(jobId: string, options?: {
|
|
468
|
+
signal?: AbortSignal;
|
|
469
|
+
}): AsyncGenerator<SSEEvent>;
|
|
443
470
|
}
|
|
444
471
|
|
|
445
472
|
interface AssetManagerVenue extends VenueRequestContext {
|
|
@@ -556,7 +583,6 @@ declare class OperationManager {
|
|
|
556
583
|
|
|
557
584
|
interface WorkspaceManagerVenue extends VenueRequestContext {
|
|
558
585
|
operations: OperationRunner;
|
|
559
|
-
lastKnownStatus?: StatusData;
|
|
560
586
|
}
|
|
561
587
|
/**
|
|
562
588
|
* Workspace (lattice) operations against a venue.
|
|
@@ -584,9 +610,10 @@ declare class WorkspaceManager {
|
|
|
584
610
|
private _values;
|
|
585
611
|
/**
|
|
586
612
|
* Whether the venue serves `GET /api/v1/values/*`: no if a probe already
|
|
587
|
-
* 404'd
|
|
588
|
-
*
|
|
589
|
-
*
|
|
613
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
614
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
615
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
616
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet.
|
|
590
617
|
*/
|
|
591
618
|
private supportsValues;
|
|
592
619
|
private unsupported;
|
|
@@ -803,6 +830,47 @@ declare class UserManager {
|
|
|
803
830
|
revokeAuthenticator(key: string, did?: string, ucans?: string[]): Promise<AuthenticatorRevokeResult>;
|
|
804
831
|
}
|
|
805
832
|
|
|
833
|
+
interface OpOps {
|
|
834
|
+
run<T = unknown>(assetId: string, input?: unknown, options?: InvokeOptions): Promise<T>;
|
|
835
|
+
invoke(assetId: string, input?: unknown, options?: InvokeOptions): Promise<Job>;
|
|
836
|
+
}
|
|
837
|
+
interface A2AManagerVenue {
|
|
838
|
+
operations: OpOps;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Bring-your-own-agent (A2A): import a remote A2A endpoint or another Covia
|
|
842
|
+
* agent as an immutable agent Asset, then task it. Both calls persist a Job
|
|
843
|
+
* (the venue records the import and mirrors the remote Task's lifecycle onto
|
|
844
|
+
* `send`'s Job) — there is no job-free surface here.
|
|
845
|
+
*/
|
|
846
|
+
declare class A2AManager {
|
|
847
|
+
private venue;
|
|
848
|
+
constructor(venue: A2AManagerVenue);
|
|
849
|
+
/**
|
|
850
|
+
* Register a remote A2A endpoint or Covia agent as an immutable agent
|
|
851
|
+
* Asset, with a mutable binding at `w/a2a/agents/<name>`. Waits for the
|
|
852
|
+
* import to complete and returns its result directly.
|
|
853
|
+
*/
|
|
854
|
+
importAgent(input: A2AImportAgentInput): Promise<A2AImportAgentResult>;
|
|
855
|
+
/**
|
|
856
|
+
* Task an imported agent. Returns the raw Job rather than waiting for a
|
|
857
|
+
* result: the local Job mirrors the remote Task's lifecycle, so a reply
|
|
858
|
+
* that pauses (INPUT_REQUIRED, AUTH_REQUIRED) is a paused Job the caller
|
|
859
|
+
* inspects and continues via `job.sendMessage()` — the same shape as any
|
|
860
|
+
* other paused job, not a special case for A2A. Once the Job reaches a
|
|
861
|
+
* terminal state, `job.output` is the final remote `A2ATask`.
|
|
862
|
+
*
|
|
863
|
+
* @param agent Imported agent reference — `w/a2a/agents/<name>` or its
|
|
864
|
+
* immutable `did:.../a/<hash>` id.
|
|
865
|
+
* @param message An A2A Message: `{ role, parts, messageId? }`.
|
|
866
|
+
* @param options.taskId Continue an existing remote Task instead of
|
|
867
|
+
* starting a new one.
|
|
868
|
+
*/
|
|
869
|
+
send(agent: string, message: A2AMessage, options?: {
|
|
870
|
+
taskId?: string;
|
|
871
|
+
}): Promise<Job>;
|
|
872
|
+
}
|
|
873
|
+
|
|
806
874
|
/**
|
|
807
875
|
* Resolve a non-DID venue id into the ordered list of base URLs that
|
|
808
876
|
* {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
|
|
@@ -859,6 +927,7 @@ declare class Venue implements VenueInterface {
|
|
|
859
927
|
private _memory?;
|
|
860
928
|
private _dlfs?;
|
|
861
929
|
private _users?;
|
|
930
|
+
private _a2a?;
|
|
862
931
|
get adapters(): AdapterManager;
|
|
863
932
|
get agents(): AgentManager;
|
|
864
933
|
get jobs(): JobManager;
|
|
@@ -871,6 +940,7 @@ declare class Venue implements VenueInterface {
|
|
|
871
940
|
get memory(): MemoryManager;
|
|
872
941
|
get dlfs(): DLFSManager;
|
|
873
942
|
get users(): UserManager;
|
|
943
|
+
get a2a(): A2AManager;
|
|
874
944
|
constructor(options?: VenueOptions);
|
|
875
945
|
/**
|
|
876
946
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
@@ -1384,6 +1454,99 @@ interface AgentFailTaskResult {
|
|
|
1384
1454
|
taskId: string;
|
|
1385
1455
|
status: string;
|
|
1386
1456
|
}
|
|
1457
|
+
/** Fields present on every agent run-loop event frame (covia#394). */
|
|
1458
|
+
interface AgentEventEnvelope {
|
|
1459
|
+
seq: number;
|
|
1460
|
+
ts: number;
|
|
1461
|
+
agentId: string;
|
|
1462
|
+
address: string;
|
|
1463
|
+
}
|
|
1464
|
+
interface AgentRunStartEvent extends AgentEventEnvelope {
|
|
1465
|
+
type: 'run:start';
|
|
1466
|
+
run: number;
|
|
1467
|
+
}
|
|
1468
|
+
interface AgentRunEndEvent extends AgentEventEnvelope {
|
|
1469
|
+
type: 'run:end';
|
|
1470
|
+
run: number;
|
|
1471
|
+
status: AgentStatus;
|
|
1472
|
+
cycles: number;
|
|
1473
|
+
}
|
|
1474
|
+
interface AgentCycleStartEvent extends AgentEventEnvelope {
|
|
1475
|
+
type: 'cycle:start';
|
|
1476
|
+
run: number;
|
|
1477
|
+
cycle: number;
|
|
1478
|
+
op?: string;
|
|
1479
|
+
sessionId?: string;
|
|
1480
|
+
jobId?: string;
|
|
1481
|
+
jobs?: string[];
|
|
1482
|
+
tasks: unknown;
|
|
1483
|
+
messages: unknown;
|
|
1484
|
+
pending: unknown;
|
|
1485
|
+
}
|
|
1486
|
+
interface AgentCycleEndEvent extends AgentEventEnvelope {
|
|
1487
|
+
type: 'cycle:end';
|
|
1488
|
+
run: number;
|
|
1489
|
+
cycle: number;
|
|
1490
|
+
ms: number;
|
|
1491
|
+
response?: unknown;
|
|
1492
|
+
error?: string;
|
|
1493
|
+
tokens?: unknown;
|
|
1494
|
+
timeline?: unknown;
|
|
1495
|
+
detail?: {
|
|
1496
|
+
turns: unknown;
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
interface AgentInferenceStartEvent extends AgentEventEnvelope {
|
|
1500
|
+
type: 'inference:start';
|
|
1501
|
+
op: string;
|
|
1502
|
+
model?: string;
|
|
1503
|
+
messages: unknown;
|
|
1504
|
+
tools: unknown;
|
|
1505
|
+
bytes: number;
|
|
1506
|
+
budget: unknown;
|
|
1507
|
+
depth?: number;
|
|
1508
|
+
}
|
|
1509
|
+
interface AgentInferenceEndEvent extends AgentEventEnvelope {
|
|
1510
|
+
type: 'inference:end';
|
|
1511
|
+
ms: number;
|
|
1512
|
+
model?: string;
|
|
1513
|
+
content?: unknown;
|
|
1514
|
+
toolCalls?: {
|
|
1515
|
+
id: string;
|
|
1516
|
+
name: string;
|
|
1517
|
+
}[];
|
|
1518
|
+
tokens?: unknown;
|
|
1519
|
+
error?: string;
|
|
1520
|
+
depth?: number;
|
|
1521
|
+
}
|
|
1522
|
+
interface AgentToolStartEvent extends AgentEventEnvelope {
|
|
1523
|
+
type: 'tool:start';
|
|
1524
|
+
id: string;
|
|
1525
|
+
name: string;
|
|
1526
|
+
depth?: number;
|
|
1527
|
+
detail: {
|
|
1528
|
+
input: unknown;
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
interface AgentToolResultEvent extends AgentEventEnvelope {
|
|
1532
|
+
type: 'tool:result';
|
|
1533
|
+
id: string;
|
|
1534
|
+
name: string;
|
|
1535
|
+
ms: number;
|
|
1536
|
+
isError?: boolean;
|
|
1537
|
+
depth?: number;
|
|
1538
|
+
detail: {
|
|
1539
|
+
result: unknown;
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
interface AgentStatusEvent extends AgentEventEnvelope {
|
|
1543
|
+
type: 'status';
|
|
1544
|
+
status: AgentStatus;
|
|
1545
|
+
error?: string;
|
|
1546
|
+
}
|
|
1547
|
+
/** One frame from the venue's agent run-loop event stream (`GET
|
|
1548
|
+
* /agents/{id}/sse`, covia#394), discriminated on `type`. */
|
|
1549
|
+
type AgentEvent = AgentRunStartEvent | AgentRunEndEvent | AgentCycleStartEvent | AgentCycleEndEvent | AgentInferenceStartEvent | AgentInferenceEndEvent | AgentToolStartEvent | AgentToolResultEvent | AgentStatusEvent;
|
|
1387
1550
|
interface AssetPinResult {
|
|
1388
1551
|
path: string;
|
|
1389
1552
|
hash: string;
|
|
@@ -1735,6 +1898,67 @@ declare class AgentSessionNotFoundError extends CoviaError {
|
|
|
1735
1898
|
readonly sessionId: string;
|
|
1736
1899
|
constructor(agentId: string, sessionId: string);
|
|
1737
1900
|
}
|
|
1901
|
+
/** Stored authentication binding for an imported A2A agent — a reference to
|
|
1902
|
+
* a secret, never a literal credential. */
|
|
1903
|
+
interface A2AAuthRef {
|
|
1904
|
+
/** Agent Card-declared API key or Bearer scheme name. */
|
|
1905
|
+
scheme?: string;
|
|
1906
|
+
/** Bearer auth needed to discover a private card. */
|
|
1907
|
+
kind?: 'bearer';
|
|
1908
|
+
/** `s/<name>` — the stored secret this binds to. */
|
|
1909
|
+
secret: string;
|
|
1910
|
+
}
|
|
1911
|
+
interface A2AImportAgentInput {
|
|
1912
|
+
/** Local alias matching `[a-z0-9-]{1,64}`; creates `w/a2a/agents/<name>`. */
|
|
1913
|
+
name: string;
|
|
1914
|
+
/** Base URL of a standard external A2A agent. Exactly one of `url`/`coviaAgent`. */
|
|
1915
|
+
url?: string;
|
|
1916
|
+
/** Covia grid agent address: local `g/<agentId>` or full `<ownerDID>/g/<agentId>`. */
|
|
1917
|
+
coviaAgent?: string;
|
|
1918
|
+
/** Base URL of the venue hosting `coviaAgent` — required for a full address. */
|
|
1919
|
+
venue?: string;
|
|
1920
|
+
auth?: A2AAuthRef;
|
|
1921
|
+
}
|
|
1922
|
+
/** The immutable asset DID URL, mutable workspace binding, and exact agent
|
|
1923
|
+
* asset hash from importing an agent. */
|
|
1924
|
+
interface A2AImportAgentResult {
|
|
1925
|
+
/** Mutable workspace binding, e.g. `w/a2a/agents/venue-b-bot`. */
|
|
1926
|
+
path?: string;
|
|
1927
|
+
/** Immutable agent-asset hash. */
|
|
1928
|
+
a2aAgentAsset?: string;
|
|
1929
|
+
/** Whether the binding was written. */
|
|
1930
|
+
stored?: boolean;
|
|
1931
|
+
/** Full immutable DID URL of the agent asset. */
|
|
1932
|
+
id?: string;
|
|
1933
|
+
}
|
|
1934
|
+
/** One part of an A2A message/artifact (v1 wire format). */
|
|
1935
|
+
interface A2APart {
|
|
1936
|
+
type?: string;
|
|
1937
|
+
kind?: string;
|
|
1938
|
+
text?: string;
|
|
1939
|
+
data?: unknown;
|
|
1940
|
+
}
|
|
1941
|
+
interface A2AMessage {
|
|
1942
|
+
role: string;
|
|
1943
|
+
parts: A2APart[];
|
|
1944
|
+
messageId?: string;
|
|
1945
|
+
}
|
|
1946
|
+
/** The remote A2A Task snapshot a send mirrors onto the local Job's output —
|
|
1947
|
+
* final when the Job reaches a terminal state, a live snapshot while paused. */
|
|
1948
|
+
interface A2ATask {
|
|
1949
|
+
id?: string;
|
|
1950
|
+
contextId?: string;
|
|
1951
|
+
status?: {
|
|
1952
|
+
state?: string;
|
|
1953
|
+
timestamp?: string;
|
|
1954
|
+
};
|
|
1955
|
+
artifacts?: {
|
|
1956
|
+
artifactId?: string;
|
|
1957
|
+
parts?: A2APart[];
|
|
1958
|
+
}[];
|
|
1959
|
+
history?: A2AMessage[];
|
|
1960
|
+
[key: string]: unknown;
|
|
1961
|
+
}
|
|
1738
1962
|
|
|
1739
1963
|
/** Parse a Retry-After header (delta-seconds or HTTP-date) to ms from now. */
|
|
1740
1964
|
declare function parseRetryAfterMs(header: string | null, nowMs: number): number;
|
|
@@ -1793,9 +2017,13 @@ declare function createSSEEvent(fields: {
|
|
|
1793
2017
|
}): SSEEvent;
|
|
1794
2018
|
/**
|
|
1795
2019
|
* Parse an SSE stream from a fetch Response body.
|
|
1796
|
-
* Yields SSEEvent objects as they arrive.
|
|
2020
|
+
* Yields SSEEvent objects as they arrive. On `signal` abort, iteration ends
|
|
2021
|
+
* as if the stream closed (no exception thrown); callers that must
|
|
2022
|
+
* distinguish should check `signal.aborted` after the loop.
|
|
1797
2023
|
*/
|
|
1798
|
-
declare function parseSSEStream(response: Response
|
|
2024
|
+
declare function parseSSEStream(response: Response, options?: {
|
|
2025
|
+
signal?: AbortSignal;
|
|
2026
|
+
}): AsyncGenerator<SSEEvent>;
|
|
1799
2027
|
|
|
1800
2028
|
/**
|
|
1801
2029
|
* DID and lattice-path helpers for the Covia grid.
|
|
@@ -2025,4 +2253,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
2025
2253
|
*/
|
|
2026
2254
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
2027
2255
|
|
|
2028
|
-
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, 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 };
|
|
2256
|
+
export { type A2AAuthRef, type A2AImportAgentInput, type A2AImportAgentResult, A2AManager, type A2AMessage, type A2APart, type A2ATask, 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
|
*/
|
|
@@ -360,14 +368,17 @@ interface AgentManagerVenue extends VenueRequestContext {
|
|
|
360
368
|
read(path: string, maxSize?: number): Promise<WorkspaceReadResult>;
|
|
361
369
|
slice(path: string, offset?: number, limit?: number): Promise<WorkspaceSliceResult>;
|
|
362
370
|
};
|
|
363
|
-
lastKnownStatus?: StatusData;
|
|
364
371
|
}
|
|
365
372
|
declare class AgentManager {
|
|
366
373
|
private venue;
|
|
367
374
|
private agentsGetSupported;
|
|
375
|
+
private agentSseSupported;
|
|
368
376
|
constructor(venue: AgentManagerVenue);
|
|
369
377
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
370
|
-
* 404'd
|
|
378
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
379
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
380
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
381
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet. */
|
|
371
382
|
private supportsAgentsGet;
|
|
372
383
|
/** A job-free agents GET that rejects when the endpoint is unavailable. */
|
|
373
384
|
private agentsGet;
|
|
@@ -413,6 +424,20 @@ declare class AgentManager {
|
|
|
413
424
|
/** Agent info. **Job-free** on covia ≥ 0.4 (`GET /api/v1/agents/{id}`,
|
|
414
425
|
* covia#180); older venues require an explicit compatibility opt-in. */
|
|
415
426
|
info(agentId: string): Promise<AgentInfoResult>;
|
|
427
|
+
/**
|
|
428
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
429
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
430
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
431
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
432
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
433
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
434
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
435
|
+
*/
|
|
436
|
+
events(agentId: string, options?: {
|
|
437
|
+
sessionId?: string;
|
|
438
|
+
detail?: boolean;
|
|
439
|
+
signal?: AbortSignal;
|
|
440
|
+
}): AsyncGenerator<AgentEvent>;
|
|
416
441
|
/**
|
|
417
442
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
418
443
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -439,7 +464,9 @@ declare class JobManager {
|
|
|
439
464
|
pause(jobId: string): Promise<JobMetadata>;
|
|
440
465
|
resume(jobId: string): Promise<JobMetadata>;
|
|
441
466
|
sendMessage(jobId: string, message: unknown): Promise<unknown>;
|
|
442
|
-
stream(jobId: string
|
|
467
|
+
stream(jobId: string, options?: {
|
|
468
|
+
signal?: AbortSignal;
|
|
469
|
+
}): AsyncGenerator<SSEEvent>;
|
|
443
470
|
}
|
|
444
471
|
|
|
445
472
|
interface AssetManagerVenue extends VenueRequestContext {
|
|
@@ -556,7 +583,6 @@ declare class OperationManager {
|
|
|
556
583
|
|
|
557
584
|
interface WorkspaceManagerVenue extends VenueRequestContext {
|
|
558
585
|
operations: OperationRunner;
|
|
559
|
-
lastKnownStatus?: StatusData;
|
|
560
586
|
}
|
|
561
587
|
/**
|
|
562
588
|
* Workspace (lattice) operations against a venue.
|
|
@@ -584,9 +610,10 @@ declare class WorkspaceManager {
|
|
|
584
610
|
private _values;
|
|
585
611
|
/**
|
|
586
612
|
* Whether the venue serves `GET /api/v1/values/*`: no if a probe already
|
|
587
|
-
* 404'd
|
|
588
|
-
*
|
|
589
|
-
*
|
|
613
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
614
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
615
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
616
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet.
|
|
590
617
|
*/
|
|
591
618
|
private supportsValues;
|
|
592
619
|
private unsupported;
|
|
@@ -803,6 +830,47 @@ declare class UserManager {
|
|
|
803
830
|
revokeAuthenticator(key: string, did?: string, ucans?: string[]): Promise<AuthenticatorRevokeResult>;
|
|
804
831
|
}
|
|
805
832
|
|
|
833
|
+
interface OpOps {
|
|
834
|
+
run<T = unknown>(assetId: string, input?: unknown, options?: InvokeOptions): Promise<T>;
|
|
835
|
+
invoke(assetId: string, input?: unknown, options?: InvokeOptions): Promise<Job>;
|
|
836
|
+
}
|
|
837
|
+
interface A2AManagerVenue {
|
|
838
|
+
operations: OpOps;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Bring-your-own-agent (A2A): import a remote A2A endpoint or another Covia
|
|
842
|
+
* agent as an immutable agent Asset, then task it. Both calls persist a Job
|
|
843
|
+
* (the venue records the import and mirrors the remote Task's lifecycle onto
|
|
844
|
+
* `send`'s Job) — there is no job-free surface here.
|
|
845
|
+
*/
|
|
846
|
+
declare class A2AManager {
|
|
847
|
+
private venue;
|
|
848
|
+
constructor(venue: A2AManagerVenue);
|
|
849
|
+
/**
|
|
850
|
+
* Register a remote A2A endpoint or Covia agent as an immutable agent
|
|
851
|
+
* Asset, with a mutable binding at `w/a2a/agents/<name>`. Waits for the
|
|
852
|
+
* import to complete and returns its result directly.
|
|
853
|
+
*/
|
|
854
|
+
importAgent(input: A2AImportAgentInput): Promise<A2AImportAgentResult>;
|
|
855
|
+
/**
|
|
856
|
+
* Task an imported agent. Returns the raw Job rather than waiting for a
|
|
857
|
+
* result: the local Job mirrors the remote Task's lifecycle, so a reply
|
|
858
|
+
* that pauses (INPUT_REQUIRED, AUTH_REQUIRED) is a paused Job the caller
|
|
859
|
+
* inspects and continues via `job.sendMessage()` — the same shape as any
|
|
860
|
+
* other paused job, not a special case for A2A. Once the Job reaches a
|
|
861
|
+
* terminal state, `job.output` is the final remote `A2ATask`.
|
|
862
|
+
*
|
|
863
|
+
* @param agent Imported agent reference — `w/a2a/agents/<name>` or its
|
|
864
|
+
* immutable `did:.../a/<hash>` id.
|
|
865
|
+
* @param message An A2A Message: `{ role, parts, messageId? }`.
|
|
866
|
+
* @param options.taskId Continue an existing remote Task instead of
|
|
867
|
+
* starting a new one.
|
|
868
|
+
*/
|
|
869
|
+
send(agent: string, message: A2AMessage, options?: {
|
|
870
|
+
taskId?: string;
|
|
871
|
+
}): Promise<Job>;
|
|
872
|
+
}
|
|
873
|
+
|
|
806
874
|
/**
|
|
807
875
|
* Resolve a non-DID venue id into the ordered list of base URLs that
|
|
808
876
|
* {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
|
|
@@ -859,6 +927,7 @@ declare class Venue implements VenueInterface {
|
|
|
859
927
|
private _memory?;
|
|
860
928
|
private _dlfs?;
|
|
861
929
|
private _users?;
|
|
930
|
+
private _a2a?;
|
|
862
931
|
get adapters(): AdapterManager;
|
|
863
932
|
get agents(): AgentManager;
|
|
864
933
|
get jobs(): JobManager;
|
|
@@ -871,6 +940,7 @@ declare class Venue implements VenueInterface {
|
|
|
871
940
|
get memory(): MemoryManager;
|
|
872
941
|
get dlfs(): DLFSManager;
|
|
873
942
|
get users(): UserManager;
|
|
943
|
+
get a2a(): A2AManager;
|
|
874
944
|
constructor(options?: VenueOptions);
|
|
875
945
|
/**
|
|
876
946
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
@@ -1384,6 +1454,99 @@ interface AgentFailTaskResult {
|
|
|
1384
1454
|
taskId: string;
|
|
1385
1455
|
status: string;
|
|
1386
1456
|
}
|
|
1457
|
+
/** Fields present on every agent run-loop event frame (covia#394). */
|
|
1458
|
+
interface AgentEventEnvelope {
|
|
1459
|
+
seq: number;
|
|
1460
|
+
ts: number;
|
|
1461
|
+
agentId: string;
|
|
1462
|
+
address: string;
|
|
1463
|
+
}
|
|
1464
|
+
interface AgentRunStartEvent extends AgentEventEnvelope {
|
|
1465
|
+
type: 'run:start';
|
|
1466
|
+
run: number;
|
|
1467
|
+
}
|
|
1468
|
+
interface AgentRunEndEvent extends AgentEventEnvelope {
|
|
1469
|
+
type: 'run:end';
|
|
1470
|
+
run: number;
|
|
1471
|
+
status: AgentStatus;
|
|
1472
|
+
cycles: number;
|
|
1473
|
+
}
|
|
1474
|
+
interface AgentCycleStartEvent extends AgentEventEnvelope {
|
|
1475
|
+
type: 'cycle:start';
|
|
1476
|
+
run: number;
|
|
1477
|
+
cycle: number;
|
|
1478
|
+
op?: string;
|
|
1479
|
+
sessionId?: string;
|
|
1480
|
+
jobId?: string;
|
|
1481
|
+
jobs?: string[];
|
|
1482
|
+
tasks: unknown;
|
|
1483
|
+
messages: unknown;
|
|
1484
|
+
pending: unknown;
|
|
1485
|
+
}
|
|
1486
|
+
interface AgentCycleEndEvent extends AgentEventEnvelope {
|
|
1487
|
+
type: 'cycle:end';
|
|
1488
|
+
run: number;
|
|
1489
|
+
cycle: number;
|
|
1490
|
+
ms: number;
|
|
1491
|
+
response?: unknown;
|
|
1492
|
+
error?: string;
|
|
1493
|
+
tokens?: unknown;
|
|
1494
|
+
timeline?: unknown;
|
|
1495
|
+
detail?: {
|
|
1496
|
+
turns: unknown;
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
interface AgentInferenceStartEvent extends AgentEventEnvelope {
|
|
1500
|
+
type: 'inference:start';
|
|
1501
|
+
op: string;
|
|
1502
|
+
model?: string;
|
|
1503
|
+
messages: unknown;
|
|
1504
|
+
tools: unknown;
|
|
1505
|
+
bytes: number;
|
|
1506
|
+
budget: unknown;
|
|
1507
|
+
depth?: number;
|
|
1508
|
+
}
|
|
1509
|
+
interface AgentInferenceEndEvent extends AgentEventEnvelope {
|
|
1510
|
+
type: 'inference:end';
|
|
1511
|
+
ms: number;
|
|
1512
|
+
model?: string;
|
|
1513
|
+
content?: unknown;
|
|
1514
|
+
toolCalls?: {
|
|
1515
|
+
id: string;
|
|
1516
|
+
name: string;
|
|
1517
|
+
}[];
|
|
1518
|
+
tokens?: unknown;
|
|
1519
|
+
error?: string;
|
|
1520
|
+
depth?: number;
|
|
1521
|
+
}
|
|
1522
|
+
interface AgentToolStartEvent extends AgentEventEnvelope {
|
|
1523
|
+
type: 'tool:start';
|
|
1524
|
+
id: string;
|
|
1525
|
+
name: string;
|
|
1526
|
+
depth?: number;
|
|
1527
|
+
detail: {
|
|
1528
|
+
input: unknown;
|
|
1529
|
+
};
|
|
1530
|
+
}
|
|
1531
|
+
interface AgentToolResultEvent extends AgentEventEnvelope {
|
|
1532
|
+
type: 'tool:result';
|
|
1533
|
+
id: string;
|
|
1534
|
+
name: string;
|
|
1535
|
+
ms: number;
|
|
1536
|
+
isError?: boolean;
|
|
1537
|
+
depth?: number;
|
|
1538
|
+
detail: {
|
|
1539
|
+
result: unknown;
|
|
1540
|
+
};
|
|
1541
|
+
}
|
|
1542
|
+
interface AgentStatusEvent extends AgentEventEnvelope {
|
|
1543
|
+
type: 'status';
|
|
1544
|
+
status: AgentStatus;
|
|
1545
|
+
error?: string;
|
|
1546
|
+
}
|
|
1547
|
+
/** One frame from the venue's agent run-loop event stream (`GET
|
|
1548
|
+
* /agents/{id}/sse`, covia#394), discriminated on `type`. */
|
|
1549
|
+
type AgentEvent = AgentRunStartEvent | AgentRunEndEvent | AgentCycleStartEvent | AgentCycleEndEvent | AgentInferenceStartEvent | AgentInferenceEndEvent | AgentToolStartEvent | AgentToolResultEvent | AgentStatusEvent;
|
|
1387
1550
|
interface AssetPinResult {
|
|
1388
1551
|
path: string;
|
|
1389
1552
|
hash: string;
|
|
@@ -1735,6 +1898,67 @@ declare class AgentSessionNotFoundError extends CoviaError {
|
|
|
1735
1898
|
readonly sessionId: string;
|
|
1736
1899
|
constructor(agentId: string, sessionId: string);
|
|
1737
1900
|
}
|
|
1901
|
+
/** Stored authentication binding for an imported A2A agent — a reference to
|
|
1902
|
+
* a secret, never a literal credential. */
|
|
1903
|
+
interface A2AAuthRef {
|
|
1904
|
+
/** Agent Card-declared API key or Bearer scheme name. */
|
|
1905
|
+
scheme?: string;
|
|
1906
|
+
/** Bearer auth needed to discover a private card. */
|
|
1907
|
+
kind?: 'bearer';
|
|
1908
|
+
/** `s/<name>` — the stored secret this binds to. */
|
|
1909
|
+
secret: string;
|
|
1910
|
+
}
|
|
1911
|
+
interface A2AImportAgentInput {
|
|
1912
|
+
/** Local alias matching `[a-z0-9-]{1,64}`; creates `w/a2a/agents/<name>`. */
|
|
1913
|
+
name: string;
|
|
1914
|
+
/** Base URL of a standard external A2A agent. Exactly one of `url`/`coviaAgent`. */
|
|
1915
|
+
url?: string;
|
|
1916
|
+
/** Covia grid agent address: local `g/<agentId>` or full `<ownerDID>/g/<agentId>`. */
|
|
1917
|
+
coviaAgent?: string;
|
|
1918
|
+
/** Base URL of the venue hosting `coviaAgent` — required for a full address. */
|
|
1919
|
+
venue?: string;
|
|
1920
|
+
auth?: A2AAuthRef;
|
|
1921
|
+
}
|
|
1922
|
+
/** The immutable asset DID URL, mutable workspace binding, and exact agent
|
|
1923
|
+
* asset hash from importing an agent. */
|
|
1924
|
+
interface A2AImportAgentResult {
|
|
1925
|
+
/** Mutable workspace binding, e.g. `w/a2a/agents/venue-b-bot`. */
|
|
1926
|
+
path?: string;
|
|
1927
|
+
/** Immutable agent-asset hash. */
|
|
1928
|
+
a2aAgentAsset?: string;
|
|
1929
|
+
/** Whether the binding was written. */
|
|
1930
|
+
stored?: boolean;
|
|
1931
|
+
/** Full immutable DID URL of the agent asset. */
|
|
1932
|
+
id?: string;
|
|
1933
|
+
}
|
|
1934
|
+
/** One part of an A2A message/artifact (v1 wire format). */
|
|
1935
|
+
interface A2APart {
|
|
1936
|
+
type?: string;
|
|
1937
|
+
kind?: string;
|
|
1938
|
+
text?: string;
|
|
1939
|
+
data?: unknown;
|
|
1940
|
+
}
|
|
1941
|
+
interface A2AMessage {
|
|
1942
|
+
role: string;
|
|
1943
|
+
parts: A2APart[];
|
|
1944
|
+
messageId?: string;
|
|
1945
|
+
}
|
|
1946
|
+
/** The remote A2A Task snapshot a send mirrors onto the local Job's output —
|
|
1947
|
+
* final when the Job reaches a terminal state, a live snapshot while paused. */
|
|
1948
|
+
interface A2ATask {
|
|
1949
|
+
id?: string;
|
|
1950
|
+
contextId?: string;
|
|
1951
|
+
status?: {
|
|
1952
|
+
state?: string;
|
|
1953
|
+
timestamp?: string;
|
|
1954
|
+
};
|
|
1955
|
+
artifacts?: {
|
|
1956
|
+
artifactId?: string;
|
|
1957
|
+
parts?: A2APart[];
|
|
1958
|
+
}[];
|
|
1959
|
+
history?: A2AMessage[];
|
|
1960
|
+
[key: string]: unknown;
|
|
1961
|
+
}
|
|
1738
1962
|
|
|
1739
1963
|
/** Parse a Retry-After header (delta-seconds or HTTP-date) to ms from now. */
|
|
1740
1964
|
declare function parseRetryAfterMs(header: string | null, nowMs: number): number;
|
|
@@ -1793,9 +2017,13 @@ declare function createSSEEvent(fields: {
|
|
|
1793
2017
|
}): SSEEvent;
|
|
1794
2018
|
/**
|
|
1795
2019
|
* Parse an SSE stream from a fetch Response body.
|
|
1796
|
-
* Yields SSEEvent objects as they arrive.
|
|
2020
|
+
* Yields SSEEvent objects as they arrive. On `signal` abort, iteration ends
|
|
2021
|
+
* as if the stream closed (no exception thrown); callers that must
|
|
2022
|
+
* distinguish should check `signal.aborted` after the loop.
|
|
1797
2023
|
*/
|
|
1798
|
-
declare function parseSSEStream(response: Response
|
|
2024
|
+
declare function parseSSEStream(response: Response, options?: {
|
|
2025
|
+
signal?: AbortSignal;
|
|
2026
|
+
}): AsyncGenerator<SSEEvent>;
|
|
1799
2027
|
|
|
1800
2028
|
/**
|
|
1801
2029
|
* DID and lattice-path helpers for the Covia grid.
|
|
@@ -2025,4 +2253,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
2025
2253
|
*/
|
|
2026
2254
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
2027
2255
|
|
|
2028
|
-
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, 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 };
|
|
2256
|
+
export { type A2AAuthRef, type A2AImportAgentInput, type A2AImportAgentResult, A2AManager, type A2AMessage, type A2APart, type A2ATask, 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
|
|
|
@@ -1693,12 +1712,6 @@ function venueStream(venue, path, options = {}) {
|
|
|
1693
1712
|
}
|
|
1694
1713
|
|
|
1695
1714
|
// src/venue-features.ts
|
|
1696
|
-
function versionAtLeast(version, major, minor) {
|
|
1697
|
-
const m = version?.match(/^(\d+)\.(\d+)/);
|
|
1698
|
-
if (!m) return true;
|
|
1699
|
-
const [maj, min] = [Number(m[1]), Number(m[2])];
|
|
1700
|
-
return maj > major || maj === major && min >= minor;
|
|
1701
|
-
}
|
|
1702
1715
|
var ROUTE_MISSING_404 = /\bEndpoint (GET|POST|PUT|DELETE|PATCH|HEAD) /;
|
|
1703
1716
|
|
|
1704
1717
|
// src/values-util.ts
|
|
@@ -1746,15 +1759,18 @@ var AgentManager = class {
|
|
|
1746
1759
|
// Whether this venue serves GET /api/v1/agents — flipped on the first 404 so
|
|
1747
1760
|
// pre-0.4 venues pay the probe once, not one failed GET per read (covia#180).
|
|
1748
1761
|
this.agentsGetSupported = true;
|
|
1762
|
+
// Whether this venue serves GET /api/v1/agents/{id}/sse — flipped on a
|
|
1763
|
+
// route-missing 404 (covia#394 landed in venue 0.9.7). No version fast-path:
|
|
1764
|
+
// versionAtLeast() only resolves major.minor, not the patch precision this
|
|
1765
|
+
// needs, so rely purely on the lazy 404 latch (matches UserManager.usersGet).
|
|
1766
|
+
this.agentSseSupported = true;
|
|
1749
1767
|
}
|
|
1750
1768
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
1751
|
-
* 404'd
|
|
1769
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
1770
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
1771
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
1772
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet. */
|
|
1752
1773
|
supportsAgentsGet() {
|
|
1753
|
-
if (!this.agentsGetSupported) return false;
|
|
1754
|
-
const status = this.venue.lastKnownStatus;
|
|
1755
|
-
if (status && (!status.version || !versionAtLeast(status.version, 0, 4))) {
|
|
1756
|
-
this.agentsGetSupported = false;
|
|
1757
|
-
}
|
|
1758
1774
|
return this.agentsGetSupported;
|
|
1759
1775
|
}
|
|
1760
1776
|
/** A job-free agents GET that rejects when the endpoint is unavailable. */
|
|
@@ -1848,6 +1864,38 @@ var AgentManager = class {
|
|
|
1848
1864
|
async info(agentId) {
|
|
1849
1865
|
return this.agentsGet(`/${encodeURIComponent(agentId)}`, {});
|
|
1850
1866
|
}
|
|
1867
|
+
/**
|
|
1868
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
1869
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
1870
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
1871
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
1872
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
1873
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
1874
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
1875
|
+
*/
|
|
1876
|
+
async *events(agentId, options = {}) {
|
|
1877
|
+
if (!this.agentSseSupported) throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1878
|
+
const qs = new URLSearchParams();
|
|
1879
|
+
if (options.sessionId !== void 0) qs.set("sessionId", options.sessionId);
|
|
1880
|
+
if (options.detail !== void 0) qs.set("detail", String(options.detail));
|
|
1881
|
+
const q = qs.toString();
|
|
1882
|
+
let response;
|
|
1883
|
+
try {
|
|
1884
|
+
response = await venueStream(
|
|
1885
|
+
this.venue,
|
|
1886
|
+
`/api/v1/agents/${encodeURIComponent(agentId)}/sse${q ? `?${q}` : ""}`,
|
|
1887
|
+
{ headers: { "Accept": "text/event-stream" }, signal: options.signal }
|
|
1888
|
+
);
|
|
1889
|
+
} catch (e) {
|
|
1890
|
+
if (!(e instanceof NotFoundError)) throw e;
|
|
1891
|
+
if (!ROUTE_MISSING_404.test(e.message)) throw e;
|
|
1892
|
+
this.agentSseSupported = false;
|
|
1893
|
+
throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1894
|
+
}
|
|
1895
|
+
for await (const evt of parseSSEStream(response, { signal: options.signal })) {
|
|
1896
|
+
yield evt.json();
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1851
1899
|
/**
|
|
1852
1900
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
1853
1901
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -1998,8 +2046,8 @@ var Job = class {
|
|
|
1998
2046
|
* Stream server-sent events for this job.
|
|
1999
2047
|
* @returns AsyncGenerator yielding SSEEvent objects
|
|
2000
2048
|
*/
|
|
2001
|
-
async *stream() {
|
|
2002
|
-
yield* this._jobs.stream(this.id);
|
|
2049
|
+
async *stream(options) {
|
|
2050
|
+
yield* this._jobs.stream(this.id, options);
|
|
2003
2051
|
}
|
|
2004
2052
|
/**
|
|
2005
2053
|
* Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
|
|
@@ -2173,11 +2221,12 @@ var JobManager = class {
|
|
|
2173
2221
|
throw error;
|
|
2174
2222
|
}
|
|
2175
2223
|
}
|
|
2176
|
-
async *stream(jobId) {
|
|
2224
|
+
async *stream(jobId, options) {
|
|
2177
2225
|
const response = await venueStream(this.venue, `/api/v1/jobs/${jobId}/sse`, {
|
|
2178
|
-
headers: { "Accept": "text/event-stream" }
|
|
2226
|
+
headers: { "Accept": "text/event-stream" },
|
|
2227
|
+
signal: options?.signal
|
|
2179
2228
|
});
|
|
2180
|
-
yield* parseSSEStream(response);
|
|
2229
|
+
yield* parseSSEStream(response, { signal: options?.signal });
|
|
2181
2230
|
}
|
|
2182
2231
|
};
|
|
2183
2232
|
|
|
@@ -2541,16 +2590,12 @@ var WorkspaceManager = class {
|
|
|
2541
2590
|
}
|
|
2542
2591
|
/**
|
|
2543
2592
|
* Whether the venue serves `GET /api/v1/values/*`: no if a probe already
|
|
2544
|
-
* 404'd
|
|
2545
|
-
*
|
|
2546
|
-
*
|
|
2593
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
2594
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
2595
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
2596
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet.
|
|
2547
2597
|
*/
|
|
2548
2598
|
supportsValues() {
|
|
2549
|
-
if (!this.valuesSupported) return false;
|
|
2550
|
-
const status = this.venue.lastKnownStatus;
|
|
2551
|
-
if (status && (!status.version || !versionAtLeast(status.version, 0, 3))) {
|
|
2552
|
-
this.valuesSupported = false;
|
|
2553
|
-
}
|
|
2554
2599
|
return this.valuesSupported;
|
|
2555
2600
|
}
|
|
2556
2601
|
unsupported(feature) {
|
|
@@ -2913,6 +2958,44 @@ var UserManager = class {
|
|
|
2913
2958
|
}
|
|
2914
2959
|
};
|
|
2915
2960
|
|
|
2961
|
+
// src/A2AManager.ts
|
|
2962
|
+
var IMPORT_AGENT_OP = "v/ops/a2a/import-agent";
|
|
2963
|
+
var SEND_OP = "v/ops/a2a/send";
|
|
2964
|
+
var A2AManager = class {
|
|
2965
|
+
constructor(venue) {
|
|
2966
|
+
this.venue = venue;
|
|
2967
|
+
}
|
|
2968
|
+
/**
|
|
2969
|
+
* Register a remote A2A endpoint or Covia agent as an immutable agent
|
|
2970
|
+
* Asset, with a mutable binding at `w/a2a/agents/<name>`. Waits for the
|
|
2971
|
+
* import to complete and returns its result directly.
|
|
2972
|
+
*/
|
|
2973
|
+
async importAgent(input) {
|
|
2974
|
+
return this.venue.operations.run(IMPORT_AGENT_OP, input);
|
|
2975
|
+
}
|
|
2976
|
+
/**
|
|
2977
|
+
* Task an imported agent. Returns the raw Job rather than waiting for a
|
|
2978
|
+
* result: the local Job mirrors the remote Task's lifecycle, so a reply
|
|
2979
|
+
* that pauses (INPUT_REQUIRED, AUTH_REQUIRED) is a paused Job the caller
|
|
2980
|
+
* inspects and continues via `job.sendMessage()` — the same shape as any
|
|
2981
|
+
* other paused job, not a special case for A2A. Once the Job reaches a
|
|
2982
|
+
* terminal state, `job.output` is the final remote `A2ATask`.
|
|
2983
|
+
*
|
|
2984
|
+
* @param agent Imported agent reference — `w/a2a/agents/<name>` or its
|
|
2985
|
+
* immutable `did:.../a/<hash>` id.
|
|
2986
|
+
* @param message An A2A Message: `{ role, parts, messageId? }`.
|
|
2987
|
+
* @param options.taskId Continue an existing remote Task instead of
|
|
2988
|
+
* starting a new one.
|
|
2989
|
+
*/
|
|
2990
|
+
async send(agent, message, options) {
|
|
2991
|
+
return this.venue.operations.invoke(SEND_OP, {
|
|
2992
|
+
agent,
|
|
2993
|
+
message,
|
|
2994
|
+
...options?.taskId !== void 0 && { taskId: options.taskId }
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
};
|
|
2998
|
+
|
|
2916
2999
|
// src/Agent.ts
|
|
2917
3000
|
var Agent = class _Agent {
|
|
2918
3001
|
constructor(id, venue) {
|
|
@@ -2962,6 +3045,10 @@ var Agent = class _Agent {
|
|
|
2962
3045
|
async getSession(sessionId) {
|
|
2963
3046
|
return this._agents.getSession(this.id, sessionId);
|
|
2964
3047
|
}
|
|
3048
|
+
/** Stream this agent's run-loop events. See `AgentManager.events`. */
|
|
3049
|
+
async *events(options) {
|
|
3050
|
+
yield* this._agents.events(this.id, options);
|
|
3051
|
+
}
|
|
2965
3052
|
/**
|
|
2966
3053
|
* Fork this agent into a new agent.
|
|
2967
3054
|
* @param agentId - ID for the new forked agent
|
|
@@ -3117,6 +3204,9 @@ var Venue = class _Venue {
|
|
|
3117
3204
|
get users() {
|
|
3118
3205
|
return this._users ?? (this._users = new UserManager(this));
|
|
3119
3206
|
}
|
|
3207
|
+
get a2a() {
|
|
3208
|
+
return this._a2a ?? (this._a2a = new A2AManager(this));
|
|
3209
|
+
}
|
|
3120
3210
|
/**
|
|
3121
3211
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
3122
3212
|
* venue is auth-gated (status answers 401/403 — public access disabled), the
|
|
@@ -3448,6 +3538,7 @@ function relayDelegation(privateKey, venueDID, lifetimeSeconds, caps = []) {
|
|
|
3448
3538
|
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
3449
3539
|
*/
|
|
3450
3540
|
|
|
3541
|
+
exports.A2AManager = A2AManager;
|
|
3451
3542
|
exports.AdapterManager = AdapterManager;
|
|
3452
3543
|
exports.Agent = Agent;
|
|
3453
3544
|
exports.AgentManager = AgentManager;
|
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
|
|
|
@@ -1691,12 +1710,6 @@ function venueStream(venue, path, options = {}) {
|
|
|
1691
1710
|
}
|
|
1692
1711
|
|
|
1693
1712
|
// src/venue-features.ts
|
|
1694
|
-
function versionAtLeast(version, major, minor) {
|
|
1695
|
-
const m = version?.match(/^(\d+)\.(\d+)/);
|
|
1696
|
-
if (!m) return true;
|
|
1697
|
-
const [maj, min] = [Number(m[1]), Number(m[2])];
|
|
1698
|
-
return maj > major || maj === major && min >= minor;
|
|
1699
|
-
}
|
|
1700
1713
|
var ROUTE_MISSING_404 = /\bEndpoint (GET|POST|PUT|DELETE|PATCH|HEAD) /;
|
|
1701
1714
|
|
|
1702
1715
|
// src/values-util.ts
|
|
@@ -1744,15 +1757,18 @@ var AgentManager = class {
|
|
|
1744
1757
|
// Whether this venue serves GET /api/v1/agents — flipped on the first 404 so
|
|
1745
1758
|
// pre-0.4 venues pay the probe once, not one failed GET per read (covia#180).
|
|
1746
1759
|
this.agentsGetSupported = true;
|
|
1760
|
+
// Whether this venue serves GET /api/v1/agents/{id}/sse — flipped on a
|
|
1761
|
+
// route-missing 404 (covia#394 landed in venue 0.9.7). No version fast-path:
|
|
1762
|
+
// versionAtLeast() only resolves major.minor, not the patch precision this
|
|
1763
|
+
// needs, so rely purely on the lazy 404 latch (matches UserManager.usersGet).
|
|
1764
|
+
this.agentSseSupported = true;
|
|
1747
1765
|
}
|
|
1748
1766
|
/** Whether the venue serves `GET /api/v1/agents`: no if a probe already
|
|
1749
|
-
* 404'd
|
|
1767
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
1768
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
1769
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
1770
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet. */
|
|
1750
1771
|
supportsAgentsGet() {
|
|
1751
|
-
if (!this.agentsGetSupported) return false;
|
|
1752
|
-
const status = this.venue.lastKnownStatus;
|
|
1753
|
-
if (status && (!status.version || !versionAtLeast(status.version, 0, 4))) {
|
|
1754
|
-
this.agentsGetSupported = false;
|
|
1755
|
-
}
|
|
1756
1772
|
return this.agentsGetSupported;
|
|
1757
1773
|
}
|
|
1758
1774
|
/** A job-free agents GET that rejects when the endpoint is unavailable. */
|
|
@@ -1846,6 +1862,38 @@ var AgentManager = class {
|
|
|
1846
1862
|
async info(agentId) {
|
|
1847
1863
|
return this.agentsGet(`/${encodeURIComponent(agentId)}`, {});
|
|
1848
1864
|
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Stream this agent's run-loop events (run/cycle boundaries, inferences,
|
|
1867
|
+
* tool calls, status changes) from the venue's live tap (covia#394,
|
|
1868
|
+
* venue ≥ 0.9.7). Narrow to one session with `sessionId`; omit owner-only
|
|
1869
|
+
* tool input/result and appended-turn detail with `detail: false`. Pass
|
|
1870
|
+
* `signal` to abort — reader cancellation on abort or early exit is
|
|
1871
|
+
* handled by `parseSSEStream` (covia-sdk#30).
|
|
1872
|
+
* @throws {UnsupportedVenueFeatureError} on venues before 0.9.7.
|
|
1873
|
+
*/
|
|
1874
|
+
async *events(agentId, options = {}) {
|
|
1875
|
+
if (!this.agentSseSupported) throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1876
|
+
const qs = new URLSearchParams();
|
|
1877
|
+
if (options.sessionId !== void 0) qs.set("sessionId", options.sessionId);
|
|
1878
|
+
if (options.detail !== void 0) qs.set("detail", String(options.detail));
|
|
1879
|
+
const q = qs.toString();
|
|
1880
|
+
let response;
|
|
1881
|
+
try {
|
|
1882
|
+
response = await venueStream(
|
|
1883
|
+
this.venue,
|
|
1884
|
+
`/api/v1/agents/${encodeURIComponent(agentId)}/sse${q ? `?${q}` : ""}`,
|
|
1885
|
+
{ headers: { "Accept": "text/event-stream" }, signal: options.signal }
|
|
1886
|
+
);
|
|
1887
|
+
} catch (e) {
|
|
1888
|
+
if (!(e instanceof NotFoundError)) throw e;
|
|
1889
|
+
if (!ROUTE_MISSING_404.test(e.message)) throw e;
|
|
1890
|
+
this.agentSseSupported = false;
|
|
1891
|
+
throw new UnsupportedVenueFeatureError("agent event stream");
|
|
1892
|
+
}
|
|
1893
|
+
for await (const evt of parseSSEStream(response, { signal: options.signal })) {
|
|
1894
|
+
yield evt.json();
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1849
1897
|
/**
|
|
1850
1898
|
* Page an agent's sessions directly from `g/<agentId>/sessions`.
|
|
1851
1899
|
* This is a job-free Values read; session adapter-specific fields remain
|
|
@@ -1996,8 +2044,8 @@ var Job = class {
|
|
|
1996
2044
|
* Stream server-sent events for this job.
|
|
1997
2045
|
* @returns AsyncGenerator yielding SSEEvent objects
|
|
1998
2046
|
*/
|
|
1999
|
-
async *stream() {
|
|
2000
|
-
yield* this._jobs.stream(this.id);
|
|
2047
|
+
async *stream(options) {
|
|
2048
|
+
yield* this._jobs.stream(this.id, options);
|
|
2001
2049
|
}
|
|
2002
2050
|
/**
|
|
2003
2051
|
* Whether the job is paused (PAUSED, INPUT_REQUIRED, or AUTH_REQUIRED)
|
|
@@ -2171,11 +2219,12 @@ var JobManager = class {
|
|
|
2171
2219
|
throw error;
|
|
2172
2220
|
}
|
|
2173
2221
|
}
|
|
2174
|
-
async *stream(jobId) {
|
|
2222
|
+
async *stream(jobId, options) {
|
|
2175
2223
|
const response = await venueStream(this.venue, `/api/v1/jobs/${jobId}/sse`, {
|
|
2176
|
-
headers: { "Accept": "text/event-stream" }
|
|
2224
|
+
headers: { "Accept": "text/event-stream" },
|
|
2225
|
+
signal: options?.signal
|
|
2177
2226
|
});
|
|
2178
|
-
yield* parseSSEStream(response);
|
|
2227
|
+
yield* parseSSEStream(response, { signal: options?.signal });
|
|
2179
2228
|
}
|
|
2180
2229
|
};
|
|
2181
2230
|
|
|
@@ -2539,16 +2588,12 @@ var WorkspaceManager = class {
|
|
|
2539
2588
|
}
|
|
2540
2589
|
/**
|
|
2541
2590
|
* Whether the venue serves `GET /api/v1/values/*`: no if a probe already
|
|
2542
|
-
* 404'd
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2591
|
+
* 404'd. No version fast-path — a venue's self-reported version is weaker
|
|
2592
|
+
* evidence than its answer to the request (an embedded venue can report
|
|
2593
|
+
* its host application's version instead of its own; see covia-sdk#36).
|
|
2594
|
+
* Rely purely on the lazy 404 latch, same as UserManager.usersGet.
|
|
2545
2595
|
*/
|
|
2546
2596
|
supportsValues() {
|
|
2547
|
-
if (!this.valuesSupported) return false;
|
|
2548
|
-
const status = this.venue.lastKnownStatus;
|
|
2549
|
-
if (status && (!status.version || !versionAtLeast(status.version, 0, 3))) {
|
|
2550
|
-
this.valuesSupported = false;
|
|
2551
|
-
}
|
|
2552
2597
|
return this.valuesSupported;
|
|
2553
2598
|
}
|
|
2554
2599
|
unsupported(feature) {
|
|
@@ -2911,6 +2956,44 @@ var UserManager = class {
|
|
|
2911
2956
|
}
|
|
2912
2957
|
};
|
|
2913
2958
|
|
|
2959
|
+
// src/A2AManager.ts
|
|
2960
|
+
var IMPORT_AGENT_OP = "v/ops/a2a/import-agent";
|
|
2961
|
+
var SEND_OP = "v/ops/a2a/send";
|
|
2962
|
+
var A2AManager = class {
|
|
2963
|
+
constructor(venue) {
|
|
2964
|
+
this.venue = venue;
|
|
2965
|
+
}
|
|
2966
|
+
/**
|
|
2967
|
+
* Register a remote A2A endpoint or Covia agent as an immutable agent
|
|
2968
|
+
* Asset, with a mutable binding at `w/a2a/agents/<name>`. Waits for the
|
|
2969
|
+
* import to complete and returns its result directly.
|
|
2970
|
+
*/
|
|
2971
|
+
async importAgent(input) {
|
|
2972
|
+
return this.venue.operations.run(IMPORT_AGENT_OP, input);
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Task an imported agent. Returns the raw Job rather than waiting for a
|
|
2976
|
+
* result: the local Job mirrors the remote Task's lifecycle, so a reply
|
|
2977
|
+
* that pauses (INPUT_REQUIRED, AUTH_REQUIRED) is a paused Job the caller
|
|
2978
|
+
* inspects and continues via `job.sendMessage()` — the same shape as any
|
|
2979
|
+
* other paused job, not a special case for A2A. Once the Job reaches a
|
|
2980
|
+
* terminal state, `job.output` is the final remote `A2ATask`.
|
|
2981
|
+
*
|
|
2982
|
+
* @param agent Imported agent reference — `w/a2a/agents/<name>` or its
|
|
2983
|
+
* immutable `did:.../a/<hash>` id.
|
|
2984
|
+
* @param message An A2A Message: `{ role, parts, messageId? }`.
|
|
2985
|
+
* @param options.taskId Continue an existing remote Task instead of
|
|
2986
|
+
* starting a new one.
|
|
2987
|
+
*/
|
|
2988
|
+
async send(agent, message, options) {
|
|
2989
|
+
return this.venue.operations.invoke(SEND_OP, {
|
|
2990
|
+
agent,
|
|
2991
|
+
message,
|
|
2992
|
+
...options?.taskId !== void 0 && { taskId: options.taskId }
|
|
2993
|
+
});
|
|
2994
|
+
}
|
|
2995
|
+
};
|
|
2996
|
+
|
|
2914
2997
|
// src/Agent.ts
|
|
2915
2998
|
var Agent = class _Agent {
|
|
2916
2999
|
constructor(id, venue) {
|
|
@@ -2960,6 +3043,10 @@ var Agent = class _Agent {
|
|
|
2960
3043
|
async getSession(sessionId) {
|
|
2961
3044
|
return this._agents.getSession(this.id, sessionId);
|
|
2962
3045
|
}
|
|
3046
|
+
/** Stream this agent's run-loop events. See `AgentManager.events`. */
|
|
3047
|
+
async *events(options) {
|
|
3048
|
+
yield* this._agents.events(this.id, options);
|
|
3049
|
+
}
|
|
2963
3050
|
/**
|
|
2964
3051
|
* Fork this agent into a new agent.
|
|
2965
3052
|
* @param agentId - ID for the new forked agent
|
|
@@ -3115,6 +3202,9 @@ var Venue = class _Venue {
|
|
|
3115
3202
|
get users() {
|
|
3116
3203
|
return this._users ?? (this._users = new UserManager(this));
|
|
3117
3204
|
}
|
|
3205
|
+
get a2a() {
|
|
3206
|
+
return this._a2a ?? (this._a2a = new A2AManager(this));
|
|
3207
|
+
}
|
|
3118
3208
|
/**
|
|
3119
3209
|
* Connect to a venue, validating it with `GET {base}/api/v1/status`. If the
|
|
3120
3210
|
* venue is auth-gated (status answers 401/403 — public access disabled), the
|
|
@@ -3446,4 +3536,4 @@ function relayDelegation(privateKey, venueDID, lifetimeSeconds, caps = []) {
|
|
|
3446
3536
|
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
3447
3537
|
*/
|
|
3448
3538
|
|
|
3449
|
-
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 };
|
|
3539
|
+
export { A2AManager, 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 };
|