@harnesys/sdk 0.0.0-stage → 1.1.0

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.
Files changed (147) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +80 -2
  3. package/dist/addon-context-factory.d.ts +6 -0
  4. package/dist/addon-context-factory.js +160 -0
  5. package/dist/addon-context.d.ts +346 -0
  6. package/dist/addon-context.js +0 -0
  7. package/dist/define-addon.d.ts +57 -0
  8. package/dist/define-addon.js +53 -0
  9. package/dist/families/config.d.ts +14 -0
  10. package/dist/families/config.js +16 -0
  11. package/dist/families/content.d.ts +28 -0
  12. package/dist/families/content.js +19 -0
  13. package/dist/families/field-spec.d.ts +100 -0
  14. package/dist/families/field-spec.js +85 -0
  15. package/dist/families/hook.d.ts +37 -0
  16. package/dist/families/hook.js +25 -0
  17. package/dist/families/job.d.ts +45 -0
  18. package/dist/families/job.js +26 -0
  19. package/dist/families/json-schema-value.d.ts +12 -0
  20. package/dist/families/json-schema-value.js +243 -0
  21. package/dist/families/json-schema.d.ts +36 -0
  22. package/dist/families/json-schema.js +101 -0
  23. package/dist/families/lsp.d.ts +18 -0
  24. package/dist/families/lsp.js +18 -0
  25. package/dist/families/mcp.d.ts +18 -0
  26. package/dist/families/mcp.js +18 -0
  27. package/dist/families/registry.d.ts +9 -0
  28. package/dist/families/registry.js +34 -0
  29. package/dist/families/route.d.ts +38 -0
  30. package/dist/families/route.js +37 -0
  31. package/dist/families/source-kind.d.ts +24 -0
  32. package/dist/families/source-kind.js +21 -0
  33. package/dist/families/tool-pack.d.ts +68 -0
  34. package/dist/families/tool-pack.js +57 -0
  35. package/dist/families/transport.d.ts +52 -0
  36. package/dist/families/transport.js +29 -0
  37. package/dist/families/trigger.d.ts +97 -0
  38. package/dist/families/trigger.js +46 -0
  39. package/dist/families/view.d.ts +255 -0
  40. package/dist/families/view.js +87 -0
  41. package/dist/families/viewer.d.ts +31 -0
  42. package/dist/families/viewer.js +26 -0
  43. package/dist/families/worker.d.ts +23 -0
  44. package/dist/families/worker.js +19 -0
  45. package/dist/host-client.d.ts +11 -0
  46. package/dist/host-client.js +30 -0
  47. package/dist/index.d.ts +36 -0
  48. package/dist/index.js +36 -0
  49. package/dist/manifest/branding.d.ts +14 -0
  50. package/dist/manifest/branding.js +18 -0
  51. package/dist/manifest/connections.d.ts +21 -0
  52. package/dist/manifest/connections.js +10 -0
  53. package/dist/manifest/json-schema.d.ts +2 -0
  54. package/dist/manifest/json-schema.js +13 -0
  55. package/dist/manifest/l10n.d.ts +9 -0
  56. package/dist/manifest/l10n.js +28 -0
  57. package/dist/manifest/manifest.d.ts +112 -0
  58. package/dist/manifest/manifest.js +45 -0
  59. package/dist/manifest/validate.d.ts +14 -0
  60. package/dist/manifest/validate.js +144 -0
  61. package/dist/permissions/permissions.d.ts +31 -0
  62. package/dist/permissions/permissions.js +53 -0
  63. package/dist/process-entry.d.ts +26 -0
  64. package/dist/process-entry.js +146 -0
  65. package/dist/protocol/envelope.d.ts +115 -0
  66. package/dist/protocol/envelope.js +72 -0
  67. package/dist/protocol/error.d.ts +67 -0
  68. package/dist/protocol/error.js +61 -0
  69. package/dist/protocol/handshake.d.ts +55 -0
  70. package/dist/protocol/handshake.js +26 -0
  71. package/dist/protocol/map.d.ts +1090 -0
  72. package/dist/protocol/map.js +127 -0
  73. package/dist/protocol/meta.d.ts +31 -0
  74. package/dist/protocol/meta.js +14 -0
  75. package/dist/protocol/method-spec.d.ts +13 -0
  76. package/dist/protocol/method-spec.js +9 -0
  77. package/dist/protocol/org-service-methods.d.ts +135 -0
  78. package/dist/protocol/org-service-methods.js +106 -0
  79. package/dist/protocol/shared.d.ts +389 -0
  80. package/dist/protocol/shared.js +231 -0
  81. package/dist/protocol/source-methods.d.ts +218 -0
  82. package/dist/protocol/source-methods.js +18 -0
  83. package/dist/protocol/thread-service-methods.d.ts +50 -0
  84. package/dist/protocol/thread-service-methods.js +32 -0
  85. package/dist/runtime.d.ts +25 -0
  86. package/dist/runtime.js +229 -0
  87. package/dist/testing/fake-db.d.ts +15 -0
  88. package/dist/testing/fake-db.js +120 -0
  89. package/dist/testing/fake-files.d.ts +9 -0
  90. package/dist/testing/fake-files.js +87 -0
  91. package/dist/testing/fake-host.d.ts +115 -0
  92. package/dist/testing/fake-host.js +217 -0
  93. package/dist/testing/fake-services.d.ts +63 -0
  94. package/dist/testing/fake-services.js +277 -0
  95. package/dist/testing/fixtures.d.ts +5 -0
  96. package/dist/testing/fixtures.js +101 -0
  97. package/dist/testing/index.d.ts +4 -0
  98. package/dist/testing/index.js +2 -0
  99. package/package.json +66 -4
  100. package/src/addon-context-factory.ts +236 -0
  101. package/src/addon-context.ts +313 -0
  102. package/src/define-addon.ts +178 -0
  103. package/src/families/config.ts +24 -0
  104. package/src/families/content.ts +35 -0
  105. package/src/families/field-spec.ts +175 -0
  106. package/src/families/hook.ts +34 -0
  107. package/src/families/job.ts +41 -0
  108. package/src/families/json-schema-value.ts +322 -0
  109. package/src/families/json-schema.ts +167 -0
  110. package/src/families/lsp.ts +28 -0
  111. package/src/families/mcp.ts +28 -0
  112. package/src/families/registry.ts +44 -0
  113. package/src/families/route.ts +52 -0
  114. package/src/families/source-kind.ts +34 -0
  115. package/src/families/tool-pack.ts +92 -0
  116. package/src/families/transport.ts +52 -0
  117. package/src/families/trigger.ts +92 -0
  118. package/src/families/view.ts +144 -0
  119. package/src/families/viewer.ts +43 -0
  120. package/src/families/worker.ts +30 -0
  121. package/src/host-client.ts +52 -0
  122. package/src/index.ts +345 -0
  123. package/src/manifest/branding.ts +24 -0
  124. package/src/manifest/connections.ts +21 -0
  125. package/src/manifest/json-schema.ts +24 -0
  126. package/src/manifest/l10n.ts +39 -0
  127. package/src/manifest/manifest.ts +94 -0
  128. package/src/manifest/validate.ts +200 -0
  129. package/src/permissions/permissions.ts +79 -0
  130. package/src/process-entry.ts +205 -0
  131. package/src/protocol/envelope.ts +126 -0
  132. package/src/protocol/error.ts +81 -0
  133. package/src/protocol/handshake.ts +43 -0
  134. package/src/protocol/map.ts +339 -0
  135. package/src/protocol/meta.ts +26 -0
  136. package/src/protocol/method-spec.ts +40 -0
  137. package/src/protocol/org-service-methods.ts +148 -0
  138. package/src/protocol/shared.ts +345 -0
  139. package/src/protocol/source-methods.ts +61 -0
  140. package/src/protocol/thread-service-methods.ts +50 -0
  141. package/src/runtime.ts +332 -0
  142. package/src/testing/fake-db.ts +140 -0
  143. package/src/testing/fake-files.ts +114 -0
  144. package/src/testing/fake-host.ts +350 -0
  145. package/src/testing/fake-services.ts +345 -0
  146. package/src/testing/fixtures.ts +106 -0
  147. package/src/testing/index.ts +12 -0
@@ -0,0 +1,243 @@
1
+ const MAX_VALIDATION_DEPTH = 16;
2
+ /**
3
+ * Validates a value against the §6.5 JSON Schema subset (`type`, `properties`,
4
+ * `required`, `items`, `enum`, `const`, numeric and string bounds,
5
+ * `additionalProperties`, limited `oneOf`/`anyOf`, local `$defs`/`$ref`).
6
+ * Same contract the host applies to route request bodies; the fake host uses it
7
+ * to validate tool `inputSchema`/`outputSchema`.
8
+ */
9
+ export function schemaValueIssues(value, schema) {
10
+ const ctx = { root: schema, issues: [] };
11
+ validateNode(value, schema, '$', 0, ctx);
12
+ return ctx.issues;
13
+ }
14
+ function validateNode(value, node, path, depth, ctx) {
15
+ if (depth > MAX_VALIDATION_DEPTH) {
16
+ ctx.issues.push({ path, message: 'value nesting exceeds the maximum depth' });
17
+ return;
18
+ }
19
+ if (node.$ref !== undefined) {
20
+ validateRef(value, node.$ref, path, depth, ctx);
21
+ return;
22
+ }
23
+ if (!matchesUnion(value, node, path, ctx)) {
24
+ return;
25
+ }
26
+ if (!matchesEnum(value, node, path, ctx)) {
27
+ return;
28
+ }
29
+ if (node.const !== undefined && node.const !== value) {
30
+ ctx.issues.push({ path, message: 'value does not equal the const constraint' });
31
+ return;
32
+ }
33
+ if (typeof value === 'string') {
34
+ validateString(value, node, path, ctx);
35
+ }
36
+ else if (typeof value === 'number' && Number.isFinite(value)) {
37
+ validateNumber(value, node, path, ctx);
38
+ }
39
+ else if (Array.isArray(value)) {
40
+ validateArray(value, node, path, depth, ctx);
41
+ }
42
+ else if (isPlainObject(value)) {
43
+ validateObject(value, node, path, depth, ctx);
44
+ }
45
+ }
46
+ function validateRef(value, ref, path, depth, ctx) {
47
+ const resolved = resolveRef(ctx.root, ref);
48
+ if (resolved === null) {
49
+ ctx.issues.push({ path, message: `unresolvable $ref '${ref}'` });
50
+ return;
51
+ }
52
+ validateNode(value, resolved, path, depth + 1, ctx);
53
+ }
54
+ function matchesUnion(value, node, path, ctx) {
55
+ if (node.oneOf !== undefined && node.oneOf.length > 0) {
56
+ const matches = node.oneOf.filter((branch) => branchIssues(value, branch, ctx) === 0).length;
57
+ if (matches !== 1) {
58
+ ctx.issues.push({ path, message: `expected exactly one oneOf branch, matched ${matches}` });
59
+ return false;
60
+ }
61
+ return true;
62
+ }
63
+ if (node.anyOf !== undefined && node.anyOf.length > 0) {
64
+ if (!node.anyOf.some((branch) => branchIssues(value, branch, ctx) === 0)) {
65
+ ctx.issues.push({ path, message: 'value matches no anyOf branch' });
66
+ return false;
67
+ }
68
+ return true;
69
+ }
70
+ if (!matchesType(value, node.type)) {
71
+ ctx.issues.push({ path, message: `expected ${node.type ?? 'any'}, got ${kindOf(value)}` });
72
+ return false;
73
+ }
74
+ return true;
75
+ }
76
+ function matchesEnum(value, node, path, ctx) {
77
+ if (node.enum === undefined || node.enum.some((entry) => entry === value)) {
78
+ return true;
79
+ }
80
+ ctx.issues.push({ path, message: 'value is not one of the allowed enum entries' });
81
+ return false;
82
+ }
83
+ function matchesType(value, expected) {
84
+ if (expected === undefined) {
85
+ return true;
86
+ }
87
+ switch (expected) {
88
+ case 'string':
89
+ return typeof value === 'string';
90
+ case 'boolean':
91
+ return typeof value === 'boolean';
92
+ case 'null':
93
+ return value === null;
94
+ case 'integer':
95
+ return typeof value === 'number' && Number.isInteger(value);
96
+ case 'number':
97
+ return typeof value === 'number' && Number.isFinite(value);
98
+ case 'array':
99
+ return Array.isArray(value);
100
+ case 'object':
101
+ return isPlainObject(value);
102
+ default:
103
+ return true;
104
+ }
105
+ }
106
+ function validateString(value, node, path, ctx) {
107
+ if (node.minLength !== undefined && value.length < node.minLength) {
108
+ ctx.issues.push({ path, message: `length is below minLength ${node.minLength}` });
109
+ }
110
+ if (node.maxLength !== undefined && value.length > node.maxLength) {
111
+ ctx.issues.push({ path, message: `length exceeds maxLength ${node.maxLength}` });
112
+ }
113
+ if (node.pattern === undefined) {
114
+ return;
115
+ }
116
+ try {
117
+ if (!new RegExp(node.pattern).test(value)) {
118
+ ctx.issues.push({ path, message: `value does not match pattern '${node.pattern}'` });
119
+ }
120
+ }
121
+ catch {
122
+ ctx.issues.push({ path, message: `schema pattern '${node.pattern}' is not a valid regex` });
123
+ }
124
+ }
125
+ function validateNumber(value, node, path, ctx) {
126
+ if (node.minimum !== undefined && value < node.minimum) {
127
+ ctx.issues.push({ path, message: `value is below minimum ${node.minimum}` });
128
+ }
129
+ if (node.maximum !== undefined && value > node.maximum) {
130
+ ctx.issues.push({ path, message: `value exceeds maximum ${node.maximum}` });
131
+ }
132
+ if (node.exclusiveMinimum !== undefined && value <= node.exclusiveMinimum) {
133
+ ctx.issues.push({
134
+ path,
135
+ message: `value is not above exclusiveMinimum ${node.exclusiveMinimum}`,
136
+ });
137
+ }
138
+ if (node.exclusiveMaximum !== undefined && value >= node.exclusiveMaximum) {
139
+ ctx.issues.push({
140
+ path,
141
+ message: `value is not below exclusiveMaximum ${node.exclusiveMaximum}`,
142
+ });
143
+ }
144
+ }
145
+ function validateArray(value, node, path, depth, ctx) {
146
+ if (node.minItems !== undefined && value.length < node.minItems) {
147
+ ctx.issues.push({ path, message: `array has fewer than minItems ${node.minItems}` });
148
+ }
149
+ if (node.maxItems !== undefined && value.length > node.maxItems) {
150
+ ctx.issues.push({ path, message: `array has more than maxItems ${node.maxItems}` });
151
+ }
152
+ if (node.uniqueItems === true && hasDuplicates(value)) {
153
+ ctx.issues.push({ path, message: 'array entries are not unique' });
154
+ }
155
+ if (node.items === undefined) {
156
+ return;
157
+ }
158
+ const items = node.items;
159
+ if (Array.isArray(items)) {
160
+ for (const [index, item] of value.entries()) {
161
+ const itemSchema = items[index];
162
+ if (itemSchema !== undefined) {
163
+ validateNode(item, itemSchema, `${path}[${index}]`, depth + 1, ctx);
164
+ }
165
+ }
166
+ return;
167
+ }
168
+ for (const [index, item] of value.entries()) {
169
+ validateNode(item, items, `${path}[${index}]`, depth + 1, ctx);
170
+ }
171
+ }
172
+ function validateObject(value, node, path, depth, ctx) {
173
+ for (const key of node.required ?? []) {
174
+ if (!(key in value)) {
175
+ ctx.issues.push({ path, message: `missing required property '${key}'` });
176
+ }
177
+ }
178
+ const additional = node.additionalProperties;
179
+ if (additional === undefined || additional === true) {
180
+ validateDeclaredProperties(value, node, path, depth, ctx);
181
+ return;
182
+ }
183
+ for (const [key, child] of Object.entries(value)) {
184
+ const childPath = `${path}.${key}`;
185
+ const declared = node.properties?.[key];
186
+ if (declared !== undefined) {
187
+ validateNode(child, declared, childPath, depth + 1, ctx);
188
+ continue;
189
+ }
190
+ if (additional === false) {
191
+ ctx.issues.push({ path: childPath, message: 'property is not allowed by the schema' });
192
+ continue;
193
+ }
194
+ validateNode(child, additional, childPath, depth + 1, ctx);
195
+ }
196
+ }
197
+ function validateDeclaredProperties(value, node, path, depth, ctx) {
198
+ for (const [key, child] of Object.entries(node.properties ?? {})) {
199
+ if (key in value) {
200
+ validateNode(value[key], child, `${path}.${key}`, depth + 1, ctx);
201
+ }
202
+ }
203
+ }
204
+ function branchIssues(value, branch, ctx) {
205
+ const issues = [];
206
+ validateNode(value, branch, '$', 0, { root: ctx.root, issues });
207
+ return issues.length;
208
+ }
209
+ function resolveRef(root, ref) {
210
+ if (!ref.startsWith('#/')) {
211
+ return null;
212
+ }
213
+ let current = root;
214
+ for (const segment of ref.slice(2).split('/')) {
215
+ if (!isPlainObject(current)) {
216
+ return null;
217
+ }
218
+ current = current[segment];
219
+ }
220
+ return isPlainObject(current) ? current : null;
221
+ }
222
+ function hasDuplicates(value) {
223
+ const seen = new Set();
224
+ for (const entry of value) {
225
+ const key = JSON.stringify(entry);
226
+ if (seen.has(key)) {
227
+ return true;
228
+ }
229
+ }
230
+ return false;
231
+ }
232
+ function isPlainObject(value) {
233
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
234
+ }
235
+ function kindOf(value) {
236
+ if (value === null) {
237
+ return 'null';
238
+ }
239
+ if (Array.isArray(value)) {
240
+ return 'array';
241
+ }
242
+ return typeof value;
243
+ }
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ export type JsonSchemaItems = JsonSchemaSubset | JsonSchemaSubset[];
3
+ export interface JsonSchemaSubset {
4
+ type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null';
5
+ properties?: Record<string, JsonSchemaSubset>;
6
+ required?: string[];
7
+ additionalProperties?: boolean | JsonSchemaSubset;
8
+ items?: JsonSchemaItems;
9
+ enum?: unknown[];
10
+ const?: unknown;
11
+ minimum?: number;
12
+ maximum?: number;
13
+ exclusiveMinimum?: number;
14
+ exclusiveMaximum?: number;
15
+ minLength?: number;
16
+ maxLength?: number;
17
+ pattern?: string;
18
+ minItems?: number;
19
+ maxItems?: number;
20
+ uniqueItems?: boolean;
21
+ oneOf?: JsonSchemaSubset[];
22
+ anyOf?: JsonSchemaSubset[];
23
+ description?: string;
24
+ default?: unknown;
25
+ $defs?: Record<string, JsonSchemaSubset>;
26
+ $ref?: string;
27
+ }
28
+ export declare const JsonSchemaSubsetSchema: z.ZodLazy<z.ZodType<JsonSchemaSubset, unknown, z.core.$ZodTypeInternals<JsonSchemaSubset, unknown>>>;
29
+ export declare const INPUT_SCHEMA_MAX_DEPTH = 8;
30
+ export declare const INPUT_SCHEMA_MAX_BYTES: number;
31
+ export interface SchemaViolation {
32
+ path: string;
33
+ code: 'schema' | 'depth' | 'size' | 'external_ref';
34
+ message: string;
35
+ }
36
+ export declare function validateInputSchema(raw: unknown): SchemaViolation[];
@@ -0,0 +1,101 @@
1
+ import { z } from 'zod';
2
+ const node = z.lazy(() => z.strictObject({
3
+ type: z
4
+ .enum(['object', 'array', 'string', 'number', 'integer', 'boolean', 'null'])
5
+ .optional(),
6
+ properties: z.record(z.string(), node).optional(),
7
+ required: z.array(z.string()).optional(),
8
+ additionalProperties: z.union([z.boolean(), node]).optional(),
9
+ items: z.union([node, z.array(node)]).optional(),
10
+ enum: z.array(z.unknown()).optional(),
11
+ const: z.unknown().optional(),
12
+ minimum: z.number().optional(),
13
+ maximum: z.number().optional(),
14
+ exclusiveMinimum: z.number().optional(),
15
+ exclusiveMaximum: z.number().optional(),
16
+ minLength: z.number().int().nonnegative().optional(),
17
+ maxLength: z.number().int().nonnegative().optional(),
18
+ pattern: z.string().optional(),
19
+ minItems: z.number().int().nonnegative().optional(),
20
+ maxItems: z.number().int().nonnegative().optional(),
21
+ uniqueItems: z.boolean().optional(),
22
+ oneOf: z.array(node).optional(),
23
+ anyOf: z.array(node).optional(),
24
+ description: z.string().optional(),
25
+ default: z.unknown().optional(),
26
+ $defs: z.record(z.string(), node).optional(),
27
+ $ref: z.string().optional(),
28
+ }));
29
+ export const JsonSchemaSubsetSchema = node;
30
+ export const INPUT_SCHEMA_MAX_DEPTH = 8;
31
+ export const INPUT_SCHEMA_MAX_BYTES = 64 * 1024;
32
+ export function validateInputSchema(raw) {
33
+ const violations = [];
34
+ const parsed = JsonSchemaSubsetSchema.safeParse(raw);
35
+ if (!parsed.success) {
36
+ for (const issue of parsed.error.issues) {
37
+ violations.push({
38
+ path: issue.path.map(String).join('.') || '(root)',
39
+ code: 'schema',
40
+ message: issue.message,
41
+ });
42
+ }
43
+ return violations;
44
+ }
45
+ const size = new TextEncoder().encode(JSON.stringify(raw)).length;
46
+ if (size > INPUT_SCHEMA_MAX_BYTES) {
47
+ violations.push({
48
+ path: '(root)',
49
+ code: 'size',
50
+ message: `schema exceeds ${INPUT_SCHEMA_MAX_BYTES} bytes (${size})`,
51
+ });
52
+ }
53
+ checkNode(parsed.data, '$', 0, violations);
54
+ return violations;
55
+ }
56
+ const LOCAL_REF = /^#(\/(\$defs|properties)\/[A-Za-z0-9_-]+)*$/;
57
+ function checkNode(nodeValue, path, depth, violations) {
58
+ if (depth > INPUT_SCHEMA_MAX_DEPTH) {
59
+ violations.push({
60
+ path,
61
+ code: 'depth',
62
+ message: `schema depth exceeds ${INPUT_SCHEMA_MAX_DEPTH}`,
63
+ });
64
+ return;
65
+ }
66
+ checkRef(nodeValue, path, violations);
67
+ checkChildren(nodeValue, path, depth, violations);
68
+ }
69
+ function checkRef(nodeValue, path, violations) {
70
+ if (nodeValue.$ref !== undefined && !LOCAL_REF.test(nodeValue.$ref)) {
71
+ violations.push({
72
+ path,
73
+ code: 'external_ref',
74
+ message: `external $ref '${nodeValue.$ref}' is not allowed`,
75
+ });
76
+ }
77
+ }
78
+ function checkChildren(nodeValue, path, depth, violations) {
79
+ for (const child of Object.values(nodeValue.properties ?? {})) {
80
+ checkNode(child, `${path}.properties`, depth + 1, violations);
81
+ }
82
+ checkItems(nodeValue.items, path, depth, violations);
83
+ const branches = [...(nodeValue.oneOf ?? []), ...(nodeValue.anyOf ?? [])];
84
+ for (const branch of branches) {
85
+ checkNode(branch, `${path}.oneOf`, depth + 1, violations);
86
+ }
87
+ if (typeof nodeValue.additionalProperties === 'object') {
88
+ checkNode(nodeValue.additionalProperties, `${path}.additionalProperties`, depth + 1, violations);
89
+ }
90
+ for (const def of Object.values(nodeValue.$defs ?? {})) {
91
+ checkNode(def, `${path}.$defs`, depth + 1, violations);
92
+ }
93
+ }
94
+ function checkItems(items, path, depth, violations) {
95
+ if (!items) {
96
+ return;
97
+ }
98
+ for (const item of Array.isArray(items) ? items : [items]) {
99
+ checkNode(item, `${path}.items`, depth + 1, violations);
100
+ }
101
+ }
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import type { L10n } from '../manifest/l10n.ts';
3
+ export declare const LSP_SCHEMA_VERSION = 1;
4
+ export interface LspDescriptor {
5
+ id: string;
6
+ title: L10n;
7
+ connection?: string;
8
+ }
9
+ export declare const LspDescriptorSchema: z.ZodObject<{
10
+ id: z.ZodString;
11
+ title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
12
+ connection: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>;
14
+ export declare const lspFamily: {
15
+ family: string;
16
+ versions: number[];
17
+ schema: (v: number) => z.ZodType;
18
+ };
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { L10nSchema } from "../manifest/l10n.js";
3
+ export const LSP_SCHEMA_VERSION = 1;
4
+ export const LspDescriptorSchema = z.object({
5
+ id: z.string().min(1),
6
+ title: L10nSchema,
7
+ connection: z.string().min(1).optional(),
8
+ });
9
+ export const lspFamily = {
10
+ family: 'lsp',
11
+ versions: [LSP_SCHEMA_VERSION],
12
+ schema: (v) => {
13
+ if (v !== LSP_SCHEMA_VERSION) {
14
+ throw new Error(`lsp descriptor schema version ${v} is not supported`);
15
+ }
16
+ return LspDescriptorSchema;
17
+ },
18
+ };
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import type { L10n } from '../manifest/l10n.ts';
3
+ export declare const MCP_SCHEMA_VERSION = 1;
4
+ export interface McpDescriptor {
5
+ id: string;
6
+ title: L10n;
7
+ connection?: string;
8
+ }
9
+ export declare const McpDescriptorSchema: z.ZodObject<{
10
+ id: z.ZodString;
11
+ title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
12
+ connection: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>;
14
+ export declare const mcpFamily: {
15
+ family: string;
16
+ versions: number[];
17
+ schema: (v: number) => z.ZodType;
18
+ };
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { L10nSchema } from "../manifest/l10n.js";
3
+ export const MCP_SCHEMA_VERSION = 1;
4
+ export const McpDescriptorSchema = z.object({
5
+ id: z.string().min(1),
6
+ title: L10nSchema,
7
+ connection: z.string().min(1).optional(),
8
+ });
9
+ export const mcpFamily = {
10
+ family: 'mcp',
11
+ versions: [MCP_SCHEMA_VERSION],
12
+ schema: (v) => {
13
+ if (v !== MCP_SCHEMA_VERSION) {
14
+ throw new Error(`mcp descriptor schema version ${v} is not supported`);
15
+ }
16
+ return McpDescriptorSchema;
17
+ },
18
+ };
@@ -0,0 +1,9 @@
1
+ import type { z } from 'zod';
2
+ export interface FamilyDefinition {
3
+ readonly family: string;
4
+ readonly versions: readonly number[];
5
+ schema(v: number): z.ZodType;
6
+ }
7
+ export declare const familyRegistry: Record<string, FamilyDefinition>;
8
+ export declare const FAMILY_NAMES: Array<keyof typeof familyRegistry>;
9
+ export declare function familyDefinition(family: string): FamilyDefinition | undefined;
@@ -0,0 +1,34 @@
1
+ import { configFamily } from "./config.js";
2
+ import { contentFamily } from "./content.js";
3
+ import { hookFamily } from "./hook.js";
4
+ import { jobFamily } from "./job.js";
5
+ import { lspFamily } from "./lsp.js";
6
+ import { mcpFamily } from "./mcp.js";
7
+ import { routeFamily } from "./route.js";
8
+ import { sourceKindFamily } from "./source-kind.js";
9
+ import { toolPackFamily } from "./tool-pack.js";
10
+ import { transportFamily } from "./transport.js";
11
+ import { triggerFamily } from "./trigger.js";
12
+ import { viewFamily } from "./view.js";
13
+ import { viewerFamily } from "./viewer.js";
14
+ import { workerFamily } from "./worker.js";
15
+ export const familyRegistry = {
16
+ 'tool-pack': toolPackFamily,
17
+ trigger: triggerFamily,
18
+ job: jobFamily,
19
+ worker: workerFamily,
20
+ route: routeFamily,
21
+ transport: transportFamily,
22
+ hook: hookFamily,
23
+ content: contentFamily,
24
+ config: configFamily,
25
+ view: viewFamily,
26
+ 'source-kind': sourceKindFamily,
27
+ mcp: mcpFamily,
28
+ lsp: lspFamily,
29
+ viewer: viewerFamily,
30
+ };
31
+ export const FAMILY_NAMES = Object.keys(familyRegistry);
32
+ export function familyDefinition(family) {
33
+ return familyRegistry[family];
34
+ }
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ export declare const ROUTE_SCHEMA_VERSION = 1;
3
+ export type RouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
4
+ export interface RouteDescriptor {
5
+ id: string;
6
+ method: RouteMethod;
7
+ path: string;
8
+ role?: 'member' | 'admin';
9
+ exposure?: 'org' | 'public';
10
+ bodyLimitKb?: number;
11
+ requestSchema?: Record<string, unknown>;
12
+ }
13
+ export declare const RouteDescriptorSchema: z.ZodObject<{
14
+ id: z.ZodString;
15
+ method: z.ZodEnum<{
16
+ GET: "GET";
17
+ POST: "POST";
18
+ PUT: "PUT";
19
+ PATCH: "PATCH";
20
+ DELETE: "DELETE";
21
+ }>;
22
+ path: z.ZodString;
23
+ role: z.ZodOptional<z.ZodEnum<{
24
+ member: "member";
25
+ admin: "admin";
26
+ }>>;
27
+ exposure: z.ZodOptional<z.ZodEnum<{
28
+ org: "org";
29
+ public: "public";
30
+ }>>;
31
+ bodyLimitKb: z.ZodOptional<z.ZodNumber>;
32
+ requestSchema: z.ZodOptional<z.ZodLazy<z.ZodType<import("./json-schema.ts").JsonSchemaSubset, unknown, z.core.$ZodTypeInternals<import("./json-schema.ts").JsonSchemaSubset, unknown>>>>;
33
+ }, z.core.$strip>;
34
+ export declare const routeFamily: {
35
+ family: string;
36
+ versions: number[];
37
+ schema: (v: number) => z.ZodType;
38
+ };
@@ -0,0 +1,37 @@
1
+ import { z } from 'zod';
2
+ import { JsonSchemaSubsetSchema, validateInputSchema } from "./json-schema.js";
3
+ export const ROUTE_SCHEMA_VERSION = 1;
4
+ export const RouteDescriptorSchema = z
5
+ .object({
6
+ id: z.string().min(1),
7
+ method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
8
+ path: z
9
+ .string()
10
+ .regex(/^\/[A-Za-z0-9/_:.-]*$/, 'path must start with / and use :param segments'),
11
+ role: z.enum(['member', 'admin']).optional(),
12
+ exposure: z.enum(['org', 'public']).optional(),
13
+ bodyLimitKb: z.number().int().positive().optional(),
14
+ requestSchema: JsonSchemaSubsetSchema.optional(),
15
+ })
16
+ .superRefine((descriptor, ctx) => {
17
+ if (descriptor.requestSchema === undefined) {
18
+ return;
19
+ }
20
+ for (const violation of validateInputSchema(descriptor.requestSchema)) {
21
+ ctx.addIssue({
22
+ code: 'custom',
23
+ path: ['requestSchema', violation.path],
24
+ message: `${violation.code}: ${violation.message}`,
25
+ });
26
+ }
27
+ });
28
+ export const routeFamily = {
29
+ family: 'route',
30
+ versions: [ROUTE_SCHEMA_VERSION],
31
+ schema: (v) => {
32
+ if (v !== ROUTE_SCHEMA_VERSION) {
33
+ throw new Error(`route descriptor schema version ${v} is not supported`);
34
+ }
35
+ return RouteDescriptorSchema;
36
+ },
37
+ };
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ import type { L10n } from '../manifest/l10n.ts';
3
+ export declare const SOURCE_KIND_SCHEMA_VERSION = 1;
4
+ export interface SourceKindDescriptor {
5
+ id: string;
6
+ title: L10n;
7
+ connection?: string;
8
+ supportsRootMount?: boolean;
9
+ supportsSearch?: boolean;
10
+ rootTitle?: string;
11
+ }
12
+ export declare const SourceKindDescriptorSchema: z.ZodObject<{
13
+ id: z.ZodString;
14
+ title: z.ZodUnion<readonly [z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>;
15
+ connection: z.ZodOptional<z.ZodString>;
16
+ supportsRootMount: z.ZodOptional<z.ZodBoolean>;
17
+ supportsSearch: z.ZodOptional<z.ZodBoolean>;
18
+ rootTitle: z.ZodOptional<z.ZodString>;
19
+ }, z.core.$strip>;
20
+ export declare const sourceKindFamily: {
21
+ family: string;
22
+ versions: number[];
23
+ schema: (v: number) => z.ZodType;
24
+ };
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ import { L10nSchema } from "../manifest/l10n.js";
3
+ export const SOURCE_KIND_SCHEMA_VERSION = 1;
4
+ export const SourceKindDescriptorSchema = z.object({
5
+ id: z.string().min(1),
6
+ title: L10nSchema,
7
+ connection: z.string().min(1).optional(),
8
+ supportsRootMount: z.boolean().optional(),
9
+ supportsSearch: z.boolean().optional(),
10
+ rootTitle: z.string().min(1).optional(),
11
+ });
12
+ export const sourceKindFamily = {
13
+ family: 'source-kind',
14
+ versions: [SOURCE_KIND_SCHEMA_VERSION],
15
+ schema: (v) => {
16
+ if (v !== SOURCE_KIND_SCHEMA_VERSION) {
17
+ throw new Error(`source-kind descriptor schema version ${v} is not supported`);
18
+ }
19
+ return SourceKindDescriptorSchema;
20
+ },
21
+ };