@lalalic/markcut 3.2.56 → 3.2.58
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/docs/developer-reference.md +18 -3
- package/package.json +1 -1
- package/src/mcp/bridge.mjs +16 -18
- package/src/mcp/compile-operation.mjs +2 -2
- package/src/mcp/compile-worker.mjs +3 -3
- package/src/mcp/mobile-review-cli.mjs +6 -14
- package/src/mcp/review-delivery.mjs +37 -53
- package/src/mcp/server.mjs +4 -6
- package/tests/mcp-preview-bridge.test.ts +14 -11
- package/tests/mcp-preview-delivery.test.ts +30 -31
- package/tests/mobile-preview-cli.test.ts +6 -5
|
@@ -317,6 +317,21 @@ When extracting HTTPS BGM from a preview tree, traverse the tree **before** retu
|
|
|
317
317
|
|
|
318
318
|
For `map view:route`, omit `zoom` to auto-fit geotagged stops to the Remotion composition dimensions, including 9:16 vertical output; auto-fit reserves 14% padding. The route schema and both descriptive compiler paths must leave omitted zoom undefined, or their old `zoom:10` defaults silently override the runtime fit. Explicit `zoom` and camera tweens still override fit. Verify the real browser map's zoom/center and rendered tiles, not just a successful Markdown compile or Google API HTTP response. A calculated Directions line is not proof of a recorded GPS track.
|
|
319
319
|
|
|
320
|
-
##
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
## Generic Preview event delivery
|
|
321
|
+
|
|
322
|
+
Markcut is a renderer and event transport, not a workflow or review authority. With
|
|
323
|
+
`review: {delivery: "event", eventTemplate: {type, source, data, responseKey?}}`,
|
|
324
|
+
the caller supplies an Events Bus envelope. Markcut validates only its transport
|
|
325
|
+
shape and basic safety constraints, preserves the opaque caller data, appends the
|
|
326
|
+
human decision and comments at `data[responseKey ?? "review"]`, then calls the
|
|
327
|
+
host Events provider with `command: "publish"`. A positive publish receipt
|
|
328
|
+
means **transport accepted**, not that the receiving workflow completed.
|
|
329
|
+
|
|
330
|
+
Neither Markcut Preview nor its standalone CLI interprets the event type/source,
|
|
331
|
+
Relay Task/Execution IDs, commits, or revision policy. The Neo Wrapper owns
|
|
332
|
+
Relay-specific event construction and identity verification; Relay owns Task
|
|
333
|
+
state and recovery. Neo Mobile follows the same generic event transport rule.
|
|
334
|
+
Media `contentHash` is only for compiled player retrieval and does not become
|
|
335
|
+
an event revision or Git identity. On event publication failures, preserve
|
|
336
|
+
comments/idempotency and report the transport failure; do not silently change
|
|
337
|
+
delivery channels.
|
package/package.json
CHANGED
package/src/mcp/bridge.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function buildPreviewBridgeScript() {
|
|
2
2
|
return `
|
|
3
3
|
const feedback=document.getElementById('feedback'),status=document.getElementById('status'),pathLabel=document.getElementById('path-label');
|
|
4
|
-
let nextId=0,identity=null,busy=false,expectedPath=null,activePath=null,
|
|
4
|
+
let nextId=0,identity=null,busy=false,expectedPath=null,activePath=null,activeReview={delivery:"text"},expectedDelivery="text",expectedReadonly=false,submittedRevision=null,submission=null;
|
|
5
5
|
const comments=[];
|
|
6
6
|
let currentScene={sceneId:null,sceneName:null,sceneStart:0,timeSeconds:0},selectedId=0,nextCommentId=0;
|
|
7
7
|
const mode=document.getElementById('comment-mode');
|
|
@@ -148,25 +148,25 @@ function applyToolInput(params){
|
|
|
148
148
|
}
|
|
149
149
|
let operationGeneration=0;
|
|
150
150
|
function eventEnvelope(template,review){
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
['
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
151
|
+
// Markcut delivers caller-authored events without inspecting their business type or identity.
|
|
152
|
+
if(!template || typeof template.type!=='string'||typeof template.source!=='string'||
|
|
153
|
+
!template.data||typeof template.data!=='object'||Array.isArray(template.data))
|
|
154
|
+
throw new Error('Invalid caller event template');
|
|
155
|
+
const key=template.responseKey||'review';
|
|
156
|
+
if(!/^[A-Za-z_][A-Za-z0-9_-]{0,63}$/.test(key)||['__proto__','constructor','prototype'].includes(key)||
|
|
157
|
+
(template.data[key]!==undefined && (typeof template.data[key]!=='object'||Array.isArray(template.data[key])||!template.data[key])))
|
|
158
|
+
throw new Error('Invalid caller response key');
|
|
159
|
+
const fixed=template.data[key]||{};
|
|
160
|
+
if(['decision','feedback','comments','previewId','requestId','idempotencyKey'].some(k=>Object.prototype.hasOwnProperty.call(fixed,k)))
|
|
161
|
+
throw new Error('Review data cannot be prefilled');
|
|
162
|
+
return {type:template.type,source:template.source,data:{...template.data,[key]:{
|
|
163
|
+
...fixed,previewId:review.previewId,requestId:review.requestId,decision:review.decision,
|
|
162
164
|
feedback:review.feedback||review.comments.map(c=>c.text).join('\\n'),
|
|
163
165
|
comments:review.comments,idempotencyKey:review.idempotencyKey
|
|
164
166
|
}}};
|
|
165
167
|
}
|
|
166
|
-
|
|
167
168
|
async function sendReviewEvent(result){
|
|
168
|
-
if(
|
|
169
|
-
result.commitSha=activeReview.commitSha;
|
|
169
|
+
if(!activeReview.eventTemplate)throw new Error('Review event template unavailable');
|
|
170
170
|
const event=eventEnvelope(activeReview.eventTemplate,result);
|
|
171
171
|
// MCP Apps tools/call is host-mediated; an unavailable or unauthorized Events
|
|
172
172
|
// provider MUST fail, never be substituted with ui/message.
|
|
@@ -203,7 +203,7 @@ async function trackOperation(data){
|
|
|
203
203
|
if(generation!==operationGeneration)return;
|
|
204
204
|
if(progress.state==='ready'&&progress.result){
|
|
205
205
|
await renderRevision({...progress.result,requestedPath:data.requestedPath||data.path,
|
|
206
|
-
requestId:progress.result.requestId||data.requestId,review:progress.result.review||data.review
|
|
206
|
+
requestId:progress.result.requestId||data.requestId,review:progress.result.review||data.review});
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
if(progress.state==='failed'){reviewReadonly(true,'Compilation failed: '+progress.error);return;}
|
|
@@ -252,7 +252,6 @@ async function renderRevision(data){
|
|
|
252
252
|
activeReview=data.review||{delivery:'text'};
|
|
253
253
|
updateDeliveryMode();
|
|
254
254
|
activePath=data.requestedPath||data.path||expectedPath||null;
|
|
255
|
-
activeRelay=data.relay||null;
|
|
256
255
|
if(submittedRevision!==data.revisionId){busy=false;submittedRevision=null;submission=null;}
|
|
257
256
|
reviewReadonly(true,'Loading static compiled scenes…');
|
|
258
257
|
try{
|
|
@@ -331,7 +330,6 @@ async function submit(decision){
|
|
|
331
330
|
if(!submission || submission.signature!==signature)submission={signature,key:crypto.randomUUID()};
|
|
332
331
|
result.idempotencyKey=submission.key;
|
|
333
332
|
if(activePath)result.path=activePath;
|
|
334
|
-
if(activeRelay)result.relay=activeRelay;
|
|
335
333
|
if(decision==='changes_requested'){
|
|
336
334
|
result.feedback=preparedComments.length===1?preparedComments[0].text:preparedComments.map((item,index)=>String(index+1)+'. ['+sceneKey(item.playbackContext)+' @ '+(item.playbackContext.timeSeconds??0)+'s] '+item.text).join('\\n');
|
|
337
335
|
if(window.__markcutPlaybackContext)result.playbackContext=window.__markcutPlaybackContext;
|
|
@@ -27,7 +27,7 @@ export function writeOperation(id,data){
|
|
|
27
27
|
writeFileSync(temp,JSON.stringify(data),{mode:0o644});
|
|
28
28
|
renameSync(temp,join(folder,id+".json"));
|
|
29
29
|
}
|
|
30
|
-
export function startCompileOperation(path,
|
|
30
|
+
export function startCompileOperation(path,review={delivery:"text"}){
|
|
31
31
|
const valid=validateMarkdownPath(resolvePreviewPath(path));
|
|
32
32
|
if(!statSync(valid).isFile())throw new Error("Preview source must be a Markdown file");
|
|
33
33
|
const input=fingerprintInputs(valid);
|
|
@@ -36,7 +36,7 @@ export function startCompileOperation(path,relay,review={delivery:"text"}){
|
|
|
36
36
|
const id=randomUUID(),startedAt=Date.now();
|
|
37
37
|
writeOperation(id,{id,state:"compiling",stage:"queued",startedAt,requestedPath:path});
|
|
38
38
|
const worker=fileURLToPath(new URL("./compile-worker.mjs",import.meta.url));
|
|
39
|
-
const child=spawn(process.execPath,[worker,id,valid,path,
|
|
39
|
+
const child=spawn(process.execPath,[worker,id,valid,path,sourceHash,JSON.stringify(review)],{detached:true,stdio:"ignore"});
|
|
40
40
|
child.on("error",e=>{
|
|
41
41
|
writeOperation(id,{id,state:"failed",stage:"failed",startedAt,requestedPath:path,error:e.message});
|
|
42
42
|
});
|
|
@@ -3,7 +3,7 @@ import {ensureVideoPreview} from "./preview.mjs";
|
|
|
3
3
|
import {publishPreviewRevision} from "./remote-assets.mjs";
|
|
4
4
|
import {writeOperation} from "./compile-operation.mjs";
|
|
5
5
|
import {fingerprintInputs} from "./source-fingerprint.mjs";
|
|
6
|
-
const [id,path,requestedPath,
|
|
6
|
+
const [id,path,requestedPath,sourceHash,reviewText]=process.argv.slice(2);
|
|
7
7
|
const startedAt=Date.now();
|
|
8
8
|
const review=JSON.parse(reviewText||'{"delivery":"text"}');
|
|
9
9
|
function update(stage){writeOperation(id,{id,state:"compiling",stage,startedAt,updatedAt:Date.now(),requestedPath});}
|
|
@@ -17,9 +17,9 @@ try{
|
|
|
17
17
|
publishPreviewRevision(requestedPath,{...result,requestedPath});
|
|
18
18
|
// Markcut is a pure preview provider. The Neo MCP wrapper owns mobile delivery.
|
|
19
19
|
writeOperation(id,{id,state:"ready",stage:"complete",startedAt,updatedAt:Date.now(),requestedPath,
|
|
20
|
-
result:{...result,requestedPath,requestId:id,review
|
|
20
|
+
result:{...result,requestedPath,requestId:id,review}});
|
|
21
21
|
|
|
22
22
|
}catch(e){
|
|
23
|
-
writeOperation(id,{id,state:"failed",stage:"failed",startedAt,updatedAt:Date.now(),requestedPath,review,
|
|
23
|
+
writeOperation(id,{id,state:"failed",stage:"failed",startedAt,updatedAt:Date.now(),requestedPath,review,error:e?.message||String(e)});
|
|
24
24
|
process.exitCode=1;
|
|
25
25
|
}
|
|
@@ -10,20 +10,17 @@ const delay = ms => new Promise(done => setTimeout(done,ms));
|
|
|
10
10
|
|
|
11
11
|
export function parseEventPreviewOptions(argv) {
|
|
12
12
|
if (argv[0] !== 'preview' || !argv[1] || argv[1].startsWith('--')) throw new Error('Usage: markcut preview <file.md> --delivery event --event-template <file.json>');
|
|
13
|
-
const allowed=new Set(['--delivery','--event-template','--timeout-ms'
|
|
13
|
+
const allowed=new Set(['--delivery','--event-template','--timeout-ms']);
|
|
14
14
|
const options={file:resolve(argv[1])};
|
|
15
15
|
for(let i=2;i<argv.length;i+=2){
|
|
16
16
|
const flag=argv[i],value=argv[i+1];
|
|
17
17
|
if(!allowed.has(flag) || !value || value.startsWith('--'))throw new Error('Missing or unsupported preview event flag: '+flag);
|
|
18
|
-
const key={'--delivery':'delivery','--event-template':'eventTemplatePath','--timeout-ms':'timeoutMs'
|
|
18
|
+
const key={'--delivery':'delivery','--event-template':'eventTemplatePath','--timeout-ms':'timeoutMs'}[flag];
|
|
19
19
|
if(Object.hasOwn(options,key))throw new Error('Duplicate flag: '+flag);
|
|
20
20
|
options[key]=value;
|
|
21
21
|
}
|
|
22
22
|
if(!['text','event'].includes(options.delivery) || (options.delivery==='event')!==Boolean(options.eventTemplatePath))
|
|
23
23
|
throw new Error('Event delivery requires --event-template; Text delivery must omit it');
|
|
24
|
-
if(options.delivery==='event' && !/^[a-f0-9]{40}$/.test(options.commitSha||''))
|
|
25
|
-
throw new Error('Event review requires --commit-sha with full 40-character Git SHA');
|
|
26
|
-
if(options.delivery==='text' && options.commitSha)throw new Error('Text previews do not bind a Git Commit SHA');
|
|
27
24
|
const limit=options.timeoutMs===undefined ? 300000 : Number(options.timeoutMs);
|
|
28
25
|
if(!Number.isSafeInteger(limit) || limit<1000 || limit>1800000)throw new Error('--timeout-ms must be 1000..1800000');
|
|
29
26
|
options.timeoutMs=limit;
|
|
@@ -57,13 +54,9 @@ export function buildReviewRequest(options,config,state,operationId){
|
|
|
57
54
|
throw Error('Compiled Preview has no immutable revision identity');
|
|
58
55
|
const request={id:operationId,previewId:data.id,title:basename(options.file,'.md'),delivery:config.delivery};
|
|
59
56
|
if(config.delivery==='event'){
|
|
60
|
-
if(!/^[a-f0-9]{40}$/.test(options.commitSha||''))throw Error('Git Commit SHA required for Event Review');
|
|
61
|
-
request.commitSha=options.commitSha;
|
|
62
57
|
request.mediaHash=data.contentHash; // Transport-only lookup for the compiled player, never the review identity.
|
|
63
|
-
const fixed=config.eventTemplate.data.interactive;
|
|
64
58
|
request.eventTemplate=config.eventTemplate;
|
|
65
|
-
request.
|
|
66
|
-
request.groupId=`job/${fixed.jobId}/task/${fixed.taskId}`;
|
|
59
|
+
request.groupId=options.file;
|
|
67
60
|
}else {request.contentHash=data.contentHash;request.revisionId=data.revisionId;request.groupId=options.file;}
|
|
68
61
|
return request;
|
|
69
62
|
}
|
|
@@ -84,12 +77,12 @@ export async function submitNeoReview(request,{fetchImpl=fetch,url=neoReviewEndp
|
|
|
84
77
|
|
|
85
78
|
export async function runMobilePreview(argv){
|
|
86
79
|
const opts=parseEventPreviewOptions(argv);
|
|
87
|
-
const config=opts.delivery==='event' ? normalizeReviewConfig({delivery:'event',
|
|
80
|
+
const config=opts.delivery==='event' ? normalizeReviewConfig({delivery:'event',
|
|
88
81
|
eventTemplate:JSON.parse(readFileSync(resolve(opts.eventTemplatePath),'utf8'))}) : {delivery:'text'};
|
|
89
82
|
const [{startCompileOperation},{EXPORT_ROOT}]=await Promise.all([
|
|
90
83
|
import('./compile-operation.mjs'),import('./remote-assets.mjs'),
|
|
91
84
|
]);
|
|
92
|
-
const operation=startCompileOperation(opts.file,
|
|
85
|
+
const operation=startCompileOperation(opts.file,config);
|
|
93
86
|
const stateFile=join(EXPORT_ROOT,'operations',operation.operationId+'.json');
|
|
94
87
|
let state;
|
|
95
88
|
const until=Date.now()+opts.timeoutMs;
|
|
@@ -103,8 +96,7 @@ export async function runMobilePreview(argv){
|
|
|
103
96
|
const request=buildReviewRequest(opts,config,state,operation.operationId);
|
|
104
97
|
const receipt=await submitNeoReview(request);
|
|
105
98
|
return {status:'review_requested',operationId:operation.operationId,requestId:request.id,
|
|
106
|
-
...(opts.delivery==='event' ? {
|
|
107
|
-
...(config.delivery==='event' ? {jobId:config.eventTemplate.data.interactive.jobId} : {}),
|
|
99
|
+
...(opts.delivery==='event' ? {} : {contentHash:state.result.contentHash,revisionId:state.result.revisionId}),
|
|
108
100
|
delivery:config.delivery,notification:receipt.accepted?'apns_submitted':'inbox_stored'};
|
|
109
101
|
}
|
|
110
102
|
|
|
@@ -1,67 +1,51 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Generic event transport. The caller owns the event type, source and business data.
|
|
2
2
|
const ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
3
|
-
const
|
|
4
|
-
const RECORD = value => value && typeof value ===
|
|
5
|
-
const
|
|
6
|
-
const
|
|
3
|
+
const KEY = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
4
|
+
const RECORD = value => value && typeof value === 'object' && !Array.isArray(value);
|
|
5
|
+
const FORBIDDEN = new Set(['__proto__','constructor','prototype']);
|
|
6
|
+
const RESULT_FIELDS = ['previewId','requestId','decision','feedback','comments','idempotencyKey'];
|
|
7
7
|
function copyData(value) {
|
|
8
|
-
if (!RECORD(value)) throw new Error(
|
|
9
|
-
// No executable values or reserved overrides can be shipped in a template.
|
|
8
|
+
if (!RECORD(value)) throw new Error('eventTemplate.data must be an object');
|
|
10
9
|
const encoded=JSON.stringify(value);
|
|
11
|
-
if (!encoded || encoded.length
|
|
10
|
+
if (!encoded || encoded.length>12000) throw new Error('Invalid eventTemplate.data');
|
|
12
11
|
const clean=JSON.parse(encoded);
|
|
13
|
-
const walk=
|
|
14
|
-
if
|
|
15
|
-
for
|
|
16
|
-
if
|
|
12
|
+
const walk=node=>{
|
|
13
|
+
if(!node || typeof node!=='object')return;
|
|
14
|
+
for(const [key,val] of Object.entries(node)){
|
|
15
|
+
if(FORBIDDEN.has(key))throw new Error('Unsafe eventTemplate data');
|
|
17
16
|
walk(val);
|
|
18
17
|
}
|
|
19
18
|
};
|
|
20
|
-
walk(clean);
|
|
21
|
-
return clean;
|
|
19
|
+
walk(clean);return clean;
|
|
22
20
|
}
|
|
23
|
-
export function normalizeReviewConfig(value)
|
|
24
|
-
if
|
|
25
|
-
if
|
|
26
|
-
if
|
|
27
|
-
if
|
|
28
|
-
return {delivery:
|
|
21
|
+
export function normalizeReviewConfig(value){
|
|
22
|
+
if(value===undefined)return {delivery:'text'};
|
|
23
|
+
if(!RECORD(value)||!['text','event'].includes(value.delivery??'text'))throw Error('Unsupported review delivery');
|
|
24
|
+
if(value.delivery!=='event'){
|
|
25
|
+
if(value.eventTemplate!==undefined)throw Error('eventTemplate requires event delivery');
|
|
26
|
+
return {delivery:'text'};
|
|
29
27
|
}
|
|
30
28
|
const template=value.eventTemplate;
|
|
31
|
-
if
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
if(!RECORD(template) || typeof template.type!=='string' || !/^[A-Za-z0-9_.:-]{1,128}$/.test(template.type) ||
|
|
30
|
+
typeof template.source!=='string' || !template.source || template.source.length>512 || /[\r\n\x00-\x1f]/.test(template.source) ||
|
|
31
|
+
!RECORD(template.data) || Object.keys(template).some(k=>!['type','source','data','responseKey'].includes(k)))
|
|
32
|
+
throw Error('Invalid event template envelope');
|
|
33
|
+
const responseKey=template.responseKey??'review';
|
|
34
|
+
if(typeof responseKey!=='string'||!KEY.test(responseKey)||FORBIDDEN.has(responseKey))throw Error('Invalid responseKey');
|
|
35
35
|
const data=copyData(template.data);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
interactive.taskId!==match[2] || interactive.executionId!==match[3] ||
|
|
40
|
-
!ID.test(interactive.invocationId||"") ||
|
|
41
|
-
REVIEW_FIELDS.some(field=>Object.hasOwn(interactive,field)))
|
|
42
|
-
throw new Error("Invalid task.interactive_decision event template");
|
|
43
|
-
if (!/^[a-f0-9]{40}$/.test(value.commitSha||"")) throw new Error("Event review requires full Git Commit SHA");
|
|
44
|
-
return {delivery:"event",commitSha:value.commitSha,eventTemplate:{
|
|
45
|
-
type:template.type,source:template.source,data,
|
|
46
|
-
}};
|
|
36
|
+
if(data[responseKey]!==undefined && (!RECORD(data[responseKey])||RESULT_FIELDS.some(k=>Object.hasOwn(data[responseKey],k))))
|
|
37
|
+
throw Error('Event response payload must be caller-owned metadata only');
|
|
38
|
+
return {delivery:'event',eventTemplate:{type:template.type,source:template.source,data,responseKey}};
|
|
47
39
|
}
|
|
48
|
-
export function eventForReview(config,review)
|
|
40
|
+
export function eventForReview(config,review){
|
|
49
41
|
const {eventTemplate:template}=normalizeReviewConfig(config);
|
|
50
|
-
if
|
|
51
|
-
if
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return {type:INTERACTIVE_TYPE,source:template.source,data:{
|
|
60
|
-
...template.data,
|
|
61
|
-
interactive:{...details,
|
|
62
|
-
revision:review.commitSha,commitSha:review.commitSha,
|
|
63
|
-
previewId:review.previewId,requestId:review.requestId,
|
|
64
|
-
decision:review.decision,feedback,comments:structuredClone(review.comments),
|
|
65
|
-
idempotencyKey:review.idempotencyKey},
|
|
66
|
-
}};
|
|
42
|
+
if(!template)throw Error('Event mode required');
|
|
43
|
+
if(!RECORD(review)||!ID.test(review.requestId||'')||!ID.test(review.idempotencyKey||'')||
|
|
44
|
+
!['approved','changes_requested'].includes(review.decision)||!Array.isArray(review.comments))throw Error('Invalid review result');
|
|
45
|
+
const feedback=typeof review.feedback==='string'?review.feedback:
|
|
46
|
+
review.comments.map(c=>c.text).filter(x=>typeof x==='string').join('\n');
|
|
47
|
+
const key=template.responseKey;
|
|
48
|
+
return {type:template.type,source:template.source,data:{...template.data,
|
|
49
|
+
[key]:{...(template.data[key]||{}),previewId:review.previewId,requestId:review.requestId,
|
|
50
|
+
decision:review.decision,feedback,comments:structuredClone(review.comments),idempotencyKey:review.idempotencyKey}}};
|
|
67
51
|
}
|
package/src/mcp/server.mjs
CHANGED
|
@@ -47,12 +47,11 @@ registerAppTool(
|
|
|
47
47
|
server,
|
|
48
48
|
TOOL_NAME,
|
|
49
49
|
{
|
|
50
|
-
description: "Compile and publish an immutable Markcut preview revision for this ChatGPT conversation. Review delivery defaults to ui/message, or submits an authorized caller-bound event when explicitly configured. Event-mode decisions
|
|
50
|
+
description: "Compile and publish an immutable Markcut preview revision for this ChatGPT conversation. Review delivery defaults to ui/message, or submits an authorized caller-bound event when explicitly configured. Event-mode decisions use the caller-provided event envelope; Markcut does not interpret the event type or payload.",
|
|
51
51
|
inputSchema: z.object({
|
|
52
52
|
path: z.string().describe("Absolute .md path or NeoY HTTPS mounted file URL; Neo Wrapper also accepts single local image/audio/video files"),
|
|
53
53
|
readonly: z.boolean().optional().describe("View-only preview: no review controls, Relay binding, Git checkpoint, or mobile review notification."),
|
|
54
|
-
review: z.object({delivery:z.enum(["text","event"]).optional(),
|
|
55
|
-
relay:z.object({jobId:z.string(),taskId:z.union([z.string(),z.number()]),executionId:z.string().optional()}).optional().describe("Optional managed review correlation; no Relay needed for standalone review."),
|
|
54
|
+
review: z.object({delivery:z.enum(["text","event"]).optional(),eventTemplate:z.object({type:z.string(),source:z.string(),data:z.record(z.string(),z.unknown()),responseKey:z.string().optional()}).optional(),
|
|
56
55
|
}).optional(),
|
|
57
56
|
}),
|
|
58
57
|
_meta: {
|
|
@@ -60,13 +59,12 @@ registerAppTool(
|
|
|
60
59
|
},
|
|
61
60
|
},
|
|
62
61
|
async ({ path, review, readonly }) => {
|
|
63
|
-
const relay=review?.relay;
|
|
64
62
|
try {
|
|
65
63
|
if (readonly && review !== undefined)
|
|
66
64
|
throw new Error("Read-only preview cannot request Relay or review delivery");
|
|
67
65
|
const config={...normalizeReviewConfig(review),...(readonly ? {readonly:true} : {})};
|
|
68
|
-
const operation=startCompileOperation(path,
|
|
69
|
-
const payload=
|
|
66
|
+
const operation=startCompileOperation(path,config);
|
|
67
|
+
const payload=operation;
|
|
70
68
|
return {
|
|
71
69
|
content: [{ type: "text", text: `Compilation started: ${operation.path}` }],
|
|
72
70
|
structuredContent: payload,
|
|
@@ -164,13 +164,13 @@ describe('MCP Remotion bridge',()=>{
|
|
|
164
164
|
second.nodes.approve.onclick?.();
|
|
165
165
|
expect(second.messages.filter(m=>m.method==='tools/call')).toHaveLength(0);
|
|
166
166
|
});
|
|
167
|
-
it('
|
|
167
|
+
it('does not interpret or expose caller-owned Relay context in a text review',async()=>{
|
|
168
168
|
const h=harness();
|
|
169
169
|
const relay={jobId:'job-7',taskId:19,executionId:'exec-1'};
|
|
170
170
|
h.result({id:'r',revisionId:'r',contentHash:'hash',path:'/video.md',relay,compiled:{children:[]}});
|
|
171
171
|
h.nodes.feedback.value='shorter title';h.nodes['save-spot'].onclick?.();h.nodes.changes.onclick?.();
|
|
172
172
|
await nextTick();
|
|
173
|
-
expect(JSON.parse(h.messages.find(m=>m.method==='ui/message').params.content[0].text).relay).
|
|
173
|
+
expect(JSON.parse(h.messages.find(m=>m.method==='ui/message').params.content[0].text).relay).toBeUndefined();
|
|
174
174
|
});
|
|
175
175
|
it('handles request changes followed by a new revision and approval in the same app',async()=>{
|
|
176
176
|
const h=harness();h.respond(1);await nextTick();
|
|
@@ -392,9 +392,9 @@ describe('async compilation UI transition',()=>{
|
|
|
392
392
|
|
|
393
393
|
describe('Review event delivery',()=>{
|
|
394
394
|
const template={type:'task.interactive_decision',
|
|
395
|
-
source:'job/551/task/producer/execution/e1',data:{interactive:{jobId:'551',taskId:'producer',executionId:'e1'
|
|
395
|
+
source:'job/551/task/producer/execution/e1',responseKey:'interactive',data:{interactive:{jobId:'551',taskId:'producer',executionId:'e1'},purpose:'video'}};
|
|
396
396
|
const media={id:'video1',requestId:'d9b2006a-0618-45aa-a3d8-31363fa629ca',revisionId:'rv1',
|
|
397
|
-
contentHash:'a'.repeat(64),path:'/tmp/video.md',compiled:{children:[]},review:{delivery:'event',
|
|
397
|
+
contentHash:'a'.repeat(64),path:'/tmp/video.md',compiled:{children:[]},review:{delivery:'event',eventTemplate:template}};
|
|
398
398
|
it('does not publish until explicit Submit, preserves fixed envelope and scoped comments',async()=>{
|
|
399
399
|
const h=harness(undefined,undefined, m=> m.method==='tools/call'?{published:true,event:{event_id:'ack'}}:undefined);
|
|
400
400
|
h.result(media);h.selectSpot(0);h.scene({sceneId:'intro',timeSeconds:2.25,sceneStart:0});
|
|
@@ -405,19 +405,22 @@ describe('Review event delivery',()=>{
|
|
|
405
405
|
expect(calls).toHaveLength(1);
|
|
406
406
|
expect(calls[0]).toMatchObject({params:{name:'events',arguments:{command:'publish',
|
|
407
407
|
args:{type:template.type,source:template.source,data:{purpose:'video',
|
|
408
|
-
interactive:{jobId:'551',taskId:'producer',executionId:'e1',
|
|
409
|
-
requestId:media.requestId,
|
|
408
|
+
interactive:{jobId:'551',taskId:'producer',executionId:'e1',
|
|
409
|
+
requestId:media.requestId,
|
|
410
410
|
decision:'changes_requested',feedback:'Trim opening',comments:[{sceneId:'intro',timeSeconds:2.25,text:'Trim opening'}]}}}}}});
|
|
411
411
|
expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
412
412
|
expect(h.nodes.status.textContent).toContain('submitted');
|
|
413
413
|
});
|
|
414
|
-
it('
|
|
415
|
-
const
|
|
414
|
+
it('publishes arbitrary caller event types without interpreting semantics',async()=>{
|
|
415
|
+
const arbitrary={...template,type:'markcut.review.submitted',source:'custom/feedback/events'};
|
|
416
416
|
const h=harness(undefined,undefined,m=>m.method==='tools/call'?{published:true}:undefined);
|
|
417
|
-
h.result({...media,review:{delivery:'event',eventTemplate:
|
|
417
|
+
h.result({...media,review:{delivery:'event',eventTemplate:arbitrary}});
|
|
418
418
|
h.nodes.approve.onclick?.();await nextTick();
|
|
419
|
-
expect(h.nodes.status.textContent).toContain('
|
|
420
|
-
|
|
419
|
+
expect(h.nodes.status.textContent).toContain('submitted');
|
|
420
|
+
const calls=h.messages.filter(m=>m.method==='tools/call');
|
|
421
|
+
expect(calls).toHaveLength(1);
|
|
422
|
+
expect(calls[0].params.arguments.args.type).toBe('markcut.review.submitted');
|
|
423
|
+
expect(calls[0].params.arguments.args.source).toBe('custom/feedback/events');
|
|
421
424
|
});
|
|
422
425
|
it('fails visibly without host Events access and reuses the idempotency key on retry',async()=>{
|
|
423
426
|
const h=harness(undefined,undefined,m=>m.method==='tools/call'?{rpcError:{message:'Host denies cross-server tool'}}:undefined);
|
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import {describe,it,expect} from 'vitest';
|
|
2
2
|
import {normalizeReviewConfig,eventForReview} from '../src/mcp/review-delivery.mjs';
|
|
3
3
|
|
|
4
|
-
const template={type:'
|
|
5
|
-
data:{
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
decision:'changes_requested',comments:[{sceneId:'intro',timeSeconds:3.2,text:'Shorter intro'}],idempotencyKey:'key1'};
|
|
4
|
+
const template={type:'other.product.feedback',source:'app/custom-destination',responseKey:'response',
|
|
5
|
+
data:{response:{opaque:'from caller'},meta:{source:'ok'}}};
|
|
6
|
+
const review={requestId:'r1',previewId:'p1',decision:'changes_requested',
|
|
7
|
+
comments:[{sceneId:'intro',timeSeconds:3.2,text:'Shorter intro'}],idempotencyKey:'key1'};
|
|
9
8
|
|
|
10
|
-
describe('
|
|
11
|
-
it('defaults to text
|
|
9
|
+
describe('Generic Preview event transport',()=>{
|
|
10
|
+
it('defaults to text; event delivery requires a caller envelope',()=>{
|
|
12
11
|
expect(normalizeReviewConfig(undefined)).toEqual({delivery:'text'});
|
|
13
12
|
expect(normalizeReviewConfig({delivery:'text'})).toEqual({delivery:'text'});
|
|
14
13
|
expect(()=>normalizeReviewConfig({delivery:'callback'})).toThrow();
|
|
15
14
|
expect(()=>normalizeReviewConfig({delivery:'event'})).toThrow();
|
|
16
15
|
});
|
|
17
|
-
it('
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
expect(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
24
|
-
data:{interactive:{...template.data.interactive,taskId:'forged'}}}})).toThrow();
|
|
25
|
-
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
26
|
-
data:{interactive:{...template.data.interactive,revision:sha}}}})).toThrow();
|
|
16
|
+
it('accepts arbitrary caller event type, source and response key without reading business identity',()=>{
|
|
17
|
+
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
18
|
+
const ev=eventForReview(config,review);
|
|
19
|
+
expect(ev).toMatchObject({type:'other.product.feedback',source:'app/custom-destination',
|
|
20
|
+
data:{meta:{source:'ok'},response:{opaque:'from caller',decision:'changes_requested',
|
|
21
|
+
feedback:'Shorter intro',comments:review.comments,requestId:'r1',idempotencyKey:'key1'}}});
|
|
27
22
|
});
|
|
28
|
-
it('freezes caller
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
decision:'changes_requested',feedback:'Shorter intro',comments:review.comments,
|
|
36
|
-
idempotencyKey:'key1'}}});
|
|
37
|
-
expect(template.data.interactive).not.toHaveProperty('decision');
|
|
23
|
+
it('freezes caller metadata and does not let decisions rewrite it',()=>{
|
|
24
|
+
const input={...template,data:{response:{opaque:'from caller'},meta:{source:'ok'}}};
|
|
25
|
+
const config=normalizeReviewConfig({delivery:'event',eventTemplate:input});
|
|
26
|
+
input.data.meta.source='changed after binding';
|
|
27
|
+
const ev=eventForReview(config,review);
|
|
28
|
+
expect(ev.data.meta.source).toBe('ok');
|
|
29
|
+
expect(ev.data.response.opaque).toBe('from caller');
|
|
38
30
|
});
|
|
39
|
-
it('
|
|
40
|
-
|
|
41
|
-
expect(()=>
|
|
42
|
-
expect(()=>
|
|
31
|
+
it('rejects invalid transport structure and unsafe property overrides',()=>{
|
|
32
|
+
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,source:'a\nb'}})).toThrow();
|
|
33
|
+
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,responseKey:'__proto__'}})).toThrow();
|
|
34
|
+
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,data:{response:{decision:'prefilled'}}}})).toThrow();
|
|
35
|
+
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,data:JSON.parse('{"__proto__":{}}')}})).toThrow();
|
|
36
|
+
expect(()=>eventForReview({delivery:'event',eventTemplate:template},{...review,decision:'invalid'})).toThrow();
|
|
37
|
+
});
|
|
38
|
+
it('default response key is review for any event',()=>{
|
|
39
|
+
const t={type:'work.done',source:'workspace/123',data:{context:{id:123}}};
|
|
40
|
+
expect(eventForReview({delivery:'event',eventTemplate:t},review)).toMatchObject({
|
|
41
|
+
type:t.type,source:t.source,data:{context:{id:123},review:{decision:'changes_requested'}}});
|
|
43
42
|
});
|
|
44
43
|
});
|
|
@@ -3,7 +3,7 @@ import {parseEventPreviewOptions,neoReviewEndpoint,buildReviewRequest,submitNeoR
|
|
|
3
3
|
|
|
4
4
|
describe('Standalone Markcut CLI preview (notification belongs to Neo)',()=>{
|
|
5
5
|
it('accepts externally supplied event templates without a phone or APNs URL',()=>{
|
|
6
|
-
expect(parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','template.json'
|
|
6
|
+
expect(parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','template.json']).delivery).toBe('event');
|
|
7
7
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','event'])).toThrow();
|
|
8
8
|
expect(()=>parseEventPreviewOptions(['preview','video.md','--delivery','event','--event-template','a','--phone-url','http://phone'])).toThrow();
|
|
9
9
|
expect(parseEventPreviewOptions(['preview','video.md','--delivery','text']).delivery).toBe('text');
|
|
@@ -15,18 +15,19 @@ describe('Neo-owned REST notification from standalone CLI',()=>{
|
|
|
15
15
|
const id='82ba2e6c-6432-4ecd-83ee-cb78ba87c668';
|
|
16
16
|
const hash='f'.repeat(64);
|
|
17
17
|
const options={file:'/tmp/preview.md'};
|
|
18
|
-
const eventOptions={...options
|
|
18
|
+
const eventOptions={...options};
|
|
19
19
|
const state={result:{id:'preview-123',contentHash:hash,revisionId:'revision-123'}};
|
|
20
20
|
it('builds a durable, immutable text request for phone view-only sync',()=>{
|
|
21
21
|
const request=buildReviewRequest(options,{delivery:'text'},state,id);
|
|
22
22
|
expect(request).toMatchObject({id,contentHash:hash,revisionId:'revision-123',
|
|
23
23
|
previewId:'preview-123',title:'preview',delivery:'text',groupId:'/tmp/preview.md'});
|
|
24
24
|
});
|
|
25
|
-
it('
|
|
25
|
+
it('passes an opaque event template without interpreting the caller identity',()=>{
|
|
26
26
|
const template={type:'task.interactive_decision',source:'job/12/task/prod/execution/ex1',
|
|
27
|
-
data:{interactive:{jobId:'12',taskId:'prod',executionId:'ex1'
|
|
27
|
+
data:{interactive:{jobId:'12',taskId:'prod',executionId:'ex1'}}};
|
|
28
28
|
const request=buildReviewRequest(eventOptions,{delivery:'event',eventTemplate:template},state,id);
|
|
29
|
-
expect(request).toMatchObject({id,
|
|
29
|
+
expect(request).toMatchObject({id,mediaHash:hash,eventTemplate:template,groupId:'/tmp/preview.md'});
|
|
30
|
+
expect(request).not.toHaveProperty('jobId');
|
|
30
31
|
expect(request).not.toHaveProperty('revisionId');expect(request).not.toHaveProperty('contentHash');
|
|
31
32
|
});
|
|
32
33
|
it('POSTs to local Neo Core REST and requires persisted matching ACK',async()=>{
|