@seamward/setup-mcp 0.1.0-alpha.9

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,931 @@
1
+ import * as z from "zod/v4";
2
+ export const setupMcpSchemaVersion = "seamward.setup-mcp/4";
3
+ export const fingerprintSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
4
+ export const setupMcpErrorCodes = [
5
+ "plan_not_found",
6
+ "legacy_plan_requires_replan",
7
+ "confirmation_required",
8
+ "no_matching_actions",
9
+ "invalid_input",
10
+ "scan_limit_exceeded",
11
+ "generated_file_conflict",
12
+ "apply_in_progress",
13
+ "setup_preview_stale",
14
+ "idempotency_conflict",
15
+ "verification_failed",
16
+ "setup_state_conflict",
17
+ "stale_setup_lock",
18
+ "configuration_required",
19
+ "contract_preview_expired",
20
+ "contract_activation_conflict",
21
+ "authentication_required",
22
+ "insufficient_scope",
23
+ "integration_scope_mismatch",
24
+ "integration_mapping_required",
25
+ "contract_version_conflict",
26
+ "source_verification_required",
27
+ "not_found",
28
+ "remote_conflict",
29
+ "rate_limited",
30
+ "service_unavailable",
31
+ "remote_request_failed",
32
+ "remote_response_invalid",
33
+ "plan_conflict",
34
+ "internal_error",
35
+ ];
36
+ export const setupMcpErrorCodeSchema = z.enum(setupMcpErrorCodes);
37
+ export const setupMcpErrorRecovery = {
38
+ plan_not_found: {
39
+ retryable: false,
40
+ recovery: "Run prepare_setup to create a current setup plan.",
41
+ },
42
+ legacy_plan_requires_replan: {
43
+ retryable: false,
44
+ recovery: "Run prepare_setup and review the replacement plan.",
45
+ },
46
+ confirmation_required: {
47
+ retryable: false,
48
+ recovery: "Approve the requested trust boundary before applying it.",
49
+ },
50
+ no_matching_actions: {
51
+ retryable: false,
52
+ recovery: "Run prepare_setup and choose one of the proposed operations.",
53
+ },
54
+ invalid_input: {
55
+ retryable: false,
56
+ recovery: "Correct the request to match the published tool schema.",
57
+ },
58
+ scan_limit_exceeded: {
59
+ retryable: false,
60
+ recovery: "Narrow the configured service root, then run prepare_setup again.",
61
+ },
62
+ generated_file_conflict: {
63
+ retryable: false,
64
+ recovery: "Review the changed generated file and explicitly replace or preserve it before preparing again.",
65
+ },
66
+ apply_in_progress: {
67
+ retryable: true,
68
+ recovery: "Wait for the active local apply to finish, then retry.",
69
+ },
70
+ setup_preview_stale: {
71
+ retryable: false,
72
+ recovery: "Run review_remote_setup again and approve the current Integration preview.",
73
+ },
74
+ idempotency_conflict: {
75
+ retryable: false,
76
+ recovery: "Keep the original request for that idempotency key, or review the setup again before applying a different request.",
77
+ },
78
+ verification_failed: {
79
+ retryable: false,
80
+ recovery: "Review the verification failure, correct the source or project checks, then prepare and apply again.",
81
+ },
82
+ setup_state_conflict: {
83
+ retryable: false,
84
+ recovery: "Run check_setup_status, then prepare and review the current state again.",
85
+ },
86
+ stale_setup_lock: {
87
+ retryable: false,
88
+ recovery: "Confirm no setup apply is running, remove only the reported stale lock, then prepare again.",
89
+ },
90
+ configuration_required: {
91
+ retryable: false,
92
+ recovery: "Run npx @seamward/setup@alpha to authorize the application environment, then restart the coding agent and review the remote setup again.",
93
+ },
94
+ contract_preview_expired: {
95
+ retryable: false,
96
+ recovery: "Run review_remote_setup again before approving a remote change.",
97
+ },
98
+ contract_activation_conflict: {
99
+ retryable: false,
100
+ recovery: "Read the current contract state and run review_remote_setup again.",
101
+ },
102
+ authentication_required: {
103
+ retryable: false,
104
+ recovery: "Run npx @seamward/setup@alpha and approve the application environment again, then restart the coding agent.",
105
+ },
106
+ insufficient_scope: {
107
+ retryable: false,
108
+ recovery: "Run npx @seamward/setup@alpha and approve the application environment again with the requested access, then restart the coding agent.",
109
+ },
110
+ integration_scope_mismatch: {
111
+ retryable: false,
112
+ recovery: "Choose the correct integration boundary and run prepare_setup again.",
113
+ },
114
+ integration_mapping_required: {
115
+ retryable: false,
116
+ recovery: "Select the matching existing Integration or adjust the proposed name and provider, then run the setup review again.",
117
+ },
118
+ contract_version_conflict: {
119
+ retryable: false,
120
+ recovery: "Choose a new immutable contract version or review the existing version.",
121
+ },
122
+ source_verification_required: {
123
+ retryable: false,
124
+ recovery: "Run apply_local_setup and resolve every source verification failure.",
125
+ },
126
+ not_found: {
127
+ retryable: false,
128
+ recovery: "Verify the workspace and integration connection, then review the setup again.",
129
+ },
130
+ remote_conflict: {
131
+ retryable: false,
132
+ recovery: "Read the current remote state and run review_remote_setup again.",
133
+ },
134
+ rate_limited: {
135
+ retryable: true,
136
+ recovery: "Wait for the reported retry interval, then repeat the same request.",
137
+ },
138
+ service_unavailable: {
139
+ retryable: true,
140
+ recovery: "Wait for Seamward service health to recover, then repeat the same request.",
141
+ },
142
+ remote_request_failed: {
143
+ retryable: false,
144
+ recovery: "Verify the request and access configuration, then review again.",
145
+ },
146
+ remote_response_invalid: {
147
+ retryable: false,
148
+ recovery: "Report the invalid service response before trying again.",
149
+ },
150
+ plan_conflict: {
151
+ retryable: false,
152
+ recovery: "Run prepare_setup and review the current plan again.",
153
+ },
154
+ internal_error: {
155
+ retryable: false,
156
+ recovery: "Inspect the local setup logs and report the failure before trying again.",
157
+ },
158
+ };
159
+ export const setupMcpErrorOutputSchema = z
160
+ .object({
161
+ schemaVersion: z.literal(setupMcpSchemaVersion),
162
+ error: z
163
+ .object({
164
+ code: setupMcpErrorCodeSchema,
165
+ retryable: z.boolean(),
166
+ message: z.string().min(1),
167
+ recovery: z.string().min(1),
168
+ })
169
+ .strict(),
170
+ })
171
+ .strict();
172
+ const envelope = (data) => z.object({ schemaVersion: z.literal(setupMcpSchemaVersion), data }).strict();
173
+ const fingerprint = fingerprintSchema;
174
+ const integrationScope = z
175
+ .object({
176
+ direction: z.enum(["inbound", "outbound"]),
177
+ protocol: z.enum(["http-api", "http-webhook", "queue", "scheduled-feed"]),
178
+ })
179
+ .strict();
180
+ const integrationGroupSummary = z
181
+ .object({
182
+ setupId: z.string().min(1),
183
+ name: z.string().min(1),
184
+ scope: integrationScope,
185
+ operationCount: z.number().int().positive(),
186
+ contractFiles: z.array(z.string()),
187
+ confidence: z.enum(["high", "review_required"]),
188
+ requiredEnvironment: z.array(z.string()).length(2).optional(),
189
+ })
190
+ .strict();
191
+ const contractArtifact = z
192
+ .object({
193
+ file: z.string(),
194
+ format: z.enum(["openapi", "json_schema"]),
195
+ operationCount: z.number().int().nonnegative().nullable(),
196
+ fingerprint,
197
+ })
198
+ .strict();
199
+ const discoveryFinding = z
200
+ .object({
201
+ id: z.string(),
202
+ file: z.string(),
203
+ line: z.number().int().positive(),
204
+ language: z.enum(["typescript", "javascript", "python", "php", "go"]),
205
+ protocol: z.enum(["http", "webhook", "queue", "scheduled_feed"]),
206
+ direction: z.enum(["inbound", "outbound"]),
207
+ kind: z.enum([
208
+ "http_client",
209
+ "http_server",
210
+ "webhook_handler",
211
+ "queue_publish",
212
+ "queue_consume",
213
+ "scheduled_feed",
214
+ ]),
215
+ confidence: z.enum(["high", "medium"]),
216
+ detector: z.string(),
217
+ fileFingerprint: fingerprint,
218
+ targetHint: z.string().optional(),
219
+ })
220
+ .strict();
221
+ const discoveryResult = z
222
+ .object({
223
+ schemaVersion: z.literal("0.2"),
224
+ repositoryFingerprint: fingerprint,
225
+ scanPolicyVersion: z.literal("seamward-scan/1"),
226
+ scannedFiles: z.number().int().nonnegative(),
227
+ skippedFiles: z.number().int().nonnegative(),
228
+ languages: z.array(z.enum(["typescript", "javascript", "python", "php", "go"])),
229
+ findings: z.array(discoveryFinding),
230
+ contracts: z.array(contractArtifact),
231
+ })
232
+ .strict();
233
+ const setupAction = z
234
+ .object({
235
+ id: z.string(),
236
+ type: z.enum([
237
+ "create_bootstrap",
238
+ "instrument_operation",
239
+ "register_contract",
240
+ ]),
241
+ mode: z.enum(["automatic", "review_required", "manual"]),
242
+ adapter: z.string(),
243
+ language: z
244
+ .enum(["typescript", "javascript", "python", "php", "go"])
245
+ .optional(),
246
+ findingId: z.string().optional(),
247
+ file: z.string().optional(),
248
+ line: z.number().int().positive().optional(),
249
+ direction: z.enum(["inbound", "outbound"]).optional(),
250
+ protocol: z.enum(["http", "webhook", "queue", "scheduled_feed"]).optional(),
251
+ operationKind: z
252
+ .enum([
253
+ "http_client",
254
+ "http_server",
255
+ "webhook_handler",
256
+ "queue_publish",
257
+ "queue_consume",
258
+ "scheduled_feed",
259
+ ])
260
+ .optional(),
261
+ targetHint: z.string().optional(),
262
+ confidence: z.enum(["high", "medium"]).optional(),
263
+ contract: contractArtifact.optional(),
264
+ integrationScope: integrationScope.optional(),
265
+ })
266
+ .strict();
267
+ const setupPlan = z
268
+ .object({
269
+ schemaVersion: z.literal("0.2"),
270
+ setupId: z.string().min(1).optional(),
271
+ analysisFingerprint: fingerprint,
272
+ projectName: z.string(),
273
+ integrationScope: integrationScope.nullable(),
274
+ excludedIntegrationScopes: z.array(integrationScope),
275
+ unassignedContracts: z.array(contractArtifact),
276
+ connectionKeyEnvironment: z.string(),
277
+ runtimeTarget: z.enum(["node-esm", "node-commonjs", "unknown"]),
278
+ packageManager: z.enum(["npm", "pnpm", "yarn", "bun"]).nullable(),
279
+ requiredEnvironment: z.tuple([z.string(), z.string()]),
280
+ install: z
281
+ .object({
282
+ package: z.literal("@seamward/collector"),
283
+ command: z.string(),
284
+ })
285
+ .strict()
286
+ .nullable(),
287
+ discovery: discoveryResult,
288
+ actions: z.array(setupAction),
289
+ generatedFiles: z.array(z
290
+ .object({
291
+ path: z.string(),
292
+ template: z.enum(["node_collector", "node_collector_v2"]),
293
+ })
294
+ .strict()),
295
+ fingerprint,
296
+ })
297
+ .strict();
298
+ const applyResult = z
299
+ .object({
300
+ applied: z.boolean(),
301
+ fingerprint,
302
+ files: z.array(z.string()),
303
+ })
304
+ .strict();
305
+ const contractStatus = z
306
+ .object({
307
+ integrationId: z.string(),
308
+ activeContractVersionId: z.string().nullable(),
309
+ contracts: z.array(z
310
+ .object({
311
+ id: z.string(),
312
+ declaredVersion: z.string(),
313
+ lifecycleStatus: z.enum(["draft", "active", "superseded"]),
314
+ })
315
+ .strict()),
316
+ })
317
+ .strict();
318
+ const actionEvidence = z
319
+ .object({
320
+ actionId: z.string(),
321
+ actionType: z.enum([
322
+ "create_bootstrap",
323
+ "instrument_operation",
324
+ "register_contract",
325
+ ]),
326
+ status: z.enum([
327
+ "pending",
328
+ "source_verified",
329
+ "attested_only",
330
+ "stale",
331
+ "missing",
332
+ "registered",
333
+ ]),
334
+ evidenceFingerprint: fingerprint.optional(),
335
+ recordedAt: z.string().optional(),
336
+ })
337
+ .strict();
338
+ const remoteLifecycle = z
339
+ .object({
340
+ activation: z
341
+ .object({ contractVersionId: z.string(), recordedAt: z.string() })
342
+ .strict()
343
+ .optional(),
344
+ firstObservation: z
345
+ .object({
346
+ integrationId: z.string(),
347
+ observationId: z.string(),
348
+ receivedAt: z.string(),
349
+ recordedAt: z.string(),
350
+ })
351
+ .strict()
352
+ .optional(),
353
+ })
354
+ .strict();
355
+ export const contractBindingSchema = z
356
+ .object({
357
+ method: z.string().min(1).max(16).optional(),
358
+ routeTemplate: z.string().min(1).max(512),
359
+ eventType: z.string().min(1).max(200).optional(),
360
+ payloadLocation: z.enum(["request", "response", "message"]),
361
+ statusSelector: z.string().min(1).max(64).optional(),
362
+ })
363
+ .strict();
364
+ export const setupMcpInputSchemas = {
365
+ prepare_setup: z
366
+ .object({
367
+ direction: z.enum(["inbound", "outbound"]).optional(),
368
+ protocol: z
369
+ .enum(["http-api", "http-webhook", "queue", "scheduled-feed"])
370
+ .optional(),
371
+ contractFiles: z.array(z.string().min(1).max(512)).max(20).default([]),
372
+ includeSetupIds: z.array(z.string().min(1).max(63)).max(50).default([]),
373
+ excludeSetupIds: z.array(z.string().min(1).max(63)).max(50).default([]),
374
+ })
375
+ .strict()
376
+ .refine((value) => (value.direction === undefined) === (value.protocol === undefined), { message: "Direction and protocol must be selected together" })
377
+ .refine((value) => value.includeSetupIds.every((setupId) => !value.excludeSetupIds.includes(setupId)), { message: "A setup cannot be both included and excluded" }),
378
+ apply_local_setup: z.object({}).strict(),
379
+ review_remote_setup: z
380
+ .object({
381
+ declaredVersion: z.string().min(1).max(128).optional(),
382
+ contractFile: z.string().min(1).max(512).optional(),
383
+ integrationProposals: z
384
+ .array(z
385
+ .object({
386
+ setupId: z.string().min(1).max(128),
387
+ name: z.string().trim().min(1).max(120),
388
+ provider: z.string().trim().min(1).max(120),
389
+ preferredIntegrationId: z
390
+ .string()
391
+ .regex(/^int_[A-Za-z0-9_-]+$/)
392
+ .optional(),
393
+ })
394
+ .strict())
395
+ .max(20)
396
+ .default([]),
397
+ integrationMappings: z
398
+ .array(z
399
+ .object({
400
+ setupId: z.string().min(1).max(63),
401
+ integrationId: z.string().min(1).max(200),
402
+ })
403
+ .strict())
404
+ .max(50)
405
+ .default([]),
406
+ })
407
+ .strict(),
408
+ connect_remote_setup: z.object({}).strict(),
409
+ check_setup_status: z.object({}).strict(),
410
+ analyze_repository: z.object({}).strict(),
411
+ plan_setup: z
412
+ .object({
413
+ direction: z.enum(["inbound", "outbound"]),
414
+ protocol: z.enum(["http-api", "http-webhook", "queue", "scheduled-feed"]),
415
+ contractFiles: z.array(z.string().min(1).max(512)).max(20).default([]),
416
+ })
417
+ .strict(),
418
+ apply_generated_setup: z
419
+ .object({
420
+ planFingerprint: fingerprintSchema,
421
+ confirmation: z.literal("write_generated_setup"),
422
+ })
423
+ .strict(),
424
+ replace_generated_setup: z
425
+ .object({
426
+ previousPlanFingerprint: fingerprintSchema,
427
+ planFingerprint: fingerprintSchema,
428
+ confirmation: z.literal("replace_generated_setup"),
429
+ })
430
+ .strict(),
431
+ record_setup_evidence: z
432
+ .object({
433
+ planFingerprint: fingerprintSchema,
434
+ expectedStateFingerprint: fingerprintSchema,
435
+ implementationFiles: z.array(z.string().min(1).max(512)).min(1).max(100),
436
+ note: z.string().min(1).max(256).optional(),
437
+ confirmation: z.literal("record_source_evidence"),
438
+ })
439
+ .strict(),
440
+ verify_setup: z.object({ planFingerprint: fingerprintSchema }).strict(),
441
+ preview_contract_registration: z
442
+ .object({
443
+ planFingerprint: fingerprintSchema,
444
+ file: z.string().min(1).max(512).optional(),
445
+ declaredVersion: z.string().min(1).max(128),
446
+ includeExamples: z.boolean().default(false),
447
+ jsonSchemaBinding: contractBindingSchema.optional(),
448
+ })
449
+ .strict(),
450
+ register_contract: z
451
+ .object({
452
+ approvalFingerprint: fingerprintSchema,
453
+ confirmation: z.literal("register_contract"),
454
+ })
455
+ .strict(),
456
+ read_contract_status: z
457
+ .object({ planFingerprint: fingerprintSchema })
458
+ .strict(),
459
+ preview_contract_activation: z
460
+ .object({
461
+ planFingerprint: fingerprintSchema,
462
+ contractVersionId: z.string().min(1).max(128),
463
+ reason: z.enum(["promote", "rollback"]),
464
+ })
465
+ .strict(),
466
+ activate_contract: z
467
+ .object({
468
+ approvalFingerprint: fingerprintSchema,
469
+ confirmation: z.literal("activate_contract"),
470
+ })
471
+ .strict(),
472
+ check_first_observation: z
473
+ .object({ planFingerprint: fingerprintSchema })
474
+ .strict(),
475
+ };
476
+ export const setupMcpOutputSchemas = {
477
+ prepare_setup: envelope(z.discriminatedUnion("status", [
478
+ z
479
+ .object({
480
+ status: z.literal("ready"),
481
+ summary: z.string(),
482
+ scope: integrationScope.optional(),
483
+ groups: z.array(integrationGroupSummary).min(1).optional(),
484
+ removedGroups: z
485
+ .array(z
486
+ .object({
487
+ setupId: z.string(),
488
+ files: z.array(z.string()),
489
+ remoteAction: z.literal("left_active"),
490
+ })
491
+ .strict())
492
+ .optional(),
493
+ proposedChanges: z.array(z.union([
494
+ z
495
+ .object({
496
+ file: z.string(),
497
+ description: z.string(),
498
+ kind: z.literal("source"),
499
+ operationLabel: z.string().min(1),
500
+ line: z.number().int().positive(),
501
+ direction: z.enum(["inbound", "outbound"]),
502
+ operationKind: z.enum([
503
+ "http_client",
504
+ "http_server",
505
+ "webhook_handler",
506
+ "queue_publish",
507
+ "queue_consume",
508
+ "scheduled_feed",
509
+ ]),
510
+ adapter: z.string().min(1),
511
+ })
512
+ .strict(),
513
+ z
514
+ .object({
515
+ file: z.string(),
516
+ description: z.string(),
517
+ kind: z.enum([
518
+ "generated",
519
+ "dependency",
520
+ "contract",
521
+ "removal",
522
+ ]),
523
+ })
524
+ .strict(),
525
+ ])),
526
+ })
527
+ .strict(),
528
+ z
529
+ .object({
530
+ status: z.literal("needs_input"),
531
+ summary: z.string(),
532
+ choices: z.array(integrationScope),
533
+ contractChoices: z.array(z.string()),
534
+ })
535
+ .strict(),
536
+ z
537
+ .object({
538
+ status: z.literal("manual_required"),
539
+ summary: z.string(),
540
+ reasons: z.array(z.string()),
541
+ })
542
+ .strict(),
543
+ ])),
544
+ apply_local_setup: envelope(z.discriminatedUnion("status", [
545
+ z
546
+ .object({
547
+ status: z.literal("verified"),
548
+ summary: z.string(),
549
+ files: z.array(z.string()),
550
+ groups: z
551
+ .array(z
552
+ .object({
553
+ setupId: z.string(),
554
+ status: z.literal("verified"),
555
+ files: z.array(z.string()),
556
+ })
557
+ .strict())
558
+ .optional(),
559
+ retiredGroups: z
560
+ .array(z
561
+ .object({
562
+ setupId: z.string(),
563
+ files: z.array(z.string()),
564
+ remoteAction: z.literal("left_active"),
565
+ })
566
+ .strict())
567
+ .optional(),
568
+ localSetupComplete: z.literal(true),
569
+ })
570
+ .strict(),
571
+ z
572
+ .object({
573
+ status: z.literal("manual_required"),
574
+ summary: z.string(),
575
+ reasons: z.array(z.string()),
576
+ localSetupComplete: z.literal(false),
577
+ })
578
+ .strict(),
579
+ ])),
580
+ review_remote_setup: envelope(z.discriminatedUnion("status", [
581
+ z
582
+ .object({
583
+ status: z.literal("ready"),
584
+ summary: z.string(),
585
+ contractFile: z.string().optional(),
586
+ declaredVersion: z.string().optional(),
587
+ effects: z.array(z.string()),
588
+ groups: z
589
+ .array(z
590
+ .object({
591
+ setupId: z.string(),
592
+ integrationId: z.string(),
593
+ name: z.string(),
594
+ action: z.enum(["create", "reuse"]).optional(),
595
+ provider: z.string().optional(),
596
+ direction: z.enum(["inbound", "outbound"]).optional(),
597
+ protocol: z
598
+ .enum([
599
+ "http-api",
600
+ "http-webhook",
601
+ "queue",
602
+ "scheduled-feed",
603
+ ])
604
+ .optional(),
605
+ contractFile: z.string().optional(),
606
+ declaredVersion: z.string().optional(),
607
+ effects: z.array(z.string()),
608
+ })
609
+ .strict())
610
+ .optional(),
611
+ })
612
+ .strict(),
613
+ z
614
+ .object({
615
+ status: z.literal("not_applicable"),
616
+ summary: z.string(),
617
+ })
618
+ .strict(),
619
+ z
620
+ .object({
621
+ status: z.literal("blocked"),
622
+ summary: z.string(),
623
+ blockers: z.array(z.string()),
624
+ })
625
+ .strict(),
626
+ z
627
+ .object({
628
+ status: z.literal("needs_input"),
629
+ summary: z.string(),
630
+ contractChoices: z.array(z.string()).optional(),
631
+ integrationChoices: z
632
+ .array(z
633
+ .object({
634
+ setupId: z.string(),
635
+ name: z.string(),
636
+ candidates: z.array(z
637
+ .object({
638
+ integrationId: z.string(),
639
+ name: z.string(),
640
+ provider: z.string(),
641
+ direction: z.enum(["inbound", "outbound"]),
642
+ protocol: z.enum([
643
+ "http-api",
644
+ "http-webhook",
645
+ "queue",
646
+ "scheduled-feed",
647
+ ]),
648
+ })
649
+ .strict()),
650
+ })
651
+ .strict())
652
+ .optional(),
653
+ })
654
+ .strict(),
655
+ ])),
656
+ connect_remote_setup: envelope(z
657
+ .object({
658
+ status: z.enum([
659
+ "connected",
660
+ "partially_connected",
661
+ "already_connected",
662
+ ]),
663
+ summary: z.string(),
664
+ contractStatus: z.enum([
665
+ "not_applicable",
666
+ "draft",
667
+ "active",
668
+ "unknown",
669
+ ]),
670
+ groups: z
671
+ .array(z
672
+ .object({
673
+ setupId: z.string(),
674
+ integrationId: z.string(),
675
+ status: z.enum([
676
+ "connected",
677
+ "partially_connected",
678
+ "already_connected",
679
+ "failed",
680
+ "not_attempted",
681
+ ]),
682
+ contractStatus: z.enum([
683
+ "not_applicable",
684
+ "draft",
685
+ "active",
686
+ "unknown",
687
+ ]),
688
+ errorCode: setupMcpErrorCodeSchema.optional(),
689
+ })
690
+ .strict())
691
+ .optional(),
692
+ })
693
+ .strict()),
694
+ check_setup_status: envelope(z
695
+ .object({
696
+ status: z.enum([
697
+ "not_prepared",
698
+ "local_changes_required",
699
+ "ready_to_connect",
700
+ "waiting_for_traffic",
701
+ "partially_connected",
702
+ "connected",
703
+ "stale",
704
+ "conflict",
705
+ ]),
706
+ summary: z.string(),
707
+ localSetupComplete: z.boolean(),
708
+ contractStatus: z.enum([
709
+ "not_applicable",
710
+ "missing",
711
+ "draft",
712
+ "active",
713
+ ]),
714
+ firstObservation: z.enum(["not_checked", "waiting", "observed"]),
715
+ groups: z
716
+ .array(z
717
+ .object({
718
+ setupId: z.string(),
719
+ status: z.enum([
720
+ "local_changes_required",
721
+ "ready_to_connect",
722
+ "waiting_for_traffic",
723
+ "connected",
724
+ "stale",
725
+ "conflict",
726
+ ]),
727
+ contractStatus: z.enum([
728
+ "not_applicable",
729
+ "missing",
730
+ "draft",
731
+ "active",
732
+ ]),
733
+ firstObservation: z.enum([
734
+ "not_checked",
735
+ "waiting",
736
+ "observed",
737
+ ]),
738
+ })
739
+ .strict())
740
+ .optional(),
741
+ })
742
+ .strict()),
743
+ analyze_repository: envelope(z
744
+ .object({
745
+ project: z
746
+ .object({
747
+ projectName: z.string(),
748
+ packageManager: z.enum(["npm", "pnpm", "yarn", "bun"]),
749
+ runtimeTarget: z.enum(["node-esm", "node-commonjs", "unknown"]),
750
+ })
751
+ .strict(),
752
+ discovery: discoveryResult,
753
+ integrationScopes: z.array(integrationScope),
754
+ privacy: z
755
+ .object({
756
+ sourceContentReturned: z.literal(false),
757
+ environmentFilesRead: z.literal(false),
758
+ absolutePathsReturned: z.literal(false),
759
+ credentialsReturned: z.literal(false),
760
+ })
761
+ .strict(),
762
+ })
763
+ .strict()),
764
+ plan_setup: envelope(z
765
+ .object({
766
+ plan: setupPlan,
767
+ applyPreview: applyResult,
768
+ })
769
+ .strict()),
770
+ apply_generated_setup: envelope(applyResult),
771
+ replace_generated_setup: envelope(applyResult),
772
+ record_setup_evidence: envelope(z
773
+ .object({
774
+ applied: z.literal(true),
775
+ planFingerprint: fingerprint,
776
+ recordedActions: z.array(z
777
+ .object({
778
+ file: z.string().nullable(),
779
+ status: z.literal("recorded"),
780
+ })
781
+ .strict()),
782
+ })
783
+ .strict()),
784
+ verify_setup: envelope(z
785
+ .object({
786
+ planFingerprint: fingerprint,
787
+ stateFingerprint: fingerprint,
788
+ sourceBackedComplete: z.boolean(),
789
+ localSetupComplete: z.boolean(),
790
+ setupComplete: z.boolean(),
791
+ blockers: z.array(z.object({ code: z.string(), file: z.string().optional() }).strict()),
792
+ artifactsValid: z.boolean(),
793
+ collectorDependency: z
794
+ .object({
795
+ present: z.boolean(),
796
+ compatible: z.boolean(),
797
+ version: z.string().nullable(),
798
+ minimumVersion: z.string(),
799
+ })
800
+ .strict(),
801
+ generatedFiles: z.array(z
802
+ .object({
803
+ file: z.string(),
804
+ present: z.boolean(),
805
+ matches: z.boolean(),
806
+ })
807
+ .strict()),
808
+ instrumentationActions: z.array(actionEvidence),
809
+ contractActions: z.array(actionEvidence),
810
+ remoteLifecycle,
811
+ })
812
+ .strict()),
813
+ preview_contract_registration: envelope(z
814
+ .object({
815
+ approvalFingerprint: fingerprint,
816
+ integrationId: z.string(),
817
+ file: z.string(),
818
+ format: z.enum(["openapi", "json_schema"]),
819
+ fingerprint,
820
+ byteSize: z.number().int().nonnegative(),
821
+ removedExampleFields: z.number().int().nonnegative(),
822
+ operationBinding: contractBindingSchema.optional(),
823
+ })
824
+ .strict()),
825
+ register_contract: envelope(z
826
+ .object({
827
+ integrationId: z.string(),
828
+ registered: z.array(z
829
+ .object({
830
+ file: z.string(),
831
+ contractVersionId: z.string(),
832
+ status: z.literal("draft"),
833
+ removedExampleFields: z.number().int().nonnegative(),
834
+ })
835
+ .strict()),
836
+ skipped: z.array(z.never()),
837
+ })
838
+ .strict()),
839
+ read_contract_status: envelope(contractStatus),
840
+ preview_contract_activation: envelope(z
841
+ .object({
842
+ planFingerprint: fingerprint,
843
+ stateFingerprint: fingerprint,
844
+ contractVersionId: z.string(),
845
+ expectedActiveContractVersionId: z.string().nullable(),
846
+ reason: z.enum(["promote", "rollback"]),
847
+ reconcile: z.boolean(),
848
+ integrationId: z.string(),
849
+ approvalFingerprint: fingerprint,
850
+ })
851
+ .strict()),
852
+ activate_contract: envelope(z.union([
853
+ z
854
+ .object({
855
+ integrationId: z.string(),
856
+ activationId: z.string(),
857
+ activeContractVersionId: z.string(),
858
+ previousActiveContractVersionId: z.string().nullable(),
859
+ revision: z.number().int().positive(),
860
+ })
861
+ .strict(),
862
+ z
863
+ .object({
864
+ integrationId: z.string(),
865
+ activeContractVersionId: z.string(),
866
+ reconciled: z.literal(true),
867
+ })
868
+ .strict(),
869
+ ])),
870
+ check_first_observation: envelope(z.discriminatedUnion("status", [
871
+ z.object({ status: z.literal("source_verification_required") }).strict(),
872
+ z.object({ status: z.literal("contract_activation_required") }).strict(),
873
+ z
874
+ .object({
875
+ status: z.literal("waiting"),
876
+ integrationId: z.string(),
877
+ checkedFrom: z.string(),
878
+ })
879
+ .strict(),
880
+ z
881
+ .object({
882
+ status: z.literal("observed"),
883
+ integrationId: z.string(),
884
+ observation: z
885
+ .object({ id: z.string(), receivedAt: z.string() })
886
+ .strict(),
887
+ scope: z.literal("integration_connection"),
888
+ })
889
+ .strict(),
890
+ ])),
891
+ };
892
+ function tool(name, title, description, options) {
893
+ return {
894
+ name,
895
+ title,
896
+ description,
897
+ inputSchema: setupMcpInputSchemas[name],
898
+ outputSchema: setupMcpOutputSchemas[name],
899
+ ...options,
900
+ };
901
+ }
902
+ export const setupMcpToolDefinitions = [
903
+ tool("prepare_setup", "Prepare Seamward setup", "Analyze this service and present one plain-language setup proposal. If the repository is ambiguous, return readable choices without guessing.", { readOnly: true, destructive: false, idempotent: true, openWorld: false }),
904
+ tool("apply_local_setup", "Apply local Seamward setup", "Apply the reviewed local setup as one operation: install the collector, write plan-owned files, instrument supported source boundaries, run project verification, record evidence, and roll back on failure.", { readOnly: false, destructive: true, idempotent: true, openWorld: true }),
905
+ tool("review_remote_setup", "Review remote Seamward connection", "Read current contract state and present the exact remote effects for one approval. This tool does not change remote state.", { readOnly: true, destructive: false, idempotent: true, openWorld: true }),
906
+ tool("connect_remote_setup", "Connect Seamward remotely", "Connect the reviewed contract as one retry-safe operation. Register and activate a new version when required, or link an exact already-active version to the reviewed local setup without a remote write.", { readOnly: false, destructive: true, idempotent: true, openWorld: true }),
907
+ tool("check_setup_status", "Check Seamward setup status", "Read local verification, active contract state, and the first accepted observation without changing local or remote state.", { readOnly: true, destructive: false, idempotent: true, openWorld: true }),
908
+ ];
909
+ export const legacySetupMcpToolDefinitions = [
910
+ tool("analyze_repository", "Analyze repository", "Scan the configured service root locally and return redacted integration boundaries. Source contents and environment files are never returned.", { readOnly: true, destructive: false, idempotent: true, openWorld: false }),
911
+ tool("plan_setup", "Plan Seamward setup", "Build one deterministic, scope-specific setup plan without writing files.", { readOnly: true, destructive: false, idempotent: true, openWorld: false }),
912
+ tool("apply_generated_setup", "Apply generated setup", "Write only a first reviewed setup plan and generated collector bootstrap after exact confirmation.", { readOnly: false, destructive: false, idempotent: true, openWorld: false }),
913
+ tool("replace_generated_setup", "Replace generated setup", "Replace an unchanged generated plan with a reviewed replan, then reset prior evidence. Reviewer-modified generated files are never overwritten.", { readOnly: false, destructive: true, idempotent: false, openWorld: false }),
914
+ tool("record_setup_evidence", "Record source-backed setup evidence", "Verify planned adapters in local implementation files and replace their evidence record after an optimistic state check.", { readOnly: false, destructive: true, idempotent: false, openWorld: false }),
915
+ tool("verify_setup", "Verify Seamward setup", "Verify local artifacts, current source evidence, contract lifecycle, and first-observation state without writing.", { readOnly: true, destructive: false, idempotent: true, openWorld: false }),
916
+ tool("preview_contract_registration", "Preview contract registration", "Validate one planned contract locally and return an approval fingerprint without a network request.", { readOnly: true, destructive: false, idempotent: true, openWorld: false }),
917
+ tool("register_contract", "Register contract", "Register the exact locally previewed contract as an immutable draft after confirmation.", { readOnly: false, destructive: false, idempotent: false, openWorld: true }),
918
+ tool("read_contract_status", "Read contract status", "List contract versions and the active version for this Integration.", { readOnly: true, destructive: false, idempotent: true, openWorld: true }),
919
+ tool("preview_contract_activation", "Preview contract activation", "Require source-backed evidence, read the active contract, and bind a plan-owned promotion or rollback to an approval fingerprint.", { readOnly: true, destructive: false, idempotent: true, openWorld: true }),
920
+ tool("activate_contract", "Activate contract", "Activate the exact previewed contract version after confirmation and optimistic-concurrency validation.", { readOnly: false, destructive: true, idempotent: false, openWorld: true }),
921
+ tool("check_first_observation", "Check first observation", "Read the redacted Observation API after source verification and persist the first accepted observation.", { readOnly: false, destructive: false, idempotent: true, openWorld: true }),
922
+ ];
923
+ export function toolAnnotations(readOnly, destructive, idempotent, openWorld) {
924
+ return {
925
+ readOnlyHint: readOnly,
926
+ destructiveHint: destructive,
927
+ idempotentHint: idempotent,
928
+ openWorldHint: openWorld,
929
+ };
930
+ }
931
+ //# sourceMappingURL=contracts.js.map