@lalalic/markcut 3.2.46 → 3.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/bin/markcut +18 -9
- package/package.json +1 -1
- package/src/mcp/bridge.mjs +44 -20
- package/src/mcp/compile-operation.mjs +2 -2
- package/src/mcp/compile-worker.mjs +6 -22
- package/src/mcp/mobile-review-cli.mjs +62 -14
- package/src/mcp/preview.mjs +5 -6
- package/src/mcp/remotion-app.bundle.js +73 -73
- package/src/mcp/remotion-app.tsx +2 -3
- package/tests/mcp-preview-bridge.test.ts +39 -26
- package/tests/mcp-preview.test.ts +14 -0
- package/tests/mobile-preview-cli.test.ts +36 -35
- package/src/mcp/phone-notification.mjs +0 -52
package/src/mcp/remotion-app.tsx
CHANGED
|
@@ -16,7 +16,7 @@ function App(){
|
|
|
16
16
|
const [currentTime,setCurrentTime]=React.useState(0);
|
|
17
17
|
const [browserTts,setBrowserTts]=React.useState(true);
|
|
18
18
|
const [commentedScenes,setCommentedScenes]=React.useState<string[]>([]);
|
|
19
|
-
const [spotMarkers,setSpotMarkers]=React.useState<Array<{id:number;scope:'overall'|'scene'|'spot';text:string;context:{timeSeconds:number;sceneName?:string};selected:boolean;placeholder?:boolean}>>([{id:0,scope:'overall',text:'',context:{timeSeconds:0},selected:
|
|
19
|
+
const [spotMarkers,setSpotMarkers]=React.useState<Array<{id:number;scope:'overall'|'scene'|'spot';text:string;context:{timeSeconds:number;sceneName?:string};selected:boolean;placeholder?:boolean}>>([{id:0,scope:'overall',text:'',context:{timeSeconds:0},selected:true,placeholder:true}]);
|
|
20
20
|
const [seekBar,setSeekBar]=React.useState<HTMLElement|null>(null);
|
|
21
21
|
React.useEffect(()=>{
|
|
22
22
|
const listener=(event:Event)=>setCommentedScenes((event as CustomEvent).detail?.sceneNames||[]);
|
|
@@ -31,7 +31,7 @@ function App(){
|
|
|
31
31
|
React.useEffect(()=>{const receive=(e:Event)=>setRevision((e as CustomEvent).detail);window.addEventListener('markcut:revision',receive);return ()=>window.removeEventListener('markcut:revision',receive)},[]);
|
|
32
32
|
const data=revision?.compiled?.root||revision?.compiled;
|
|
33
33
|
const useBrowserTts=browserTts&&Boolean(data?.subtitle?.src);
|
|
34
|
-
const {playbackRoot:generatedRoot
|
|
34
|
+
const {playbackRoot:generatedRoot}=useWebAudioPreview(data,ref);
|
|
35
35
|
const playbackRoot=React.useMemo(()=>{
|
|
36
36
|
if(!useBrowserTts)return generatedRoot;
|
|
37
37
|
return withoutRecordedNarration(generatedRoot);
|
|
@@ -112,7 +112,6 @@ function App(){
|
|
|
112
112
|
onPointerDown={e=>e.stopPropagation()} onClick={e=>{e.stopPropagation();window.dispatchEvent(new CustomEvent('markcut:spot-select',{detail:{id:note.id}}));}}/>;
|
|
113
113
|
})}
|
|
114
114
|
</>,seekBar)}
|
|
115
|
-
{status && !/initializing|ready|paused/i.test(status) && <div id="preview-audio-status" role="status" style={{fontSize:12,padding:'4px 0'}}>{status.replace(/^Web Audio /,'Audio ')}</div>}
|
|
116
115
|
</div>;
|
|
117
116
|
}
|
|
118
117
|
const el=document.getElementById('remotion-root');
|
|
@@ -12,7 +12,7 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>, too
|
|
|
12
12
|
replaceChildren(){this.children=[]},append(...items:any[]){this.children.push(...items)}
|
|
13
13
|
});
|
|
14
14
|
const nodes:Record<string,ReturnType<typeof element>>={
|
|
15
|
-
feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes:element(),'save-spot':element(),'remove-spot':element(),'comment-target':element(),'comment-
|
|
15
|
+
feedback:element(),status:element(),'path-label':element(),'video-md-version':element(),'interactive-ui':element(),approve:element(),changes:element(),'save-spot':element(),'remove-spot':element(),'comment-target':element(),'comment-mode':element(),'overall-mode':element(),'review-delivery-mode':element()
|
|
16
16
|
};
|
|
17
17
|
nodes['comment-mode'].value='spot';
|
|
18
18
|
let dispatch:(message:any,source?:any)=>void;
|
|
@@ -29,6 +29,7 @@ function harness(remoteData?:any, fetchOverride?:(url:string)=>Promise<any>, too
|
|
|
29
29
|
const result=(data:any)=>dispatch({method:'ui/notifications/tool-result',params:{result:{structuredContent:{...data}}}});
|
|
30
30
|
const respond=(id:number,result:any={})=>dispatch({id,result});
|
|
31
31
|
vm.runInContext(buildPreviewBridgeScript().replaceAll("__MARKCUT_ORIGIN__",JSON.stringify("https://neoy.qili2.com")),context);
|
|
32
|
+
events.length=0; // Ignore the initial Overall marker/selection render in tests about later events.
|
|
32
33
|
return {messages,nodes,events,dispatch,result,respond,scene:(detail:any)=>(listeners['markcut:scene-change']||[]).forEach(listener=>listener({detail})),selectSpot:(id:number)=>(listeners['markcut:spot-select']||[]).forEach(listener=>listener({detail:{id}}))};
|
|
33
34
|
}
|
|
34
35
|
const nextTick=()=>new Promise(resolve=>setTimeout(resolve,0));
|
|
@@ -79,6 +80,20 @@ describe('MCP Remotion bridge',()=>{
|
|
|
79
80
|
await nextTick();
|
|
80
81
|
expect(h.nodes.status.textContent).toBe('Review sent.');
|
|
81
82
|
});
|
|
83
|
+
it('shows Text mode by default, Event mode only with a provider-bound template',()=>{
|
|
84
|
+
const h=harness();
|
|
85
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Text mode');
|
|
86
|
+
const eventTemplate={type:'task.interactive_decision',source:'job/1/task/2/execution/3',
|
|
87
|
+
data:{interactive:{jobId:'1',taskId:'2',executionId:'3',invocationId:'i1'}}};
|
|
88
|
+
h.dispatch({method:'ui/notifications/tool-input',params:{arguments:{path:'/test.md',review:{delivery:'event'}}}});
|
|
89
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Event mode · unavailable');
|
|
90
|
+
h.result({path:'/test.md',id:'one',revisionId:'r1',contentHash:'a'.repeat(64),
|
|
91
|
+
compiled:{children:[]},review:{delivery:'event',eventTemplate}});
|
|
92
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Event mode');
|
|
93
|
+
h.result({path:'/test.md',id:'two',revisionId:'r2',contentHash:'b'.repeat(64),
|
|
94
|
+
compiled:{children:[]},review:{delivery:'text'}});
|
|
95
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Event mode · unavailable');
|
|
96
|
+
});
|
|
82
97
|
it('retries ui/message delivery errors and never reports success before delivery',async()=>{
|
|
83
98
|
let failed=0;const h=harness(undefined,undefined,(m)=>{if(m.method==='ui/message'&&failed++<2)return {rpcError:{message:'temporary delivery failure'}};return {content:[]};});
|
|
84
99
|
h.result({id:'retry',revisionId:'retry-r1',contentHash:'c'.repeat(64),path:'/retry.md',compiled:{children:[]}});
|
|
@@ -97,7 +112,6 @@ describe('MCP Remotion bridge',()=>{
|
|
|
97
112
|
a.nodes.changes.onclick?.();
|
|
98
113
|
expect(a.nodes.status.textContent).toBe('Feedback is required.');
|
|
99
114
|
expect(a.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
100
|
-
a.selectSpot(0);
|
|
101
115
|
a.nodes.feedback.value='Shorten the opening';
|
|
102
116
|
a.nodes['save-spot'].onclick?.();
|
|
103
117
|
a.nodes.changes.onclick?.();
|
|
@@ -137,7 +151,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
137
151
|
const h=harness();
|
|
138
152
|
const relay={jobId:'job-7',taskId:19,executionId:'exec-1'};
|
|
139
153
|
h.result({id:'r',revisionId:'r',contentHash:'hash',path:'/video.md',relay,compiled:{children:[]}});
|
|
140
|
-
h.
|
|
154
|
+
h.nodes.feedback.value='shorter title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
141
155
|
await nextTick();
|
|
142
156
|
expect(JSON.parse(h.messages.find(m=>m.method==='ui/message').params.content[0].text).relay).toEqual(relay);
|
|
143
157
|
});
|
|
@@ -146,7 +160,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
146
160
|
const first={id:'first',revisionId:'r1',contentHash:'sha1',path:'/video.md',compiled:{children:[{name:'First'}]}};
|
|
147
161
|
const next={id:'second',revisionId:'r2',contentHash:'sha2',path:'/video.md',compiled:{children:[{name:'Next'}]}};
|
|
148
162
|
h.result(first);
|
|
149
|
-
h.
|
|
163
|
+
h.nodes.feedback.value='lowercase title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
150
164
|
expect(JSON.parse(h.messages.find(m=>m.method==='ui/message').params.content[0].text)).toMatchObject({decision:'changes_requested'});
|
|
151
165
|
await nextTick();
|
|
152
166
|
h.respond(3);await nextTick();
|
|
@@ -163,36 +177,37 @@ describe('MCP Remotion bridge',()=>{
|
|
|
163
177
|
});
|
|
164
178
|
|
|
165
179
|
|
|
166
|
-
it('
|
|
180
|
+
it('preselects Overall by default, with no extra comment-count row',()=>{
|
|
167
181
|
const h=harness();
|
|
168
182
|
expect(h.nodes['comment-mode'].value).toBe('spot');
|
|
169
|
-
h.selectSpot(0);
|
|
170
183
|
expect(h.nodes['comment-mode'].hidden).toBe(true);
|
|
184
|
+
expect(h.nodes['review-delivery-mode'].textContent).toBe('Text mode');
|
|
171
185
|
expect(h.nodes['overall-mode'].hidden).toBe(false);
|
|
172
186
|
expect(h.nodes['remove-spot'].disabled).toBe(true);
|
|
173
187
|
h.nodes.feedback.value='Overall note';h.nodes['save-spot'].onclick?.();
|
|
174
188
|
let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
175
189
|
expect(dots.filter((x:any)=>x.scope==='overall')).toHaveLength(1);
|
|
176
190
|
expect(dots[0].placeholder).toBeUndefined();
|
|
177
|
-
h.
|
|
191
|
+
h.nodes['remove-spot'].onclick?.();
|
|
178
192
|
dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
179
193
|
expect(dots[0]).toMatchObject({id:0,scope:'overall',placeholder:true});
|
|
180
194
|
});
|
|
181
|
-
it('toggles
|
|
195
|
+
it('toggles default Overall marker off and back on',()=>{
|
|
182
196
|
const h=harness();
|
|
183
|
-
h.selectSpot(0);
|
|
184
|
-
let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
185
|
-
expect(dots[0].selected).toBe(true);
|
|
186
197
|
expect(h.nodes['overall-mode'].hidden).toBe(false);
|
|
187
198
|
h.selectSpot(0);
|
|
188
|
-
dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
199
|
+
let dots=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots;
|
|
189
200
|
expect(dots[0].selected).toBe(false);
|
|
190
201
|
expect(h.nodes['comment-mode'].hidden).toBe(false);
|
|
191
202
|
expect(h.nodes['overall-mode'].hidden).toBe(true);
|
|
192
203
|
expect(h.nodes.feedback.value).toBe('');
|
|
204
|
+
h.selectSpot(0);
|
|
205
|
+
expect(h.nodes['overall-mode'].hidden).toBe(false);
|
|
206
|
+
expect(h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots[0].selected).toBe(true);
|
|
193
207
|
});
|
|
194
208
|
it('auto-saves edits and new overall drafts when switching marker selection',()=>{
|
|
195
209
|
const h=harness();
|
|
210
|
+
h.selectSpot(0); // Leave default Overall to create timeline-specific spots.
|
|
196
211
|
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:0,timeSeconds:0});
|
|
197
212
|
h.nodes.feedback.value='First spot';h.nodes['save-spot'].onclick?.();
|
|
198
213
|
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:0,timeSeconds:5});
|
|
@@ -215,8 +230,8 @@ describe('MCP Remotion bridge',()=>{
|
|
|
215
230
|
});
|
|
216
231
|
it('saves overall, scene and spot scopes at their canonical timeline positions',async()=>{
|
|
217
232
|
const h=harness();h.result({id:'multi',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
218
|
-
h.selectSpot(0);
|
|
219
233
|
h.nodes.feedback.value='Improve pacing';h.nodes['save-spot'].onclick?.();
|
|
234
|
+
h.selectSpot(0); // Deselect Overall before creating scene/spot comments.
|
|
220
235
|
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:3,timeSeconds:4});
|
|
221
236
|
h.nodes['comment-mode'].value='scene';
|
|
222
237
|
h.nodes.feedback.value='Improve intro';h.nodes['save-spot'].onclick?.();
|
|
@@ -233,6 +248,7 @@ describe('MCP Remotion bridge',()=>{
|
|
|
233
248
|
});
|
|
234
249
|
it('supports multiple timed notes on one scene and restores a saved note',async()=>{
|
|
235
250
|
const h=harness();
|
|
251
|
+
h.selectSpot(0);
|
|
236
252
|
h.result({id:'spots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
237
253
|
h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
|
|
238
254
|
h.nodes.feedback.value='Trim opening';
|
|
@@ -253,27 +269,24 @@ describe('MCP Remotion bridge',()=>{
|
|
|
253
269
|
await nextTick();
|
|
254
270
|
const payload=JSON.parse(h.messages.at(-1).params.content[0].text);
|
|
255
271
|
expect(payload.comments).toHaveLength(2);
|
|
256
|
-
expect(h.nodes['comment-count'].textContent).toBe('2 comments');
|
|
257
272
|
expect(payload.comments.map((x:any)=>x.text)).toContain('Trim first second');
|
|
258
273
|
expect(payload.comments.map((x:any)=>x.text)).toContain('Keep reaction');
|
|
259
274
|
});
|
|
260
|
-
it('
|
|
275
|
+
it('submits typed unsaved text immediately as Overall feedback without an extra plus click',async()=>{
|
|
261
276
|
const h=harness();h.result({id:'draft',revisionId:'r',contentHash:'hash',compiled:{children:[]}});
|
|
262
|
-
h.scene({sceneId:'s1',sceneName:'Scene-A',sceneStart:2,timeSeconds:3});
|
|
263
277
|
h.nodes.feedback.value='Keep this text';
|
|
264
|
-
h.nodes['comment-mode'].value='scene';h.nodes['comment-mode'].onchange?.();
|
|
265
|
-
expect(h.nodes.feedback.value).toBe('Keep this text');
|
|
266
|
-
h.nodes.changes.onclick?.();
|
|
267
|
-
expect(h.nodes.status.textContent).toContain('Add or remove');
|
|
268
|
-
h.nodes['save-spot'].onclick?.();
|
|
269
|
-
const note=h.events.filter(e=>e.type==='markcut:spots-change').at(-1).detail.spots.find((x:any)=>!x.placeholder);
|
|
270
|
-
h.selectSpot(note.id);
|
|
271
278
|
h.nodes.changes.onclick?.();
|
|
272
279
|
await nextTick();
|
|
273
|
-
|
|
280
|
+
const sent=h.messages.filter(m=>m.method==='ui/message');
|
|
281
|
+
expect(sent).toHaveLength(1);
|
|
282
|
+
expect(JSON.parse(sent[0].params.content[0].text)).toMatchObject({
|
|
283
|
+
decision:'changes_requested',feedback:'Keep this text',comments:[{scope:'overall',text:'Keep this text'}]
|
|
284
|
+
});
|
|
285
|
+
expect(h.nodes.status.textContent).not.toContain('Add or remove');
|
|
274
286
|
});
|
|
275
287
|
it('deletes only the selected timeline marker',async()=>{
|
|
276
|
-
const h=harness();
|
|
288
|
+
const h=harness();
|
|
289
|
+
h.selectSpot(0);h.result({id:'dots',revisionId:'r1',contentHash:'hash',compiled:{children:[]}});
|
|
277
290
|
h.scene({sceneId:'s1',sceneName:'Scene-A',timeSeconds:1});
|
|
278
291
|
h.nodes.feedback.value='First';h.nodes['save-spot'].onclick?.();
|
|
279
292
|
h.scene({sceneId:'s2',sceneName:'Scene-B',timeSeconds:3});
|
|
@@ -367,7 +380,7 @@ describe('Review event delivery',()=>{
|
|
|
367
380
|
contentHash:'a'.repeat(64),path:'/tmp/video.md',compiled:{children:[]},review:{delivery:'event',eventTemplate:template}};
|
|
368
381
|
it('does not publish until explicit Submit, preserves fixed envelope and scoped comments',async()=>{
|
|
369
382
|
const h=harness(undefined,undefined, m=> m.method==='tools/call'?{published:true,event:{event_id:'ack'}}:undefined);
|
|
370
|
-
h.result(media);h.scene({sceneId:'intro',timeSeconds:2.25,sceneStart:0});
|
|
383
|
+
h.result(media);h.selectSpot(0);h.scene({sceneId:'intro',timeSeconds:2.25,sceneStart:0});
|
|
371
384
|
h.nodes.feedback.value='Trim opening';h.nodes['save-spot'].onclick?.();
|
|
372
385
|
expect(h.messages.filter(m=>m.method==='tools/call')).toHaveLength(0);
|
|
373
386
|
h.nodes.changes.onclick?.();await nextTick();
|
|
@@ -5,6 +5,7 @@ import {buildPreviewBridgeScript} from '../src/mcp/bridge.mjs';
|
|
|
5
5
|
import {mkdtemp,writeFile,rm} from 'node:fs/promises';
|
|
6
6
|
import {tmpdir} from 'node:os';
|
|
7
7
|
import {join} from 'node:path';
|
|
8
|
+
import {readFileSync} from 'node:fs';
|
|
8
9
|
describe('Markcut Remotion MCP App',()=>{
|
|
9
10
|
it('requires absolute Markdown path',()=>{expect(()=>validateMarkdownPath('a.md')).toThrow(/absolute/);expect(()=>validateMarkdownPath('/tmp/a.txt')).toThrow(/Markdown/);});
|
|
10
11
|
it('loads the React Remotion bundle from remote HTTPS',()=>{
|
|
@@ -16,6 +17,12 @@ describe('Markcut Remotion MCP App',()=>{
|
|
|
16
17
|
expect(html).toContain('<textarea id="feedback" rows="3"');
|
|
17
18
|
expect(html).toContain('id="comment-tools"');
|
|
18
19
|
expect(html).toContain('id="overall-mode" hidden>Overall');
|
|
20
|
+
expect(html).toContain('id="review-delivery-mode"');
|
|
21
|
+
expect(html).toContain('Text mode');
|
|
22
|
+
expect(html).toContain('Submit feedback');
|
|
23
|
+
expect(html).not.toContain('Submit all feedback');
|
|
24
|
+
expect(html).not.toContain('id="comment-count"');
|
|
25
|
+
expect(html).not.toContain('Add or remove the current comment before submitting.');
|
|
19
26
|
expect(html).not.toContain('<option value="overall"');
|
|
20
27
|
expect(html).toContain('#comment-tools>*{width:30px;height:28px;padding:0;border:0');
|
|
21
28
|
expect(html).toContain('https://neoy.example.test/files/_neoy/markcut/player/');
|
|
@@ -27,6 +34,13 @@ describe('Markcut Remotion MCP App',()=>{
|
|
|
27
34
|
expect(html).not.toContain('127.0.0.1');
|
|
28
35
|
expect(html).not.toContain('src="/player.js"');
|
|
29
36
|
});
|
|
37
|
+
it('omits the developer BGM decode-status row while preserving Web Audio playback',()=>{
|
|
38
|
+
const renderer=readFileSync(new URL('../src/mcp/remotion-app.tsx',import.meta.url),'utf8');
|
|
39
|
+
const audio=readFileSync(new URL('../src/mcp/web-audio-preview.ts',import.meta.url),'utf8');
|
|
40
|
+
expect(renderer).not.toContain('id="preview-audio-status"');
|
|
41
|
+
expect(audio).toContain('ctx.decodeAudioData(bytes)');
|
|
42
|
+
expect(audio).toContain("p.addEventListener('play',play)");
|
|
43
|
+
});
|
|
30
44
|
it('registers latest resource at startup and aliases previous URIs',()=>{
|
|
31
45
|
for(const uri of [RESOURCE_URI,...LEGACY_RESOURCE_URIS]){
|
|
32
46
|
const result=buildPreviewResourceResult(uri);
|
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
import {describe,it,expect} from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
import {mkdtempSync,writeFileSync,rmSync} from 'node:fs';
|
|
4
|
-
import {tmpdir} from 'node:os';
|
|
5
|
-
import {join} from 'node:path';
|
|
6
|
-
import {parseEventPreviewOptions} from '../src/mcp/mobile-review-cli.mjs';
|
|
7
|
-
import {buildPhoneReviewRequest,sendMasterReviewRequest} from '../src/mcp/phone-notification.mjs';
|
|
8
|
-
const hash='a'.repeat(64);
|
|
9
|
-
const operationId=randomUUID();
|
|
10
|
-
const template={type:'task.interactive_decision',source:'job/j1/task/producer/execution/e1',
|
|
11
|
-
data:{interactive:{jobId:'j1',taskId:'producer',executionId:'e1',invocationId:'review1'}}};
|
|
12
|
-
const result={id:hash,contentHash:hash,revisionId:hash,requestedPath:'/tmp/preview.md'};
|
|
2
|
+
import {parseEventPreviewOptions,neoReviewEndpoint,buildReviewRequest,submitNeoReview} from '../src/mcp/mobile-review-cli.mjs';
|
|
13
3
|
|
|
14
|
-
describe('
|
|
15
|
-
it('
|
|
4
|
+
describe('Standalone Markcut CLI preview (notification belongs to Neo)',()=>{
|
|
5
|
+
it('accepts externally supplied event templates without a phone or APNs URL',()=>{
|
|
16
6
|
expect(parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','template.json']).delivery).toBe('event');
|
|
17
7
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','event'])).toThrow();
|
|
18
8
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','a','--phone-url','http://phone'])).toThrow();
|
|
19
9
|
expect(parseEventPreviewOptions(['preview','video.md','--delivery','text']).delivery).toBe('text');
|
|
20
10
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','text','--event-template','a'])).toThrow();
|
|
21
11
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('Neo-owned REST notification from standalone CLI',()=>{
|
|
15
|
+
const id='82ba2e6c-6432-4ecd-83ee-cb78ba87c668';
|
|
16
|
+
const hash='f'.repeat(64);
|
|
17
|
+
const options={file:'/tmp/preview.md'};
|
|
18
|
+
const state={result:{id:'preview-123',contentHash:hash,revisionId:'revision-123'}};
|
|
19
|
+
it('builds a durable, immutable text request for phone view-only sync',()=>{
|
|
20
|
+
const request=buildReviewRequest(options,{delivery:'text'},state,id);
|
|
21
|
+
expect(request).toMatchObject({id,contentHash:hash,revisionId:'revision-123',
|
|
22
|
+
previewId:'preview-123',title:'preview',delivery:'text',groupId:'/tmp/preview.md'});
|
|
23
|
+
});
|
|
24
|
+
it('uses exact caller-bound template for Relay event review',()=>{
|
|
25
|
+
const template={type:'task.interactive_decision',source:'job/12/task/prod/execution/ex1',
|
|
26
|
+
data:{interactive:{jobId:'12',taskId:'prod',executionId:'ex1',invocationId:'i1'}}};
|
|
27
|
+
const request=buildReviewRequest(options,{delivery:'event',eventTemplate:template},state,id);
|
|
28
|
+
expect(request).toMatchObject({id,eventTemplate:template,jobId:'12',groupId:'job/12/task/prod'});
|
|
29
29
|
});
|
|
30
|
-
it('
|
|
31
|
-
const request=
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
it('POSTs to local Neo Core REST and requires persisted matching ACK',async()=>{
|
|
31
|
+
const request=buildReviewRequest(options,{delivery:'text'},state,id);
|
|
32
|
+
const seen:any[]=[];
|
|
33
|
+
const fetchImpl=async (url:string,init:any)=>{
|
|
34
|
+
seen.push({url,init});return {ok:true,json:async()=>({stored:true,requestId:id,accepted:false})};
|
|
35
|
+
};
|
|
36
|
+
const receipt=await submitNeoReview(request,{url:'http://127.0.0.1:6767/mobile/review/notify',fetchImpl} as any);
|
|
37
|
+
expect(receipt.stored).toBe(true);
|
|
38
|
+
expect(seen[0].init.method).toBe('POST');
|
|
39
|
+
expect(JSON.parse(seen[0].init.body)).toEqual(request);
|
|
40
|
+
expect(seen[0].init.headers['Content-Type']).toBe('application/json');
|
|
41
|
+
await expect(submitNeoReview(request,{url:'http://127.0.0.1:6767/mobile/review/notify',fetchImpl:async()=>({ok:true,json:async()=>({stored:false,requestId:id})})} as any)).rejects.toThrow('acknowledge');
|
|
42
|
+
await expect(submitNeoReview(request,{url:'http://127.0.0.1:6767/mobile/review/notify',fetchImpl:async()=>({ok:false,status:403})} as any)).rejects.toThrow('403');
|
|
35
43
|
});
|
|
36
|
-
it('
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const request=buildPhoneReviewRequest(operationId,result,{delivery:'event',eventTemplate:template});
|
|
40
|
-
try{
|
|
41
|
-
writeFileSync(script,`import fs from 'node:fs';const data=JSON.parse(fs.readFileSync(0,'utf8'));process.stdout.write(JSON.stringify({stored:true,accepted:false,requestId:data.id}));`);
|
|
42
|
-
expect(await sendMasterReviewRequest(request,{bridge:script})).toMatchObject({stored:true,accepted:false,requestId:operationId});
|
|
43
|
-
writeFileSync(script,`process.stdout.write(JSON.stringify({stored:false,requestId:'${operationId}'}));`);
|
|
44
|
-
await expect(sendMasterReviewRequest(request,{bridge:script})).rejects.toThrow(/persist/);
|
|
45
|
-
}finally{rmSync(tmp,{recursive:true,force:true});}
|
|
44
|
+
it('rejects delivery to remote origins and non-review routes',async()=>{
|
|
45
|
+
expect(()=>neoReviewEndpoint('https://evil.example/mobile/review/notify')).toThrow('local REST');
|
|
46
|
+
await expect(submitNeoReview({id} as any,{url:'http://127.0.0.1:6767/mcp'})).rejects.toThrow('nonlocal');
|
|
46
47
|
});
|
|
47
48
|
});
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/** Shared mobile-review delivery for both hosted MCP and Codex CLI previews. */
|
|
2
|
-
import {spawn} from 'node:child_process';
|
|
3
|
-
import {existsSync} from 'node:fs';
|
|
4
|
-
import {join,basename} from 'node:path';
|
|
5
|
-
import {homedir} from 'node:os';
|
|
6
|
-
import {normalizeReviewConfig} from './review-delivery.mjs';
|
|
7
|
-
const UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
|
-
const SHA=/^[0-9a-f]{64}$/;
|
|
9
|
-
|
|
10
|
-
export function buildPhoneReviewRequest(operationId,result,review,options={}){
|
|
11
|
-
const config=normalizeReviewConfig(review);
|
|
12
|
-
if(!UUID.test(operationId) || !result || !SHA.test(result.contentHash||'') ||
|
|
13
|
-
!result.revisionId || !result.id)throw new Error('Immutable Preview is not ready');
|
|
14
|
-
const id=options.requestId||operationId;
|
|
15
|
-
if(!UUID.test(id))throw new Error('Invalid phone request UUID');
|
|
16
|
-
const title=options.title || basename(result.requestedPath||'video.md','.md');
|
|
17
|
-
const request={id,contentHash:result.contentHash,revisionId:result.revisionId,
|
|
18
|
-
previewId:result.id,title,delivery:config.delivery};
|
|
19
|
-
if(config.delivery==='event'){
|
|
20
|
-
const fixed=config.eventTemplate.data.interactive;
|
|
21
|
-
request.eventTemplate=config.eventTemplate;
|
|
22
|
-
request.jobId=fixed.jobId;
|
|
23
|
-
request.groupId=options.groupId||`job/${fixed.jobId}/task/${fixed.taskId}`;
|
|
24
|
-
}else{
|
|
25
|
-
// A ChatGPT text-only preview has no Relay event identity or owning thread.
|
|
26
|
-
// Mirror the video to iPhone as view-only; ChatGPT still owns its text review.
|
|
27
|
-
request.groupId=options.groupId||result.requestedPath;
|
|
28
|
-
}
|
|
29
|
-
if(options.groupTitle)request.groupTitle=options.groupTitle;
|
|
30
|
-
return request;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function sendMasterReviewRequest(request,{bridge=process.env.NEOX_APNS_BRIDGE,timeoutMs=20000}={}){
|
|
34
|
-
const binary=bridge || join(homedir(),'Workspace/neox/NeoxAPNs/review-cli.mjs');
|
|
35
|
-
if(!existsSync(binary))throw new Error('Neo Master APNs review bridge unavailable: '+binary);
|
|
36
|
-
return await new Promise((resolve,reject)=>{
|
|
37
|
-
const child=spawn(process.execPath,[binary,'notify'],{stdio:['pipe','pipe','pipe']});
|
|
38
|
-
let out='',err='',done=false;
|
|
39
|
-
const finish=(error,result)=>{if(done)return;done=true;clearTimeout(timer);if(error)reject(error);else resolve(result);};
|
|
40
|
-
const timer=setTimeout(()=>{child.kill('SIGTERM');finish(new Error('Master review push timed out'));},timeoutMs);
|
|
41
|
-
child.stdout.on('data',d=>{out+=d; if(out.length>256000)child.kill('SIGTERM');});
|
|
42
|
-
child.stderr.on('data',d=>{if(err.length<1000)err+=d;});
|
|
43
|
-
child.on('error',e=>finish(e));
|
|
44
|
-
child.on('exit',code=>{
|
|
45
|
-
if(code!==0)return finish(new Error('Master review delivery failed: '+err.slice(0,250)));
|
|
46
|
-
let parsed;try{parsed=JSON.parse(out);}catch{return finish(new Error('Invalid Master review receipt'));}
|
|
47
|
-
if(parsed.stored!==true || parsed.requestId!==request.id)return finish(new Error('Master did not persist review request'));
|
|
48
|
-
finish(null,parsed);
|
|
49
|
-
});
|
|
50
|
-
child.stdin.end(JSON.stringify(request));
|
|
51
|
-
});
|
|
52
|
-
}
|