Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
masnwilliams
left a comment
There was a problem hiding this comment.
Approve with comments.
The no-retry handling, the "not invoked" vs "may have run" errors, and the escaping of untrusted output all match how fill and 1pw_fill already behave, and the tests are thorough. Three things I'd like fixed before merge (inline):
input_path: "/"is rejected locally but valid against the API.- Parse straight into
kernel.WebmcpInvokeVaultItemOperationRequestParaminstead of a parallel struct. - Reuse the spec-file reader for
--input-file.
Optional:
vaultWebMCPRequestErroris nearly identical tovaultFillRequestError(and to the inline block inonePasswordFill). OnevaultOperationRequestError(err, op, messages, rejected, uncertain)would cover all three.vaultFillOutcomeError.Error()returns"fill " + status, so a failed WebMCP invoke reports itself asfill error. It's silent, so nobody sees it today, but a generic name with the operation in the message would be clearer.- The status values appear in three switches (validation, human-mode hint, exit code). One
map[status]{ok, hint}would combine them. The awaiting-submission text could also be shared withbrowsers_webmcp.go.
| // vaultWebMCPNullSlot mirrors the API: a binding replaces an existing null and never | ||
| // creates a property or array entry. | ||
| func vaultWebMCPNullSlot(input any, path string) bool { | ||
| if len(path) < 2 || len(path) > 2048 || path[0] != '/' { |
There was a problem hiding this comment.
"/" is the RFC 6901 pointer to the empty-string key, and the API accepts it (it only rejects len(path) < 1). Changing this to len(path) < 1 fixes it. Since this copies the server's rules on purpose, a comment pointing to the API as the source of truth would help keep the two from drifting.
There was a problem hiding this comment.
Fixed in ebbfb39. The check is now len(path) < 1, so "/" addresses the empty-string key and only the root pointer "" is rejected. I added a doc comment on validateVaultWebMCPParams and vaultWebMCPNullSlot saying they mirror the API's rules and the API is the source of truth. New test: TestVaultWebMCPInvokeEmptyKeyPointerAndInputFile binds email=/ against {"":null,...} through --input, --input-file, stdin, and --params.
| "execution_failed": "WebMCP invocation failed", | ||
| } | ||
|
|
||
| type vaultWebMCPParams struct { |
There was a problem hiding this comment.
vaultWebMCPParams and vaultWebMCPBinding restate kernel.WebmcpInvokeVaultItemOperationRequestParam / kernel.VaultWebmcpBindingParam field for field, and webMCPInvoke spends about 20 lines (229-249) converting one into the other. 1pw_* already stores the full SDK request in vaultOperationParams. If decodeVaultWebMCPInput returns map[string]any with json.RawMessage values (as browsers_webmcp.go does), the conversion goes away and large numbers are still preserved.
There was a problem hiding this comment.
Fixed in ebbfb39. I removed vaultWebMCPParams and vaultWebMCPBinding. Both parseVaultWebMCPParams and vaultWebMCPParamsFromFlags now build kernel.WebmcpInvokeVaultItemOperationRequestParam directly, and vaultOperationParams.WebMCP holds that type. decodeVaultWebMCPInput returns map[string]any with json.RawMessage values, the same as browsers_webmcp.go, so the conversion block is gone and large numbers still pass through unchanged. The existing large-integer assertions still pass.
| params.PageURL, _ = cmd.Flags().GetString("page-url") | ||
| input, _ := cmd.Flags().GetString("input") | ||
| data := []byte(input) | ||
| if cmd.Flags().Changed("input-file") { |
There was a problem hiding this comment.
This repeats readVaultSpecFile: open the path or -, apply the 128 KiB limit, return the same errors. Changing it to readVaultJSONFile(cmd, flag) and calling it from both places removes the copy.
There was a problem hiding this comment.
Fixed in ebbfb39. I renamed readVaultSpecFile to readVaultJSONFile(cmd, flag), and --spec-file and --input-file now both use it. The spec-file errors are unchanged. --input-file gets the same open/128 KiB/JSON-object errors with its own flag name, covered by TestVaultWebMCPInvokeInputFileErrors.
|
Thanks @masnwilliams. All three required fixes are in ebbfb39 (replies inline). I took the optional ones too:
|
Summary
Adds CLI support for the vault
webmcp_invokeoperation, which invokes a live WebMCP tool with values from a credential item or ready Link card substituted into null input slots.github.com/kernel/kernel-go-sdkfrom v0.116.0 to v0.117.0, which addsWebmcpInvokeVaultItemOperationRequestParamand thewebmcp_invokeresult.--input-file <path|->replaces--input. Card expiration uses--bind expiration:MM/YY=/pointer.kernel vaults items invoke <vault> <key> webmcp_invoke --params/--spec-fileaccepts the same request as JSON (browser_id,tool_ref,page_url,input,bindings[{field,input_path,format?}],timeout_sec). Both forms go through the sameInvokepath: the item is fetched first, and the operation must appear inavailable_operations. Before this change, an advertisedwebmcp_invokefell through to the parameterless-operation branch.input_pathis an RFC 6901 pointer to an existingnull(no root, no-append, canonical in-range indices, valid~0/~1escapes). It also checks: input is a JSON object of at most 64 KiB;tool_refis non-empty and at most 128 bytes;page_urlis absolute with no fragment;timeout_secis 1-120. Top-level input members are sent as raw JSON so numbers are not re-encoded. The SDK encodesjson.Numberas a string, which would change them.-o jsonprintstype,status,invocation_id,output(raw JSON preserved) anderror_textas returned. Human output labelsoutput/error_textas untrusted page data that may contain supplied values. Both are JSON-encoded so page-supplied terminal control characters are escaped.completedandawaiting_submissionexit 0.awaiting_submissiondirects the user to submit the populated form instead of re-invoking, matchingbrowsers webmcp invoke.canceled,errorandunknownexit nonzero with no extra diagnostic; the JSON result stays on stdout.WithMaxRetries(0).vaults,items,items invoke,items webmcp invoke) and README updated. Existing fill semantics are unchanged.Tests
make test(go vet + go test ./...) passes. Newcmd/vaults_webmcp_test.gocovers:email/passwordnull slots) through both the flag command anditems invoke ... webmcp_invoke --spec-file, asserting the exact request body and the JSON result, including a large integer preserved in outputerror_textNot run against the live API.