@tacitai/mcp-server 0.9.5 → 0.9.6
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/dist/tools/career.js +58 -12
- package/package.json +1 -1
package/dist/tools/career.js
CHANGED
|
@@ -337,11 +337,19 @@ export function registerCareerTools(server, getClientFn) {
|
|
|
337
337
|
job_artifact_id: artifact_id,
|
|
338
338
|
});
|
|
339
339
|
const matList = (matResult?.['artifacts'] ?? []);
|
|
340
|
+
const jobLinked = matList.filter((m) => {
|
|
341
|
+
const meta = (m['structured_metadata'] ?? {});
|
|
342
|
+
return meta['job_artifact_id'] === artifact_id;
|
|
343
|
+
});
|
|
344
|
+
// Filter out superseded materials (those with a successor in the revision chain)
|
|
345
|
+
const supersededIds = new Set();
|
|
346
|
+
for (const m of jobLinked) {
|
|
347
|
+
const sid = m['supersedes_artifact_id'];
|
|
348
|
+
if (sid)
|
|
349
|
+
supersededIds.add(sid);
|
|
350
|
+
}
|
|
340
351
|
materials = {
|
|
341
|
-
artifacts:
|
|
342
|
-
const meta = (m['structured_metadata'] ?? {});
|
|
343
|
-
return meta['job_artifact_id'] === artifact_id;
|
|
344
|
-
}),
|
|
352
|
+
artifacts: jobLinked.filter((m) => !supersededIds.has(m['artifact_id'])),
|
|
345
353
|
};
|
|
346
354
|
}
|
|
347
355
|
const metadata = (job['structured_metadata'] ?? {});
|
|
@@ -547,7 +555,7 @@ export function registerCareerTools(server, getClientFn) {
|
|
|
547
555
|
}
|
|
548
556
|
});
|
|
549
557
|
// ── 13. tacit_career_list_materials ────────────────────────────────────
|
|
550
|
-
server.tool('tacit_career_list_materials', 'List career materials in a campaign. Filter by link status (all/linked/unlinked) or search query.
|
|
558
|
+
server.tool('tacit_career_list_materials', 'List career materials in a campaign. Filter by link status (all/linked/unlinked) or search query. Superseded materials (those with a revision) are excluded.', listMaterialsSchema.shape, async (args) => {
|
|
551
559
|
try {
|
|
552
560
|
const client = await getClientFn();
|
|
553
561
|
const input = args;
|
|
@@ -561,7 +569,15 @@ export function registerCareerTools(server, getClientFn) {
|
|
|
561
569
|
if (input.scope && input.scope !== 'all')
|
|
562
570
|
params['scope'] = input.scope;
|
|
563
571
|
const res = await client.get(`/api/v1/portfolios/${input.portfolio_id}/artifacts`, params);
|
|
564
|
-
|
|
572
|
+
// Filter out superseded materials
|
|
573
|
+
const artifacts = (res?.['artifacts'] ?? []);
|
|
574
|
+
const supersededIds = new Set();
|
|
575
|
+
for (const m of artifacts) {
|
|
576
|
+
const sid = m['supersedes_artifact_id'];
|
|
577
|
+
if (sid)
|
|
578
|
+
supersededIds.add(sid);
|
|
579
|
+
}
|
|
580
|
+
return ok({ ...res, artifacts: artifacts.filter((m) => !supersededIds.has(m['artifact_id'])) });
|
|
565
581
|
}
|
|
566
582
|
catch (err) {
|
|
567
583
|
return apiErrorResult(err, 'tacit_career_list_materials');
|
|
@@ -604,7 +620,7 @@ export function registerCareerTools(server, getClientFn) {
|
|
|
604
620
|
}
|
|
605
621
|
});
|
|
606
622
|
// ── 16. tacit_career_save_material (FEAT-275 W2) ──────────────────────
|
|
607
|
-
server.tool('tacit_career_save_material', 'Save locally edited career material
|
|
623
|
+
server.tool('tacit_career_save_material', 'Save locally edited career material back to TACIT. DRAFT materials are updated in place; PUBLISHED materials create a new DRAFT revision (parent unchanged, sidecar re-pointed). Enforces script stripping and drift detection. Never publishes.', saveMaterialSchema.shape, async (args) => {
|
|
608
624
|
const blocked = flagGuard();
|
|
609
625
|
if (blocked)
|
|
610
626
|
return blocked;
|
|
@@ -631,23 +647,29 @@ export function registerCareerTools(server, getClientFn) {
|
|
|
631
647
|
else {
|
|
632
648
|
body = input.content;
|
|
633
649
|
}
|
|
634
|
-
// Script check: reject content
|
|
650
|
+
// Script/embed check: reject dangerous content
|
|
635
651
|
if (/<script[\s>]/i.test(body)) {
|
|
636
652
|
return { content: [{ type: 'text', text: 'Refused: content contains <script> elements. Strip scripts before saving.' }], isError: true };
|
|
637
653
|
}
|
|
638
654
|
if (/\bon(click|load|error|mouseover|mouseout|focus|blur|submit|change|input|keydown|keyup)\s*=/i.test(body)) {
|
|
639
655
|
return { content: [{ type: 'text', text: 'Refused: content contains inline event-handler attributes. Strip them before saving.' }], isError: true };
|
|
640
656
|
}
|
|
657
|
+
if (/javascript\s*:/i.test(body)) {
|
|
658
|
+
return { content: [{ type: 'text', text: 'Refused: content contains javascript: URLs. Strip them before saving.' }], isError: true };
|
|
659
|
+
}
|
|
660
|
+
if (/<(iframe|object|embed)[\s>]/i.test(body)) {
|
|
661
|
+
return { content: [{ type: 'text', text: 'Refused: content contains <iframe>, <object>, or <embed> elements. Strip them before saving.' }], isError: true };
|
|
662
|
+
}
|
|
641
663
|
// Fetch current artifact state
|
|
642
664
|
const artifact = await client.get(`/api/v1/artifacts/editor/${input.artifact_id}`);
|
|
643
665
|
if (!artifact || !artifact['artifact_id']) {
|
|
644
666
|
return { content: [{ type: 'text', text: `Material ${input.artifact_id} not found` }], isError: true };
|
|
645
667
|
}
|
|
646
|
-
// DRAFT-only check (DB stores uppercase status values)
|
|
647
668
|
const status = artifact['status'];
|
|
648
|
-
|
|
669
|
+
const upperStatus = status ? status.toUpperCase() : '';
|
|
670
|
+
if (upperStatus !== 'DRAFT' && upperStatus !== 'PUBLISHED') {
|
|
649
671
|
return {
|
|
650
|
-
content: [{ type: 'text', text: `Material is ${status}
|
|
672
|
+
content: [{ type: 'text', text: `Material is ${status}. Only DRAFT or PUBLISHED materials can be saved back.` }],
|
|
651
673
|
isError: true,
|
|
652
674
|
};
|
|
653
675
|
}
|
|
@@ -665,8 +687,32 @@ export function registerCareerTools(server, getClientFn) {
|
|
|
665
687
|
};
|
|
666
688
|
}
|
|
667
689
|
}
|
|
668
|
-
// Write content back
|
|
669
690
|
const contentHash = crypto.createHash('sha256').update(body, 'utf8').digest('hex');
|
|
691
|
+
if (upperStatus === 'PUBLISHED') {
|
|
692
|
+
// PUBLISHED → create a DRAFT revision via revise endpoint; parent stays unchanged
|
|
693
|
+
const reviseResult = await client.post(`/api/v1/artifacts/${input.artifact_id}/revise`, {
|
|
694
|
+
content: body,
|
|
695
|
+
content_type: 'text/html',
|
|
696
|
+
});
|
|
697
|
+
const revisionId = reviseResult['artifact_id'];
|
|
698
|
+
// Set save-back metadata on the NEW revision
|
|
699
|
+
const metadata = {
|
|
700
|
+
edited_after_generation: 'true',
|
|
701
|
+
edited_at: new Date().toISOString(),
|
|
702
|
+
local_edit_sha256: contentHash,
|
|
703
|
+
};
|
|
704
|
+
await client.patch(`/api/v1/artifacts/${revisionId}/metadata`, { metadata_updates: metadata });
|
|
705
|
+
return ok({
|
|
706
|
+
artifact_id: revisionId,
|
|
707
|
+
parent_artifact_id: input.artifact_id,
|
|
708
|
+
revised: true,
|
|
709
|
+
saved: true,
|
|
710
|
+
content_sha256: contentHash,
|
|
711
|
+
version: reviseResult['version'],
|
|
712
|
+
metadata_set: Object.keys(metadata),
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
// DRAFT path: write content back directly
|
|
670
716
|
await client.put(`/api/v1/artifacts/editor/${input.artifact_id}`, { content: body });
|
|
671
717
|
// Set save-back metadata
|
|
672
718
|
const metadata = {
|