From 0c08b6ac1e52453870b8d76650cc018ca545aa62 Mon Sep 17 00:00:00 2001 From: Buffy Date: Fri, 4 Dec 2026 01:51:45 +0000 Subject: [PATCH] Let task submit sign a duration when the task has none 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 ` and the MCP tool as `duration`, and `--duration` together with `--withdraw` is rejected. --- packages/cli/src/task.test.ts | 22 ++++ packages/cli/src/task.ts | 19 +++- packages/core/src/tasks/operations.test.ts | 115 +++++++++++++++++++++ packages/core/src/tasks/operations.ts | 27 +++-- packages/mcp/src/tools/tasks.ts | 17 ++- 5 files changed, 189 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/task.test.ts b/packages/cli/src/task.test.ts index 6dcd518..0170b8b 100644 --- a/packages/cli/src/task.test.ts +++ b/packages/cli/src/task.test.ts @@ -1042,6 +1042,28 @@ describe("vapi task", () => { expect(result.value!.proposal).toMatchObject({ id: PROPOSAL_ID }); }); + it("signs the caller's --duration when the task has none (#143)", async () => { + const { client, dependencies } = await fixture(); + const result = await invoke( + ["submit", ID, "--proof", "https://example.com/proof", "--duration", "7d"], + dependencies, + ); + expect(result.code).toBe(0); + const [, input] = vi.mocked(client.submit).mock.calls[0]!; + if (!("signedPayload" in input)) throw new Error("Expected signed submission"); + expect(input.signedPayload.milestones[0]!.workDurationSeconds).toBe(604800); + }); + + it("refuses --duration with --withdraw and out-of-range durations", async () => { + const { dependencies } = await fixture(); + expect((await invoke(["submit", ID, "--withdraw", "--duration", "7d"], dependencies)).code).not.toBe(0); + const short = await invoke( + ["submit", ID, "--proof", "https://example.com/proof", "--duration", "5m"], + dependencies, + ); + expect(short.code, short.stdout.join(" ") + short.stderr.join(" ")).not.toBe(0); + }); + it.each([401, 403])("explains sign-in for participant HTTP %s", async (status) => { const { dependencies } = await fixture( true, diff --git a/packages/cli/src/task.ts b/packages/cli/src/task.ts index db9a7a8..4e56eba 100644 --- a/packages/cli/src/task.ts +++ b/packages/cli/src/task.ts @@ -133,7 +133,7 @@ export const TASK_HELP = `Usage: vapi task profile [--name --bio --skill ...] [--language ...] [--location ] [--photo |--remove-photo] [--account ] [--json] vapi task offer [] [--title ] [--description ] [--package ::