marona 2.8.0 → 2.10.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.
@@ -0,0 +1,679 @@
1
+ import { McpServer, createMcpHandler, fromJsonSchema, LATEST_PROTOCOL_VERSION } from "@modelcontextprotocol/server";
2
+ export const packageVersion = "2.10.0";
3
+ export const protocolVersion = LATEST_PROTOCOL_VERSION;
4
+ export const defaultPresentationHint = "display_as_provided";
5
+ export const defaultSuccessContext = "Use content as the primary user-facing result. Use data/items only for structured details.";
6
+ export const defaultFailureContext = "This tool failed. Show content/message as the user-facing failure and use error for diagnostics.";
7
+ export const standardOutputRequiredFields = [
8
+ "status",
9
+ "success",
10
+ "message",
11
+ "content",
12
+ "content_type",
13
+ "presentation_hint",
14
+ "context",
15
+ ];
16
+ export function success(message, options = {}) {
17
+ return compactResult({
18
+ ...(options.extra ?? {}),
19
+ status: options.status ?? "completed",
20
+ success: true,
21
+ message,
22
+ content: options.content ?? message,
23
+ content_type: options.contentType ?? options.content_type ?? "text",
24
+ presentation_hint: options.presentationHint ?? options.presentation_hint ?? defaultPresentationHint,
25
+ context: options.context ?? defaultSuccessContext,
26
+ data: options.data,
27
+ items: options.items,
28
+ count: options.count,
29
+ artifacts: options.artifacts,
30
+ job: options.job,
31
+ });
32
+ }
33
+ export function failure(message, options = {}) {
34
+ const errorCode = options.errorCode ?? options.error_code ?? "tool_failed";
35
+ const errorMessage = options.errorMessage ?? options.error_message ?? message;
36
+ return compactResult({
37
+ ...(options.extra ?? {}),
38
+ status: options.status ?? "failed",
39
+ success: false,
40
+ message,
41
+ content: options.content ?? message,
42
+ content_type: options.contentType ?? options.content_type ?? "error",
43
+ presentation_hint: options.presentationHint ?? options.presentation_hint ?? defaultPresentationHint,
44
+ context: options.context ?? defaultFailureContext,
45
+ data: options.data,
46
+ items: options.items,
47
+ count: options.count,
48
+ artifacts: options.artifacts,
49
+ job: options.job,
50
+ error: {
51
+ code: errorCode,
52
+ message: errorMessage,
53
+ },
54
+ });
55
+ }
56
+ export function contractFailure(toolName, detail) {
57
+ return failure("The tool returned an invalid Marona result.", {
58
+ errorCode: "contract_error",
59
+ errorMessage: `${toolName}: ${detail}`,
60
+ });
61
+ }
62
+ export function ensureMaronaResult(toolName, value) {
63
+ if (!isPlainObject(value)) {
64
+ return contractFailure(toolName, "tool result must be an object");
65
+ }
66
+ const missing = standardOutputRequiredFields.filter((field) => !(field in value));
67
+ if (missing.length > 0) {
68
+ return contractFailure(toolName, `missing result field(s): ${missing.join(", ")}`);
69
+ }
70
+ return value;
71
+ }
72
+ export function standardOutputSchema(schema) {
73
+ const base = deepClone(STANDARD_OUTPUT_SCHEMA);
74
+ if (!schema) {
75
+ return base;
76
+ }
77
+ const merged = deepClone(schema);
78
+ const mergedProperties = {
79
+ ...asRecord(base.properties),
80
+ ...asRecord(merged.properties),
81
+ };
82
+ const required = uniqueStrings([
83
+ ...standardOutputRequiredFields,
84
+ ...arrayOfStrings(merged.required),
85
+ ]);
86
+ return {
87
+ ...merged,
88
+ type: merged.type ?? "object",
89
+ properties: mergedProperties,
90
+ required,
91
+ additionalProperties: merged.additionalProperties ?? true,
92
+ };
93
+ }
94
+ export function standardAttachmentSchema() {
95
+ return deepClone(STANDARD_ATTACHMENT_SCHEMA);
96
+ }
97
+ export function standardAttachmentsProperty() {
98
+ return deepClone(STANDARD_ATTACHMENTS_PROPERTY);
99
+ }
100
+ export class PermissionSpec {
101
+ key;
102
+ name;
103
+ description;
104
+ required;
105
+ scope;
106
+ constructor(input) {
107
+ if (!/^[a-zA-Z0-9_.:-]+$/.test(input.key)) {
108
+ throw new Error("Permission key must contain only letters, numbers, underscore, dot, colon, or hyphen.");
109
+ }
110
+ this.key = input.key;
111
+ this.name = input.name;
112
+ this.description = cleanString(input.description);
113
+ this.required = input.required ?? true;
114
+ this.scope = cleanString(input.scope);
115
+ }
116
+ toJSON() {
117
+ return this.toJson();
118
+ }
119
+ toJson() {
120
+ return omitEmpty({
121
+ key: this.key,
122
+ name: this.name,
123
+ description: this.description,
124
+ required: this.required,
125
+ scope: this.scope,
126
+ });
127
+ }
128
+ }
129
+ export class AuthConfig {
130
+ isAuthRequired;
131
+ authType;
132
+ authInstructions;
133
+ connectionSchema;
134
+ constructor(input = {}) {
135
+ this.isAuthRequired = input.isAuthRequired ?? input.is_auth_required ?? false;
136
+ this.authType = input.authType ?? input.auth_type ?? "none";
137
+ this.authInstructions = cleanString(input.authInstructions ?? input.auth_instructions);
138
+ this.connectionSchema = input.connectionSchema ?? input.connection_schema;
139
+ }
140
+ toJSON() {
141
+ return this.toJson();
142
+ }
143
+ toJson() {
144
+ return omitEmpty({
145
+ is_auth_required: this.isAuthRequired,
146
+ auth_type: this.authType,
147
+ auth_instructions: this.authInstructions,
148
+ connection_schema: this.connectionSchema,
149
+ });
150
+ }
151
+ }
152
+ export class ToolSpec {
153
+ name;
154
+ title;
155
+ description;
156
+ inputSchema;
157
+ outputSchema;
158
+ isDestructive;
159
+ requiresUserConfirmation;
160
+ constructor(input) {
161
+ this.name = input.name;
162
+ this.title = cleanString(input.title);
163
+ this.description = input.description;
164
+ this.inputSchema = input.inputSchema ?? input.input_schema ?? {};
165
+ this.outputSchema = standardOutputSchema(input.outputSchema ?? input.output_schema);
166
+ this.isDestructive = input.isDestructive ?? input.is_destructive ?? false;
167
+ this.requiresUserConfirmation = input.requiresUserConfirmation ?? input.requires_user_confirmation ?? false;
168
+ }
169
+ descriptor() {
170
+ return {
171
+ name: this.name,
172
+ title: this.title ?? titleFromName(this.name),
173
+ description: this.description,
174
+ input_schema: this.inputSchema,
175
+ output_schema: standardOutputSchema(this.outputSchema),
176
+ is_destructive: this.isDestructive,
177
+ requires_user_confirmation: this.requiresUserConfirmation,
178
+ };
179
+ }
180
+ mcpDescriptor() {
181
+ return {
182
+ name: this.name,
183
+ title: this.title ?? titleFromName(this.name),
184
+ description: this.description,
185
+ inputSchema: this.inputSchema,
186
+ annotations: {
187
+ readOnlyHint: !this.isDestructive,
188
+ destructiveHint: this.isDestructive,
189
+ openWorldHint: true,
190
+ },
191
+ };
192
+ }
193
+ validate() {
194
+ return validateToolSpec(this);
195
+ }
196
+ toJSON() {
197
+ return this.descriptor();
198
+ }
199
+ }
200
+ export class AgentApp {
201
+ name;
202
+ slug;
203
+ serverName;
204
+ description;
205
+ category;
206
+ version;
207
+ tagline;
208
+ iconUrl;
209
+ websiteUrl;
210
+ privacyUrl;
211
+ termsUrl;
212
+ supportUrl;
213
+ executionModes;
214
+ executionTargets;
215
+ connectionConfig;
216
+ auth;
217
+ toolSpecs;
218
+ permissionSpecs;
219
+ handlers = new Map();
220
+ extensions = [];
221
+ /** Register a callable tool and its platform metadata together. */
222
+ tool(spec, handler) {
223
+ if (this.handlers.has(spec.name) || this.toolSpecs.some(t => t.name === spec.name))
224
+ throw new Error(`Tool ${spec.name} is already registered`);
225
+ const tool = this.addTool(spec);
226
+ this.handlers.set(tool.name, handler);
227
+ return this;
228
+ }
229
+ /** Configure native MCP resources, prompts, UI resources, and advanced capabilities. */
230
+ configure(callback) {
231
+ this.extensions.push(callback);
232
+ return this;
233
+ }
234
+ createMcpServer() {
235
+ const server = new McpServer({ name: this.serverName, version: this.version });
236
+ for (const spec of this.toolSpecs) {
237
+ const handler = this.handlers.get(spec.name);
238
+ if (!handler)
239
+ throw new Error(`Tool ${spec.name} has no handler`);
240
+ server.registerTool(spec.name, {
241
+ title: spec.title, description: spec.description,
242
+ inputSchema: fromJsonSchema(spec.inputSchema),
243
+ outputSchema: fromJsonSchema(spec.outputSchema),
244
+ annotations: { readOnlyHint: !spec.isDestructive, destructiveHint: spec.isDestructive, openWorldHint: true },
245
+ }, async (args, context) => {
246
+ try {
247
+ const result = await handler(args, context);
248
+ return { content: [{ type: "text", text: result.content }], structuredContent: result, isError: !result.success };
249
+ }
250
+ catch {
251
+ const result = failure("Tool execution failed");
252
+ return { content: [{ type: "text", text: result.content }], structuredContent: result, isError: true };
253
+ }
254
+ });
255
+ }
256
+ for (const configure of this.extensions)
257
+ configure(server);
258
+ return server;
259
+ }
260
+ /** Fetch handler usable in Node, serverless and other Fetch-compatible runtimes. */
261
+ createHandler(options = {}) {
262
+ const mcp = createMcpHandler(() => this.createMcpServer());
263
+ const handle = async (request) => {
264
+ const url = new URL(request.url);
265
+ const hosts = options.allowedHosts ?? ["localhost", "127.0.0.1", "[::1]"];
266
+ if (!hosts.includes(url.hostname))
267
+ return new Response("Invalid Host", { status: 403 });
268
+ const origin = request.headers.get("origin");
269
+ if (origin && origin !== url.origin && !(options.allowedOrigins ?? []).includes(origin))
270
+ return new Response("Invalid Origin", { status: 403 });
271
+ if (options.apiKey !== undefined && !options.apiKey)
272
+ return new Response("Authentication is not configured", { status: 503 });
273
+ if (url.pathname === "/mcp" || url.pathname === "/mcp/") {
274
+ if (options.apiKey && request.headers.get("authorization") !== `Bearer ${options.apiKey}` && request.headers.get("x-marona-api-key") !== options.apiKey)
275
+ return new Response("Unauthorized", { status: 401 });
276
+ return mcp.fetch(request);
277
+ }
278
+ if (request.method !== "GET")
279
+ return new Response("Method not allowed", { status: 405 });
280
+ const base = (options.publicUrl ?? url.origin).replace(/\/$/, "");
281
+ if (url.pathname === "/health")
282
+ return Response.json({ status: "ok", service: this.serverName, version: this.version, mcp_sdk: "marona" });
283
+ if (url.pathname === "/manifest")
284
+ return Response.json(this.manifest({ serverUrl: `${base}/mcp`, healthCheckUrl: `${base}/health` }));
285
+ if (url.pathname === "/hub-registration")
286
+ return Response.json(this.hubRegistration({ serverUrl: `${base}/mcp`, healthCheckUrl: `${base}/health` }));
287
+ return new Response("Not found", { status: 404 });
288
+ };
289
+ return { fetch: handle, close: () => mcp.close() };
290
+ }
291
+ async run(options = {}) {
292
+ if (options.transport === "stdio") {
293
+ const { StdioServerTransport } = await import("@modelcontextprotocol/server/stdio");
294
+ const server = this.createMcpServer();
295
+ await server.connect(new StdioServerTransport());
296
+ return { close: () => server.close() };
297
+ }
298
+ const { createServer } = await import("node:http");
299
+ const { toNodeHandler } = await import("@modelcontextprotocol/node");
300
+ const handler = this.createHandler(options);
301
+ const server = createServer(toNodeHandler(handler));
302
+ await new Promise((resolve, reject) => {
303
+ server.once("error", reject);
304
+ server.listen(options.port ?? 62900, options.host ?? "127.0.0.1", () => { server.off("error", reject); resolve(); });
305
+ });
306
+ return { address: server.address(), close: async () => {
307
+ await handler.close();
308
+ await new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve()));
309
+ } };
310
+ }
311
+ constructor(input) {
312
+ this.name = input.name;
313
+ this.slug = input.slug;
314
+ this.serverName = input.serverName ?? input.server_name ?? input.slug;
315
+ this.description = input.description;
316
+ this.category = input.category;
317
+ this.version = input.version ?? "0.1.0";
318
+ this.tagline = cleanString(input.tagline);
319
+ this.iconUrl = cleanString(input.iconUrl ?? input.icon_url);
320
+ this.websiteUrl = cleanString(input.websiteUrl ?? input.website_url);
321
+ this.privacyUrl = cleanString(input.privacyUrl ?? input.privacy_url);
322
+ this.termsUrl = cleanString(input.termsUrl ?? input.terms_url);
323
+ this.supportUrl = cleanString(input.supportUrl ?? input.support_url);
324
+ this.executionModes = normalizeExecutionModes(input.executionModes ?? input.execution_modes);
325
+ this.executionTargets = normalizeExecutionTargets(input.executionTargets ?? input.execution_targets);
326
+ this.connectionConfig = input.connectionConfig ?? input.connection_config;
327
+ this.auth = new AuthConfig(input.auth);
328
+ this.toolSpecs = (input.tools ?? []).map((tool) => new ToolSpec(tool));
329
+ this.permissionSpecs = (input.permissions ?? []).map((permission) => new PermissionSpec(permission));
330
+ }
331
+ get tools() {
332
+ return [...this.toolSpecs];
333
+ }
334
+ get permissions() {
335
+ return [...this.permissionSpecs];
336
+ }
337
+ addTool(tool) {
338
+ const spec = tool instanceof ToolSpec ? tool : new ToolSpec(tool);
339
+ this.toolSpecs.push(spec);
340
+ return spec;
341
+ }
342
+ manifest(options) {
343
+ return {
344
+ name: this.serverName,
345
+ display_name: this.name,
346
+ version: this.version,
347
+ protocol_version: protocolVersion,
348
+ transport: "streamable_http",
349
+ server_url: options.serverUrl,
350
+ health_check_url: options.healthCheckUrl,
351
+ icon_url: options.iconUrl ?? this.iconUrl,
352
+ execution_modes: this.executionModes,
353
+ execution_targets: this.executionTargetsFor(options.serverUrl),
354
+ tools: this.toolSpecs.map((tool) => tool.descriptor()),
355
+ permissions: this.permissionSpecs.map((permission) => permission.toJson()),
356
+ };
357
+ }
358
+ hubRegistration(options) {
359
+ return {
360
+ name: this.name,
361
+ slug: this.slug,
362
+ tagline: this.tagline,
363
+ description: this.description,
364
+ category: this.category,
365
+ version: this.version,
366
+ icon_url: options.iconUrl ?? this.iconUrl,
367
+ website_url: this.websiteUrl,
368
+ privacy_url: this.privacyUrl,
369
+ terms_url: this.termsUrl,
370
+ support_url: this.supportUrl,
371
+ execution_modes: this.executionModes,
372
+ execution_targets: this.executionTargetsFor(options.serverUrl),
373
+ mcp_server: {
374
+ name: this.name,
375
+ server_url: options.serverUrl,
376
+ transport: "streamable_http",
377
+ protocol_version: protocolVersion,
378
+ health_check_url: options.healthCheckUrl,
379
+ connection_config: this.connectionConfig ??
380
+ defaultConnectionConfig(options.serverUrl, this.executionModes, this.executionTargetsFor(options.serverUrl)),
381
+ },
382
+ tools: this.toolSpecs.map((tool) => tool.descriptor()),
383
+ permissions: this.permissionSpecs.map((permission) => permission.toJson()),
384
+ ...this.auth.toJson(),
385
+ };
386
+ }
387
+ validate() {
388
+ const issues = [];
389
+ if (this.toolSpecs.length === 0) {
390
+ issues.push("Agent App must declare at least one tool");
391
+ }
392
+ issues.push(...validateExecutionTargets(this.executionTargets));
393
+ if (this.executionModes.some((mode) => mode === "offline" || mode === "hybrid") &&
394
+ !this.executionTargets.some((target) => (target.mode === "offline" || target.mode === "hybrid") &&
395
+ ["python_package", "wasm", "static_cache", "builtin"].includes(target.type))) {
396
+ issues.push("Offline or hybrid Agent Apps must declare a signed local execution target such as python_package, wasm, static_cache, or builtin");
397
+ }
398
+ for (const tool of this.toolSpecs) {
399
+ issues.push(...validateToolSpec(tool));
400
+ }
401
+ return issues;
402
+ }
403
+ executionTargetsFor(serverUrl) {
404
+ const targets = this.executionTargets.map((target) => ({ ...target }));
405
+ if (this.executionModes.some((mode) => mode === "online" || mode === "hybrid")) {
406
+ const hasOnline = targets.some((target) => (target.mode === "online" || target.mode === "hybrid") &&
407
+ (target.type === "remote_mcp" || target.type === "marona_hosted"));
408
+ if (!hasOnline) {
409
+ targets.unshift({
410
+ mode: "online",
411
+ type: "remote_mcp",
412
+ url: serverUrl,
413
+ transport: "streamable_http",
414
+ endpoint: "/mcp",
415
+ });
416
+ }
417
+ else {
418
+ for (const target of targets) {
419
+ if ((target.mode === "online" || target.mode === "hybrid") &&
420
+ target.type === "remote_mcp" &&
421
+ !target.url) {
422
+ target.url = serverUrl;
423
+ target.transport ??= "streamable_http";
424
+ target.endpoint ??= "/mcp";
425
+ }
426
+ }
427
+ }
428
+ }
429
+ return targets;
430
+ }
431
+ }
432
+ export function toolSpec(input) {
433
+ return new ToolSpec(input);
434
+ }
435
+ export function permissionSpec(input) {
436
+ return new PermissionSpec(input);
437
+ }
438
+ export function validateToolSpec(tool) {
439
+ const spec = tool instanceof ToolSpec ? tool : new ToolSpec(tool);
440
+ const issues = [];
441
+ const required = new Set(arrayOfStrings(spec.outputSchema.required));
442
+ const missing = standardOutputRequiredFields.filter((field) => !required.has(field));
443
+ if (missing.length > 0) {
444
+ issues.push(`Tool \`${spec.name}\` output_schema must require ${missing.join(", ")}`);
445
+ }
446
+ if (spec.inputSchema.type !== "object") {
447
+ issues.push(`Tool \`${spec.name}\` input_schema must be an object schema`);
448
+ }
449
+ return issues;
450
+ }
451
+ export function titleFromName(name) {
452
+ return name
453
+ .split("_")
454
+ .filter(Boolean)
455
+ .map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`)
456
+ .join(" ");
457
+ }
458
+ const STANDARD_OUTPUT_SCHEMA = {
459
+ type: "object",
460
+ properties: {
461
+ status: { type: "string" },
462
+ success: { type: "boolean" },
463
+ message: { type: "string" },
464
+ content: {
465
+ type: "string",
466
+ description: "Primary user-facing content the agent can display or reason over.",
467
+ },
468
+ content_type: {
469
+ type: "string",
470
+ description: "Provider-neutral semantic type for content, such as text, document, message, list, media, or search_results.",
471
+ },
472
+ presentation_hint: {
473
+ type: "string",
474
+ description: "Provider-neutral presentation hint, such as display_as_provided or summarize_if_requested.",
475
+ },
476
+ context: {
477
+ type: "string",
478
+ description: "Provider-neutral guidance for interpreting this result.",
479
+ },
480
+ data: {
481
+ type: "object",
482
+ description: "Provider-specific structured object payload. Keep provider fields inside this object.",
483
+ additionalProperties: true,
484
+ },
485
+ items: {
486
+ type: "array",
487
+ description: "Provider-specific structured list payload. Use for search/list results from any tool.",
488
+ items: { type: "object", additionalProperties: true },
489
+ },
490
+ count: {
491
+ type: "integer",
492
+ description: "Number of items represented in items when applicable.",
493
+ },
494
+ artifacts: {
495
+ type: "array",
496
+ description: "Generic artifacts produced by the tool.",
497
+ items: {
498
+ type: "object",
499
+ properties: {
500
+ type: { type: "string" },
501
+ label: { type: "string" },
502
+ mime_type: { type: "string" },
503
+ url: { type: "string" },
504
+ base64: { type: "string" },
505
+ text: { type: "string" },
506
+ external_id: { type: "string" },
507
+ filename: { type: "string" },
508
+ metadata: { type: "object", additionalProperties: true },
509
+ },
510
+ additionalProperties: true,
511
+ },
512
+ },
513
+ job: {
514
+ type: "object",
515
+ description: "Generic async job payload with provider-specific details.",
516
+ additionalProperties: true,
517
+ },
518
+ },
519
+ required: [...standardOutputRequiredFields],
520
+ additionalProperties: true,
521
+ };
522
+ const STANDARD_ATTACHMENT_SCHEMA = {
523
+ type: "object",
524
+ description: "Provider-neutral user file/artifact passed by the runtime.",
525
+ properties: {
526
+ artifact_id: {
527
+ type: "string",
528
+ description: "Runtime artifact id for this attachment, when available.",
529
+ },
530
+ filename: {
531
+ type: "string",
532
+ description: "Original or display filename.",
533
+ },
534
+ mime_type: {
535
+ type: "string",
536
+ description: "MIME type, for example application/pdf or image/png.",
537
+ },
538
+ kind: {
539
+ type: "string",
540
+ description: "Runtime artifact kind, for example document, image, audio, video, or file.",
541
+ },
542
+ url: {
543
+ type: "string",
544
+ description: "Runtime-accessible URL for the attachment, when available.",
545
+ },
546
+ file_url: {
547
+ type: "string",
548
+ description: "Runtime-accessible file URL for tools that consume file_url.",
549
+ },
550
+ content_base64: {
551
+ type: "string",
552
+ description: "Base64-encoded attachment bytes when the runtime sends inline bytes.",
553
+ },
554
+ content: {
555
+ type: "string",
556
+ description: "Inline text content when the attachment is text-like.",
557
+ },
558
+ metadata: {
559
+ type: "object",
560
+ description: "Runtime or provider-specific attachment metadata.",
561
+ additionalProperties: true,
562
+ },
563
+ },
564
+ additionalProperties: true,
565
+ };
566
+ const STANDARD_ATTACHMENTS_PROPERTY = {
567
+ type: "array",
568
+ description: "User-provided files or runtime artifacts. Declare this property on any tool that can consume uploaded files; the runtime injects the current conversation attachments automatically.",
569
+ items: STANDARD_ATTACHMENT_SCHEMA,
570
+ };
571
+ function compactResult(result) {
572
+ return omitEmpty(result);
573
+ }
574
+ function defaultConnectionConfig(serverUrl, executionModes, executionTargets) {
575
+ return {
576
+ docs_url: serverUrl.replace(/\/mcp\/?$/, "/docs"),
577
+ manifest_url: serverUrl.replace(/\/mcp\/?$/, "/manifest"),
578
+ execution_modes: executionModes,
579
+ execution_targets: executionTargets,
580
+ };
581
+ }
582
+ function normalizeExecutionModes(value) {
583
+ const raw = value?.length ? value : ["online"];
584
+ const modes = [];
585
+ for (const item of raw) {
586
+ const mode = String(item).trim().toLowerCase();
587
+ if (!["online", "offline", "hybrid"].includes(mode)) {
588
+ throw new Error("execution_modes must contain only online, offline, and hybrid");
589
+ }
590
+ if (!modes.includes(mode))
591
+ modes.push(mode);
592
+ }
593
+ return modes.length ? modes : ["online"];
594
+ }
595
+ function normalizeExecutionTargets(value) {
596
+ if (!value?.length)
597
+ return [];
598
+ return value.map((item) => {
599
+ for (const key of Object.keys(item)) {
600
+ if (isNonPortableExecutionField(key)) {
601
+ throw new Error("execution_targets must describe portable targets, not runtime-resolved local fields");
602
+ }
603
+ }
604
+ const mode = String(item.mode ?? "online").trim().toLowerCase();
605
+ const type = String(item.type ?? item.kind ?? "").trim().toLowerCase();
606
+ if (!["online", "offline", "hybrid"].includes(mode)) {
607
+ throw new Error("execution target mode must be online, offline, or hybrid");
608
+ }
609
+ if (![
610
+ "remote_mcp",
611
+ "marona_hosted",
612
+ "python_package",
613
+ "wasm",
614
+ "static_cache",
615
+ "builtin",
616
+ ].includes(type)) {
617
+ throw new Error("execution target type is not supported");
618
+ }
619
+ return { ...item, mode, type };
620
+ });
621
+ }
622
+ function validateExecutionTargets(targets) {
623
+ const issues = [];
624
+ for (const target of targets) {
625
+ if (target.type === "marona_hosted" && !(target.deployment_id || target.url)) {
626
+ issues.push("marona_hosted execution target requires deployment_id or url");
627
+ }
628
+ if (target.type === "python_package" && !(target.package || target.package_url)) {
629
+ issues.push("python_package execution target requires package or package_url");
630
+ }
631
+ if (target.type === "wasm" && !(target.url || target.package)) {
632
+ issues.push("wasm execution target requires url or package");
633
+ }
634
+ if (target.type === "static_cache" && !(target.cache_manifest_url || target.manifest_url || target.assets)) {
635
+ issues.push("static_cache execution target requires cache_manifest_url, manifest_url, or assets");
636
+ }
637
+ if (target.type === "builtin" && !target.name) {
638
+ issues.push("builtin execution target requires name");
639
+ }
640
+ }
641
+ return issues;
642
+ }
643
+ function isNonPortableExecutionField(key) {
644
+ const value = key.trim().toLowerCase();
645
+ return value.startsWith("local_") || value === "runtime_url" || value === "resolved_url";
646
+ }
647
+ function deepClone(value) {
648
+ return JSON.parse(JSON.stringify(value));
649
+ }
650
+ function omitEmpty(input) {
651
+ return Object.fromEntries(Object.entries(input).filter(([, value]) => {
652
+ if (value === undefined || value === null)
653
+ return false;
654
+ if (typeof value === "string" && value.trim() === "")
655
+ return false;
656
+ if (Array.isArray(value) && value.length === 0)
657
+ return false;
658
+ if (isPlainObject(value) && Object.keys(value).length === 0)
659
+ return false;
660
+ return true;
661
+ }));
662
+ }
663
+ function asRecord(value) {
664
+ return isPlainObject(value) ? value : {};
665
+ }
666
+ function arrayOfStrings(value) {
667
+ return Array.isArray(value) ? value.map((item) => String(item)) : [];
668
+ }
669
+ function uniqueStrings(values) {
670
+ return [...new Set(values)];
671
+ }
672
+ function cleanString(value) {
673
+ return typeof value === "string" && value.trim() ? value : undefined;
674
+ }
675
+ function isPlainObject(value) {
676
+ return typeof value === "object" && value !== null && !Array.isArray(value);
677
+ }
678
+ export { DeveloperPlatformClient } from "./platform-client.js";
679
+ //# sourceMappingURL=mcp-authoring.js.map