返回 JoyAI-Echo
director-merge-protocol.md
根目录 / echo_longvideo / Director_Agent / docs / director-merge-protocol.md
1 # Director Merge Protocol
2
3 This document defines the Echo Director contract for final video merge jobs. Echo Server owns the
4 FFmpeg operation, the resulting video, and its artifact metadata.
5
6 ## Request
7
8 Nanobot submits merge jobs with:
9
10 - Method: `POST`
11 - Path: `/merge`
12 - Content type: `application/json`
13 - Protocol version: `director-http-v1`
14
15 Request body:
16
17 ```json
18 {
19 "protocol_version": "director-http-v1",
20 "operation": "merge_shot",
21 "job": {
22 "job_id": "merge-work-20260429-demo-final-20260429T140000Z",
23 "work_id": "work-20260429-demo",
24 "target": "final",
25 "created_at": "2026-04-29T14:00:00Z"
26 },
27 "callback": {
28 "event_type": "director_remote_result",
29 "protocol_version": "director-http-v1",
30 "operation": "merge_shot",
31 "work_id": "work-20260429-demo",
32 "job_id": "merge-work-20260429-demo-final-20260429T140000Z",
33 "target": "final",
34 "channel": "websocket",
35 "chat_id": "cafc067e-c8e3-4fb2-af11-62bc5c04e8d2",
36 "session_key": "websocket:cafc067e-c8e3-4fb2-af11-62bc5c04e8d2",
37 "inject_back_to_agent": true,
38 "url": "http://127.0.0.1:18791/api/director/merge-shot/callback"
39 },
40 "payload": {
41 "work_id": "work-20260429-demo",
42 "shot_ids": [1, 2],
43 "shots": [
44 {
45 "shot_id": 1,
46 "version_id": "r2v-version-id-for-shot-001"
47 }
48 ]
49 }
50 }
51 ```
52
53 The backend acknowledgement should be JSON:
54
55 ```json
56 {
57 "accepted": true,
58 "task_id": "remote-merge-task-id",
59 "version_id": "remote-merge-task-id",
60 "status": "queued",
61 "status_url": "https://backend.example/version/remote-merge-task-id"
62 }
63 ```
64
65 `remote_task_id` may also be returned as `task_id`.
66
67 ## Callback
68
69 When the merge completes, the backend calls the callback URL from the request:
70
71 - Method: `POST`
72 - Path: `/api/director/merge-shot/callback`
73 - Content type: `application/json`
74
75 Successful callback body:
76
77 ```json
78 {
79 "work_id": "work-20260429-demo",
80 "job_id": "merge-work-20260429-demo-final-20260429T140000Z",
81 "status": "completed",
82 "session_key": "websocket:cafc067e-c8e3-4fb2-af11-62bc5c04e8d2",
83 "channel": "websocket",
84 "chat_id": "cafc067e-c8e3-4fb2-af11-62bc5c04e8d2",
85 "remote_task_id": "remote-merge-task-id",
86 "result": {
87 "artifact_url": "http://127.0.0.1:8221/media/merges/remote-merge-task-id.mp4",
88 "result_url": "http://127.0.0.1:8221/media/merges/remote-merge-task-id.mp4"
89 },
90 "completed_at": "2026-04-29T14:02:00Z"
91 }
92 ```
93
94 The Agent treats the returned URL as an opaque media location; filesystem and object-storage details
95 remain inside Echo Server.
96
97 Failed callback body:
98
99 ```json
100 {
101 "work_id": "work-20260429-demo",
102 "job_id": "merge-work-20260429-demo-final-20260429T140000Z",
103 "status": "failed",
104 "session_key": "websocket:cafc067e-c8e3-4fb2-af11-62bc5c04e8d2",
105 "channel": "websocket",
106 "chat_id": "cafc067e-c8e3-4fb2-af11-62bc5c04e8d2",
107 "remote_task_id": "remote-merge-task-id",
108 "error": "merge failed"
109 }
110 ```
111
112 Nanobot applies completed callbacks to `state.final_output_url` or `state.final_output_path`, clears the pending merge job, publishes a workplace update, and exposes the final video in the workplace timeline after the shot list.
113
113 lines MARKDOWN