@lalalic/markcut 3.2.56 → 3.2.57
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/src/mcp/bridge.mjs +4 -5
- package/src/mcp/mobile-review-cli.mjs +4 -9
- package/src/mcp/review-delivery.mjs +5 -7
- package/src/mcp/server.mjs +2 -2
- package/tests/mcp-preview-bridge.test.ts +4 -4
- package/tests/mcp-preview-delivery.test.ts +5 -7
- package/tests/mobile-preview-cli.test.ts +4 -4
package/package.json
CHANGED
package/src/mcp/bridge.mjs
CHANGED
|
@@ -153,11 +153,11 @@ function eventEnvelope(template,review){
|
|
|
153
153
|
const match=template.source.match(/^job\\/([^/]+)\\/task\\/([^/]+)\\/execution\\/([^/]+)$/);
|
|
154
154
|
const fixed=template.data.interactive;
|
|
155
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','previewId','requestId','idempotencyKey']
|
|
156
|
+
fixed.executionId!==match[3] ||
|
|
157
|
+
['decision','feedback','comments','revision','revisionId','contentHash','commitSha','invocationId','previewId','requestId','idempotencyKey']
|
|
158
158
|
.some(key=>Object.prototype.hasOwnProperty.call(fixed,key)))throw new Error('Invalid bound interactive decision');
|
|
159
159
|
return {type:template.type,source:template.source,data:{...template.data,interactive:{
|
|
160
|
-
...fixed,
|
|
160
|
+
...fixed,
|
|
161
161
|
previewId:review.previewId,requestId:review.requestId,decision:review.decision,
|
|
162
162
|
feedback:review.feedback||review.comments.map(c=>c.text).join('\\n'),
|
|
163
163
|
comments:review.comments,idempotencyKey:review.idempotencyKey
|
|
@@ -165,8 +165,7 @@ function eventEnvelope(template,review){
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
async function sendReviewEvent(result){
|
|
168
|
-
if(
|
|
169
|
-
result.commitSha=activeReview.commitSha;
|
|
168
|
+
if(!activeReview.eventTemplate)throw new Error('Review event template unavailable');
|
|
170
169
|
const event=eventEnvelope(activeReview.eventTemplate,result);
|
|
171
170
|
// MCP Apps tools/call is host-mediated; an unavailable or unauthorized Events
|
|
172
171
|
// provider MUST fail, never be substituted with ui/message.
|
|
@@ -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,8 +54,6 @@ 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
58
|
const fixed=config.eventTemplate.data.interactive;
|
|
64
59
|
request.eventTemplate=config.eventTemplate;
|
|
@@ -84,7 +79,7 @@ export async function submitNeoReview(request,{fetchImpl=fetch,url=neoReviewEndp
|
|
|
84
79
|
|
|
85
80
|
export async function runMobilePreview(argv){
|
|
86
81
|
const opts=parseEventPreviewOptions(argv);
|
|
87
|
-
const config=opts.delivery==='event' ? normalizeReviewConfig({delivery:'event',
|
|
82
|
+
const config=opts.delivery==='event' ? normalizeReviewConfig({delivery:'event',
|
|
88
83
|
eventTemplate:JSON.parse(readFileSync(resolve(opts.eventTemplatePath),'utf8'))}) : {delivery:'text'};
|
|
89
84
|
const [{startCompileOperation},{EXPORT_ROOT}]=await Promise.all([
|
|
90
85
|
import('./compile-operation.mjs'),import('./remote-assets.mjs'),
|
|
@@ -103,7 +98,7 @@ export async function runMobilePreview(argv){
|
|
|
103
98
|
const request=buildReviewRequest(opts,config,state,operation.operationId);
|
|
104
99
|
const receipt=await submitNeoReview(request);
|
|
105
100
|
return {status:'review_requested',operationId:operation.operationId,requestId:request.id,
|
|
106
|
-
...(opts.delivery==='event' ? {
|
|
101
|
+
...(opts.delivery==='event' ? {} : {contentHash:state.result.contentHash,revisionId:state.result.revisionId}),
|
|
107
102
|
...(config.delivery==='event' ? {jobId:config.eventTemplate.data.interactive.jobId} : {}),
|
|
108
103
|
delivery:config.delivery,notification:receipt.accepted?'apns_submitted':'inbox_stored'};
|
|
109
104
|
}
|
|
@@ -3,7 +3,7 @@ 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
5
|
const INTERACTIVE_TYPE = "task.interactive_decision";
|
|
6
|
-
const REVIEW_FIELDS = ["decision","feedback","comments","revision","revisionId","contentHash","commitSha","previewId","requestId","idempotencyKey"];
|
|
6
|
+
const REVIEW_FIELDS = ["decision","feedback","comments","revision","revisionId","contentHash","commitSha","invocationId","previewId","requestId","idempotencyKey"];
|
|
7
7
|
function copyData(value) {
|
|
8
8
|
if (!RECORD(value)) throw new Error("eventTemplate.data must be an object");
|
|
9
9
|
// No executable values or reserved overrides can be shipped in a template.
|
|
@@ -37,29 +37,27 @@ export function normalizeReviewConfig(value) {
|
|
|
37
37
|
const interactive=data.interactive;
|
|
38
38
|
if (!match || !RECORD(interactive) || interactive.jobId!==match[1] ||
|
|
39
39
|
interactive.taskId!==match[2] || interactive.executionId!==match[3] ||
|
|
40
|
-
!ID.test(interactive.invocationId||"") ||
|
|
41
40
|
REVIEW_FIELDS.some(field=>Object.hasOwn(interactive,field)))
|
|
42
41
|
throw new Error("Invalid task.interactive_decision event template");
|
|
43
|
-
if (
|
|
44
|
-
return {delivery:"event",
|
|
42
|
+
if (value.commitSha !== undefined) throw new Error('Git SHA is not a Review field');
|
|
43
|
+
return {delivery:"event",eventTemplate:{
|
|
45
44
|
type:template.type,source:template.source,data,
|
|
46
45
|
}};
|
|
47
46
|
}
|
|
48
47
|
export function eventForReview(config,review) {
|
|
49
48
|
const {eventTemplate:template}=normalizeReviewConfig(config);
|
|
50
49
|
if (!template) throw new Error("Event mode required");
|
|
51
|
-
if (!RECORD(review) || !ID.test(review.requestId || "")
|
|
50
|
+
if (!RECORD(review) || !ID.test(review.requestId || "")
|
|
52
51
|
|| !["approved","changes_requested"].includes(review.decision)
|
|
53
52
|
|| !ID.test(review.idempotencyKey || "") || !Array.isArray(review.comments))
|
|
54
53
|
throw new Error("Invalid review result");
|
|
55
|
-
if (review.commitSha !==
|
|
54
|
+
if (review.commitSha !== undefined || review.invocationId !== undefined) throw new Error('Review identity is Task execution only');
|
|
56
55
|
const details=template.data.interactive;
|
|
57
56
|
const feedback=typeof review.feedback==="string" ? review.feedback :
|
|
58
57
|
review.comments.map(comment=>comment.text).filter(value=>typeof value==="string").join("\n");
|
|
59
58
|
return {type:INTERACTIVE_TYPE,source:template.source,data:{
|
|
60
59
|
...template.data,
|
|
61
60
|
interactive:{...details,
|
|
62
|
-
revision:review.commitSha,commitSha:review.commitSha,
|
|
63
61
|
previewId:review.previewId,requestId:review.requestId,
|
|
64
62
|
decision:review.decision,feedback,comments:structuredClone(review.comments),
|
|
65
63
|
idempotencyKey:review.idempotencyKey},
|
package/src/mcp/server.mjs
CHANGED
|
@@ -47,11 +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 the
|
|
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.",
|
|
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(),
|
|
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
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."),
|
|
56
56
|
}).optional(),
|
|
57
57
|
}),
|
|
@@ -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',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,8 +405,8 @@ 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');
|
|
@@ -2,9 +2,8 @@ import {describe,it,expect} from 'vitest';
|
|
|
2
2
|
import {normalizeReviewConfig,eventForReview} from '../src/mcp/review-delivery.mjs';
|
|
3
3
|
|
|
4
4
|
const template={type:'task.interactive_decision',source:'job/j1/task/t1/execution/e1',
|
|
5
|
-
data:{interactive:{jobId:'j1',taskId:'t1',executionId:'e1'
|
|
6
|
-
const
|
|
7
|
-
const review={requestId:'r1',previewId:'p1',commitSha:sha,
|
|
5
|
+
data:{interactive:{jobId:'j1',taskId:'t1',executionId:'e1'},meta:{source:'ok'}}};
|
|
6
|
+
const review={requestId:'r1',previewId:'p1',
|
|
8
7
|
decision:'changes_requested',comments:[{sceneId:'intro',timeSeconds:3.2,text:'Shorter intro'}],idempotencyKey:'key1'};
|
|
9
8
|
|
|
10
9
|
describe('Provider-bound preview delivery',()=>{
|
|
@@ -23,21 +22,20 @@ describe('Provider-bound preview delivery',()=>{
|
|
|
23
22
|
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
24
23
|
data:{interactive:{...template.data.interactive,taskId:'forged'}}}})).toThrow();
|
|
25
24
|
expect(()=>normalizeReviewConfig({delivery:'event',eventTemplate:{...template,
|
|
26
|
-
data:{interactive:{...template.data.interactive,revision:
|
|
25
|
+
data:{interactive:{...template.data.interactive,revision:'bad'}}}})).toThrow();
|
|
27
26
|
});
|
|
28
27
|
it('freezes caller-owned identity and fills only data.interactive fields on human submit',()=>{
|
|
29
|
-
const config=normalizeReviewConfig({delivery:'event',
|
|
28
|
+
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
30
29
|
template.data.meta.source='changed after validation';
|
|
31
30
|
const event=eventForReview(config,review);
|
|
32
31
|
expect(event).toMatchObject({type:'task.interactive_decision',source:template.source,
|
|
33
32
|
data:{meta:{source:'ok'},interactive:{jobId:'j1',taskId:'t1',executionId:'e1',
|
|
34
|
-
invocationId:'review-r1',revision:sha,commitSha:sha,
|
|
35
33
|
decision:'changes_requested',feedback:'Shorter intro',comments:review.comments,
|
|
36
34
|
idempotencyKey:'key1'}}});
|
|
37
35
|
expect(template.data.interactive).not.toHaveProperty('decision');
|
|
38
36
|
});
|
|
39
37
|
it('refuses malformed review identity or unauthorized decision',()=>{
|
|
40
|
-
const config=normalizeReviewConfig({delivery:'event',
|
|
38
|
+
const config=normalizeReviewConfig({delivery:'event',eventTemplate:template});
|
|
41
39
|
expect(()=>eventForReview(config,{...review,commitSha:'bogus'})).toThrow();
|
|
42
40
|
expect(()=>eventForReview(config,{...review,decision:'task.completed'})).toThrow();
|
|
43
41
|
});
|
|
@@ -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,7 +15,7 @@ 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);
|
|
@@ -24,9 +24,9 @@ describe('Neo-owned REST notification from standalone CLI',()=>{
|
|
|
24
24
|
});
|
|
25
25
|
it('uses exact caller-bound template for Relay event review',()=>{
|
|
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,jobId:'12',groupId:'job/12/task/prod'});
|
|
30
30
|
expect(request).not.toHaveProperty('revisionId');expect(request).not.toHaveProperty('contentHash');
|
|
31
31
|
});
|
|
32
32
|
it('POSTs to local Neo Core REST and requires persisted matching ACK',async()=>{
|