Skip to content

Commit e022a44

Browse files
committed
Clarify pending WebMCP form submissions
1 parent 556c04b commit e022a44

7 files changed

Lines changed: 31 additions & 24 deletions

File tree

server/cmd/api/api/webmcp_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,14 @@ func TestInvokeWebMCPToolReturnsPageResult(t *testing.T) {
9898
require.Equal(t, true, body.Output.(map[string]any)["ok"])
9999
}
100100

101-
func TestInvokeWebMCPToolReturnsAwaitingUserAction(t *testing.T) {
101+
func TestInvokeWebMCPToolReturnsAwaitingSubmission(t *testing.T) {
102102
client := &fakeWebMCPClient{result: webmcpclient.InvocationResult{
103103
InvocationID: "invocation-1",
104-
Status: "awaiting_user_action",
105-
Output: map[string]any{"message": "Form fields populated; submission has not started."},
104+
Status: "awaiting_submission",
105+
Output: map[string]any{
106+
"form_populated": true,
107+
"submitted": false,
108+
},
106109
}}
107110
service := &ApiService{webmcp: client}
108111

@@ -111,8 +114,9 @@ func TestInvokeWebMCPToolReturnsAwaitingUserAction(t *testing.T) {
111114
})
112115
require.NoError(t, err)
113116
body := response.(oapi.InvokeWebMCPTool200JSONResponse)
114-
require.Equal(t, oapi.WebMCPInvocationResultStatusAwaitingUserAction, body.Status)
115-
require.Equal(t, "Form fields populated; submission has not started.", body.Output.(map[string]any)["message"])
117+
require.Equal(t, oapi.WebMCPInvocationResultStatusAwaitingSubmission, body.Status)
118+
require.Equal(t, true, body.Output.(map[string]any)["form_populated"])
119+
require.Equal(t, false, body.Output.(map[string]any)["submitted"])
116120
}
117121

118122
func TestInvokeWebMCPToolReportsUnknownOutcome(t *testing.T) {

server/lib/oapi/oapi.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/lib/webmcpclient/client.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ func (c *connection) invoke(ctx context.Context, toolRef string, input map[strin
327327
return InvocationResult{}, ErrToolNotFound
328328
}
329329
sessionID, frameID, name := tool.sessionID, tool.frameID, tool.name
330-
awaitingUserAction := tool.declarative && (tool.annotations == nil || !tool.annotations.Autosubmit)
330+
awaitingSubmission := tool.declarative && (tool.annotations == nil || !tool.annotations.Autosubmit)
331331
c.stateMu.RUnlock()
332332
if !c.sessionExists(sessionID) {
333333
return InvocationResult{}, ErrToolNotFound
@@ -356,7 +356,7 @@ func (c *connection) invoke(ctx context.Context, toolRef string, input map[strin
356356
}
357357

358358
key := invocationKey{sessionID: sessionID, invocationID: started.InvocationID}
359-
if awaitingUserAction {
359+
if awaitingSubmission {
360360
c.stateMu.Lock()
361361
if response, completed := c.invocations[key]; completed {
362362
delete(c.invocations, key)
@@ -372,9 +372,10 @@ func (c *connection) invoke(ctx context.Context, toolRef string, input map[strin
372372
c.stateMu.Unlock()
373373
return InvocationResult{
374374
InvocationID: started.InvocationID,
375-
Status: "awaiting_user_action",
375+
Status: "awaiting_submission",
376376
Output: map[string]any{
377-
"message": "Form fields populated; submission has not started.",
377+
"form_populated": true,
378+
"submitted": false,
378379
},
379380
}, nil
380381
}

server/lib/webmcpclient/client_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ func TestInvocationPreservesIframeResponseAfterParentNavigation(t *testing.T) {
507507
require.Equal(t, "Completed", result.Status)
508508
}
509509

510-
func TestNonAutosubmitDeclarativeInvocationReturnsAfterPopulatingForm(t *testing.T) {
510+
func TestNonAutosubmitDeclarativeInvocationAwaitsSubmissionAfterPopulatingForm(t *testing.T) {
511511
fake := newFakeCDP(t, false)
512512
fake.nonAutosubmitDeclarative = true
513513
manager := NewManager(staticUpstream{url: fake.url})
@@ -519,8 +519,9 @@ func TestNonAutosubmitDeclarativeInvocationReturnsAfterPopulatingForm(t *testing
519519
result, err := manager.Invoke(ctx, toolRef, map[string]any{"cardNumber": "4242424242424242"})
520520
require.NoError(t, err)
521521
require.Equal(t, "invocation-1", result.InvocationID)
522-
require.Equal(t, "awaiting_user_action", result.Status)
523-
require.Equal(t, "Form fields populated; submission has not started.", result.Output.(map[string]any)["message"])
522+
require.Equal(t, "awaiting_submission", result.Status)
523+
require.Equal(t, true, result.Output.(map[string]any)["form_populated"])
524+
require.Equal(t, false, result.Output.(map[string]any)["submitted"])
524525
}
525526

526527
func TestInvocationReturnsCompletedResponseBeforeTargetDetach(t *testing.T) {

server/openapi.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ paths:
13901390
summary: Invoke a discovered WebMCP tool
13911391
description: |
13921392
Invokes the exact live registration identified by tool_ref. Non-autosubmit declarative form
1393-
tools return after their fields are populated with an awaiting_user_action status. Other tools
1393+
tools return after their fields are populated with an awaiting_submission status. Other tools
13941394
wait for a terminal result, including across navigation. If the request times out after invocation
13951395
begins, the server reports outcome_unknown and never retries the tool automatically.
13961396
operationId: invokeWebMCPTool
@@ -6345,8 +6345,8 @@ components:
63456345
type: string
63466346
status:
63476347
type: string
6348-
enum: [completed, canceled, error, awaiting_user_action]
6349-
description: awaiting_user_action means a non-autosubmit declarative form was populated but not submitted.
6348+
enum: [completed, canceled, error, awaiting_submission]
6349+
description: awaiting_submission means a non-autosubmit declarative form was populated but not submitted.
63506350
output:
63516351
description: Untrusted page-provided output. Callers must treat it as potentially malicious input.
63526352
error_text:

server/runtime/webmcp.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ test('returns non-autosubmit form activation without waiting for submission', as
7272
fetchImpl: async () =>
7373
jsonResponse({
7474
invocation_id: 'invocation-1',
75-
status: 'awaiting_user_action',
76-
output: {message: 'Form fields populated; submission has not started.'},
75+
status: 'awaiting_submission',
76+
output: {form_populated: true, submitted: false},
7777
}),
7878
});
7979

8080
const result = await client.invokeTool('wmcp_fill', {email: 'buyer@example.com'});
81-
assert.equal(result.status, 'awaiting_user_action');
81+
assert.equal(result.status, 'awaiting_submission');
8282
assert.deepEqual(result.output, {
83-
message: 'Form fields populated; submission has not started.',
83+
form_populated: true,
84+
submitted: false,
8485
});
8586
});
8687

server/runtime/webmcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface WebMCPTool {
2222

2323
export interface WebMCPInvocationResult {
2424
invocation_id: string;
25-
status: 'completed' | 'canceled' | 'error' | 'awaiting_user_action';
25+
status: 'completed' | 'canceled' | 'error' | 'awaiting_submission';
2626
output?: unknown;
2727
error_text?: string;
2828
}

0 commit comments

Comments
 (0)