@covia/covia-sdk 1.3.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/LICENSE.md +190 -21
- package/README.md +592 -528
- package/dist/index.d.mts +155 -2
- package/dist/index.d.ts +155 -2
- package/dist/index.js +164 -5
- package/dist/index.mjs +163 -6
- package/package.json +66 -66
package/dist/index.js
CHANGED
|
@@ -1350,11 +1350,42 @@ var AgentManager = class {
|
|
|
1350
1350
|
async message(agentId, message) {
|
|
1351
1351
|
return this.venue.operations.run("v/ops/agent/message", { agentId, message });
|
|
1352
1352
|
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Send a message to an agent and synchronously await its next response on the session.
|
|
1355
|
+
*
|
|
1356
|
+
* Session lifecycle:
|
|
1357
|
+
* - Omit `sessionId` on the first call — the server mints a new session and returns
|
|
1358
|
+
* its id in the result. Capture it.
|
|
1359
|
+
* - Pass the returned `sessionId` on every subsequent call to continue the conversation.
|
|
1360
|
+
* - An unknown `sessionId` is rejected (the server will not silently mint one); omit
|
|
1361
|
+
* the field entirely to start a new session.
|
|
1362
|
+
*
|
|
1363
|
+
* Concurrency: only one chat may be in flight per session. Concurrent calls on the
|
|
1364
|
+
* same session are rejected by the venue.
|
|
1365
|
+
*
|
|
1366
|
+
* Blocking: always blocks until the agent produces its next response on the session.
|
|
1367
|
+
* No polling required.
|
|
1368
|
+
*/
|
|
1369
|
+
async chat(agentId, message, sessionId) {
|
|
1370
|
+
return this.venue.operations.run("v/ops/agent/chat", { agentId, message, sessionId });
|
|
1371
|
+
}
|
|
1353
1372
|
async trigger(agentId) {
|
|
1354
1373
|
return this.venue.operations.run("v/ops/agent/trigger", { agentId });
|
|
1355
1374
|
}
|
|
1356
1375
|
async query(agentId) {
|
|
1357
|
-
|
|
1376
|
+
const read = (path) => this.venue.operations.run("v/ops/covia/read", { path }).catch(() => ({ value: null }));
|
|
1377
|
+
const [info, timelineRes, stateRes, inboxRes] = await Promise.all([
|
|
1378
|
+
this.venue.operations.run("v/ops/agent/info", { agentId }),
|
|
1379
|
+
read(`g/${agentId}/timeline`),
|
|
1380
|
+
read(`g/${agentId}/state`),
|
|
1381
|
+
read(`g/${agentId}/inbox`)
|
|
1382
|
+
]);
|
|
1383
|
+
return {
|
|
1384
|
+
...info,
|
|
1385
|
+
timeline: Array.isArray(timelineRes.value) ? timelineRes.value : [],
|
|
1386
|
+
state: stateRes.value ?? {},
|
|
1387
|
+
inbox: Array.isArray(inboxRes.value) ? inboxRes.value : []
|
|
1388
|
+
};
|
|
1358
1389
|
}
|
|
1359
1390
|
async list(includeTerminated) {
|
|
1360
1391
|
return this.venue.operations.run("v/ops/agent/list", { includeTerminated });
|
|
@@ -1374,6 +1405,21 @@ var AgentManager = class {
|
|
|
1374
1405
|
async cancelTask(agentId, taskId) {
|
|
1375
1406
|
return this.venue.operations.run("v/ops/agent/cancel-task", { agentId, taskId });
|
|
1376
1407
|
}
|
|
1408
|
+
async info(agentId) {
|
|
1409
|
+
return this.venue.operations.run("v/ops/agent/info", { agentId });
|
|
1410
|
+
}
|
|
1411
|
+
async fork(input) {
|
|
1412
|
+
return this.venue.operations.run("v/ops/agent/fork", input);
|
|
1413
|
+
}
|
|
1414
|
+
async context(agentId, task) {
|
|
1415
|
+
return this.venue.operations.run("v/ops/agent/context", { agentId, task });
|
|
1416
|
+
}
|
|
1417
|
+
async completeTask(result) {
|
|
1418
|
+
return this.venue.operations.run("v/ops/agent/complete-task", { result });
|
|
1419
|
+
}
|
|
1420
|
+
async failTask(error) {
|
|
1421
|
+
return this.venue.operations.run("v/ops/agent/fail-task", { error });
|
|
1422
|
+
}
|
|
1377
1423
|
};
|
|
1378
1424
|
|
|
1379
1425
|
// src/Job.ts
|
|
@@ -1527,11 +1573,15 @@ var JobManager = class {
|
|
|
1527
1573
|
this.venue = venue;
|
|
1528
1574
|
}
|
|
1529
1575
|
async list() {
|
|
1530
|
-
return fetchWithError(`${this.venue.baseUrl}/api/v1/jobs
|
|
1576
|
+
return fetchWithError(`${this.venue.baseUrl}/api/v1/jobs`, {
|
|
1577
|
+
headers: this._buildHeaders()
|
|
1578
|
+
});
|
|
1531
1579
|
}
|
|
1532
1580
|
async get(jobId) {
|
|
1533
1581
|
try {
|
|
1534
|
-
const data = await fetchWithError(`${this.venue.baseUrl}/api/v1/jobs/${jobId}
|
|
1582
|
+
const data = await fetchWithError(`${this.venue.baseUrl}/api/v1/jobs/${jobId}`, {
|
|
1583
|
+
headers: this._buildHeaders()
|
|
1584
|
+
});
|
|
1535
1585
|
return new Job(jobId, this.venue, data);
|
|
1536
1586
|
} catch (error) {
|
|
1537
1587
|
if (error instanceof NotFoundError) {
|
|
@@ -1809,6 +1859,14 @@ var AssetManager = class {
|
|
|
1809
1859
|
throw error;
|
|
1810
1860
|
}
|
|
1811
1861
|
}
|
|
1862
|
+
/**
|
|
1863
|
+
* Pin a resolvable value into the content-addressed asset store.
|
|
1864
|
+
* Idempotent — same value produces the same hash.
|
|
1865
|
+
* @param path - Source address (hex hash, /a/<hash>, /o/<name>, /v/<path>, DID URL, or workspace path)
|
|
1866
|
+
*/
|
|
1867
|
+
async pin(path) {
|
|
1868
|
+
return this.venue.operations.run("v/ops/asset/pin", { path });
|
|
1869
|
+
}
|
|
1812
1870
|
/**
|
|
1813
1871
|
* Clear the asset cache.
|
|
1814
1872
|
*/
|
|
@@ -1835,7 +1893,7 @@ var OperationManager = class {
|
|
|
1835
1893
|
}
|
|
1836
1894
|
/**
|
|
1837
1895
|
* Get details of a named operation
|
|
1838
|
-
* @param name - Operation name (e.g., "
|
|
1896
|
+
* @param name - Operation name (e.g., "v/ops/schema/infer")
|
|
1839
1897
|
*/
|
|
1840
1898
|
async get(name) {
|
|
1841
1899
|
return fetchWithError(`${this.venue.baseUrl}/api/v1/operations/${name}`);
|
|
@@ -1901,6 +1959,12 @@ var WorkspaceManager = class {
|
|
|
1901
1959
|
async slice(path, offset, limit) {
|
|
1902
1960
|
return this.venue.operations.run("v/ops/covia/slice", { path, offset, limit });
|
|
1903
1961
|
}
|
|
1962
|
+
async copy(from, to) {
|
|
1963
|
+
return this.venue.operations.run("v/ops/covia/copy", { from, to });
|
|
1964
|
+
}
|
|
1965
|
+
async inspect(paths, budget, compact) {
|
|
1966
|
+
return this.venue.operations.run("v/ops/covia/inspect", { paths, budget, compact });
|
|
1967
|
+
}
|
|
1904
1968
|
};
|
|
1905
1969
|
|
|
1906
1970
|
// src/UCANManager.ts
|
|
@@ -1939,6 +2003,90 @@ var SecretManager = class {
|
|
|
1939
2003
|
return this.venue.deleteSecret(name);
|
|
1940
2004
|
}
|
|
1941
2005
|
};
|
|
2006
|
+
|
|
2007
|
+
// src/Agent.ts
|
|
2008
|
+
var Agent = class _Agent {
|
|
2009
|
+
constructor(id, venue) {
|
|
2010
|
+
this.id = id;
|
|
2011
|
+
this.venue = venue;
|
|
2012
|
+
this._agents = venue.agents;
|
|
2013
|
+
}
|
|
2014
|
+
async request(input, wait) {
|
|
2015
|
+
return this._agents.request(this.id, input, wait);
|
|
2016
|
+
}
|
|
2017
|
+
async message(message) {
|
|
2018
|
+
return this._agents.message(this.id, message);
|
|
2019
|
+
}
|
|
2020
|
+
async chat(message, sessionId) {
|
|
2021
|
+
return this._agents.chat(this.id, message, sessionId);
|
|
2022
|
+
}
|
|
2023
|
+
/**
|
|
2024
|
+
* Create a ChatSession bound to this agent.
|
|
2025
|
+
* @param sessionId - Optional session ID to resume an existing session
|
|
2026
|
+
*/
|
|
2027
|
+
chatSession(sessionId) {
|
|
2028
|
+
return new ChatSession(this, sessionId);
|
|
2029
|
+
}
|
|
2030
|
+
async trigger() {
|
|
2031
|
+
return this._agents.trigger(this.id);
|
|
2032
|
+
}
|
|
2033
|
+
async query() {
|
|
2034
|
+
return this._agents.query(this.id);
|
|
2035
|
+
}
|
|
2036
|
+
async suspend() {
|
|
2037
|
+
return this._agents.suspend(this.id);
|
|
2038
|
+
}
|
|
2039
|
+
async resume(autoWake) {
|
|
2040
|
+
return this._agents.resume(this.id, autoWake);
|
|
2041
|
+
}
|
|
2042
|
+
async update(options) {
|
|
2043
|
+
return this._agents.update({ agentId: this.id, ...options });
|
|
2044
|
+
}
|
|
2045
|
+
async cancelTask(taskId) {
|
|
2046
|
+
return this._agents.cancelTask(this.id, taskId);
|
|
2047
|
+
}
|
|
2048
|
+
async info() {
|
|
2049
|
+
return this._agents.info(this.id);
|
|
2050
|
+
}
|
|
2051
|
+
/**
|
|
2052
|
+
* Fork this agent into a new agent.
|
|
2053
|
+
* @param agentId - ID for the new forked agent
|
|
2054
|
+
* @param options - Fork options
|
|
2055
|
+
* @returns A new Agent instance for the forked agent
|
|
2056
|
+
*/
|
|
2057
|
+
async fork(agentId, options) {
|
|
2058
|
+
await this._agents.fork({ sourceId: this.id, agentId, ...options });
|
|
2059
|
+
return new _Agent(agentId, this.venue);
|
|
2060
|
+
}
|
|
2061
|
+
async context(task) {
|
|
2062
|
+
return this._agents.context(this.id, task);
|
|
2063
|
+
}
|
|
2064
|
+
async delete(remove) {
|
|
2065
|
+
return this._agents.delete(this.id, remove);
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
var ChatSession = class {
|
|
2069
|
+
constructor(agent, sessionId) {
|
|
2070
|
+
this.agent = agent;
|
|
2071
|
+
this._sessionId = sessionId;
|
|
2072
|
+
}
|
|
2073
|
+
/** The session ID, or undefined if no message has been sent yet and no ID was provided. */
|
|
2074
|
+
get sessionId() {
|
|
2075
|
+
return this._sessionId;
|
|
2076
|
+
}
|
|
2077
|
+
/**
|
|
2078
|
+
* Send a message on this session.
|
|
2079
|
+
* On the first call (when no sessionId is set), the server mints a new session.
|
|
2080
|
+
* The returned sessionId is captured and reused for all subsequent calls.
|
|
2081
|
+
*/
|
|
2082
|
+
async send(message) {
|
|
2083
|
+
const result = await this.agent.chat(message, this._sessionId);
|
|
2084
|
+
this._sessionId = result.sessionId;
|
|
2085
|
+
return result;
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2088
|
+
|
|
2089
|
+
// src/Venue.ts
|
|
1942
2090
|
var webResolver = webDidResolver.getResolver();
|
|
1943
2091
|
var resolver = new didResolver.Resolver(webResolver);
|
|
1944
2092
|
var Venue = class _Venue {
|
|
@@ -2047,6 +2195,15 @@ var Venue = class _Venue {
|
|
|
2047
2195
|
async getJob(jobId) {
|
|
2048
2196
|
return this.jobs.get(jobId);
|
|
2049
2197
|
}
|
|
2198
|
+
/**
|
|
2199
|
+
* Get a lazy Agent handle for the given agent ID.
|
|
2200
|
+
* No network round-trip — the agent is not verified to exist.
|
|
2201
|
+
* @param agentId - Agent identifier
|
|
2202
|
+
* @returns {Agent} An Agent instance bound to this venue
|
|
2203
|
+
*/
|
|
2204
|
+
agent(agentId) {
|
|
2205
|
+
return new Agent(agentId, this);
|
|
2206
|
+
}
|
|
2050
2207
|
/**
|
|
2051
2208
|
* List secret names
|
|
2052
2209
|
* @returns {Promise<string[]>}
|
|
@@ -2055,7 +2212,7 @@ var Venue = class _Venue {
|
|
|
2055
2212
|
const result = await fetchWithError(`${this.baseUrl}/api/v1/secrets`, {
|
|
2056
2213
|
headers: this._buildHeaders()
|
|
2057
2214
|
});
|
|
2058
|
-
return result.items;
|
|
2215
|
+
return Array.isArray(result.items) ? result.items : [];
|
|
2059
2216
|
}
|
|
2060
2217
|
/**
|
|
2061
2218
|
* Store a secret value
|
|
@@ -2153,6 +2310,7 @@ var Grid = class {
|
|
|
2153
2310
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2154
2311
|
*/
|
|
2155
2312
|
|
|
2313
|
+
exports.Agent = Agent;
|
|
2156
2314
|
exports.AgentManager = AgentManager;
|
|
2157
2315
|
exports.AgentStatus = AgentStatus;
|
|
2158
2316
|
exports.Asset = Asset;
|
|
@@ -2160,6 +2318,7 @@ exports.AssetManager = AssetManager;
|
|
|
2160
2318
|
exports.AssetNotFoundError = AssetNotFoundError;
|
|
2161
2319
|
exports.Auth = Auth;
|
|
2162
2320
|
exports.BearerAuth = BearerAuth;
|
|
2321
|
+
exports.ChatSession = ChatSession;
|
|
2163
2322
|
exports.CoviaConnectionError = CoviaConnectionError;
|
|
2164
2323
|
exports.CoviaError = CoviaError;
|
|
2165
2324
|
exports.CoviaTimeoutError = CoviaTimeoutError;
|
package/dist/index.mjs
CHANGED
|
@@ -1348,11 +1348,42 @@ var AgentManager = class {
|
|
|
1348
1348
|
async message(agentId, message) {
|
|
1349
1349
|
return this.venue.operations.run("v/ops/agent/message", { agentId, message });
|
|
1350
1350
|
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Send a message to an agent and synchronously await its next response on the session.
|
|
1353
|
+
*
|
|
1354
|
+
* Session lifecycle:
|
|
1355
|
+
* - Omit `sessionId` on the first call — the server mints a new session and returns
|
|
1356
|
+
* its id in the result. Capture it.
|
|
1357
|
+
* - Pass the returned `sessionId` on every subsequent call to continue the conversation.
|
|
1358
|
+
* - An unknown `sessionId` is rejected (the server will not silently mint one); omit
|
|
1359
|
+
* the field entirely to start a new session.
|
|
1360
|
+
*
|
|
1361
|
+
* Concurrency: only one chat may be in flight per session. Concurrent calls on the
|
|
1362
|
+
* same session are rejected by the venue.
|
|
1363
|
+
*
|
|
1364
|
+
* Blocking: always blocks until the agent produces its next response on the session.
|
|
1365
|
+
* No polling required.
|
|
1366
|
+
*/
|
|
1367
|
+
async chat(agentId, message, sessionId) {
|
|
1368
|
+
return this.venue.operations.run("v/ops/agent/chat", { agentId, message, sessionId });
|
|
1369
|
+
}
|
|
1351
1370
|
async trigger(agentId) {
|
|
1352
1371
|
return this.venue.operations.run("v/ops/agent/trigger", { agentId });
|
|
1353
1372
|
}
|
|
1354
1373
|
async query(agentId) {
|
|
1355
|
-
|
|
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
|
+
};
|
|
1356
1387
|
}
|
|
1357
1388
|
async list(includeTerminated) {
|
|
1358
1389
|
return this.venue.operations.run("v/ops/agent/list", { includeTerminated });
|
|
@@ -1372,6 +1403,21 @@ var AgentManager = class {
|
|
|
1372
1403
|
async cancelTask(agentId, taskId) {
|
|
1373
1404
|
return this.venue.operations.run("v/ops/agent/cancel-task", { agentId, taskId });
|
|
1374
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
|
+
}
|
|
1375
1421
|
};
|
|
1376
1422
|
|
|
1377
1423
|
// src/Job.ts
|
|
@@ -1525,11 +1571,15 @@ var JobManager = class {
|
|
|
1525
1571
|
this.venue = venue;
|
|
1526
1572
|
}
|
|
1527
1573
|
async list() {
|
|
1528
|
-
return fetchWithError(`${this.venue.baseUrl}/api/v1/jobs
|
|
1574
|
+
return fetchWithError(`${this.venue.baseUrl}/api/v1/jobs`, {
|
|
1575
|
+
headers: this._buildHeaders()
|
|
1576
|
+
});
|
|
1529
1577
|
}
|
|
1530
1578
|
async get(jobId) {
|
|
1531
1579
|
try {
|
|
1532
|
-
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
|
+
});
|
|
1533
1583
|
return new Job(jobId, this.venue, data);
|
|
1534
1584
|
} catch (error) {
|
|
1535
1585
|
if (error instanceof NotFoundError) {
|
|
@@ -1807,6 +1857,14 @@ var AssetManager = class {
|
|
|
1807
1857
|
throw error;
|
|
1808
1858
|
}
|
|
1809
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
|
+
}
|
|
1810
1868
|
/**
|
|
1811
1869
|
* Clear the asset cache.
|
|
1812
1870
|
*/
|
|
@@ -1833,7 +1891,7 @@ var OperationManager = class {
|
|
|
1833
1891
|
}
|
|
1834
1892
|
/**
|
|
1835
1893
|
* Get details of a named operation
|
|
1836
|
-
* @param name - Operation name (e.g., "
|
|
1894
|
+
* @param name - Operation name (e.g., "v/ops/schema/infer")
|
|
1837
1895
|
*/
|
|
1838
1896
|
async get(name) {
|
|
1839
1897
|
return fetchWithError(`${this.venue.baseUrl}/api/v1/operations/${name}`);
|
|
@@ -1899,6 +1957,12 @@ var WorkspaceManager = class {
|
|
|
1899
1957
|
async slice(path, offset, limit) {
|
|
1900
1958
|
return this.venue.operations.run("v/ops/covia/slice", { path, offset, limit });
|
|
1901
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
|
+
}
|
|
1902
1966
|
};
|
|
1903
1967
|
|
|
1904
1968
|
// src/UCANManager.ts
|
|
@@ -1937,6 +2001,90 @@ var SecretManager = class {
|
|
|
1937
2001
|
return this.venue.deleteSecret(name);
|
|
1938
2002
|
}
|
|
1939
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
|
|
1940
2088
|
var webResolver = getResolver();
|
|
1941
2089
|
var resolver = new Resolver(webResolver);
|
|
1942
2090
|
var Venue = class _Venue {
|
|
@@ -2045,6 +2193,15 @@ var Venue = class _Venue {
|
|
|
2045
2193
|
async getJob(jobId) {
|
|
2046
2194
|
return this.jobs.get(jobId);
|
|
2047
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
|
+
}
|
|
2048
2205
|
/**
|
|
2049
2206
|
* List secret names
|
|
2050
2207
|
* @returns {Promise<string[]>}
|
|
@@ -2053,7 +2210,7 @@ var Venue = class _Venue {
|
|
|
2053
2210
|
const result = await fetchWithError(`${this.baseUrl}/api/v1/secrets`, {
|
|
2054
2211
|
headers: this._buildHeaders()
|
|
2055
2212
|
});
|
|
2056
|
-
return result.items;
|
|
2213
|
+
return Array.isArray(result.items) ? result.items : [];
|
|
2057
2214
|
}
|
|
2058
2215
|
/**
|
|
2059
2216
|
* Store a secret value
|
|
@@ -2151,4 +2308,4 @@ var Grid = class {
|
|
|
2151
2308
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2152
2309
|
*/
|
|
2153
2310
|
|
|
2154
|
-
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
|
-
"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 test",
|
|
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": "
|
|
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
|
}
|