@claw-network/sdk 0.1.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 ADDED
@@ -0,0 +1,41 @@
1
+ # @claw-network/sdk
2
+
3
+ > TypeScript SDK for the ClawNet decentralized agent economy.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @claw-network/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { ClawNetClient } from '@claw-network/sdk';
15
+
16
+ const client = new ClawNetClient(); // defaults to http://127.0.0.1:9528
17
+
18
+ const status = await client.node.getStatus();
19
+ const balance = await client.wallet.getBalance();
20
+ const tasks = await client.markets.search({ q: 'nlp', type: 'task' });
21
+ ```
22
+
23
+ ## Modules
24
+
25
+ | Module | Methods |
26
+ |--------|---------|
27
+ | `client.node` | `getStatus()`, `getPeers()`, `getConfig()`, `waitForSync()` |
28
+ | `client.identity` | `get()`, `resolve()`, `listCapabilities()`, `registerCapability()` |
29
+ | `client.wallet` | `getBalance()`, `transfer()`, `getHistory()`, `createEscrow()`, … |
30
+ | `client.reputation` | `getProfile()`, `getReviews()`, `record()` |
31
+ | `client.markets` | `search()`, `.info.*`, `.task.*`, `.capability.*`, `.dispute.*` |
32
+ | `client.contracts` | `create()`, `sign()`, `fund()`, `submitMilestone()`, … |
33
+
34
+ ## Documentation
35
+
36
+ - [SDK Guide](https://github.com/claw-network/clawnet/blob/main/docs/SDK_GUIDE.md)
37
+ - [API Reference](https://github.com/claw-network/clawnet/blob/main/docs/API_REFERENCE.md)
38
+
39
+ ## License
40
+
41
+ MIT
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Contracts API — create, sign, fund, milestones, disputes, settlement.
3
+ */
4
+ import type { HttpClient, RequestOptions } from './http.js';
5
+ import type { Contract, CreateContractParams, CreateContractResponse, ContractActionParams, ContractFundParams, MilestoneSubmitParams, MilestoneApproveParams, MilestoneRejectParams, ContractDisputeParams, ContractDisputeResolveParams, ContractSettlementParams } from './types.js';
6
+ interface TxHashResponse {
7
+ txHash: string;
8
+ [key: string]: unknown;
9
+ }
10
+ export declare class ContractsApi {
11
+ private readonly http;
12
+ constructor(http: HttpClient);
13
+ /** List contracts (optionally filtered by status or party). */
14
+ list(params?: {
15
+ status?: string;
16
+ party?: string;
17
+ limit?: number;
18
+ offset?: number;
19
+ }, opts?: RequestOptions): Promise<{
20
+ contracts: Contract[];
21
+ total: number;
22
+ }>;
23
+ /** Get contract by ID. */
24
+ get(contractId: string, opts?: RequestOptions): Promise<Contract>;
25
+ /** Create a new service contract. */
26
+ create(params: CreateContractParams, opts?: RequestOptions): Promise<CreateContractResponse>;
27
+ /** Sign a contract. */
28
+ sign(contractId: string, params: ContractActionParams, opts?: RequestOptions): Promise<TxHashResponse>;
29
+ /** Fund a contract (lock escrow). */
30
+ fund(contractId: string, params: ContractFundParams, opts?: RequestOptions): Promise<TxHashResponse>;
31
+ /** Mark contract as completed. */
32
+ complete(contractId: string, params: ContractActionParams, opts?: RequestOptions): Promise<TxHashResponse>;
33
+ /** Submit a milestone deliverable. */
34
+ submitMilestone(contractId: string, milestoneId: string, params: MilestoneSubmitParams, opts?: RequestOptions): Promise<TxHashResponse>;
35
+ /** Approve a submitted milestone. */
36
+ approveMilestone(contractId: string, milestoneId: string, params: MilestoneApproveParams, opts?: RequestOptions): Promise<TxHashResponse>;
37
+ /** Reject a submitted milestone. */
38
+ rejectMilestone(contractId: string, milestoneId: string, params: MilestoneRejectParams, opts?: RequestOptions): Promise<TxHashResponse>;
39
+ /** Open a dispute on a contract. */
40
+ openDispute(contractId: string, params: ContractDisputeParams, opts?: RequestOptions): Promise<TxHashResponse>;
41
+ /** Resolve a contract dispute. */
42
+ resolveDispute(contractId: string, params: ContractDisputeResolveParams, opts?: RequestOptions): Promise<TxHashResponse>;
43
+ /** Execute settlement (final payout). */
44
+ settlement(contractId: string, params: ContractSettlementParams, opts?: RequestOptions): Promise<TxHashResponse>;
45
+ }
46
+ export {};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c,CAAC;CAGvH"}
@@ -0,0 +1,67 @@
1
+ export class ContractsApi {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** List contracts (optionally filtered by status or party). */
7
+ async list(params, opts) {
8
+ return this.http.get('/api/contracts', params, opts);
9
+ }
10
+ /** Get contract by ID. */
11
+ async get(contractId, opts) {
12
+ return this.http.get(`/api/contracts/${enc(contractId)}`, undefined, opts);
13
+ }
14
+ /** Create a new service contract. */
15
+ async create(params, opts) {
16
+ return this.http.post('/api/contracts', params, opts);
17
+ }
18
+ /** Sign a contract. */
19
+ async sign(contractId, params, opts) {
20
+ return this.http.post(`/api/contracts/${enc(contractId)}/sign`, params, opts);
21
+ }
22
+ /** Fund a contract (lock escrow). */
23
+ async fund(contractId, params, opts) {
24
+ return this.http.post(`/api/contracts/${enc(contractId)}/fund`, params, opts);
25
+ }
26
+ /** Mark contract as completed. */
27
+ async complete(contractId, params, opts) {
28
+ return this.http.post(`/api/contracts/${enc(contractId)}/complete`, params, opts);
29
+ }
30
+ // -------------------------------------------------------------------------
31
+ // Milestones
32
+ // -------------------------------------------------------------------------
33
+ /** Submit a milestone deliverable. */
34
+ async submitMilestone(contractId, milestoneId, params, opts) {
35
+ return this.http.post(`/api/contracts/${enc(contractId)}/milestones/${enc(milestoneId)}/complete`, params, opts);
36
+ }
37
+ /** Approve a submitted milestone. */
38
+ async approveMilestone(contractId, milestoneId, params, opts) {
39
+ return this.http.post(`/api/contracts/${enc(contractId)}/milestones/${enc(milestoneId)}/approve`, params, opts);
40
+ }
41
+ /** Reject a submitted milestone. */
42
+ async rejectMilestone(contractId, milestoneId, params, opts) {
43
+ return this.http.post(`/api/contracts/${enc(contractId)}/milestones/${enc(milestoneId)}/reject`, params, opts);
44
+ }
45
+ // -------------------------------------------------------------------------
46
+ // Disputes
47
+ // -------------------------------------------------------------------------
48
+ /** Open a dispute on a contract. */
49
+ async openDispute(contractId, params, opts) {
50
+ return this.http.post(`/api/contracts/${enc(contractId)}/dispute`, params, opts);
51
+ }
52
+ /** Resolve a contract dispute. */
53
+ async resolveDispute(contractId, params, opts) {
54
+ return this.http.post(`/api/contracts/${enc(contractId)}/dispute/resolve`, params, opts);
55
+ }
56
+ // -------------------------------------------------------------------------
57
+ // Settlement
58
+ // -------------------------------------------------------------------------
59
+ /** Execute settlement (final payout). */
60
+ async settlement(contractId, params, opts) {
61
+ return this.http.post(`/api/contracts/${enc(contractId)}/settlement`, params, opts);
62
+ }
63
+ }
64
+ function enc(s) {
65
+ return encodeURIComponent(s);
66
+ }
67
+ //# sourceMappingURL=contracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAuBA,MAAM,OAAO,YAAY;IACM;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,+DAA+D;IAC/D,KAAK,CAAC,IAAI,CACR,MAA6E,EAC7E,IAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,gBAAgB,EAChB,MAAyC,EACzC,IAAI,CACL,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,KAAK,CAAC,GAAG,CAAC,UAAkB,EAAE,IAAqB;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,kBAAkB,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACvF,CAAC;IAED,qCAAqC;IACrC,KAAK,CAAC,MAAM,CAAC,MAA4B,EAAE,IAAqB;QAC9D,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAyB,gBAAgB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;IAED,uBAAuB;IACvB,KAAK,CAAC,IAAI,CAAC,UAAkB,EAAE,MAA4B,EAAE,IAAqB;QAChF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAiB,kBAAkB,GAAG,C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G,CAAC,WAAW,CAAC,SAAS,EACzE,MAAM,EACN,IAAI,CACL,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,WAAW;IACX,4EAA4E;IAE5E,oCAAoC;IACpC,KAAK,CAAC,WAAW,CAAC,UAAkB,EAAE,MAA6B,EAAE,IAAqB;QACxF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAiB,kBAAkB,GAAG,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACnG,CAAC;IAED,kCAAkC;IAClC,KAAK,CAAC,cAAc,CAAC,UAAkB,EAAE,MAAoC,EAAE,IAAqB;QAClG,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAiB,kBAAkB,GAAG,CAAC,UAAU,CAAC,kBAAkB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAC3G,CAAC;IAED,4EAA4E;IAC5E,aAAa;IACb,4EAA4E;IAE5E,yCAAyC;IACzC,KAAK,CAAC,UAAU,CAAC,UAAkB,EAAE,MAAgC,EAAE,IAAqB;QAC1F,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAiB,kBAAkB,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACtG,CAAC;CACF;AAED,SAAS,GAAG,CAAC,CAAS;IACpB,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAC;AAC/B,CAAC"}
package/dist/dao.d.ts ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * DAO Governance API — proposals, voting, delegation, treasury, timelock.
3
+ */
4
+ import type { HttpClient, RequestOptions } from './http.js';
5
+ import type { DaoProposalListResponse, DaoProposalResponse, DaoCreateProposalParams, DaoAdvanceProposalParams, DaoVotesResponse, DaoVoteCastParams, DaoDelegateSetParams, DaoDelegateRevokeParams, DaoDelegationsResponse, DaoTreasuryResponse, DaoTreasuryDepositParams, DaoTimelockListResponse, DaoTimelockActionParams, DaoTimelockCancelParams, DaoParamsResponse, DaoTxResult, DaoProposalStatus } from './types.js';
6
+ export declare class DaoApi {
7
+ private readonly http;
8
+ constructor(http: HttpClient);
9
+ /** List proposals, optionally filtered by status. */
10
+ listProposals(status?: DaoProposalStatus, opts?: RequestOptions): Promise<DaoProposalListResponse>;
11
+ /** Get a single proposal by ID. */
12
+ getProposal(proposalId: string, opts?: RequestOptions): Promise<DaoProposalResponse>;
13
+ /** Create a new proposal. */
14
+ createProposal(params: DaoCreateProposalParams, opts?: RequestOptions): Promise<DaoTxResult>;
15
+ /** Advance a proposal to a new status. */
16
+ advanceProposal(proposalId: string, params: DaoAdvanceProposalParams, opts?: RequestOptions): Promise<DaoTxResult>;
17
+ /** Get votes for a proposal. */
18
+ getVotes(proposalId: string, opts?: RequestOptions): Promise<DaoVotesResponse>;
19
+ /** Cast a vote on a proposal. */
20
+ vote(params: DaoVoteCastParams, opts?: RequestOptions): Promise<DaoTxResult>;
21
+ /** Set delegation to another DID. */
22
+ delegate(params: DaoDelegateSetParams, opts?: RequestOptions): Promise<DaoTxResult>;
23
+ /** Revoke a delegation. */
24
+ revokeDelegation(params: DaoDelegateRevokeParams, opts?: RequestOptions): Promise<DaoTxResult>;
25
+ /** Get delegations for a DID. */
26
+ getDelegations(did: string, opts?: RequestOptions): Promise<DaoDelegationsResponse>;
27
+ /** Get current treasury status. */
28
+ getTreasury(opts?: RequestOptions): Promise<DaoTreasuryResponse>;
29
+ /** Deposit into the treasury. */
30
+ deposit(params: DaoTreasuryDepositParams, opts?: RequestOptions): Promise<DaoTxResult>;
31
+ /** List timelock entries. */
32
+ listTimelock(opts?: RequestOptions): Promise<DaoTimelockListResponse>;
33
+ /** Execute a timelocked action. */
34
+ executeTimelock(actionId: string, params: DaoTimelockActionParams, opts?: RequestOptions): Promise<DaoTxResult>;
35
+ /** Cancel a timelocked action. */
36
+ cancelTimelock(actionId: string, params: DaoTimelockCancelParams, opts?: RequestOptions): Promise<DaoTxResult>;
37
+ /** Get governance parameters and thresholds. */
38
+ getParams(opts?: RequestOptions): Promise<DaoParamsResponse>;
39
+ }
40
+ //# sourceMappingURL=dao.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dao.d.ts","sourceRoot":"","sources":["../src/dao.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,qBAAa,MAAM;IACL,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAI7C,qDAAqD;IAC/C,aAAa,CACjB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,uBAAuB,CAAC;IASnC,mCAAmC;IAC7B,WAAW,CACf,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAQ/B,6BAA6B;IACvB,cAAc,CAClB,MAAM,EAAE,uBAAuB,EAC/B,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,WAAW,CAAC;IAIvB,0CAA0C;IACpC,eAAe,CACnB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,wBAAwB,EAChC,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,WAAW,CAAC;IAUvB,gCAAgC;IAC1B,QAAQ,CACZ,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,gBAAgB,CAAC;IAQ5B,iC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+ // ── Proposals ──────────────────────────────────────────────────────
7
+ /** List proposals, optionally filtered by status. */
8
+ async listProposals(status, opts) {
9
+ const params = status ? { status } : undefined;
10
+ return this.http.get('/api/dao/proposals', params, opts);
11
+ }
12
+ /** Get a single proposal by ID. */
13
+ async getProposal(proposalId, opts) {
14
+ return this.http.get(`/api/dao/proposals/${encodeURIComponent(proposalId)}`, undefined, opts);
15
+ }
16
+ /** Create a new proposal. */
17
+ async createProposal(params, opts) {
18
+ return this.http.post('/api/dao/proposals', params, opts);
19
+ }
20
+ /** Advance a proposal to a new status. */
21
+ async advanceProposal(proposalId, params, opts) {
22
+ return this.http.post(`/api/dao/proposals/${encodeURIComponent(proposalId)}/advance`, params, opts);
23
+ }
24
+ // ── Voting ─────────────────────────────────────────────────────────
25
+ /** Get votes for a proposal. */
26
+ async getVotes(proposalId, opts) {
27
+ return this.http.get(`/api/dao/proposals/${encodeURIComponent(proposalId)}/votes`, undefined, opts);
28
+ }
29
+ /** Cast a vote on a proposal. */
30
+ async vote(params, opts) {
31
+ return this.http.post('/api/dao/vote', params, opts);
32
+ }
33
+ // ── Delegation ─────────────────────────────────────────────────────
34
+ /** Set delegation to another DID. */
35
+ async delegate(params, opts) {
36
+ return this.http.post('/api/dao/delegate', params, opts);
37
+ }
38
+ /** Revoke a delegation. */
39
+ async revokeDelegation(params, opts) {
40
+ return this.http.post('/api/dao/delegate/revoke', params, opts);
41
+ }
42
+ /** Get delegations for a DID. */
43
+ async getDelegations(did, opts) {
44
+ return this.http.get(`/api/dao/delegations/${encodeURIComponent(did)}`, undefined, opts);
45
+ }
46
+ // ── Treasury ───────────────────────────────────────────────────────
47
+ /** Get current treasury status. */
48
+ async getTreasury(opts) {
49
+ return this.http.get('/api/dao/treasury', undefined, opts);
50
+ }
51
+ /** Deposit into the treasury. */
52
+ async deposit(params, opts) {
53
+ return this.http.post('/api/dao/treasury/deposit', params, opts);
54
+ }
55
+ // ── Timelock ───────────────────────────────────────────────────────
56
+ /** List timelock entries. */
57
+ async listTimelock(opts) {
58
+ return this.http.get('/api/dao/timelock', undefined, opts);
59
+ }
60
+ /** Execute a timelocked action. */
61
+ async executeTimelock(actionId, params, opts) {
62
+ return this.http.post(`/api/dao/timelock/${encodeURIComponent(actionId)}/execute`, params, opts);
63
+ }
64
+ /** Cancel a timelocked action. */
65
+ async cancelTimelock(actionId, params, opts) {
66
+ return this.http.post(`/api/dao/timelock/${encodeURIComponent(actionId)}/cancel`, params, opts);
67
+ }
68
+ // ── Params ─────────────────────────────────────────────────────────
69
+ /** Get governance parameters and thresholds. */
70
+ async getParams(opts) {
71
+ return this.http.get('/api/dao/params', undefined, opts);
72
+ }
73
+ }
74
+ //# sourceMappingURL=dao.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dao.js","sourceRoot":"","sources":["../src/dao.ts"],"names":[],"mappings":"AAwBA,MAAM,OAAO,MAAM;IACY;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,sEAAsE;IAEtE,qDAAqD;IACrD,KAAK,CAAC,aAAa,CACjB,MAA0B,EAC1B,IAAqB;QAErB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,oBAAoB,EACpB,MAA4C,EAC5C,IAAI,CACL,CAAC;IACJ,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,WAAW,CACf,UAAkB,EAClB,IAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,sBAAsB,kBAAkB,CAAC,UAAU,CAAC,EAAE,EACtD,SAAS,EACT,IAAI,CACL,CAAC;IACJ,CAAC;IAED,6BAA6B;IAC7B,KAAK,CAAC,cAAc,CAClB,MAA+B,EAC/B,IAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAc,oBAAoB,EAAE,M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AK,CAAC,WAAW,CAAC,IAAqB;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,mBAAmB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAClF,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,OAAO,CACX,MAAgC,EAChC,IAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAc,2BAA2B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;IAED,sEAAsE;IAEtE,6BAA6B;IAC7B,KAAK,CAAC,YAAY,CAAC,IAAqB;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAA0B,mBAAmB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACtF,CAAC;IAED,mCAAmC;IACnC,KAAK,CAAC,eAAe,CACnB,QAAgB,EAChB,MAA+B,EAC/B,IAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,qBAAqB,kBAAkB,CAAC,QAAQ,CAAC,UAAU,EAC3D,MAAM,EACN,IAAI,CACL,CAAC;IACJ,CAAC;IAED,kCAAkC;IAClC,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,MAA+B,EAC/B,IAAqB;QAErB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CACnB,qBAAqB,kBAAkB,CAAC,QAAQ,CAAC,SAAS,EAC1D,MAAM,EACN,IAAI,CACL,CAAC;IACJ,CAAC;IAED,sEAAsE;IAEtE,gDAAgD;IAChD,KAAK,CAAC,SAAS,CAAC,IAAqB;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAoB,iBAAiB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;CACF"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * HTTP client for ClawNet node API.
3
+ *
4
+ * Wraps fetch with base URL, JSON serialization, and unified error handling.
5
+ */
6
+ /** Error returned by the ClawNet node API. */
7
+ export declare class ClawNetError extends Error {
8
+ readonly status: number;
9
+ readonly code: string;
10
+ constructor(status: number, code: string, message: string);
11
+ }
12
+ /** Options passed to every HTTP request. */
13
+ export interface RequestOptions {
14
+ /** Override the default timeout (ms). 0 = no timeout. */
15
+ timeout?: number;
16
+ /** Extra headers merged into the request. */
17
+ headers?: Record<string, string>;
18
+ /** AbortSignal for manual cancellation. */
19
+ signal?: AbortSignal;
20
+ }
21
+ /** Minimal configuration for the HTTP client. */
22
+ export interface HttpClientConfig {
23
+ /** Base URL of the node API, e.g. `http://127.0.0.1:9528`. */
24
+ baseUrl: string;
25
+ /** Optional API key for remote access. */
26
+ apiKey?: string;
27
+ /** Default request timeout in milliseconds (default: 30 000). */
28
+ timeout?: number;
29
+ /** Custom fetch implementation (useful for testing). */
30
+ fetch?: typeof globalThis.fetch;
31
+ }
32
+ /**
33
+ * Low-level HTTP client that all SDK modules delegate to.
34
+ */
35
+ export declare class HttpClient {
36
+ private readonly baseUrl;
37
+ private readonly apiKey?;
38
+ private readonly defaultTimeout;
39
+ private readonly _fetch;
40
+ constructor(config: HttpClientConfig);
41
+ get<T = unknown>(path: string, query?: Record<string, string | number | boolean | undefined>, opts?: RequestOptions): Promise<T>;
42
+ post<T = unknown>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
43
+ put<T = unknown>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
44
+ delete<T = unknown>(path: string, body?: unknown, opts?: RequestOptions): Promise<T>;
45
+ private buildUrl;
46
+ private request;
47
+ }
48
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8CAA8C;AAC9C,qBAAa,YAAa,SAAQ,KAAK;aAEnB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC5B,OA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,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAKjF,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAS1F,OAAO,CAAC,QAAQ;YAYF,OAAO;CA2DtB"}
package/dist/http.js ADDED
@@ -0,0 +1,117 @@
1
+ /**
2
+ * HTTP client for ClawNet node API.
3
+ *
4
+ * Wraps fetch with base URL, JSON serialization, and unified error handling.
5
+ */
6
+ /** Error returned by the ClawNet node API. */
7
+ export class ClawNetError extends Error {
8
+ status;
9
+ code;
10
+ constructor(status, code, message) {
11
+ super(message);
12
+ this.status = status;
13
+ this.code = code;
14
+ this.name = 'ClawNetError';
15
+ }
16
+ }
17
+ /**
18
+ * Low-level HTTP client that all SDK modules delegate to.
19
+ */
20
+ export class HttpClient {
21
+ baseUrl;
22
+ apiKey;
23
+ defaultTimeout;
24
+ _fetch;
25
+ constructor(config) {
26
+ // Strip trailing slash
27
+ this.baseUrl = config.baseUrl.replace(/\/+$/, '');
28
+ this.apiKey = config.apiKey;
29
+ this.defaultTimeout = config.timeout ?? 30_000;
30
+ this._fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
31
+ }
32
+ // ---------------------------------------------------------------------------
33
+ // Public helpers
34
+ // ---------------------------------------------------------------------------
35
+ async get(path, query, opts) {
36
+ const url = this.buildUrl(path, query);
37
+ return this.request('GET', url, undefined, opts);
38
+ }
39
+ async post(path, body, opts) {
40
+ const url = this.buildUrl(path);
41
+ return this.request('POST', url, body, opts);
42
+ }
43
+ async put(path, body, opts) {
44
+ const url = this.buildUrl(path);
45
+ return this.request('PUT', url, body, opts);
46
+ }
47
+ async delete(path, body, opts) {
48
+ const url = this.buildUrl(path);
49
+ return this.request('DELETE', url, body, opts);
50
+ }
51
+ // ---------------------------------------------------------------------------
52
+ // Internals
53
+ // ---------------------------------------------------------------------------
54
+ buildUrl(path, query) {
55
+ const base = `${this.baseUrl}${path.startsWith('/') ? '' : '/'}${path}`;
56
+ if (!query)
57
+ return base;
58
+ const params = new URLSearchParams();
59
+ for (const [k, v] of Object.entries(query)) {
60
+ if (v !== undefined)
61
+ params.set(k, String(v));
62
+ }
63
+ const qs = params.toString();
64
+ return qs ? `${base}?${qs}` : base;
65
+ }
66
+ async request(method, url, body, opts) {
67
+ const headers = {
68
+ accept: 'application/json',
69
+ ...opts?.headers,
70
+ };
71
+ if (this.apiKey) {
72
+ headers['x-api-key'] = this.apiKey;
73
+ }
74
+ if (body !== undefined) {
75
+ headers['content-type'] = 'application/json';
76
+ }
77
+ const timeout = opts?.timeout ?? this.defaultTimeout;
78
+ let controller;
79
+ let timeoutId;
80
+ if (timeout > 0 && !opts?.signal) {
81
+ controller = new AbortController();
82
+ timeoutId = setTimeout(() => controller.abort(), timeout);
83
+ }
84
+ try {
85
+ const res = await this._fetch(url, {
86
+ method,
87
+ headers,
88
+ body: body !== undefined ? JSON.stringify(body) : undefined,
89
+ signal: opts?.signal ?? controller?.signal,
90
+ });
91
+ // No-content responses
92
+ if (res.status === 204)
93
+ return undefined;
94
+ const text = await res.text();
95
+ let json;
96
+ try {
97
+ json = JSON.parse(text);
98
+ }
99
+ catch {
100
+ if (!res.ok) {
101
+ throw new ClawNetError(res.status, 'UNKNOWN', text || res.statusText);
102
+ }
103
+ return text;
104
+ }
105
+ if (!res.ok) {
106
+ const err = json?.error;
107
+ throw new ClawNetError(res.status, err?.code ?? 'UNKNOWN', err?.message ?? res.statusText);
108
+ }
109
+ return json;
110
+ }
111
+ finally {
112
+ if (timeoutId !== undefined)
113
+ clearTimeout(timeoutId);
114
+ }
115
+ }
116
+ }
117
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8CAA8C;AAC9C,MAAM,OAAO,YAAa,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,CAAC,CAAC;YAC1B,CAAC;YAAC,MAAM,CAAC;gBACP,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;oBACZ,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;gBACxE,CAAC;gBACD,OAAO,IAAS,CAAC;YACnB,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,GAAG,GAAI,IAAwD,EAAE,KAAK,CAAC;gBAC7E,MAAM,IAAI,YAAY,CACpB,GAAG,CAAC,MAAM,EACV,GAAG,EAAE,IAAI,IAAI,SAAS,EACtB,GAAG,EAAE,OAAO,IAAI,GAAG,CAAC,UAAU,CAC/B,CAAC;YACJ,CAAC;YAED,OAAO,IAAS,CAAC;QACnB,CAAC;gBAAS,CAAC;YACT,IAAI,SAAS,KAAK,SAAS;gBAAE,YAAY,CAAC,SAAS,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Identity (DID) API.
3
+ */
4
+ import type { HttpClient, RequestOptions } from './http.js';
5
+ import type { Identity, Capability, CapabilitiesResponse, RegisterCapabilityParams } from './types.js';
6
+ export declare class IdentityApi {
7
+ private readonly http;
8
+ constructor(http: HttpClient);
9
+ /** Get this node's identity. */
10
+ get(opts?: RequestOptions): Promise<Identity>;
11
+ /** Resolve another agent's identity by DID. */
12
+ resolve(did: string, source?: 'store' | 'log', opts?: RequestOptions): Promise<Identity>;
13
+ /** List registered capabilities. */
14
+ listCapabilities(opts?: RequestOptions): Promise<CapabilitiesResponse>;
15
+ /** Register a new capability credential. */
16
+ registerCapability(params: RegisterCapabilityParams, opts?: RequestOptions): Promise<Capability>;
17
+ }
18
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,gCAAgC;IAC1B,GAAG,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAInD,+CAA+C;IACzC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQ9F,oCAAoC;IAC9B,gBAAgB,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI5E,4CAA4C;IACtC,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;CAGvG"}
@@ -0,0 +1,23 @@
1
+ export class IdentityApi {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /** Get this node's identity. */
7
+ async get(opts) {
8
+ return this.http.get('/api/identity', undefined, opts);
9
+ }
10
+ /** Resolve another agent's identity by DID. */
11
+ async resolve(did, source, opts) {
12
+ return this.http.get(`/api/identity/${encodeURIComponent(did)}`, source ? { source } : undefined, opts);
13
+ }
14
+ /** List registered capabilities. */
15
+ async listCapabilities(opts) {
16
+ return this.http.get('/api/identity/capabilities', undefined, opts);
17
+ }
18
+ /** Register a new capability credential. */
19
+ async registerCapability(params, opts) {
20
+ return this.http.post('/api/identity/capabilities', params, opts);
21
+ }
22
+ }
23
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,WAAW;IACO;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,gCAAgC;IAChC,KAAK,CAAC,GAAG,CAAC,IAAqB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAW,eAAe,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,+CAA+C;IAC/C,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,MAAwB,EAAE,IAAqB;QACxE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAClB,iBAAiB,kBAAkB,CAAC,GAAG,CAAC,EAAE,EAC1C,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,EAC/B,IAAI,CACL,CAAC;IACJ,CAAC;IAED,oCAAoC;IACpC,KAAK,CAAC,gBAAgB,CAAC,IAAqB;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAuB,4BAA4B,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC5F,CAAC;IAED,4CAA4C;IAC5C,KAAK,CAAC,kBAAkB,CAAC,MAAgC,EAAE,IAAqB;QAC9E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAa,4BAA4B,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @claw-network/sdk — TypeScript SDK for the ClawNet node API.
3
+ *
4
+ * Usage:
5
+ * ```ts
6
+ * import { ClawNetClient } from '@claw-network/sdk';
7
+ *
8
+ * const claw = new ClawNetClient(); // defaults to http://127.0.0.1:9528
9
+ * const status = await claw.node.getStatus();
10
+ * const balance = await claw.wallet.getBalance();
11
+ * const listings = await claw.markets.search({ q: 'data' });
12
+ * ```
13
+ */
14
+ export { HttpClient, HttpClientConfig, RequestOptions, ClawNetError } from './http.js';
15
+ export { NodeApi } from './node.js';
16
+ export { IdentityApi } from './identity.js';
17
+ export { WalletApi } from './wallet.js';
18
+ export { ReputationApi } from './reputation.js';
19
+ export { MarketsApi, InfoMarketApi, TaskMarketApi, CapabilityMarketApi, MarketDisputeApi } from './markets.js';
20
+ export { ContractsApi } from './contracts.js';
21
+ export { DaoApi } from './dao.js';
22
+ export * from './types.js';
23
+ import { HttpClient, type HttpClientConfig } from './http.js';
24
+ import { NodeApi } from './node.js';
25
+ import { IdentityApi } from './identity.js';
26
+ import { WalletApi } from './wallet.js';
27
+ import { ReputationApi } from './reputation.js';
28
+ import { MarketsApi } from './markets.js';
29
+ import { ContractsApi } from './contracts.js';
30
+ import { DaoApi } from './dao.js';
31
+ /** Configuration for the top-level client. */
32
+ export interface ClientConfig extends HttpClientConfig {
33
+ }
34
+ /**
35
+ * Top-level client that exposes all ClawNet APIs.
36
+ *
37
+ * Each property is a module that maps 1-to-1 with the REST API tags.
38
+ */
39
+ export declare class ClawNetClient {
40
+ readonly http: HttpClient;
41
+ readonly node: NodeApi;
42
+ readonly identity: IdentityApi;
43
+ readonly wallet: WalletApi;
44
+ readonly reputation: ReputationApi;
45
+ readonly markets: MarketsApi;
46
+ readonly contracts: ContractsApi;
47
+ readonly dao: DaoApi;
48
+ constructor(config?: Partial<ClientConfig>);
49
+ }
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EA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