@lalalic/markcut 3.2.42 → 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 +1 -1
- package/specs/001-preview-review-delivery/spec.md +15 -9
- package/src/mcp/bridge.mjs +15 -3
- package/src/mcp/preview.mjs +4 -1
- package/src/mcp/review-delivery.mjs +23 -4
- package/tests/mcp-preview-bridge.test.ts +18 -9
- package/tests/mcp-preview-delivery.test.ts +19 -9
- package/tests/mcp-preview.test.ts +2 -1
package/package.json
CHANGED
|
@@ -50,9 +50,10 @@ markcut.preview({
|
|
|
50
50
|
review: {
|
|
51
51
|
delivery: "event",
|
|
52
52
|
eventTemplate: {
|
|
53
|
-
type: "
|
|
53
|
+
type: "task.interactive_decision",
|
|
54
54
|
source: "job/<job-id>/task/<task-id>/execution/<execution-id>",
|
|
55
|
-
data: {
|
|
55
|
+
data: { interactive: {jobId: "<job-id>", taskId: "<task-id>",
|
|
56
|
+
executionId: "<execution-id>", invocationId: "<review-request-id>"} }
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
});
|
|
@@ -84,23 +85,28 @@ The Provider freezes the delivery choice, event template (if any), and preview i
|
|
|
84
85
|
|
|
85
86
|
### Event publish envelope
|
|
86
87
|
|
|
87
|
-
The Provider's event template owns `type`, `source` and any fixed `data` fields. On Submit, the client
|
|
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:
|
|
88
89
|
|
|
89
90
|
```json
|
|
90
91
|
{
|
|
91
92
|
"command": "publish",
|
|
92
93
|
"args": {
|
|
93
|
-
"type": "
|
|
94
|
-
"source": "
|
|
94
|
+
"type": "task.interactive_decision",
|
|
95
|
+
"source": "job/<job-id>/task/<task-id>/execution/<execution-id>",
|
|
95
96
|
"data": {
|
|
96
|
-
"
|
|
97
|
-
|
|
97
|
+
"interactive": {
|
|
98
|
+
"jobId": "<job-id>", "taskId": "<task-id>", "executionId": "<execution-id>",
|
|
99
|
+
"invocationId": "<review-request-id>", "revision": "<contentHash>",
|
|
100
|
+
"contentHash": "<contentHash>", "revisionId": "<revisionId>",
|
|
101
|
+
"decision": "changes_requested", "feedback": "Shorten the opening",
|
|
102
|
+
"comments": [], "idempotencyKey": "<stable submission ID>"
|
|
103
|
+
}
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
}
|
|
101
107
|
```
|
|
102
108
|
|
|
103
|
-
The Neo MCP command façade accepts `events` with `command: "publish"` and `args: {type,source,data}`; the standalone Events MCP provider exposes `publish({type,source,data})`. The UI must call the actually available, authorized MCP interface. Browser MCP App availability of the Events tool must be verified before promising Event mode; no arbitrary HTTP URL or shell command may be specified as an event target.
|
|
109
|
+
Relay's canonical Event Contract is at `agents-relay/skills/agents-relay/contracts/event-contract.md`. A managed Relay caller must build its Template from that Contract, not from Markcut-specific examples. The Neo MCP command façade accepts `events` with `command: "publish"` and `args: {type,source,data}`; the standalone Events MCP provider exposes `publish({type,source,data})`. The UI must call the actually available, authorized MCP interface. Browser MCP App availability of the Events tool must be verified before promising Event mode; no arbitrary HTTP URL or shell command may be specified as an event target.
|
|
104
110
|
|
|
105
111
|
## Functional requirements
|
|
106
112
|
|
|
@@ -122,7 +128,7 @@ The Neo MCP command façade accepts `events` with `command: "publish"` and `args
|
|
|
122
128
|
- **Markcut Provider**: compiles/publishes immutable media, binds review delivery metadata, validates preview revision state, provides review template to clients.
|
|
123
129
|
- **Markcut Preview UI**: gathers comments and decision, fills review fields, dispatches either text or event, displays honest receipt/failure state.
|
|
124
130
|
- **Neo Mobile**: displays the same review/revision, submits through its authenticated Neo MCP connection, retains offline retry state.
|
|
125
|
-
- **Caller/Event consumer**: owns authorization, durable business processing, any Relay Event → original Producer Agent continuation, rereview, workflow transitions, and video delivery. `
|
|
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.
|
|
126
132
|
|
|
127
133
|
## Edge cases and compatibility
|
|
128
134
|
|
package/src/mcp/bridge.mjs
CHANGED
|
@@ -129,10 +129,22 @@ function applyToolInput(params){
|
|
|
129
129
|
}
|
|
130
130
|
let operationGeneration=0;
|
|
131
131
|
function eventEnvelope(template,review){
|
|
132
|
-
if(!template || template.type!=='
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
}}};
|
|
135
146
|
}
|
|
147
|
+
|
|
136
148
|
async function sendReviewEvent(result){
|
|
137
149
|
const event=eventEnvelope(activeReview.eventTemplate,result);
|
|
138
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 = [
|
|
@@ -48,6 +48,9 @@ export const LEGACY_RESOURCE_URIS = [
|
|
|
48
48
|
"ui://markcut/video-preview-v35.html",
|
|
49
49
|
"ui://markcut/video-preview-v36.html",
|
|
50
50
|
"ui://markcut/video-preview-v37.html",
|
|
51
|
+
"ui://markcut/video-preview-v40.html",
|
|
52
|
+
"ui://markcut/video-preview-v41.html",
|
|
53
|
+
"ui://markcut/video-preview-v42.html",
|
|
51
54
|
"ui://markcut/video-preview-v39.html",
|
|
52
55
|
"ui://markcut/video-preview-v38.html",
|
|
53
56
|
];
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
const ID = /^[A-Za-z0-9_-]{1,128}$/;
|
|
3
3
|
const SOURCE = /^job\/[A-Za-z0-9_-]+\/task\/[A-Za-z0-9_-]+\/execution\/[A-Za-z0-9_-]+$/;
|
|
4
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","previewId","requestId","idempotencyKey"];
|
|
5
7
|
function copyData(value) {
|
|
6
8
|
if (!RECORD(value)) throw new Error("eventTemplate.data must be an object");
|
|
7
9
|
// No executable values or reserved overrides can be shipped in a template.
|
|
@@ -16,7 +18,6 @@ function copyData(value) {
|
|
|
16
18
|
}
|
|
17
19
|
};
|
|
18
20
|
walk(clean);
|
|
19
|
-
if (Object.hasOwn(clean,"review")) throw new Error("data.review is reserved for the human result");
|
|
20
21
|
return clean;
|
|
21
22
|
}
|
|
22
23
|
export function normalizeReviewConfig(value) {
|
|
@@ -27,12 +28,20 @@ export function normalizeReviewConfig(value) {
|
|
|
27
28
|
return {delivery:"text"};
|
|
28
29
|
}
|
|
29
30
|
const template=value.eventTemplate;
|
|
30
|
-
if (!RECORD(template) || template.type!==
|
|
31
|
+
if (!RECORD(template) || template.type!==INTERACTIVE_TYPE
|
|
31
32
|
|| typeof template.source!=="string" || !SOURCE.test(template.source)
|
|
32
33
|
|| !RECORD(template.data)) throw new Error("Invalid review event template");
|
|
33
34
|
if (Object.keys(template).some(key=>!["type","source","data"].includes(key))) throw new Error("Unexpected eventTemplate fields");
|
|
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
|
+
!ID.test(interactive.invocationId||"") ||
|
|
41
|
+
REVIEW_FIELDS.some(field=>Object.hasOwn(interactive,field)))
|
|
42
|
+
throw new Error("Invalid task.interactive_decision event template");
|
|
34
43
|
return {delivery:"event",eventTemplate:{
|
|
35
|
-
type:template.type,source:template.source,data
|
|
44
|
+
type:template.type,source:template.source,data,
|
|
36
45
|
}};
|
|
37
46
|
}
|
|
38
47
|
export function eventForReview(config,review) {
|
|
@@ -43,5 +52,15 @@ export function eventForReview(config,review) {
|
|
|
43
52
|
|| !["approved","changes_requested"].includes(review.decision)
|
|
44
53
|
|| !ID.test(review.idempotencyKey || "") || !Array.isArray(review.comments))
|
|
45
54
|
throw new Error("Invalid review result");
|
|
46
|
-
|
|
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
|
+
}};
|
|
47
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,12 +374,21 @@ 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
|
});
|
|
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
|
+
const h=harness(undefined,undefined,m=>m.method==='tools/call'?{published:true}:undefined);
|
|
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);
|
|
391
|
+
});
|
|
383
392
|
it('fails visibly without host Events access and reuses the idempotency key on retry',async()=>{
|
|
384
393
|
const h=harness(undefined,undefined,m=>m.method==='tools/call'?{rpcError:{message:'Host denies cross-server tool'}}:undefined);
|
|
385
394
|
h.result(media);h.nodes.approve.onclick?.();await nextTick();await nextTick();
|
|
@@ -387,8 +396,8 @@ describe('Review event delivery',()=>{
|
|
|
387
396
|
h.nodes.approve.onclick?.();await nextTick();await nextTick();
|
|
388
397
|
const calls=h.messages.filter(m=>m.method==='tools/call');
|
|
389
398
|
expect(calls).toHaveLength(2);
|
|
390
|
-
expect(calls[0].params.arguments.args.data.
|
|
391
|
-
.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);
|
|
392
401
|
expect(h.messages.filter(m=>m.method==='ui/message')).toHaveLength(0);
|
|
393
402
|
});
|
|
394
403
|
it('rejects non-acknowledging host and prevents a second submit after acceptance',async()=>{
|
|
@@ -1,31 +1,41 @@
|
|
|
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();
|
|
@@ -20,7 +20,8 @@ describe('Markcut Remotion MCP App',()=>{
|
|
|
20
20
|
expect(html).toContain('#comment-tools>*{width:30px;height:28px;padding:0;border:0');
|
|
21
21
|
expect(html).toContain('https://neoy.example.test/files/_neoy/markcut/player/');
|
|
22
22
|
expect(html).not.toContain('id="remotion-bundle"');
|
|
23
|
-
|
|
23
|
+
// The generic event contract requires client-side identity and reserved-field validation.
|
|
24
|
+
expect(html.length).toBeLessThan(26000);
|
|
24
25
|
expect(html).not.toContain('<video id="video-player"');
|
|
25
26
|
expect(html).not.toContain('data:video/mp4');
|
|
26
27
|
expect(html).not.toContain('127.0.0.1');
|