Skip to content

task submit: sign a duration when the task has none (#143) - #146

Open
ggwuat-afk wants to merge 1 commit into
vAPI-Network:mainfrom
ggwuat-afk:fix/143-submit-duration
Open

ggwuat-afk wants to merge 1 commit into
vAPI-Network:mainfrom
ggwuat-afk:fix/143-submit-duration

Conversation

@ggwuat-afk

Copy link
Copy Markdown

Summary

Closes #143. A task created with durationSeconds = null (submissions intake) rejected every submission with

{"ok":false,"error":{"code":"not_available","message":"The task needs a duration between 10 minutes and 90 days for signed submission terms."}}

and neither client had an option to supply the missing duration, so the task was unsubmittable for every CLI/MCP agent.

submitTask now accepts an optional durationSeconds and prefers it over the task's own, so nothing changes for tasks that already carry a duration:

  • core (packages/core/src/tasks/operations.ts): input.durationSeconds wins over task.durationSeconds; either value is validated as a whole number inside the contract's window (600 s – 7 776 000 s). An explicit value outside that window is a TaskInputError; when neither side has a usable one the old not_available error remains, now naming the escape hatch.
  • CLI (packages/cli/src/task.ts): vapi task submit <id> --duration 7d (same parseTaskDuration grammar as task propose), rejected together with --withdraw, and listed in the submit help line.
  • MCP (packages/mcp/src/tools/tasks.ts): duration on the submit tool, with the same parsing and the same withdraw conflict.

Verification

New tests in packages/core/src/tasks/operations.test.ts (5) and packages/cli/src/task.test.ts (2):

$ vitest run packages/core/src/tasks packages/cli/src/task.test.ts packages/mcp/src/tools/tasks.test.ts
 Test Files  38 passed (38)
      Tests  1558 passed (1558)
  • task without a duration + durationSeconds: 3600 → signed payload carries workDurationSeconds: 3600
  • task with 172800 + explicit 604800 → 604800 wins
  • task with 172800 and no override → 172800 (unchanged behaviour)
  • 599, 7 776 001 and 3600.5 are refused with TaskInputError
  • neither side usable → not_available
  • CLI --duration 7d → workDurationSeconds: 604800; --withdraw --duration and --duration 5m exit non-zero

pnpm lint (eslint, 0 warnings) and pnpm typecheck (all packages, including examples) are clean.

I did not run this against a live tasks server: the tests use the repo's existing client mock, so the signed payload shape is verified but no real submission was sent.

A task created without durationSeconds (submissions intake) failed every
submission with not_available, and neither client had a way to supply one, so
the task was unsubmittable for everyone.

submitTask now takes an optional durationSeconds and prefers it over the task's
own, refusing anything outside the contract's 10 minutes-90 days window. The CLI
exposes it as `vapi task submit --duration <dur>` and the MCP tool as `duration`,
and `--duration` together with `--withdraw` is rejected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Submissions-bounty tasks without durationSeconds cannot be submitted via CLI (not_available)

2 participants