@openserv-labs/client 1.1.4 → 2.0.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 CHANGED
@@ -145,12 +145,23 @@ await client.workflows.delete({ id: 789 })
145
145
  // Set workflow to running state
146
146
  await client.workflows.setRunning({ id: 789 })
147
147
 
148
- // Sync workflow configuration
148
+ // Create a fully configured workflow with triggers, tasks, and auto-generated edges
149
+ const pipeline = await client.workflows.create({
150
+ name: 'Data Pipeline',
151
+ goal: 'Process and analyze data',
152
+ triggers: [triggers.webhook({ waitForCompletion: true, timeout: 300 })],
153
+ tasks: [
154
+ { name: 'ingest', agentId: 123, description: 'Ingest the data' },
155
+ { name: 'analyze', agentId: 456, description: 'Analyze the results' }
156
+ ]
157
+ // Edges auto-generated: trigger -> ingest -> analyze
158
+ })
159
+
160
+ // Sync workflow configuration (update existing)
149
161
  await client.workflows.sync({
150
162
  id: 789,
151
- triggers: [{ name: 'webhook', type: 'webhook' }],
152
- tasks: [{ name: 'process', agentId: 123, description: 'Process data' }],
153
- edges: [{ from: 'trigger:webhook', to: 'task:process' }]
163
+ triggers: [triggers.webhook({ waitForCompletion: true })],
164
+ tasks: [{ name: 'process', agentId: 123, description: 'Process data' }]
154
165
  })
155
166
  ```
156
167
 
@@ -186,67 +197,50 @@ await client.tasks.delete({ workflowId: 789, id: 1 })
186
197
 
187
198
  ### Triggers
188
199
 
200
+ Use the `triggers` factory to create type-safe trigger configs, then pass them to `workflows.create()` or `workflow.sync()`:
201
+
189
202
  ```typescript
190
- import { triggers, triggerConfigToProps } from '@openserv-labs/client'
203
+ import { triggers } from '@openserv-labs/client'
191
204
 
192
- // Create a webhook trigger
193
- const trigger = await client.triggers.create({
194
- workflowId: 789,
195
- name: 'My Webhook',
196
- type: 'webhook',
197
- props: triggerConfigToProps(
198
- triggers.webhook({
199
- waitForCompletion: true,
200
- timeout: 300
201
- })
202
- )
205
+ // Webhook trigger
206
+ const workflow = await client.workflows.create({
207
+ name: 'My Workflow',
208
+ goal: 'Process requests',
209
+ triggers: [triggers.webhook({ waitForCompletion: true, timeout: 300 })],
210
+ tasks: [{ name: 'process', agentId: 123, description: 'Handle the request' }]
203
211
  })
204
212
 
205
- // Create a cron trigger
206
- const cronTrigger = await client.triggers.create({
207
- workflowId: 789,
208
- name: 'Daily Job',
209
- type: 'cron',
210
- props: triggerConfigToProps(
211
- triggers.cron({
212
- schedule: '0 9 * * *',
213
- timezone: 'America/New_York'
214
- })
215
- )
213
+ // x402 (paid) trigger
214
+ const paidWorkflow = await client.workflows.create({
215
+ name: 'Paid Service',
216
+ goal: 'Premium AI service',
217
+ triggers: [triggers.x402({
218
+ name: 'AI Research Assistant',
219
+ description: 'Get comprehensive research reports on any topic powered by AI',
220
+ price: '0.01',
221
+ input: { query: { type: 'string', description: 'Research topic or question' } }
222
+ })],
223
+ tasks: [{ name: 'research', agentId: 123, description: 'Research the topic' }]
216
224
  })
217
225
 
218
- // Create an x402 (paid) trigger with a beautiful name and description
219
- const paidTrigger = await client.triggers.create({
220
- workflowId: 789,
221
- name: 'AI Research Assistant',
222
- description: 'Get comprehensive research reports on any topic powered by AI',
223
- type: 'x402',
224
- props: triggerConfigToProps(
225
- triggers.x402({
226
- name: 'AI Research Assistant',
227
- description: 'Get comprehensive research reports on any topic powered by AI',
228
- price: '0.01',
229
- input: {
230
- query: { type: 'string', description: 'Research topic or question' }
231
- }
232
- })
233
- )
234
- })
226
+ // Cron (scheduled) trigger
227
+ triggers.cron({ schedule: '0 9 * * *', timezone: 'America/New_York' })
228
+
229
+ // Manual trigger
230
+ triggers.manual()
231
+ ```
232
+
233
+ #### Low-level Triggers API
234
+
235
+ For managing individual triggers on existing workflows:
235
236
 
237
+ ```typescript
236
238
  // Get a trigger
237
239
  const trigger = await client.triggers.get({ workflowId: 789, id: 'trigger-id' })
238
240
 
239
241
  // List triggers
240
242
  const allTriggers = await client.triggers.list({ workflowId: 789 })
241
243
 
242
- // Update a trigger
243
- await client.triggers.update({
244
- workflowId: 789,
245
- id: 'trigger-id',
246
- name: 'Updated Name',
247
- props: { timeout: 600 }
248
- })
249
-
250
244
  // Activate a trigger
251
245
  await client.triggers.activate({ workflowId: 789, id: 'trigger-id' })
252
246
 
@@ -254,7 +248,7 @@ await client.triggers.activate({ workflowId: 789, id: 'trigger-id' })
254
248
  await client.triggers.fire({
255
249
  workflowId: 789,
256
250
  id: 'trigger-id',
257
- payload: { data: 'test' }
251
+ input: JSON.stringify({ query: 'test' })
258
252
  })
259
253
 
260
254
  // Delete a trigger
@@ -552,9 +546,11 @@ const cronResult = await provision({
552
546
  Use the `triggers` factory for type-safe trigger configuration:
553
547
 
554
548
  ```typescript
555
- import { triggers, triggerConfigToProps } from '@openserv-labs/client'
549
+ import { triggers } from '@openserv-labs/client'
550
+
551
+ // Each factory accepts user-friendly params and returns a flat, typed config.
556
552
 
557
- // Webhook trigger with name and description
553
+ // Webhook trigger
558
554
  triggers.webhook({
559
555
  name: 'Data Ingestion Webhook',
560
556
  description: 'Receives data from external systems for processing',
@@ -562,17 +558,18 @@ triggers.webhook({
562
558
  waitForCompletion: true,
563
559
  timeout: 180
564
560
  })
561
+ // { type: 'webhook', name: '...', waitForCompletion: true, timeout: 180, inputSchema: {...} }
565
562
 
566
- // Cron trigger with name and description
563
+ // Cron trigger
567
564
  triggers.cron({
568
565
  name: 'Daily Report Generator',
569
566
  description: 'Generates daily analytics reports every 6 hours',
570
567
  schedule: '0 */6 * * *',
571
568
  timezone: 'UTC'
572
569
  })
570
+ // { type: 'cron', name: '...', schedule: '0 */6 * * *', timezone: 'UTC' }
573
571
 
574
- // x402 (paid) trigger with beautiful name and description
575
- // These appear in the x402-services listing
572
+ // x402 (paid) trigger name and description appear in the x402-services listing
576
573
  triggers.x402({
577
574
  name: 'AI Research Assistant',
578
575
  description: 'Get comprehensive research reports on any topic powered by AI',
@@ -581,12 +578,14 @@ triggers.x402({
581
578
  timeout: 300,
582
579
  walletAddress: '0x...'
583
580
  })
581
+ // { type: 'x402', name: '...', x402Pricing: '0.05', timeout: 300, x402WalletAddress: '0x...', inputSchema: {...} }
584
582
 
585
- // Manual trigger with name and description
583
+ // Manual trigger
586
584
  triggers.manual({
587
585
  name: 'Manual Test Trigger',
588
586
  description: 'For testing workflows manually'
589
587
  })
588
+ // { type: 'manual', name: '...', description: '...' }
590
589
  ```
591
590
 
592
591
  ## Environment Variables
@@ -617,7 +616,6 @@ import type {
617
616
  WorkflowData,
618
617
  Task,
619
618
  Trigger,
620
- TriggerDefinition,
621
619
  TaskDefinition,
622
620
  EdgeDefinition,
623
621
  Edge,
package/dist/client.d.ts CHANGED
@@ -24,6 +24,8 @@ import { PaymentsAPI } from "./payments-api";
24
24
  */
25
25
  export declare class PlatformClient {
26
26
  private _apiClient;
27
+ /** Wallet address, set by authenticate() or manually. Used as a fallback for x402 trigger wallet resolution. */
28
+ walletAddress?: string;
27
29
  /** API for managing agents */
28
30
  readonly agents: AgentsAPI;
29
31
  /** API for managing integration connections */
@@ -103,5 +105,15 @@ export declare class PlatformClient {
103
105
  * ```
104
106
  */
105
107
  authenticate(privateKey?: string): Promise<string>;
108
+ /**
109
+ * Resolve wallet address from stored state or environment.
110
+ *
111
+ * Returns `this.walletAddress` (set by `authenticate()`) if available,
112
+ * otherwise derives the address from `WALLET_PRIVATE_KEY` environment variable.
113
+ * Per-trigger overrides are handled at the call site, not here.
114
+ *
115
+ * @returns The resolved wallet address, or undefined if no wallet is available
116
+ */
117
+ resolveWalletAddress(): string | undefined;
106
118
  }
107
119
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD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AAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAE/B;;;OAGG;IACH,IAAI,SAAS,IAAI,aAAa,CAE7B;IAED;;;;;OAKG;IACG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKnE;;;;;;OAMG;IACG,IAAI,CAAC,CAAC,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAKb;;;;;;OAMG;IACG,GAAG,CAAC,CAAC,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAKb;;;;;OAKG;IACG,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAKtE;;;;;;OAMG;gBACS,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAqB3D;;;;;;;;;;;;;;;;;OAiBG;IACG,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAmExD;;;;;;;;OAQG;IACH,oBAAoB,IAAI,MAAM,GAAG,SAAS;CAO3C"}
package/dist/client.js CHANGED
@@ -32,6 +32,8 @@ const PLATFORM_URL = process.env.OPENSERV_API_URL || "https://api.openserv.ai";
32
32
  */
33
33
  class PlatformClient {
34
34
  _apiClient;
35
+ /** Wallet address, set by authenticate() or manually. Used as a fallback for x402 trigger wallet resolution. */
36
+ walletAddress;
35
37
  /** API for managing agents */
36
38
  agents;
37
39
  /** API for managing integration connections */
@@ -144,9 +146,10 @@ class PlatformClient {
144
146
  // If no wallet key, assume API key auth is already set up
145
147
  return "";
146
148
  }
147
- // Create wallet
149
+ // Create wallet and store address for x402 wallet resolution
148
150
  const wallet = new ethers_1.ethers.Wallet(walletKey);
149
151
  const walletAddress = wallet.address;
152
+ this.walletAddress = walletAddress;
150
153
  // Step 1: Get nonce from platform
151
154
  const nonceResponse = await this._apiClient.post("/auth/wallet/nonce", {
152
155
  walletAddress,
@@ -183,5 +186,22 @@ Issued At: ${issuedAt}`;
183
186
  this._apiClient.defaults.headers.common["x-openserv-key"] = apiKey;
184
187
  return apiKey;
185
188
  }
189
+ /**
190
+ * Resolve wallet address from stored state or environment.
191
+ *
192
+ * Returns `this.walletAddress` (set by `authenticate()`) if available,
193
+ * otherwise derives the address from `WALLET_PRIVATE_KEY` environment variable.
194
+ * Per-trigger overrides are handled at the call site, not here.
195
+ *
196
+ * @returns The resolved wallet address, or undefined if no wallet is available
197
+ */
198
+ resolveWalletAddress() {
199
+ if (this.walletAddress)
200
+ return this.walletAddress;
201
+ if (process.env.WALLET_PRIVATE_KEY) {
202
+ return new ethers_1.ethers.Wallet(process.env.WALLET_PRIVATE_KEY).address;
203
+ }
204
+ return undefined;
205
+ }
186
206
  }
187
207
  exports.PlatformClient = PlatformClient;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export type { PaginatedResponse, IdResponse, ApiKeyResponse, NonceResponse, VerifyResponse, Agent, Category, MarketplaceAgent, MarketplaceAgentsResponse, OutputOption, TriggerDefinition, TaskDefinition, EdgeDefinition, WorkflowConfig, Trigger, Task, Edge, WorkflowData, UsdcTopupConfig, UsdcVerifyRequest, UsdcVerifyResponse, UsdcTopupResult, X402PaymentRequest, X402PaymentResult, } from "./types";
1
+ export type { PaginatedResponse, IdResponse, ApiKeyResponse, NonceResponse, VerifyResponse, Agent, Category, MarketplaceAgent, MarketplaceAgentsResponse, OutputOption, TaskDefinition, EdgeDefinition, WorkflowConfig, Trigger, Task, Edge, WorkflowData, UsdcTopupConfig, UsdcVerifyRequest, UsdcVerifyResponse, UsdcTopupResult, X402PaymentRequest, X402PaymentResult, } from "./types";
2
2
  export type { InputSchemaProperty, InputSchema, WebhookTriggerConfig, X402TriggerConfig, CronTriggerConfig, ManualTriggerConfig, TriggerConfig, } from "./triggers-api";
3
- export { triggers, inputSchemaToJsonSchema, triggerConfigToProps, } from "./triggers-api";
3
+ export { triggers, inputSchemaToJsonSchema } from "./triggers-api";
4
4
  export { PlatformClient } from "./client";
5
5
  export { Workflow } from "./workflow";
6
6
  export { AgentsAPI } from "./agents-api";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EAEd,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,cAAc,EACd,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,YAAY,EAEZ,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EAEf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,GACd,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,QAAQ,EACR,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CA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O,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGhE,YAAY,EACV,aAAa,EACb,eAAe,EACf,eAAe,EACf,MAAM,GACP,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,SAAS,GACV,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setLogger = exports.clearProvisionedState = exports.getProvisionedInfo = exports.isProvisioned = exports.provision = exports.PaymentsAPI = exports.Web3API = exports.WorkflowsAPI = exports.TasksAPI = exports.TriggersAPI = exports.IntegrationsAPI = exports.AgentsAPI = exports.Workflow = exports.PlatformClient = exports.triggerConfigToProps = exports.inputSchemaToJsonSchema = exports.triggers = void 0;
3
+ exports.setLogger = exports.clearProvisionedState = exports.getProvisionedInfo = exports.isProvisioned = exports.provision = exports.PaymentsAPI = exports.Web3API = exports.WorkflowsAPI = exports.TasksAPI = exports.TriggersAPI = exports.IntegrationsAPI = exports.AgentsAPI = exports.Workflow = exports.PlatformClient = exports.inputSchemaToJsonSchema = exports.triggers = void 0;
4
4
  // Trigger factory and helpers
5
5
  var triggers_api_1 = require("./triggers-api");
6
6
  Object.defineProperty(exports, "triggers", { enumerable: true, get: function () { return triggers_api_1.triggers; } });
7
7
  Object.defineProperty(exports, "inputSchemaToJsonSchema", { enumerable: true, get: function () { return triggers_api_1.inputSchemaToJsonSchema; } });
8
- Object.defineProperty(exports, "triggerConfigToProps", { enumerable: true, get: function () { return triggers_api_1.triggerConfigToProps; } });
9
8
  // Classes
10
9
  var client_1 = require("./client");
11
10
  Object.defineProperty(exports, "PlatformClient", { enumerable: true, get: function () { return client_1.PlatformClient; } });
@@ -1,4 +1,5 @@
1
- import { type TriggerConfig } from "./triggers-api";
1
+ import type { TriggerConfig } from "./triggers-api";
2
+ import type { EdgeDefinition } from "./types";
2
3
  /**
3
4
  * Interface for an agent instance that can receive credentials.
4
5
  * This matches the Agent class from @openserv-labs/sdk.
@@ -72,13 +73,30 @@ export interface ProvisionConfig {
72
73
  name: string;
73
74
  /** Trigger configuration (use triggers factory) */
74
75
  trigger: TriggerConfig;
75
- /** Optional task configuration */
76
+ /** Single task shorthand (backward compat). Omit agentId to assign to the provisioned agent. */
76
77
  task?: {
77
78
  /** Task description */
78
79
  description?: string;
79
80
  /** Detailed task body */
80
81
  body?: string;
81
82
  };
83
+ /**
84
+ * Multi-task support. Each task can specify an agentId (marketplace agent).
85
+ * Omit agentId to assign to the provisioned agent.
86
+ * When provided, takes precedence over `task`.
87
+ */
88
+ tasks?: Array<{
89
+ name: string;
90
+ description: string;
91
+ body?: string;
92
+ input?: string;
93
+ /** Agent ID to assign the task to. Omit for the provisioned agent. */
94
+ agentId?: number;
95
+ }>;
96
+ /** Custom edges between trigger and tasks. If omitted, sequential edges are auto-generated. */
97
+ edges?: EdgeDefinition[];
98
+ /** Additional agent IDs to include in the workspace beyond those in tasks (e.g., observers). */
99
+ agentIds?: number[];
82
100
  };
83
101
  }
84
102
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"provision.d.ts","sourceRoot":"","sources":["../src/provision.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAwB,MAAM,gBAAgB,CAAC;AAM1E;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B;;;O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M,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAmBP;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAU5C"}
package/dist/provision.js CHANGED
@@ -42,7 +42,6 @@ const ethers_1 = require("ethers");
42
42
  const fs = __importStar(require("node:fs"));
43
43
  const path = __importStar(require("node:path"));
44
44
  const client_1 = require("./client");
45
- const triggers_api_1 = require("./triggers-api");
46
45
  const STATE_FILE = ".openserv.json";
47
46
  const defaultLogger = {
48
47
  info: (...args) => console.log("[provision]", ...args),
@@ -82,18 +81,6 @@ function formatAxiosError(error) {
82
81
  })
83
82
  : axiosError.message || "Unknown error";
84
83
  }
85
- /**
86
- * Inject x402 trigger properties (wallet address and waitForCompletion)
87
- */
88
- function injectX402Props(props, walletAddress, triggerType) {
89
- if (triggerType !== "x402")
90
- return props;
91
- return {
92
- ...props,
93
- x402WalletAddress: props.x402WalletAddress || walletAddress,
94
- waitForCompletion: props.waitForCompletion ?? true,
95
- };
96
- }
97
84
  // ============================================================================
98
85
  // State Management (JSON)
99
86
  // ============================================================================
@@ -202,6 +189,9 @@ async function createAuthenticatedClient(privateKey) {
202
189
  try {
203
190
  // Verify it works by listing agents (a simple authenticated call)
204
191
  await client.agents.list();
192
+ // Always set walletAddress so resolveWalletAddress() works even when
193
+ // authenticate() is skipped (API-key-reuse path)
194
+ client.walletAddress = walletAddress;
205
195
  logger.info("Using existing user API key");
206
196
  return { client, walletAddress };
207
197
  }
@@ -309,9 +299,16 @@ async function provisionAgent(client, config) {
309
299
  return { agentId, apiKey, authToken };
310
300
  }
311
301
  /**
312
- * Provision a workflow (workspace + trigger + task)
302
+ * Build sequential edges: trigger -> task1 -> task2 -> ... -> taskN
313
303
  */
314
- async function provisionWorkflow(client, agentId, agentName, walletAddress, config) {
304
+ /**
305
+ * Provision a workflow (workspace + trigger + tasks + edges).
306
+ *
307
+ * Uses the declarative workflows.create() for new workflows and workflow.sync()
308
+ * for updating existing ones. x402 wallet injection is handled automatically by
309
+ * syncInternal() using client.resolveWalletAddress().
310
+ */
311
+ async function provisionWorkflow(client, agentId, agentName, config) {
315
312
  const state = readState();
316
313
  const workflowName = config.name || "default";
317
314
  // Initialize workflows structure if needed
@@ -319,29 +316,36 @@ async function provisionWorkflow(client, agentId, agentName, walletAddress, conf
319
316
  state.workflows[agentName] = {};
320
317
  }
321
318
  const existingWorkflow = state.workflows[agentName][workflowName];
319
+ // Convert single task shorthand to tasks array if needed
320
+ const tasks = config.tasks || [
321
+ {
322
+ name: "default-task",
323
+ description: config.task?.description || "Process the incoming request",
324
+ body: config.task?.body || "",
325
+ input: "",
326
+ },
327
+ ];
328
+ // Assign provisioned agentId to tasks that don't specify one
329
+ const tasksWithAgents = tasks.map((t) => ({
330
+ ...t,
331
+ agentId: t.agentId || agentId,
332
+ }));
322
333
  let workflowId;
323
334
  let triggerId;
324
335
  let triggerToken;
325
336
  let needsCreate = true;
326
337
  if (existingWorkflow) {
327
- // Update existing workflow
338
+ // Update existing workflow using sync (full idempotency)
328
339
  workflowId = existingWorkflow.workspaceId;
329
340
  triggerId = existingWorkflow.triggerId;
330
341
  triggerToken = existingWorkflow.triggerToken;
331
342
  needsCreate = false;
332
343
  try {
333
- // Get existing trigger to preserve required fields
334
- const existingTrigger = await client.triggers.get({
335
- workflowId,
336
- id: triggerId,
337
- });
338
- // Build new props, preserving existing values and injecting x402 props
339
- const triggerProps = injectX402Props({ ...existingTrigger.props, ...(0, triggers_api_1.triggerConfigToProps)(config.trigger) }, walletAddress, config.trigger.type);
340
- await client.triggers.update({
341
- workflowId,
342
- id: triggerId,
343
- name: existingTrigger.name || config.trigger.type,
344
- props: triggerProps,
344
+ const workflow = await client.workflows.get({ id: workflowId });
345
+ await workflow.sync({
346
+ triggers: [{ ...config.trigger, id: triggerId }],
347
+ tasks: tasksWithAgents,
348
+ ...(config.edges && { edges: config.edges }),
345
349
  });
346
350
  logger.info(`Updated workflow ${workflowName} (${workflowId})`);
347
351
  }
@@ -361,93 +365,31 @@ async function provisionWorkflow(client, agentId, agentName, walletAddress, conf
361
365
  }
362
366
  }
363
367
  if (needsCreate) {
364
- // Map trigger type to integration identifier
365
- const triggerTypeToIntegration = {
366
- x402: "x402-trigger",
367
- webhook: "webhook-trigger",
368
- cron: "cron-trigger",
369
- manual: "manual-trigger",
370
- };
371
- const integrationIdentifier = triggerTypeToIntegration[config.trigger.type] || "manual-trigger";
372
- // Create trigger props with x402 properties injected
373
- const triggerProps = injectX402Props((0, triggers_api_1.triggerConfigToProps)(config.trigger), walletAddress, config.trigger.type);
374
- // Step 1: Create workflow without triggers/tasks (avoids sync API issues)
368
+ // Create workflow with full declarative config
369
+ // syncInternal() handles x402 wallet injection, integration connection resolution,
370
+ // and auto-generates sequential edges when none are provided
375
371
  const workflow = await client.workflows.create({
376
372
  name: `${workflowName} Workflow`,
377
- goal: config.task?.description || "Process requests",
378
- agentIds: [agentId],
373
+ goal: config.task?.description || tasks[0]?.description || "Process requests",
374
+ agentIds: config.agentIds,
375
+ triggers: [config.trigger],
376
+ tasks: tasksWithAgents,
377
+ ...(config.edges && { edges: config.edges }),
379
378
  });
380
379
  workflowId = workflow.id;
381
380
  logger.info(`Created workflow ${workflowName} (${workflowId})`);
382
- // Step 2: Get or create integration connection for the trigger type
383
- const integrationConnectionId = await client.integrations.getOrCreateConnection(integrationIdentifier);
384
- // Step 3: Create trigger using direct API
385
- // Use the trigger's name/description if provided, otherwise default to type
386
- const triggerName = config.trigger.name || config.trigger.type;
387
- const triggerDescription = config.trigger.description;
388
- const trigger = await client.triggers.create({
389
- workflowId,
390
- name: triggerName,
391
- description: triggerDescription,
392
- integrationConnectionId,
393
- props: triggerProps,
394
- });
395
- triggerId = trigger.id;
396
- triggerToken = trigger.token || "";
381
+ // Get trigger info from the created workflow
382
+ const trigger = workflow.triggers[0];
383
+ if (trigger) {
384
+ triggerId = trigger.id;
385
+ triggerToken = trigger.token || "";
386
+ }
397
387
  logger.info(`Created trigger ${triggerId} (token: ${triggerToken || "N/A"})`);
398
- // Step 4: Create task using direct API
399
- const task = await client.tasks.create({
400
- workflowId,
401
- agentId,
402
- description: config.task?.description || "Process the incoming request",
403
- body: config.task?.body || "",
404
- input: "",
405
- });
406
- const taskId = task.id;
407
- logger.info(`Created task ${taskId} for workflow ${workflowId}`);
408
- // Step 5: Create workflow nodes and edges to link trigger to task
409
- const triggerNodeId = `trigger-${triggerId}`;
410
- const taskNodeId = `task-${taskId}`;
411
- const workflowNodes = [
412
- {
413
- id: triggerNodeId,
414
- type: "trigger",
415
- triggerId,
416
- position: { x: 0, y: 100 },
417
- inputPorts: [],
418
- outputPorts: [{ id: "default" }],
419
- isEndNode: false,
420
- },
421
- {
422
- id: taskNodeId,
423
- type: "task",
424
- taskId,
425
- position: { x: 300, y: 100 },
426
- inputPorts: [{ id: "input" }],
427
- outputPorts: [{ id: "default" }],
428
- isEndNode: true,
429
- },
430
- ];
431
- const workflowEdges = [
432
- {
433
- id: `edge-${triggerId}-${taskId}`,
434
- source: triggerNodeId,
435
- target: taskNodeId,
436
- sourcePort: "default",
437
- targetPort: "input",
438
- },
439
- ];
440
- await client.put(`/workspaces/${workflowId}/workflow`, {
441
- workflow: {
442
- nodes: workflowNodes,
443
- edges: workflowEdges,
444
- lastUpdatedTimestamp: Date.now(),
445
- },
446
- });
447
- logger.info(`Created workflow edges linking trigger ${triggerId} to task ${taskId}`);
448
- // Step 6: Activate trigger
449
- await client.triggers.activate({ workflowId, id: triggerId });
450
- // Step 7: Set workspace to running
388
+ // Activate trigger
389
+ if (triggerId) {
390
+ await client.triggers.activate({ workflowId, id: triggerId });
391
+ }
392
+ // Set workspace to running
451
393
  await client.workflows.setRunning({ id: workflowId });
452
394
  // Re-read state to avoid overwriting concurrent changes
453
395
  const freshState = readState();
@@ -456,8 +398,8 @@ async function provisionWorkflow(client, agentId, agentName, walletAddress, conf
456
398
  }
457
399
  freshState.workflows[agentName][workflowName] = {
458
400
  workspaceId: workflowId,
459
- triggerId,
460
- triggerToken,
401
+ triggerId: triggerId || "",
402
+ triggerToken: triggerToken || "",
461
403
  };
462
404
  writeState(freshState);
463
405
  logger.info(`Provisioned workflow ${workflowName} (${workflowId})`);
@@ -533,7 +475,8 @@ async function provision(config) {
533
475
  // Get or create wallet
534
476
  const { privateKey } = await getOrCreateWallet();
535
477
  // Create authenticated client (reuses saved API key for session continuity)
536
- const { client, walletAddress } = await createAuthenticatedClient(privateKey);
478
+ // walletAddress is set on client.walletAddress for x402 resolution
479
+ const { client } = await createAuthenticatedClient(privateKey);
537
480
  // Provision agent (returns agentId, apiKey, and authToken)
538
481
  const { agentId, apiKey, authToken } = await provisionAgent(client, config.agent);
539
482
  // Bind credentials to the agent
@@ -549,8 +492,8 @@ async function provision(config) {
549
492
  process.env.OPENSERV_AUTH_TOKEN = authToken;
550
493
  }
551
494
  }
552
- // Provision workflow (pass agent name and wallet address for x402 triggers)
553
- const workflowResult = await provisionWorkflow(client, agentId, config.agent.name, walletAddress, config.workflow);
495
+ // Provision workflow (wallet address resolved automatically via client.resolveWalletAddress())
496
+ const workflowResult = await provisionWorkflow(client, agentId, config.agent.name, config.workflow);
554
497
  return {
555
498
  agentId,
556
499
  apiKey,