@covia/covia-sdk 1.17.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -24,6 +24,13 @@ 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
+ /**
28
+ * One session's transcript — its turns in order, with compacted segments
29
+ * expanded back into the turns they archived.
30
+ *
31
+ * Shorthand for `getSession(sessionId)` when only the conversation is wanted.
32
+ */
33
+ transcript(sessionId: string): Promise<AgentSessionMessage[]>;
27
34
  /** Stream this agent's run-loop events. See `AgentManager.events`. */
28
35
  events(options?: {
29
36
  sessionId?: string;
@@ -369,6 +376,9 @@ interface AgentManagerVenue extends VenueRequestContext {
369
376
  workspace: {
370
377
  read(path: string, maxSize?: number): Promise<WorkspaceReadResult>;
371
378
  slice(path: string, offset?: number, limit?: number): Promise<WorkspaceSliceResult>;
379
+ count(path: string, opts?: {
380
+ depth?: number;
381
+ }): Promise<WorkspaceCountResult>;
372
382
  };
373
383
  }
374
384
  declare class AgentManager {
@@ -446,6 +456,8 @@ declare class AgentManager {
446
456
  * available on each record's `value` while common runtime fields are typed.
447
457
  */
448
458
  listSessions(agentId: string, options?: AgentSessionListOptions): Promise<AgentSessionPage>;
459
+ /** Shape a `{key, value}` session slice into a page. */
460
+ private _sessionPage;
449
461
  /** Read one agent session directly from the workspace Values surface. */
450
462
  getSession(agentId: string, sessionId: string): Promise<AgentSession>;
451
463
  private _readLargeSession;
@@ -455,11 +467,39 @@ declare class AgentManager {
455
467
  failTask(error: string): Promise<AgentFailTaskResult>;
456
468
  }
457
469
 
458
- type JobManagerVenue = VenueRequestContext;
470
+ interface JobManagerVenue extends VenueRequestContext {
471
+ workspace: {
472
+ count(path: string, opts?: {
473
+ depth?: number;
474
+ }): Promise<WorkspaceCountResult>;
475
+ slice(path: string, offset?: number, limit?: number): Promise<WorkspaceSliceResult>;
476
+ };
477
+ }
459
478
  declare class JobManager {
460
479
  private venue;
461
480
  constructor(venue: JobManagerVenue);
462
481
  list(): Promise<string[]>;
482
+ /**
483
+ * A page of job history: `JobMetadata` rows, newest-first by default, with an
484
+ * authoritative total.
485
+ *
486
+ * `list()` answers "which jobs exist" as ids; a history view needs a bounded
487
+ * window of *records* and a count to page against. This reads the job index
488
+ * directly, so each row arrives with its metadata already attached — the
489
+ * alternative, listing ids and then fetching each one, is an N+1 fan-out per
490
+ * page. Reads stay job-free (covia#177): paging job history must not itself
491
+ * write a job record per page.
492
+ *
493
+ * The total is read before a `desc` window can be placed, so the index may
494
+ * grow in between; the page self-corrects once against the count the slice
495
+ * itself reports, which is authoritative for the rows returned with it.
496
+ */
497
+ history(options?: JobHistoryOptions): Promise<JobHistoryPage>;
498
+ /**
499
+ * Read index ranks `[start, end)` in cap-aware chunks, halving on an oversize
500
+ * response and skipping a record that is individually oversize.
501
+ */
502
+ private _readJobRange;
463
503
  get(jobId: string): Promise<Job>;
464
504
  cancel(jobId: string): Promise<JobMetadata>;
465
505
  delete(jobId: string): Promise<void>;
@@ -485,6 +525,14 @@ declare class AssetManager {
485
525
  * a mutable lattice path the venue resolves (`w/my-assets/foo`, `o/my-op`,
486
526
  * `<DID>/w/...`). Only content-addressed (immutable) refs are cached;
487
527
  * mutable paths are always re-fetched, so a changed value is never served stale.
528
+ *
529
+ * **Content-addressed refs are caller-relative, not global** (covia#502). A
530
+ * bare hash or `a/<hash>` names the asset in *your own* `a/` namespace, so it
531
+ * 404s for a hash someone else registered, and for an anonymous request.
532
+ * Address another owner's asset explicitly as `<ownerDID>/a/<hash>`, and the
533
+ * venue's own catalog as `<venueDID>/a/<hash>`. Only the DID-qualified form
534
+ * is portable, so only it is eligible for the cross-session metadata store;
535
+ * caller-relative refs are cached in memory on this manager alone.
488
536
  * @param assetId - Asset identifier or lattice address
489
537
  * @returns Returns either an Operation or DataAsset based on the asset's metadata
490
538
  */
@@ -610,6 +658,8 @@ interface WorkspaceManagerVenue extends VenueRequestContext {
610
658
  declare class WorkspaceManager {
611
659
  private venue;
612
660
  private valuesSupported;
661
+ private scopeExpansionSupported;
662
+ private fieldsSupported;
613
663
  constructor(venue: WorkspaceManagerVenue);
614
664
  /** GET a job-free `/api/v1/values/{op}` read; omit undefined params. */
615
665
  private _values;
@@ -624,8 +674,78 @@ declare class WorkspaceManager {
624
674
  private unsupported;
625
675
  /** A job-free Values read that rejects when the endpoint is unavailable. */
626
676
  private valuesRead;
677
+ /**
678
+ * A job-free Values read of an execution-scoped path, preferring the venue's
679
+ * own selector expansion and falling back to the client-side one.
680
+ *
681
+ * The venue is preferred because it expands *before* the capability check, so
682
+ * authorisation applies to the same canonical resource that is ultimately
683
+ * read — a caller cannot substitute a sibling or foreign agent's scratch.
684
+ * The fallback reaches the same resource but re-derives the layout here.
685
+ */
686
+ private scopedRead;
687
+ /**
688
+ * Bind an execution scope, giving job-free reads of the `t/`, `n/` and `c/`
689
+ * scratch shorthands that a bare GET cannot otherwise resolve (covia#177
690
+ * forbids minting a Job for a read; the shorthands need context a GET lacks).
691
+ *
692
+ * ```ts
693
+ * const scratch = venue.workspace.scoped({ agent: 'alice', task: taskId });
694
+ * await scratch.read('t/snapshot');
695
+ * await scratch.list('t/');
696
+ * ```
697
+ *
698
+ * Ordinary paths still work through the handle, so a caller rendering a task
699
+ * inspector can use one reader for both scratch and workspace. Capability
700
+ * behaviour is unchanged: the caller needs read caps on the agent's subtree.
701
+ */
702
+ scoped(scope: ExecutionScope): ScopedWorkspace;
703
+ /** @internal — the scoped read used by {@link ScopedWorkspace}. */
704
+ _scopedRead<T>(op: string, params: Record<string, string | number | boolean | undefined>, scope: ExecutionScope): Promise<T>;
627
705
  read(path: string, maxSize?: number, ucans?: string[]): Promise<WorkspaceReadResult>;
628
706
  list(path?: string, limit?: number, offset?: number, ucans?: string[]): Promise<WorkspaceListResult>;
707
+ /**
708
+ * List a node's children *and* read named subpaths of each one, in a single
709
+ * round trip (covia#191) — the standard partial-response / sparse-fieldset
710
+ * pattern, and the cure for the collection-view N+1 that list-then-read-each
711
+ * forces on every page.
712
+ *
713
+ * ```ts
714
+ * const page = await venue.workspace.listFields('j', ['status', 'meta/updated'], { limit: 50 });
715
+ * page.values['<jobid>']['status']; // → { exists: true, value: 'COMPLETE' }
716
+ * ```
717
+ *
718
+ * Each field is defined as a `read` of `<path>/<key>/<field>` and carries
719
+ * single-read semantics verbatim: stored null is present, absent is
720
+ * `{exists:false}`, and a value past `maxSize` withholds `value` and sets
721
+ * `truncated`. Projection applies *after* the `limit`/`offset` key page, so
722
+ * work is bounded by `limit × fields.length`.
723
+ *
724
+ * Output shape only — no filtering, no ordering. Filter the projected
725
+ * records locally; for a recency subset use key design plus `slice`.
726
+ *
727
+ * On a venue that predates projection this falls back to `list()` plus a
728
+ * bounded `read()` per (key, field), returning the identical shape, and
729
+ * remembers not to ask that venue again.
730
+ *
731
+ * @param path Parent node. Must be a keyed node (map/Index) — a sequence or
732
+ * scalar is a venue 400.
733
+ * @param fields Subpaths to project per key; may be nested (`meta/updated`).
734
+ * At most 16, the venue's cap.
735
+ */
736
+ listFields(path: string, fields: string[], opts?: {
737
+ limit?: number;
738
+ offset?: number;
739
+ maxSize?: number;
740
+ }): Promise<WorkspaceProjectedList>;
741
+ /**
742
+ * The pre-covia#191 fallback: one `list`, then a `read` per (key, field).
743
+ * Fan-out is bounded by the page the list already returned, so this costs
744
+ * `keys.length × fields.length` reads for the page — exactly the N+1 the
745
+ * server-side projection exists to remove, which is why it is the fallback
746
+ * and not the default.
747
+ */
748
+ private projectClientSide;
629
749
  slice(path: string, offset?: number, limit?: number, ucans?: string[]): Promise<WorkspaceSliceResult>;
630
750
  inspect(paths: string | string[], budget?: number, compact?: boolean, ucans?: string[]): Promise<WorkspaceInspectResult>;
631
751
  /**
@@ -658,6 +778,35 @@ declare class WorkspaceManager {
658
778
  append(path: string, value: unknown, ucans?: string[]): Promise<WorkspaceAppendResult>;
659
779
  copy(from: string, to: string, ucans?: string[]): Promise<WorkspaceCopyResult>;
660
780
  }
781
+ /**
782
+ * A {@link WorkspaceManager} bound to one execution scope, so `t/`, `n/` and
783
+ * `c/` scratch resolve without the caller hand-building the physical paths
784
+ * (`g/<agent>/sessions/<sid>/c/...` and friends). Reads only — scoped scratch
785
+ * is written from inside the execution that owns it, where the shorthands
786
+ * already resolve from the request's own context.
787
+ *
788
+ * Obtained from {@link WorkspaceManager.scoped}; every method mirrors the
789
+ * job-free read of the same name.
790
+ */
791
+ declare class ScopedWorkspace {
792
+ private workspace;
793
+ /** The scope every read on this handle resolves against. */
794
+ readonly scope: ExecutionScope;
795
+ constructor(workspace: WorkspaceManager,
796
+ /** The scope every read on this handle resolves against. */
797
+ scope: ExecutionScope);
798
+ read(path: string, maxSize?: number): Promise<WorkspaceReadResult>;
799
+ list(path: string, limit?: number, offset?: number): Promise<WorkspaceListResult>;
800
+ slice(path: string, offset?: number, limit?: number): Promise<WorkspaceSliceResult>;
801
+ inspect(path: string, budget?: number, compact?: boolean): Promise<WorkspaceInspectResult>;
802
+ count(path: string, opts?: {
803
+ depth?: number;
804
+ }): Promise<WorkspaceCountResult>;
805
+ aggregate(path: string, opts?: {
806
+ depth?: number;
807
+ groupBy?: string;
808
+ }): Promise<WorkspaceAggregateResult>;
809
+ }
661
810
 
662
811
  interface UCANManagerVenue {
663
812
  operations: OperationRunner;
@@ -876,6 +1025,123 @@ declare class A2AManager {
876
1025
  }): Promise<Job>;
877
1026
  }
878
1027
 
1028
+ interface MCPOps {
1029
+ invoke(assetId: string, input?: unknown, options?: InvokeOptions): Promise<Job>;
1030
+ }
1031
+ interface MCPManagerVenue extends VenueRequestContext {
1032
+ operations: MCPOps;
1033
+ mcpDiscovery(): Promise<MCPDiscovery>;
1034
+ }
1035
+ /**
1036
+ * MCP client for a venue's native `/mcp` endpoint.
1037
+ *
1038
+ * The venue speaks Streamable HTTP MCP: JSON-RPC over POST, answering either
1039
+ * `application/json` or `text/event-stream` at its discretion. Everything that
1040
+ * implies — request-id correlation, reading a response that may arrive as SSE
1041
+ * frames, applying the venue's auth with the venue DID as audience, turning
1042
+ * JSON-RPC error objects into typed errors — is protocol plumbing every
1043
+ * TypeScript consumer would otherwise rebuild (covia-sdk#23).
1044
+ *
1045
+ * ```ts
1046
+ * const page = await venue.mcp.listTools();
1047
+ * const out = await venue.mcp.callTool(page.tools[0].name, { text: 'hi' });
1048
+ * ```
1049
+ *
1050
+ * **`listTools()` is job-free.** It reads the native endpoint, never the
1051
+ * `v/ops/mcp/tools-list` operation — discovery and display must not persist a
1052
+ * job per page (covia#177).
1053
+ */
1054
+ declare class MCPManager {
1055
+ private venue;
1056
+ private nextId;
1057
+ private sessionId?;
1058
+ private endpointPromise?;
1059
+ constructor(venue: MCPManagerVenue);
1060
+ /** The venue's MCP discovery document (`GET /.well-known/mcp`). */
1061
+ discovery(): Promise<MCPDiscovery>;
1062
+ /**
1063
+ * List the tools this venue bridges, job-free.
1064
+ *
1065
+ * @param options.cursor Continue a previous page. MCP pagination is opaque:
1066
+ * pass back the `nextCursor` a page returned, and stop when it is absent.
1067
+ */
1068
+ listTools(options?: {
1069
+ cursor?: string;
1070
+ signal?: AbortSignal;
1071
+ }): Promise<MCPToolPage>;
1072
+ /**
1073
+ * Every tool the venue bridges, draining the cursor.
1074
+ *
1075
+ * A server that never stops handing back a cursor would loop forever, so a
1076
+ * repeated cursor is treated as the end rather than trusted.
1077
+ */
1078
+ listAllTools(options?: {
1079
+ signal?: AbortSignal;
1080
+ }): Promise<MCPToolPage['tools']>;
1081
+ /**
1082
+ * Call a bridged tool natively and return its MCP result.
1083
+ *
1084
+ * This is the direct protocol call: the answer comes back in the response,
1085
+ * and the caller never holds a Job. The venue still runs the tool through
1086
+ * its job machinery and records it — "direct" describes what *this* call
1087
+ * hands back, not whether the venue keeps a record.
1088
+ *
1089
+ * Use {@link callToolTracked} when you want the `Job` itself: to stream it,
1090
+ * inspect its steps, link to its receipt, or continue it when it pauses.
1091
+ *
1092
+ * An MCP tool that fails *its own* execution answers with `isError: true`
1093
+ * and the failure in `content` — a successful protocol call reporting a
1094
+ * failed tool, which is not thrown. Only a protocol-level error throws.
1095
+ */
1096
+ callTool(name: string, args?: Record<string, unknown>, options?: {
1097
+ signal?: AbortSignal;
1098
+ }): Promise<MCPToolResult>;
1099
+ /**
1100
+ * Call a tool through the `v/ops/mcp/tools-call` operation, returning the
1101
+ * `Job` so the run is an inspectable, linkable record.
1102
+ *
1103
+ * The operation is the venue's bridge to *any* MCP server, so `server`
1104
+ * defaults to this venue's own base URL — pointing the bridge back at the
1105
+ * venue, which is how a local tool gets called with a Job in hand. Name a
1106
+ * different `server` (with a `token` if it needs one) to reach a third-party
1107
+ * MCP server through the venue instead, which the native endpoint cannot do.
1108
+ *
1109
+ * Unlike {@link callTool} this always persists a job, so it belongs to a
1110
+ * user-driven execution, never a page load.
1111
+ */
1112
+ callToolTracked(name: string, args?: Record<string, unknown>, options?: {
1113
+ server?: string;
1114
+ token?: string;
1115
+ } & InvokeOptions): Promise<Job>;
1116
+ /**
1117
+ * Send an arbitrary JSON-RPC method to the venue's MCP endpoint — the escape
1118
+ * hatch for methods this manager does not wrap (`resources/list`,
1119
+ * `prompts/list`, …).
1120
+ *
1121
+ * Request ids are minted and correlated here, so callers never supply one.
1122
+ */
1123
+ request<T = unknown>(method: string, params?: Record<string, unknown>, options?: {
1124
+ signal?: AbortSignal;
1125
+ }): Promise<T>;
1126
+ /** The resolved MCP endpoint path, from discovery, probed once. */
1127
+ private endpoint;
1128
+ /**
1129
+ * Discovery names the endpoint; `${baseUrl}/mcp` is the compatibility
1130
+ * default. Discovery failing is not fatal — a venue that serves `/mcp`
1131
+ * without advertising it still works, so a failed probe falls through to the
1132
+ * default rather than failing the call that triggered it.
1133
+ */
1134
+ private resolveEndpoint;
1135
+ /**
1136
+ * Read the response frame from an SSE-framed answer: the first event whose
1137
+ * JSON-RPC id matches the request. Notifications and unrelated frames are
1138
+ * skipped rather than mistaken for the answer.
1139
+ */
1140
+ private readSSEFrame;
1141
+ /** JSON-RPC envelope → result, or a typed error. */
1142
+ private unwrap;
1143
+ }
1144
+
879
1145
  /**
880
1146
  * Resolve a non-DID venue id into the ordered list of base URLs that
881
1147
  * {@link Venue.connect} will try in turn. Explicit `http(s)://` inputs are
@@ -933,6 +1199,7 @@ declare class Venue implements VenueInterface {
933
1199
  private _dlfs?;
934
1200
  private _users?;
935
1201
  private _a2a?;
1202
+ private _mcp?;
936
1203
  get adapters(): AdapterManager;
937
1204
  get agents(): AgentManager;
938
1205
  get jobs(): JobManager;
@@ -945,6 +1212,7 @@ declare class Venue implements VenueInterface {
945
1212
  get memory(): MemoryManager;
946
1213
  get dlfs(): DLFSManager;
947
1214
  get users(): UserManager;
1215
+ get mcp(): MCPManager;
948
1216
  get a2a(): A2AManager;
949
1217
  constructor(options?: VenueOptions);
950
1218
  /**
@@ -1149,6 +1417,23 @@ interface OperationPayload {
1149
1417
  interface ContentHashResult {
1150
1418
  hash: string;
1151
1419
  }
1420
+ /** Paging/ordering for {@link JobManager.history}. */
1421
+ interface JobHistoryOptions {
1422
+ /** Rows to skip from the ordered start (default 0). */
1423
+ offset?: number;
1424
+ /** Maximum rows to return (default 50). */
1425
+ limit?: number;
1426
+ /** `desc` (default) is newest-first, the order a history view wants. */
1427
+ order?: 'asc' | 'desc';
1428
+ }
1429
+ /** One page of job history: the rows plus the window they were drawn from. */
1430
+ interface JobHistoryPage {
1431
+ items: JobMetadata[];
1432
+ /** Authoritative total at the moment the page was read. */
1433
+ total: number;
1434
+ offset: number;
1435
+ limit: number;
1436
+ }
1152
1437
  interface JobMetadata {
1153
1438
  id?: string;
1154
1439
  name?: string;
@@ -1268,6 +1553,36 @@ interface MCPDiscovery {
1268
1553
  endpoint?: Record<string, any> | string;
1269
1554
  [key: string]: any;
1270
1555
  }
1556
+ /** One tool as MCP describes it (`tools/list`). */
1557
+ interface MCPTool {
1558
+ name: string;
1559
+ description?: string;
1560
+ inputSchema: Record<string, unknown>;
1561
+ outputSchema?: Record<string, unknown>;
1562
+ [key: string]: any;
1563
+ }
1564
+ /** One page of `tools/list`. `nextCursor` absent = the last page. */
1565
+ interface MCPToolPage {
1566
+ tools: MCPTool[];
1567
+ nextCursor?: string;
1568
+ }
1569
+ /** One content block of a tool result. */
1570
+ interface MCPContent {
1571
+ type: string;
1572
+ text?: string;
1573
+ [key: string]: any;
1574
+ }
1575
+ /**
1576
+ * The result of `tools/call`. `isError` marks a tool that ran and failed —
1577
+ * a successful protocol call reporting a failed tool — as distinct from a
1578
+ * protocol error, which throws `MCPError` instead.
1579
+ */
1580
+ interface MCPToolResult {
1581
+ content?: MCPContent[];
1582
+ structuredContent?: Record<string, unknown>;
1583
+ isError?: boolean;
1584
+ [key: string]: any;
1585
+ }
1271
1586
  /**
1272
1587
  * A2A agent card from `GET /.well-known/agent-card.json`.
1273
1588
  * Field names mirror the A2A v1.0 wire format the venue serves (via the
@@ -1438,17 +1753,78 @@ interface AgentSessionMetadata {
1438
1753
  turnCount?: number;
1439
1754
  [key: string]: unknown;
1440
1755
  }
1756
+ /** The four roles a stored conversation turn may carry. */
1757
+ type AgentSessionRole = 'system' | 'user' | 'assistant' | 'tool';
1758
+ /**
1759
+ * One persisted conversation turn (AGENT_CONTEXT.md §1.1 `Turn`).
1760
+ *
1761
+ * Most turns carry text in `content`; a tool result may instead carry its typed
1762
+ * map or vector in `structuredContent`. Provider-specific continuation state
1763
+ * (`providerState`) is deliberately absent — it is opaque, is omitted from
1764
+ * retrospective session projections, and is not part of a readable transcript.
1765
+ */
1766
+ interface AgentSessionMessage {
1767
+ role: AgentSessionRole;
1768
+ content?: unknown;
1769
+ /** A typed tool result, in place of textual `content`. */
1770
+ structuredContent?: unknown;
1771
+ /** Present on an assistant turn that called tools. */
1772
+ toolCalls?: unknown[];
1773
+ /** A `tool` turn's matching call id. */
1774
+ id?: string;
1775
+ name?: string;
1776
+ isError?: boolean;
1777
+ ts?: number;
1778
+ source?: string;
1779
+ caller?: string;
1780
+ /** The job that delivered this turn — links it back to the calling job. */
1781
+ jobId?: string;
1782
+ tokens?: number;
1783
+ }
1784
+ /**
1785
+ * An archived run of turns that compaction replaced with a summary
1786
+ * (AGENT_CONTEXT.md §1.1 `CompactedSegment`). `items` is the exact recursively
1787
+ * archived vector, so no history is lost — {@link AgentSession.conversation}
1788
+ * expands it back into the transcript.
1789
+ */
1790
+ interface AgentCompactedSegment {
1791
+ summary: string;
1792
+ /** How many turns the summary stands in for. */
1793
+ turns?: number;
1794
+ items: unknown[];
1795
+ }
1441
1796
  /** A session record read directly from `g/<agentId>/sessions`. */
1442
1797
  interface AgentSession {
1443
1798
  id: string;
1444
1799
  metadata: AgentSessionMetadata;
1445
1800
  pending: unknown[];
1801
+ /**
1802
+ * Raw goal-tree frames, newest last. `frames[0]` is the root frame and a flat
1803
+ * `llmagent` session has only that one. Kept verbatim for callers that need
1804
+ * frame-level state; for the readable transcript use {@link conversation}.
1805
+ */
1446
1806
  frames: unknown[];
1807
+ /**
1808
+ * The session transcript: every frame's turns, in order, with compacted
1809
+ * segments expanded back into the turns they archived.
1810
+ *
1811
+ * This is the field a chat UI renders. Assembling it from `frames` means
1812
+ * knowing that turns live at `frames[].conversation`, that an entry there may
1813
+ * be an archived segment rather than a turn, and that segments nest — layout
1814
+ * knowledge that belongs here rather than in every consumer.
1815
+ */
1816
+ conversation: AgentSessionMessage[];
1447
1817
  wakeTime?: number;
1448
1818
  }
1449
1819
  interface AgentSessionListOptions {
1450
1820
  offset?: number;
1451
1821
  limit?: number;
1822
+ /**
1823
+ * `desc` is newest-first. Session ids are timestamp-prefixed, so the index is
1824
+ * already chronological and the window is taken from its end — the order
1825
+ * holds across pages, unlike sorting one page after the fact.
1826
+ */
1827
+ order?: 'asc' | 'desc';
1452
1828
  }
1453
1829
  interface AgentSessionPage {
1454
1830
  items: AgentSession[];
@@ -1640,6 +2016,33 @@ interface WorkspaceAppendResult {
1640
2016
  /** 0.3.0: true iff a new parent path was built. */
1641
2017
  pathCreated?: boolean;
1642
2018
  }
2019
+ /**
2020
+ * The execution context a `t/`, `n/` or `c/` scratch read resolves against.
2021
+ *
2022
+ * A GET carries no execution context of its own, so the venue cannot know which
2023
+ * job, agent or session a bare shorthand means. These selectors supply it
2024
+ * explicitly (covia#230) and are the only way to read scoped scratch job-free.
2025
+ *
2026
+ * Each namespace consumes a different part of the scope, and the venue rejects
2027
+ * a selector its namespace does not use:
2028
+ *
2029
+ * | Path | Needs | Resolves to |
2030
+ * |------|------------------|----------------------------------------------|
2031
+ * | `n/` | `agent` | `g/<agent>/n/...` |
2032
+ * | `c/` | `agent`+`session`| `g/<agent>/sessions/<session>/c/...` |
2033
+ * | `t/` | `agent`+`task` | `j/<task>/temp/...` |
2034
+ *
2035
+ * A bound scope may therefore carry all three; each read sends only what its
2036
+ * own namespace needs.
2037
+ */
2038
+ interface ExecutionScope {
2039
+ /** Agent id (`alice`) or a full agent DID. Required for every scoped read. */
2040
+ agent: string;
2041
+ /** Task id — the `agent:request` Job whose record holds `t/` scratch. */
2042
+ task?: string;
2043
+ /** Session id, for `c/` session scratch. */
2044
+ session?: string;
2045
+ }
1643
2046
  interface WorkspaceListInput {
1644
2047
  path?: string;
1645
2048
  limit?: number;
@@ -1657,6 +2060,26 @@ interface WorkspaceListResult {
1657
2060
  keys?: string[];
1658
2061
  offset?: number;
1659
2062
  }
2063
+ /**
2064
+ * One projected field of one listed record (covia#191).
2065
+ *
2066
+ * Exactly what a `values/read` of `<parent>/<key>/<field>` returns, down to
2067
+ * `valueBytes` — projection is pure composition of reads, not new semantics.
2068
+ * So: a stored null is present (`{exists: true, value: null}`), an absent
2069
+ * field is `{exists: false}`, and a value past the per-field byte guard
2070
+ * withholds `value` and sets `truncated` alongside its `type`.
2071
+ */
2072
+ type WorkspaceFieldValue = WorkspaceReadResult;
2073
+ /**
2074
+ * A `list` carrying a field projection: the ordinary list result plus, per
2075
+ * listed key, the read result of each requested subpath of that key's child.
2076
+ *
2077
+ * `values` is keyed by the same keys `keys` reports, in the same page —
2078
+ * projection applies after `limit`/`offset`.
2079
+ */
2080
+ interface WorkspaceProjectedList extends WorkspaceListResult {
2081
+ values: Record<string, Record<string, WorkspaceFieldValue>>;
2082
+ }
1660
2083
  interface WorkspaceSliceInput {
1661
2084
  path: string;
1662
2085
  offset?: number;
@@ -1834,6 +2257,15 @@ declare class CoviaError extends Error {
1834
2257
  code: number | null;
1835
2258
  constructor(message: string, code?: number | null);
1836
2259
  }
2260
+ /**
2261
+ * A JSON-RPC error from an MCP endpoint. `code` is the JSON-RPC code (e.g.
2262
+ * -32602 invalid params), not an HTTP status — a JSON-RPC error arrives in a
2263
+ * 200 response, so it would otherwise read as success.
2264
+ */
2265
+ declare class MCPError extends CoviaError {
2266
+ data?: unknown;
2267
+ constructor(message: string, code: number, data?: unknown);
2268
+ }
1837
2269
  /** Raised when the Covia API returns an error response (4xx/5xx). */
1838
2270
  declare class GridError extends CoviaError {
1839
2271
  statusCode: number;
@@ -2063,7 +2495,11 @@ declare function parseSSEStream(response: Response, options?: {
2063
2495
  * Which DID belongs in a lattice address:
2064
2496
  * - `w`/`o`/`g`/`j`/`s` are per-user: the `<DID>` is the resource *owner's* DID
2065
2497
  * (yours is your auth DID, e.g. `Ed25519Auth.getDID()`) — NOT the venue's.
2066
- * - `a` (assets) is venue-global and content-addressed.
2498
+ * - `a` (assets) is content-addressed, and **caller-relative**: a bare hash or
2499
+ * `a/<hash>` names the asset in the requesting caller's own `a/` namespace,
2500
+ * not a global one (covia#502). Name another owner's copy explicitly as
2501
+ * `<ownerDID>/a/<hash>` — the only portable form — and the venue's own
2502
+ * catalog as `<venueDID>/a/<hash>`.
2067
2503
  * - A namespace-relative path (no `<DID>`) resolves to the authenticated caller.
2068
2504
  */
2069
2505
  /** Lattice namespace identifiers. */
@@ -2116,23 +2552,30 @@ declare function assetHash(ref: string): string | null;
2116
2552
  /**
2117
2553
  * Pluggable persistent store for content-addressed asset metadata.
2118
2554
  *
2119
- * An asset id is the Convex value hash of its metadata (`AMap.getHash()`
2120
- * venue-side), so hash → metadata is immutable: entries never go stale and are
2121
- * safe to cache indefinitely, across sessions and across venues. Keys are the
2122
- * normalised bare hash (lowercase, no `0x`), so `<hash>`, `0x<hash>` and
2123
- * `<DID>/a/<hash>` refs all share one entry.
2555
+ * Keys are the **fully qualified** `<ownerDID>/a/<hash>` form, and only that
2556
+ * form is admitted. A bare hash or `a/<hash>` is *caller-relative*: it names
2557
+ * the asset in the requesting caller's own `a/` namespace, so the same bytes
2558
+ * registered by two principals are two records, each readable only under its
2559
+ * owner's authority (covia#502, `venue/docs/OPERATIONS.md` §"Content-addressed
2560
+ * forms are caller-relative, not global"). Covia has no global lookup by hash.
2561
+ * Keying this store on a bare hash would therefore let an entry populated
2562
+ * under one identity be served back to another that may have no right to read
2563
+ * it — and this store is cross-session by design, outliving the auth that
2564
+ * filled it. `persistentCacheKey` returns null for those refs, and
2565
+ * `AssetManager` keeps them in its own venue-local memory cache instead.
2124
2566
  *
2125
2567
  * Trust model: entries are cached as returned by the venue that served them.
2126
2568
  * Provable verification — recomputing the Convex value hash of the metadata
2127
2569
  * and rejecting mismatches — requires a canonical CVM cell encoder in
2128
- * TypeScript, which does not exist yet; when it lands, verification will gate
2129
- * admission to this cache so entries are correct by construction rather than
2130
- * by trust. Until then this is a availability/performance cache with the same
2131
- * trust as an uncached fetch from the same venue.
2570
+ * TypeScript, which does not exist yet (covia-sdk#18); when it lands,
2571
+ * verification will gate admission to this cache so entries are correct by
2572
+ * construction rather than by trust. Until then this is an
2573
+ * availability/performance cache with the same trust as an uncached fetch
2574
+ * from the same venue.
2132
2575
  */
2133
2576
  interface AssetMetadataStore {
2134
- get(hash: string): AssetMetadata | undefined;
2135
- put(hash: string, metadata: AssetMetadata): void;
2577
+ get(key: string): AssetMetadata | undefined;
2578
+ put(key: string, metadata: AssetMetadata): void;
2136
2579
  clear(): void;
2137
2580
  }
2138
2581
  /** Replace the persistent metadata store (e.g. a file-backed store in Node),
@@ -2282,4 +2725,4 @@ declare function grant(ownerPrivateKey: Uint8Array, audienceDID: string, withRes
2282
2725
  */
2283
2726
  declare function relayDelegation(privateKey: Uint8Array, venueDID: string, lifetimeSeconds: number, caps?: UCANCapability[]): string;
2284
2727
 
2285
- 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 };
2728
+ 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 AgentCompactedSegment, 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 AgentSessionMessage, type AgentSessionMetadata, AgentSessionNotFoundError, type AgentSessionPage, type AgentSessionRole, 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 ExecutionScope, type ExpandedAssetList, type FunctionInfo, type FunctionsResult, Grid, GridError, type GroupCount, type InvokeOptions, type InvokePayload, Job, JobFailedError, type JobHistoryOptions, type JobHistoryPage, JobManager, type JobMetadata, JobNotFoundError, JobStatus, KeyPairAuth, type MCPContent, type MCPDiscovery, MCPError, MCPManager, type MCPTool, type MCPToolPage, type MCPToolResult, type MemoryChange, type MemoryEntry, MemoryManager, type MyAssetList, Namespace, NoAuth, NotFoundError, Operation, type OperationDetails, type OperationInfo, OperationManager, type OperationPayload, type OperationRunner, RateLimitError, RunStatus, type SSEEvent, ScopedWorkspace, 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 WorkspaceFieldValue, type WorkspaceInspectInput, type WorkspaceInspectResult, type WorkspaceListInput, type WorkspaceListResult, WorkspaceManager, type WorkspaceProjectedList, 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 };