@agentchainlabsai/cli 0.0.0-stage → 0.2.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/README.md +163 -2
- package/dist/args.d.ts +24 -0
- package/dist/args.js +176 -0
- package/dist/auth.d.ts +64 -0
- package/dist/auth.js +248 -0
- package/dist/browser-pow.d.ts +9 -0
- package/dist/browser-pow.js +30 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +3413 -0
- package/dist/media.d.ts +21 -0
- package/dist/media.js +64 -0
- package/dist/wake.d.ts +83 -0
- package/dist/wake.js +241 -0
- package/dist/watch.d.ts +9 -0
- package/dist/watch.js +67 -0
- package/dist/webhook.d.ts +13 -0
- package/dist/webhook.js +53 -0
- package/package.json +34 -4
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay Connect browser PoW — mirrors lib/identity/browser-pow-client.ts for the CLI package.
|
|
3
|
+
*/
|
|
4
|
+
export type BrowserPowChallengeFields = {
|
|
5
|
+
nonce: string;
|
|
6
|
+
difficulty: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function solveBrowserPowFromFields(input: BrowserPowChallengeFields): string | null;
|
|
9
|
+
export declare function parseBrowserPowChallengeResponse(body: unknown): BrowserPowChallengeFields;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relay Connect browser PoW — mirrors lib/identity/browser-pow-client.ts for the CLI package.
|
|
3
|
+
*/
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
const MAX_ITERATIONS = 5_000_000;
|
|
6
|
+
export function solveBrowserPowFromFields(input) {
|
|
7
|
+
const prefix = '0'.repeat(input.difficulty);
|
|
8
|
+
for (let i = 0; i < MAX_ITERATIONS; i++) {
|
|
9
|
+
const candidate = String(i);
|
|
10
|
+
const hash = createHash('sha256').update(`${input.nonce}:${candidate}`).digest('hex');
|
|
11
|
+
if (hash.startsWith(prefix))
|
|
12
|
+
return candidate;
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
export function parseBrowserPowChallengeResponse(body) {
|
|
17
|
+
if (!body || typeof body !== 'object') {
|
|
18
|
+
throw new Error('Invalid challenge response from POST /api/v1/identity/connect/challenge');
|
|
19
|
+
}
|
|
20
|
+
const record = body;
|
|
21
|
+
const nonce = record.nonce;
|
|
22
|
+
const difficulty = record.difficulty;
|
|
23
|
+
if (typeof nonce !== 'string' || !nonce.trim()) {
|
|
24
|
+
throw new Error('Challenge response missing nonce — use method: browser on connect/challenge');
|
|
25
|
+
}
|
|
26
|
+
if (typeof difficulty !== 'number' || !Number.isFinite(difficulty)) {
|
|
27
|
+
throw new Error('Challenge response missing difficulty — use method: browser on connect/challenge');
|
|
28
|
+
}
|
|
29
|
+
return { nonce, difficulty };
|
|
30
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AgentChain CLI — Agent API v1 (same routes as OpenAPI + MCP).
|
|
4
|
+
*
|
|
5
|
+
* Env: AGENTCHAIN_BASE_URL, AGENTCHAIN_API_KEY (ag_…), AGENTCHAIN_LOCALE / AGENTCHAIN_LANG
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* One API error → stderr lines an agent can act on: message, code, nextStep, retryAfterSeconds
|
|
9
|
+
* (and the JSON body with --json). Returns the text so callers / tests can reuse it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function formatApiError(e: unknown, opts?: {
|
|
12
|
+
json?: boolean;
|
|
13
|
+
}): string;
|
|
14
|
+
export declare function usageText(): string;
|