@compilr-dev/sdk 0.17.3 → 0.17.5

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.
@@ -48,6 +48,30 @@ const DOC_TYPE_ENUM = [
48
48
  'session-notes',
49
49
  'chapter',
50
50
  ];
51
+ /**
52
+ * Structured-model doc types must be edited via their dedicated *_model_update
53
+ * tool (semantic operations + schema validation), NOT raw document writes/patches
54
+ * — which bypass validation and can corrupt the model (invalid JSON that then
55
+ * crashes/garbles the viewer). Reading a model as a document is fine.
56
+ */
57
+ const MODEL_DOC_UPDATE_TOOL = {
58
+ 'app-model': 'app_model_update',
59
+ 'business-model': 'business_model_update',
60
+ 'research-model': 'research_model_update',
61
+ 'book-model': 'book_model_update',
62
+ 'brand-model': 'brand_model_update',
63
+ 'curriculum-model': 'curriculum_model_update',
64
+ };
65
+ /** Returns a guard message if `docType` is a structured model (else null). */
66
+ function modelDocGuard(docType) {
67
+ const tool = MODEL_DOC_UPDATE_TOOL[docType];
68
+ if (!tool)
69
+ return null;
70
+ const kind = docType.replace('-model', '');
71
+ return (`"${docType}" is a structured model, not a free-form document. ` +
72
+ `Edit it with ${tool} (semantic operations, schema-validated) — a raw document write/patch would ` +
73
+ `bypass validation and can corrupt the model. Read it with ${kind}_model_get.`);
74
+ }
51
75
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
52
76
  export function createDocumentTools(config) {
53
77
  const { context: ctx } = config;
@@ -82,6 +106,9 @@ export function createDocumentTools(config) {
82
106
  },
83
107
  execute: async (input) => {
84
108
  try {
109
+ const guard = modelDocGuard(input.doc_type);
110
+ if (guard)
111
+ return createErrorResult(guard);
85
112
  const projectId = input.project_id ?? ctx.currentProjectId;
86
113
  if (!projectId) {
87
114
  return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
@@ -410,6 +437,9 @@ export function createDocumentTools(config) {
410
437
  },
411
438
  execute: async (input) => {
412
439
  try {
440
+ const guard = modelDocGuard(input.doc_type);
441
+ if (guard)
442
+ return createErrorResult(guard);
413
443
  const projectId = input.project_id ?? ctx.currentProjectId;
414
444
  if (!projectId) {
415
445
  return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.17.3",
3
+ "version": "0.17.5",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",