cascrow-sdk 0.2.0 → 0.4.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/CHANGELOG.md +10 -0
- package/README.md +26 -9
- package/dist/client.d.ts +266 -23
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +587 -57
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +142 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.4.0 — 2026-09-25
|
|
4
|
+
|
|
5
|
+
- `waitForProof(proofId, { timeoutMs, intervalMs })` — wait for a proof already submitted. Upload starts verification by itself, so this, not `verify()`, is the call after `submitProof`. Stops by throwing on 401 / 403 / 404 (waiting does not change them), returns `{ pending: true, interrupted: true }` when the run died, and honours `Retry-After` on 429 / 503.
|
|
6
|
+
- `watchVerification` is `submitProof` + `waitForProof`, with the same stop rules (it used to swallow every error and poll out its full timeout).
|
|
7
|
+
- Errors carry `.code` (the API's stable code, or `UPSTREAM_NON_JSON` for a non-JSON answer such as a platform error page) and `.retryAfterSeconds`; a 409 `VERIFICATION_IN_PROGRESS` also carries `.phase`, `.watchUrl` and `.expectedDoneInSeconds`.
|
|
8
|
+
- `submitProof` has a deadline (120 s); before, a stalled upload never returned.
|
|
9
|
+
- `MilestoneInput` takes `verificationCriteria` and `verificationChecklist` — the bar the AI panel judges against — normalised client-side (a bad item is refused with its index before any request).
|
|
10
|
+
- `getProofStatus` types `claimPhase` and `expectedDoneInSeconds`.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# cascrow-sdk
|
|
2
2
|
|
|
3
|
-
TypeScript client for [Cascrow](https://cascrow.com) —
|
|
3
|
+
TypeScript client for [Cascrow](https://cascrow.com) — trust infrastructure for the agent economy: AI verification, on-chain reputation, and milestone escrow on the XRP Ledger.
|
|
4
4
|
|
|
5
5
|
For AI agents connecting through Claude, Cursor, or Codex, use [`cascrow-mcp`](https://www.npmjs.com/package/cascrow-mcp) instead — it's the same API, exposed as MCP tools. This package is for plain application code (backends, scripts, other platforms) that want to call Cascrow directly without going through an LLM tool call.
|
|
6
6
|
|
|
@@ -18,7 +18,17 @@ import { CascrowClient } from "cascrow-sdk";
|
|
|
18
18
|
const client = new CascrowClient({ apiKey: "csk_..." });
|
|
19
19
|
|
|
20
20
|
const { contractId, inviteLink } = await client.createContract({
|
|
21
|
-
milestones: [
|
|
21
|
+
milestones: [
|
|
22
|
+
{
|
|
23
|
+
title: "Ship the landing page", // printed on the certificate — keep it short
|
|
24
|
+
amountUSD: 500,
|
|
25
|
+
daysUntilDeadline: 7,
|
|
26
|
+
// The bar the AI panel judges the proof against:
|
|
27
|
+
verificationCriteria: "Responsive down to 320px, LCP under 2 s on mobile, CTA links to /signup",
|
|
28
|
+
verificationChecklist: [{ title: "Mobile layout", severity: "HIGH" }, { title: "Signup CTA" }],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
agentReviewMode: "MANUAL", // what happens when the panel is unsure (60–85 % confidence)
|
|
22
32
|
});
|
|
23
33
|
|
|
24
34
|
console.log(`Contract created: ${contractId}, invite: ${inviteLink}`);
|
|
@@ -47,6 +57,8 @@ console.log(result.decision, result.confidence, result.reportUrl);
|
|
|
47
57
|
|
|
48
58
|
Verification is rate-limited to 3 per IP per 24h. Passing an `apiKey` attributes each result to your account (so it shows up in your usage) but does not currently raise that allowance — account-based verification credits are not yet purchasable.
|
|
49
59
|
|
|
60
|
+
Passing an `apiKey` also anchors the verdict on the XRP Ledger mainnet — a content-free commitment hash written into an on-chain memo, independently recomputable from the report (see `GET /api/verify/result/{hash}` in the [API reference](https://cascrow.com/api-docs)). Anonymous calls are never anchored. `result.id`, `result.reportUrl`, and the anchor fields you'd poll for (`anchorHash`, `xrplTxHash`, `anchoredAt`) live at that report URL, not in the `verifyWork()` response — anchoring happens asynchronously after the call returns.
|
|
61
|
+
|
|
50
62
|
## Agent-to-agent flow
|
|
51
63
|
|
|
52
64
|
```ts
|
|
@@ -56,14 +68,15 @@ const builder = new CascrowClient({ apiKey: builderKey });
|
|
|
56
68
|
const { contractId, inviteLink } = await requester.createContract({
|
|
57
69
|
milestones: [{ title: "Build the API", amountUSD: 1000 }],
|
|
58
70
|
});
|
|
59
|
-
await requester.escrowFund({ contractId, agentPrivateKey: requesterEvmKey
|
|
71
|
+
await requester.escrowFund({ contractId, agentPrivateKey: requesterEvmKey }); // escrows the milestone's own amountUSD; testnet MockRLUSD, not real funds — see Sandbox above
|
|
60
72
|
|
|
61
73
|
await builder.joinContract(inviteLink!);
|
|
62
74
|
const { proofId } = await builder.submitProof({ milestoneId, content: "Done — see PR #12, all tests pass." });
|
|
63
|
-
|
|
75
|
+
// Upload starts verification by itself — wait for it, don't start it again.
|
|
76
|
+
const result = await builder.waitForProof(proofId);
|
|
64
77
|
|
|
65
|
-
if (result.
|
|
66
|
-
console.log("Funds released automatically
|
|
78
|
+
if (!result.pending && result.milestoneStatus === "COMPLETED") {
|
|
79
|
+
console.log("Funds released automatically.");
|
|
67
80
|
}
|
|
68
81
|
```
|
|
69
82
|
|
|
@@ -79,14 +92,16 @@ if (result.action === "VERIFIED") {
|
|
|
79
92
|
| `getContract` | `GET /api/contracts/{id}` |
|
|
80
93
|
| `listMyContracts` | `GET /api/agent/my-contracts` |
|
|
81
94
|
| `joinContract` | `POST /api/contracts/join` |
|
|
82
|
-
| `reviewContract` | `POST /api/contracts/review` |
|
|
95
|
+
| `reviewContract` | `POST /api/contracts/review` — pass `milestoneId` when more than one milestone is pending review |
|
|
96
|
+
| `reviewQueue` | `GET /api/agent/review-queue` — the contracts on which you, as funder, still owe a verdict. The pull behind the `manual_review.required` webhook: an undecided milestone auto-approves after 48 h and releases the escrow |
|
|
83
97
|
| `checkInvites` | `GET /api/agent/pending-invites` |
|
|
84
98
|
| `handoff` | `POST /api/agent/handoff` |
|
|
85
99
|
| `fundMilestone` | `POST /api/agent/fund-milestone` |
|
|
86
100
|
| `escrowFund` | `POST /api/agent/escrow-fund` |
|
|
87
101
|
| `submitProof` | `POST /api/proof/upload` |
|
|
88
102
|
| `getProofStatus` | `GET /api/agent/proof-status/{proofId}` |
|
|
89
|
-
| `
|
|
103
|
+
| `waitForProof` | poll `getProofStatus` until the proof settles — the call to make after `submitProof` |
|
|
104
|
+
| `verify` | `POST /api/verify` (streamed) — start or re-run a verification by hand |
|
|
90
105
|
| `mcpSubmit` | `POST /api/mcp/submit` |
|
|
91
106
|
| `verifyWork` | `POST /api/verify/standalone` |
|
|
92
107
|
| `watchVerification` | `submitProof` + poll |
|
|
@@ -96,7 +111,9 @@ if (result.action === "VERIFIED") {
|
|
|
96
111
|
|
|
97
112
|
## Errors
|
|
98
113
|
|
|
99
|
-
Failed requests throw an `Error` with `.status` (HTTP status code)
|
|
114
|
+
Failed requests throw an `Error` with `.status` (HTTP status code), `.body` (parsed JSON error response), `.code` (the stable error code — branch on this, not on the message; `UPSTREAM_NON_JSON` when the server answered with something that is not JSON) and `.retryAfterSeconds` (how long the server asked you to wait) attached.
|
|
115
|
+
|
|
116
|
+
`verify(proofId)` on a proof whose verification is already running (usually the one upload started) throws `code: "VERIFICATION_IN_PROGRESS"` with `phase: "running"` — call `waitForProof(proofId)`. Its `retryAfterSeconds` is when an abandoned run could be taken over (about an hour), not a backoff.
|
|
100
117
|
|
|
101
118
|
```ts
|
|
102
119
|
try {
|
package/dist/client.d.ts
CHANGED
|
@@ -1,20 +1,65 @@
|
|
|
1
|
-
import type { Contract, CreateContractInput, CreateContractResult, DiscoverAgentsResult, MyContractSummary, RegisterInput, RegisterResult, ReputationResult, VerificationResult, VerifyWorkInput, VerifyWorkResult } from "./types.js";
|
|
1
|
+
import type { Contract, CreateContractInput, CreateContractResult, DiscoverAgentsResult, MyContractSummary, ReviewQueueResult, RegisterInput, RegisterResult, ReputationResult, VerificationResult, VerifyWorkInput, VerifyWorkResult } from "./types.js";
|
|
2
2
|
export interface CascrowClientOptions {
|
|
3
3
|
/** API key starting with csk_. Omit only for endpoints that support anonymous use (register, getReputation, verifyWork). */
|
|
4
4
|
apiKey?: string;
|
|
5
5
|
/** Override the API base URL. Defaults to https://cascrow.com. */
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
/** What `watchVerification` and `waitForProof` resolve to. */
|
|
9
|
+
export type WatchResult = {
|
|
10
|
+
pending: false;
|
|
11
|
+
/** The verdict on this proof, or `null` when the route reported none. */
|
|
12
|
+
decision: "YES" | "NO" | null;
|
|
13
|
+
confidence: number | null;
|
|
14
|
+
/** `"COMPLETED"` means the funds were released. */
|
|
15
|
+
milestoneStatus?: string;
|
|
16
|
+
/** Set when the payout is only SCHEDULED — no funds have moved. */
|
|
17
|
+
releaseHoldUntil?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* The milestone is TERMINAL (`terminalStatus`: EXPIRED or COMPLETED) and this
|
|
20
|
+
* proof's verdict cannot move it. Read this BEFORE `decision`.
|
|
21
|
+
*/
|
|
22
|
+
milestoneClosed: boolean;
|
|
23
|
+
terminalStatus: string | null;
|
|
24
|
+
/** See `getProofStatus` — `"RELEASED_ON_CHAIN"` means the builder WAS paid on-chain. */
|
|
25
|
+
terminalReason: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The milestone is VERIFIED or COMPLETED, but not on a YES from this proof —
|
|
28
|
+
* another proof won it, or the funder approved it in review. `decision` is
|
|
29
|
+
* this proof's `"NO"` or `null`; the payout, if any, is not this proof's.
|
|
30
|
+
*/
|
|
31
|
+
approvedWithoutThisVerdict: boolean;
|
|
32
|
+
reasoning?: string;
|
|
33
|
+
} | {
|
|
34
|
+
pending: true;
|
|
35
|
+
proofId: string;
|
|
36
|
+
/**
|
|
37
|
+
* Set when the panel produced no verdict and the milestone is at
|
|
38
|
+
* `PENDING_REVIEW`: a human decides, and polling will not change that.
|
|
39
|
+
*/
|
|
40
|
+
awaitingHumanReview?: true;
|
|
41
|
+
/** The run that held this proof died; nothing is running. Submitting the proof again always works; `verify()` can restart it once its claim is an hour old. */
|
|
42
|
+
interrupted?: true;
|
|
43
|
+
};
|
|
13
44
|
export declare class CascrowClient {
|
|
14
45
|
private readonly apiKey?;
|
|
15
46
|
private readonly baseUrl;
|
|
16
47
|
constructor(options?: CascrowClientOptions);
|
|
17
48
|
private authHeaders;
|
|
49
|
+
/**
|
|
50
|
+
* Every non-streaming call carries a deadline (SEC-073).
|
|
51
|
+
*
|
|
52
|
+
* Before this, the only `AbortController` in the SDK was inside `verify()`, the
|
|
53
|
+
* streaming method — so `verifyWork()`, which waits on a route the platform
|
|
54
|
+
* kills at 120 s, waited forever and then surfaced a torn connection. The
|
|
55
|
+
* default is the longest cap any route in this API declares (240 s), so it
|
|
56
|
+
* cannot cut a legitimately slow on-chain call short; `verifyWork` passes the
|
|
57
|
+
* tighter one because its own route is capped lower.
|
|
58
|
+
*
|
|
59
|
+
* An `AbortError` is re-thrown as a sentence, not as the DOM error: a caller
|
|
60
|
+
* cannot tell "we stopped waiting" from "the panel said no" out of an
|
|
61
|
+
* exception whose message is "This operation was aborted" (F-72).
|
|
62
|
+
*/
|
|
18
63
|
private request;
|
|
19
64
|
/** Self-register an agent account. No CAPTCHA, no email verification. Returns an API key — save it, it is shown only once. */
|
|
20
65
|
register(input: RegisterInput): Promise<RegisterResult>;
|
|
@@ -37,11 +82,52 @@ export declare class CascrowClient {
|
|
|
37
82
|
joinContract(inviteCode: string): Promise<{
|
|
38
83
|
contractId: string;
|
|
39
84
|
}>;
|
|
40
|
-
/**
|
|
41
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Approve or reject a borderline (PENDING_REVIEW) MILESTONE. Only valid when
|
|
87
|
+
* agentReviewMode is MANUAL or MANUAL_AUTO.
|
|
88
|
+
*
|
|
89
|
+
* The CONTRACT row need not be PENDING_REVIEW: funding a later milestone
|
|
90
|
+
* overwrites that column, and such a contract is still reviewable. Only a
|
|
91
|
+
* terminal contract (COMPLETED, EXPIRED, DECLINED) is refused.
|
|
92
|
+
*
|
|
93
|
+
* `milestoneId` is optional while exactly one milestone of the contract is
|
|
94
|
+
* pending review and REQUIRED once more than one is — the API answers 400
|
|
95
|
+
* "Multiple milestones are pending review — specify milestoneId to
|
|
96
|
+
* disambiguate". Until this parameter existed an SDK caller had no way to
|
|
97
|
+
* comply with that refusal, which is exactly the case SEC-076 is about: a
|
|
98
|
+
* multi-milestone contract where a second proof lands while the first is
|
|
99
|
+
* still under review (SEC-120, F-72).
|
|
100
|
+
*
|
|
101
|
+
* Additive optional third argument — every existing call site still compiles.
|
|
102
|
+
*/
|
|
103
|
+
reviewContract(contractId: string, decision: "APPROVE" | "REJECT", milestoneId?: string): Promise<{
|
|
42
104
|
status: string;
|
|
43
105
|
txHash: string | null;
|
|
44
106
|
}>;
|
|
107
|
+
/**
|
|
108
|
+
* The contracts on which THIS agent, as funder, still owes a manual verdict.
|
|
109
|
+
*
|
|
110
|
+
* The pull behind the `manual_review.required` webhook. A webhook that does
|
|
111
|
+
* not arrive — the agent was down, the endpoint 500'd, the subscription was
|
|
112
|
+
* never made — is a decision that never gets made, and `cron/cancel-expired`
|
|
113
|
+
* then auto-approves the milestone after 48 h (agent contracts) or 14 days
|
|
114
|
+
* (human) and releases the escrow. The whole point of the 60–85 confidence
|
|
115
|
+
* band is that somebody looks.
|
|
116
|
+
*
|
|
117
|
+
* Every browser surface the funder has for this asks
|
|
118
|
+
* `funderReviewQueueWhere()`; so does this route, so the queue an agent polls
|
|
119
|
+
* and the queue `reviewContract` accepts a verdict on cannot come apart.
|
|
120
|
+
*
|
|
121
|
+
* `reviewMilestoneId` is what to pass to {@link reviewContract}: non-null when
|
|
122
|
+
* exactly one milestone of that contract is pending, `null` for the legacy
|
|
123
|
+
* contract-level population that is reviewed by `contractId` alone. When
|
|
124
|
+
* `pendingMilestones` holds more than one entry the milestone has to be chosen
|
|
125
|
+
* — `POST /api/contracts/review` answers 400 otherwise.
|
|
126
|
+
*
|
|
127
|
+
* `truncated` says the list is capped while `total` is not, so a poller does
|
|
128
|
+
* not read a short list as "that was all".
|
|
129
|
+
*/
|
|
130
|
+
reviewQueue(): Promise<ReviewQueueResult>;
|
|
45
131
|
/** Check for pending contract invites sent to this agent. */
|
|
46
132
|
checkInvites(): Promise<{
|
|
47
133
|
invites: unknown[];
|
|
@@ -61,11 +147,32 @@ export declare class CascrowClient {
|
|
|
61
147
|
contractId: string;
|
|
62
148
|
status: string;
|
|
63
149
|
}>;
|
|
64
|
-
/**
|
|
150
|
+
/**
|
|
151
|
+
* Fund a milestone with real on-chain RLUSD escrow using the agent's own EVM
|
|
152
|
+
* private key.
|
|
153
|
+
*
|
|
154
|
+
* **The escrowed amount is the milestone's own `amountUSD`.** The route
|
|
155
|
+
* destructures `{ contractId, milestoneId, agentPrivateKey }` and funds
|
|
156
|
+
* `milestone.amountUSD`; a body `amountUSD` has never been read.
|
|
157
|
+
*
|
|
158
|
+
* SEC-120 removed the parameter from both MCP tool schemas, the OpenAPI spec
|
|
159
|
+
* and the CLI — and stopped here, at the one surface where the demand was
|
|
160
|
+
* enforced by the COMPILER rather than merely written down: `amountUSD:
|
|
161
|
+
* number`, no `?`, and `input` forwarded whole. That is the same defect the
|
|
162
|
+
* removal was about, at the door that states it most strongly, and it
|
|
163
|
+
* survived because the correction was checked against the places that
|
|
164
|
+
* document the parameter rather than against the places that require it.
|
|
165
|
+
*
|
|
166
|
+
* It is deprecated rather than deleted: deleting it would break compilation
|
|
167
|
+
* for every existing caller, which is a worse answer than telling them the
|
|
168
|
+
* truth. It is no longer forwarded, so the request body now says what the
|
|
169
|
+
* server actually reads.
|
|
170
|
+
*/
|
|
65
171
|
escrowFund(input: {
|
|
66
172
|
contractId: string;
|
|
67
173
|
agentPrivateKey: string;
|
|
68
|
-
amountUSD
|
|
174
|
+
/** @deprecated Ignored. The escrowed amount is the milestone's own `amountUSD`. */
|
|
175
|
+
amountUSD?: number;
|
|
69
176
|
milestoneId?: string;
|
|
70
177
|
}): Promise<{
|
|
71
178
|
milestoneId: string;
|
|
@@ -74,7 +181,11 @@ export declare class CascrowClient {
|
|
|
74
181
|
amountUSD: number;
|
|
75
182
|
status: string;
|
|
76
183
|
}>;
|
|
77
|
-
/**
|
|
184
|
+
/**
|
|
185
|
+
* Submit a text proof report for a milestone. Verification starts by itself —
|
|
186
|
+
* wait for the verdict with `waitForProof(proofId)`; do not call `verify()` for it,
|
|
187
|
+
* that run is already going.
|
|
188
|
+
*/
|
|
78
189
|
submitProof(input: {
|
|
79
190
|
milestoneId: string;
|
|
80
191
|
content: string;
|
|
@@ -85,11 +196,57 @@ export declare class CascrowClient {
|
|
|
85
196
|
/** Check the AI verification result for a submitted proof (poll after submitProof). */
|
|
86
197
|
getProofStatus(proofId: string): Promise<{
|
|
87
198
|
pending?: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* `true` while the verification panel is running on this proof right now. A running
|
|
201
|
+
* proof is never final, whatever `milestoneStatus` says: a `PENDING_REVIEW` a sibling
|
|
202
|
+
* proof set, or a `VERIFIED` that a failed release or a review hands back, can still
|
|
203
|
+
* be decided by it. `pending` without `running` is the other cause: not claimed yet,
|
|
204
|
+
* or a panel that produced no verdict. Absent on a server that predates the field.
|
|
205
|
+
*/
|
|
206
|
+
running?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* `"running"` — a live run holds the proof (wait for it); `"orphaned"` — the run
|
|
209
|
+
* died, nothing is running; `"unclaimed"` / `"decided"`. Absent on an older server.
|
|
210
|
+
*/
|
|
211
|
+
claimPhase?: "unclaimed" | "running" | "orphaned" | "decided";
|
|
212
|
+
/** While `claimPhase` is `"running"`: roughly when the verdict is due. */
|
|
213
|
+
expectedDoneInSeconds?: number;
|
|
214
|
+
/** The verdict on THIS PROOF. It does not say whether the money moved. */
|
|
88
215
|
decision?: "YES" | "NO";
|
|
89
216
|
confidence?: number | null;
|
|
90
217
|
contractStatus?: string;
|
|
91
218
|
milestoneTitle?: string;
|
|
219
|
+
/**
|
|
220
|
+
* The MILESTONE's state, which is the question most callers are actually asking.
|
|
221
|
+
* `"COMPLETED"` means the funds were released.
|
|
222
|
+
*/
|
|
92
223
|
milestoneStatus?: string;
|
|
224
|
+
/**
|
|
225
|
+
* SEC-058. Set when the payout is SCHEDULED rather than done: the milestone is at
|
|
226
|
+
* `VERIFIED`, the funds are still in escrow, the funder can contest until this
|
|
227
|
+
* instant, and the instant itself can move. The route has returned it since
|
|
228
|
+
* 2026-09-12; a TypeScript caller could not read it without a cast, so
|
|
229
|
+
* `milestoneStatus: "VERIFIED"` looked like a completed payout.
|
|
230
|
+
*/
|
|
231
|
+
releaseHoldUntil?: string | null;
|
|
232
|
+
/**
|
|
233
|
+
* `true` when the milestone (or, for a legacy contract-level proof, the contract)
|
|
234
|
+
* is TERMINAL — `EXPIRED` or `COMPLETED` — so no verdict on this proof can move it
|
|
235
|
+
* any more. Check it BEFORE `decision` and `pending`: a milestone the funder
|
|
236
|
+
* cancelled, or the deadline cron closed, while the panel ran stays `EXPIRED` with
|
|
237
|
+
* this proof's `decision` still recorded (YES or NO) — or with `pending: true` for
|
|
238
|
+
* good, when the panel could not reach a verdict. A YES here moved no funds.
|
|
239
|
+
*/
|
|
240
|
+
milestoneClosed?: boolean;
|
|
241
|
+
/** `"EXPIRED"` or `"COMPLETED"` when `milestoneClosed`, else null. */
|
|
242
|
+
terminalStatus?: string | null;
|
|
243
|
+
/**
|
|
244
|
+
* Why an `EXPIRED` milestone ended, when recorded. `"RELEASED_ON_CHAIN"` means the
|
|
245
|
+
* chain shows the builder WAS paid — just not by this verification; the other
|
|
246
|
+
* values (`DEADLINE_EXPIRED`, `CANCELLED_AFTER_APPROVAL`, …) mean the funder was
|
|
247
|
+
* refunded or no escrow existed. Null when not recorded.
|
|
248
|
+
*/
|
|
249
|
+
terminalReason?: string | null;
|
|
93
250
|
reasoning?: string;
|
|
94
251
|
}>;
|
|
95
252
|
/**
|
|
@@ -120,11 +277,38 @@ export declare class CascrowClient {
|
|
|
120
277
|
customFields?: Record<string, unknown>;
|
|
121
278
|
};
|
|
122
279
|
}): Promise<{
|
|
123
|
-
|
|
124
|
-
|
|
280
|
+
/**
|
|
281
|
+
* SEC-059's shape at a fourth consumer, found by deriving the set of readers from
|
|
282
|
+
* what the route SENDS rather than from the two MCP servers a finding compared.
|
|
283
|
+
*
|
|
284
|
+
* The route has two 200 responses that carry NO `verdict` key at all, and this
|
|
285
|
+
* union claimed three values:
|
|
286
|
+
*
|
|
287
|
+
* - `decided_elsewhere` — the milestone was settled by a concurrent request or by
|
|
288
|
+
* the investor's review while this proof was being verified. The route answers
|
|
289
|
+
* `{ ok: true, decided: "elsewhere" }`; `verdict` was simply `undefined` here,
|
|
290
|
+
* outside its own declared type, and a consumer treating it as falsy read it as
|
|
291
|
+
* a rejection.
|
|
292
|
+
* - `panel_unavailable` — fewer than three of the five models answered. OUR
|
|
293
|
+
* outage, not a judgement of the work, and resubmitting will not help.
|
|
294
|
+
*
|
|
295
|
+
* `releaseHoldUntil` is the other half: an `approved` verdict with a hold means
|
|
296
|
+
* APPROVED and NOT PAID — the funder can contest until then, and the date can move.
|
|
297
|
+
*/
|
|
298
|
+
verdict: "approved" | "rejected" | "pending_review" | "decided_elsewhere" | "panel_unavailable";
|
|
299
|
+
confidence: number | null;
|
|
125
300
|
reasoning: string;
|
|
126
301
|
onChainUrl: string | null;
|
|
127
302
|
proofId: string | null;
|
|
303
|
+
/** Set when `verdict` is `approved` but the payout is scheduled rather than done. */
|
|
304
|
+
releaseHoldUntil: string | null;
|
|
305
|
+
/**
|
|
306
|
+
* With `decided_elsewhere`: the TERMINAL status the milestone was already in
|
|
307
|
+
* (`"EXPIRED"`, `"COMPLETED"`) — it was closed before this submission could settle
|
|
308
|
+
* it, e.g. by the funder's cancel or the deadline, and resubmitting is pointless.
|
|
309
|
+
* Null when it was decided by the investor's review or a concurrent submission.
|
|
310
|
+
*/
|
|
311
|
+
settledAs: string | null;
|
|
128
312
|
}>;
|
|
129
313
|
/**
|
|
130
314
|
* Verify AI-generated work with no escrow contract — a task description
|
|
@@ -134,25 +318,84 @@ export declare class CascrowClient {
|
|
|
134
318
|
* yet, so do not treat a key as a way to get more runs.
|
|
135
319
|
*/
|
|
136
320
|
verifyWork(input: VerifyWorkInput): Promise<VerifyWorkResult>;
|
|
321
|
+
/**
|
|
322
|
+
* True when a thrown `CascrowApiError` means "cascrow could not run the panel",
|
|
323
|
+
* not "the work was not verified" (SEC-128).
|
|
324
|
+
*
|
|
325
|
+
* `verifyWork` resolves ONLY when a verdict exists. When fewer than three of the
|
|
326
|
+
* five models answer, the endpoint answers 503 with `panelUnavailable: true` and
|
|
327
|
+
* carries NO decision and NO confidence, so `request` throws — deliberately, and
|
|
328
|
+
* that is the whole repair: the previous behaviour was a 200 carrying
|
|
329
|
+
* `decision: "NO", confidence: 65`, which every consumer rendered as a rejection
|
|
330
|
+
* of the submitted work. An outage is not a verdict, and a retry is the right
|
|
331
|
+
* next move rather than a resubmission with "stronger" evidence.
|
|
332
|
+
*
|
|
333
|
+
* A thrown 500 from the same endpoint is NOT this: it reports `false` here,
|
|
334
|
+
* because "the models did not answer" is a claim about the panel and a crash is
|
|
335
|
+
* not evidence for it.
|
|
336
|
+
*/
|
|
337
|
+
static isPanelUnavailable(err: unknown): boolean;
|
|
137
338
|
/**
|
|
138
339
|
* Submit a proof and wait for AI verification to complete — combines
|
|
139
340
|
* submitProof + polling into a single call. Times out after ~100s and
|
|
140
341
|
* returns { pending: true, proofId } so you can poll manually.
|
|
342
|
+
*
|
|
343
|
+
* Returns early, with `milestoneClosed: true`, when the milestone is already
|
|
344
|
+
* terminal — including when no verdict was recorded, which on a closed milestone
|
|
345
|
+
* will never change. Check `milestoneClosed` before `decision`: a `"YES"` on a
|
|
346
|
+
* closed, `EXPIRED` milestone is the panel's opinion of the proof and moved no funds.
|
|
347
|
+
*
|
|
348
|
+
* Also returns early, with `approvedWithoutThisVerdict: true`, when the milestone is
|
|
349
|
+
* VERIFIED or COMPLETED without a YES from this proof (another proof won it, or the
|
|
350
|
+
* funder approved it in review): `decision` is then `"NO"` or `null`, and the
|
|
351
|
+
* milestone's outcome is NOT this proof's.
|
|
352
|
+
*
|
|
353
|
+
* A proof parked for a human (no verdict, milestone at `PENDING_REVIEW`) returns
|
|
354
|
+
* `{ pending: true, proofId, awaitingHumanReview: true }` on the first poll instead of
|
|
355
|
+
* after the full timeout: no poll will change it, the funder decides.
|
|
356
|
+
*
|
|
357
|
+
* Neither early return is taken while the server reports `running: true` on a
|
|
358
|
+
* VERIFIED or PENDING_REVIEW milestone: this proof's panel is still running and can
|
|
359
|
+
* still decide the row, so the loop keeps polling. A server that predates `running`
|
|
360
|
+
* cannot say so, and there the early returns stay as described.
|
|
141
361
|
*/
|
|
142
362
|
watchVerification(input: {
|
|
143
363
|
milestoneId: string;
|
|
144
364
|
content: string;
|
|
145
365
|
filename?: string;
|
|
146
|
-
}): Promise<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
366
|
+
}): Promise<WatchResult>;
|
|
367
|
+
/**
|
|
368
|
+
* Wait for the verification of a proof that is already submitted — the call to
|
|
369
|
+
* make after `submitProof`, and after `verify()` threw a 409 VERIFICATION_IN_PROGRESS
|
|
370
|
+
* with `phase: "running"` (T01-7). Same results as `watchVerification`, which is
|
|
371
|
+
* this plus the upload.
|
|
372
|
+
*
|
|
373
|
+
* Stops early, by throwing, when waiting cannot help: 401 / 403 (the key or the
|
|
374
|
+
* account does not change by waiting) and 404 (permanent — upload answers only
|
|
375
|
+
* after the proof exists and proof-status reads the primary database, so a 404
|
|
376
|
+
* means deleted or erased). Returns `{ pending: true, interrupted: true }` when the
|
|
377
|
+
* run that held the proof died (`claimPhase: "orphaned"`). On 429 / 503 it waits at
|
|
378
|
+
* least the server's Retry-After, never past `timeoutMs`; network errors and other
|
|
379
|
+
* 5xx are transient and it polls again.
|
|
380
|
+
*/
|
|
381
|
+
waitForProof(proofId: string, options?: {
|
|
382
|
+
timeoutMs?: number;
|
|
383
|
+
intervalMs?: number;
|
|
384
|
+
}): Promise<WatchResult>;
|
|
385
|
+
/**
|
|
386
|
+
* Look up any agent's on-chain reputation by EVM wallet address. No auth required.
|
|
387
|
+
*
|
|
388
|
+
* `summary` reaches you RAW, and so do `name` and `skills` from `discoverAgents`
|
|
389
|
+
* below. The route deliberately does not mark them (the browser profile page renders
|
|
390
|
+
* the same fields) and both MCP servers do mark them — so this SDK is a machine
|
|
391
|
+
* boundary that does not, exactly like `verify()`.
|
|
392
|
+
*
|
|
393
|
+
* The DECISION is the same and so is its reason: a library cannot know whether its
|
|
394
|
+
* return value ends in a model's context or on a page, where a marker is noise.
|
|
395
|
+
* What was missing here was the REASON, stated at `verify()` and nowhere
|
|
396
|
+
* else, which made this door look like an oversight rather than a choice (SEC-120).
|
|
397
|
+
* If you feed these fields to a model, treat them as data and not as instructions.
|
|
398
|
+
*/
|
|
156
399
|
getReputation(walletAddress: string): Promise<ReputationResult>;
|
|
157
400
|
/** Search for discoverable Builder agents by skill tag and minimum success rate. */
|
|
158
401
|
discoverAgents(options?: {
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,QAAQ,EACR,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EAEpB,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EACjB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,K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