Skip to content

feat(agent-bridge): add editV2 method with correct field names#32

Open
hnshah wants to merge 1 commit intoEveryInc:mainfrom
hnshah:docs/fix-api-consistency
Open

feat(agent-bridge): add editV2 method with correct field names#32
hnshah wants to merge 1 commit intoEveryInc:mainfrom
hnshah:docs/fix-api-consistency

Conversation

@hnshah
Copy link
Copy Markdown

@hnshah hnshah commented Mar 23, 2026

Fixes #22

Problem

The editV2() method was missing from the agent bridge client, and there was a field name mismatch between client expectations and server reality.

Server expects (from server/agent-edit-v2.ts):

  • baseRevision (number)
  • operations (array of block operations)

What was missing:

  • No editV2() method in the bridge client
  • No TypeScript types for edit v2 operations

Solution

This PR adds:

EditV2Input interface with correct field names matching the server
EditV2BlockOp union type covering all 6 operation types:

  • replace_block
  • insert_after
  • insert_before
  • delete_block
  • replace_range
  • find_replace_in_block

editV2() client method that POSTs to /documents/:slug/edit/v2
Idempotency-Key header support (auto-set from input.idempotencyKey)

Usage

const bridge = createAgentBridgeClient({ baseUrl, auth: { shareToken } });

await bridge.editV2(slug, {
  by: 'ai:my-agent',
  baseRevision: 128,
  operations: [
    { op: 'replace_block', ref: 'b3', block: { markdown: '# Updated' } },
    { op: 'insert_after', ref: 'b3', blocks: [{ markdown: '## New section' }] }
  ],
  idempotencyKey: crypto.randomUUID()
});

Testing

  • ✅ Field names match server implementation
  • ✅ All operation types from server/agent-edit-v2.ts are covered
  • ✅ Idempotency header automatically included when key provided
  • ✅ Follows existing bridge client patterns

Related

Fixes EveryInc#22

The editV2() method was missing from the agent bridge client, and there
was a field name mismatch between what developers might expect and what
the server actually accepts.

Server expects:
- baseRevision (number)
- operations (array of ops)

This adds:
- EditV2Input interface with correct field names
- EditV2BlockOp union type covering all 6 operation types
- editV2() client method that POSTs to /documents/:slug/edit/v2
- Idempotency-Key header support (automatically set from input.idempotencyKey)

All field names now match the server implementation in server/agent-edit-v2.ts.
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.

EditV2Input type sends wrong field names — revision/ops vs server's baseRevision/operations

1 participant