diff --git a/packages/agent-bridge/src/index.ts b/packages/agent-bridge/src/index.ts index 6c3ea31..5357253 100644 --- a/packages/agent-bridge/src/index.ts +++ b/packages/agent-bridge/src/index.ts @@ -48,6 +48,21 @@ export interface AgentBridgePresenceInput { avatar?: string; } +export type EditV2BlockOp = + | { op: 'replace_block'; ref: string; block: { markdown: string } } + | { op: 'insert_after'; ref: string; blocks: Array<{ markdown: string }> } + | { op: 'insert_before'; ref: string; blocks: Array<{ markdown: string }> } + | { op: 'delete_block'; ref: string } + | { op: 'replace_range'; fromRef: string; toRef: string; blocks: Array<{ markdown: string }> } + | { op: 'find_replace_in_block'; ref: string; find: string; replace: string; occurrence?: 'first' | 'all' }; + +export interface EditV2Input { + by: string; + baseRevision: number; + operations: EditV2BlockOp[]; + idempotencyKey?: string; +} + export interface AgentProviderMessage { role: 'system' | 'user' | 'assistant' | 'tool'; content: string; @@ -267,6 +282,16 @@ export function createAgentBridgeClient(config: AgentBridgeClientConfig) { ...options, }); }, + editV2(slug: string, input: EditV2Input, options: AgentBridgeRequestOptions = {}): Promise { + return requestJson(config, `${documentBasePath(slug)}/edit/v2`, { + method: 'POST', + body: JSON.stringify(input), + headers: { + ...(input.idempotencyKey ? { 'Idempotency-Key': input.idempotencyKey } : {}), + }, + ...options, + }); + }, }; }