@withone/cli 1.13.3 → 1.13.5

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,26 @@ 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
304
  return `${knowledge}
298
305
 
299
- API REQUEST STRUCTURE
306
+ CLI PARAMETER MAPPING
300
307
  ======================
301
- URL: ${baseUrl}/v1/passthrough/{{PATH}}
308
+ Use the One CLI to execute this action. Map parameters from the documentation above to CLI flags:
302
309
 
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.
310
+ - **Path variables** (URL placeholders like {userId}, {id}) \u2192 \`--path-vars '{"userId": "me", "id": "123"}'\`
311
+ - **Query parameters** (filtering, pagination, format options) \u2192 \`--query-params '{"key": "value"}'\`
312
+ - For repeated params, use arrays: \`--query-params '{"metadataHeaders": ["From", "Subject"]}'\`
313
+ - **Request body** (POST/PUT/PATCH data) \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
+ Do NOT pass path variables or query parameters in the -d body flag \u2014 they will be ignored.
309
316
 
310
- METHOD: ${method}
317
+ EXAMPLE COMMAND:
318
+ one --agent actions execute ${platform} ${actionId} <connectionKey> \\
319
+ --path-vars '{ ... }' \\
320
+ --query-params '{ ... }' \\
321
+ -d '{ ... }'
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)
317
-
318
- BODY: {{BODY}}
319
-
320
- QUERY PARAMS: {{QUERY_PARAMS}}`;
323
+ Replace the JSON objects above with the actual parameters from the documentation. Omit any flag that has no parameters for this action (e.g., omit --path-vars if the URL has no placeholders, omit -d for GET requests).`;
321
324
  }
322
325
 
323
326
  // src/lib/flow-engine.ts
@@ -655,7 +658,7 @@ async function executeSubflowStep(step, context, api, permissions, allowedAction
655
658
  if (flowStack.includes(resolvedKey)) {
656
659
  throw new Error(`Circular flow detected: ${[...flowStack, resolvedKey].join(" \u2192 ")}`);
657
660
  }
658
- const { loadFlow: loadFlow2 } = await import("./flow-runner-JHEAUFDL.js");
661
+ const { loadFlow: loadFlow2 } = await import("./flow-runner-ZTLAFPFP.js");
659
662
  const subFlow = loadFlow2(resolvedKey);
660
663
  const subContext = await executeFlow(
661
664
  subFlow,
@@ -991,12 +994,18 @@ var FlowRunner = class _FlowRunner {
991
994
  ensureDir(LOGS_DIR);
992
995
  this.statePath = path2.join(RUNS_DIR, `${flow.key}-${this.runId}.state.json`);
993
996
  this.logPath = path2.join(LOGS_DIR, `${flow.key}-${this.runId}.log`);
997
+ const resolvedInputs = { ...inputs };
998
+ for (const [name, decl] of Object.entries(flow.inputs)) {
999
+ if (resolvedInputs[name] === void 0 && decl.default !== void 0) {
1000
+ resolvedInputs[name] = decl.default;
1001
+ }
1002
+ }
994
1003
  this.state = {
995
1004
  runId: this.runId,
996
1005
  flowKey: flow.key,
997
1006
  status: "running",
998
1007
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
999
- inputs,
1008
+ inputs: resolvedInputs,
1000
1009
  completedSteps: [],
1001
1010
  context: {
1002
1011
  input: inputs,
@@ -4,7 +4,7 @@ import {
4
4
  loadFlow,
5
5
  resolveFlowPath,
6
6
  saveFlow
7
- } from "./chunk-NHI5URAV.js";
7
+ } from "./chunk-GNYFRZSZ.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-NHI5URAV.js";
14
+ } from "./chunk-GNYFRZSZ.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.3",
3
+ "version": "1.13.5",
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