@lalalic/markcut 3.2.57 → 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.
@@ -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
- ## Git-backed interactive Review identity (2026-11)
321
-
322
- Event-mode Markcut Preview requires a full 40-character Git Commit SHA from a **validated** Neo Project Stage, supplied with `--commit-sha SHA` (CLI) or `review.commitSha` (MCP). The Neo Project Runner commits *before* preview delivery, then adds an immutable `review/rN` tag. The Neo Master REST request and Relay `task.interactive_decision` use `commitSha` as the only review revision identity (with `interactive.revision=commitSha`). `mediaHash` is retained separately for compiled preview media retrieval, **not** for decision binding; standalone `delivery:text` continues to use Markcut's internal compile cache identity. Never accept an Event review without an explicit SHA or silently revert to content-hash identity.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lalalic/markcut",
3
- "version": "3.2.57",
3
+ "version": "3.2.58",
4
4
  "description": "Markdown-to-video engine. Describe scenes in markdown, get a rendered video.",
5
5
  "bin": {
6
6
  "markcut": "bin/markcut"
@@ -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,activeRelay=null,activeReview={delivery:"text"},expectedDelivery="text",expectedReadonly=false,submittedRevision=null,submission=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,22 +148,23 @@ function applyToolInput(params){
148
148
  }
149
149
  let operationGeneration=0;
150
150
  function eventEnvelope(template,review){
151
- if(!template || template.type!=='task.interactive_decision' || !template.source || !template.data)
152
- throw new Error('Invalid bound review event template');
153
- const match=template.source.match(/^job\\/([^/]+)\\/task\\/([^/]+)\\/execution\\/([^/]+)$/);
154
- const fixed=template.data.interactive;
155
- if(!match || !fixed || fixed.jobId!==match[1] || fixed.taskId!==match[2] ||
156
- fixed.executionId!==match[3] ||
157
- ['decision','feedback','comments','revision','revisionId','contentHash','commitSha','invocationId','previewId','requestId','idempotencyKey']
158
- .some(key=>Object.prototype.hasOwnProperty.call(fixed,key)))throw new Error('Invalid bound interactive decision');
159
- return {type:template.type,source:template.source,data:{...template.data,interactive:{
160
- ...fixed,
161
- previewId:review.previewId,requestId:review.requestId,decision:review.decision,
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
169
  if(!activeReview.eventTemplate)throw new Error('Review event template unavailable');
169
170
  const event=eventEnvelope(activeReview.eventTemplate,result);
@@ -202,7 +203,7 @@ async function trackOperation(data){
202
203
  if(generation!==operationGeneration)return;
203
204
  if(progress.state==='ready'&&progress.result){
204
205
  await renderRevision({...progress.result,requestedPath:data.requestedPath||data.path,
205
- requestId:progress.result.requestId||data.requestId,review:progress.result.review||data.review,relay:data.relay});
206
+ requestId:progress.result.requestId||data.requestId,review:progress.result.review||data.review});
206
207
  return;
207
208
  }
208
209
  if(progress.state==='failed'){reviewReadonly(true,'Compilation failed: '+progress.error);return;}
@@ -251,7 +252,6 @@ async function renderRevision(data){
251
252
  activeReview=data.review||{delivery:'text'};
252
253
  updateDeliveryMode();
253
254
  activePath=data.requestedPath||data.path||expectedPath||null;
254
- activeRelay=data.relay||null;
255
255
  if(submittedRevision!==data.revisionId){busy=false;submittedRevision=null;submission=null;}
256
256
  reviewReadonly(true,'Loading static compiled scenes…');
257
257
  try{
@@ -330,7 +330,6 @@ async function submit(decision){
330
330
  if(!submission || submission.signature!==signature)submission={signature,key:crypto.randomUUID()};
331
331
  result.idempotencyKey=submission.key;
332
332
  if(activePath)result.path=activePath;
333
- if(activeRelay)result.relay=activeRelay;
334
333
  if(decision==='changes_requested'){
335
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');
336
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,relay,review={delivery:"text"}){
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,JSON.stringify(relay||null),sourceHash,JSON.stringify(review)],{detached:true,stdio:"ignore"});
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,relayText,sourceHash,reviewText]=process.argv.slice(2);
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,relay:JSON.parse(relayText)}});
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,relay:JSON.parse(relayText||"null"),error:e?.message||String(e)});
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
  }
@@ -55,10 +55,8 @@ export function buildReviewRequest(options,config,state,operationId){
55
55
  const request={id:operationId,previewId:data.id,title:basename(options.file,'.md'),delivery:config.delivery};
56
56
  if(config.delivery==='event'){
57
57
  request.mediaHash=data.contentHash; // Transport-only lookup for the compiled player, never the review identity.
58
- const fixed=config.eventTemplate.data.interactive;
59
58
  request.eventTemplate=config.eventTemplate;
60
- request.jobId=fixed.jobId;
61
- request.groupId=`job/${fixed.jobId}/task/${fixed.taskId}`;
59
+ request.groupId=options.file;
62
60
  }else {request.contentHash=data.contentHash;request.revisionId=data.revisionId;request.groupId=options.file;}
63
61
  return request;
64
62
  }
@@ -84,7 +82,7 @@ export async function runMobilePreview(argv){
84
82
  const [{startCompileOperation},{EXPORT_ROOT}]=await Promise.all([
85
83
  import('./compile-operation.mjs'),import('./remote-assets.mjs'),
86
84
  ]);
87
- const operation=startCompileOperation(opts.file,undefined,config);
85
+ const operation=startCompileOperation(opts.file,config);
88
86
  const stateFile=join(EXPORT_ROOT,'operations',operation.operationId+'.json');
89
87
  let state;
90
88
  const until=Date.now()+opts.timeoutMs;
@@ -99,7 +97,6 @@ export async function runMobilePreview(argv){
99
97
  const receipt=await submitNeoReview(request);
100
98
  return {status:'review_requested',operationId:operation.operationId,requestId:request.id,
101
99
  ...(opts.delivery==='event' ? {} : {contentHash:state.result.contentHash,revisionId:state.result.revisionId}),
102
- ...(config.delivery==='event' ? {jobId:config.eventTemplate.data.interactive.jobId} : {}),
103
100
  delivery:config.delivery,notification:receipt.accepted?'apns_submitted':'inbox_stored'};
104
101
  }
105
102
 
@@ -1,65 +1,51 @@
1
- // Provider-side validation: the UI cannot invent an event destination or a Relay terminal event.
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 SOURCE = /^job\/[A-Za-z0-9_-]+\/task\/[A-Za-z0-9_-]+\/execution\/[A-Za-z0-9_-]+$/;
4
- const RECORD = value => value && typeof value === "object" && !Array.isArray(value);
5
- const INTERACTIVE_TYPE = "task.interactive_decision";
6
- const REVIEW_FIELDS = ["decision","feedback","comments","revision","revisionId","contentHash","commitSha","invocationId","previewId","requestId","idempotencyKey"];
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("eventTemplate.data must be an object");
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 > 12000) throw new Error("Invalid eventTemplate.data");
10
+ if (!encoded || encoded.length>12000) throw new Error('Invalid eventTemplate.data');
12
11
  const clean=JSON.parse(encoded);
13
- const walk=(node)=>{
14
- if (!node || typeof node !== "object") return;
15
- for (const [key, val] of Object.entries(node)) {
16
- if (["__proto__", "constructor", "prototype"].includes(key)) throw new Error("Unsafe eventTemplate data");
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 (value === undefined) return {delivery:"text"};
25
- if (!RECORD(value) || !["text","event"].includes(value.delivery ?? "text")) throw new Error("Unsupported review delivery");
26
- if (value.delivery !== "event") {
27
- if (value.eventTemplate !== undefined) throw new Error("eventTemplate requires event delivery");
28
- return {delivery:"text"};
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 (!RECORD(template) || template.type!==INTERACTIVE_TYPE
32
- || typeof template.source!=="string" || !SOURCE.test(template.source)
33
- || !RECORD(template.data)) throw new Error("Invalid review event template");
34
- if (Object.keys(template).some(key=>!["type","source","data"].includes(key))) throw new Error("Unexpected eventTemplate fields");
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
- const match=template.source.match(/^job\/([^/]+)\/task\/([^/]+)\/execution\/([^/]+)$/);
37
- const interactive=data.interactive;
38
- if (!match || !RECORD(interactive) || interactive.jobId!==match[1] ||
39
- interactive.taskId!==match[2] || interactive.executionId!==match[3] ||
40
- REVIEW_FIELDS.some(field=>Object.hasOwn(interactive,field)))
41
- throw new Error("Invalid task.interactive_decision event template");
42
- if (value.commitSha !== undefined) throw new Error('Git SHA is not a Review field');
43
- return {delivery:"event",eventTemplate:{
44
- type:template.type,source:template.source,data,
45
- }};
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}};
46
39
  }
47
- export function eventForReview(config,review) {
40
+ export function eventForReview(config,review){
48
41
  const {eventTemplate:template}=normalizeReviewConfig(config);
49
- if (!template) throw new Error("Event mode required");
50
- if (!RECORD(review) || !ID.test(review.requestId || "")
51
- || !["approved","changes_requested"].includes(review.decision)
52
- || !ID.test(review.idempotencyKey || "") || !Array.isArray(review.comments))
53
- throw new Error("Invalid review result");
54
- if (review.commitSha !== undefined || review.invocationId !== undefined) throw new Error('Review identity is Task execution only');
55
- const details=template.data.interactive;
56
- const feedback=typeof review.feedback==="string" ? review.feedback :
57
- review.comments.map(comment=>comment.text).filter(value=>typeof value==="string").join("\n");
58
- return {type:INTERACTIVE_TYPE,source:template.source,data:{
59
- ...template.data,
60
- interactive:{...details,
61
- previewId:review.previewId,requestId:review.requestId,
62
- decision:review.decision,feedback,comments:structuredClone(review.comments),
63
- idempotencyKey:review.idempotencyKey},
64
- }};
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}}};
65
51
  }
@@ -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 bind only the current Relay Task execution; compiled media is used for playback.",
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(),eventTemplate:z.object({type:z.string(),source:z.string(),data:z.record(z.string(),z.unknown())}).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,relay,config);
69
- const payload={...operation,...(relay ? {relay} : {})};
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('preserves optional Relay job/task context across review decisions',async()=>{
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).toEqual(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,7 +392,7 @@ 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'},purpose:'video'}};
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
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()=>{
@@ -411,13 +411,16 @@ describe('Review event delivery',()=>{
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('rejects legacy Markcut event templates instead of publishing or falling back to messages',async()=>{
415
- const legacy={...template,type:'markcut.review.submitted'};
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:legacy}});
417
+ h.result({...media,review:{delivery:'event',eventTemplate:arbitrary}});
418
418
  h.nodes.approve.onclick?.();await nextTick();
419
- expect(h.nodes.status.textContent).toContain('Review not submitted');
420
- expect(h.messages.filter(m=>m.method==='tools/call'||m.method==='ui/message')).toHaveLength(0);
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,42 +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:'task.interactive_decision',source:'job/j1/task/t1/execution/e1',
5
- data:{interactive:{jobId:'j1',taskId:'t1',executionId:'e1'},meta:{source:'ok'}}};
6
- const review={requestId:'r1',previewId:'p1',
7
- 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'};
8
8
 
9
- describe('Provider-bound preview delivery',()=>{
10
- it('defaults to text and rejects unsupported delivery modes',()=>{
9
+ describe('Generic Preview event transport',()=>{
10
+ it('defaults to text; event delivery requires a caller envelope',()=>{
11
11
  expect(normalizeReviewConfig(undefined)).toEqual({delivery:'text'});
12
12
  expect(normalizeReviewConfig({delivery:'text'})).toEqual({delivery:'text'});
13
13
  expect(()=>normalizeReviewConfig({delivery:'callback'})).toThrow();
14
14
  expect(()=>normalizeReviewConfig({delivery:'event'})).toThrow();
15
15
  });
16
- it('rejects old Markcut events, terminal spoofing, untrusted sources and fixed decision overrides',()=>{
17
- expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,type:'markcut.review.submitted'}})).toThrow();
18
- expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,type:'task.completed'}})).toThrow();
19
- expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,source:'job/a/task/b/execution/e/forged'}})).toThrow();
20
- expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
21
- data:{interactive:{...template.data.interactive,decision:'approved'}}}})).toThrow();
22
- expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
23
- data:{interactive:{...template.data.interactive,taskId:'forged'}}}})).toThrow();
24
- expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
25
- data:{interactive:{...template.data.interactive,revision:'bad'}}}})).toThrow();
26
- });
27
- it('freezes caller-owned identity and fills only data.interactive fields on human submit',()=>{
16
+ it('accepts arbitrary caller event type, source and response key without reading business identity',()=>{
28
17
  const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
29
- template.data.meta.source='changed after validation';
30
- const event=eventForReview(config,review);
31
- expect(event).toMatchObject({type:'task.interactive_decision',source:template.source,
32
- data:{meta:{source:'ok'},interactive:{jobId:'j1',taskId:'t1',executionId:'e1',
33
- decision:'changes_requested',feedback:'Shorter intro',comments:review.comments,
34
- idempotencyKey:'key1'}}});
35
- expect(template.data.interactive).not.toHaveProperty('decision');
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'}}});
36
22
  });
37
- it('refuses malformed review identity or unauthorized decision',()=>{
38
- const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
39
- expect(()=>eventForReview(config,{...review,commitSha:'bogus'})).toThrow();
40
- expect(()=>eventForReview(config,{...review,decision:'task.completed'})).toThrow();
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');
30
+ });
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'}}});
41
42
  });
42
43
  });
@@ -22,11 +22,12 @@ describe('Neo-owned REST notification from standalone CLI',()=>{
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('uses exact caller-bound template for Relay event review',()=>{
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
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,mediaHash:hash,eventTemplate:template,jobId:'12',groupId:'job/12/task/prod'});
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()=>{