@withone/cli 1.13.4 → 1.13.6

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.
@@ -150,9 +150,17 @@ var OneApi = class {
150
150
  }
151
151
  let queryString = "";
152
152
  if (args.queryParams && Object.keys(args.queryParams).length > 0) {
153
- const params = new URLSearchParams(
154
- Object.entries(args.queryParams).map(([k, v]) => [k, String(v)])
155
- );
153
+ const entries = [];
154
+ for (const [k, v] of Object.entries(args.queryParams)) {
155
+ if (Array.isArray(v)) {
156
+ for (const item of v) {
157
+ entries.push([k, String(item)]);
158
+ }
159
+ } else {
160
+ entries.push([k, String(v)]);
161
+ }
162
+ }
163
+ const params = new URLSearchParams(entries);
156
164
  queryString = `?${params.toString()}`;
157
165
  }
158
166
  const fullUrl = `${url}${queryString}`;
@@ -293,31 +301,30 @@ function isActionAllowed(actionId, allowedActionIds) {
293
301
  return allowedActionIds.includes("*") || allowedActionIds.includes(actionId);
294
302
  }
295
303
  function buildActionKnowledgeWithGuidance(knowledge, method, platform, actionId) {
296
- const baseUrl = "https://api.withone.ai";
297
- return `${knowledge}
298
-
299
- API REQUEST STRUCTURE
300
- ======================
301
- URL: ${baseUrl}/v1/passthrough/{{PATH}}
304
+ return `CLI EXECUTION GUIDE (read this FIRST)
305
+ ========================================
306
+ To execute this action, use the One CLI with SEPARATE flags for each parameter type.
307
+ Do NOT pass path variables or query parameters in the -d body flag \u2014 this causes 403 errors.
302
308
 
303
- IMPORTANT: When constructing the URL, only include the API endpoint path after the base URL.
304
- Do NOT include the full third-party API URL.
309
+ PARAMETER \u2192 FLAG MAPPING:
310
+ - Path variables (URL placeholders like {userId}, {id}) \u2192 --path-vars '{"userId": "me"}'
311
+ - Query parameters (filtering, pagination, format) \u2192 --query-params '{"key": "value"}'
312
+ - For repeated params, use arrays: --query-params '{"metadataHeaders": ["From", "Subject"]}'
313
+ - Request body (POST/PUT/PATCH payload) \u2192 -d '{"field": "value"}'
305
314
 
306
- Examples:
307
- Correct: ${baseUrl}/v1/passthrough/crm/v3/objects/contacts/search
308
- Incorrect: ${baseUrl}/v1/passthrough/https://api.hubapi.com/crm/v3/objects/contacts/search
315
+ EXAMPLE:
316
+ one --agent actions execute ${platform} ${actionId} <connectionKey> \\
317
+ --path-vars '{ ... }' \\
318
+ --query-params '{ ... }' \\
319
+ -d '{ ... }'
309
320
 
310
- METHOD: ${method}
321
+ Omit any flag not needed (e.g., omit --path-vars if URL has no placeholders, omit -d for GET).
311
322
 
312
- HEADERS:
313
- - x-one-secret: {{process.env.ONE_SECRET}}
314
- - x-one-connection-key: {{process.env.ONE_${platform.toUpperCase()}_CONNECTION_KEY}}
315
- - x-one-action-id: ${actionId}
316
- - ... (other headers)
323
+ Read the API documentation below to identify which parameters are path variables, query parameters, or body fields, then map them to the correct flags above.
317
324
 
318
- BODY: {{BODY}}
325
+ ========================================
319
326
 
320
- QUERY PARAMS: {{QUERY_PARAMS}}`;
327
+ ${knowledge}`;
321
328
  }
322
329
 
323
330
  // src/lib/flow-engine.ts
@@ -655,7 +662,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
655
662
  if (flowStack.includes(resolvedKey)) {
656
663
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
657
664
  }
658
- const { loadFlow: loadFlow2 } = await import("./flow-runner-EPSYHAD6.js");
665
+ const { loadFlow: loadFlow2 } = await import("./flow-runner-5ZBACWKL.js");
659
666
  const subFlow = loadFlow2(resolvedKey);
660
667
  const subContext = await executeFlow(
661
668
  subFlow,
@@ -4,7 +4,7 @@ import {
4
4
  loadFlow,
5
5
  resolveFlowPath,
6
6
  saveFlow
7
- } from "./chunk-MCVD3QCG.js";
7
+ } from "./chunk-T54OTDAW.js";
8
8
  export {
9
9
  FlowRunner,
10
10
  listFlows,
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  loadFlow,
12
12
  resolveFlowPath,
13
13
  saveFlow
14
- } from "./chunk-MCVD3QCG.js";
14
+ } from "./chunk-T54OTDAW.js";
15
15
 
16
16
  // src/index.ts
17
17
  import { createRequire as createRequire2 } from "module";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@withone/cli",
3
- "version": "1.13.4",
3
+ "version": "1.13.6",
4
4
  "description": "CLI for managing One",
5
5
  "type": "module",
6
6
  "files": [
@@ -78,7 +78,7 @@ one --agent actions knowledge <platform> <actionId>
78
78
 
79
79
  Get comprehensive documentation for an action including parameters, requirements, validation rules, request/response structure, and examples. Returns JSON with the full API knowledge and HTTP method.
80
80
 
81
- Always call this before executing — it tells you exactly what parameters are required and how to structure the request.
81
+ Always call this before executing — it tells you exactly what parameters are required, how to structure the request, and which CLI flags to use for path variables, query parameters, and body data. Do NOT pass path or query parameters in the `-d` body flag.
82
82
 
83
83
  Example:
84
84
  ```bash
@@ -124,6 +124,11 @@ one --agent actions execute hub-spot <actionId> <connectionKey> \
124
124
  one --agent actions execute shopify <actionId> <connectionKey> \
125
125
  --path-vars '{"order_id": "12345"}' \
126
126
  --query-params '{"limit": "10"}'
127
+
128
+ # With repeated query params (array values expand to repeated keys)
129
+ one --agent actions execute gmail <actionId> <connectionKey> \
130
+ --path-vars '{"userId": "me", "id": "msg123"}' \
131
+ --query-params '{"format": "metadata", "metadataHeaders": ["From", "Subject", "Date"]}'
127
132
  ```
128
133
 
129
134
  Output format:
@@ -147,5 +152,6 @@ Parse the output as JSON. If the `error` key is present, the command failed —
147
152
  - Always use the **exact action ID** from search results — don't guess or construct them
148
153
  - Always read the knowledge output carefully — it tells you which parameters are required vs optional, what format they need to be in, and any caveats specific to that API
149
154
  - JSON values passed to `-d`, `--path-vars`, `--query-params`, and `--headers` must be valid JSON strings (use single quotes around the JSON to avoid shell escaping issues)
155
+ - **Array query params**: Use JSON arrays for repeated query parameters — `{"metadataHeaders": ["From", "Subject"]}` expands to `metadataHeaders=From&metadataHeaders=Subject`
150
156
  - If search returns no results, try broader queries (e.g., `"list"` instead of `"list active premium customers"`)
151
157
  - The execute command respects access control settings configured via `one config` — if execution is blocked, the user may need to adjust their permissions