Skip to content

PA-8226: feat: deel app search, describe and run for web-app actions - #43

Merged
guilherme-soares-deel merged 10 commits into
devfrom
PA-8226-deel-app
Nov 25, 2026
Merged

guilherme-soares-deel merged 10 commits into
devfrom
PA-8226-deel-app

Conversation

@guilherme-soares-deel

@guilherme-soares-deel guilherme-soares-deel commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

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 and run_with (read or write). --generate-input prints a {path_params, query, body} skeleton.
  • deel app run <name> [--input ...] [--dry-run] runs it. --input is one {path_params, query, body} object in any existing --input form (file, stdin, JSON, nested shorthand such as path_params={id=123}). run reads the action first and calls the read or write tool that run_with names. There is no confirmation step, so the agent host's permission settings decide whether a write runs.

Behaviour

  • Login checked before any call. A PAT, no login, or a login that hides sensitive data fails at once with auth.oauth_required or app.sensitive_data_hidden and a next step.
  • 401 handling. A 401 refreshes the OAuth login once and retries. This is safe because the server answers it before the action runs.
  • Retries. search, describe and reads retry on 429/5xx and on transient server codes. Writes are never retried. A write that gets no answer is app.outcome_unknown, and the message says to check with a read first.
  • Error mapping. Server error codes map to CLI errors with a next step: 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 as app.<code>.
  • Large responses. A response the server cut at 100 KB comes back as text with meta.truncated and a warning on stderr.
  • DEEL_MCP_URL points the commands at another /mcp, for test environments that serve it on their own host. It's documented in the README's configuration reference.
  • No feature flag in the CLI. The server decides which organizations can use web-app actions. The README says they carry no stability promise.

Fixes for every command, found during the end-to-end run

  • Piped output was cut at 64 KB. main.ts called process.exit() while stdout was still writing to a pipe (macOS), so deel ... | jq lost 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. dev has 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.
  • --jq on 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). Where dev had 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 --input handling, the error-envelope helpers and the --jq inline build. app is a reserved command again, and DEEL_MCP_URL is 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"]) and null in 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 written null is 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-url value 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.
    • Additions to oauth.test.ts, auth.test.ts and output.test.ts.
  • npm run check on the branch merged with dev: 792 tests pass, coverage 98.1% lines, 95.1% branches. npm run build:smoke passes, 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 login as a sandbox client user. Every command and error path:

    • search, describe, --generate-input, --dry-run;
    • a read;
    • a read over 100 KB: text, meta.truncated 102,400 of 159,264 bytes, warning on stderr;
    • a real write, read back and then restored;
    • a write the backend refuses for a business rule, passed through;
    • a write without its required input: app.invalid_input;
    • org not enabled: app.unavailable;
    • a scope the login lacks: auth.insufficient_scope, with the scope named;
    • an unknown action;
    • a PAT;
    • an expired login, refreshed mid-run;
    • the compiled binary piping its full 117 KB output to a slow reader, where it was cut before the fix.
  • 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 no meta.truncated and no warning. Fixed here, with tests for both forms.

  • Then against a released environment (the dev API), signed in with deel auth login as a client user of an organization with web-app actions enabled, with the compiled binary as well as from source:

    • search (--limit, --quiet, --jq), describe and describe --generate-input;
    • --dry-run, and a read with JSON and with shorthand --input;
    • a write and its read-back and delete: a folder created, listed, then deleted, with the organization back to its start;
    • a read over 100 KB: text, meta.truncated 102,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;
    • an unknown action; the server's per-field app.invalid_input and the backend's own error passed through; app.unavailable before 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:

$ deel app run <read-action> --base-url $SANDBOX
{ "data": { "pinnedIds": [] }, "meta": { "request_id": "…" } }

$ deel app run <write-action> --input '{"body":{"pinnedIds":["<item>"]}}' --base-url $SANDBOX
{ "data": { "pinnedIds": ["<ITEM>"] }, "meta": { "request_id": "…" } }

$ deel app run <read-action> --base-url $SANDBOX --jq '.pinnedIds'
[ "<ITEM>" ]

$ deel app run <write-action> --input '{"body":{"pinnedIds":[]}}' --base-url $SANDBOX
{ "data": { "pinnedIds": [] }, "meta": { "request_id": "…" } }

Search:

$ deel app search <words> --base-url $SANDBOX
{
  "data": {
    "actions": [
      { "name": "<action-a>", "title": "…", "description": "…", "method": "GET", "scopes": ["<scope>:read"] },
      { "name": "<action-b>", "title": "…", "description": "…", "method": "GET", "scopes": ["<scope>:read"] }
    ]
  },
  "meta": { "request_id": "…" }
}

Errors and a truncated read:

$ deel app run <write-action-2> --base-url $SANDBOX
{ "error": { "code": "app.invalid_input", "message": "Invalid arguments for <write-action-2>: path_params: Invalid input: expected object, received undefined", "next": "See the input with 'deel app describe <write-action-2>'.", "request_id": "…" } }

$ deel app describe <action-needing-another-scope> --base-url $SANDBOX
{ "error": { "code": "auth.insufficient_scope", "message": "<action> needs one of these scopes: <scope>:read", "next": "Run 'deel auth login --scopes <scope>:read' to add a scope it needs.", "request_id": "…" } }

$ deel app run <large-read-action> --base-url $SANDBOX --fields request_id
warning: the response was cut at 102400 of 159264 bytes, so it is returned as text. Narrow the query to get all of it.
{ "data": {}, "meta": { "request_id": "…", "truncated": { "total_bytes": 159264, "shown_bytes": 102400 } } }

Piped output before and after the exit fix (300 KB written, slow reader):

process.exit() right after the write  ->  65536 of 300000 bytes (Node and Bun)
exitAfterFlush                        ->  300000 of 300000 bytes (Node and Bun)

Release checklist

  • npm run check passes locally (typecheck, tests + coverage gate, manifest / lockfile / version / shell checks)
  • User-facing change → README updated
  • src/manifest.generated.ts untouched, or regenerated with the deel-cli-extractor skill (never hand-edited) and the PR labelled script-generated
  • No credentials, tokens or personal data in tests, fixtures, logs or this description
  • Exactly one type label: bug / enhancement / refactor / documentation / chore

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
@guilherme-soares-deel guilherme-soares-deel added enhancement New feature or request ai-assisted PR created or modified with AI assistance labels Nov 9, 2026
Base automatically changed from feat/oauth-browser-login to dev November 9, 2026 21:24
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>
@guilherme-soares-deel
guilherme-soares-deel marked this pull request as ready for review November 9, 2026 21:44
deel-ai-studio-app[bot]

This comment was marked as resolved.

…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>
deel-ai-studio-app-2[bot]

This comment was marked as resolved.

- 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>
deel-ai-studio-app[bot]

This comment was marked as resolved.

- 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>
deel-ai-studio-app-2[bot]

This comment was marked as resolved.

- 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>

@deel-ai-studio-app deel-ai-studio-app Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
  • Flag before the subcommand is dropped, so app --dry-run run still writes · fixed in 2b31ea5
  • No test covers --jq, alone or with --quiet, on app search/describe output · fixed in 2b31ea5
  • SSE data: null event makes parseRpcBody throw TypeError, not mcp.response · fixed in 2b31ea5
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>
@guilherme-soares-deel
guilherme-soares-deel merged commit 9284cef into dev Nov 25, 2026
3 checks passed
@guilherme-soares-deel
guilherme-soares-deel deleted the PA-8226-deel-app branch November 25, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted PR created or modified with AI assistance enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants