@covia/covia-sdk 1.13.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 +127 -5
- package/dist/index.d.ts +127 -5
- package/dist/index.js +69 -8
- package/dist/index.mjs +69 -8
- 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 {
|
|
@@ -1384,6 +1409,99 @@ interface AgentFailTaskResult {
|
|
|
1384
1409
|
taskId: string;
|
|
1385
1410
|
status: string;
|
|
1386
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;
|
|
1387
1505
|
interface AssetPinResult {
|
|
1388
1506
|
path: string;
|
|
1389
1507
|
hash: string;
|
|
@@ -1793,9 +1911,13 @@ declare function createSSEEvent(fields: {
|
|
|
1793
1911
|
}): SSEEvent;
|
|
1794
1912
|
/**
|
|
1795
1913
|
* Parse an SSE stream from a fetch Response body.
|
|
1796
|
-
* 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.
|
|
1797
1917
|
*/
|
|
1798
|
-
declare function parseSSEStream(response: Response
|
|
1918
|
+
declare function parseSSEStream(response: Response, options?: {
|
|
1919
|
+
signal?: AbortSignal;
|
|
1920
|
+
}): AsyncGenerator<SSEEvent>;
|
|
1799
1921
|
|
|
1800
1922
|
/**
|
|
1801
1923
|
* DID and lattice-path helpers for the Covia grid.
|
|
@@ -2025,4 +2147,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
2025
2147
|
*/
|
|
2026
2148
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
2027
2149
|
|
|
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 };
|
|
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 {
|
|
@@ -1384,6 +1409,99 @@ interface AgentFailTaskResult {
|
|
|
1384
1409
|
taskId: string;
|
|
1385
1410
|
status: string;
|
|
1386
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;
|
|
1387
1505
|
interface AssetPinResult {
|
|
1388
1506
|
path: string;
|
|
1389
1507
|
hash: string;
|
|
@@ -1793,9 +1911,13 @@ declare function createSSEEvent(fields: {
|
|
|
1793
1911
|
}): SSEEvent;
|
|
1794
1912
|
/**
|
|
1795
1913
|
* Parse an SSE stream from a fetch Response body.
|
|
1796
|
-
* 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.
|
|
1797
1917
|
*/
|
|
1798
|
-
declare function parseSSEStream(response: Response
|
|
1918
|
+
declare function parseSSEStream(response: Response, options?: {
|
|
1919
|
+
signal?: AbortSignal;
|
|
1920
|
+
}): AsyncGenerator<SSEEvent>;
|
|
1799
1921
|
|
|
1800
1922
|
/**
|
|
1801
1923
|
* DID and lattice-path helpers for the Covia grid.
|
|
@@ -2025,4 +2147,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
|
|
|
2025
2147
|
*/
|
|
2026
2148
|
declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
|
|
2027
2149
|
|
|
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 };
|
|
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
|
|
|
@@ -2962,6 +3019,10 @@ var Agent = class _Agent {
|
|
|
2962
3019
|
async getSession(sessionId) {
|
|
2963
3020
|
return this._agents.getSession(this.id, sessionId);
|
|
2964
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
|
+
}
|
|
2965
3026
|
/**
|
|
2966
3027
|
* Fork this agent into a new agent.
|
|
2967
3028
|
* @param agentId - ID for the new forked agent
|
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
|
|
|
@@ -2960,6 +3017,10 @@ var Agent = class _Agent {
|
|
|
2960
3017
|
async getSession(sessionId) {
|
|
2961
3018
|
return this._agents.getSession(this.id, sessionId);
|
|
2962
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
|
+
}
|
|
2963
3024
|
/**
|
|
2964
3025
|
* Fork this agent into a new agent.
|
|
2965
3026
|
* @param agentId - ID for the new forked agent
|