@lalalic/markcut 3.2.43 → 3.2.44
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/package.json
CHANGED
|
@@ -85,7 +85,7 @@ The Provider freezes the delivery choice, event template (if any), and preview i
|
|
|
85
85
|
|
|
86
86
|
### Event publish envelope
|
|
87
87
|
|
|
88
|
-
The Provider's event template owns `type`, `source` and any fixed `data` fields.
|
|
88
|
+
The Provider's event template owns `type`, `source` and any fixed `data` fields. The **only supported Event type** is `task.interactive_decision` from the Relay Event Contract. On Submit, the client fills reserved `data.interactive` fields (`decision`, `feedback`, `comments`, `revision`, `contentHash`, `revisionId`, `previewId`, `requestId`, `idempotencyKey`); `revision` equals `contentHash`. It never overwrites caller-owned execution identity. Templates using any other type are rejected without publishing. Then it publishes through the existing Events MCP interface:
|
|
89
89
|
|
|
90
90
|
```json
|
|
91
91
|
{
|
|
@@ -128,7 +128,7 @@ Relay's canonical Event Contract is at `agents-relay/skills/agents-relay/contrac
|
|
|
128
128
|
- **Markcut Provider**: compiles/publishes immutable media, binds review delivery metadata, validates preview revision state, provides review template to clients.
|
|
129
129
|
- **Markcut Preview UI**: gathers comments and decision, fills review fields, dispatches either text or event, displays honest receipt/failure state.
|
|
130
130
|
- **Neo Mobile**: displays the same review/revision, submits through its authenticated Neo MCP connection, retains offline retry state.
|
|
131
|
-
- **Caller/Event consumer**: owns authorization, durable business processing, any Relay Event → original Producer Agent continuation, rereview, workflow transitions, and video delivery. `task.interactive_decision` is Relay human-interaction input, **not** Relay task-completion authority.
|
|
131
|
+
- **Caller/Event consumer**: owns authorization, durable business processing, any Relay Event → original Producer Agent continuation, rereview, workflow transitions, and video delivery. `task.interactive_decision` is Relay human-interaction input, **not** Relay task-completion authority. No alternate or legacy review event type is accepted by the Preview provider.
|
|
132
132
|
|
|
133
133
|
## Edge cases and compatibility
|
|
134
134
|
|
package/src/mcp/bridge.mjs
CHANGED
|
@@ -129,25 +129,22 @@ function applyToolInput(params){
|
|
|
129
129
|
}
|
|
130
130
|
let operationGeneration=0;
|
|
131
131
|
function eventEnvelope(template,review){
|
|
132
|
-
if(!template || !template.source || !template.data)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
if(template.type!=='markcut.review.submitted' ||
|
|
148
|
-
Object.prototype.hasOwnProperty.call(template.data,'review'))throw new Error('Invalid bound review event template');
|
|
149
|
-
return {type:template.type,source:template.source,data:{...template.data,review}};
|
|
132
|
+
if(!template || template.type!=='task.interactive_decision' || !template.source || !template.data)
|
|
133
|
+
throw new Error('Invalid bound review event template');
|
|
134
|
+
const match=template.source.match(/^job\\/([^/]+)\\/task\\/([^/]+)\\/execution\\/([^/]+)$/);
|
|
135
|
+
const fixed=template.data.interactive;
|
|
136
|
+
if(!match || !fixed || fixed.jobId!==match[1] || fixed.taskId!==match[2] ||
|
|
137
|
+
fixed.executionId!==match[3] || !fixed.invocationId ||
|
|
138
|
+
['decision','feedback','comments','revision','revisionId','contentHash','previewId','requestId','idempotencyKey']
|
|
139
|
+
.some(key=>Object.prototype.hasOwnProperty.call(fixed,key)))throw new Error('Invalid bound interactive decision');
|
|
140
|
+
return {type:template.type,source:template.source,data:{...template.data,interactive:{
|
|
141
|
+
...fixed,revision:review.contentHash,revisionId:review.revisionId,contentHash:review.contentHash,
|
|
142
|
+
previewId:review.previewId,requestId:review.requestId,decision:review.decision,
|
|
143
|
+
feedback:review.feedback||review.comments.map(c=>c.text).join('\\n'),
|
|
144
|
+
comments:review.comments,idempotencyKey:review.idempotencyKey
|
|
145
|
+
}}};
|
|
150
146
|
}
|
|
147
|
+
|
|
151
148
|
async function sendReviewEvent(result){
|
|
152
149
|
const event=eventEnvelope(activeReview.eventTemplate,result);
|
|
153
150
|
// MCP Apps tools/call is host-mediated; an unavailable or unauthorized Events
|
package/src/mcp/preview.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { externalizePreviewMedia, publicOrigin, resolveMountedFile, resolvePrevi
|
|
|
9
9
|
import {fingerprintInputs} from "./source-fingerprint.mjs";
|
|
10
10
|
|
|
11
11
|
export const TOOL_NAME = "markcut.preview";
|
|
12
|
-
export const RESOURCE_URI = "ui://markcut/video-preview-
|
|
12
|
+
export const RESOURCE_URI = "ui://markcut/video-preview-v43.html";
|
|
13
13
|
const PREVIEW_VERSION = RESOURCE_URI.match(/video-preview-(v\d+)/)?.[1] ?? "unknown";
|
|
14
14
|
// Legacy entrypoints remain registered, but serve the current implementation.
|
|
15
15
|
export const LEGACY_RESOURCE_URIS = [
|
|
@@ -50,6 +50,7 @@ export const LEGACY_RESOURCE_URIS = [
|
|
|
50
50
|
"ui://markcut/video-preview-v37.html",
|
|
51
51
|
"ui://markcut/video-preview-v40.html",
|
|
52
52
|
"ui://markcut/video-preview-v41.html",
|
|
53
|
+
"ui://markcut/video-preview-v42.html",
|
|
53
54
|
"ui://markcut/video-preview-v39.html",
|
|
54
55
|
"ui://markcut/video-preview-v38.html",
|
|
55
56
|
];
|
|
@@ -28,22 +28,18 @@ export function normalizeReviewConfig(value) {
|
|
|
28
28
|
return {delivery:"text"};
|
|
29
29
|
}
|
|
30
30
|
const template=value.eventTemplate;
|
|
31
|
-
if (!RECORD(template) ||
|
|
31
|
+
if (!RECORD(template) || template.type!==INTERACTIVE_TYPE
|
|
32
32
|
|| typeof template.source!=="string" || !SOURCE.test(template.source)
|
|
33
33
|
|| !RECORD(template.data)) throw new Error("Invalid review event template");
|
|
34
34
|
if (Object.keys(template).some(key=>!["type","source","data"].includes(key))) throw new Error("Unexpected eventTemplate fields");
|
|
35
35
|
const data=copyData(template.data);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
throw new Error("Invalid task.interactive_decision event template");
|
|
44
|
-
} else if (Object.hasOwn(data,"review")) {
|
|
45
|
-
throw new Error("data.review is reserved for the human result");
|
|
46
|
-
}
|
|
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
|
+
!ID.test(interactive.invocationId||"") ||
|
|
41
|
+
REVIEW_FIELDS.some(field=>Object.hasOwn(interactive,field)))
|
|
42
|
+
throw new Error("Invalid task.interactive_decision event template");
|
|
47
43
|
return {delivery:"event",eventTemplate:{
|
|
48
44
|
type:template.type,source:template.source,data,
|
|
49
45
|
}};
|
|
@@ -56,18 +52,15 @@ export function eventForReview(config,review) {
|
|
|
56
52
|
|| !["approved","changes_requested"].includes(review.decision)
|
|
57
53
|
|| !ID.test(review.idempotencyKey || "") || !Array.isArray(review.comments))
|
|
58
54
|
throw new Error("Invalid review result");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}};
|
|
71
|
-
}
|
|
72
|
-
return {type:template.type,source:template.source,data:{...template.data,review:structuredClone(review)}};
|
|
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
|
+
revision:review.contentHash,revisionId:review.revisionId,contentHash:review.contentHash,
|
|
62
|
+
previewId:review.previewId,requestId:review.requestId,
|
|
63
|
+
decision:review.decision,feedback,comments:structuredClone(review.comments),
|
|
64
|
+
idempotencyKey:review.idempotencyKey},
|
|
65
|
+
}};
|
|
73
66
|
}
|
|
@@ -49,8 +49,8 @@ describe('MCP Remotion bridge',()=>{
|
|
|
49
49
|
compiled:{children:[{name:'Shared'}]}};
|
|
50
50
|
const h=harness(remote);
|
|
51
51
|
h.dispatch({method:'ui/notifications/tool-input',params:{arguments:{path,
|
|
52
|
-
review:{delivery:'event',eventTemplate:{type:'
|
|
53
|
-
source:'job/a/task/b/execution/c',data:{
|
|
52
|
+
review:{delivery:'event',eventTemplate:{type:'task.interactive_decision',
|
|
53
|
+
source:'job/a/task/b/execution/c',data:{interactive:{jobId:'a',taskId:'b',executionId:'c',invocationId:'other'}}}}}}});
|
|
54
54
|
for(let i=0;i<20&&!h.events.some(e=>e.detail?.revisionId==='rev1');i++)await nextTick();
|
|
55
55
|
expect(h.events.some(e=>e.detail?.revisionId==='rev1')).toBe(true);
|
|
56
56
|
expect(h.nodes.approve.disabled).toBe(true);
|
|
@@ -361,8 +361,8 @@ describe('async compilation UI transition',()=>{
|
|
|
361
361
|
});
|
|
362
362
|
|
|
363
363
|
describe('Review event delivery',()=>{
|
|
364
|
-
const template={type:'
|
|
365
|
-
source:'job/551/task/producer/execution/e1',data:{
|
|
364
|
+
const template={type:'task.interactive_decision',
|
|
365
|
+
source:'job/551/task/producer/execution/e1',data:{interactive:{jobId:'551',taskId:'producer',executionId:'e1',invocationId:'review-551'},purpose:'video'}};
|
|
366
366
|
const media={id:'video1',requestId:'d9b2006a-0618-45aa-a3d8-31363fa629ca',revisionId:'rv1',
|
|
367
367
|
contentHash:'a'.repeat(64),path:'/tmp/video.md',compiled:{children:[]},review:{delivery:'event',eventTemplate:template}};
|
|
368
368
|
it('does not publish until explicit Submit, preserves fixed envelope and scoped comments',async()=>{
|
|
@@ -374,27 +374,20 @@ describe('Review event delivery',()=>{
|
|
|
374
374
|
const calls=h.messages.filter(m=>m.method==='tools/call');
|
|
375
375
|
expect(calls).toHaveLength(1);
|
|
376
376
|
expect(calls[0]).toMatchObject({params:{name:'events',arguments:{command:'publish',
|
|
377
|
-
args:{type:template.type,source:template.source,data:{
|
|
378
|
-
|
|
379
|
-
|
|
377
|
+
args:{type:template.type,source:template.source,data:{purpose:'video',
|
|
378
|
+
interactive:{jobId:'551',taskId:'producer',executionId:'e1',invocationId:'review-551',
|
|
379
|
+
requestId:media.requestId,revisionId:media.revisionId,revision:media.contentHash,contentHash:media.contentHash,
|
|
380
|
+
decision:'changes_requested',feedback:'Trim opening',comments:[{sceneId:'intro',timeSeconds:2.25,text:'Trim opening'}]}}}}}});
|
|
380
381
|
expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
381
382
|
expect(h.nodes.status.textContent).toContain('submitted');
|
|
382
383
|
});
|
|
383
|
-
it('
|
|
384
|
-
const
|
|
385
|
-
data:{interactive:{jobId:'551',taskId:'producer',executionId:'e1',invocationId:'request-7'}}};
|
|
384
|
+
it('rejects legacy Markcut event templates instead of publishing or falling back to messages',async()=>{
|
|
385
|
+
const legacy={...template,type:'markcut.review.submitted'};
|
|
386
386
|
const h=harness(undefined,undefined,m=>m.method==='tools/call'?{published:true}:undefined);
|
|
387
|
-
h.result({...media,review:{delivery:'event',eventTemplate:
|
|
388
|
-
h.
|
|
389
|
-
h.nodes.
|
|
390
|
-
h.
|
|
391
|
-
const event=h.messages.find(m=>m.method==='tools/call')?.params?.arguments?.args;
|
|
392
|
-
expect(event).toMatchObject({type:'task.interactive_decision',source:common.source,
|
|
393
|
-
data:{interactive:{jobId:'551',taskId:'producer',executionId:'e1',
|
|
394
|
-
invocationId:'request-7',revision:media.contentHash,contentHash:media.contentHash,
|
|
395
|
-
revisionId:media.revisionId,decision:'changes_requested',feedback:'Cut opening',
|
|
396
|
-
comments:[{sceneId:'opening',timeSeconds:3.5,text:'Cut opening'}]}}});
|
|
397
|
-
expect(h.messages.some(m=>m.method==='ui/message')).toBe(false);
|
|
387
|
+
h.result({...media,review:{delivery:'event',eventTemplate:legacy}});
|
|
388
|
+
h.nodes.approve.onclick?.();await nextTick();
|
|
389
|
+
expect(h.nodes.status.textContent).toContain('Review not submitted');
|
|
390
|
+
expect(h.messages.filter(m=>m.method==='tools/call'||m.method==='ui/message')).toHaveLength(0);
|
|
398
391
|
});
|
|
399
392
|
it('fails visibly without host Events access and reuses the idempotency key on retry',async()=>{
|
|
400
393
|
const h=harness(undefined,undefined,m=>m.method==='tools/call'?{rpcError:{message:'Host denies cross-server tool'}}:undefined);
|
|
@@ -403,8 +396,8 @@ describe('Review event delivery',()=>{
|
|
|
403
396
|
h.nodes.approve.onclick?.();await nextTick();await nextTick();
|
|
404
397
|
const calls=h.messages.filter(m=>m.method==='tools/call');
|
|
405
398
|
expect(calls).toHaveLength(2);
|
|
406
|
-
expect(calls[0].params.arguments.args.data.
|
|
407
|
-
.toBe(calls[1].params.arguments.args.data.
|
|
399
|
+
expect(calls[0].params.arguments.args.data.interactive.idempotencyKey)
|
|
400
|
+
.toBe(calls[1].params.arguments.args.data.interactive.idempotencyKey);
|
|
408
401
|
expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
409
402
|
});
|
|
410
403
|
it('rejects non-acknowledging host and prevents a second submit after acceptance',async()=>{
|
|
@@ -1,51 +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:'
|
|
4
|
+
const template={type:'task.interactive_decision',source:'job/j1/task/t1/execution/e1',
|
|
5
|
+
data:{interactive:{jobId:'j1',taskId:'t1',executionId:'e1',invocationId:'review-r1'},meta:{source:'ok'}}};
|
|
5
6
|
const review={requestId:'r1',previewId:'p1',revisionId:'rev1',contentHash:'a'.repeat(64),
|
|
6
7
|
decision:'changes_requested',comments:[{sceneId:'intro',timeSeconds:3.2,text:'Shorter intro'}],idempotencyKey:'key1'};
|
|
7
8
|
|
|
8
9
|
describe('Provider-bound preview delivery',()=>{
|
|
9
|
-
it('defaults to text and
|
|
10
|
+
it('defaults to text and rejects unsupported delivery modes',()=>{
|
|
10
11
|
expect(normalizeReviewConfig(undefined)).toEqual({delivery:'text'});
|
|
11
12
|
expect(normalizeReviewConfig({delivery:'text'})).toEqual({delivery:'text'});
|
|
12
13
|
expect(()=>normalizeReviewConfig({delivery:'callback'})).toThrow();
|
|
13
14
|
expect(()=>normalizeReviewConfig({delivery:'event'})).toThrow();
|
|
14
15
|
});
|
|
15
|
-
it('rejects terminal
|
|
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();
|
|
16
18
|
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,type:'task.completed'}})).toThrow();
|
|
17
19
|
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,source:'job/a/task/b/execution/e/forged'}})).toThrow();
|
|
18
|
-
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
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:review.contentHash}}}})).toThrow();
|
|
19
26
|
});
|
|
20
|
-
it('
|
|
27
|
+
it('freezes caller-owned identity and fills only data.interactive fields on human submit',()=>{
|
|
21
28
|
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
22
29
|
template.data.meta.source='changed after validation';
|
|
23
30
|
const event=eventForReview(config,review);
|
|
24
|
-
expect(event).toMatchObject({type:'
|
|
25
|
-
data:{
|
|
26
|
-
|
|
31
|
+
expect(event).toMatchObject({type:'task.interactive_decision',source:template.source,
|
|
32
|
+
data:{meta:{source:'ok'},interactive:{jobId:'j1',taskId:'t1',executionId:'e1',
|
|
33
|
+
invocationId:'review-r1',revision:review.contentHash,revisionId:review.revisionId,
|
|
34
|
+
decision:'changes_requested',feedback:'Shorter intro',comments:review.comments,
|
|
35
|
+
idempotencyKey:'key1'}}});
|
|
36
|
+
expect(template.data.interactive).not.toHaveProperty('decision');
|
|
27
37
|
});
|
|
28
|
-
it('refuses malformed review identity or decision',()=>{
|
|
38
|
+
it('refuses malformed review identity or unauthorized decision',()=>{
|
|
29
39
|
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
30
40
|
expect(()=>eventForReview(config,{...review,contentHash:'bogus'})).toThrow();
|
|
31
41
|
expect(()=>eventForReview(config,{...review,decision:'task.completed'})).toThrow();
|
|
32
42
|
});
|
|
33
|
-
it('supports Relay common interactive decision without a Markcut-specific event type',()=>{
|
|
34
|
-
const relayTemplate={type:'task.interactive_decision',source:'job/j1/task/t1/execution/e1',
|
|
35
|
-
data:{interactive:{jobId:'j1',taskId:'t1',executionId:'e1',invocationId:'preview-invocation'},context:{stage:'video'}}};
|
|
36
|
-
const config=normalizeReviewConfig({delivery:'event',eventTemplate:relayTemplate});
|
|
37
|
-
const event=eventForReview(config,{...review,feedback:'Shorten scene'});
|
|
38
|
-
expect(event).toMatchObject({type:'task.interactive_decision',source:relayTemplate.source,
|
|
39
|
-
data:{context:{stage:'video'},interactive:{jobId:'j1',taskId:'t1',executionId:'e1',
|
|
40
|
-
invocationId:'preview-invocation',revision:review.contentHash,revisionId:review.revisionId,
|
|
41
|
-
decision:'changes_requested',feedback:'Shorten scene',comments:review.comments,
|
|
42
|
-
idempotencyKey:review.idempotencyKey}}});
|
|
43
|
-
expect(relayTemplate.data.interactive).not.toHaveProperty('decision');
|
|
44
|
-
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...relayTemplate,
|
|
45
|
-
data:{interactive:{...relayTemplate.data.interactive,decision:'approved'}}}})).toThrow();
|
|
46
|
-
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...relayTemplate,
|
|
47
|
-
data:{interactive:{...relayTemplate.data.interactive,taskId:'forged'}}}})).toThrow();
|
|
48
|
-
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...relayTemplate,
|
|
49
|
-
data:{interactive:{...relayTemplate.data.interactive,revision:review.contentHash}}}})).toThrow();
|
|
50
|
-
});
|
|
51
43
|
});
|