@0gfoundation/0g-agentdna 0.4.0 → 0.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/GUIDE.md +190 -40
- package/OPERATORS.md +164 -0
- package/OPERATORS.zh.md +141 -0
- package/PROVIDERS.md +6 -0
- package/PROVIDERS.zh.md +3 -1
- package/README.md +84 -11
- package/dist/AgentClient.d.ts +374 -26
- package/dist/AgentClient.d.ts.map +1 -1
- package/dist/AgentClient.js +323 -40
- package/dist/AgentClient.js.map +1 -1
- package/dist/AgenticID.d.ts +170 -80
- package/dist/AgenticID.d.ts.map +1 -1
- package/dist/AgenticID.js +300 -42
- package/dist/AgenticID.js.map +1 -1
- package/dist/AttestorClient.d.ts +115 -31
- package/dist/AttestorClient.d.ts.map +1 -1
- package/dist/AttestorClient.js +276 -56
- package/dist/AttestorClient.js.map +1 -1
- package/dist/Credentials.d.ts +574 -0
- package/dist/Credentials.d.ts.map +1 -0
- package/dist/Credentials.js +838 -0
- package/dist/Credentials.js.map +1 -0
- package/dist/Operators.d.ts +60 -0
- package/dist/Operators.d.ts.map +1 -0
- package/dist/Operators.js +38 -0
- package/dist/Operators.js.map +1 -0
- package/dist/Providers.d.ts +13 -0
- package/dist/Providers.d.ts.map +1 -1
- package/dist/Providers.js +20 -1
- package/dist/Providers.js.map +1 -1
- package/dist/Releases.d.ts +51 -0
- package/dist/Releases.d.ts.map +1 -0
- package/dist/Releases.js +72 -0
- package/dist/Releases.js.map +1 -0
- package/dist/ReputationClient.d.ts +47 -3
- package/dist/ReputationClient.d.ts.map +1 -1
- package/dist/ReputationClient.js +204 -78
- package/dist/ReputationClient.js.map +1 -1
- package/dist/ServeProof.d.ts +70 -23
- package/dist/ServeProof.d.ts.map +1 -1
- package/dist/ServeProof.js +94 -35
- package/dist/ServeProof.js.map +1 -1
- package/dist/ServeSession.d.ts +17 -2
- package/dist/ServeSession.d.ts.map +1 -1
- package/dist/ServeSession.js +77 -9
- package/dist/ServeSession.js.map +1 -1
- package/dist/Settings.d.ts +25 -1
- package/dist/Settings.d.ts.map +1 -1
- package/dist/Settings.js +53 -1
- package/dist/Settings.js.map +1 -1
- package/dist/TrustRegistry.d.ts +28 -0
- package/dist/TrustRegistry.d.ts.map +1 -0
- package/dist/TrustRegistry.js +67 -0
- package/dist/TrustRegistry.js.map +1 -0
- package/dist/abi.d.ts +346 -34
- package/dist/abi.d.ts.map +1 -1
- package/dist/abi.js +150 -30
- package/dist/abi.js.map +1 -1
- package/dist/cli/attach.d.ts +79 -0
- package/dist/cli/attach.d.ts.map +1 -0
- package/dist/cli/attach.js +253 -0
- package/dist/cli/attach.js.map +1 -0
- package/dist/cli/commands/cells.d.ts +45 -0
- package/dist/cli/commands/cells.d.ts.map +1 -1
- package/dist/cli/commands/cells.js +77 -0
- package/dist/cli/commands/cells.js.map +1 -1
- package/dist/cli/commands/cred.d.ts +12 -0
- package/dist/cli/commands/cred.d.ts.map +1 -0
- package/dist/cli/commands/cred.js +43 -0
- package/dist/cli/commands/cred.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +44 -35
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/interactive.d.ts +597 -21
- package/dist/cli/commands/interactive.d.ts.map +1 -1
- package/dist/cli/commands/interactive.js +5082 -1323
- package/dist/cli/commands/interactive.js.map +1 -1
- package/dist/cli/commands/list.d.ts +5 -5
- package/dist/cli/commands/list.d.ts.map +1 -1
- package/dist/cli/commands/list.js +21 -26
- package/dist/cli/commands/list.js.map +1 -1
- package/dist/cli/commands/providers.d.ts +4 -0
- package/dist/cli/commands/providers.d.ts.map +1 -1
- package/dist/cli/commands/providers.js +19 -5
- package/dist/cli/commands/providers.js.map +1 -1
- package/dist/cli/commands/releases.d.ts +13 -0
- package/dist/cli/commands/releases.d.ts.map +1 -0
- package/dist/cli/commands/releases.js +65 -0
- package/dist/cli/commands/releases.js.map +1 -0
- package/dist/cli/commands/settings.d.ts +5 -0
- package/dist/cli/commands/settings.d.ts.map +1 -1
- package/dist/cli/commands/settings.js +70 -24
- package/dist/cli/commands/settings.js.map +1 -1
- package/dist/cli/commands/status.d.ts +2 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +22 -19
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/config.d.ts +48 -1
- package/dist/cli/config.d.ts.map +1 -1
- package/dist/cli/config.js +114 -5
- package/dist/cli/config.js.map +1 -1
- package/dist/cli/credentials.d.ts +179 -0
- package/dist/cli/credentials.d.ts.map +1 -0
- package/dist/cli/credentials.js +1443 -0
- package/dist/cli/credentials.js.map +1 -0
- package/dist/cli/download.d.ts +21 -0
- package/dist/cli/download.d.ts.map +1 -0
- package/dist/cli/download.js +89 -0
- package/dist/cli/download.js.map +1 -0
- package/dist/cli/env.d.ts +6 -0
- package/dist/cli/env.d.ts.map +1 -1
- package/dist/cli/env.js +18 -6
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/envelope.d.ts +4 -2
- package/dist/cli/envelope.d.ts.map +1 -1
- package/dist/cli/envelope.js +10 -6
- package/dist/cli/envelope.js.map +1 -1
- package/dist/cli/errors.d.ts +45 -1
- package/dist/cli/errors.d.ts.map +1 -1
- package/dist/cli/errors.js +77 -0
- package/dist/cli/errors.js.map +1 -1
- package/dist/cli/inference.d.ts.map +1 -1
- package/dist/cli/inference.js +7 -0
- package/dist/cli/inference.js.map +1 -1
- package/dist/cli/inkView.d.ts +341 -0
- package/dist/cli/inkView.d.ts.map +1 -0
- package/dist/cli/inkView.js +1019 -0
- package/dist/cli/inkView.js.map +1 -0
- package/dist/cli/legacy/modelKey.d.ts +24 -0
- package/dist/cli/legacy/modelKey.d.ts.map +1 -0
- package/dist/cli/legacy/modelKey.js +32 -0
- package/dist/cli/legacy/modelKey.js.map +1 -0
- package/dist/cli/livePrompt.d.ts +212 -0
- package/dist/cli/livePrompt.d.ts.map +1 -0
- package/dist/cli/livePrompt.js +576 -0
- package/dist/cli/livePrompt.js.map +1 -0
- package/dist/cli/main.js +206 -72
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/modelkey.d.ts +64 -0
- package/dist/cli/modelkey.d.ts.map +1 -0
- package/dist/cli/modelkey.js +113 -0
- package/dist/cli/modelkey.js.map +1 -0
- package/dist/cli/outboxSync.d.ts +51 -0
- package/dist/cli/outboxSync.d.ts.map +1 -0
- package/dist/cli/outboxSync.js +210 -0
- package/dist/cli/outboxSync.js.map +1 -0
- package/dist/cli/plain.d.ts +46 -0
- package/dist/cli/plain.d.ts.map +1 -0
- package/dist/cli/plain.js +260 -0
- package/dist/cli/plain.js.map +1 -0
- package/dist/cli/proofs.d.ts +5 -0
- package/dist/cli/proofs.d.ts.map +1 -1
- package/dist/cli/proofs.js +20 -0
- package/dist/cli/proofs.js.map +1 -1
- package/dist/cli/ref.d.ts.map +1 -1
- package/dist/cli/ref.js +3 -2
- package/dist/cli/ref.js.map +1 -1
- package/dist/cli/releaseNotice.d.ts +64 -0
- package/dist/cli/releaseNotice.d.ts.map +1 -0
- package/dist/cli/releaseNotice.js +194 -0
- package/dist/cli/releaseNotice.js.map +1 -0
- package/dist/cli/sdk.d.ts +18 -0
- package/dist/cli/sdk.d.ts.map +1 -1
- package/dist/cli/sdk.js +99 -1
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli/settings.d.ts +87 -6
- package/dist/cli/settings.d.ts.map +1 -1
- package/dist/cli/settings.js +270 -18
- package/dist/cli/settings.js.map +1 -1
- package/dist/cli/textfit.d.ts +28 -0
- package/dist/cli/textfit.d.ts.map +1 -0
- package/dist/cli/textfit.js +111 -0
- package/dist/cli/textfit.js.map +1 -0
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/context.d.ts +26 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -0
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy/modelKey.d.ts +67 -0
- package/dist/legacy/modelKey.d.ts.map +1 -0
- package/dist/legacy/modelKey.js +80 -0
- package/dist/legacy/modelKey.js.map +1 -0
- package/dist/legacy/serveProofV1.d.ts +56 -0
- package/dist/legacy/serveProofV1.d.ts.map +1 -0
- package/dist/legacy/serveProofV1.js +91 -0
- package/dist/legacy/serveProofV1.js.map +1 -0
- package/dist/provider-catalog.json +3 -2
- package/dist/secretEnv.d.ts +18 -3
- package/dist/secretEnv.d.ts.map +1 -1
- package/dist/secretEnv.js +16 -2
- package/dist/secretEnv.js.map +1 -1
- package/dist/types.d.ts +63 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/viemErrors.d.ts +30 -0
- package/dist/viemErrors.d.ts.map +1 -0
- package/dist/viemErrors.js +36 -0
- package/dist/viemErrors.js.map +1 -0
- package/package.json +5 -1
- package/src/AgentClient.ts +622 -68
- package/src/AgenticID.ts +345 -56
- package/src/AttestorClient.ts +330 -83
- package/src/Credentials.ts +1027 -0
- package/src/Operators.ts +71 -0
- package/src/Providers.ts +20 -0
- package/src/Releases.ts +95 -0
- package/src/ReputationClient.ts +231 -79
- package/src/ServeProof.ts +123 -39
- package/src/ServeSession.ts +91 -9
- package/src/Settings.ts +61 -1
- package/src/TrustRegistry.ts +75 -0
- package/src/abi.ts +153 -30
- package/src/cli/attach.ts +257 -0
- package/src/cli/commands/cells.ts +104 -0
- package/src/cli/commands/cred.ts +44 -0
- package/src/cli/commands/doctor.ts +45 -37
- package/src/cli/commands/interactive.ts +4120 -664
- package/src/cli/commands/list.ts +21 -30
- package/src/cli/commands/providers.ts +17 -4
- package/src/cli/commands/releases.ts +60 -0
- package/src/cli/commands/settings.ts +75 -28
- package/src/cli/commands/status.ts +24 -21
- package/src/cli/config.ts +119 -4
- package/src/cli/credentials.ts +1379 -0
- package/src/cli/download.ts +80 -0
- package/src/cli/env.ts +22 -7
- package/src/cli/envelope.ts +10 -6
- package/src/cli/errors.ts +92 -0
- package/src/cli/inference.ts +8 -1
- package/src/cli/inkView.ts +969 -0
- package/src/cli/legacy/modelKey.ts +35 -0
- package/src/cli/livePrompt.ts +615 -0
- package/src/cli/main.ts +206 -76
- package/src/cli/modelkey.ts +124 -0
- package/src/cli/outboxSync.ts +231 -0
- package/src/cli/plain.ts +260 -0
- package/src/cli/proofs.ts +27 -0
- package/src/cli/ref.ts +5 -4
- package/src/cli/releaseNotice.ts +200 -0
- package/src/cli/sdk.ts +87 -7
- package/src/cli/settings.ts +272 -22
- package/src/cli/textfit.ts +95 -0
- package/src/constants.ts +1 -1
- package/src/context.ts +28 -0
- package/src/index.ts +50 -7
- package/src/legacy/modelKey.ts +80 -0
- package/src/legacy/serveProofV1.ts +124 -0
- package/src/provider-catalog.json +3 -2
- package/src/secretEnv.ts +18 -3
- package/src/types.ts +60 -1
- package/src/viemErrors.ts +39 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* New files in the agent's `~/outbox` come to the owner by themselves (0g-harness):
|
|
3
|
+
* each one is saved to `~/agentdna/<agentId>/outbox/<name>` on this machine.
|
|
4
|
+
* A file already saved there with the same content is not saved again; a
|
|
5
|
+
* different file of the same name is never overwritten: the new one gets
|
|
6
|
+
* "-1", "-2", … before its extension (saveDownload). Files over the download
|
|
7
|
+
* limit are skipped and reported once.
|
|
8
|
+
*
|
|
9
|
+
* Once a file is saved and its size (and hash, when the listing has one)
|
|
10
|
+
* match the outbox's, it is removed from the outbox (`remove`): the owner
|
|
11
|
+
* has it, and the agent's disk does not keep a copy. A runtime without the
|
|
12
|
+
* delete route keeps its files; deleting is then not tried again this
|
|
13
|
+
* session.
|
|
14
|
+
*
|
|
15
|
+
* Which versions of which files were saved is kept next to that folder
|
|
16
|
+
* (`outbox-saved.json`: name → size, time, hash, local path), so a check
|
|
17
|
+
* downloads only what changed. Without it (lost, unreadable) a check downloads
|
|
18
|
+
* the outbox again and the content comparison keeps it from saving copies.
|
|
19
|
+
*/
|
|
20
|
+
import { createHash } from 'node:crypto';
|
|
21
|
+
import { mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'node:fs';
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { extname, join, sep } from 'node:path';
|
|
24
|
+
import { pathToFileURL } from 'node:url';
|
|
25
|
+
import type { AgentFile } from '../AgentClient';
|
|
26
|
+
import { cleanCell } from './commands/cells';
|
|
27
|
+
import { DOWNLOAD_MAX_BYTES, localName, saveDownload, size } from './download';
|
|
28
|
+
|
|
29
|
+
/** How often the session looks at the outbox. */
|
|
30
|
+
export const OUTBOX_POLL_MS = 30_000;
|
|
31
|
+
|
|
32
|
+
/** What a check did with one file. */
|
|
33
|
+
export interface OutboxEvent {
|
|
34
|
+
kind: 'saved' | 'skipped' | 'failed';
|
|
35
|
+
/** Its name in the outbox. */
|
|
36
|
+
name: string;
|
|
37
|
+
bytes: number;
|
|
38
|
+
/** Where it was saved. */
|
|
39
|
+
path?: string;
|
|
40
|
+
error?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface Saved { bytes: number; mtime: string; sha256?: string; path?: string }
|
|
44
|
+
|
|
45
|
+
/** This machine's folder for one agent's files: `~/agentdna/<agentId>`. */
|
|
46
|
+
export function agentFilesDir(agentId: string, home: string = homedir()): string {
|
|
47
|
+
return join(home, 'agentdna', agentId);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface OutboxSync {
|
|
51
|
+
/** Look at the outbox now (a check already running is shared). With
|
|
52
|
+
* saving on, new files are saved; off, they are only counted. */
|
|
53
|
+
check(): Promise<OutboxEvent[]>;
|
|
54
|
+
/** New files the last check counted and did not save (saving off), less
|
|
55
|
+
* those `/files` has listed since. */
|
|
56
|
+
unseen(): number;
|
|
57
|
+
/** `/files` listed these: not new any more. */
|
|
58
|
+
listed(files: readonly AgentFile[]): void;
|
|
59
|
+
/** Where files are saved. */
|
|
60
|
+
readonly dir: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function makeOutboxSync(o: {
|
|
64
|
+
agentId: string;
|
|
65
|
+
home?: string;
|
|
66
|
+
list(): Promise<AgentFile[]>;
|
|
67
|
+
download(name: string): Promise<Uint8Array>;
|
|
68
|
+
/** Whether new files are saved (else only counted). */
|
|
69
|
+
auto(): boolean;
|
|
70
|
+
/** Remove a saved file from the outbox; see {@link AgentClient.deleteFile}. */
|
|
71
|
+
remove?(name: string): Promise<'deleted' | 'missing' | 'unsupported'>;
|
|
72
|
+
}): OutboxSync {
|
|
73
|
+
const base = agentFilesDir(o.agentId, o.home);
|
|
74
|
+
const dir = join(base, 'outbox');
|
|
75
|
+
const indexFile = join(base, 'outbox-saved.json');
|
|
76
|
+
const index = readIndex(indexFile);
|
|
77
|
+
// Versions reported this session (skipped, failed) and listed by /files.
|
|
78
|
+
const reported = new Set<string>();
|
|
79
|
+
const shown = new Set<string>();
|
|
80
|
+
let unseen: AgentFile[] = [];
|
|
81
|
+
let running: Promise<OutboxEvent[]> | null = null;
|
|
82
|
+
let canRemove = !!o.remove;
|
|
83
|
+
|
|
84
|
+
const version = (f: AgentFile): string => `${f.name}\u0000${f.bytes}\u0000${f.mtime}`;
|
|
85
|
+
const isNew = (f: AgentFile): boolean => {
|
|
86
|
+
const s = index[f.name];
|
|
87
|
+
return !s || s.bytes !== f.bytes || s.mtime !== f.mtime || (!!f.sha256 && !!s.sha256 && f.sha256 !== s.sha256);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
async function run(): Promise<OutboxEvent[]> {
|
|
91
|
+
const files = (await o.list()).filter((f) => isNew(f) && !reported.has(version(f))).reverse(); // oldest first
|
|
92
|
+
const events: OutboxEvent[] = [];
|
|
93
|
+
if (!o.auto()) {
|
|
94
|
+
unseen = files.filter((f) => !shown.has(version(f)));
|
|
95
|
+
return events;
|
|
96
|
+
}
|
|
97
|
+
unseen = [];
|
|
98
|
+
for (const f of files) {
|
|
99
|
+
if (f.bytes > DOWNLOAD_MAX_BYTES) {
|
|
100
|
+
reported.add(version(f));
|
|
101
|
+
events.push({ kind: 'skipped', name: f.name, bytes: f.bytes });
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
const bytes = await o.download(f.name);
|
|
106
|
+
const sha256 = createHash('sha256').update(bytes).digest('hex');
|
|
107
|
+
mkdirSync(dir, { recursive: true });
|
|
108
|
+
const have = sameFile(dir, f.name, bytes.length, sha256);
|
|
109
|
+
const path = have ?? saveDownload(bytes, f.name, dir);
|
|
110
|
+
index[f.name] = { bytes: f.bytes, mtime: f.mtime, sha256: f.sha256 ?? sha256, path };
|
|
111
|
+
writeIndex(indexFile, index);
|
|
112
|
+
if (!have) events.push({ kind: 'saved', name: f.name, bytes: bytes.length, path });
|
|
113
|
+
// The owner has it: take it off the agent's disk, unless what came
|
|
114
|
+
// down is not what the listing described (it changed meanwhile).
|
|
115
|
+
if (canRemove && bytes.length === f.bytes && (!f.sha256 || f.sha256 === sha256)) {
|
|
116
|
+
try {
|
|
117
|
+
if ((await o.remove!(f.name)) === 'unsupported') canRemove = false;
|
|
118
|
+
} catch { /* kept in the outbox; its age clears it later */ }
|
|
119
|
+
}
|
|
120
|
+
} catch (e) {
|
|
121
|
+
reported.add(version(f));
|
|
122
|
+
events.push({ kind: 'failed', name: f.name, bytes: f.bytes, error: (e as Error).message });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return events;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
dir,
|
|
130
|
+
check() {
|
|
131
|
+
running ??= run().finally(() => { running = null; });
|
|
132
|
+
return running;
|
|
133
|
+
},
|
|
134
|
+
unseen: () => unseen.filter((f) => !shown.has(version(f))).length,
|
|
135
|
+
listed(files) {
|
|
136
|
+
for (const f of files) shown.add(version(f));
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A file in `dir` that is `name` (or `name` saved under -1, -2, …) with this content, if any. */
|
|
142
|
+
function sameFile(dir: string, name: string, bytes: number, sha256: string): string | null {
|
|
143
|
+
const file = localName(name);
|
|
144
|
+
const ext = extname(file);
|
|
145
|
+
const stem = file.slice(0, file.length - ext.length) || 'download';
|
|
146
|
+
const esc = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
147
|
+
const same = new RegExp(`^${esc(stem)}(?:-\\d+)?${esc(ext)}$`);
|
|
148
|
+
let names: string[];
|
|
149
|
+
try {
|
|
150
|
+
names = readdirSync(dir);
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
for (const n of names) {
|
|
155
|
+
if (!same.test(n)) continue;
|
|
156
|
+
const p = join(dir, n);
|
|
157
|
+
try {
|
|
158
|
+
const st = statSync(p);
|
|
159
|
+
if (!st.isFile() || st.size !== bytes) continue;
|
|
160
|
+
if (createHash('sha256').update(readFileSync(p)).digest('hex') === sha256) return p;
|
|
161
|
+
} catch {
|
|
162
|
+
// gone or unreadable: not this one
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function readIndex(file: string): Record<string, Saved> {
|
|
169
|
+
try {
|
|
170
|
+
const j = JSON.parse(readFileSync(file, 'utf8')) as unknown;
|
|
171
|
+
return j && typeof j === 'object' && !Array.isArray(j) ? (j as Record<string, Saved>) : {};
|
|
172
|
+
} catch {
|
|
173
|
+
return {};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function writeIndex(file: string, index: Record<string, Saved>): void {
|
|
178
|
+
try {
|
|
179
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
180
|
+
writeFileSync(tmp, `${JSON.stringify(index, null, 2)}\n`, { mode: 0o600 });
|
|
181
|
+
renameSync(tmp, file);
|
|
182
|
+
} catch {
|
|
183
|
+
// The files are saved; without the record the next session compares content instead.
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** `path` with the home folder written as `~`. */
|
|
188
|
+
export function tildePath(path: string, home: string = homedir()): string {
|
|
189
|
+
return path === home || path.startsWith(home + sep) ? `~${path.slice(home.length)}` : path;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Whether the terminal shows OSC 8 hyperlinks: FORCE_HYPERLINK=1|0 decides
|
|
194
|
+
* when set; otherwise the terminals known to (iTerm2, WezTerm, VS Code,
|
|
195
|
+
* Ghostty, kitty, Windows Terminal, VTE-based ones such as GNOME Terminal,
|
|
196
|
+
* Konsole, Alacritty) on a terminal.
|
|
197
|
+
*/
|
|
198
|
+
export function supportsHyperlinks(env: NodeJS.ProcessEnv = process.env, isTTY = !!process.stdout.isTTY): boolean {
|
|
199
|
+
const force = env.FORCE_HYPERLINK;
|
|
200
|
+
if (force !== undefined && force !== '') return !/^(0|false|no|off)$/i.test(force);
|
|
201
|
+
if (!isTTY || env.TERM === 'dumb') return false;
|
|
202
|
+
if (env.TMUX || env.STY) return false; // a multiplexer may not pass the sequence on
|
|
203
|
+
const program = env.TERM_PROGRAM ?? '';
|
|
204
|
+
if (program === 'iTerm.app') {
|
|
205
|
+
const [major, minor] = (env.TERM_PROGRAM_VERSION ?? '0.0').split('.').map(Number);
|
|
206
|
+
return major > 3 || (major === 3 && minor >= 1);
|
|
207
|
+
}
|
|
208
|
+
if (['WezTerm', 'vscode', 'ghostty', 'Hyper', 'Tabby'].includes(program)) return true;
|
|
209
|
+
if (env.WT_SESSION || env.KITTY_WINDOW_ID || env.KONSOLE_VERSION || env.ALACRITTY_WINDOW_ID || env.DOMTERM) return true;
|
|
210
|
+
if (env.TERM === 'xterm-kitty' || env.TERM === 'alacritty' || env.TERM === 'xterm-ghostty') return true;
|
|
211
|
+
return Number(env.VTE_VERSION ?? 0) >= 5000;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** `text` as an OSC 8 link to a local file, when `on`; plain text otherwise. */
|
|
215
|
+
export function fileLink(text: string, path: string, on: boolean): string {
|
|
216
|
+
return on ? `\x1b]8;;${pathToFileURL(path).href}\x1b\\${text}\x1b]8;;\x1b\\` : text;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** One check's result as the session prints it. `links`: the path as a hyperlink. */
|
|
220
|
+
export function renderOutboxEvent(e: OutboxEvent, links: boolean, home: string = homedir()): string {
|
|
221
|
+
const name = cleanCell(e.name);
|
|
222
|
+
if (e.kind === 'skipped') {
|
|
223
|
+
return `${name} (${size(e.bytes)}) is over the ${size(DOWNLOAD_MAX_BYTES)} download limit: not saved\n`;
|
|
224
|
+
}
|
|
225
|
+
if (e.kind === 'failed') {
|
|
226
|
+
return `could not save ${name}: ${cleanCell(e.error ?? 'no reason given')} — /download ${name} tries again\n`;
|
|
227
|
+
}
|
|
228
|
+
const path = e.path ?? '';
|
|
229
|
+
const renamed = localName(e.name) !== path.slice(path.lastIndexOf(sep) + 1);
|
|
230
|
+
return `saved ${name} → ${fileLink(cleanCell(tildePath(path, home)), path, links)}${renamed ? ` (another file named ${name} is already there)` : ''}\n`;
|
|
231
|
+
}
|
package/src/cli/plain.ts
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file plain.ts
|
|
3
|
+
* @description What the owner reads when a command fails, and the checks
|
|
4
|
+
* that come before a transaction. An error is one or two plain lines with a
|
|
5
|
+
* remedy the owner can type where they are (errors.ts: shellStep): no raw
|
|
6
|
+
* HTTP bodies, no wei, no viem dumps (request arguments, docs link,
|
|
7
|
+
* version), no SDK or console references. `--json` keeps the full original
|
|
8
|
+
* text in `error.details.cause`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { formatEther, parseEther } from 'viem';
|
|
12
|
+
import { findViemError } from '../viemErrors';
|
|
13
|
+
import { CliError, cmdStep, lifecycleTo, shellStep, shellTo, type ErrorCode } from './errors';
|
|
14
|
+
|
|
15
|
+
/** An error as the owner reads it. */
|
|
16
|
+
export interface Plain {
|
|
17
|
+
message: string;
|
|
18
|
+
remedy?: string;
|
|
19
|
+
/** The CLI error code it maps to (one-shot exit codes); UNKNOWN when none fits. */
|
|
20
|
+
code?: ErrorCode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
|
|
24
|
+
|
|
25
|
+
/** `0.005` — an OG amount as a person writes it (no trailing zeros). */
|
|
26
|
+
export function ogAmount(wei: bigint): string {
|
|
27
|
+
return formatEther(wei);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** `681.357721 OG` — an OG balance to read, with six decimals (as whoami shows them). */
|
|
31
|
+
export function ogShown(wei: bigint): string {
|
|
32
|
+
return `${(Number(wei) / 1e18).toFixed(6)} OG`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* An amount of OG typed by the owner, in wei. Refuses anything that is not a
|
|
37
|
+
* plain positive decimal (`-1`, `abc`, `0`, `1e3`, more than 18 decimals)
|
|
38
|
+
* before any transaction is built.
|
|
39
|
+
*/
|
|
40
|
+
export function parseOgAmount(text: string): bigint {
|
|
41
|
+
const t = text.trim();
|
|
42
|
+
const decimals = t.split('.')[1]?.length ?? 0;
|
|
43
|
+
if (!/^(?:\d+(?:\.\d*)?|\.\d+)$/.test(t) || decimals > 18) {
|
|
44
|
+
throw new CliError('BAD_FLAG', `${t ? `"${t}"` : 'nothing'} is not an amount of OG — type a number above 0, e.g. 0.5`);
|
|
45
|
+
}
|
|
46
|
+
const wei = parseEther(t.endsWith('.') ? `${t}0` : t);
|
|
47
|
+
if (wei <= 0n) throw new CliError('BAD_FLAG', 'the amount must be above 0 OG');
|
|
48
|
+
return wei;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The contract's custom revert, in one sentence; undefined for anything else.
|
|
53
|
+
* Kept to the errors the CLI's own commands can hit.
|
|
54
|
+
*/
|
|
55
|
+
export function revertText(e: unknown): string | undefined {
|
|
56
|
+
const revert = findViemError(e, ['ContractFunctionRevertedError']) as { data?: { errorName?: string; args?: readonly unknown[] } } | null;
|
|
57
|
+
const d = revert?.data;
|
|
58
|
+
if (!d?.errorName) return undefined;
|
|
59
|
+
const a = (d.args ?? []) as readonly unknown[];
|
|
60
|
+
switch (d.errorName) {
|
|
61
|
+
case 'CloneGateNotTokenOwner':
|
|
62
|
+
return `agent ${a[1]} is not yours — its owner is ${a[2]} (you signed as ${a[0]})`;
|
|
63
|
+
case 'StdCloneAuthNotSeller':
|
|
64
|
+
return `only agent ${a[1]}'s owner (${a[2]}) can manage its fork grants — you signed as ${a[0]}`;
|
|
65
|
+
case 'CloneGateDenied':
|
|
66
|
+
return a[1] === ZERO_ADDR
|
|
67
|
+
? `agent ${a[0]} has no fork policy configured — its owner opens sales with: authorizer ${a[0]} <policy>`
|
|
68
|
+
: `agent ${a[0]}'s fork policy (${a[1]}) declined — ask the seller to: grant ${a[0]} <your wallet>`;
|
|
69
|
+
case 'CloneGateNotTrustedAttestor':
|
|
70
|
+
return 'cloneFrom may only be submitted by a trusted attestor — use the attestor /clone flow, not a direct tx';
|
|
71
|
+
default:
|
|
72
|
+
return `the contract refused it: ${d.errorName}(${a.map(String).join(', ')})`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** An SDK error that carries an HTTP answer: `<what> failed: HTTP <status> <body>`. */
|
|
77
|
+
const HTTP_RE = /^([^\n]*?)(?: failed)?:?\s?HTTP (\d{3})\b:?\s*([\s\S]*)$/;
|
|
78
|
+
|
|
79
|
+
/** Names for the requests the CLI makes, as the owner thinks of them. */
|
|
80
|
+
const WHAT: Record<string, string> = {
|
|
81
|
+
'/start': 'start',
|
|
82
|
+
'/stop': 'stop',
|
|
83
|
+
'/reset': 'reset',
|
|
84
|
+
'/deploy': 'deploy',
|
|
85
|
+
'/clone': 'clone',
|
|
86
|
+
'/retry': 'retry',
|
|
87
|
+
'/settings': 'settings',
|
|
88
|
+
'/operator': 'operator',
|
|
89
|
+
'GET /releases': 'release notices',
|
|
90
|
+
'provider /api/balance': 'the sandbox provider',
|
|
91
|
+
'credentials.audit': 'the credential log',
|
|
92
|
+
'credentials.pending': 'pending requests',
|
|
93
|
+
'credentials.pendingCounts': 'pending requests',
|
|
94
|
+
'credentials.get': 'the credentials',
|
|
95
|
+
'credentials.connect': 'connect',
|
|
96
|
+
'credentials.loaded': 'the running agent',
|
|
97
|
+
'credentials.notifyAddress': 'the notification address',
|
|
98
|
+
'credentials.setNotifyAddress': 'the notification address',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/** What the server said, from a JSON error body or a short text one. */
|
|
102
|
+
function serverSays(body: string): { code?: string; text?: string } {
|
|
103
|
+
const raw = body.trim();
|
|
104
|
+
if (!raw) return {};
|
|
105
|
+
try {
|
|
106
|
+
const j = JSON.parse(raw) as { error?: unknown; code?: unknown; message?: unknown };
|
|
107
|
+
const err = j?.error;
|
|
108
|
+
const code = err && typeof err === 'object' ? (err as { code?: unknown }).code : j?.code;
|
|
109
|
+
const text = typeof err === 'string'
|
|
110
|
+
? err
|
|
111
|
+
: err && typeof err === 'object' && typeof (err as { message?: unknown }).message === 'string'
|
|
112
|
+
? (err as { message: string }).message
|
|
113
|
+
: typeof j?.message === 'string' ? j.message : undefined;
|
|
114
|
+
return { code: typeof code === 'string' ? code : undefined, text };
|
|
115
|
+
} catch {
|
|
116
|
+
// A web page (a proxy's error page) says nothing the owner can use.
|
|
117
|
+
return /^</.test(raw) ? {} : { text: raw };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** A server's sentence made readable: one line, wei as OG, no console/SDK asides. */
|
|
122
|
+
function tidy(text: string): string {
|
|
123
|
+
let t = text.split('\n').find((l) => l.trim())?.trim() ?? '';
|
|
124
|
+
t = t.replace(/\b(\d{7,}) wei\b/g, (_m, w: string) => `${ogAmount(BigInt(w))} OG`);
|
|
125
|
+
t = t.replace(/\s*\((?:[^()]*\b(?:console|SDK)\b[^()]*)\)/g, '');
|
|
126
|
+
t = t.replace(/\s+—\s+(?:deposit via|call) [^—]*$/, '');
|
|
127
|
+
return t.length > 200 ? `${t.slice(0, 199)}…` : t;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function httpPlain(status: number, what: string, body: string): Plain {
|
|
131
|
+
const { code, text } = serverSays(body);
|
|
132
|
+
if (code === 'insufficient_sandbox_balance') {
|
|
133
|
+
const wei = /(\d+) wei/.exec(text ?? '')?.[1];
|
|
134
|
+
return {
|
|
135
|
+
code: 'PREFLIGHT_BALANCE',
|
|
136
|
+
message: wei
|
|
137
|
+
? `the prepaid balance is ${ogAmount(BigInt(wei))} OG — an agent needs at least 0.1 OG to run`
|
|
138
|
+
: 'the prepaid balance is below the 0.1 OG an agent needs to run',
|
|
139
|
+
remedy: `${shellStep('deposit 0.1')}, then try again`,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (code === 'trust_roots_not_acked') {
|
|
143
|
+
return {
|
|
144
|
+
code: 'PREFLIGHT_ACK',
|
|
145
|
+
message: "this wallet has not acknowledged the attestor's trust root",
|
|
146
|
+
remedy: `${shellStep('ack')}, then try again`,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const name = WHAT[what.trim()] ?? (what.trim().replace(/^\//, '').replace(/^credentials\./, '') || 'the request');
|
|
150
|
+
const said = text ? tidy(text) : '';
|
|
151
|
+
if (status >= 500) {
|
|
152
|
+
return { message: `${name}: the server had an error (HTTP ${status})${said ? `: ${said}` : ''}`, remedy: 'try again in a minute' };
|
|
153
|
+
}
|
|
154
|
+
if (status === 404 && !said) return { message: `${name}: not offered here (HTTP 404)` };
|
|
155
|
+
if (status === 401 || status === 403) {
|
|
156
|
+
return { code: 'AUTH_REJECTED', message: `${name}: refused (HTTP ${status})${said ? `: ${said}` : ''}` };
|
|
157
|
+
}
|
|
158
|
+
return { message: `${name}: ${said || 'refused'} (HTTP ${status})` };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The structured answer an SDK error may carry (AttestorClient sets these). */
|
|
162
|
+
function httpFields(e: unknown): { status: number; what: string; body: string } | null {
|
|
163
|
+
const f = e as { httpStatus?: unknown; httpWhat?: unknown; httpBody?: unknown };
|
|
164
|
+
if (typeof f?.httpStatus === 'number') {
|
|
165
|
+
return { status: f.httpStatus, what: String(f.httpWhat ?? ''), body: String(f.httpBody ?? '') };
|
|
166
|
+
}
|
|
167
|
+
const msg = e instanceof Error ? e.message : typeof e === 'string' ? e : '';
|
|
168
|
+
const m = HTTP_RE.exec(msg);
|
|
169
|
+
return m ? { status: Number(m[2]), what: m[1], body: m[3] } : null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Any error as the owner reads it. A CliError is the CLI's own and already
|
|
174
|
+
* plain; a viem error becomes its one sentence; an SDK error carrying an HTTP
|
|
175
|
+
* answer becomes what the server said, in one line.
|
|
176
|
+
*/
|
|
177
|
+
export function explainError(e: unknown): Plain {
|
|
178
|
+
if (e instanceof CliError) return { message: e.message, remedy: e.remedy, code: e.code };
|
|
179
|
+
// viem's errors, found by name along the cause chain (viemErrors.ts: not by
|
|
180
|
+
// instanceof — viem ships separate ESM and CommonJS builds).
|
|
181
|
+
const short = (e as { shortMessage?: unknown } | null)?.shortMessage;
|
|
182
|
+
if (e instanceof Error && typeof short === 'string') {
|
|
183
|
+
const revert = revertText(e);
|
|
184
|
+
if (revert) return { message: revert };
|
|
185
|
+
if (findViemError(e, ['InsufficientFundsError'])) {
|
|
186
|
+
return {
|
|
187
|
+
code: 'PREFLIGHT_GAS',
|
|
188
|
+
message: 'the wallet does not hold enough OG for this and its gas',
|
|
189
|
+
remedy: `use a smaller amount, or fund the wallet (${shellTo('whoami', 'see its address')})`,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
const net = findViemError(e, ['HttpRequestError', 'TimeoutError', 'WebSocketRequestError']) as { url?: string } | null;
|
|
193
|
+
if (net) {
|
|
194
|
+
const url = net.url;
|
|
195
|
+
return {
|
|
196
|
+
code: 'RPC_UNREACHABLE',
|
|
197
|
+
message: `the chain did not answer${url ? ` (${url})` : ''}`,
|
|
198
|
+
remedy: 'check your network (or AGENTIC_RPC_URL), then try again',
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
const reverted = findViemError(e, ['ContractFunctionRevertedError']) as { reason?: string } | null;
|
|
202
|
+
if (reverted) return { message: `the contract refused it${reverted.reason ? `: ${reverted.reason}` : ''}` };
|
|
203
|
+
return { message: short.split('\n')[0] };
|
|
204
|
+
}
|
|
205
|
+
const http = httpFields(e);
|
|
206
|
+
if (http) return httpPlain(http.status, http.what, http.body);
|
|
207
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
208
|
+
if (/^fetch failed$/i.test(msg.trim())) return { message: 'a network request got no answer (fetch failed)', remedy: 'check your network, then try again' };
|
|
209
|
+
// An owner route of the agent while it is not running.
|
|
210
|
+
if (/the agent has no public URL yet/.test(msg)) {
|
|
211
|
+
return { code: 'AGENT_NOT_RUNNING', message: 'the agent is not running, and only the running agent can answer this', remedy: lifecycleTo('start', 'start it') };
|
|
212
|
+
}
|
|
213
|
+
// A deploy that stopped before the mint (the SDK's waitForMint).
|
|
214
|
+
const failed = /^waitForMint: seal (0x[0-9a-fA-F]{64}) failed — ([\s\S]*)$/.exec(msg);
|
|
215
|
+
if (failed) {
|
|
216
|
+
// A contract call's name ("registerWithSeal reverted: …") says nothing to the owner.
|
|
217
|
+
const why = (failed[2].split('\n')[0].trim() || 'no reason given').replace(/^[a-z][A-Za-z]+ reverted:?\s*/, 'the chain refused the mint: ');
|
|
218
|
+
return {
|
|
219
|
+
message: `the deploy stopped before the mint: ${why}`,
|
|
220
|
+
remedy: shellTo(`retry 0x${failed[1].slice(2, 12)}`, 'resume it under the same identity'),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const late = /^waitForMint: seal (0x[0-9a-fA-F]{64}) not minted within (\d+)ms/.exec(msg);
|
|
224
|
+
if (late) {
|
|
225
|
+
return {
|
|
226
|
+
code: 'TIMEOUT',
|
|
227
|
+
message: `agent 0x${late[1].slice(2, 12)} is not minted after ${Math.round(Number(late[2]) / 1000)} s`,
|
|
228
|
+
remedy: `${cmdStep('list')} shows when it is`,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
// The first line, without the SDK function a message starts with.
|
|
232
|
+
const first = msg.split('\n').find((l) => l.trim())?.trim() ?? msg;
|
|
233
|
+
return { message: first.replace(/^[a-z][A-Za-z]+(?:\.[a-z][A-Za-z]+)?: (?=\S)/, '') };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** The full text behind a plain error, for `--json`'s `details.cause`. */
|
|
237
|
+
export function causeOf(e: unknown): string | undefined {
|
|
238
|
+
if (e instanceof CliError) return undefined;
|
|
239
|
+
if (e instanceof Error) return e.message;
|
|
240
|
+
return e === undefined ? undefined : String(e);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Any thrown value as the CliError a one-shot command reports: the CLI's own
|
|
245
|
+
* unchanged; anything else plain, with its original text in `details.cause`.
|
|
246
|
+
*/
|
|
247
|
+
export function plainCliError(e: unknown): CliError {
|
|
248
|
+
if (e instanceof CliError) return e;
|
|
249
|
+
if (e instanceof Error && (e as Error & { code?: string }).code === 'provider_binding_unsupported') {
|
|
250
|
+
return new CliError('INFERENCE_PROVIDER_UNSUPPORTED', e.message, {
|
|
251
|
+
remedy: 'ask the attestor operator to enable provider-bound credentials for this runtime image, then retry',
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
const p = explainError(e);
|
|
255
|
+
const cause = causeOf(e);
|
|
256
|
+
return new CliError(p.code ?? 'UNKNOWN', p.message, {
|
|
257
|
+
remedy: p.remedy,
|
|
258
|
+
...(cause && cause !== p.message ? { details: { cause } } : {}),
|
|
259
|
+
});
|
|
260
|
+
}
|
package/src/cli/proofs.ts
CHANGED
|
@@ -32,6 +32,13 @@ export interface SavedProof {
|
|
|
32
32
|
taskHash: `0x${string}`; dataHashes: `0x${string}`[]; frameworkHash: `0x${string}`;
|
|
33
33
|
signature: `0x${string}`;
|
|
34
34
|
validator?: `0x${string}`; // envelope diagnostics: lets `rate` tell a registry mismatch from a bad ticket
|
|
35
|
+
// v2 (LEGACY(v1): absent on a v1 ticket): the version picks the digest
|
|
36
|
+
// and the registry entry point, so a ticket keeps all of it.
|
|
37
|
+
version?: number;
|
|
38
|
+
sealedHash?: `0x${string}`;
|
|
39
|
+
harnessHash?: `0x${string}`;
|
|
40
|
+
inferenceURL?: string;
|
|
41
|
+
model?: string;
|
|
35
42
|
};
|
|
36
43
|
task: TaskReveal;
|
|
37
44
|
}
|
|
@@ -80,6 +87,16 @@ export function saveProof(proof: ServeProof, task: TaskReveal, endpoint: string)
|
|
|
80
87
|
frameworkHash: proof.frameworkHash,
|
|
81
88
|
signature: proof.signature,
|
|
82
89
|
...(proof.validator ? { validator: proof.validator } : {}),
|
|
90
|
+
// LEGACY(v1): a proof without a version keeps no layers.
|
|
91
|
+
...(proof.version === undefined
|
|
92
|
+
? {}
|
|
93
|
+
: {
|
|
94
|
+
version: proof.version,
|
|
95
|
+
sealedHash: proof.sealedHash,
|
|
96
|
+
harnessHash: proof.harnessHash,
|
|
97
|
+
inferenceURL: proof.inferenceURL,
|
|
98
|
+
model: proof.model,
|
|
99
|
+
}),
|
|
83
100
|
},
|
|
84
101
|
task,
|
|
85
102
|
};
|
|
@@ -156,5 +173,15 @@ export function toServeProof(e: SavedProof): ServeProof {
|
|
|
156
173
|
frameworkHash: e.proof.frameworkHash,
|
|
157
174
|
signature: e.proof.signature,
|
|
158
175
|
...(e.proof.validator ? { validator: e.proof.validator } : {}),
|
|
176
|
+
// LEGACY(v1): a v1 ticket has no layers.
|
|
177
|
+
...(e.proof.version === undefined
|
|
178
|
+
? {}
|
|
179
|
+
: {
|
|
180
|
+
version: e.proof.version,
|
|
181
|
+
sealedHash: e.proof.sealedHash,
|
|
182
|
+
harnessHash: e.proof.harnessHash,
|
|
183
|
+
inferenceURL: e.proof.inferenceURL,
|
|
184
|
+
model: e.proof.model,
|
|
185
|
+
}),
|
|
159
186
|
};
|
|
160
187
|
}
|
package/src/cli/ref.ts
CHANGED
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
* only classifies the input, so it is trivially unit-testable.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { CliError } from './errors';
|
|
15
|
+
import { CliError, cmdStep } from './errors';
|
|
16
|
+
import { cleanCell } from './commands/cells';
|
|
16
17
|
|
|
17
18
|
/** A classified agent reference. */
|
|
18
19
|
export type AgentRef =
|
|
@@ -42,9 +43,9 @@ export function parseAgentRef(input: string | undefined): AgentRef {
|
|
|
42
43
|
throw new CliError(
|
|
43
44
|
'BAD_AGENT_REF',
|
|
44
45
|
input
|
|
45
|
-
? `not an agent reference: "${input}"
|
|
46
|
-
: 'missing <agent
|
|
47
|
-
{ remedy: '
|
|
46
|
+
? `not an agent reference: "${cleanCell(input)}" — an agent is named by its agentId (33) or its sealId (0x…, 8 or more hex digits)`
|
|
47
|
+
: 'missing <agent>: an agentId (33) or a sealId (0x…, 8 or more hex digits)',
|
|
48
|
+
{ remedy: `${cmdStep('list')} shows the agents and their ids` },
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
|