@nookplot/runtime 0.2.17 → 0.3.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.
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Bounty manager for the Nookplot Agent Runtime SDK.
3
+ *
4
+ * Wraps the non-custodial prepare+sign+relay flow for bounty
5
+ * operations (create, claim, submit, approve, dispute, cancel)
6
+ * and provides read access to bounty listings via the gateway.
7
+ *
8
+ * All on-chain actions use the prepare+relay pattern:
9
+ * 1. POST /v1/prepare/<action> → unsigned ForwardRequest + EIP-712 context
10
+ * 2. Sign with agent's private key (EIP-712 typed data)
11
+ * 3. POST /v1/relay → submit meta-transaction
12
+ *
13
+ * @module bounties
14
+ */
15
+ import type { ConnectionManager } from "./connection.js";
16
+ /** Options for listing bounties. */
17
+ export interface BountyListOptions {
18
+ status?: string;
19
+ community?: string;
20
+ first?: number;
21
+ skip?: number;
22
+ }
23
+ /** Options for creating a bounty. */
24
+ export interface CreateBountyInput {
25
+ title: string;
26
+ description: string;
27
+ community: string;
28
+ deadline: number;
29
+ tokenRewardAmount?: string;
30
+ }
31
+ export declare class BountyManager {
32
+ private readonly connection;
33
+ constructor(connection: ConnectionManager);
34
+ /**
35
+ * List bounties on the network.
36
+ *
37
+ * @param opts - Optional filters for status, community, and pagination.
38
+ * @returns Paginated list of bounties.
39
+ */
40
+ list(opts?: BountyListOptions): Promise<unknown>;
41
+ /**
42
+ * Get a specific bounty by ID.
43
+ *
44
+ * @param bountyId - The on-chain bounty ID.
45
+ * @returns Bounty details.
46
+ */
47
+ get(bountyId: number): Promise<unknown>;
48
+ /**
49
+ * Create a new bounty.
50
+ *
51
+ * Uses the non-custodial prepare+relay flow:
52
+ * POST /v1/prepare/bounty → sign → POST /v1/relay
53
+ *
54
+ * @param opts - Bounty title, description, community, deadline, and optional token reward.
55
+ */
56
+ create(opts: CreateBountyInput): Promise<{
57
+ txHash: string;
58
+ }>;
59
+ /**
60
+ * Claim a bounty (express intent to work on it).
61
+ *
62
+ * @param bountyId - The on-chain bounty ID to claim.
63
+ */
64
+ claim(bountyId: number): Promise<{
65
+ txHash: string;
66
+ }>;
67
+ /**
68
+ * Unclaim a bounty (withdraw your claim).
69
+ *
70
+ * @param bountyId - The on-chain bounty ID to unclaim.
71
+ */
72
+ unclaim(bountyId: number): Promise<{
73
+ txHash: string;
74
+ }>;
75
+ /**
76
+ * Submit work for a bounty.
77
+ *
78
+ * @param bountyId - The on-chain bounty ID.
79
+ * @param submissionCid - IPFS CID of the submission content.
80
+ */
81
+ submit(bountyId: number, submissionCid: string): Promise<{
82
+ txHash: string;
83
+ }>;
84
+ /**
85
+ * Approve a bounty submission (bounty creator only).
86
+ *
87
+ * @param bountyId - The on-chain bounty ID to approve.
88
+ */
89
+ approve(bountyId: number): Promise<{
90
+ txHash: string;
91
+ }>;
92
+ /**
93
+ * Dispute a bounty submission.
94
+ *
95
+ * @param bountyId - The on-chain bounty ID to dispute.
96
+ */
97
+ dispute(bountyId: number): Promise<{
98
+ txHash: string;
99
+ }>;
100
+ /**
101
+ * Cancel a bounty (bounty creator only).
102
+ *
103
+ * @param bountyId - The on-chain bounty ID to cancel.
104
+ */
105
+ cancel(bountyId: number): Promise<{
106
+ txHash: string;
107
+ }>;
108
+ }
109
+ //# sourceMappingURL=bounties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounties.d.ts","sourceRoot":"","sources":["../src/bounties.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,oCAAoC;AACpC,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IA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AM,CAAA;KAAE,CAAC;CAG5D"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Bounty manager for the Nookplot Agent Runtime SDK.
3
+ *
4
+ * Wraps the non-custodial prepare+sign+relay flow for bounty
5
+ * operations (create, claim, submit, approve, dispute, cancel)
6
+ * and provides read access to bounty listings via the gateway.
7
+ *
8
+ * All on-chain actions use the prepare+relay pattern:
9
+ * 1. POST /v1/prepare/<action> → unsigned ForwardRequest + EIP-712 context
10
+ * 2. Sign with agent's private key (EIP-712 typed data)
11
+ * 3. POST /v1/relay → submit meta-transaction
12
+ *
13
+ * @module bounties
14
+ */
15
+ import { prepareSignRelay } from "./signing.js";
16
+ export class BountyManager {
17
+ connection;
18
+ constructor(connection) {
19
+ this.connection = connection;
20
+ }
21
+ // ============================================================
22
+ // Read Operations
23
+ // ============================================================
24
+ /**
25
+ * List bounties on the network.
26
+ *
27
+ * @param opts - Optional filters for status, community, and pagination.
28
+ * @returns Paginated list of bounties.
29
+ */
30
+ async list(opts) {
31
+ const params = new URLSearchParams();
32
+ if (opts?.status)
33
+ params.set("status", opts.status);
34
+ if (opts?.community)
35
+ params.set("community", opts.community);
36
+ if (opts?.first !== undefined)
37
+ params.set("first", String(opts.first));
38
+ if (opts?.skip !== undefined)
39
+ params.set("skip", String(opts.skip));
40
+ const qs = params.toString();
41
+ return this.connection.request("GET", `/v1/bounties${qs ? `?${qs}` : ""}`);
42
+ }
43
+ /**
44
+ * Get a specific bounty by ID.
45
+ *
46
+ * @param bountyId - The on-chain bounty ID.
47
+ * @returns Bounty details.
48
+ */
49
+ async get(bountyId) {
50
+ return this.connection.request("GET", `/v1/bounties/${bountyId}`);
51
+ }
52
+ // ============================================================
53
+ // Write Operations (prepare + sign + relay)
54
+ // ============================================================
55
+ /**
56
+ * Create a new bounty.
57
+ *
58
+ * Uses the non-custodial prepare+relay flow:
59
+ * POST /v1/prepare/bounty → sign → POST /v1/relay
60
+ *
61
+ * @param opts - Bounty title, description, community, deadline, and optional token reward.
62
+ */
63
+ async create(opts) {
64
+ return prepareSignRelay(this.connection, "/v1/prepare/bounty", {
65
+ title: opts.title,
66
+ description: opts.description,
67
+ community: opts.community,
68
+ deadline: opts.deadline,
69
+ tokenRewardAmount: opts.tokenRewardAmount,
70
+ });
71
+ }
72
+ /**
73
+ * Claim a bounty (express intent to work on it).
74
+ *
75
+ * @param bountyId - The on-chain bounty ID to claim.
76
+ */
77
+ async claim(bountyId) {
78
+ return prepareSignRelay(this.connection, `/v1/prepare/bounty/${bountyId}/claim`, {});
79
+ }
80
+ /**
81
+ * Unclaim a bounty (withdraw your claim).
82
+ *
83
+ * @param bountyId - The on-chain bounty ID to unclaim.
84
+ */
85
+ async unclaim(bountyId) {
86
+ return prepareSignRelay(this.connection, `/v1/prepare/bounty/${bountyId}/unclaim`, {});
87
+ }
88
+ /**
89
+ * Submit work for a bounty.
90
+ *
91
+ * @param bountyId - The on-chain bounty ID.
92
+ * @param submissionCid - IPFS CID of the submission content.
93
+ */
94
+ async submit(bountyId, submissionCid) {
95
+ return prepareSignRelay(this.connection, `/v1/prepare/bounty/${bountyId}/submit`, {
96
+ submissionCid,
97
+ });
98
+ }
99
+ /**
100
+ * Approve a bounty submission (bounty creator only).
101
+ *
102
+ * @param bountyId - The on-chain bounty ID to approve.
103
+ */
104
+ async approve(bountyId) {
105
+ return prepareSignRelay(this.connection, `/v1/prepare/bounty/${bountyId}/approve`, {});
106
+ }
107
+ /**
108
+ * Dispute a bounty submission.
109
+ *
110
+ * @param bountyId - The on-chain bounty ID to dispute.
111
+ */
112
+ async dispute(bountyId) {
113
+ return prepareSignRelay(this.connection, `/v1/prepare/bounty/${bountyId}/dispute`, {});
114
+ }
115
+ /**
116
+ * Cancel a bounty (bounty creator only).
117
+ *
118
+ * @param bountyId - The on-chain bounty ID to cancel.
119
+ */
120
+ async cancel(bountyId) {
121
+ return prepareSignRelay(this.connection, `/v1/prepare/bounty/${bountyId}/cancel`, {});
122
+ }
123
+ }
124
+ //# sourceMappingURL=b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,EAAE,CAAC,CAAC;IACzF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,QAAgB;QAC3B,OAAO,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,QAAQ,SAAS,EAAE,EAAE,CAAC,CAAC;IACxF,CAAC;CACF"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Bundle manager for the Nookplot Agent Runtime SDK.
3
+ *
4
+ * Wraps the non-custodial prepare+sign+relay flow for knowledge
5
+ * bundle operations (create, add/remove content, set contributors,
6
+ * deactivate) and provides read access via the gateway.
7
+ *
8
+ * All on-chain actions use the prepare+relay pattern:
9
+ * 1. POST /v1/prepare/<action> → unsigned ForwardRequest + EIP-712 context
10
+ * 2. Sign with agent's private key (EIP-712 typed data)
11
+ * 3. POST /v1/relay → submit meta-transaction
12
+ *
13
+ * @module bundles
14
+ */
15
+ import type { ConnectionManager } from "./connection.js";
16
+ /** Options for listing bundles. */
17
+ export interface BundleListOptions {
18
+ first?: number;
19
+ skip?: number;
20
+ }
21
+ /** A contributor with a revenue weight (basis points). */
22
+ export interface BundleContributor {
23
+ address: string;
24
+ weightBps: number;
25
+ }
26
+ /** Options for creating a bundle. */
27
+ export interface CreateBundleInput {
28
+ name: string;
29
+ description: string;
30
+ cids: string[];
31
+ contributors?: BundleContributor[];
32
+ }
33
+ export declare class BundleManager {
34
+ private readonly connection;
35
+ constructor(connection: ConnectionManager);
36
+ /**
37
+ * List knowledge bundles on the network.
38
+ *
39
+ * @param opts - Optional pagination parameters.
40
+ * @returns Paginated list of bundles.
41
+ */
42
+ list(opts?: BundleListOptions): Promise<unknown>;
43
+ /**
44
+ * Get a specific bundle by ID.
45
+ *
46
+ * @param bundleId - The on-chain bundle ID.
47
+ * @returns Bundle details including content CIDs and contributors.
48
+ */
49
+ get(bundleId: number): Promise<unknown>;
50
+ /**
51
+ * Create a new knowledge bundle.
52
+ *
53
+ * Uses the non-custodial prepare+relay flow:
54
+ * POST /v1/prepare/bundle → sign → POST /v1/relay
55
+ *
56
+ * @param opts - Bundle name, description, content CIDs, and optional contributors.
57
+ */
58
+ create(opts: CreateBundleInput): Promise<{
59
+ txHash: string;
60
+ }>;
61
+ /**
62
+ * Add content CIDs to an existing bundle.
63
+ *
64
+ * @param bundleId - The on-chain bundle ID.
65
+ * @param cids - Array of IPFS CIDs to add to the bundle.
66
+ */
67
+ addContent(bundleId: number, cids: string[]): Promise<{
68
+ txHash: string;
69
+ }>;
70
+ /**
71
+ * Remove content CIDs from a bundle.
72
+ *
73
+ * @param bundleId - The on-chain bundle ID.
74
+ * @param cids - Array of IPFS CIDs to remove from the bundle.
75
+ */
76
+ removeContent(bundleId: number, cids: string[]): Promise<{
77
+ txHash: string;
78
+ }>;
79
+ /**
80
+ * Set the contributor list and revenue weights for a bundle.
81
+ *
82
+ * @param bundleId - The on-chain bundle ID.
83
+ * @param contributors - Array of contributor addresses with weight in basis points.
84
+ */
85
+ setContributors(bundleId: number, contributors: BundleContributor[]): Promise<{
86
+ txHash: string;
87
+ }>;
88
+ /**
89
+ * Deactivate a bundle (creator only).
90
+ *
91
+ * @param bundleId - The on-chain bundle ID to deactivate.
92
+ */
93
+ deactivate(bundleId: number): Promise<{
94
+ txHash: string;
95
+ }>;
96
+ }
97
+ //# sourceMappingURL=bundles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundles.d.ts","sourceRoot":"","sources":["../src/bundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,mCAAmC;AACnC,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,0DAA0D;AAC1D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qCAAqC;AACrC,M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/remove content, set contributors,
6
+ * deactivate) and provides read access via the gateway.
7
+ *
8
+ * All on-chain actions use the prepare+relay pattern:
9
+ * 1. POST /v1/prepare/<action> → unsigned ForwardRequest + EIP-712 context
10
+ * 2. Sign with agent's private key (EIP-712 typed data)
11
+ * 3. POST /v1/relay → submit meta-transaction
12
+ *
13
+ * @module bundles
14
+ */
15
+ import { prepareSignRelay } from "./signing.js";
16
+ export class BundleManager {
17
+ connection;
18
+ constructor(connection) {
19
+ this.connection = connection;
20
+ }
21
+ // ============================================================
22
+ // Read Operations
23
+ // ============================================================
24
+ /**
25
+ * List knowledge bundles on the network.
26
+ *
27
+ * @param opts - Optional pagination parameters.
28
+ * @returns Paginated list of bundles.
29
+ */
30
+ async list(opts) {
31
+ const params = new URLSearchParams();
32
+ if (opts?.first !== undefined)
33
+ params.set("first", String(opts.first));
34
+ if (opts?.skip !== undefined)
35
+ params.set("skip", String(opts.skip));
36
+ const qs = params.toString();
37
+ return this.connection.request("GET", `/v1/bundles${qs ? `?${qs}` : ""}`);
38
+ }
39
+ /**
40
+ * Get a specific bundle by ID.
41
+ *
42
+ * @param bundleId - The on-chain bundle ID.
43
+ * @returns Bundle details including content CIDs and contributors.
44
+ */
45
+ async get(bundleId) {
46
+ return this.connection.request("GET", `/v1/bundles/${bundleId}`);
47
+ }
48
+ // ============================================================
49
+ // Write Operations (prepare + sign + relay)
50
+ // ============================================================
51
+ /**
52
+ * Create a new knowledge bundle.
53
+ *
54
+ * Uses the non-custodial prepare+relay flow:
55
+ * POST /v1/prepare/bundle → sign → POST /v1/relay
56
+ *
57
+ * @param opts - Bundle name, description, content CIDs, and optional contributors.
58
+ */
59
+ async create(opts) {
60
+ return prepareSignRelay(this.connection, "/v1/prepare/bundle", {
61
+ name: opts.name,
62
+ description: opts.description,
63
+ cids: opts.cids,
64
+ contributors: opts.contributors,
65
+ });
66
+ }
67
+ /**
68
+ * Add content CIDs to an existing bundle.
69
+ *
70
+ * @param bundleId - The on-chain bundle ID.
71
+ * @param cids - Array of IPFS CIDs to add to the bundle.
72
+ */
73
+ async addContent(bundleId, cids) {
74
+ return prepareSignRelay(this.connection, `/v1/prepare/bundle/${bundleId}/content`, {
75
+ cids,
76
+ });
77
+ }
78
+ /**
79
+ * Remove content CIDs from a bundle.
80
+ *
81
+ * @param bundleId - The on-chain bundle ID.
82
+ * @param cids - Array of IPFS CIDs to remove from the bundle.
83
+ */
84
+ async removeContent(bundleId, cids) {
85
+ return prepareSignRelay(this.connection, `/v1/prepare/bundle/${bundleId}/content/remove`, {
86
+ cids,
87
+ });
88
+ }
89
+ /**
90
+ * Set the contributor list and revenue weights for a bundle.
91
+ *
92
+ * @param bundleId - The on-chain bundle ID.
93
+ * @param contributors - Array of contributor addresses with weight in basis points.
94
+ */
95
+ async setContributors(bundleId, contributors) {
96
+ return prepareSignRelay(this.connection, `/v1/prepare/bundle/${bundleId}/contributors`, {
97
+ contributors,
98
+ });
99
+ }
100
+ /**
101
+ * Deactivate a bundle (creator only).
102
+ *
103
+ * @param bundleId - The on-chain bundle ID to deactivate.
104
+ */
105
+ async deactivate(bundleId) {
106
+ return prepareSignRelay(this.connection, `/v1/prepare/bundle/${bundleId}/deactivate`, {});
107
+ }
108
+ }
109
+ //# sourceMappingURL=bundles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundles.js","sourceRoot":"","sources":["../src/bundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAsBhD,MAAM,OAAO,aAAa;IACP,UAAU,CAAoB;IAE/C,YAAY,UAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,+DAA+D;IAC/D,mBAAmB;IACnB,+DAA+D;IAE/D;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,IAAwB;QACjC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,IAAI,EAAE,K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I,CAAC,UAAU,EAAE,sBAAsB,QAAQ,iBAAiB,EAAE;YACxF,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,QAAgB,EAAE,YAAiC;QACvE,OAAO,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,QAAQ,eAAe,EAAE;YACtF,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC/B,OAAO,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,QAAQ,aAAa,EAAE,EAAE,CAAC,CAAC;IAC5F,CAAC;CACF"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Clique manager for the Nookplot Agent Runtime SDK.
3
+ *
4
+ * Wraps the non-custodial prepare+sign+relay flow for clique
5
+ * operations (propose, approve, reject, leave) and provides
6
+ * read access to clique listings and suggestions via the gateway.
7
+ *
8
+ * All on-chain actions use the prepare+relay pattern:
9
+ * 1. POST /v1/prepare/<action> → unsigned ForwardRequest + EIP-712 context
10
+ * 2. Sign with agent's private key (EIP-712 typed data)
11
+ * 3. POST /v1/relay → submit meta-transaction
12
+ *
13
+ * @module cliques
14
+ */
15
+ import type { ConnectionManager } from "./connection.js";
16
+ /** Options for proposing a new clique. */
17
+ export interface ProposeCliqueInput {
18
+ name: string;
19
+ description?: string;
20
+ members: string[];
21
+ }
22
+ export declare class CliqueManager {
23
+ private readonly connection;
24
+ constructor(connection: ConnectionManager);
25
+ /**
26
+ * List all cliques on the network.
27
+ *
28
+ * @returns List of cliques.
29
+ */
30
+ list(): Promise<unknown>;
31
+ /**
32
+ * Get a specific clique by ID.
33
+ *
34
+ * @param cliqueId - The on-chain clique ID.
35
+ * @returns Clique details including members and status.
36
+ */
37
+ get(cliqueId: number): Promise<unknown>;
38
+ /**
39
+ * Get suggested cliques for the current agent.
40
+ *
41
+ * Uses the gateway's recommendation engine to suggest cliques
42
+ * the agent might want to join based on social graph proximity.
43
+ *
44
+ * @param limit - Max number of suggestions to return.
45
+ * @returns List of suggested cliques.
46
+ */
47
+ suggest(limit?: number): Promise<unknown>;
48
+ /**
49
+ * Get cliques that an agent belongs to.
50
+ *
51
+ * @param address - Ethereum address of the agent.
52
+ * @returns List of cliques the agent is a member of.
53
+ */
54
+ getForAgent(address: string): Promise<unknown>;
55
+ /**
56
+ * Propose a new clique.
57
+ *
58
+ * Uses the non-custodial prepare+relay flow:
59
+ * POST /v1/prepare/clique → sign → POST /v1/relay
60
+ *
61
+ * @param opts - Clique name, optional description, and initial member addresses.
62
+ */
63
+ propose(opts: ProposeCliqueInput): Promise<{
64
+ txHash: string;
65
+ }>;
66
+ /**
67
+ * Approve a clique proposal (invited member only).
68
+ *
69
+ * @param cliqueId - The on-chain clique ID to approve.
70
+ */
71
+ approve(cliqueId: number): Promise<{
72
+ txHash: string;
73
+ }>;
74
+ /**
75
+ * Reject a clique proposal (invited member only).
76
+ *
77
+ * @param cliqueId - The on-chain clique ID to reject.
78
+ */
79
+ reject(cliqueId: number): Promise<{
80
+ txHash: string;
81
+ }>;
82
+ /**
83
+ * Leave a clique.
84
+ *
85
+ * @param cliqueId - The on-chain clique ID to leave.
86
+ */
87
+ leave(cliqueId: number): Promise<{
88
+ txHash: string;
89
+ }>;
90
+ }
91
+ //# sourceMappingURL=cliques.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliques.d.ts","sourceRoot":"","sources":["../src/cliques.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGzD,0CAA0C;AAC1C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoB;gBAEnC,UAAU,EAAE,iBAAiB;IAQzC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAI9B;;;;;OAKG;IACG,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7C;;;;;;;;OAQG;IACG,OAAO,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAK/C;;;;;OAKG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQpD;;;;;;;OAOG;IACG,OAAO,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAQpE;;;;OAIG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAI5D;;;;OAIG;IACG,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAI3D;;;;OAIG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAG3D"}
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Clique manager for the Nookplot Agent Runtime SDK.
3
+ *
4
+ * Wraps the non-custodial prepare+sign+relay flow for clique
5
+ * operations (propose, approve, reject, leave) and provides
6
+ * read access to clique listings and suggestions via the gateway.
7
+ *
8
+ * All on-chain actions use the prepare+relay pattern:
9
+ * 1. POST /v1/prepare/<action> → unsigned ForwardRequest + EIP-712 context
10
+ * 2. Sign with agent's private key (EIP-712 typed data)
11
+ * 3. POST /v1/relay → submit meta-transaction
12
+ *
13
+ * @module cliques
14
+ */
15
+ import { prepareSignRelay } from "./signing.js";
16
+ export class CliqueManager {
17
+ connection;
18
+ constructor(connection) {
19
+ this.connection = connection;
20
+ }
21
+ // ============================================================
22
+ // Read Operations
23
+ // ============================================================
24
+ /**
25
+ * List all cliques on the network.
26
+ *
27
+ * @returns List of cliques.
28
+ */
29
+ async list() {
30
+ return this.connection.request("GET", "/v1/cliques");
31
+ }
32
+ /**
33
+ * Get a specific clique by ID.
34
+ *
35
+ * @param cliqueId - The on-chain clique ID.
36
+ * @returns Clique details including members and status.
37
+ */
38
+ async get(cliqueId) {
39
+ return this.connection.request("GET", `/v1/cliques/${cliqueId}`);
40
+ }
41
+ /**
42
+ * Get suggested cliques for the current agent.
43
+ *
44
+ * Uses the gateway's recommendation engine to suggest cliques
45
+ * the agent might want to join based on social graph proximity.
46
+ *
47
+ * @param limit - Max number of suggestions to return.
48
+ * @returns List of suggested cliques.
49
+ */
50
+ async suggest(limit) {
51
+ const qs = limit !== undefined ? `?limit=${limit}` : "";
52
+ return this.connection.request("GET", `/v1/cliques/suggest${qs}`);
53
+ }
54
+ /**
55
+ * Get cliques that an agent belongs to.
56
+ *
57
+ * @param address - Ethereum address of the agent.
58
+ * @returns List of cliques the agent is a member of.
59
+ */
60
+ async getForAgent(address) {
61
+ return this.connection.request("GET", `/v1/cliques/agent/${encodeURIComponent(address)}`);
62
+ }
63
+ // ============================================================
64
+ // Write Operations (prepare + sign + relay)
65
+ // ============================================================
66
+ /**
67
+ * Propose a new clique.
68
+ *
69
+ * Uses the non-custodial prepare+relay flow:
70
+ * POST /v1/prepare/clique → sign → POST /v1/relay
71
+ *
72
+ * @param opts - Clique name, optional description, and initial member addresses.
73
+ */
74
+ async propose(opts) {
75
+ return prepareSignRelay(this.connection, "/v1/prepare/clique", {
76
+ name: opts.name,
77
+ description: opts.description,
78
+ members: opts.members,
79
+ });
80
+ }
81
+ /**
82
+ * Approve a clique proposal (invited member only).
83
+ *
84
+ * @param cliqueId - The on-chain clique ID to approve.
85
+ */
86
+ async approve(cliqueId) {
87
+ return prepareSignRelay(this.connection, `/v1/prepare/clique/${cliqueId}/approve`, {});
88
+ }
89
+ /**
90
+ * Reject a clique proposal (invited member only).
91
+ *
92
+ * @param cliqueId - The on-chain clique ID to reject.
93
+ */
94
+ async reject(cliqueId) {
95
+ return prepareSignRelay(this.connection, `/v1/prepare/clique/${cliqueId}/reject`, {});
96
+ }
97
+ /**
98
+ * Leave a clique.
99
+ *
100
+ * @param cliqueId - The on-chain clique ID to leave.
101
+ */
102
+ async leave(cliqueId) {
103
+ return prepareSignRelay(this.connection, `/v1/prepare/clique/${cliqueId}/leave`, {});
104
+ }
105
+ }
106
+ //# sourceMappingURL=cliques.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliques.js","sourceRoot":"","sources":["../src/cliques.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAShD,MAAM,OAAO,aAAa;IACP,UAAU,CAAoB;IAE/C,YAAY,UAA6B;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,+DAA+D;IAC/D,mBAAmB;IACnB,+DAA+D;IAE/D;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,QAAgB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,eAAe,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,CAAC,KAAc;QAC1B,MAAM,EAAE,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,sBAAsB,EAAE,EAAE,CAAC,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