Repository navigation
PA-8226: feat: deel app search, describe and run for web-app actions - #43
Conversation
Adds `deel app`, which finds and runs the Deel web-app actions published for
agents, as the signed-in user, through Deel's MCP endpoint (/mcp): a small
JSON-RPC client (no MCP SDK) and three commands on top of it.
- search / describe / run map to the search_actions, get_action and
run_read_action / run_write_action tools; run picks the tool from
get_action's run_with, and --input is one {path_params, query, body} object.
- The login is checked before any call (an OAuth login, no sensitive-data
claims); a 401 refreshes the login once; reads retry, writes never do; errors
map to the CLI envelope with a next step; a body the server cut at 100 KB is
returned as text with meta.truncated and a warning.
- DEEL_MCP_URL points the commands at another /mcp for test environments.
Also fixes two problems the end-to-end run found, for every command: output
piped into another process was cut at 64 KB because the CLI exited before
stdout drained (now it sets the exit code and ends on its own, safe under Node
and Bun), and --jq parsed a text payload as JSON instead of taking it as a
string.
PA-8226
Registers dev's static tokens command next to app, in the command registry, RESERVED_COMMANDS and the README layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…odies, rpc results) - DEEL_MCP_URL only receives a stored OAuth login on the API or issuer host - shorthand --input numbers stay text and are typed by the action schema - MCP replies are never written to the local log, even with --log-bodies - allOf skeletons merge properties; JSON-RPC replies without a tool result are errors - a write that fails after it was sent reports an unknown outcome; 4xx do not - search/describe results are shape-checked; unused flags are refused - tests for main.ts exit paths, the citty wiring, retry cap and declined renew Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- keep shorthand true/false as text until the schema says boolean - a failed login refresh or an unreachable host is never an unknown outcome - search/describe return the action list as data (--fields, --quiet work) - main.ts prints one envelope via failureEnvelope(); tested directly - refuse unknown flags so a mistyped --dry-run cannot run a write - number coercion only when it reads back as written; read allOf/anyOf/oneOf - statusless tool failures and non-tool "not found" errors keep their own code - search rejects a reply without an actions list; refuse --log-bodies Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- refuse single-dash options (-dry-run) the way --dryrun is refused - test the token-provider refresh wrapper with a login that expires mid-run - --dry-run prints the call even with --quiet - read an SSE message that spans several data lines; ignore a reply to another call Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- an option before the last command word is dropped by citty (`deel --dry-run app run` would write), so it is refused - an SSE `data: null` or a non-object reply is not a message - test --jq on search/describe output, alone and with --quiet Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Universal code reviewer
🟢 Approval recommended · Confidence 100 / 100
Round 5 · head 2b31ea5 · reviewed 9c20d3a..2b31ea5 · 3 fixed · 0 still open · 0 new · View DCA Session
Found: 0 🔴 CRITICAL · 0 🟠 HIGH · 0 🟡 MEDIUM · 0 ⚪ LOW
Open (0)
No open findings.
Fixed (3)
Low priority, not posted inline (0)
None.
What changed in this PR
Adds the static command deel app search | describe | run, which lists, describes and runs the Deel web-app actions published for agents, as the signed-in OAuth user, through Deel's MCP endpoint (/mcp). The login is checked before any call, a 401 refreshes once and retries, reads retry on 429/5xx while writes never retry (a lost write answer is app.outcome_unknown), server error codes map to CLI errors, and responses truncated at 100 KB come back as text with meta.truncated. It also fixes piped output being cut at 64 KB (main.ts no longer calls process.exit() mid-write) and --jq on text payloads, and adds OAuthSource.renew() and accessTokenClaims().
| File | Change |
|---|---|
README.md |
Documents deel app and DEEL_MCP_URL |
scripts/doctor-hashes.json |
Doctor gate hashes (generated, not reviewed) |
src/cli.ts |
Registers app; refuses options placed before a subcommand |
src/commands/app.ts |
New thin citty command for app search / describe / run |
src/commands/index.ts |
Adds app to the static commands |
src/core/app-actions.ts |
New eligibility, retries, renewal, error mapping, input coercion, skeleton |
src/core/auth.ts |
Token claims and renew support for app actions |
src/core/config.ts |
DEEL_MCP_URL resolution |
src/core/constants.ts |
Reserves app and adds MCP constants |
src/core/errors.ts |
New app.* error codes |
src/core/http.ts |
Transport changes used by the MCP client |
src/core/input.ts |
--input parsing shared with app run |
src/core/io.ts |
Exit flush without process.exit() mid-write |
src/core/mcp.ts |
New JSON-RPC / SSE client for /mcp |
src/core/oauth.ts |
OAuthSource.renew() and accessTokenClaims() |
src/core/output.ts |
--jq on a text payload passed as a string |
src/main.ts |
Sets the exit code and ends on its own |
test/app-actions.test.ts |
New tests for app-actions |
test/app.test.ts |
New end-to-end command tests |
test/auth.test.ts |
Additions |
test/cli.test.ts |
Additions, including option-before-subcommand |
test/config.test.ts |
Additions for DEEL_MCP_URL |
test/errors.test.ts |
Additions |
test/http.test.ts |
Additions |
test/input.test.ts |
Additions |
test/io.test.ts |
New exit-flush tests with a slow pipe reader |
test/logging.test.ts |
Additions |
test/main.test.ts |
New main exit-path tests |
test/mcp.test.ts |
New JSON-RPC client tests |
test/oauth.test.ts |
Additions |
test/output.test.ts |
Additions |
Reviewers run: ucr-bugs-reviewer, ucr-security-reviewer, ucr-performance-reviewer, ucr-types-conventions-reviewer, ucr-repo-rules-reviewer, ucr-tests-reviewer, permission-framework-auth-sdk-ucr-reviewer, dba-ucr-reviewer, ucr-infosec-reviewer. Rules referenced: none this round.
Resolves the conflicts with dev's flush fix (#24), the public API commands, the options-before-command guard, the shorthand string handling and the env-name list: - main.ts keeps exitAfterFlush and builds the error body from dev's usage helpers - the option guard before the command words is dev's, which covers every command - shorthand parsing keeps dev's raw-text handling and this branch's exact mode - DEEL_MCP_URL joins CLI_SETTING_ENV; app is a reserved command again Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The server cuts a body in two ways and says so in a second text item: the whole body was read and is over the 100 KB cap, or reading stopped early (a body past the 5 MB read limit, a timeout, a broken connection), where it words the notice differently and the full size is unknown. Only the first form was recognised, so in the second the cut text came back with no meta.truncated and no warning. - meta.truncated carries read_bytes, shown_bytes and the server's reason for the second form; the first form is unchanged - any other notice that starts '[Response truncated:' still counts as cut - README describes both shapes Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Found running the commands against a real server. Shorthand reads a value with
spaces as a list of words and cannot know a field is a string, so
'body={title=Payroll sync}' sent ["Payroll","sync"] for a string field, and
'query={org=null}' sent the text "null" for a nullable integer, which the server
refused. The schema is known only after get_action, so once it arrives the parsed
shorthand is typed by it, in place: a string field gets its text as written, and
a nullable field written null becomes a real null, at any depth. JSON input is
never touched, so a JSON "null" stays a string.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Takes dev's wording for the domains.json layout line, keeping app in the list of static commands. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Description
Adds
deel app search | describe | run: find and run the Deel web-app actions that Deel publishes for agents, as the signed-in user and with that user's permissions. The commands call Deel's MCP endpoint (/mcp), the only place web-app endpoints accept an OAuth login. Builds on the browser sign-in from #21.New commands
deel app search <words> [--limit 1-20]lists the actions this login can run (name, title, description, method, scopes).deel app describe <name>... [--generate-input]shows an action's input schema, scopes andrun_with(read or write).--generate-inputprints a{path_params, query, body}skeleton.deel app run <name> [--input ...] [--dry-run]runs it.--inputis one{path_params, query, body}object in any existing--inputform (file, stdin, JSON, nested shorthand such aspath_params={id=123}).runreads the action first and calls the read or write tool thatrun_withnames. There is no confirmation step, so the agent host's permission settings decide whether a write runs.Behaviour
auth.oauth_requiredorapp.sensitive_data_hiddenand a next step.search,describeand reads retry on 429/5xx and on transient server codes. Writes are never retried. A write that gets no answer isapp.outcome_unknown, and the message says to check with a read first.app.unavailable,app.action_not_found,auth.insufficient_scope(naming the scopes to log in with),app.invalid_input(the server's per-field message),app.rate_limited, and others passed through asapp.<code>.meta.truncatedand a warning on stderr.DEEL_MCP_URLpoints the commands at another/mcp, for test environments that serve it on their own host. It's documented in the README's configuration reference.Fixes for every command, found during the end-to-end run
main.tscalledprocess.exit()while stdout was still writing to a pipe (macOS), sodeel ... | jqlost the end of large outputs. The CLI now sets the exit code and ends on its own, with a forced exit after 5 s as a fallback. Under Bun, waiting for the write callback wasn't enough, because it fires before the data is flushed; this approach works under both Node and the compiled binary.devhas since fixed the success path the same way (fix: let stdout drain before the process exits #24); this branch keeps its version, which also flushes the error path, so a failing command piped into another process isn't cut either.--jqon a text payload handed the text to jq-wasm, which parsed it as JSON. It's now passed as a string.Merged with
dev(conflicts in 21 files). Wheredevhad grown the same thing, its version won: the check that refuses an option written before the command words (it covers every command,deel --dry-run app run ...included), the shorthand--inputhandling, the error-envelope helpers and the--jqinline build.appis a reserved command again, andDEEL_MCP_URLis in the list of CLI settings.Found by the live run and fixed here: in shorthand
--input, a string field with spaces was sent as a list of words (body={title=Payroll sync}became["Payroll","sync"]) andnullin a nullable field was sent as the text"null". Once the action's schema is known, the parsed shorthand is now typed by it: a string field gets its text as written and a nullable field writtennullis a real null, at any depth. JSON input is never rewritten.Small additions to the OAuth modules:
OAuthSource.renew()refreshes after a rejected token, unless another process already stored a newer one.accessTokenClaims()generalises the existing scope decoding.Testing
How I Tested:
Unit and command tests, all against a stubbed transport and in-memory keychain, with made-up actions only:
test/mcp.test.ts: the JSON-RPC client.test/app-actions.test.ts: eligibility, retries, renewal, error mapping, input coercion,run_with, truncation, the skeleton.test/app.test.ts: the commands end to end through the real context, keychain and transport seams, plus the hidden--base-urlvalue not counting as a positional word.test/io.test.ts: the exit flush, including a 300 KB output piped to a slow reader through a real child process.oauth.test.ts,auth.test.tsandoutput.test.ts.npm run checkon the branch merged with dev: 792 tests pass, coverage 98.1% lines, 95.1% branches.npm run build:smokepasses, and the doctor gate is clear.Manually, against an internal sandbox running the server side of web-app actions as it was before release, signed in with
deel auth loginas a sandbox client user. Every command and error path:--generate-input,--dry-run;meta.truncated102,400 of 159,264 bytes, warning on stderr;app.invalid_input;app.unavailable;auth.insufficient_scope, with the scope named;Since then the server side has been released, with changes made in review after that run. I re-read the released tool contract against what the CLI sends and maps (tool names and arguments,
run_with, the error codes, the sign-in checks, the 100 KB cap). It matches, apart from one thing: a body the server stopped reading (over its read limit, a timeout, a broken connection) comes with a differently worded notice, which the CLI did not recognise, so that response came back with nometa.truncatedand no warning. Fixed here, with tests for both forms.Then against a released environment (the dev API), signed in with
deel auth loginas a client user of an organization with web-app actions enabled, with the compiled binary as well as from source:search(--limit,--quiet,--jq),describeanddescribe --generate-input;--dry-run, and a read with JSON and with shorthand--input;meta.truncated102,400 of 188,136 bytes, warning on stderr; piped to a slow reader the full 111,825 bytes of output arrive, from source and from the compiled binary;app.invalid_inputand the backend's own error passed through;app.unavailablebefore the organization was enabled (also seen on the demo environment).Not covered live: the 401 renewal,
auth.insufficient_scope, and the notice for a body the server stopped reading (it needs over 5 MB or a timeout); those are covered by the unit tests.Evidence/Proof:
Sandbox run, action names replaced by placeholders, request IDs dropped. Read, write, read back, restore:
Search:
Errors and a truncated read:
Piped output before and after the exit fix (300 KB written, slow reader):
Release checklist
npm run checkpasses locally (typecheck, tests + coverage gate, manifest / lockfile / version / shell checks)src/manifest.generated.tsuntouched, or regenerated with thedeel-cli-extractorskill (never hand-edited) and the PR labelledscript-generatedbug/enhancement/refactor/documentation/chore