Description
When flows call `claude --print --output-format json` via bash steps, the response is wrapped in an envelope:
{"type": "result", "result": "```json\n{\"actual\": \"data\"}\n```"}
Every flow that consumes this output must implement identical unwrap logic:
- Detect the `{"type": "result", "result": "..."}` envelope
- Strip markdown fences (```json ... ```)
- Strip any preamble text before the JSON
- Parse the inner JSON
- Handle parse failures gracefully
This pattern is duplicated 20+ times across flows. Each copy is ~8 lines of JavaScript.
Current Workaround
Each code step defines an inline `unwrap()` function:
var unwrap = function(r) {
if (r && r.type === 'result' && r.result) {
var s = String(r.result)
.replace(/^\`\`\`[a-z]*\\s*\\n?/gm, '')
.replace(/\\n?\`\`\`\\s*$/gm, '')
.trim();
try { return JSON.parse(s); } catch(e) { return r; }
}
return r;
};
raw = unwrap(raw);
Suggested Fix
One or more of:
- `parseEnvelope: true` option on bash steps — automatically unwrap the Claude envelope before passing to downstream steps
- Built-in helper exposed to code steps — e.g., `$.unwrapEnvelope(raw)` available in the sandbox
- `--raw-json` flag for `claude --print` — return just the JSON without the envelope (this may be an Anthropic CLI issue, not One CLI)
Description
When flows call `claude --print --output-format json` via bash steps, the response is wrapped in an envelope:
{"type": "result", "result": "```json\n{\"actual\": \"data\"}\n```"}Every flow that consumes this output must implement identical unwrap logic:
This pattern is duplicated 20+ times across flows. Each copy is ~8 lines of JavaScript.
Current Workaround
Each code step defines an inline `unwrap()` function:
Suggested Fix
One or more of: