@agent-wire/terminal 1.7.6 → 1.7.7
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/README.md +447 -405
- package/dist/api.d.ts +69 -19
- package/dist/api.js +126 -36
- package/dist/api.js.map +1 -1
- package/dist/cli-projection.d.ts +8 -0
- package/dist/cli-projection.js +124 -0
- package/dist/cli-projection.js.map +1 -0
- package/dist/cli.js +43 -953
- package/dist/cli.js.map +1 -1
- package/dist/contracts/credit-amount.d.ts +19 -0
- package/dist/contracts/credit-amount.js +87 -0
- package/dist/contracts/credit-amount.js.map +1 -0
- package/dist/local-pull.js +1 -1
- package/dist/local-pull.js.map +1 -1
- package/dist/mcp-server.js +211 -126
- package/dist/mcp-server.js.map +1 -1
- package/dist/sync/paginate.d.ts +2 -16
- package/dist/sync/paginate.js +2 -33
- package/dist/sync/paginate.js.map +1 -1
- package/dist/tool-projection.d.ts +10 -0
- package/dist/tool-projection.js +51 -0
- package/dist/tool-projection.js.map +1 -1
- package/dist/wait-cli.js +46 -21
- package/dist/wait-cli.js.map +1 -1
- package/package.json +60 -58
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import type { CreditAmount } from './contracts/credit-amount.js';
|
|
1
2
|
import type { WireNodeConfig } from './config.js';
|
|
2
3
|
import type { MarketNativeDocsIngestMode, RemoteDocument } from './sync/types.js';
|
|
4
|
+
export declare class RegistrationError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
constructor(status: number, message: string);
|
|
7
|
+
}
|
|
3
8
|
type LegacyActionInvokeParams = {
|
|
4
9
|
action_id: string;
|
|
5
10
|
mode: string;
|
|
@@ -11,8 +16,18 @@ type LegacyActionInvokeParams = {
|
|
|
11
16
|
type LegacyActionChainParams = LegacyActionInvokeParams & {
|
|
12
17
|
chain_id?: string;
|
|
13
18
|
};
|
|
19
|
+
export interface MeshScopeParams {
|
|
20
|
+
scope?: 'agent' | 'fleet' | 'circle';
|
|
21
|
+
circle_id?: string;
|
|
22
|
+
}
|
|
14
23
|
export interface QueryParams {
|
|
15
|
-
text
|
|
24
|
+
text?: string;
|
|
25
|
+
types?: string | string[];
|
|
26
|
+
type?: string;
|
|
27
|
+
exclude_types?: string | string[];
|
|
28
|
+
exclude_type?: string;
|
|
29
|
+
creator?: string;
|
|
30
|
+
agent?: string;
|
|
16
31
|
domain?: string;
|
|
17
32
|
limit?: number;
|
|
18
33
|
offset?: number;
|
|
@@ -46,14 +61,14 @@ export interface ContributeParams {
|
|
|
46
61
|
claim: string;
|
|
47
62
|
trackable: boolean;
|
|
48
63
|
}>;
|
|
49
|
-
price?:
|
|
64
|
+
price?: CreditAmount;
|
|
50
65
|
pricing_curve?: Array<{
|
|
51
66
|
credits: number;
|
|
52
67
|
after_hours: number;
|
|
53
68
|
}>;
|
|
54
69
|
curve_power?: number;
|
|
55
70
|
bid?: {
|
|
56
|
-
amount:
|
|
71
|
+
amount: CreditAmount;
|
|
57
72
|
duration_hours: number;
|
|
58
73
|
};
|
|
59
74
|
embargo_until?: string;
|
|
@@ -111,7 +126,7 @@ export interface StakeResult {
|
|
|
111
126
|
position: {
|
|
112
127
|
id: string;
|
|
113
128
|
side: string;
|
|
114
|
-
amount:
|
|
129
|
+
amount: CreditAmount;
|
|
115
130
|
created_at: string;
|
|
116
131
|
};
|
|
117
132
|
market: {
|
|
@@ -133,7 +148,7 @@ export interface MarketStatus {
|
|
|
133
148
|
your_positions: Array<{
|
|
134
149
|
id: string;
|
|
135
150
|
side: string;
|
|
136
|
-
amount:
|
|
151
|
+
amount: CreditAmount;
|
|
137
152
|
created_at: string;
|
|
138
153
|
}>;
|
|
139
154
|
resolution: {
|
|
@@ -165,8 +180,8 @@ export interface PinPreview {
|
|
|
165
180
|
export interface RetractionResult {
|
|
166
181
|
retracted: boolean;
|
|
167
182
|
contribution_id: string;
|
|
168
|
-
deposit_refund:
|
|
169
|
-
deposit_forfeit:
|
|
183
|
+
deposit_refund: CreditAmount;
|
|
184
|
+
deposit_forfeit: CreditAmount;
|
|
170
185
|
bounty_clawback: number;
|
|
171
186
|
}
|
|
172
187
|
export interface RateParams {
|
|
@@ -272,13 +287,14 @@ export type WireEventStreamMessage = {
|
|
|
272
287
|
data: unknown;
|
|
273
288
|
};
|
|
274
289
|
export declare function normalizeWaitTimeoutSeconds(timeoutSeconds: number | undefined): number;
|
|
275
|
-
declare function normalizeHelpTopic(topic: string | undefined): string;
|
|
290
|
+
export declare function normalizeHelpTopic(topic: string | undefined): string;
|
|
276
291
|
export declare const __wireApiTestInternals: {
|
|
277
292
|
normalizeHelpTopic: typeof normalizeHelpTopic;
|
|
278
293
|
parseSseBlock: typeof parseSseBlock;
|
|
279
294
|
};
|
|
280
295
|
declare function parseSseBlock(block: string): WireEventStreamMessage | null;
|
|
281
296
|
export declare class WireAPI {
|
|
297
|
+
claims(params: Record<string, unknown>): Promise<unknown>;
|
|
282
298
|
private baseUrl;
|
|
283
299
|
private token;
|
|
284
300
|
private nodeId;
|
|
@@ -328,7 +344,7 @@ export declare class WireAPI {
|
|
|
328
344
|
}>;
|
|
329
345
|
submitResult(workId: string, result: Record<string, unknown>): Promise<{
|
|
330
346
|
credits_awarded: number;
|
|
331
|
-
balance_after:
|
|
347
|
+
balance_after: CreditAmount;
|
|
332
348
|
}>;
|
|
333
349
|
heartbeat(nodeId: string): Promise<{
|
|
334
350
|
status: string;
|
|
@@ -362,6 +378,30 @@ export declare class WireAPI {
|
|
|
362
378
|
private localHeaders;
|
|
363
379
|
private localAuthToken;
|
|
364
380
|
private tryLocalContributionRead;
|
|
381
|
+
/**
|
|
382
|
+
* Generic local-node fetch for the pyramid consume-head proxies. Returns the
|
|
383
|
+
* parsed JSON body on success, throws a descriptive error on non-2xx.
|
|
384
|
+
*/
|
|
385
|
+
private localNodeFetch;
|
|
386
|
+
/**
|
|
387
|
+
* pyramid_map — GET /pyramid/{slug}/map.
|
|
388
|
+
* Apex synthesis + freshness counts + nav skeleton + unresolved gaps.
|
|
389
|
+
* Orient first at boot, then drill via pyramid_hydrate using nav node ids.
|
|
390
|
+
*/
|
|
391
|
+
getPyramidMap(slug: string): Promise<Record<string, unknown>>;
|
|
392
|
+
/**
|
|
393
|
+
* pyramid_hydrate — GET /pyramid/{slug}/drill/{node_id}.
|
|
394
|
+
* Returns the DrillResult: full node content (headline/distilled/narrative
|
|
395
|
+
* via the node payload) plus children, evidence, gaps, web_edges, and
|
|
396
|
+
* question context. Pull one node/region after orienting via pyramid_map.
|
|
397
|
+
*/
|
|
398
|
+
getPyramidDrill(slug: string, nodeId: string): Promise<Record<string, unknown>>;
|
|
399
|
+
/**
|
|
400
|
+
* pyramid_ask — POST /pyramid/{slug}/question body { question }.
|
|
401
|
+
* Cheap (<5s, no-LLM) mechanical retrieval over the existing pyramid;
|
|
402
|
+
* returns a markdown answer plus node-id citations / sources.
|
|
403
|
+
*/
|
|
404
|
+
askPyramid(slug: string, question: string): Promise<Record<string, unknown>>;
|
|
365
405
|
/**
|
|
366
406
|
* Rate a Wire item. Free. Must have accessed it first.
|
|
367
407
|
*/
|
|
@@ -418,31 +458,31 @@ export declare class WireAPI {
|
|
|
418
458
|
/**
|
|
419
459
|
* Get full mesh status: active threads, intents, blackboard.
|
|
420
460
|
*/
|
|
421
|
-
meshStatus(): Promise<Record<string, unknown>>;
|
|
461
|
+
meshStatus(scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
422
462
|
/**
|
|
423
463
|
* Read the shared blackboard.
|
|
424
464
|
*/
|
|
425
|
-
meshBoardRead(): Promise<Record<string, unknown>>;
|
|
465
|
+
meshBoardRead(scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
426
466
|
/**
|
|
427
467
|
* Write a key-value entry to the shared blackboard.
|
|
428
468
|
*/
|
|
429
|
-
meshBoardWrite(key: string, value: unknown, ttl?: number): Promise<Record<string, unknown>>;
|
|
469
|
+
meshBoardWrite(key: string, value: unknown, ttl?: number, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
430
470
|
/**
|
|
431
471
|
* Delete a key from the shared blackboard.
|
|
432
472
|
*/
|
|
433
|
-
meshBoardDelete(key: string): Promise<Record<string, unknown>>;
|
|
473
|
+
meshBoardDelete(key: string, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
434
474
|
/**
|
|
435
475
|
* Declare an intent (what this thread is about to do).
|
|
436
476
|
*/
|
|
437
|
-
meshDeclareIntent(action: string, domain?: string, meta?: Record<string, unknown>, ttl?: number): Promise<Record<string, unknown>>;
|
|
477
|
+
meshDeclareIntent(action: string, domain?: string, meta?: Record<string, unknown>, ttl?: number, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
438
478
|
/**
|
|
439
479
|
* Release (delete) an intent.
|
|
440
480
|
*/
|
|
441
|
-
meshReleaseIntent(intentId: string): Promise<Record<string, unknown>>;
|
|
481
|
+
meshReleaseIntent(intentId: string, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
442
482
|
/**
|
|
443
483
|
* Get active intents for this agent.
|
|
444
484
|
*/
|
|
445
|
-
meshGetIntents(): Promise<Record<string, unknown>>;
|
|
485
|
+
meshGetIntents(scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
446
486
|
/**
|
|
447
487
|
* Stake credits on a prediction market attached to a contribution.
|
|
448
488
|
* The contribution must have a claim with `market.enabled: true`.
|
|
@@ -452,7 +492,7 @@ export declare class WireAPI {
|
|
|
452
492
|
* @param side - 'agree' or 'disagree'
|
|
453
493
|
* @param amount - Number of credits to stake (must be >= market's min_stake)
|
|
454
494
|
*/
|
|
455
|
-
stakeMarket(contributionId: string, side: 'agree' | 'disagree', amount:
|
|
495
|
+
stakeMarket(contributionId: string, side: 'agree' | 'disagree', amount: CreditAmount, requestId?: string): Promise<StakeResult>;
|
|
456
496
|
/**
|
|
457
497
|
* Get the current status of a prediction market, including pool sizes,
|
|
458
498
|
* your positions, and resolution status if resolved.
|
|
@@ -619,8 +659,9 @@ export declare class WireAPI {
|
|
|
619
659
|
acceptSupersession(proposalId: string): Promise<Record<string, unknown>>;
|
|
620
660
|
rejectSupersession(proposalId: string): Promise<Record<string, unknown>>;
|
|
621
661
|
executeSupersession(targetId: string, newContributionId: string, allowTypeChange?: boolean): Promise<Record<string, unknown>>;
|
|
622
|
-
submitCorrection(targetId: string, correctionContributionId: string, depositAmount:
|
|
623
|
-
|
|
662
|
+
submitCorrection(targetId: string, correctionContributionId: string, depositAmount: CreditAmount): Promise<Record<string, unknown>>;
|
|
663
|
+
withdrawCorrection(correctionId: string): Promise<Record<string, unknown>>;
|
|
664
|
+
endorseCorrection(correctionId: string, depositAmount: CreditAmount): Promise<Record<string, unknown>>;
|
|
624
665
|
listCircles(): Promise<Record<string, unknown>>;
|
|
625
666
|
createCircle(name: string, partnerEmail: string, description?: string): Promise<Record<string, unknown>>;
|
|
626
667
|
joinCircle(circleId: string): Promise<Record<string, unknown>>;
|
|
@@ -729,4 +770,13 @@ export declare class WireAPI {
|
|
|
729
770
|
getRosterWithDeviceSecret(deviceSecret: string, harness?: string, hintName?: string): Promise<Record<string, unknown>>;
|
|
730
771
|
resumeAgent(agentName: string, deviceSecret: string, nonce: string): Promise<Record<string, unknown>>;
|
|
731
772
|
}
|
|
773
|
+
/**
|
|
774
|
+
* Paginate through all results from a fetch function.
|
|
775
|
+
* Concatenates pages until a page returns fewer than pageSize items.
|
|
776
|
+
*
|
|
777
|
+
* @param fetchPage - Function that fetches a page (1-indexed page number, pageSize)
|
|
778
|
+
* @param pageSize - Number of items per page (default 100)
|
|
779
|
+
* @returns All items concatenated
|
|
780
|
+
*/
|
|
781
|
+
export declare function paginateAll<T>(fetchPage: (page: number, pageSize: number) => Promise<T[]>, pageSize?: number): Promise<T[]>;
|
|
732
782
|
export {};
|
package/dist/api.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { paginateAll } from './sync/paginate.js';
|
|
2
1
|
const DEFAULT_TRUSTED_CHAIN_TIMEOUT_MS = 600_000;
|
|
3
2
|
const TRUSTED_CHAIN_CLIENT_GRACE_MS = 5_000;
|
|
4
3
|
const DEFAULT_WIRE_SYNC_TIMEOUT_MS = DEFAULT_TRUSTED_CHAIN_TIMEOUT_MS + TRUSTED_CHAIN_CLIENT_GRACE_MS;
|
|
5
4
|
const DEFAULT_ACTION_QUOTE_TIMEOUT_MS = 30_000;
|
|
5
|
+
export class RegistrationError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
constructor(status, message) {
|
|
8
|
+
super(`Registration failed (${status}): ${message}`);
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.name = 'RegistrationError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
6
13
|
function legacyActionRequestOptions(params) {
|
|
7
14
|
if (params.mode === 'quote') {
|
|
8
15
|
return { body: params, timeoutMs: DEFAULT_ACTION_QUOTE_TIMEOUT_MS };
|
|
@@ -13,6 +20,14 @@ function legacyActionRequestOptions(params) {
|
|
|
13
20
|
timeoutMs: timeoutMs + TRUSTED_CHAIN_CLIENT_GRACE_MS,
|
|
14
21
|
};
|
|
15
22
|
}
|
|
23
|
+
function meshQuery(params, extra = {}) {
|
|
24
|
+
const query = new URLSearchParams(extra);
|
|
25
|
+
if (params.scope)
|
|
26
|
+
query.set('scope', params.scope);
|
|
27
|
+
if (params.circle_id)
|
|
28
|
+
query.set('circle_id', params.circle_id);
|
|
29
|
+
return query.size ? `?${query}` : '';
|
|
30
|
+
}
|
|
16
31
|
const DEFAULT_WAIT_TIMEOUT_SECONDS = 30;
|
|
17
32
|
// Raised from 1800 (30m): the SSE event stream is server-side UNCAPPED + 30s-keepalived, so a long
|
|
18
33
|
// client park is just a client-side deadline, not an infra limit. 86400 = 24h finite ceiling.
|
|
@@ -69,7 +84,7 @@ function appendWaitParams(url, params) {
|
|
|
69
84
|
url.searchParams.set(key, String(value));
|
|
70
85
|
}
|
|
71
86
|
}
|
|
72
|
-
function normalizeHelpTopic(topic) {
|
|
87
|
+
export function normalizeHelpTopic(topic) {
|
|
73
88
|
return (topic || '')
|
|
74
89
|
.trim()
|
|
75
90
|
.replace(/^https?:\/\/[^/]+\/api\/v1\/help\/?/i, '')
|
|
@@ -131,6 +146,13 @@ function parseSseBlock(block) {
|
|
|
131
146
|
}
|
|
132
147
|
}
|
|
133
148
|
export class WireAPI {
|
|
149
|
+
async claims(params) {
|
|
150
|
+
const { action, claim_id } = params;
|
|
151
|
+
if (action === 'get' || action === 'list') {
|
|
152
|
+
return this.request('GET', '/wire/claims' + (claim_id ? `?claim_id=${encodeURIComponent(String(claim_id))}` : ''));
|
|
153
|
+
}
|
|
154
|
+
return this.request('POST', '/wire/claims', params, 120_000);
|
|
155
|
+
}
|
|
134
156
|
baseUrl;
|
|
135
157
|
token;
|
|
136
158
|
nodeId;
|
|
@@ -222,7 +244,7 @@ export class WireAPI {
|
|
|
222
244
|
return response;
|
|
223
245
|
}
|
|
224
246
|
async getMe() {
|
|
225
|
-
return this.request('GET', '/me');
|
|
247
|
+
return this.unwrapEnvelopeOrPlain(await this.request('GET', '/me'));
|
|
226
248
|
}
|
|
227
249
|
async registerNode(name, capabilities) {
|
|
228
250
|
return this.request('POST', '/node/register', { name, capabilities });
|
|
@@ -242,7 +264,7 @@ export class WireAPI {
|
|
|
242
264
|
});
|
|
243
265
|
if (!res.ok) {
|
|
244
266
|
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
245
|
-
throw new
|
|
267
|
+
throw new RegistrationError(res.status, err.error || res.statusText);
|
|
246
268
|
}
|
|
247
269
|
// Server wraps response in wireEnvelope: { data: { ... }, mesh, fleet, ... }
|
|
248
270
|
const envelope = await res.json();
|
|
@@ -263,21 +285,10 @@ export class WireAPI {
|
|
|
263
285
|
}
|
|
264
286
|
async query(params) {
|
|
265
287
|
const qs = new URLSearchParams();
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (params.offset !== undefined)
|
|
271
|
-
qs.set('offset', String(params.offset));
|
|
272
|
-
qs.set('sort', params.sort || 'recency');
|
|
273
|
-
if (params.watchlist)
|
|
274
|
-
qs.set('watchlist', 'true');
|
|
275
|
-
if (params.list)
|
|
276
|
-
qs.set('list', params.list);
|
|
277
|
-
if (params.changed_only)
|
|
278
|
-
qs.set('changed_only', 'true');
|
|
279
|
-
if (params.price_below !== undefined)
|
|
280
|
-
qs.set('price_below', String(params.price_below));
|
|
288
|
+
for (const [key, value] of Object.entries({ domain: 'all', sort: 'recency', ...params })) {
|
|
289
|
+
if (value !== undefined && value !== null)
|
|
290
|
+
qs.set(key, String(value));
|
|
291
|
+
}
|
|
281
292
|
return this.request('GET', `/wire/query?${qs.toString()}`);
|
|
282
293
|
}
|
|
283
294
|
async help(params = {}) {
|
|
@@ -476,6 +487,55 @@ export class WireAPI {
|
|
|
476
487
|
return null;
|
|
477
488
|
}
|
|
478
489
|
}
|
|
490
|
+
// ── Pyramid consume-head proxies (spec green playful/176/24) ───────────
|
|
491
|
+
// Thin HTTP proxies to the LOCAL AWN node's read-time pyramid routes
|
|
492
|
+
// (pyramid_routes mounted at /pyramid/*). They forward (slug, args) to the
|
|
493
|
+
// route and return the parsed JSON as-is. Auth: pass the local Bearer token
|
|
494
|
+
// (this.localHeaders()); the AWN routes enforce dual-auth + access-tier +
|
|
495
|
+
// nano-payment. Same local-node fetch pattern as tryLocalContributionRead.
|
|
496
|
+
/**
|
|
497
|
+
* Generic local-node fetch for the pyramid consume-head proxies. Returns the
|
|
498
|
+
* parsed JSON body on success, throws a descriptive error on non-2xx.
|
|
499
|
+
*/
|
|
500
|
+
async localNodeFetch(method, path, body, timeoutMs = 15_000) {
|
|
501
|
+
const res = await fetch(`${this.localNodeUrl}${path}`, {
|
|
502
|
+
method,
|
|
503
|
+
headers: this.localHeaders(),
|
|
504
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
505
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
506
|
+
});
|
|
507
|
+
if (!res.ok) {
|
|
508
|
+
const err = await res.json().catch(() => ({ error: res.statusText }));
|
|
509
|
+
const message = err.error || res.statusText;
|
|
510
|
+
throw new Error(`Local node ${method} ${path} failed (${res.status}): ${message}`);
|
|
511
|
+
}
|
|
512
|
+
return await res.json();
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* pyramid_map — GET /pyramid/{slug}/map.
|
|
516
|
+
* Apex synthesis + freshness counts + nav skeleton + unresolved gaps.
|
|
517
|
+
* Orient first at boot, then drill via pyramid_hydrate using nav node ids.
|
|
518
|
+
*/
|
|
519
|
+
async getPyramidMap(slug) {
|
|
520
|
+
return this.localNodeFetch('GET', `/pyramid/${encodeURIComponent(slug)}/map`);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* pyramid_hydrate — GET /pyramid/{slug}/drill/{node_id}.
|
|
524
|
+
* Returns the DrillResult: full node content (headline/distilled/narrative
|
|
525
|
+
* via the node payload) plus children, evidence, gaps, web_edges, and
|
|
526
|
+
* question context. Pull one node/region after orienting via pyramid_map.
|
|
527
|
+
*/
|
|
528
|
+
async getPyramidDrill(slug, nodeId) {
|
|
529
|
+
return this.localNodeFetch('GET', `/pyramid/${encodeURIComponent(slug)}/drill/${encodeURIComponent(nodeId)}`);
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* pyramid_ask — POST /pyramid/{slug}/question body { question }.
|
|
533
|
+
* Cheap (<5s, no-LLM) mechanical retrieval over the existing pyramid;
|
|
534
|
+
* returns a markdown answer plus node-id citations / sources.
|
|
535
|
+
*/
|
|
536
|
+
async askPyramid(slug, question) {
|
|
537
|
+
return this.localNodeFetch('POST', `/pyramid/${encodeURIComponent(slug)}/question`, { question });
|
|
538
|
+
}
|
|
479
539
|
/**
|
|
480
540
|
* Rate a Wire item. Free. Must have accessed it first.
|
|
481
541
|
*/
|
|
@@ -523,7 +583,8 @@ export class WireAPI {
|
|
|
523
583
|
* Read a source document by ID.
|
|
524
584
|
*/
|
|
525
585
|
async readDocument(documentId) {
|
|
526
|
-
|
|
586
|
+
const quote = await this.request('GET', `/wire/documents/${documentId}`, undefined, 30_000);
|
|
587
|
+
return this.request('POST', `/wire/documents/${quote.id ?? quote.data?.id ?? documentId}`, { max_price: quote.current_price ?? quote.data?.current_price ?? 0 }, 30_000);
|
|
527
588
|
}
|
|
528
589
|
/**
|
|
529
590
|
* Find unscouted documents — unclaimed bounties.
|
|
@@ -596,44 +657,44 @@ export class WireAPI {
|
|
|
596
657
|
/**
|
|
597
658
|
* Get full mesh status: active threads, intents, blackboard.
|
|
598
659
|
*/
|
|
599
|
-
async meshStatus() {
|
|
600
|
-
return this.request('GET',
|
|
660
|
+
async meshStatus(scope = {}) {
|
|
661
|
+
return this.request('GET', `/mesh/status${meshQuery(scope)}`);
|
|
601
662
|
}
|
|
602
663
|
/**
|
|
603
664
|
* Read the shared blackboard.
|
|
604
665
|
*/
|
|
605
|
-
async meshBoardRead() {
|
|
606
|
-
return this.request('GET',
|
|
666
|
+
async meshBoardRead(scope = {}) {
|
|
667
|
+
return this.request('GET', `/mesh/board${meshQuery(scope)}`);
|
|
607
668
|
}
|
|
608
669
|
/**
|
|
609
670
|
* Write a key-value entry to the shared blackboard.
|
|
610
671
|
*/
|
|
611
|
-
async meshBoardWrite(key, value, ttl) {
|
|
612
|
-
return this.request('POST', '/mesh/board', { key, value, ttl });
|
|
672
|
+
async meshBoardWrite(key, value, ttl, scope = {}) {
|
|
673
|
+
return this.request('POST', '/mesh/board', { key, value, ttl, ...scope });
|
|
613
674
|
}
|
|
614
675
|
/**
|
|
615
676
|
* Delete a key from the shared blackboard.
|
|
616
677
|
*/
|
|
617
|
-
async meshBoardDelete(key) {
|
|
618
|
-
return this.request('DELETE', `/mesh/board
|
|
678
|
+
async meshBoardDelete(key, scope = {}) {
|
|
679
|
+
return this.request('DELETE', `/mesh/board${meshQuery(scope, { key })}`);
|
|
619
680
|
}
|
|
620
681
|
/**
|
|
621
682
|
* Declare an intent (what this thread is about to do).
|
|
622
683
|
*/
|
|
623
|
-
async meshDeclareIntent(action, domain, meta, ttl) {
|
|
624
|
-
return this.request('POST', '/mesh/intent', { action, domain, meta, ttl });
|
|
684
|
+
async meshDeclareIntent(action, domain, meta, ttl, scope = {}) {
|
|
685
|
+
return this.request('POST', '/mesh/intent', { action, domain, meta, ttl, ...scope });
|
|
625
686
|
}
|
|
626
687
|
/**
|
|
627
688
|
* Release (delete) an intent.
|
|
628
689
|
*/
|
|
629
|
-
async meshReleaseIntent(intentId) {
|
|
630
|
-
return this.request('DELETE', `/mesh/intent
|
|
690
|
+
async meshReleaseIntent(intentId, scope = {}) {
|
|
691
|
+
return this.request('DELETE', `/mesh/intent${meshQuery(scope, { intent_id: intentId })}`);
|
|
631
692
|
}
|
|
632
693
|
/**
|
|
633
694
|
* Get active intents for this agent.
|
|
634
695
|
*/
|
|
635
|
-
async meshGetIntents() {
|
|
636
|
-
return this.request('GET',
|
|
696
|
+
async meshGetIntents(scope = {}) {
|
|
697
|
+
return this.request('GET', `/mesh/intent${meshQuery(scope)}`);
|
|
637
698
|
}
|
|
638
699
|
// ── Prediction Markets ─────────────────────────────────────
|
|
639
700
|
/**
|
|
@@ -645,8 +706,8 @@ export class WireAPI {
|
|
|
645
706
|
* @param side - 'agree' or 'disagree'
|
|
646
707
|
* @param amount - Number of credits to stake (must be >= market's min_stake)
|
|
647
708
|
*/
|
|
648
|
-
async stakeMarket(contributionId, side, amount) {
|
|
649
|
-
return this.request('POST', `/wire/market/${contributionId}/stake`, { side, amount });
|
|
709
|
+
async stakeMarket(contributionId, side, amount, requestId = crypto.randomUUID()) {
|
|
710
|
+
return this.request('POST', `/wire/market/${contributionId}/stake`, { side, amount, request_id: requestId });
|
|
650
711
|
}
|
|
651
712
|
/**
|
|
652
713
|
* Get the current status of a prediction market, including pool sizes,
|
|
@@ -1020,6 +1081,9 @@ export class WireAPI {
|
|
|
1020
1081
|
async submitCorrection(targetId, correctionContributionId, depositAmount) {
|
|
1021
1082
|
return this.request('POST', `/wire/contributions/${encodeURIComponent(targetId)}/correct`, { correction_contribution_id: correctionContributionId, deposit_amount: depositAmount });
|
|
1022
1083
|
}
|
|
1084
|
+
async withdrawCorrection(correctionId) {
|
|
1085
|
+
return this.request('DELETE', `/wire/contributions/${encodeURIComponent(correctionId)}/endorse-correction`);
|
|
1086
|
+
}
|
|
1023
1087
|
async endorseCorrection(correctionId, depositAmount) {
|
|
1024
1088
|
return this.request('POST', `/wire/contributions/${encodeURIComponent(correctionId)}/endorse-correction`, { deposit_amount: depositAmount });
|
|
1025
1089
|
}
|
|
@@ -1313,4 +1377,30 @@ export class WireAPI {
|
|
|
1313
1377
|
return json.data || json;
|
|
1314
1378
|
}
|
|
1315
1379
|
}
|
|
1380
|
+
/**
|
|
1381
|
+
* Paginate through all results from a fetch function.
|
|
1382
|
+
* Concatenates pages until a page returns fewer than pageSize items.
|
|
1383
|
+
*
|
|
1384
|
+
* @param fetchPage - Function that fetches a page (1-indexed page number, pageSize)
|
|
1385
|
+
* @param pageSize - Number of items per page (default 100)
|
|
1386
|
+
* @returns All items concatenated
|
|
1387
|
+
*/
|
|
1388
|
+
export async function paginateAll(fetchPage, pageSize = 100) {
|
|
1389
|
+
const allItems = [];
|
|
1390
|
+
let page = 1;
|
|
1391
|
+
const MAX_PAGES = 500; // 500 pages * 100 per page = 50k docs max
|
|
1392
|
+
while (true) {
|
|
1393
|
+
if (page > MAX_PAGES) {
|
|
1394
|
+
console.error(`[wire-sync] Pagination stopped at ${MAX_PAGES} pages (${allItems.length} items). If your corpus has more documents, contact support.`);
|
|
1395
|
+
break;
|
|
1396
|
+
}
|
|
1397
|
+
const items = await fetchPage(page, pageSize);
|
|
1398
|
+
allItems.push(...items);
|
|
1399
|
+
if (items.length < pageSize) {
|
|
1400
|
+
break;
|
|
1401
|
+
}
|
|
1402
|
+
page++;
|
|
1403
|
+
}
|
|
1404
|
+
return allItems;
|
|
1405
|
+
}
|
|
1316
1406
|
//# sourceMappingURL=api.js.map
|