@openserv-labs/client 2.0.2 → 2.1.2

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.
@@ -1,5 +1,5 @@
1
1
  import type { PlatformClient } from "./client";
2
- import type { WorkflowConfig, TaskDefinition, EdgeDefinition, Edge } from "./types";
2
+ import type { WorkflowConfig, TaskDefinition, EdgeDefinition, Edge, ImportWeb3WalletRequest, SignFeedbackAuthResponse, Web3Wallet } from "./types";
3
3
  import type { TriggerConfig } from "./triggers-api";
4
4
  import { Workflow } from "./workflow";
5
5
  /**
@@ -159,5 +159,114 @@ export declare class WorkflowsAPI {
159
159
  private getTriggerName;
160
160
  private resolveEdgeRef;
161
161
  private resolveNodeId;
162
+ /**
163
+ * Get the web3 wallet associated with a workspace.
164
+ *
165
+ * @param params - Parameters
166
+ * @param params.id - The workflow (workspace) ID
167
+ * @returns The web3 wallet details
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const wallet = await client.workflows.getWallet({ id: 123 });
172
+ * console.log(wallet.address, wallet.deployed, wallet.erc8004AgentId);
173
+ * ```
174
+ */
175
+ getWallet(params: {
176
+ id: number;
177
+ }): Promise<Web3Wallet>;
178
+ /**
179
+ * Generate a new web3 wallet for a workspace.
180
+ *
181
+ * Creates a fresh wallet with a server-generated private key. The wallet
182
+ * is stored securely on the platform and used for ERC-8004 operations.
183
+ * A workspace can only have one web3 wallet.
184
+ *
185
+ * @param params - Parameters
186
+ * @param params.id - The workflow (workspace) ID
187
+ * @returns The generated web3 wallet
188
+ * @throws Error if the workspace already has a web3 wallet
189
+ *
190
+ * @example
191
+ * ```typescript
192
+ * const wallet = await client.workflows.generateWallet({ id: 123 });
193
+ * console.log('Wallet address:', wallet.address);
194
+ * ```
195
+ */
196
+ generateWallet(params: {
197
+ id: number;
198
+ }): Promise<Web3Wallet>;
199
+ /**
200
+ * Import an existing web3 wallet into a workspace.
201
+ *
202
+ * Use this to associate a pre-existing wallet (e.g., one that already has
203
+ * an ERC-8004 registration) with a workspace.
204
+ * A workspace can only have one web3 wallet.
205
+ *
206
+ * @param params - Import parameters
207
+ * @param params.id - The workflow (workspace) ID
208
+ * @param params.address - Wallet address
209
+ * @param params.network - Network name (e.g., "base")
210
+ * @param params.chainId - Chain ID (e.g., 8453)
211
+ * @param params.privateKey - Wallet private key
212
+ * @returns The imported web3 wallet
213
+ * @throws Error if the workspace already has a web3 wallet
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * const wallet = await client.workflows.importWallet({
218
+ * id: 123,
219
+ * address: '0x...',
220
+ * network: 'base',
221
+ * chainId: 8453,
222
+ * privateKey: '0x...',
223
+ * });
224
+ * ```
225
+ */
226
+ importWallet(params: ImportWeb3WalletRequest & {
227
+ id: number;
228
+ }): Promise<Web3Wallet>;
229
+ /**
230
+ * Delete the web3 wallet associated with a workspace.
231
+ *
232
+ * This removes the wallet record from the platform. Note that the on-chain
233
+ * ERC-8004 registration is not affected -- this only removes the platform's
234
+ * association.
235
+ *
236
+ * @param params - Parameters
237
+ * @param params.id - The workflow (workspace) ID
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * await client.workflows.deleteWallet({ id: 123 });
242
+ * ```
243
+ */
244
+ deleteWallet(params: {
245
+ id: number;
246
+ }): Promise<void>;
247
+ /**
248
+ * Sign a feedback auth message for a buyer address.
249
+ *
250
+ * This is used for the ERC-8004 reputation system. The workspace's web3 wallet
251
+ * signs an auth message that allows a buyer to submit feedback/reputation
252
+ * for the agent on-chain.
253
+ *
254
+ * @param params - Parameters
255
+ * @param params.id - The workflow (workspace) ID
256
+ * @param params.buyerAddress - The buyer's wallet address to authorize
257
+ * @returns Object containing the signed feedback auth
258
+ *
259
+ * @example
260
+ * ```typescript
261
+ * const { signature } = await client.workflows.signFeedbackAuth({
262
+ * id: 123,
263
+ * buyerAddress: '0xBuyer...',
264
+ * });
265
+ * ```
266
+ */
267
+ signFeedbackAuth(params: {
268
+ id: number;
269
+ buyerAddress: string;
270
+ }): Promise<SignFeedbackAuthResponse>;
162
271
  }
163
272
  //# sourceMappingURL=workflows-api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflows-api.d.ts","sourceRoot":"","sources":["../src/workflows-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EACV,cAAc,EAEd,cAAc,EACd,cAAc,EACd,IAAI,EAGL,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,cAAc;IAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACG,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiCvD;;;;;OAKG;IACG,GAAG,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IA8C7D;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAWjC;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE;QACnB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWrB;;;;OAIG;IACG,MAAM,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI5D;;;;;;;OAOG;IACG,UAAU,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,G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AAC,EAAE,cAAc,EAAE,CAAC;QACzB,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;KAC1B,GAAG,OAAO,CAAC,IAAI,CAAC;YAWH,YAAY;IAqP1B,OAAO,CAAC,wBAAwB;IAWhC,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,cAAc;IAMtB,OAAO,CAAC,aAAa;IAarB;;;;;;;;;;;;OAYG;IACG,SAAS,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAI5D;;;;;;;;;;;;;;;;;OAiBG;IACG,cAAc,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAMjE;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,YAAY,CAChB,MAAM,EAAE,uBAAuB,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAC/C,OAAO,CAAC,UAAU,CAAC;IAKtB;;;;;;;;;;;;;;OAcG;IACG,YAAY,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD;;;;;;;;;;;;;;;;;;;OAmBG;IACG,gBAAgB,CAAC,MAAM,EAAE;QAC7B,EAAE,EAAE,MAAM,CAAC;QACX,YAAY,EAAE,MAAM,CAAC;KACtB,GAAG,OAAO,CAAC,wBAAwB,CAAC;CAMtC"}
@@ -474,5 +474,117 @@ class WorkflowsAPI {
474
474
  }
475
475
  return `${ref.type}-${ref.id}`;
476
476
  }
477
+ // ===========================================================================
478
+ // Web3 Wallet Management
479
+ // ===========================================================================
480
+ /**
481
+ * Get the web3 wallet associated with a workspace.
482
+ *
483
+ * @param params - Parameters
484
+ * @param params.id - The workflow (workspace) ID
485
+ * @returns The web3 wallet details
486
+ *
487
+ * @example
488
+ * ```typescript
489
+ * const wallet = await client.workflows.getWallet({ id: 123 });
490
+ * console.log(wallet.address, wallet.deployed, wallet.erc8004AgentId);
491
+ * ```
492
+ */
493
+ async getWallet(params) {
494
+ return this.client.get(`/workspaces/${params.id}/web3`);
495
+ }
496
+ /**
497
+ * Generate a new web3 wallet for a workspace.
498
+ *
499
+ * Creates a fresh wallet with a server-generated private key. The wallet
500
+ * is stored securely on the platform and used for ERC-8004 operations.
501
+ * A workspace can only have one web3 wallet.
502
+ *
503
+ * @param params - Parameters
504
+ * @param params.id - The workflow (workspace) ID
505
+ * @returns The generated web3 wallet
506
+ * @throws Error if the workspace already has a web3 wallet
507
+ *
508
+ * @example
509
+ * ```typescript
510
+ * const wallet = await client.workflows.generateWallet({ id: 123 });
511
+ * console.log('Wallet address:', wallet.address);
512
+ * ```
513
+ */
514
+ async generateWallet(params) {
515
+ return this.client.post(`/workspaces/${params.id}/web3/generate`);
516
+ }
517
+ /**
518
+ * Import an existing web3 wallet into a workspace.
519
+ *
520
+ * Use this to associate a pre-existing wallet (e.g., one that already has
521
+ * an ERC-8004 registration) with a workspace.
522
+ * A workspace can only have one web3 wallet.
523
+ *
524
+ * @param params - Import parameters
525
+ * @param params.id - The workflow (workspace) ID
526
+ * @param params.address - Wallet address
527
+ * @param params.network - Network name (e.g., "base")
528
+ * @param params.chainId - Chain ID (e.g., 8453)
529
+ * @param params.privateKey - Wallet private key
530
+ * @returns The imported web3 wallet
531
+ * @throws Error if the workspace already has a web3 wallet
532
+ *
533
+ * @example
534
+ * ```typescript
535
+ * const wallet = await client.workflows.importWallet({
536
+ * id: 123,
537
+ * address: '0x...',
538
+ * network: 'base',
539
+ * chainId: 8453,
540
+ * privateKey: '0x...',
541
+ * });
542
+ * ```
543
+ */
544
+ async importWallet(params) {
545
+ const { id, ...body } = params;
546
+ return this.client.post(`/workspaces/${id}/web3/import`, body);
547
+ }
548
+ /**
549
+ * Delete the web3 wallet associated with a workspace.
550
+ *
551
+ * This removes the wallet record from the platform. Note that the on-chain
552
+ * ERC-8004 registration is not affected -- this only removes the platform's
553
+ * association.
554
+ *
555
+ * @param params - Parameters
556
+ * @param params.id - The workflow (workspace) ID
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * await client.workflows.deleteWallet({ id: 123 });
561
+ * ```
562
+ */
563
+ async deleteWallet(params) {
564
+ await this.client.delete(`/workspaces/${params.id}/web3`);
565
+ }
566
+ /**
567
+ * Sign a feedback auth message for a buyer address.
568
+ *
569
+ * This is used for the ERC-8004 reputation system. The workspace's web3 wallet
570
+ * signs an auth message that allows a buyer to submit feedback/reputation
571
+ * for the agent on-chain.
572
+ *
573
+ * @param params - Parameters
574
+ * @param params.id - The workflow (workspace) ID
575
+ * @param params.buyerAddress - The buyer's wallet address to authorize
576
+ * @returns Object containing the signed feedback auth
577
+ *
578
+ * @example
579
+ * ```typescript
580
+ * const { signature } = await client.workflows.signFeedbackAuth({
581
+ * id: 123,
582
+ * buyerAddress: '0xBuyer...',
583
+ * });
584
+ * ```
585
+ */
586
+ async signFeedbackAuth(params) {
587
+ return this.client.post(`/workspaces/${params.id}/web3/sign-feedback-auth`, { buyerAddress: params.buyerAddress });
588
+ }
477
589
  }
478
590
  exports.WorkflowsAPI = WorkflowsAPI;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openserv-labs/client",
3
- "version": "2.0.2",
3
+ "version": "2.1.2",
4
4
  "description": "OpenServ Platform Client - Manage agents, workflows, tasks, and triggers via the OpenServ API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -39,6 +39,7 @@
39
39
  "dependencies": {
40
40
  "axios": "^1.6.8",
41
41
  "ethers": "^6.16.0",
42
+ "pinata": "^2.5.1",
42
43
  "viem": "^2.45.1",
43
44
  "x402-fetch": "^1.1.0"
44
45
  },