@covia/covia-sdk 1.4.0 → 1.5.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.mjs CHANGED
@@ -1371,7 +1371,19 @@ var AgentManager = class {
1371
1371
  return this.venue.operations.run("v/ops/agent/trigger", { agentId });
1372
1372
  }
1373
1373
  async query(agentId) {
1374
- return this.venue.operations.run("v/ops/agent/info", { agentId });
1374
+ const read = (path) => this.venue.operations.run("v/ops/covia/read", { path }).catch(() => ({ value: null }));
1375
+ const [info, timelineRes, stateRes, inboxRes] = await Promise.all([
1376
+ this.venue.operations.run("v/ops/agent/info", { agentId }),
1377
+ read(`g/${agentId}/timeline`),
1378
+ read(`g/${agentId}/state`),
1379
+ read(`g/${agentId}/inbox`)
1380
+ ]);
1381
+ return {
1382
+ ...info,
1383
+ timeline: Array.isArray(timelineRes.value) ? timelineRes.value : [],
1384
+ state: stateRes.value ?? {},
1385
+ inbox: Array.isArray(inboxRes.value) ? inboxRes.value : []
1386
+ };
1375
1387
  }
1376
1388
  async list(includeTerminated) {
1377
1389
  return this.venue.operations.run("v/ops/agent/list", { includeTerminated });
@@ -1391,6 +1403,21 @@ var AgentManager = class {
1391
1403
  async cancelTask(agentId, taskId) {
1392
1404
  return this.venue.operations.run("v/ops/agent/cancel-task", { agentId, taskId });
1393
1405
  }
1406
+ async info(agentId) {
1407
+ return this.venue.operations.run("v/ops/agent/info", { agentId });
1408
+ }
1409
+ async fork(input) {
1410
+ return this.venue.operations.run("v/ops/agent/fork", input);
1411
+ }
1412
+ async context(agentId, task) {
1413
+ return this.venue.operations.run("v/ops/agent/context", { agentId, task });
1414
+ }
1415
+ async completeTask(result) {
1416
+ return this.venue.operations.run("v/ops/agent/complete-task", { result });
1417
+ }
1418
+ async failTask(error) {
1419
+ return this.venue.operations.run("v/ops/agent/fail-task", { error });
1420
+ }
1394
1421
  };
1395
1422
 
1396
1423
  // src/Job.ts
@@ -1544,11 +1571,15 @@ var JobManager = class {
1544
1571
  this.venue = venue;
1545
1572
  }
1546
1573
  async list() {
1547
- return fetchWithError(`${this.venue.baseUrl}/api/v1/jobs`);
1574
+ return fetchWithError(`${this.venue.baseUrl}/api/v1/jobs`, {
1575
+ headers: this._buildHeaders()
1576
+ });
1548
1577
  }
1549
1578
  async get(jobId) {
1550
1579
  try {
1551
- const data = await fetchWithError(`${this.venue.baseUrl}/api/v1/jobs/${jobId}`);
1580
+ const data = await fetchWithError(`${this.venue.baseUrl}/api/v1/jobs/${jobId}`, {
1581
+ headers: this._buildHeaders()
1582
+ });
1552
1583
  return new Job(jobId, this.venue, data);
1553
1584
  } catch (error) {
1554
1585
  if (error instanceof NotFoundError) {
@@ -1826,6 +1857,14 @@ var AssetManager = class {
1826
1857
  throw error;
1827
1858
  }
1828
1859
  }
1860
+ /**
1861
+ * Pin a resolvable value into the content-addressed asset store.
1862
+ * Idempotent — same value produces the same hash.
1863
+ * @param path - Source address (hex hash, /a/<hash>, /o/<name>, /v/<path>, DID URL, or workspace path)
1864
+ */
1865
+ async pin(path) {
1866
+ return this.venue.operations.run("v/ops/asset/pin", { path });
1867
+ }
1829
1868
  /**
1830
1869
  * Clear the asset cache.
1831
1870
  */
@@ -1852,7 +1891,7 @@ var OperationManager = class {
1852
1891
  }
1853
1892
  /**
1854
1893
  * Get details of a named operation
1855
- * @param name - Operation name (e.g., "test:echo")
1894
+ * @param name - Operation name (e.g., "v/ops/schema/infer")
1856
1895
  */
1857
1896
  async get(name) {
1858
1897
  return fetchWithError(`${this.venue.baseUrl}/api/v1/operations/${name}`);
@@ -1918,6 +1957,12 @@ var WorkspaceManager = class {
1918
1957
  async slice(path, offset, limit) {
1919
1958
  return this.venue.operations.run("v/ops/covia/slice", { path, offset, limit });
1920
1959
  }
1960
+ async copy(from, to) {
1961
+ return this.venue.operations.run("v/ops/covia/copy", { from, to });
1962
+ }
1963
+ async inspect(paths, budget, compact) {
1964
+ return this.venue.operations.run("v/ops/covia/inspect", { paths, budget, compact });
1965
+ }
1921
1966
  };
1922
1967
 
1923
1968
  // src/UCANManager.ts
@@ -1956,6 +2001,90 @@ var SecretManager = class {
1956
2001
  return this.venue.deleteSecret(name);
1957
2002
  }
1958
2003
  };
2004
+
2005
+ // src/Agent.ts
2006
+ var Agent = class _Agent {
2007
+ constructor(id, venue) {
2008
+ this.id = id;
2009
+ this.venue = venue;
2010
+ this._agents = venue.agents;
2011
+ }
2012
+ async request(input, wait) {
2013
+ return this._agents.request(this.id, input, wait);
2014
+ }
2015
+ async message(message) {
2016
+ return this._agents.message(this.id, message);
2017
+ }
2018
+ async chat(message, sessionId) {
2019
+ return this._agents.chat(this.id, message, sessionId);
2020
+ }
2021
+ /**
2022
+ * Create a ChatSession bound to this agent.
2023
+ * @param sessionId - Optional session ID to resume an existing session
2024
+ */
2025
+ chatSession(sessionId) {
2026
+ return new ChatSession(this, sessionId);
2027
+ }
2028
+ async trigger() {
2029
+ return this._agents.trigger(this.id);
2030
+ }
2031
+ async query() {
2032
+ return this._agents.query(this.id);
2033
+ }
2034
+ async suspend() {
2035
+ return this._agents.suspend(this.id);
2036
+ }
2037
+ async resume(autoWake) {
2038
+ return this._agents.resume(this.id, autoWake);
2039
+ }
2040
+ async update(options) {
2041
+ return this._agents.update({ agentId: this.id, ...options });
2042
+ }
2043
+ async cancelTask(taskId) {
2044
+ return this._agents.cancelTask(this.id, taskId);
2045
+ }
2046
+ async info() {
2047
+ return this._agents.info(this.id);
2048
+ }
2049
+ /**
2050
+ * Fork this agent into a new agent.
2051
+ * @param agentId - ID for the new forked agent
2052
+ * @param options - Fork options
2053
+ * @returns A new Agent instance for the forked agent
2054
+ */
2055
+ async fork(agentId, options) {
2056
+ await this._agents.fork({ sourceId: this.id, agentId, ...options });
2057
+ return new _Agent(agentId, this.venue);
2058
+ }
2059
+ async context(task) {
2060
+ return this._agents.context(this.id, task);
2061
+ }
2062
+ async delete(remove) {
2063
+ return this._agents.delete(this.id, remove);
2064
+ }
2065
+ };
2066
+ var ChatSession = class {
2067
+ constructor(agent, sessionId) {
2068
+ this.agent = agent;
2069
+ this._sessionId = sessionId;
2070
+ }
2071
+ /** The session ID, or undefined if no message has been sent yet and no ID was provided. */
2072
+ get sessionId() {
2073
+ return this._sessionId;
2074
+ }
2075
+ /**
2076
+ * Send a message on this session.
2077
+ * On the first call (when no sessionId is set), the server mints a new session.
2078
+ * The returned sessionId is captured and reused for all subsequent calls.
2079
+ */
2080
+ async send(message) {
2081
+ const result = await this.agent.chat(message, this._sessionId);
2082
+ this._sessionId = result.sessionId;
2083
+ return result;
2084
+ }
2085
+ };
2086
+
2087
+ // src/Venue.ts
1959
2088
  var webResolver = getResolver();
1960
2089
  var resolver = new Resolver(webResolver);
1961
2090
  var Venue = class _Venue {
@@ -2064,6 +2193,15 @@ var Venue = class _Venue {
2064
2193
  async getJob(jobId) {
2065
2194
  return this.jobs.get(jobId);
2066
2195
  }
2196
+ /**
2197
+ * Get a lazy Agent handle for the given agent ID.
2198
+ * No network round-trip — the agent is not verified to exist.
2199
+ * @param agentId - Agent identifier
2200
+ * @returns {Agent} An Agent instance bound to this venue
2201
+ */
2202
+ agent(agentId) {
2203
+ return new Agent(agentId, this);
2204
+ }
2067
2205
  /**
2068
2206
  * List secret names
2069
2207
  * @returns {Promise<string[]>}
@@ -2072,7 +2210,7 @@ var Venue = class _Venue {
2072
2210
  const result = await fetchWithError(`${this.baseUrl}/api/v1/secrets`, {
2073
2211
  headers: this._buildHeaders()
2074
2212
  });
2075
- return result.items;
2213
+ return Array.isArray(result.items) ? result.items : [];
2076
2214
  }
2077
2215
  /**
2078
2216
  * Store a secret value
@@ -2170,4 +2308,4 @@ var Grid = class {
2170
2308
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2171
2309
  */
2172
2310
 
2173
- export { AgentManager, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BearerAuth, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DataAsset, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, NoAuth, NotFoundError, Operation, OperationManager, RunStatus, SecretManager, UCANManager, Venue, WorkspaceManager, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex };
2311
+ export { Agent, AgentManager, AgentStatus, Asset, AssetManager, AssetNotFoundError, Auth, BearerAuth, ChatSession, CoviaConnectionError, CoviaError, CoviaTimeoutError, CredentialsHTTP, DataAsset, Grid, GridError, Job, JobFailedError, JobManager, JobNotFoundError, JobStatus, KeyPairAuth, NoAuth, NotFoundError, Operation, OperationManager, RunStatus, SecretManager, UCANManager, Venue, WorkspaceManager, createSSEEvent, decodePublicKey, didFromPublicKey, encodePublicKey, fetchStreamWithError, fetchWithError, generateKeyPair, getAssetIdFromPath, getAssetIdFromVenueId, getParsedAssetId, hexToPrivateKey, isJobComplete, isJobFinished, isJobPaused, logger, parseSSEStream, privateKeyToHex };
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "@covia/covia-sdk",
3
- "version": "1.4.0",
4
- "description": "Typescript library for covia-ai",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "require": "./dist/index.js",
12
- "import": "./dist/index.mjs"
13
- }
14
- },
15
- "files": [
16
- "dist"
17
- ],
18
- "scripts": {
19
- "build": "tsup src/index.ts --format cjs,esm --dts --clean",
20
- "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
21
- "lint": "eslint src --ext .ts",
22
- "test": "jest",
23
- "test:unit": "jest src/__tests__/",
24
- "test:integration": "jest venue.test.ts",
25
- "prepublishOnly": "npm run build && npm run test:unit",
26
- "prepare": "npm run build"
27
- },
28
- "keywords": [
29
- "covia",
30
- "grid",
31
- "api",
32
- "typescript",
33
- "data-assets",
34
- "operations"
35
- ],
36
- "author": "Covia AI",
37
- "license": "MIT",
38
- "repository": {
39
- "type": "git",
40
- "url": "https://github.com/covia-ai/covia-sdk.git"
41
- },
42
- "bugs": {
43
- "url": "https://github.com/covia-ai/covia-sdk/issues"
44
- },
45
- "homepage": "https://github.com/covia-ai/covia-sdk#readme",
46
- "publishConfig": {
47
- "access": "public"
48
- },
49
- "devDependencies": {
50
- "@types/jest": "^30.0.0",
51
- "@types/node": "^20.0.0",
52
- "dotenv": "^17.2.3",
53
- "jest": "^30.2.0",
54
- "ts-jest": "^29.4.6",
55
- "tsup": "^8.0.0",
56
- "typescript": "^5.3.0"
57
- },
58
- "engines": {
59
- "node": ">=18"
60
- },
61
- "dependencies": {
62
- "@noble/ed25519": "^2.0.0",
63
- "@noble/hashes": "^1.0.0",
64
- "did-resolver": "^4.1.0",
65
- "web-did-resolver": "^2.0.32"
66
- }
1
+ {
2
+ "name": "@covia/covia-sdk",
3
+ "version": "1.5.0",
4
+ "description": "Typescript library for covia-ai",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "require": "./dist/index.js",
12
+ "import": "./dist/index.mjs"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
20
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
21
+ "lint": "eslint src --ext .ts",
22
+ "test": "jest",
23
+ "test:unit": "jest src/__tests__/",
24
+ "test:integration": "jest venue.test.ts",
25
+ "prepublishOnly": "npm run build && npm run test:unit",
26
+ "prepare": "npm run build"
27
+ },
28
+ "keywords": [
29
+ "covia",
30
+ "grid",
31
+ "api",
32
+ "typescript",
33
+ "data-assets",
34
+ "operations"
35
+ ],
36
+ "author": "Covia AI",
37
+ "license": "Apache-2.0",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/covia-ai/covia-sdk.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/covia-ai/covia-sdk/issues"
44
+ },
45
+ "homepage": "https://github.com/covia-ai/covia-sdk#readme",
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "devDependencies": {
50
+ "@types/jest": "^30.0.0",
51
+ "@types/node": "^20.0.0",
52
+ "dotenv": "^17.2.3",
53
+ "jest": "^30.2.0",
54
+ "ts-jest": "^29.4.6",
55
+ "tsup": "^8.0.0",
56
+ "typescript": "^5.3.0"
57
+ },
58
+ "engines": {
59
+ "node": ">=18"
60
+ },
61
+ "dependencies": {
62
+ "@noble/ed25519": "^2.0.0",
63
+ "@noble/hashes": "^1.0.0",
64
+ "did-resolver": "^4.1.0",
65
+ "web-did-resolver": "^2.0.32"
66
+ }
67
67
  }