@agent-wire/terminal 1.7.6 → 1.7.9
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 +492 -403
- package/dist/api-token.d.ts +7 -0
- package/dist/api-token.js +42 -0
- package/dist/api-token.js.map +1 -0
- package/dist/api.d.ts +84 -21
- package/dist/api.js +179 -55
- package/dist/api.js.map +1 -1
- package/dist/cli-projection.d.ts +8 -0
- package/dist/cli-projection.js +139 -0
- package/dist/cli-projection.js.map +1 -0
- package/dist/cli.js +62 -961
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +4 -1
- package/dist/config.js +20 -9
- package/dist/config.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 +258 -133
- package/dist/mcp-server.js.map +1 -1
- package/dist/response-shaper.js +54 -14
- package/dist/response-shaper.js.map +1 -1
- package/dist/resume.d.ts +7 -0
- package/dist/resume.js +15 -0
- package/dist/resume.js.map +1 -0
- 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 +54 -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 +4 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface TokenConfig {
|
|
2
|
+
apiToken: string;
|
|
3
|
+
apiTokenFile?: string;
|
|
4
|
+
}
|
|
5
|
+
/** Explicit environment token > environment file > saved configuration. */
|
|
6
|
+
export declare function resolveApiToken(config: TokenConfig, allowInvalidTokenFile?: boolean): TokenConfig;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute } from 'node:path';
|
|
3
|
+
// Capture credentials for this process; rotating a token file requires a restart.
|
|
4
|
+
const envToken = process.env.WIRE_API_TOKEN;
|
|
5
|
+
const envTokenFile = process.env.WIRE_API_TOKEN_FILE;
|
|
6
|
+
const fileTokens = new Map();
|
|
7
|
+
/** Explicit environment token > environment file > saved configuration. */
|
|
8
|
+
export function resolveApiToken(config, allowInvalidTokenFile = false) {
|
|
9
|
+
if (envToken)
|
|
10
|
+
return { apiToken: envToken, apiTokenFile: undefined };
|
|
11
|
+
const path = envTokenFile ?? config.apiTokenFile;
|
|
12
|
+
if (path === undefined)
|
|
13
|
+
return { apiToken: config.apiToken, apiTokenFile: undefined };
|
|
14
|
+
let token = fileTokens.get(path);
|
|
15
|
+
if (token === undefined) {
|
|
16
|
+
if (!isAbsolute(path)) {
|
|
17
|
+
token = new Error('WIRE_API_TOKEN_FILE must be an absolute path to a file containing only your token');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
try {
|
|
21
|
+
token = readFileSync(path, 'utf8').trim();
|
|
22
|
+
if (!token)
|
|
23
|
+
token = new Error('The file referenced by WIRE_API_TOKEN_FILE is empty; it must contain only your token');
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
// Only expose the OS code, never file contents or an arbitrary error message.
|
|
27
|
+
const code = error.code ?? 'read failed';
|
|
28
|
+
token = new Error(`Cannot read the file referenced by WIRE_API_TOKEN_FILE (${code}); set it to an absolute path to a file containing only your token`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
fileTokens.set(path, token);
|
|
32
|
+
}
|
|
33
|
+
if (token instanceof Error) {
|
|
34
|
+
// Public help/discovery may proceed anonymously; authenticated callers retry
|
|
35
|
+
// this same cached result and receive the error without exposing the value.
|
|
36
|
+
if (allowInvalidTokenFile)
|
|
37
|
+
return { apiToken: '', apiTokenFile: path };
|
|
38
|
+
throw token;
|
|
39
|
+
}
|
|
40
|
+
return { apiToken: token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;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,8EAA8E;gBAC9E,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,IAAI,aAAa,CAAC;gBACpE,KAAK,GAAG,IAAI,KAAK,CAAC,2DAA2D,IAAI,oEAAoE,CAAC,CAAC;YACzJ,CAAC;QACH,CAAC;QACD,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,6EAA6E;QAC7E,4EAA4E;QAC5E,IAAI,qBAAqB;YAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QACvE,MAAM,KAAK,CAAC;IACd,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC"}
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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 function normalizeWireApiUrl(value: string): string;
|
|
5
|
+
export declare class RegistrationError extends Error {
|
|
6
|
+
readonly status: number;
|
|
7
|
+
constructor(status: number, message: string);
|
|
8
|
+
}
|
|
3
9
|
type LegacyActionInvokeParams = {
|
|
4
10
|
action_id: string;
|
|
5
11
|
mode: string;
|
|
@@ -11,8 +17,19 @@ type LegacyActionInvokeParams = {
|
|
|
11
17
|
type LegacyActionChainParams = LegacyActionInvokeParams & {
|
|
12
18
|
chain_id?: string;
|
|
13
19
|
};
|
|
20
|
+
export interface MeshScopeParams {
|
|
21
|
+
scope?: 'agent' | 'fleet' | 'circle';
|
|
22
|
+
circle_id?: string;
|
|
23
|
+
}
|
|
14
24
|
export interface QueryParams {
|
|
15
|
-
|
|
25
|
+
count?: 'exact';
|
|
26
|
+
text?: string;
|
|
27
|
+
types?: string | string[];
|
|
28
|
+
type?: string;
|
|
29
|
+
exclude_types?: string | string[];
|
|
30
|
+
exclude_type?: string;
|
|
31
|
+
creator?: string;
|
|
32
|
+
agent?: string;
|
|
16
33
|
domain?: string;
|
|
17
34
|
limit?: number;
|
|
18
35
|
offset?: number;
|
|
@@ -24,6 +41,7 @@ export interface QueryParams {
|
|
|
24
41
|
}
|
|
25
42
|
export interface ContributeParams {
|
|
26
43
|
type: string;
|
|
44
|
+
original?: boolean;
|
|
27
45
|
contribution_type?: 'mechanical' | 'intelligence';
|
|
28
46
|
title: string;
|
|
29
47
|
body: string;
|
|
@@ -46,14 +64,14 @@ export interface ContributeParams {
|
|
|
46
64
|
claim: string;
|
|
47
65
|
trackable: boolean;
|
|
48
66
|
}>;
|
|
49
|
-
price?:
|
|
67
|
+
price?: CreditAmount;
|
|
50
68
|
pricing_curve?: Array<{
|
|
51
69
|
credits: number;
|
|
52
70
|
after_hours: number;
|
|
53
71
|
}>;
|
|
54
72
|
curve_power?: number;
|
|
55
73
|
bid?: {
|
|
56
|
-
amount:
|
|
74
|
+
amount: CreditAmount;
|
|
57
75
|
duration_hours: number;
|
|
58
76
|
};
|
|
59
77
|
embargo_until?: string;
|
|
@@ -88,6 +106,9 @@ export interface BrowseParams {
|
|
|
88
106
|
include_definition?: boolean;
|
|
89
107
|
definition_purpose?: string;
|
|
90
108
|
definition_scope?: string;
|
|
109
|
+
cursor?: string;
|
|
110
|
+
limit?: number;
|
|
111
|
+
offset?: number;
|
|
91
112
|
}
|
|
92
113
|
export interface FlagParams {
|
|
93
114
|
item_id: string;
|
|
@@ -111,7 +132,7 @@ export interface StakeResult {
|
|
|
111
132
|
position: {
|
|
112
133
|
id: string;
|
|
113
134
|
side: string;
|
|
114
|
-
amount:
|
|
135
|
+
amount: CreditAmount;
|
|
115
136
|
created_at: string;
|
|
116
137
|
};
|
|
117
138
|
market: {
|
|
@@ -133,7 +154,7 @@ export interface MarketStatus {
|
|
|
133
154
|
your_positions: Array<{
|
|
134
155
|
id: string;
|
|
135
156
|
side: string;
|
|
136
|
-
amount:
|
|
157
|
+
amount: CreditAmount;
|
|
137
158
|
created_at: string;
|
|
138
159
|
}>;
|
|
139
160
|
resolution: {
|
|
@@ -165,8 +186,8 @@ export interface PinPreview {
|
|
|
165
186
|
export interface RetractionResult {
|
|
166
187
|
retracted: boolean;
|
|
167
188
|
contribution_id: string;
|
|
168
|
-
deposit_refund:
|
|
169
|
-
deposit_forfeit:
|
|
189
|
+
deposit_refund: CreditAmount;
|
|
190
|
+
deposit_forfeit: CreditAmount;
|
|
170
191
|
bounty_clawback: number;
|
|
171
192
|
}
|
|
172
193
|
export interface RateParams {
|
|
@@ -272,13 +293,21 @@ export type WireEventStreamMessage = {
|
|
|
272
293
|
data: unknown;
|
|
273
294
|
};
|
|
274
295
|
export declare function normalizeWaitTimeoutSeconds(timeoutSeconds: number | undefined): number;
|
|
275
|
-
declare function normalizeHelpTopic(topic: string | undefined): string;
|
|
296
|
+
export declare function normalizeHelpTopic(topic: string | undefined): string;
|
|
276
297
|
export declare const __wireApiTestInternals: {
|
|
277
298
|
normalizeHelpTopic: typeof normalizeHelpTopic;
|
|
278
299
|
parseSseBlock: typeof parseSseBlock;
|
|
279
300
|
};
|
|
280
301
|
declare function parseSseBlock(block: string): WireEventStreamMessage | null;
|
|
302
|
+
/** Keep actionable server refusals intact across MCP and terminal transports. */
|
|
303
|
+
export declare class WireApiRefusal extends Error {
|
|
304
|
+
readonly status: number;
|
|
305
|
+
readonly body: Record<string, unknown>;
|
|
306
|
+
constructor(status: number, body: Record<string, unknown>);
|
|
307
|
+
}
|
|
281
308
|
export declare class WireAPI {
|
|
309
|
+
private httpFetch?;
|
|
310
|
+
claims(params: Record<string, unknown>): Promise<unknown>;
|
|
282
311
|
private baseUrl;
|
|
283
312
|
private token;
|
|
284
313
|
private nodeId;
|
|
@@ -287,7 +316,7 @@ export declare class WireAPI {
|
|
|
287
316
|
private localNodeEnabled;
|
|
288
317
|
private localNodeToken;
|
|
289
318
|
private localContributionRouteStatus;
|
|
290
|
-
constructor(config: WireNodeConfig, threadId?: string);
|
|
319
|
+
constructor(config: WireNodeConfig, threadId?: string, httpFetch?: typeof fetch | undefined);
|
|
291
320
|
/** Set or update the thread ID (used for mesh coordination) */
|
|
292
321
|
setThreadId(id: string): void;
|
|
293
322
|
request<T>(method: string, path: string, body?: unknown, timeoutMs?: number): Promise<T>;
|
|
@@ -328,7 +357,7 @@ export declare class WireAPI {
|
|
|
328
357
|
}>;
|
|
329
358
|
submitResult(workId: string, result: Record<string, unknown>): Promise<{
|
|
330
359
|
credits_awarded: number;
|
|
331
|
-
balance_after:
|
|
360
|
+
balance_after: CreditAmount;
|
|
332
361
|
}>;
|
|
333
362
|
heartbeat(nodeId: string): Promise<{
|
|
334
363
|
status: string;
|
|
@@ -362,6 +391,30 @@ export declare class WireAPI {
|
|
|
362
391
|
private localHeaders;
|
|
363
392
|
private localAuthToken;
|
|
364
393
|
private tryLocalContributionRead;
|
|
394
|
+
/**
|
|
395
|
+
* Generic local-node fetch for the pyramid consume-head proxies. Returns the
|
|
396
|
+
* parsed JSON body on success, throws a descriptive error on non-2xx.
|
|
397
|
+
*/
|
|
398
|
+
private localNodeFetch;
|
|
399
|
+
/**
|
|
400
|
+
* pyramid_map — GET /pyramid/{slug}/map.
|
|
401
|
+
* Apex synthesis + freshness counts + nav skeleton + unresolved gaps.
|
|
402
|
+
* Orient first at boot, then drill via pyramid_hydrate using nav node ids.
|
|
403
|
+
*/
|
|
404
|
+
getPyramidMap(slug: string): Promise<Record<string, unknown>>;
|
|
405
|
+
/**
|
|
406
|
+
* pyramid_hydrate — GET /pyramid/{slug}/drill/{node_id}.
|
|
407
|
+
* Returns the DrillResult: full node content (headline/distilled/narrative
|
|
408
|
+
* via the node payload) plus children, evidence, gaps, web_edges, and
|
|
409
|
+
* question context. Pull one node/region after orienting via pyramid_map.
|
|
410
|
+
*/
|
|
411
|
+
getPyramidDrill(slug: string, nodeId: string): Promise<Record<string, unknown>>;
|
|
412
|
+
/**
|
|
413
|
+
* pyramid_ask — POST /pyramid/{slug}/question body { question }.
|
|
414
|
+
* Cheap (<5s, no-LLM) mechanical retrieval over the existing pyramid;
|
|
415
|
+
* returns a markdown answer plus node-id citations / sources.
|
|
416
|
+
*/
|
|
417
|
+
askPyramid(slug: string, question: string): Promise<Record<string, unknown>>;
|
|
365
418
|
/**
|
|
366
419
|
* Rate a Wire item. Free. Must have accessed it first.
|
|
367
420
|
*/
|
|
@@ -418,31 +471,31 @@ export declare class WireAPI {
|
|
|
418
471
|
/**
|
|
419
472
|
* Get full mesh status: active threads, intents, blackboard.
|
|
420
473
|
*/
|
|
421
|
-
meshStatus(): Promise<Record<string, unknown>>;
|
|
474
|
+
meshStatus(scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
422
475
|
/**
|
|
423
476
|
* Read the shared blackboard.
|
|
424
477
|
*/
|
|
425
|
-
meshBoardRead(): Promise<Record<string, unknown>>;
|
|
478
|
+
meshBoardRead(scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
426
479
|
/**
|
|
427
480
|
* Write a key-value entry to the shared blackboard.
|
|
428
481
|
*/
|
|
429
|
-
meshBoardWrite(key: string, value: unknown, ttl?: number): Promise<Record<string, unknown>>;
|
|
482
|
+
meshBoardWrite(key: string, value: unknown, ttl?: number, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
430
483
|
/**
|
|
431
484
|
* Delete a key from the shared blackboard.
|
|
432
485
|
*/
|
|
433
|
-
meshBoardDelete(key: string): Promise<Record<string, unknown>>;
|
|
486
|
+
meshBoardDelete(key: string, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
434
487
|
/**
|
|
435
488
|
* Declare an intent (what this thread is about to do).
|
|
436
489
|
*/
|
|
437
|
-
meshDeclareIntent(action: string, domain?: string, meta?: Record<string, unknown>, ttl?: number): Promise<Record<string, unknown>>;
|
|
490
|
+
meshDeclareIntent(action: string, domain?: string, meta?: Record<string, unknown>, ttl?: number, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
438
491
|
/**
|
|
439
492
|
* Release (delete) an intent.
|
|
440
493
|
*/
|
|
441
|
-
meshReleaseIntent(intentId: string): Promise<Record<string, unknown>>;
|
|
494
|
+
meshReleaseIntent(intentId: string, scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
442
495
|
/**
|
|
443
496
|
* Get active intents for this agent.
|
|
444
497
|
*/
|
|
445
|
-
meshGetIntents(): Promise<Record<string, unknown>>;
|
|
498
|
+
meshGetIntents(scope?: MeshScopeParams): Promise<Record<string, unknown>>;
|
|
446
499
|
/**
|
|
447
500
|
* Stake credits on a prediction market attached to a contribution.
|
|
448
501
|
* The contribution must have a claim with `market.enabled: true`.
|
|
@@ -452,7 +505,7 @@ export declare class WireAPI {
|
|
|
452
505
|
* @param side - 'agree' or 'disagree'
|
|
453
506
|
* @param amount - Number of credits to stake (must be >= market's min_stake)
|
|
454
507
|
*/
|
|
455
|
-
stakeMarket(contributionId: string, side: 'agree' | 'disagree', amount:
|
|
508
|
+
stakeMarket(contributionId: string, side: 'agree' | 'disagree', amount: CreditAmount, requestId?: string): Promise<StakeResult>;
|
|
456
509
|
/**
|
|
457
510
|
* Get the current status of a prediction market, including pool sizes,
|
|
458
511
|
* your positions, and resolution status if resolved.
|
|
@@ -619,8 +672,9 @@ export declare class WireAPI {
|
|
|
619
672
|
acceptSupersession(proposalId: string): Promise<Record<string, unknown>>;
|
|
620
673
|
rejectSupersession(proposalId: string): Promise<Record<string, unknown>>;
|
|
621
674
|
executeSupersession(targetId: string, newContributionId: string, allowTypeChange?: boolean): Promise<Record<string, unknown>>;
|
|
622
|
-
submitCorrection(targetId: string, correctionContributionId: string, depositAmount:
|
|
623
|
-
|
|
675
|
+
submitCorrection(targetId: string, correctionContributionId: string, depositAmount: CreditAmount): Promise<Record<string, unknown>>;
|
|
676
|
+
withdrawCorrection(correctionId: string): Promise<Record<string, unknown>>;
|
|
677
|
+
endorseCorrection(correctionId: string, depositAmount: CreditAmount): Promise<Record<string, unknown>>;
|
|
624
678
|
listCircles(): Promise<Record<string, unknown>>;
|
|
625
679
|
createCircle(name: string, partnerEmail: string, description?: string): Promise<Record<string, unknown>>;
|
|
626
680
|
joinCircle(circleId: string): Promise<Record<string, unknown>>;
|
|
@@ -704,7 +758,7 @@ export declare class WireAPI {
|
|
|
704
758
|
material_class?: string;
|
|
705
759
|
visibility?: string;
|
|
706
760
|
themes?: string[];
|
|
707
|
-
attestation_tier
|
|
761
|
+
attestation_tier: 'ownership' | 'authorization' | 'good_faith';
|
|
708
762
|
authorizing_party?: string;
|
|
709
763
|
authorization_basis?: string;
|
|
710
764
|
rights_basis?: string;
|
|
@@ -729,4 +783,13 @@ export declare class WireAPI {
|
|
|
729
783
|
getRosterWithDeviceSecret(deviceSecret: string, harness?: string, hintName?: string): Promise<Record<string, unknown>>;
|
|
730
784
|
resumeAgent(agentName: string, deviceSecret: string, nonce: string): Promise<Record<string, unknown>>;
|
|
731
785
|
}
|
|
786
|
+
/**
|
|
787
|
+
* Paginate through all results from a fetch function.
|
|
788
|
+
* Concatenates pages until a page returns fewer than pageSize items.
|
|
789
|
+
*
|
|
790
|
+
* @param fetchPage - Function that fetches a page (1-indexed page number, pageSize)
|
|
791
|
+
* @param pageSize - Number of items per page (default 100)
|
|
792
|
+
* @returns All items concatenated
|
|
793
|
+
*/
|
|
794
|
+
export declare function paginateAll<T>(fetchPage: (page: number, pageSize: number) => Promise<T[]>, pageSize?: number): Promise<T[]>;
|
|
732
795
|
export {};
|